Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Side by Side Diff: media/formats/webm/webm_cluster_parser.cc

Issue 506683002: Remove implicit conversions from scoped_refptr to T* in media/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/formats/webm/webm_cluster_parser.h" 5 #include "media/formats/webm/webm_cluster_parser.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/sys_byteorder.h" 10 #include "base/sys_byteorder.h"
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 estimated_next_frame_duration_(kNoTimestamp()), 434 estimated_next_frame_duration_(kNoTimestamp()),
435 log_cb_(log_cb) { 435 log_cb_(log_cb) {
436 DCHECK(default_duration_ == kNoTimestamp() || 436 DCHECK(default_duration_ == kNoTimestamp() ||
437 default_duration_ > base::TimeDelta()); 437 default_duration_ > base::TimeDelta());
438 } 438 }
439 439
440 WebMClusterParser::Track::~Track() {} 440 WebMClusterParser::Track::~Track() {}
441 441
442 DecodeTimestamp WebMClusterParser::Track::GetReadyUpperBound() { 442 DecodeTimestamp WebMClusterParser::Track::GetReadyUpperBound() {
443 DCHECK(ready_buffers_.empty()); 443 DCHECK(ready_buffers_.empty());
444 if (last_added_buffer_missing_duration_) 444 if (last_added_buffer_missing_duration_.get())
445 return last_added_buffer_missing_duration_->GetDecodeTimestamp(); 445 return last_added_buffer_missing_duration_->GetDecodeTimestamp();
446 446
447 return DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max()); 447 return DecodeTimestamp::FromPresentationTime(base::TimeDelta::Max());
448 } 448 }
449 449
450 void WebMClusterParser::Track::ExtractReadyBuffers( 450 void WebMClusterParser::Track::ExtractReadyBuffers(
451 const DecodeTimestamp before_timestamp) { 451 const DecodeTimestamp before_timestamp) {
452 DCHECK(ready_buffers_.empty()); 452 DCHECK(ready_buffers_.empty());
453 DCHECK(DecodeTimestamp() <= before_timestamp); 453 DCHECK(DecodeTimestamp() <= before_timestamp);
454 DCHECK(kNoDecodeTimestamp() != before_timestamp); 454 DCHECK(kNoDecodeTimestamp() != before_timestamp);
(...skipping 27 matching lines...) Expand all
482 } 482 }
483 483
484 bool WebMClusterParser::Track::AddBuffer( 484 bool WebMClusterParser::Track::AddBuffer(
485 const scoped_refptr<StreamParserBuffer>& buffer) { 485 const scoped_refptr<StreamParserBuffer>& buffer) {
486 DVLOG(2) << "AddBuffer() : " << track_num_ 486 DVLOG(2) << "AddBuffer() : " << track_num_
487 << " ts " << buffer->timestamp().InSecondsF() 487 << " ts " << buffer->timestamp().InSecondsF()
488 << " dur " << buffer->duration().InSecondsF() 488 << " dur " << buffer->duration().InSecondsF()
489 << " kf " << buffer->IsKeyframe() 489 << " kf " << buffer->IsKeyframe()
490 << " size " << buffer->data_size(); 490 << " size " << buffer->data_size();
491 491
492 if (last_added_buffer_missing_duration_) { 492 if (last_added_buffer_missing_duration_.get()) {
493 base::TimeDelta derived_duration = 493 base::TimeDelta derived_duration =
494 buffer->timestamp() - last_added_buffer_missing_duration_->timestamp(); 494 buffer->timestamp() - last_added_buffer_missing_duration_->timestamp();
495 last_added_buffer_missing_duration_->set_duration(derived_duration); 495 last_added_buffer_missing_duration_->set_duration(derived_duration);
496 496
497 DVLOG(2) << "AddBuffer() : applied derived duration to held-back buffer : " 497 DVLOG(2) << "AddBuffer() : applied derived duration to held-back buffer : "
498 << " ts " 498 << " ts "
499 << last_added_buffer_missing_duration_->timestamp().InSecondsF() 499 << last_added_buffer_missing_duration_->timestamp().InSecondsF()
500 << " dur " 500 << " dur "
501 << last_added_buffer_missing_duration_->duration().InSecondsF() 501 << last_added_buffer_missing_duration_->duration().InSecondsF()
502 << " kf " << last_added_buffer_missing_duration_->IsKeyframe() 502 << " kf " << last_added_buffer_missing_duration_->IsKeyframe()
503 << " size " << last_added_buffer_missing_duration_->data_size(); 503 << " size " << last_added_buffer_missing_duration_->data_size();
504 scoped_refptr<StreamParserBuffer> updated_buffer = 504 scoped_refptr<StreamParserBuffer> updated_buffer =
505 last_added_buffer_missing_duration_; 505 last_added_buffer_missing_duration_;
506 last_added_buffer_missing_duration_ = NULL; 506 last_added_buffer_missing_duration_ = NULL;
507 if (!QueueBuffer(updated_buffer)) 507 if (!QueueBuffer(updated_buffer))
508 return false; 508 return false;
509 } 509 }
510 510
511 if (buffer->duration() == kNoTimestamp()) { 511 if (buffer->duration() == kNoTimestamp()) {
512 last_added_buffer_missing_duration_ = buffer; 512 last_added_buffer_missing_duration_ = buffer;
513 DVLOG(2) << "AddBuffer() : holding back buffer that is missing duration"; 513 DVLOG(2) << "AddBuffer() : holding back buffer that is missing duration";
514 return true; 514 return true;
515 } 515 }
516 516
517 return QueueBuffer(buffer); 517 return QueueBuffer(buffer);
518 } 518 }
519 519
520 void WebMClusterParser::Track::ApplyDurationEstimateIfNeeded() { 520 void WebMClusterParser::Track::ApplyDurationEstimateIfNeeded() {
521 if (!last_added_buffer_missing_duration_) 521 if (!last_added_buffer_missing_duration_.get())
522 return; 522 return;
523 523
524 last_added_buffer_missing_duration_->set_duration(GetDurationEstimate()); 524 last_added_buffer_missing_duration_->set_duration(GetDurationEstimate());
525 525
526 DVLOG(2) << "ApplyDurationEstimateIfNeeded() : new dur : " 526 DVLOG(2) << "ApplyDurationEstimateIfNeeded() : new dur : "
527 << " ts " 527 << " ts "
528 << last_added_buffer_missing_duration_->timestamp().InSecondsF() 528 << last_added_buffer_missing_duration_->timestamp().InSecondsF()
529 << " dur " 529 << " dur "
530 << last_added_buffer_missing_duration_->duration().InSecondsF() 530 << last_added_buffer_missing_duration_->duration().InSecondsF()
531 << " kf " << last_added_buffer_missing_duration_->IsKeyframe() 531 << " kf " << last_added_buffer_missing_duration_->IsKeyframe()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 // Verify VP8 keyframe startcode. 567 // Verify VP8 keyframe startcode.
568 // http://tools.ietf.org/html/rfc6386 Section 19.1 568 // http://tools.ietf.org/html/rfc6386 Section 19.1
569 if (data[3] != 0x9d || data[4] != 0x01 || data[5] != 0x2a) 569 if (data[3] != 0x9d || data[4] != 0x01 || data[5] != 0x2a)
570 return false; 570 return false;
571 571
572 return true; 572 return true;
573 } 573 }
574 574
575 bool WebMClusterParser::Track::QueueBuffer( 575 bool WebMClusterParser::Track::QueueBuffer(
576 const scoped_refptr<StreamParserBuffer>& buffer) { 576 const scoped_refptr<StreamParserBuffer>& buffer) {
577 DCHECK(!last_added_buffer_missing_duration_); 577 DCHECK(!last_added_buffer_missing_duration_.get());
578 578
579 // WebMClusterParser::OnBlock() gives MEDIA_LOG and parse error on decreasing 579 // WebMClusterParser::OnBlock() gives MEDIA_LOG and parse error on decreasing
580 // block timecode detection within a cluster. Therefore, we should not see 580 // block timecode detection within a cluster. Therefore, we should not see
581 // those here. 581 // those here.
582 DecodeTimestamp previous_buffers_timestamp = buffers_.empty() ? 582 DecodeTimestamp previous_buffers_timestamp = buffers_.empty() ?
583 DecodeTimestamp() : buffers_.back()->GetDecodeTimestamp(); 583 DecodeTimestamp() : buffers_.back()->GetDecodeTimestamp();
584 CHECK(previous_buffers_timestamp <= buffer->GetDecodeTimestamp()); 584 CHECK(previous_buffers_timestamp <= buffer->GetDecodeTimestamp());
585 585
586 base::TimeDelta duration = buffer->duration(); 586 base::TimeDelta duration = buffer->duration();
587 if (duration < base::TimeDelta() || duration == kNoTimestamp()) { 587 if (duration < base::TimeDelta() || duration == kNoTimestamp()) {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 WebMClusterParser::FindTextTrack(int track_num) { 678 WebMClusterParser::FindTextTrack(int track_num) {
679 const TextTrackMap::iterator it = text_track_map_.find(track_num); 679 const TextTrackMap::iterator it = text_track_map_.find(track_num);
680 680
681 if (it == text_track_map_.end()) 681 if (it == text_track_map_.end())
682 return NULL; 682 return NULL;
683 683
684 return &it->second; 684 return &it->second;
685 } 685 }
686 686
687 } // namespace media 687 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698