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

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

Issue 1260193005: Fix incorrect opus seek preroll and flaky pre-skip removal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Simplify Created 5 years, 4 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 (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 <algorithm> 5 #include <algorithm>
6 #include <deque> 6 #include <deque>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 video->Read(NewReadCB(FROM_HERE, 631, 66482, false)); 587 video->Read(NewReadCB(FROM_HERE, 631, 66482, false));
588 message_loop_.Run(); 588 message_loop_.Run();
589 589
590 // Seek back to the beginning and repeat the test. 590 // Seek back to the beginning and repeat the test.
591 WaitableMessageLoopEvent event; 591 WaitableMessageLoopEvent event;
592 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB()); 592 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB());
593 event.RunAndWaitForStatus(PIPELINE_OK); 593 event.RunAndWaitForStatus(PIPELINE_OK);
594 } 594 }
595 } 595 }
596 596
597 // Similar to the test above, but using an opus clip with a large amount of
598 // pre-skip, which ffmpeg encodes as negative timestamps.
599 TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOpusDiscard_Sync) {
600 CreateDemuxer("opus-trimming-video-test.webm");
601 InitializeDemuxer();
602
603 // Attempt a read from the video stream and run the message loop until done.
604 DemuxerStream* video = demuxer_->GetStream(DemuxerStream::VIDEO);
605 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
606 EXPECT_EQ(audio->audio_decoder_config().codec_delay(), 65535);
607
608 // Packet size to timestamp (in microseconds) mapping for the first N packets
609 // which should be fully discarded.
610 static const int kTestExpectations[][2] = {
611 {635, 0}, {594, 120000}, {597, 240000}, {591, 360000},
612 {582, 480000}, {583, 600000}, {592, 720000}, {567, 840000},
613 {579, 960000}, {572, 1080000}, {583, 1200000}};
614
615 // Run the test twice with a seek in between.
616 for (int i = 0; i < 2; ++i) {
617 for (size_t j = 0; j < arraysize(kTestExpectations); ++j) {
618 audio->Read(NewReadCB(FROM_HERE, kTestExpectations[j][0],
619 kTestExpectations[j][1], true));
620 message_loop_.Run();
621 }
622
623 // Though the internal start time may be below zero, the exposed media time
624 // must always be greater than zero.
625 EXPECT_EQ(base::TimeDelta(), demuxer_->GetStartTime());
wolenetz 2015/08/06 22:21:27 Dale and I chatted a little offline about some pot
626
627 video->Read(NewReadCB(FROM_HERE, 16009, 0, true));
628 message_loop_.Run();
629
630 video->Read(NewReadCB(FROM_HERE, 2715, 1000, false));
631 message_loop_.Run();
632
633 video->Read(NewReadCB(FROM_HERE, 427, 33000, false));
634 message_loop_.Run();
635
636 // Seek back to the beginning and repeat the test.
637 WaitableMessageLoopEvent event;
638 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB());
639 event.RunAndWaitForStatus(PIPELINE_OK);
640 }
641 }
642
643 // Similar to the test above, but using sfx-opus.ogg, which has a much smaller
644 // amount of discard padding and no |start_time| set on the AVStream.
645 TEST_F(FFmpegDemuxerTest, Read_AudioNegativeStartTimeAndOpusSfxDiscard_Sync) {
646 CreateDemuxer("sfx-opus.ogg");
647 InitializeDemuxer();
648
649 // Attempt a read from the video stream and run the message loop until done.
650 DemuxerStream* audio = demuxer_->GetStream(DemuxerStream::AUDIO);
651 EXPECT_EQ(audio->audio_decoder_config().codec_delay(), 312);
652
653 // Run the test twice with a seek in between.
654 for (int i = 0; i < 2; ++i) {
655 audio->Read(NewReadCB(FROM_HERE, 314, 0, true));
656 message_loop_.Run();
657
658 audio->Read(NewReadCB(FROM_HERE, 244, 20000, true));
659 message_loop_.Run();
660
661 // Though the internal start time may be below zero, the exposed media time
662 // must always be greater than zero.
663 EXPECT_EQ(base::TimeDelta(), demuxer_->GetStartTime());
664
665 // Seek back to the beginning and repeat the test.
666 WaitableMessageLoopEvent event;
667 demuxer_->Seek(base::TimeDelta(), event.GetPipelineStatusCB());
668 event.RunAndWaitForStatus(PIPELINE_OK);
669 }
670 }
671
597 TEST_F(FFmpegDemuxerTest, Read_EndOfStream) { 672 TEST_F(FFmpegDemuxerTest, Read_EndOfStream) {
598 // Verify that end of stream buffers are created. 673 // Verify that end of stream buffers are created.
599 CreateDemuxer("bear-320x240.webm"); 674 CreateDemuxer("bear-320x240.webm");
600 InitializeDemuxer(); 675 InitializeDemuxer();
601 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO)); 676 ReadUntilEndOfStream(demuxer_->GetStream(DemuxerStream::AUDIO));
602 } 677 }
603 678
604 TEST_F(FFmpegDemuxerTest, Read_EndOfStreamText) { 679 TEST_F(FFmpegDemuxerTest, Read_EndOfStreamText) {
605 // Verify that end of stream buffers are created. 680 // Verify that end of stream buffers are created.
606 CreateDemuxer("bear-vp8-webvtt.webm"); 681 CreateDemuxer("bear-vp8-webvtt.webm");
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
968 InitializeDemuxer(); 1043 InitializeDemuxer();
969 1044
970 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO); 1045 DemuxerStream* stream = demuxer_->GetStream(DemuxerStream::VIDEO);
971 ASSERT_TRUE(stream); 1046 ASSERT_TRUE(stream);
972 ASSERT_EQ(VIDEO_ROTATION_270, stream->video_rotation()); 1047 ASSERT_EQ(VIDEO_ROTATION_270, stream->video_rotation());
973 } 1048 }
974 1049
975 #endif 1050 #endif
976 1051
977 } // namespace media 1052 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698