OLD | NEW |
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 DCHECK_GT(frame_count, 0); | 234 DCHECK_GT(frame_count, 0); |
235 base::TimeDelta duration = base::TimeDelta::FromMicroseconds( | 235 base::TimeDelta duration = base::TimeDelta::FromMicroseconds( |
236 kOpusFrameDurationsMu[opusConfig] * frame_count); | 236 kOpusFrameDurationsMu[opusConfig] * frame_count); |
237 | 237 |
238 if (duration > kPacketDurationMax) { | 238 if (duration > kPacketDurationMax) { |
239 // Intentionally allowing packet to pass through for now. Decoder should | 239 // Intentionally allowing packet to pass through for now. Decoder should |
240 // either handle or fail gracefully. MEDIA_LOG as breadcrumbs in case | 240 // either handle or fail gracefully. MEDIA_LOG as breadcrumbs in case |
241 // things go sideways. | 241 // things go sideways. |
242 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_duration_errors_, | 242 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_duration_errors_, |
243 kMaxDurationErrorLogs) | 243 kMaxDurationErrorLogs) |
244 << "Warning, demuxed Opus packet with encoded duration: " << duration | 244 << "Warning, demuxed Opus packet with encoded duration: " |
245 << ". Should be no greater than " << kPacketDurationMax; | 245 << duration.InMilliseconds() << "ms. Should be no greater than " |
| 246 << kPacketDurationMax.InMilliseconds() << "ms."; |
246 } | 247 } |
247 | 248 |
248 return duration; | 249 return duration; |
249 } | 250 } |
250 | 251 |
251 WebMParserClient* WebMClusterParser::OnListStart(int id) { | 252 WebMParserClient* WebMClusterParser::OnListStart(int id) { |
252 if (id == kWebMIdCluster) { | 253 if (id == kWebMIdCluster) { |
253 cluster_timecode_ = -1; | 254 cluster_timecode_ = -1; |
254 cluster_start_time_ = kNoTimestamp(); | 255 cluster_start_time_ = kNoTimestamp(); |
255 } else if (id == kWebMIdBlockGroup) { | 256 } else if (id == kWebMIdBlockGroup) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 | 555 |
555 if (block_duration_time_delta != kNoTimestamp()) { | 556 if (block_duration_time_delta != kNoTimestamp()) { |
556 base::TimeDelta duration_difference = | 557 base::TimeDelta duration_difference = |
557 block_duration_time_delta - encoded_duration; | 558 block_duration_time_delta - encoded_duration; |
558 | 559 |
559 const auto kWarnDurationDiff = | 560 const auto kWarnDurationDiff = |
560 base::TimeDelta::FromMicroseconds(timecode_multiplier_ * 2); | 561 base::TimeDelta::FromMicroseconds(timecode_multiplier_ * 2); |
561 if (duration_difference.magnitude() > kWarnDurationDiff) { | 562 if (duration_difference.magnitude() > kWarnDurationDiff) { |
562 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_duration_errors_, | 563 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_duration_errors_, |
563 kMaxDurationErrorLogs) | 564 kMaxDurationErrorLogs) |
564 << "BlockDuration " | 565 << "BlockDuration (" << block_duration_time_delta.InMilliseconds() |
565 << "(" << block_duration_time_delta << ") " | 566 << "ms) differs significantly from encoded duration (" |
566 << "differs significantly from encoded duration " | 567 << encoded_duration.InMilliseconds() << "ms)."; |
567 << "(" << encoded_duration << ")."; | |
568 } | 568 } |
569 } | 569 } |
570 } else if (block_duration_time_delta != kNoTimestamp()) { | 570 } else if (block_duration_time_delta != kNoTimestamp()) { |
571 buffer->set_duration(block_duration_time_delta); | 571 buffer->set_duration(block_duration_time_delta); |
572 } else { | 572 } else { |
573 DCHECK_NE(buffer_type, DemuxerStream::TEXT); | 573 DCHECK_NE(buffer_type, DemuxerStream::TEXT); |
574 buffer->set_duration(track->default_duration()); | 574 buffer->set_duration(track->default_duration()); |
575 } | 575 } |
576 | 576 |
577 if (discard_padding != 0) { | 577 if (discard_padding != 0) { |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 if (is_video_) { | 686 if (is_video_) { |
687 // Exposing estimation so splicing/overlap frame processing can make | 687 // Exposing estimation so splicing/overlap frame processing can make |
688 // informed decisions downstream. | 688 // informed decisions downstream. |
689 // TODO(chcunningham): Set this for audio as well in later change where | 689 // TODO(chcunningham): Set this for audio as well in later change where |
690 // audio is switched to max estimation and splicing is disabled. | 690 // audio is switched to max estimation and splicing is disabled. |
691 last_added_buffer_missing_duration_->set_is_duration_estimated(true); | 691 last_added_buffer_missing_duration_->set_is_duration_estimated(true); |
692 } | 692 } |
693 | 693 |
694 LIMITED_MEDIA_LOG(INFO, media_log_, num_duration_estimates_, | 694 LIMITED_MEDIA_LOG(INFO, media_log_, num_duration_estimates_, |
695 kMaxDurationEstimateLogs) | 695 kMaxDurationEstimateLogs) |
696 << "Estimating WebM block duration to be " << estimated_duration << " " | 696 << "Estimating WebM block duration to be " |
697 << "for the last (Simple)Block in the Cluster for this Track. Use " | 697 << estimated_duration.InMilliseconds() |
698 << "BlockGroups with BlockDurations at the end of each Track in a " | 698 << "ms for the last (Simple)Block in the Cluster for this Track. Use " |
699 << "Cluster to avoid estimation."; | 699 "BlockGroups with BlockDurations at the end of each Track in a " |
| 700 "Cluster to avoid estimation."; |
700 | 701 |
701 DVLOG(2) << __FUNCTION__ << " new dur : ts " | 702 DVLOG(2) << __FUNCTION__ << " new dur : ts " |
702 << last_added_buffer_missing_duration_->timestamp().InSecondsF() | 703 << last_added_buffer_missing_duration_->timestamp().InSecondsF() |
703 << " dur " | 704 << " dur " |
704 << last_added_buffer_missing_duration_->duration().InSecondsF() | 705 << last_added_buffer_missing_duration_->duration().InSecondsF() |
705 << " kf " << last_added_buffer_missing_duration_->is_key_frame() | 706 << " kf " << last_added_buffer_missing_duration_->is_key_frame() |
706 << " size " << last_added_buffer_missing_duration_->data_size(); | 707 << " size " << last_added_buffer_missing_duration_->data_size(); |
707 | 708 |
708 // Don't use the applied duration as a future estimation (don't use | 709 // Don't use the applied duration as a future estimation (don't use |
709 // QueueBuffer() here.) | 710 // QueueBuffer() here.) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 WebMClusterParser::FindTextTrack(int track_num) { | 873 WebMClusterParser::FindTextTrack(int track_num) { |
873 const TextTrackMap::iterator it = text_track_map_.find(track_num); | 874 const TextTrackMap::iterator it = text_track_map_.find(track_num); |
874 | 875 |
875 if (it == text_track_map_.end()) | 876 if (it == text_track_map_.end()) |
876 return NULL; | 877 return NULL; |
877 | 878 |
878 return &it->second; | 879 return &it->second; |
879 } | 880 } |
880 | 881 |
881 } // namespace media | 882 } // namespace media |
OLD | NEW |