Commit 6abddce1 authored by Ted Meyer's avatar Ted Meyer Committed by Commit Bot

Special case when packet->pos==-1

Sometimes video containers report audio packet timestamps as -1,
which was triggering the packet drop code from background track seeking.

Bug: 902634
Change-Id: I2b74fde01f9f2e06aeaf5fa4c2a3a1a4af8ead5d
Reviewed-on: https://chromium-review.googlesource.com/c/1352579
Commit-Queue: Ted Meyer <tmathmeyer@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611923}
parent 192d5422
......@@ -382,13 +382,19 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
// video frame dropping is handled by the renderer when correcting for a/v
// sync.
if (is_audio && !fixup_chained_ogg_ && last_packet_pos_ != AV_NOPTS_VALUE) {
// Some containers have unknown position...
if (packet->pos == -1)
packet->pos = last_packet_pos_;
if (packet->pos < last_packet_pos_) {
DVLOG(3) << "Dropped packet with out of order position";
DVLOG(3) << "Dropped packet with out of order position (" << packet->pos
<< " < " << last_packet_pos_ << ")";
return;
}
if (packet->pos == last_packet_pos_ && packet_dts <= last_packet_dts_) {
DCHECK_NE(last_packet_dts_, AV_NOPTS_VALUE);
DVLOG(3) << "Dropped packet with out of order display timestamp";
DVLOG(3) << "Dropped packet with out of order display timestamp ("
<< packet_dts << " < " << last_packet_dts_ << ")";
return;
}
}
......@@ -405,7 +411,7 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
if (packet->flags & AV_PKT_FLAG_KEY)
waiting_for_keyframe_ = false;
else {
DVLOG(3) << "Dropped non-keyframe pts=" << packet->pts;
DLOG(WARNING) << "Dropped non-keyframe pts=" << packet->pts;
return;
}
}
......
......@@ -748,7 +748,7 @@ TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOggDiscard_Sync) {
event.RunAndWaitForStatus(PIPELINE_OK);
}
}
#endif
#endif // !defined(OS_ANDROID)
// Similar to the test above, but using an opus clip with a large amount of
// pre-skip, which ffmpeg encodes as negative timestamps.
......@@ -797,6 +797,30 @@ TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOpusDiscard_Sync) {
}
#if BUILDFLAG(USE_PROPRIETARY_CODECS)
#if defined(OS_CHROMEOS)
TEST_F(FFmpegDemuxerTest, TestAudioNegativeTimestamps) {
// Note: This test will _crash_ the browser if negative timestamp
// values are skipped, since this file is heavily truncated to avoid
// copyright issue. If the negative timestamp packets are dropped, the
// demuxer will continue to read off the end of the stream.
CreateDemuxer("negative-audio-timestamps.avi");
InitializeDemuxer();
DemuxerStream* audio = GetStream(DemuxerStream::AUDIO);
audio->Read(NewReadCB(FROM_HERE, 104, 0, true));
base::RunLoop().Run();
audio->Read(NewReadCB(FROM_HERE, 104, 25873, true));
base::RunLoop().Run();
audio->Read(NewReadCB(FROM_HERE, 104, 51746, true));
base::RunLoop().Run();
audio->Read(NewReadCB(FROM_HERE, 104, 77619, true));
base::RunLoop().Run();
audio->Read(NewReadCB(FROM_HERE, 104, 103492, true));
base::RunLoop().Run();
}
#endif // defined(OS_CHROMEOS)
// Similar to the test above, but using an opus clip plus h264 b-frames to
// ensure we don't apply chained ogg workarounds to other content.
TEST_F(FFmpegDemuxerTest,
......@@ -847,7 +871,7 @@ TEST_F(FFmpegDemuxerTest,
event.RunAndWaitForStatus(PIPELINE_OK);
}
}
#endif
#endif // BUILDFLAG(USE_PROPRIETARY_CODECS)
// Similar to the test above, but using sfx-opus.ogg, which has a much smaller
// amount of discard padding and no |start_time| set on the AVStream.
......
......@@ -46,6 +46,9 @@ bear-vp8-webvtt.webm as a 'subt' handler type.
Just the first initialization segment of bear-1280x720_av_frag.mp4, modified to
have the mvhd version 0 32-bit duration field set to all 1's.
#### media/test/data/negative-audio-timestamps.avi
A truncated audio/video file with audio packet timestamps of -1. We need to ensure that these packets arent dropped.
### FLAC
#### bear-flac.mp4
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment