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

Side by Side Diff: media/test/pipeline_integration_test.cc

Issue 1492163002: Roll ffmpeg DEPS for MP3 seek bug, add tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing test typo. Created 5 years 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 | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | no next file » | 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_split.h" 9 #include "base/strings/string_split.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed)); 1222 ASSERT_EQ(PIPELINE_OK, Start("sfx.mp3", kHashed));
1223 1223
1224 Play(); 1224 Play();
1225 1225
1226 ASSERT_TRUE(WaitUntilOnEnded()); 1226 ASSERT_TRUE(WaitUntilOnEnded());
1227 1227
1228 // Verify codec delay and preroll are stripped. 1228 // Verify codec delay and preroll are stripped.
1229 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash()); 1229 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash());
1230 } 1230 }
1231 1231
1232 class Mp3FastSeekParams {
1233 public:
1234 Mp3FastSeekParams(const char* filename, const char* hash)
1235 : filename(filename), hash(hash) {}
1236 const char* filename;
1237 const char* hash;
1238 };
1239
1240 class Mp3FastSeekIntegrationTest
1241 : public PipelineIntegrationTest,
1242 public testing::WithParamInterface<Mp3FastSeekParams> {};
1243
1244 TEST_P(Mp3FastSeekIntegrationTest, FastSeekAccuracy_MP3) {
1245 Mp3FastSeekParams config = GetParam();
1246 ASSERT_EQ(PIPELINE_OK, Start(config.filename, kHashed));
1247
1248 // The XING TOC is inaccurate. We don't use it for CBR, we tolerate it for VBR
1249 // (best option for fast seeking; see Mp3SeekFFmpegDemuxerTest). The chosen
1250 // seek time exposes inaccuracy in TOC such that the hash will change if seek
1251 // logic is regressed. See https://crbug.com/545914.
1252 //
1253 // Quick TOC design (not pretty!):
1254 // - All MP3 TOCs are 100 bytes
1255 // - Each byte is read as a uint8; value between 0 - 255.
1256 // - The index into this array is the numerator in the ratio: index / 100.
1257 // This fraction represents a playback time as a percentage of duration.
1258 // - The value at the given index is the numerator in the ratio: value / 256.
1259 // This fraction represents a byte offset as a percentage of the file size.
1260 //
1261 // For CBR files, each frame is the same size, so the offset for time of
1262 // (0.98 * duration) should be around (0.98 * file size). This is 250.88 / 256
1263 // but the numerator will be truncated in the TOC as 250, losing precision.
1264 base::TimeDelta seek_time(0.98 * pipeline_->GetMediaDuration());
1265
1266 ASSERT_TRUE(Seek(seek_time));
1267 Play();
1268 ASSERT_TRUE(WaitUntilOnEnded());
1269
1270 EXPECT_HASH_EQ(config.hash, GetAudioHash());
1271 }
1272
1273 // CBR seeks should always be fast and accurate.
1274 INSTANTIATE_TEST_CASE_P(
1275 AccurateSeeks,
ddorwin 2015/12/04 19:31:50 CBRSeeks? The test itself is not accurate/inaccura
chcunningham 2015/12/04 22:34:29 Done.
1276 Mp3FastSeekIntegrationTest,
1277 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-CBR-has-TOC.mp3",
1278 "-0.71,0.36,2.96,2.68,2.10,-1.08,"),
1279 Mp3FastSeekParams("bear-audio-10s-CBR-no-TOC.mp3",
1280 "0.95,0.56,1.34,0.47,1.77,0.84,")));
1281
1282 // VBR seeks can be fast *OR* accurate, but not both. We chose fast.
1283 INSTANTIATE_TEST_CASE_P(
1284 InaccurateSeeks,
1285 Mp3FastSeekIntegrationTest,
1286 ::testing::Values(Mp3FastSeekParams("bear-audio-10s-VBR-has-TOC.mp3",
1287 "-0.15,-0.83,0.54,1.00,1.94,0.93,"),
1288 Mp3FastSeekParams("bear-audio-10s-VBR-no-TOC.mp3",
1289 "-0.22,0.80,1.19,0.73,-0.31,-1.12,")));
1290
1232 TEST_F(PipelineIntegrationTest, MediaSource_MP3) { 1291 TEST_F(PipelineIntegrationTest, MediaSource_MP3) {
1233 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile); 1292 MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile);
1234 StartHashedPipelineWithMediaSource(&source); 1293 StartHashedPipelineWithMediaSource(&source);
1235 source.EndOfStream(); 1294 source.EndOfStream();
1236 1295
1237 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size()); 1296 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1238 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds()); 1297 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1239 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1298 EXPECT_EQ(313, pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1240 1299
1241 Play(); 1300 Play();
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 1899
1841 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { 1900 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) {
1842 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm")); 1901 ASSERT_EQ(PIPELINE_OK, Start("nonzero-start-time.webm"));
1843 Play(); 1902 Play();
1844 ASSERT_TRUE(WaitUntilOnEnded()); 1903 ASSERT_TRUE(WaitUntilOnEnded());
1845 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), 1904 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
1846 demuxer_->GetStartTime()); 1905 demuxer_->GetStartTime());
1847 } 1906 }
1848 1907
1849 } // namespace media 1908 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_demuxer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698