Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 79 for (size_t i = 0; i < frame_length; ++i) { | 79 for (size_t i = 0; i < frame_length; ++i) { |
| 80 if (reference_frame[k][i] != frame[k][i]) { | 80 if (reference_frame[k][i] != frame[k][i]) { |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 // Verifies the that samples in the output frame are identical to the samples | |
| 90 // that were produced for the input frame, with an offset in order to compensate | |
| 91 // for buffering delays. | |
| 92 bool VerifyOutputFrameBitexactness(size_t frame_length, | |
| 93 size_t frame_index, | |
| 94 const float* const* frame, | |
| 95 int offset) { | |
| 96 float reference_frame[480]; | |
| 97 | |
| 98 PopulateInputFrame(frame_length, frame_index, reference_frame, offset); | |
| 99 for (size_t i = 0; i < frame_length; ++i) { | |
| 100 if (reference_frame[i] != frame[0][i]) { | |
| 101 return false; | |
| 102 } | |
| 103 } | |
| 104 | |
| 105 return true; | |
| 106 } | |
| 107 | |
| 108 // Class for testing that the capture data is properly received by the block | 89 // Class for testing that the capture data is properly received by the block |
| 109 // processor and that the processor data is properly passed to the | 90 // processor and that the processor data is properly passed to the |
| 110 // EchoCanceller3 output. | 91 // EchoCanceller3 output. |
| 111 class CaptureTransportVerificationProcessor : public BlockProcessor { | 92 class CaptureTransportVerificationProcessor : public BlockProcessor { |
| 112 public: | 93 public: |
| 113 explicit CaptureTransportVerificationProcessor(size_t num_bands) {} | 94 explicit CaptureTransportVerificationProcessor(size_t num_bands) {} |
| 114 ~CaptureTransportVerificationProcessor() override = default; | 95 ~CaptureTransportVerificationProcessor() override = default; |
| 115 | 96 |
| 116 void ProcessCapture(bool level_change, | 97 void ProcessCapture(bool level_change, |
| 117 bool saturated_microphone_signal, | 98 bool saturated_microphone_signal, |
| 118 std::vector<std::vector<float>>* capture_block) override { | 99 std::vector<std::vector<float>>* capture_block) override { |
| 119 } | 100 } |
| 120 | 101 |
| 121 bool BufferRender(std::vector<std::vector<float>>* block) override { | 102 void BufferRender(std::vector<std::vector<float>>* block) override {} |
| 122 return true; | |
| 123 } | |
| 124 | 103 |
| 125 void UpdateEchoLeakageStatus(bool leakage_detected) override {} | 104 void UpdateEchoLeakageStatus(bool leakage_detected) override {} |
| 126 | 105 |
| 127 private: | 106 private: |
| 128 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTransportVerificationProcessor); | 107 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CaptureTransportVerificationProcessor); |
| 129 }; | 108 }; |
| 130 | 109 |
| 131 // Class for testing that the render data is properly received by the block | 110 // Class for testing that the render data is properly received by the block |
| 132 // processor. | 111 // processor. |
| 133 class RenderTransportVerificationProcessor : public BlockProcessor { | 112 class RenderTransportVerificationProcessor : public BlockProcessor { |
| 134 public: | 113 public: |
| 135 explicit RenderTransportVerificationProcessor(size_t num_bands) {} | 114 explicit RenderTransportVerificationProcessor(size_t num_bands) {} |
| 136 ~RenderTransportVerificationProcessor() override = default; | 115 ~RenderTransportVerificationProcessor() override = default; |
| 137 | 116 |
| 138 void ProcessCapture(bool level_change, | 117 void ProcessCapture(bool level_change, |
| 139 bool saturated_microphone_signal, | 118 bool saturated_microphone_signal, |
| 140 std::vector<std::vector<float>>* capture_block) override { | 119 std::vector<std::vector<float>>* capture_block) override { |
| 141 std::vector<std::vector<float>> render_block = | 120 std::vector<std::vector<float>> render_block = |
| 142 received_render_blocks_.front(); | 121 received_render_blocks_.front(); |
| 143 received_render_blocks_.pop_front(); | 122 received_render_blocks_.pop_front(); |
| 144 capture_block->swap(render_block); | 123 capture_block->swap(render_block); |
| 145 } | 124 } |
| 146 | 125 |
| 147 bool BufferRender(std::vector<std::vector<float>>* block) override { | 126 void BufferRender(std::vector<std::vector<float>>* block) override { |
| 148 received_render_blocks_.push_back(*block); | 127 received_render_blocks_.push_back(*block); |
| 149 return true; | |
| 150 } | 128 } |
| 151 | 129 |
| 152 void UpdateEchoLeakageStatus(bool leakage_detected) override {} | 130 void UpdateEchoLeakageStatus(bool leakage_detected) override {} |
| 153 | 131 |
| 154 private: | 132 private: |
| 155 std::deque<std::vector<std::vector<float>>> received_render_blocks_; | 133 std::deque<std::vector<std::vector<float>>> received_render_blocks_; |
| 156 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RenderTransportVerificationProcessor); | 134 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(RenderTransportVerificationProcessor); |
| 157 }; | 135 }; |
| 158 | 136 |
| 159 class EchoCanceller3Tester { | 137 class EchoCanceller3Tester { |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 185 | 163 |
| 186 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; | 164 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; |
| 187 ++frame_index) { | 165 ++frame_index) { |
| 188 aec3.AnalyzeCapture(&capture_buffer_); | 166 aec3.AnalyzeCapture(&capture_buffer_); |
| 189 OptionalBandSplit(); | 167 OptionalBandSplit(); |
| 190 PopulateInputFrame(frame_length_, num_bands_, frame_index, | 168 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 191 &capture_buffer_.split_bands_f(0)[0], 0); | 169 &capture_buffer_.split_bands_f(0)[0], 0); |
| 192 PopulateInputFrame(frame_length_, frame_index, | 170 PopulateInputFrame(frame_length_, frame_index, |
| 193 &render_buffer_.channels_f()[0][0], 0); | 171 &render_buffer_.channels_f()[0][0], 0); |
| 194 | 172 |
| 195 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 173 aec3.AnalyzeRender(&render_buffer_); |
| 196 aec3.ProcessCapture(&capture_buffer_, false); | 174 aec3.ProcessCapture(&capture_buffer_, false); |
| 197 EXPECT_TRUE(VerifyOutputFrameBitexactness( | 175 EXPECT_TRUE(VerifyOutputFrameBitexactness( |
| 198 frame_length_, num_bands_, frame_index, | 176 frame_length_, num_bands_, frame_index, |
| 199 &capture_buffer_.split_bands_f(0)[0], -64)); | 177 &capture_buffer_.split_bands_f(0)[0], -64)); |
| 200 } | 178 } |
| 201 } | 179 } |
| 202 | 180 |
| 203 // Test method for testing that the render data is properly received by the | 181 // Test method for testing that the render data is properly received by the |
| 204 // block processor. | 182 // block processor. |
| 205 void RunRenderTransportVerificationTest() { | 183 void RunRenderTransportVerificationTest() { |
| 206 EchoCanceller3 aec3( | 184 EchoCanceller3 aec3( |
| 207 sample_rate_hz_, false, | 185 sample_rate_hz_, false, |
| 208 std::unique_ptr<BlockProcessor>( | 186 std::unique_ptr<BlockProcessor>( |
| 209 new RenderTransportVerificationProcessor(num_bands_))); | 187 new RenderTransportVerificationProcessor(num_bands_))); |
| 210 | 188 |
| 211 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; | 189 for (size_t frame_index = 0; frame_index < kNumFramesToProcess; |
| 212 ++frame_index) { | 190 ++frame_index) { |
| 213 aec3.AnalyzeCapture(&capture_buffer_); | 191 aec3.AnalyzeCapture(&capture_buffer_); |
| 214 OptionalBandSplit(); | 192 OptionalBandSplit(); |
| 215 PopulateInputFrame(frame_length_, num_bands_, frame_index, | 193 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 216 &capture_buffer_.split_bands_f(0)[0], 100); | 194 &capture_buffer_.split_bands_f(0)[0], 100); |
| 217 PopulateInputFrame(frame_length_, frame_index, | 195 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 218 &render_buffer_.channels_f()[0][0], 0); | 196 &render_buffer_.split_bands_f(0)[0], 0); |
| 219 | 197 |
| 220 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 198 aec3.AnalyzeRender(&render_buffer_); |
| 221 aec3.ProcessCapture(&capture_buffer_, false); | 199 aec3.ProcessCapture(&capture_buffer_, false); |
| 222 EXPECT_TRUE(VerifyOutputFrameBitexactness( | 200 EXPECT_TRUE(VerifyOutputFrameBitexactness( |
| 223 frame_length_, frame_index, &capture_buffer_.split_bands_f(0)[0], | 201 frame_length_, num_bands_, frame_index, |
| 224 -64)); | 202 &capture_buffer_.split_bands_f(0)[0], -64)); |
| 225 } | 203 } |
| 226 } | 204 } |
| 227 | 205 |
| 228 // Verifies that information about echo path changes are properly propagated | 206 // Verifies that information about echo path changes are properly propagated |
| 229 // to the block processor. | 207 // to the block processor. |
| 230 // The cases tested are: | 208 // The cases tested are: |
| 231 // -That no set echo path change flags are received when there is no echo path | 209 // -That no set echo path change flags are received when there is no echo path |
| 232 // change. | 210 // change. |
| 233 // -That set echo path change flags are received and continues to be received | 211 // -That set echo path change flags are received and continues to be received |
| 234 // as long as echo path changes are flagged. | 212 // as long as echo path changes are flagged. |
| 235 // -That set echo path change flags are no longer received when echo path | 213 // -That set echo path change flags are no longer received when echo path |
| 236 // change events stop being flagged. | 214 // change events stop being flagged. |
| 237 enum class EchoPathChangeTestVariant { kNone, kOneSticky, kOneNonSticky }; | 215 enum class EchoPathChangeTestVariant { kNone, kOneSticky, kOneNonSticky }; |
| 238 | 216 |
| 239 void RunEchoPathChangeVerificationTest( | 217 void RunEchoPathChangeVerificationTest( |
| 240 EchoPathChangeTestVariant echo_path_change_test_variant) { | 218 EchoPathChangeTestVariant echo_path_change_test_variant) { |
| 241 const size_t num_full_blocks_per_frame = | 219 const size_t num_full_blocks_per_frame = |
| 242 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100) / kBlockSize; | 220 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100) / kBlockSize; |
| 243 const size_t expected_num_block_to_process = | 221 const size_t expected_num_block_to_process = |
| 244 (kNumFramesToProcess * | 222 (kNumFramesToProcess * |
| 245 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100)) / | 223 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100)) / |
| 246 kBlockSize; | 224 kBlockSize; |
| 247 std::unique_ptr<testing::StrictMock<webrtc::test::MockBlockProcessor>> | 225 std::unique_ptr<testing::StrictMock<webrtc::test::MockBlockProcessor>> |
| 248 block_processor_mock( | 226 block_processor_mock( |
| 249 new StrictMock<webrtc::test::MockBlockProcessor>()); | 227 new StrictMock<webrtc::test::MockBlockProcessor>()); |
| 250 EXPECT_CALL(*block_processor_mock, BufferRender(_)) | 228 EXPECT_CALL(*block_processor_mock, BufferRender(_)) |
| 251 .Times(expected_num_block_to_process) | 229 .Times(expected_num_block_to_process); |
| 252 .WillRepeatedly(Return(true)); | |
| 253 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); | 230 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); |
| 254 | 231 |
| 255 switch (echo_path_change_test_variant) { | 232 switch (echo_path_change_test_variant) { |
| 256 case EchoPathChangeTestVariant::kNone: | 233 case EchoPathChangeTestVariant::kNone: |
| 257 EXPECT_CALL(*block_processor_mock, ProcessCapture(false, _, _)) | 234 EXPECT_CALL(*block_processor_mock, ProcessCapture(false, _, _)) |
| 258 .Times(expected_num_block_to_process); | 235 .Times(expected_num_block_to_process); |
| 259 break; | 236 break; |
| 260 case EchoPathChangeTestVariant::kOneSticky: | 237 case EchoPathChangeTestVariant::kOneSticky: |
| 261 EXPECT_CALL(*block_processor_mock, ProcessCapture(true, _, _)) | 238 EXPECT_CALL(*block_processor_mock, ProcessCapture(true, _, _)) |
| 262 .Times(expected_num_block_to_process); | 239 .Times(expected_num_block_to_process); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 289 } | 266 } |
| 290 | 267 |
| 291 aec3.AnalyzeCapture(&capture_buffer_); | 268 aec3.AnalyzeCapture(&capture_buffer_); |
| 292 OptionalBandSplit(); | 269 OptionalBandSplit(); |
| 293 | 270 |
| 294 PopulateInputFrame(frame_length_, num_bands_, frame_index, | 271 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 295 &capture_buffer_.split_bands_f(0)[0], 0); | 272 &capture_buffer_.split_bands_f(0)[0], 0); |
| 296 PopulateInputFrame(frame_length_, frame_index, | 273 PopulateInputFrame(frame_length_, frame_index, |
| 297 &render_buffer_.channels_f()[0][0], 0); | 274 &render_buffer_.channels_f()[0][0], 0); |
| 298 | 275 |
| 299 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 276 aec3.AnalyzeRender(&render_buffer_); |
| 300 aec3.ProcessCapture(&capture_buffer_, echo_path_change); | 277 aec3.ProcessCapture(&capture_buffer_, echo_path_change); |
| 301 } | 278 } |
| 302 } | 279 } |
| 303 | 280 |
| 304 // Test for verifying that echo leakage information is being properly passed | 281 // Test for verifying that echo leakage information is being properly passed |
| 305 // to the processor. | 282 // to the processor. |
| 306 // The cases tested are: | 283 // The cases tested are: |
| 307 // -That no method calls are received when they should not. | 284 // -That no method calls are received when they should not. |
| 308 // -That false values are received each time they are flagged. | 285 // -That false values are received each time they are flagged. |
| 309 // -That true values are received each time they are flagged. | 286 // -That true values are received each time they are flagged. |
| 310 // -That a false value is received when flagged after a true value has been | 287 // -That a false value is received when flagged after a true value has been |
| 311 // flagged. | 288 // flagged. |
| 312 enum class EchoLeakageTestVariant { | 289 enum class EchoLeakageTestVariant { |
| 313 kNone, | 290 kNone, |
| 314 kFalseSticky, | 291 kFalseSticky, |
| 315 kTrueSticky, | 292 kTrueSticky, |
| 316 kTrueNonSticky | 293 kTrueNonSticky |
| 317 }; | 294 }; |
| 318 | 295 |
| 319 void RunEchoLeakageVerificationTest( | 296 void RunEchoLeakageVerificationTest( |
| 320 EchoLeakageTestVariant leakage_report_variant) { | 297 EchoLeakageTestVariant leakage_report_variant) { |
| 321 const size_t expected_num_block_to_process = | 298 const size_t expected_num_block_to_process = |
| 322 (kNumFramesToProcess * | 299 (kNumFramesToProcess * |
| 323 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100)) / | 300 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100)) / |
| 324 kBlockSize; | 301 kBlockSize; |
| 325 std::unique_ptr<testing::StrictMock<webrtc::test::MockBlockProcessor>> | 302 std::unique_ptr<testing::StrictMock<webrtc::test::MockBlockProcessor>> |
| 326 block_processor_mock( | 303 block_processor_mock( |
| 327 new StrictMock<webrtc::test::MockBlockProcessor>()); | 304 new StrictMock<webrtc::test::MockBlockProcessor>()); |
| 328 EXPECT_CALL(*block_processor_mock, BufferRender(_)) | 305 EXPECT_CALL(*block_processor_mock, BufferRender(_)) |
| 329 .Times(expected_num_block_to_process) | 306 .Times(expected_num_block_to_process); |
| 330 .WillRepeatedly(Return(true)); | |
| 331 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, _, _)) | 307 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, _, _)) |
| 332 .Times(expected_num_block_to_process); | 308 .Times(expected_num_block_to_process); |
| 333 | 309 |
| 334 switch (leakage_report_variant) { | 310 switch (leakage_report_variant) { |
| 335 case EchoLeakageTestVariant::kNone: | 311 case EchoLeakageTestVariant::kNone: |
| 336 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); | 312 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); |
| 337 break; | 313 break; |
| 338 case EchoLeakageTestVariant::kFalseSticky: | 314 case EchoLeakageTestVariant::kFalseSticky: |
| 339 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(false)) | 315 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(false)) |
| 340 .Times(1); | 316 .Times(1); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 } | 356 } |
| 381 | 357 |
| 382 aec3.AnalyzeCapture(&capture_buffer_); | 358 aec3.AnalyzeCapture(&capture_buffer_); |
| 383 OptionalBandSplit(); | 359 OptionalBandSplit(); |
| 384 | 360 |
| 385 PopulateInputFrame(frame_length_, num_bands_, frame_index, | 361 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 386 &capture_buffer_.split_bands_f(0)[0], 0); | 362 &capture_buffer_.split_bands_f(0)[0], 0); |
| 387 PopulateInputFrame(frame_length_, frame_index, | 363 PopulateInputFrame(frame_length_, frame_index, |
| 388 &render_buffer_.channels_f()[0][0], 0); | 364 &render_buffer_.channels_f()[0][0], 0); |
| 389 | 365 |
| 390 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 366 aec3.AnalyzeRender(&render_buffer_); |
| 391 aec3.ProcessCapture(&capture_buffer_, false); | 367 aec3.ProcessCapture(&capture_buffer_, false); |
| 392 } | 368 } |
| 393 } | 369 } |
| 394 | 370 |
| 395 // This verifies that saturation information is properly passed to the | 371 // This verifies that saturation information is properly passed to the |
| 396 // BlockProcessor. | 372 // BlockProcessor. |
| 397 // The cases tested are: | 373 // The cases tested are: |
| 398 // -That no saturation event is passed to the processor if there is no | 374 // -That no saturation event is passed to the processor if there is no |
| 399 // saturation. | 375 // saturation. |
| 400 // -That one frame with one negative saturated sample value is reported to be | 376 // -That one frame with one negative saturated sample value is reported to be |
| 401 // saturated and that following non-saturated frames are properly reported as | 377 // saturated and that following non-saturated frames are properly reported as |
| 402 // not being saturated. | 378 // not being saturated. |
| 403 // -That one frame with one positive saturated sample value is reported to be | 379 // -That one frame with one positive saturated sample value is reported to be |
| 404 // saturated and that following non-saturated frames are properly reported as | 380 // saturated and that following non-saturated frames are properly reported as |
| 405 // not being saturated. | 381 // not being saturated. |
| 406 enum class SaturationTestVariant { kNone, kOneNegative, kOnePositive }; | 382 enum class SaturationTestVariant { kNone, kOneNegative, kOnePositive }; |
| 407 | 383 |
| 408 void RunCaptureSaturationVerificationTest( | 384 void RunCaptureSaturationVerificationTest( |
| 409 SaturationTestVariant saturation_variant) { | 385 SaturationTestVariant saturation_variant) { |
| 410 const size_t num_full_blocks_per_frame = | 386 const size_t num_full_blocks_per_frame = |
| 411 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100) / kBlockSize; | 387 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100) / kBlockSize; |
| 412 const size_t expected_num_block_to_process = | 388 const size_t expected_num_block_to_process = |
| 413 (kNumFramesToProcess * | 389 (kNumFramesToProcess * |
| 414 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100)) / | 390 rtc::CheckedDivExact(LowestBandRate(sample_rate_hz_), 100)) / |
| 415 kBlockSize; | 391 kBlockSize; |
| 416 std::unique_ptr<testing::StrictMock<webrtc::test::MockBlockProcessor>> | 392 std::unique_ptr<testing::StrictMock<webrtc::test::MockBlockProcessor>> |
| 417 block_processor_mock( | 393 block_processor_mock( |
| 418 new StrictMock<webrtc::test::MockBlockProcessor>()); | 394 new StrictMock<webrtc::test::MockBlockProcessor>()); |
| 419 EXPECT_CALL(*block_processor_mock, BufferRender(_)) | 395 EXPECT_CALL(*block_processor_mock, BufferRender(_)) |
| 420 .Times(expected_num_block_to_process) | 396 .Times(expected_num_block_to_process); |
| 421 .WillRepeatedly(Return(true)); | |
| 422 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); | 397 EXPECT_CALL(*block_processor_mock, UpdateEchoLeakageStatus(_)).Times(0); |
| 423 | 398 |
| 424 switch (saturation_variant) { | 399 switch (saturation_variant) { |
| 425 case SaturationTestVariant::kNone: | 400 case SaturationTestVariant::kNone: |
| 426 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, false, _)) | 401 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, false, _)) |
| 427 .Times(expected_num_block_to_process); | 402 .Times(expected_num_block_to_process); |
| 428 break; | 403 break; |
| 429 case SaturationTestVariant::kOneNegative: { | 404 case SaturationTestVariant::kOneNegative: { |
| 430 testing::InSequence s; | 405 testing::InSequence s; |
| 431 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, true, _)) | 406 EXPECT_CALL(*block_processor_mock, ProcessCapture(_, true, _)) |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 462 capture_buffer_.channels_f()[0][10] = 32767.f; | 437 capture_buffer_.channels_f()[0][10] = 32767.f; |
| 463 } | 438 } |
| 464 break; | 439 break; |
| 465 } | 440 } |
| 466 | 441 |
| 467 aec3.AnalyzeCapture(&capture_buffer_); | 442 aec3.AnalyzeCapture(&capture_buffer_); |
| 468 OptionalBandSplit(); | 443 OptionalBandSplit(); |
| 469 | 444 |
| 470 PopulateInputFrame(frame_length_, num_bands_, frame_index, | 445 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 471 &capture_buffer_.split_bands_f(0)[0], 0); | 446 &capture_buffer_.split_bands_f(0)[0], 0); |
| 472 PopulateInputFrame(frame_length_, frame_index, | 447 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 473 &render_buffer_.channels_f()[0][0], 0); | 448 &render_buffer_.split_bands_f(0)[0], 0); |
| 474 | 449 |
| 475 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 450 aec3.AnalyzeRender(&render_buffer_); |
| 476 aec3.ProcessCapture(&capture_buffer_, false); | 451 aec3.ProcessCapture(&capture_buffer_, false); |
| 477 } | 452 } |
| 478 } | 453 } |
| 479 | 454 |
| 480 // This test verifies that the swapqueue is able to handle jitter in the | 455 // This test verifies that the swapqueue is able to handle jitter in the |
| 481 // capture and render API calls. | 456 // capture and render API calls. |
| 482 void RunRenderSwapQueueVerificationTest() { | 457 void RunRenderSwapQueueVerificationTest() { |
| 483 EchoCanceller3 aec3( | 458 EchoCanceller3 aec3( |
| 484 sample_rate_hz_, false, | 459 sample_rate_hz_, false, |
| 485 std::unique_ptr<BlockProcessor>( | 460 std::unique_ptr<BlockProcessor>( |
| 486 new RenderTransportVerificationProcessor(num_bands_))); | 461 new RenderTransportVerificationProcessor(num_bands_))); |
| 487 | 462 |
| 488 constexpr size_t kSwapQueueLength = 30; | 463 for (size_t frame_index = 0; frame_index < kRenderTransferQueueSize; |
| 489 for (size_t frame_index = 0; frame_index < kSwapQueueLength; | |
| 490 ++frame_index) { | 464 ++frame_index) { |
| 491 if (sample_rate_hz_ > 16000) { | 465 if (sample_rate_hz_ > 16000) { |
| 492 render_buffer_.SplitIntoFrequencyBands(); | 466 render_buffer_.SplitIntoFrequencyBands(); |
| 493 } | 467 } |
| 494 PopulateInputFrame(frame_length_, frame_index, | 468 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 495 &render_buffer_.channels_f()[0][0], 0); | 469 &render_buffer_.split_bands_f(0)[0], 0); |
| 496 | 470 |
| 497 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 471 if (sample_rate_hz_ > 16000) { |
| 472 render_buffer_.SplitIntoFrequencyBands(); | |
| 473 } | |
| 474 | |
| 475 aec3.AnalyzeRender(&render_buffer_); | |
| 498 } | 476 } |
| 499 | 477 |
| 500 for (size_t frame_index = 0; frame_index < kSwapQueueLength; | 478 for (size_t frame_index = 0; frame_index < kRenderTransferQueueSize; |
| 501 ++frame_index) { | 479 ++frame_index) { |
| 502 aec3.AnalyzeCapture(&capture_buffer_); | 480 aec3.AnalyzeCapture(&capture_buffer_); |
| 503 if (sample_rate_hz_ > 16000) { | 481 if (sample_rate_hz_ > 16000) { |
| 504 capture_buffer_.SplitIntoFrequencyBands(); | 482 capture_buffer_.SplitIntoFrequencyBands(); |
| 505 } | 483 } |
| 506 | 484 |
| 507 PopulateInputFrame(frame_length_, num_bands_, frame_index, | 485 PopulateInputFrame(frame_length_, num_bands_, frame_index, |
| 508 &capture_buffer_.split_bands_f(0)[0], 0); | 486 &capture_buffer_.split_bands_f(0)[0], 0); |
| 509 | 487 |
| 510 aec3.ProcessCapture(&capture_buffer_, false); | 488 aec3.ProcessCapture(&capture_buffer_, false); |
| 511 EXPECT_TRUE(VerifyOutputFrameBitexactness( | 489 EXPECT_TRUE(VerifyOutputFrameBitexactness( |
| 512 frame_length_, frame_index, &capture_buffer_.split_bands_f(0)[0], | 490 frame_length_, num_bands_, frame_index, |
| 513 -64)); | 491 &capture_buffer_.split_bands_f(0)[0], -64)); |
| 514 } | 492 } |
| 515 } | 493 } |
| 516 | 494 |
| 517 // This test verifies that a buffer overrun in the render swapqueue is | 495 // This test verifies that a buffer overrun in the render swapqueue is |
| 518 // properly reported. | 496 // properly reported. |
| 519 void RunRenderPipelineSwapQueueOverrunReturnValueTest() { | 497 void RunRenderPipelineSwapQueueOverrunReturnValueTest() { |
| 520 EchoCanceller3 aec3(sample_rate_hz_, false); | 498 EchoCanceller3 aec3(sample_rate_hz_, false); |
| 521 | 499 |
| 522 constexpr size_t kSwapQueueLength = 30; | 500 constexpr size_t kRenderTransferQueueSize = 30; |
| 523 for (size_t k = 0; k < 2; ++k) { | 501 for (size_t k = 0; k < 2; ++k) { |
| 524 for (size_t frame_index = 0; frame_index < kSwapQueueLength; | 502 for (size_t frame_index = 0; frame_index < kRenderTransferQueueSize; |
| 525 ++frame_index) { | 503 ++frame_index) { |
| 526 if (sample_rate_hz_ > 16000) { | 504 if (sample_rate_hz_ > 16000) { |
| 527 render_buffer_.SplitIntoFrequencyBands(); | 505 render_buffer_.SplitIntoFrequencyBands(); |
| 528 } | 506 } |
| 529 PopulateInputFrame(frame_length_, frame_index, | 507 PopulateInputFrame(frame_length_, frame_index, |
| 530 &render_buffer_.channels_f()[0][0], 0); | 508 &render_buffer_.channels_f()[0][0], 0); |
| 531 | 509 |
| 532 if (k == 0) { | 510 if (k == 0) { |
| 533 EXPECT_TRUE(aec3.AnalyzeRender(&render_buffer_)); | 511 aec3.AnalyzeRender(&render_buffer_); |
| 534 } else { | 512 } else { |
| 535 EXPECT_FALSE(aec3.AnalyzeRender(&render_buffer_)); | 513 aec3.AnalyzeRender(&render_buffer_); |
| 536 } | 514 } |
| 537 } | 515 } |
| 538 } | 516 } |
| 539 } | 517 } |
| 540 | 518 |
| 541 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) | 519 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID) |
| 542 // Verifies the that the check for the number of bands in the AnalyzeRender | 520 // Verifies the that the check for the number of bands in the AnalyzeRender |
| 543 // input is correct by adjusting the sample rates of EchoCanceller3 and the | 521 // input is correct by adjusting the sample rates of EchoCanceller3 and the |
| 544 // input AudioBuffer to have a different number of bands. | 522 // input AudioBuffer to have a different number of bands. |
| 545 void RunAnalyzeRenderNumBandsCheckVerification() { | 523 void RunAnalyzeRenderNumBandsCheckVerification() { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 } | 617 } |
| 640 | 618 |
| 641 TEST(EchoCanceller3Buffering, RenderBitexactness) { | 619 TEST(EchoCanceller3Buffering, RenderBitexactness) { |
| 642 for (auto rate : {8000, 16000, 32000, 48000}) { | 620 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 643 SCOPED_TRACE(ProduceDebugText(rate)); | 621 SCOPED_TRACE(ProduceDebugText(rate)); |
| 644 EchoCanceller3Tester(rate).RunRenderTransportVerificationTest(); | 622 EchoCanceller3Tester(rate).RunRenderTransportVerificationTest(); |
| 645 } | 623 } |
| 646 } | 624 } |
| 647 | 625 |
| 648 TEST(EchoCanceller3Buffering, RenderSwapQueue) { | 626 TEST(EchoCanceller3Buffering, RenderSwapQueue) { |
| 649 for (auto rate : {8000, 16000, 32000, 48000}) { | 627 for (auto rate : {8000, 16000}) { |
|
peah-webrtc
2017/03/30 05:36:56
I chose to simply remove the multi-band rates, as
| |
| 650 SCOPED_TRACE(ProduceDebugText(rate)); | 628 SCOPED_TRACE(ProduceDebugText(rate)); |
| 651 EchoCanceller3Tester(rate).RunRenderSwapQueueVerificationTest(); | 629 EchoCanceller3Tester(rate).RunRenderSwapQueueVerificationTest(); |
| 652 } | 630 } |
| 653 } | 631 } |
| 654 | 632 |
| 655 TEST(EchoCanceller3Buffering, RenderSwapQueueOverrunReturnValue) { | 633 TEST(EchoCanceller3Buffering, RenderSwapQueueOverrunReturnValue) { |
| 656 for (auto rate : {8000, 16000, 32000, 48000}) { | 634 for (auto rate : {8000, 16000, 32000, 48000}) { |
| 657 SCOPED_TRACE(ProduceDebugText(rate)); | 635 SCOPED_TRACE(ProduceDebugText(rate)); |
| 658 EchoCanceller3Tester(rate) | 636 EchoCanceller3Tester(rate) |
| 659 .RunRenderPipelineSwapQueueOverrunReturnValueTest(); | 637 .RunRenderPipelineSwapQueueOverrunReturnValueTest(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 745 | 723 |
| 746 // Verifies the check for correct sample rate. | 724 // Verifies the check for correct sample rate. |
| 747 TEST(EchoCanceller3InputCheck, WrongSampleRate) { | 725 TEST(EchoCanceller3InputCheck, WrongSampleRate) { |
| 748 ApmDataDumper data_dumper(0); | 726 ApmDataDumper data_dumper(0); |
| 749 EXPECT_DEATH(EchoCanceller3(8001, false), ""); | 727 EXPECT_DEATH(EchoCanceller3(8001, false), ""); |
| 750 } | 728 } |
| 751 | 729 |
| 752 #endif | 730 #endif |
| 753 | 731 |
| 754 } // namespace webrtc | 732 } // namespace webrtc |
| OLD | NEW |