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: " | 244 << "Warning, demuxed Opus packet with encoded duration: " << duration |
245 << duration.InMilliseconds() << "ms. Should be no greater than " | 245 << ". Should be no greater than " << kPacketDurationMax; |
246 << kPacketDurationMax.InMilliseconds() << "ms."; | |
247 } | 246 } |
248 | 247 |
249 return duration; | 248 return duration; |
250 } | 249 } |
251 | 250 |
252 WebMParserClient* WebMClusterParser::OnListStart(int id) { | 251 WebMParserClient* WebMClusterParser::OnListStart(int id) { |
253 if (id == kWebMIdCluster) { | 252 if (id == kWebMIdCluster) { |
254 cluster_timecode_ = -1; | 253 cluster_timecode_ = -1; |
255 cluster_start_time_ = kNoTimestamp(); | 254 cluster_start_time_ = kNoTimestamp(); |
256 } else if (id == kWebMIdBlockGroup) { | 255 } else if (id == kWebMIdBlockGroup) { |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 | 554 |
556 if (block_duration_time_delta != kNoTimestamp()) { | 555 if (block_duration_time_delta != kNoTimestamp()) { |
557 base::TimeDelta duration_difference = | 556 base::TimeDelta duration_difference = |
558 block_duration_time_delta - encoded_duration; | 557 block_duration_time_delta - encoded_duration; |
559 | 558 |
560 const auto kWarnDurationDiff = | 559 const auto kWarnDurationDiff = |
561 base::TimeDelta::FromMicroseconds(timecode_multiplier_ * 2); | 560 base::TimeDelta::FromMicroseconds(timecode_multiplier_ * 2); |
562 if (duration_difference.magnitude() > kWarnDurationDiff) { | 561 if (duration_difference.magnitude() > kWarnDurationDiff) { |
563 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_duration_errors_, | 562 LIMITED_MEDIA_LOG(DEBUG, media_log_, num_duration_errors_, |
564 kMaxDurationErrorLogs) | 563 kMaxDurationErrorLogs) |
565 << "BlockDuration (" << block_duration_time_delta.InMilliseconds() | 564 << "BlockDuration " |
566 << "ms) differs significantly from encoded duration (" | 565 << "(" << block_duration_time_delta << ") " |
567 << encoded_duration.InMilliseconds() << "ms)."; | 566 << "differs significantly from encoded duration " |
| 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 " | 696 << "Estimating WebM block duration to be " << estimated_duration << " " |
697 << estimated_duration.InMilliseconds() | 697 << "for the last (Simple)Block in the Cluster for this Track. Use " |
698 << "ms for the last (Simple)Block in the Cluster for this Track. Use " | 698 << "BlockGroups with BlockDurations at the end of each Track in a " |
699 "BlockGroups with BlockDurations at the end of each Track in a " | 699 << "Cluster to avoid estimation."; |
700 "Cluster to avoid estimation."; | |
701 | 700 |
702 DVLOG(2) << __FUNCTION__ << " new dur : ts " | 701 DVLOG(2) << __FUNCTION__ << " new dur : ts " |
703 << last_added_buffer_missing_duration_->timestamp().InSecondsF() | 702 << last_added_buffer_missing_duration_->timestamp().InSecondsF() |
704 << " dur " | 703 << " dur " |
705 << last_added_buffer_missing_duration_->duration().InSecondsF() | 704 << last_added_buffer_missing_duration_->duration().InSecondsF() |
706 << " kf " << last_added_buffer_missing_duration_->is_key_frame() | 705 << " kf " << last_added_buffer_missing_duration_->is_key_frame() |
707 << " size " << last_added_buffer_missing_duration_->data_size(); | 706 << " size " << last_added_buffer_missing_duration_->data_size(); |
708 | 707 |
709 // Don't use the applied duration as a future estimation (don't use | 708 // Don't use the applied duration as a future estimation (don't use |
710 // QueueBuffer() here.) | 709 // QueueBuffer() here.) |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 WebMClusterParser::FindTextTrack(int track_num) { | 872 WebMClusterParser::FindTextTrack(int track_num) { |
874 const TextTrackMap::iterator it = text_track_map_.find(track_num); | 873 const TextTrackMap::iterator it = text_track_map_.find(track_num); |
875 | 874 |
876 if (it == text_track_map_.end()) | 875 if (it == text_track_map_.end()) |
877 return NULL; | 876 return NULL; |
878 | 877 |
879 return &it->second; | 878 return &it->second; |
880 } | 879 } |
881 | 880 |
882 } // namespace media | 881 } // namespace media |
OLD | NEW |