| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 TEST(FrameCombiner, CombiningZeroFramesShouldProduceSilence) { | 105 TEST(FrameCombiner, CombiningZeroFramesShouldProduceSilence) { |
| 106 FrameCombiner combiner(false); | 106 FrameCombiner combiner(false); |
| 107 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { | 107 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { |
| 108 for (const int number_of_channels : {1, 2}) { | 108 for (const int number_of_channels : {1, 2}) { |
| 109 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 0)); | 109 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 0)); |
| 110 | 110 |
| 111 const std::vector<AudioFrame*> frames_to_combine; | 111 const std::vector<AudioFrame*> frames_to_combine; |
| 112 combiner.Combine(frames_to_combine, number_of_channels, rate, | 112 combiner.Combine(frames_to_combine, number_of_channels, rate, |
| 113 frames_to_combine.size(), &audio_frame_for_mixing); | 113 frames_to_combine.size(), &audio_frame_for_mixing); |
| 114 | 114 |
| 115 const int16_t* audio_frame_for_mixing_data = |
| 116 audio_frame_for_mixing.data(); |
| 115 const std::vector<int16_t> mixed_data( | 117 const std::vector<int16_t> mixed_data( |
| 116 audio_frame_for_mixing.data_, | 118 audio_frame_for_mixing_data, |
| 117 audio_frame_for_mixing.data_ + number_of_channels * rate / 100); | 119 audio_frame_for_mixing_data + number_of_channels * rate / 100); |
| 118 | 120 |
| 119 const std::vector<int16_t> expected(number_of_channels * rate / 100, 0); | 121 const std::vector<int16_t> expected(number_of_channels * rate / 100, 0); |
| 120 EXPECT_EQ(mixed_data, expected); | 122 EXPECT_EQ(mixed_data, expected); |
| 121 } | 123 } |
| 122 } | 124 } |
| 123 } | 125 } |
| 124 | 126 |
| 125 TEST(FrameCombiner, CombiningOneFrameShouldNotChangeFrame) { | 127 TEST(FrameCombiner, CombiningOneFrameShouldNotChangeFrame) { |
| 126 FrameCombiner combiner(false); | 128 FrameCombiner combiner(false); |
| 127 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { | 129 for (const int rate : {8000, 10000, 11000, 32000, 44100}) { |
| 128 for (const int number_of_channels : {1, 2}) { | 130 for (const int number_of_channels : {1, 2}) { |
| 129 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 1)); | 131 SCOPED_TRACE(ProduceDebugText(rate, number_of_channels, 1)); |
| 130 | 132 |
| 131 SetUpFrames(rate, number_of_channels); | 133 SetUpFrames(rate, number_of_channels); |
| 132 std::iota(frame1.data_, frame1.data_ + number_of_channels * rate / 100, | 134 int16_t* frame1_data = frame1.mutable_data(); |
| 133 0); | 135 std::iota(frame1_data, frame1_data + number_of_channels * rate / 100, 0); |
| 134 const std::vector<AudioFrame*> frames_to_combine = {&frame1}; | 136 const std::vector<AudioFrame*> frames_to_combine = {&frame1}; |
| 135 combiner.Combine(frames_to_combine, number_of_channels, rate, | 137 combiner.Combine(frames_to_combine, number_of_channels, rate, |
| 136 frames_to_combine.size(), &audio_frame_for_mixing); | 138 frames_to_combine.size(), &audio_frame_for_mixing); |
| 137 | 139 |
| 140 const int16_t* audio_frame_for_mixing_data = |
| 141 audio_frame_for_mixing.data(); |
| 138 const std::vector<int16_t> mixed_data( | 142 const std::vector<int16_t> mixed_data( |
| 139 audio_frame_for_mixing.data_, | 143 audio_frame_for_mixing_data, |
| 140 audio_frame_for_mixing.data_ + number_of_channels * rate / 100); | 144 audio_frame_for_mixing_data + number_of_channels * rate / 100); |
| 141 | 145 |
| 142 std::vector<int16_t> expected(number_of_channels * rate / 100); | 146 std::vector<int16_t> expected(number_of_channels * rate / 100); |
| 143 std::iota(expected.begin(), expected.end(), 0); | 147 std::iota(expected.begin(), expected.end(), 0); |
| 144 EXPECT_EQ(mixed_data, expected); | 148 EXPECT_EQ(mixed_data, expected); |
| 145 } | 149 } |
| 146 } | 150 } |
| 147 } | 151 } |
| 148 | 152 |
| 149 // Send a sine wave through the FrameCombiner, and check that the | 153 // Send a sine wave through the FrameCombiner, and check that the |
| 150 // difference between input and output varies smoothly. This is to | 154 // difference between input and output varies smoothly. This is to |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 frames_to_combine.push_back(&frame2); | 187 frames_to_combine.push_back(&frame2); |
| 184 } | 188 } |
| 185 const size_t number_of_samples = | 189 const size_t number_of_samples = |
| 186 frame1.samples_per_channel_ * number_of_channels; | 190 frame1.samples_per_channel_ * number_of_channels; |
| 187 | 191 |
| 188 // Ensures limiter is on if 'use_limiter'. | 192 // Ensures limiter is on if 'use_limiter'. |
| 189 constexpr size_t number_of_streams = 2; | 193 constexpr size_t number_of_streams = 2; |
| 190 combiner.Combine(frames_to_combine, number_of_channels, rate, | 194 combiner.Combine(frames_to_combine, number_of_channels, rate, |
| 191 number_of_streams, &audio_frame_for_mixing); | 195 number_of_streams, &audio_frame_for_mixing); |
| 192 cumulative_change += change_calculator.CalculateGainChange( | 196 cumulative_change += change_calculator.CalculateGainChange( |
| 193 rtc::ArrayView<const int16_t>(frame1.data_, number_of_samples), | 197 rtc::ArrayView<const int16_t>(frame1.data(), number_of_samples), |
| 194 rtc::ArrayView<const int16_t>(audio_frame_for_mixing.data_, | 198 rtc::ArrayView<const int16_t>(audio_frame_for_mixing.data(), |
| 195 number_of_samples)); | 199 number_of_samples)); |
| 196 } | 200 } |
| 197 RTC_DCHECK_LT(cumulative_change, 10); | 201 RTC_DCHECK_LT(cumulative_change, 10); |
| 198 } | 202 } |
| 199 } | 203 } |
| 200 } | 204 } |
| 201 } | 205 } |
| 202 } // namespace webrtc | 206 } // namespace webrtc |
| OLD | NEW |