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

Unified Diff: media/base/audio_buffer_unittest.cc

Issue 2349873002: AudioBuffer: remove PadSilence() (Closed)
Patch Set: feedback: extra headers Created 4 years, 3 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') | no next file » | 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 434be34133373691f211fef7a2774543fde07bf0..a897d8fa84957ea9a9eee583e4f23101fa6c64b7 100644
--- a/media/base/audio_buffer_unittest.cc
+++ b/media/base/audio_buffer_unittest.cc
@@ -24,7 +24,6 @@ static void VerifyBusWithOffset(AudioBus* bus,
float increment) {
for (int ch = 0; ch < bus->channels(); ++ch) {
const float v = start_offset + start + ch * bus->frames() * increment;
-
for (int i = offset; i < offset + frames; ++i) {
ASSERT_FLOAT_EQ(v + i * increment, bus->channel(ch)[i]) << "i=" << i
<< ", ch=" << ch;
@@ -158,40 +157,6 @@ static void TrimRangeTest(SampleFormat sample_format) {
1);
}
-void PadStartTest(SampleFormat sample_format) {
- const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0;
- const int channels = ChannelLayoutToChannelCount(channel_layout);
- const int frames = 100;
- const int silence_frames = frames / 5;
- const base::TimeDelta start_time;
- scoped_refptr<AudioBuffer> buffer =
- MakeAudioBuffer<float>(sample_format, channel_layout, channels,
- kSampleRate, 0.0f, 1.0f, frames, start_time);
-
- // Read all 100 frames from the buffer.
- std::unique_ptr<AudioBus> bus = AudioBus::Create(channels, frames);
- buffer->ReadFrames(frames, 0, 0, bus.get());
- VerifyBus(bus.get(), frames, 0, 1);
-
- // Now trim off some frames and add in leading silence.
- buffer->TrimStart(silence_frames);
- buffer->PadStart(silence_frames);
-
- // Re-read. Verify first 20 frames of silence, next 80 frames same as before.
- bus->Zero();
- buffer->ReadFrames(frames, 0, 0, bus.get());
- VerifyBus(bus.get(), silence_frames, 0, 0);
- VerifyBusWithOffset(bus.get(), silence_frames, frames - silence_frames, 0, 0,
- 1);
-
- // Now trim off the silence. Verify silence is gone.
- buffer->TrimStart(silence_frames);
- bus->Zero();
- buffer->ReadFrames(frames - silence_frames, 0, 0, bus.get());
- VerifyBusWithOffset(bus.get(), 0, frames - silence_frames, silence_frames, 0,
- 1);
-}
-
TEST(AudioBufferTest, CopyFrom) {
const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_MONO;
scoped_refptr<AudioBuffer> original_buffer = MakeAudioBuffer<uint8_t>(
@@ -469,49 +434,4 @@ TEST(AudioBufferTest, TrimRangeInterleaved) {
TrimRangeTest(kSampleFormatF32);
}
-TEST(AudioBufferTest, PadStartPlanar) {
- PadStartTest(kSampleFormatPlanarF32);
-}
-
-TEST(AudioBufferTest, PadStartInterleaved) {
- PadStartTest(kSampleFormatF32);
-}
-
-TEST(AudioBufferTest, PadStartEmptyBuffer) {
- const ChannelLayout channel_layout = CHANNEL_LAYOUT_4_0;
- const int channels = ChannelLayoutToChannelCount(channel_layout);
- const int frames = kSampleRate / 10;
- const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
- const base::TimeDelta start_time;
- scoped_refptr<AudioBuffer> buffer = AudioBuffer::CreateEmptyBuffer(
- channel_layout, channels, kSampleRate, frames, start_time);
-
- // Empty buffer should zero data size with non-zero frame count and duration.
- EXPECT_EQ(std::size_t{0}, buffer->data_size());
- EXPECT_EQ(frames, buffer->frame_count());
- EXPECT_EQ(duration, buffer->duration());
-
- // Read all frames from the buffer. All data should be 0.
- std::unique_ptr<AudioBus> bus = AudioBus::Create(channels, frames);
- buffer->ReadFrames(frames, 0, 0, bus.get());
- VerifyBus(bus.get(), frames, 0, 0);
-
- // Double the number of frames by padding the start of the buffer with
- // |frames| of silence.
- buffer->PadStart(frames);
- const int new_frame_count = frames * 2;
- const base::TimeDelta new_duration = base::TimeDelta::FromMilliseconds(200);
-
- // Adding silence should not trigger an allocation, but the frame count and
- // duration should be increased.
- EXPECT_EQ(std::size_t{0}, buffer->data_size());
- EXPECT_EQ(new_frame_count, buffer->frame_count());
- EXPECT_EQ(new_duration, buffer->duration());
-
- // Read all frames from the buffer. All data should be 0.
- bus = AudioBus::Create(channels, new_frame_count);
- buffer->ReadFrames(new_frame_count, 0, 0, bus.get());
- VerifyBus(bus.get(), new_frame_count, 0, 0);
-}
-
} // namespace media
« no previous file with comments | « media/base/audio_buffer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698