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

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 2727573005: Remove useless DCHECK; discard helper enforces invalid values. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | media/test/pipeline_integration_fuzzertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 498
499 buffer->set_timestamp(stream_timestamp - start_time); 499 buffer->set_timestamp(stream_timestamp - start_time);
500 500
501 // Only allow negative timestamps past if we know they'll be fixed up by the 501 // Only allow negative timestamps past if we know they'll be fixed up by the
502 // code paths below; otherwise they should be treated as a parse error. 502 // code paths below; otherwise they should be treated as a parse error.
503 if (!fixup_negative_timestamps_ && buffer->timestamp() < base::TimeDelta()) { 503 if (!fixup_negative_timestamps_ && buffer->timestamp() < base::TimeDelta()) {
504 demuxer_->NotifyDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE); 504 demuxer_->NotifyDemuxerError(DEMUXER_ERROR_COULD_NOT_PARSE);
505 return; 505 return;
506 } 506 }
507 507
508 // If enabled, and no codec delay is present, mark audio packets with 508 // If enabled, and no codec delay is present, mark audio packets with negative
509 // negative timestamps for post-decode discard. 509 // timestamps for post-decode discard. If codec delay is present, discard is
510 // handled by the decoder using that value.
510 if (fixup_negative_timestamps_ && is_audio && 511 if (fixup_negative_timestamps_ && is_audio &&
511 stream_timestamp < base::TimeDelta() && 512 stream_timestamp < base::TimeDelta() &&
512 buffer->duration() != kNoTimestamp) { 513 buffer->duration() != kNoTimestamp &&
513 if (!audio_decoder_config().codec_delay()) { 514 !audio_decoder_config().codec_delay()) {
514 DCHECK_EQ(buffer->discard_padding().first, base::TimeDelta()); 515 DCHECK_EQ(buffer->discard_padding().first, base::TimeDelta());
515 516
516 if (stream_timestamp + buffer->duration() < base::TimeDelta()) { 517 if (stream_timestamp + buffer->duration() < base::TimeDelta()) {
517 DCHECK_EQ(buffer->discard_padding().second, base::TimeDelta()); 518 DCHECK_EQ(buffer->discard_padding().second, base::TimeDelta());
518 519
519 // Discard the entire packet if it's entirely before zero. 520 // Discard the entire packet if it's entirely before zero.
520 buffer->set_discard_padding( 521 buffer->set_discard_padding(
521 std::make_pair(kInfiniteDuration, base::TimeDelta())); 522 std::make_pair(kInfiniteDuration, base::TimeDelta()));
522 } else {
523 // Only discard part of the frame if it overlaps zero.
524 buffer->set_discard_padding(std::make_pair(
525 -stream_timestamp, buffer->discard_padding().second));
526 }
527 } else { 523 } else {
528 // Verify that codec delay would cover discard and that we don't need to 524 // Only discard part of the frame if it overlaps zero.
529 // mark the packet for post decode discard. Since timestamps may be in 525 buffer->set_discard_padding(
530 // milliseconds and codec delay in nanosecond precision, round up to the 526 std::make_pair(-stream_timestamp, buffer->discard_padding().second));
531 // nearest millisecond. See enable_negative_timestamp_fixups().
532 DCHECK_LE(-std::ceil(FramesToTimeDelta(
533 audio_decoder_config().codec_delay(),
534 audio_decoder_config().samples_per_second())
535 .InMillisecondsF()),
536 stream_timestamp.InMillisecondsF());
537 } 527 }
538 } 528 }
539 529
540 if (last_packet_timestamp_ != kNoTimestamp) { 530 if (last_packet_timestamp_ != kNoTimestamp) {
541 // FFmpeg doesn't support chained ogg correctly. Instead of guaranteeing 531 // FFmpeg doesn't support chained ogg correctly. Instead of guaranteeing
542 // continuity across links in the chain it uses the timestamp information 532 // continuity across links in the chain it uses the timestamp information
543 // from each link directly. Doing so can lead to timestamps which appear to 533 // from each link directly. Doing so can lead to timestamps which appear to
544 // go backwards in time. 534 // go backwards in time.
545 // 535 //
546 // If the new link starts with a negative timestamp or a timestamp less than 536 // If the new link starts with a negative timestamp or a timestamp less than
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 1834
1845 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1835 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1846 DCHECK(task_runner_->BelongsToCurrentThread()); 1836 DCHECK(task_runner_->BelongsToCurrentThread());
1847 for (const auto& stream : streams_) { 1837 for (const auto& stream : streams_) {
1848 if (stream) 1838 if (stream)
1849 stream->SetLiveness(liveness); 1839 stream->SetLiveness(liveness);
1850 } 1840 }
1851 } 1841 }
1852 1842
1853 } // namespace media 1843 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/test/pipeline_integration_fuzzertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698