OLD | NEW |
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 // MSVC++ requires this to be set before any other includes to get M_SQRT1_2. | 5 // MSVC++ requires this to be set before any other includes to get M_SQRT1_2. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
11 #include "media/base/audio_bus.h" | 11 #include "media/base/audio_bus.h" |
12 #include "media/base/channel_mixer.h" | 12 #include "media/base/channel_mixer.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Number of frames to test with. | 17 // Number of frames to test with. |
18 enum { kFrames = 16 }; | 18 enum { kFrames = 16 }; |
19 | 19 |
20 // Test all possible layout conversions can be constructed and mixed. | 20 // Test all possible layout conversions can be constructed and mixed. |
21 TEST(ChannelMixerTest, ConstructAllPossibleLayouts) { | 21 TEST(ChannelMixerTest, ConstructAllPossibleLayouts) { |
22 for (ChannelLayout input_layout = CHANNEL_LAYOUT_MONO; | 22 for (ChannelLayout input_layout = CHANNEL_LAYOUT_MONO; |
23 input_layout < CHANNEL_LAYOUT_MAX; | 23 input_layout < CHANNEL_LAYOUT_MAX; |
24 input_layout = static_cast<ChannelLayout>(input_layout + 1)) { | 24 input_layout = static_cast<ChannelLayout>(input_layout + 1)) { |
25 for (ChannelLayout output_layout = CHANNEL_LAYOUT_MONO; | 25 for (ChannelLayout output_layout = CHANNEL_LAYOUT_MONO; |
26 output_layout < CHANNEL_LAYOUT_STEREO_DOWNMIX; | 26 output_layout < CHANNEL_LAYOUT_STEREO_DOWNMIX; |
27 output_layout = static_cast<ChannelLayout>(output_layout + 1)) { | 27 output_layout = static_cast<ChannelLayout>(output_layout + 1)) { |
28 // DISCRETE can't be tested here based on the current approach. | |
29 if (input_layout == CHANNEL_LAYOUT_DISCRETE || | |
30 output_layout == CHANNEL_LAYOUT_DISCRETE) | |
31 continue; | |
32 | |
33 SCOPED_TRACE(base::StringPrintf( | 28 SCOPED_TRACE(base::StringPrintf( |
34 "Input Layout: %d, Output Layout: %d", input_layout, output_layout)); | 29 "Input Layout: %d, Output Layout: %d", input_layout, output_layout)); |
35 ChannelMixer mixer(input_layout, output_layout); | 30 ChannelMixer mixer(input_layout, output_layout); |
36 scoped_ptr<AudioBus> input_bus = AudioBus::Create( | 31 scoped_ptr<AudioBus> input_bus = AudioBus::Create( |
37 ChannelLayoutToChannelCount(input_layout), kFrames); | 32 ChannelLayoutToChannelCount(input_layout), kFrames); |
38 scoped_ptr<AudioBus> output_bus = AudioBus::Create( | 33 scoped_ptr<AudioBus> output_bus = AudioBus::Create( |
39 ChannelLayoutToChannelCount(output_layout), kFrames); | 34 ChannelLayoutToChannelCount(output_layout), kFrames); |
40 for (int ch = 0; ch < input_bus->channels(); ++ch) | 35 for (int ch = 0; ch < input_bus->channels(); ++ch) |
41 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames, 1); | 36 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames, 1); |
42 | 37 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 0.5f), | 114 0.5f), |
120 ChannelMixerTestData(CHANNEL_LAYOUT_MONO, CHANNEL_LAYOUT_STEREO, | 115 ChannelMixerTestData(CHANNEL_LAYOUT_MONO, CHANNEL_LAYOUT_STEREO, |
121 kMonoToStereoValues, arraysize(kMonoToStereoValues), | 116 kMonoToStereoValues, arraysize(kMonoToStereoValues), |
122 1.0f), | 117 1.0f), |
123 ChannelMixerTestData(CHANNEL_LAYOUT_5_1, CHANNEL_LAYOUT_MONO, | 118 ChannelMixerTestData(CHANNEL_LAYOUT_5_1, CHANNEL_LAYOUT_MONO, |
124 kFiveOneToMonoValues, arraysize(kFiveOneToMonoValues), | 119 kFiveOneToMonoValues, arraysize(kFiveOneToMonoValues), |
125 static_cast<float>(M_SQRT1_2)) | 120 static_cast<float>(M_SQRT1_2)) |
126 )); | 121 )); |
127 | 122 |
128 } // namespace media | 123 } // namespace media |
OLD | NEW |