OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "media/base/audio_buffer.h" | 6 #include "media/base/audio_buffer.h" |
7 #include "media/base/audio_bus.h" | 7 #include "media/base/audio_bus.h" |
8 #include "media/base/audio_discard_helper.h" | 8 #include "media/base/audio_discard_helper.h" |
9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
10 #include "media/base/decoder_buffer.h" | 10 #include "media/base/decoder_buffer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 static scoped_refptr<AudioBuffer> CreateDecodedBuffer(int frames) { | 28 static scoped_refptr<AudioBuffer> CreateDecodedBuffer(int frames) { |
29 return MakeAudioBuffer(kSampleFormatPlanarF32, | 29 return MakeAudioBuffer(kSampleFormatPlanarF32, |
30 CHANNEL_LAYOUT_MONO, | 30 CHANNEL_LAYOUT_MONO, |
31 1, | 31 1, |
32 kSampleRate, | 32 kSampleRate, |
33 0.0f, | 33 0.0f, |
34 kDataStep, | 34 kDataStep, |
35 frames, | 35 frames, |
36 kNoTimestamp(), | |
37 kNoTimestamp()); | 36 kNoTimestamp()); |
38 } | 37 } |
39 | 38 |
40 static float ExtractDecodedData(const scoped_refptr<AudioBuffer>& buffer, | 39 static float ExtractDecodedData(const scoped_refptr<AudioBuffer>& buffer, |
41 int index) { | 40 int index) { |
42 // This is really inefficient, but we can't access the raw AudioBuffer if any | 41 // This is really inefficient, but we can't access the raw AudioBuffer if any |
43 // start trimming has been applied. | 42 // start trimming has been applied. |
44 scoped_ptr<AudioBus> temp_bus = AudioBus::Create(buffer->channel_count(), 1); | 43 scoped_ptr<AudioBus> temp_bus = AudioBus::Create(buffer->channel_count(), 1); |
45 buffer->ReadFrames(1, index, 0, temp_bus.get()); | 44 buffer->ReadFrames(1, index, 0, temp_bus.get()); |
46 return temp_bus->channel(0)[0]; | 45 return temp_bus->channel(0)[0]; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); | 251 ASSERT_TRUE(discard_helper.ProcessBuffers(encoded_buffer, decoded_buffer)); |
253 ASSERT_TRUE(discard_helper.initialized()); | 252 ASSERT_TRUE(discard_helper.initialized()); |
254 EXPECT_EQ(kTimestamp, decoded_buffer->timestamp()); | 253 EXPECT_EQ(kTimestamp, decoded_buffer->timestamp()); |
255 EXPECT_EQ(kDuration / 2, decoded_buffer->duration()); | 254 EXPECT_EQ(kDuration / 2, decoded_buffer->duration()); |
256 EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count()); | 255 EXPECT_EQ(kTestFrames / 2, decoded_buffer->frame_count()); |
257 ASSERT_FLOAT_EQ(kDiscardFrames * kDataStep, | 256 ASSERT_FLOAT_EQ(kDiscardFrames * kDataStep, |
258 ExtractDecodedData(decoded_buffer, 0)); | 257 ExtractDecodedData(decoded_buffer, 0)); |
259 } | 258 } |
260 | 259 |
261 } // namespace media | 260 } // namespace media |
OLD | NEW |