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

Unified Diff: media/base/audio_buffer_unittest.cc

Issue 251893002: Support start trimming post-decoding. Use it with FFmpegDemuxer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Typo. Created 6 years, 8 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
« no previous file with comments | « media/base/audio_buffer.cc ('k') | media/base/audio_discard_helper.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/audio_buffer_unittest.cc
diff --git a/media/base/audio_buffer_unittest.cc b/media/base/audio_buffer_unittest.cc
index c40c076bd5e8ee73c224df4db6b972f0c00fea84..09da83e5fa45973c2ab8da63f6c60b2ee31c3068 100644
--- a/media/base/audio_buffer_unittest.cc
+++ b/media/base/audio_buffer_unittest.cc
@@ -358,4 +358,49 @@ TEST(AudioBufferTest, Trim) {
EXPECT_EQ(buffer->duration(), base::TimeDelta::FromSeconds(0));
}
+TEST(AudioBufferTest, TrimRange) {
+ const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0;
+ const int channels = ChannelLayoutToChannelCount(channel_layout);
+ const int frames = 100;
+ const base::TimeDelta start_time;
+ const base::TimeDelta duration = base::TimeDelta::FromSeconds(frames);
+ const float step = 1.0f;
+ scoped_refptr<AudioBuffer> buffer =
+ MakeAudioBuffer<float>(kSampleFormatPlanarF32,
+ channel_layout,
+ channels,
+ kSampleRate,
+ 0,
+ step,
+ frames,
+ start_time,
+ duration);
+ EXPECT_EQ(frames, buffer->frame_count());
+ EXPECT_EQ(start_time, buffer->timestamp());
+ EXPECT_EQ(frames, buffer->duration().InSeconds());
+
+ scoped_ptr<AudioBus> bus = AudioBus::Create(channels, frames);
+
+ const int trim_start = 25;
+ const int trim_length = 50;
+
+ // Verify the first 25 frames before trimming.
+ buffer->ReadFrames(trim_start, 0, 0, bus.get());
+ VerifyResult(bus->channel(0), trim_start, 0, step);
+
+ // Trim frames from the middle of the buffer.
+ buffer->TrimRange(trim_start, trim_start + trim_length);
+ EXPECT_EQ(buffer->frame_count(), frames - trim_length);
+ EXPECT_EQ(buffer->timestamp(), start_time);
+ EXPECT_EQ(buffer->duration(), base::TimeDelta::FromSeconds(50));
+
+ // Verify the first 25 frames.
+ buffer->ReadFrames(trim_start, 0, 0, bus.get());
+ VerifyResult(bus->channel(0), trim_start, 0, step);
+
+ // Verify the next 25 frames.
+ buffer->ReadFrames(trim_start, trim_start, 0, bus.get());
+ VerifyResult(bus->channel(0), trim_start, trim_start + trim_length, step);
+}
+
} // namespace media
« no previous file with comments | « media/base/audio_buffer.cc ('k') | media/base/audio_discard_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698