| 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 |
| 28 SCOPED_TRACE(base::StringPrintf( | 33 SCOPED_TRACE(base::StringPrintf( |
| 29 "Input Layout: %d, Output Layout: %d", input_layout, output_layout)); | 34 "Input Layout: %d, Output Layout: %d", input_layout, output_layout)); |
| 30 ChannelMixer mixer(input_layout, output_layout); | 35 ChannelMixer mixer(input_layout, output_layout); |
| 31 scoped_ptr<AudioBus> input_bus = AudioBus::Create( | 36 scoped_ptr<AudioBus> input_bus = AudioBus::Create( |
| 32 ChannelLayoutToChannelCount(input_layout), kFrames); | 37 ChannelLayoutToChannelCount(input_layout), kFrames); |
| 33 scoped_ptr<AudioBus> output_bus = AudioBus::Create( | 38 scoped_ptr<AudioBus> output_bus = AudioBus::Create( |
| 34 ChannelLayoutToChannelCount(output_layout), kFrames); | 39 ChannelLayoutToChannelCount(output_layout), kFrames); |
| 35 for (int ch = 0; ch < input_bus->channels(); ++ch) | 40 for (int ch = 0; ch < input_bus->channels(); ++ch) |
| 36 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames, 1); | 41 std::fill(input_bus->channel(ch), input_bus->channel(ch) + kFrames, 1); |
| 37 | 42 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 0.5f), | 119 0.5f), |
| 115 ChannelMixerTestData(CHANNEL_LAYOUT_MONO, CHANNEL_LAYOUT_STEREO, | 120 ChannelMixerTestData(CHANNEL_LAYOUT_MONO, CHANNEL_LAYOUT_STEREO, |
| 116 kMonoToStereoValues, arraysize(kMonoToStereoValues), | 121 kMonoToStereoValues, arraysize(kMonoToStereoValues), |
| 117 1.0f), | 122 1.0f), |
| 118 ChannelMixerTestData(CHANNEL_LAYOUT_5_1, CHANNEL_LAYOUT_MONO, | 123 ChannelMixerTestData(CHANNEL_LAYOUT_5_1, CHANNEL_LAYOUT_MONO, |
| 119 kFiveOneToMonoValues, arraysize(kFiveOneToMonoValues), | 124 kFiveOneToMonoValues, arraysize(kFiveOneToMonoValues), |
| 120 static_cast<float>(M_SQRT1_2)) | 125 static_cast<float>(M_SQRT1_2)) |
| 121 )); | 126 )); |
| 122 | 127 |
| 123 } // namespace media | 128 } // namespace media |
| OLD | NEW |