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

Unified Diff: media/filters/audio_file_reader_unittest.cc

Issue 311373004: Consolidate and improve audio decoding test for all decoders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Megapatch! Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: media/filters/audio_file_reader_unittest.cc
diff --git a/media/filters/audio_file_reader_unittest.cc b/media/filters/audio_file_reader_unittest.cc
index 28c9837cb2e189d48629c3f0d5fec9adca0af999..fbf7f53e981bf29f1ee084476f9d8e7d1e1b6028 100644
--- a/media/filters/audio_file_reader_unittest.cc
+++ b/media/filters/audio_file_reader_unittest.cc
@@ -3,12 +3,14 @@
// found in the LICENSE file.
#include "base/logging.h"
+#include "base/md5.h"
#include "base/memory/scoped_ptr.h"
#include "build/build_config.h"
#include "media/base/audio_bus.h"
#include "media/base/audio_hash.h"
#include "media/base/decoder_buffer.h"
#include "media/base/test_data_util.h"
+#include "media/ffmpeg/ffmpeg_common.h"
#include "media/filters/audio_file_reader.h"
#include "media/filters/in_memory_url_protocol.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -40,6 +42,37 @@ class AudioFileReaderTest : public testing::Test {
EXPECT_EQ(expected_audio_hash, audio_hash.ToString());
}
+ // Verify packets are consistent across demuxer runs.
+ void VerifyPackets() {
+ const int kReads = 3;
+ const int kTestPasses = 2;
+
+ // Seek to the effective start of the file. For ogg files this may not be
+ // the actual first packet, but it should correspond to the first decoded
wolenetz 2014/06/06 21:00:05 If not the actual first packet, why not? (elaborat
DaleCurtis 2014/06/06 21:17:00 I think this is sufficient. I don't need to expla
+ // samples.
+ ASSERT_TRUE(reader_->SeekForTesting(base::TimeDelta()));
wolenetz 2014/06/06 21:00:05 nit: is base::TimeDelta() the first timestamp in a
DaleCurtis 2014/06/06 21:17:00 Setting AV_SEEK_FLAG_BACKWARD chooses the first PT
wolenetz 2014/06/06 21:52:31 Ok. I was confusing with MSE where lowest PTS in a
+
+ AVPacket packet;
+ std::vector<std::string> packet_md5_hashes_;
+ for (int i = 0; i < kTestPasses; ++i) {
+ for (int j = 0; j < kReads; ++j) {
+ ASSERT_TRUE(reader_->ReadPacketForTesting(&packet));
+ const std::string md5_hash = base::MD5String(base::StringPiece(
+ reinterpret_cast<char*>(packet.data), packet.size));
+
+ // On the first pass save the MD5 hash of each packet, on subsequent
+ // passes ensure it matches.
+ if (i == 0)
+ packet_md5_hashes_.push_back(md5_hash);
+ else
+ EXPECT_EQ(packet_md5_hashes_[j], md5_hash);
+
+ av_free_packet(&packet);
+ }
+ ASSERT_TRUE(reader_->SeekForTesting(base::TimeDelta()));
+ }
+ }
+
void RunTest(const char* fn, const char* hash, int channels, int sample_rate,
base::TimeDelta duration, int frames, int trimmed_frames) {
Initialize(fn);
@@ -50,6 +83,9 @@ class AudioFileReaderTest : public testing::Test {
reader_->GetDuration().InMicroseconds());
EXPECT_EQ(frames, reader_->GetNumberOfFrames());
ReadAndVerify(hash, trimmed_frames);
+
+ // After the normal checks, perform some seek based tests on the packets.
+ VerifyPackets();
}
void RunTestFailingDemux(const char* fn) {

Powered by Google App Engine
This is Rietveld 408576698