| 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 #include <vector> | 10 #include <vector> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 void ProcessOneFrame(int sample_rate_hz, | 24 void ProcessOneFrame(int sample_rate_hz, |
| 25 AudioBuffer* render_audio_buffer, | 25 AudioBuffer* render_audio_buffer, |
| 26 AudioBuffer* capture_audio_buffer, | 26 AudioBuffer* capture_audio_buffer, |
| 27 GainControlImpl* gain_controller) { | 27 GainControlImpl* gain_controller) { |
| 28 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { | 28 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { |
| 29 render_audio_buffer->SplitIntoFrequencyBands(); | 29 render_audio_buffer->SplitIntoFrequencyBands(); |
| 30 capture_audio_buffer->SplitIntoFrequencyBands(); | 30 capture_audio_buffer->SplitIntoFrequencyBands(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 gain_controller->ProcessRenderAudio(render_audio_buffer); | 33 gain_controller->ProcessRenderAudio(render_audio_buffer); |
| 34 gain_controller->ReadQueuedRenderData(); |
| 34 gain_controller->AnalyzeCaptureAudio(capture_audio_buffer); | 35 gain_controller->AnalyzeCaptureAudio(capture_audio_buffer); |
| 35 gain_controller->ProcessCaptureAudio(capture_audio_buffer, false); | 36 gain_controller->ProcessCaptureAudio(capture_audio_buffer, false); |
| 36 | 37 |
| 37 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { | 38 if (sample_rate_hz > AudioProcessing::kSampleRate16kHz) { |
| 38 capture_audio_buffer->MergeFrequencyBands(); | 39 capture_audio_buffer->MergeFrequencyBands(); |
| 39 } | 40 } |
| 40 } | 41 } |
| 41 | 42 |
| 42 void SetupComponent(int sample_rate_hz, | 43 void SetupComponent(int sample_rate_hz, |
| 43 GainControl::Mode mode, | 44 GainControl::Mode mode, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 | 227 |
| 227 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 228 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 228 defined(WEBRTC_ANDROID)) | 229 defined(WEBRTC_ANDROID)) |
| 229 TEST(GainControlBitExactnessTest, | 230 TEST(GainControlBitExactnessTest, |
| 230 Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 231 Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 231 #else | 232 #else |
| 232 TEST(GainControlBitExactnessTest, | 233 TEST(GainControlBitExactnessTest, |
| 233 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 234 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 234 #endif | 235 #endif |
| 235 const int kStreamAnalogLevelReference = 50; | 236 const int kStreamAnalogLevelReference = 50; |
| 236 const float kOutputReference[] = {-0.003967f, -0.002808f, -0.001770f}; | 237 const float kOutputReference[] = {-0.003967f, -0.002777f, -0.001770f}; |
| 237 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5, | 238 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5, |
| 238 true, 0, 100, kStreamAnalogLevelReference, | 239 true, 0, 100, kStreamAnalogLevelReference, |
| 239 kOutputReference); | 240 kOutputReference); |
| 240 } | 241 } |
| 241 | 242 |
| 242 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 243 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 243 defined(WEBRTC_ANDROID)) | 244 defined(WEBRTC_ANDROID)) |
| 244 TEST(GainControlBitExactnessTest, | 245 TEST(GainControlBitExactnessTest, |
| 245 Stereo16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 246 Stereo16kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 246 #else | 247 #else |
| (...skipping 10 matching lines...) Expand all Loading... |
| 257 | 258 |
| 258 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 259 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 259 defined(WEBRTC_ANDROID)) | 260 defined(WEBRTC_ANDROID)) |
| 260 TEST(GainControlBitExactnessTest, | 261 TEST(GainControlBitExactnessTest, |
| 261 Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 262 Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 262 #else | 263 #else |
| 263 TEST(GainControlBitExactnessTest, | 264 TEST(GainControlBitExactnessTest, |
| 264 DISABLED_Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 265 DISABLED_Mono32kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 265 #endif | 266 #endif |
| 266 const int kStreamAnalogLevelReference = 50; | 267 const int kStreamAnalogLevelReference = 50; |
| 267 const float kOutputReference[] = {-0.006134f, -0.005554f, -0.005005f}; | 268 const float kOutputReference[] = {-0.006104f, -0.005524f, -0.004974f}; |
| 268 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5, | 269 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5, |
| 269 true, 0, 100, kStreamAnalogLevelReference, | 270 true, 0, 100, kStreamAnalogLevelReference, |
| 270 kOutputReference); | 271 kOutputReference); |
| 271 } | 272 } |
| 272 | 273 |
| 273 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 274 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 274 defined(WEBRTC_ANDROID)) | 275 defined(WEBRTC_ANDROID)) |
| 275 TEST(GainControlBitExactnessTest, | 276 TEST(GainControlBitExactnessTest, |
| 276 Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 277 Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 277 #else | 278 #else |
| 278 TEST(GainControlBitExactnessTest, | 279 TEST(GainControlBitExactnessTest, |
| 279 DISABLED_Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 280 DISABLED_Mono48kHz_AdaptiveDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 280 #endif | 281 #endif |
| 281 const int kStreamAnalogLevelReference = 50; | 282 const int kStreamAnalogLevelReference = 50; |
| 282 const float kOutputReference[] = {-0.006134f, -0.005554f, -0.005005f}; | 283 const float kOutputReference[] = {-0.006104f, -0.005524f, -0.004974f}; |
| 283 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5, | 284 RunBitExactnessTest(32000, 1, GainControl::Mode::kAdaptiveDigital, 10, 50, 5, |
| 284 true, 0, 100, kStreamAnalogLevelReference, | 285 true, 0, 100, kStreamAnalogLevelReference, |
| 285 kOutputReference); | 286 kOutputReference); |
| 286 } | 287 } |
| 287 | 288 |
| 288 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 289 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 289 defined(WEBRTC_ANDROID)) | 290 defined(WEBRTC_ANDROID)) |
| 290 TEST(GainControlBitExactnessTest, | 291 TEST(GainControlBitExactnessTest, |
| 291 Mono8kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 292 Mono8kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 292 #else | 293 #else |
| 293 TEST(GainControlBitExactnessTest, | 294 TEST(GainControlBitExactnessTest, |
| 294 DISABLED_Mono8kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 295 DISABLED_Mono8kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 295 #endif | 296 #endif |
| 296 const int kStreamAnalogLevelReference = 50; | 297 const int kStreamAnalogLevelReference = 50; |
| 297 const float kOutputReference[] = {-0.011871f, -0.004944f, 0.002838f}; | 298 const float kOutputReference[] = {-0.011871f, -0.004944f, 0.002838f}; |
| 298 RunBitExactnessTest(8000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5, | 299 RunBitExactnessTest(8000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5, |
| 299 true, 0, 100, kStreamAnalogLevelReference, | 300 true, 0, 100, kStreamAnalogLevelReference, |
| 300 kOutputReference); | 301 kOutputReference); |
| 301 } | 302 } |
| 302 | 303 |
| 303 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 304 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 304 defined(WEBRTC_ANDROID)) | 305 defined(WEBRTC_ANDROID)) |
| 305 TEST(GainControlBitExactnessTest, | 306 TEST(GainControlBitExactnessTest, |
| 306 Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 307 Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 307 #else | 308 #else |
| 308 TEST(GainControlBitExactnessTest, | 309 TEST(GainControlBitExactnessTest, |
| 309 DISABLED_Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 310 DISABLED_Mono16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 310 #endif | 311 #endif |
| 311 const int kStreamAnalogLevelReference = 50; | 312 const int kStreamAnalogLevelReference = 50; |
| 312 const float kOutputReference[] = {-0.011780f, -0.008270f, -0.005219f}; | 313 const float kOutputReference[] = {-0.011749f, -0.008270f, -0.005219f}; |
| 313 RunBitExactnessTest(16000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5, | 314 RunBitExactnessTest(16000, 1, GainControl::Mode::kFixedDigital, 10, 50, 5, |
| 314 true, 0, 100, kStreamAnalogLevelReference, | 315 true, 0, 100, kStreamAnalogLevelReference, |
| 315 kOutputReference); | 316 kOutputReference); |
| 316 } | 317 } |
| 317 | 318 |
| 318 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 319 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 319 defined(WEBRTC_ANDROID)) | 320 defined(WEBRTC_ANDROID)) |
| 320 TEST(GainControlBitExactnessTest, | 321 TEST(GainControlBitExactnessTest, |
| 321 Stereo16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { | 322 Stereo16kHz_FixedDigital_Tl10_SL50_CG5_Lim_AL0_100) { |
| 322 #else | 323 #else |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 | 379 |
| 379 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 380 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 380 defined(WEBRTC_ANDROID)) | 381 defined(WEBRTC_ANDROID)) |
| 381 TEST(GainControlBitExactnessTest, | 382 TEST(GainControlBitExactnessTest, |
| 382 Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) { | 383 Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) { |
| 383 #else | 384 #else |
| 384 TEST(GainControlBitExactnessTest, | 385 TEST(GainControlBitExactnessTest, |
| 385 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) { | 386 DISABLED_Mono16kHz_AdaptiveAnalog_Tl10_SL100_CG5_Lim_AL70_80) { |
| 386 #endif | 387 #endif |
| 387 const int kStreamAnalogLevelReference = 100; | 388 const int kStreamAnalogLevelReference = 100; |
| 388 const float kOutputReference[] = {-0.004028f, -0.002838f, -0.001801f}; | 389 const float kOutputReference[] = {-0.003998f, -0.002808f, -0.001770f}; |
| 389 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 100, 5, | 390 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveAnalog, 10, 100, 5, |
| 390 true, 70, 80, kStreamAnalogLevelReference, | 391 true, 70, 80, kStreamAnalogLevelReference, |
| 391 kOutputReference); | 392 kOutputReference); |
| 392 } | 393 } |
| 393 | 394 |
| 394 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 395 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 395 defined(WEBRTC_ANDROID)) | 396 defined(WEBRTC_ANDROID)) |
| 396 TEST(GainControlBitExactnessTest, | 397 TEST(GainControlBitExactnessTest, |
| 397 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) { | 398 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) { |
| 398 #else | 399 #else |
| 399 TEST(GainControlBitExactnessTest, | 400 TEST(GainControlBitExactnessTest, |
| 400 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) { | 401 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG5_NoLim_AL0_100) { |
| 401 #endif | 402 #endif |
| 402 const int kStreamAnalogLevelReference = 100; | 403 const int kStreamAnalogLevelReference = 100; |
| 403 const float kOutputReference[] = {-0.004028f, -0.002838f, -0.001801f}; | 404 const float kOutputReference[] = {-0.004028f, -0.002838f, -0.001770f}; |
| 404 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100, 5, | 405 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100, 5, |
| 405 false, 0, 100, kStreamAnalogLevelReference, | 406 false, 0, 100, kStreamAnalogLevelReference, |
| 406 kOutputReference); | 407 kOutputReference); |
| 407 } | 408 } |
| 408 | 409 |
| 409 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 410 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 410 defined(WEBRTC_ANDROID)) | 411 defined(WEBRTC_ANDROID)) |
| 411 TEST(GainControlBitExactnessTest, | 412 TEST(GainControlBitExactnessTest, |
| 412 Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) { | 413 Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) { |
| 413 #else | 414 #else |
| 414 TEST(GainControlBitExactnessTest, | 415 TEST(GainControlBitExactnessTest, |
| 415 DISABLED_Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) { | 416 DISABLED_Mono16kHz_AdaptiveDigital_Tl40_SL100_CG5_Lim_AL0_100) { |
| 416 #endif | 417 #endif |
| 417 const int kStreamAnalogLevelReference = 100; | 418 const int kStreamAnalogLevelReference = 100; |
| 418 const float kOutputReference[] = {-0.008759f, -0.006134f, -0.003876f}; | 419 const float kOutputReference[] = {-0.008728f, -0.006134f, -0.003845f}; |
| 419 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 40, 100, 5, | 420 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 40, 100, 5, |
| 420 true, 0, 100, kStreamAnalogLevelReference, | 421 true, 0, 100, kStreamAnalogLevelReference, |
| 421 kOutputReference); | 422 kOutputReference); |
| 422 } | 423 } |
| 423 | 424 |
| 424 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ | 425 #if !(defined(WEBRTC_ARCH_ARM64) || defined(WEBRTC_ARCH_ARM) || \ |
| 425 defined(WEBRTC_ANDROID)) | 426 defined(WEBRTC_ANDROID)) |
| 426 TEST(GainControlBitExactnessTest, | 427 TEST(GainControlBitExactnessTest, |
| 427 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) { | 428 Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) { |
| 428 #else | 429 #else |
| 429 TEST(GainControlBitExactnessTest, | 430 TEST(GainControlBitExactnessTest, |
| 430 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) { | 431 DISABLED_Mono16kHz_AdaptiveDigital_Tl10_SL100_CG30_Lim_AL0_100) { |
| 431 #endif | 432 #endif |
| 432 const int kStreamAnalogLevelReference = 100; | 433 const int kStreamAnalogLevelReference = 100; |
| 433 const float kOutputReference[] = {-0.006134f, -0.004303f, -0.002716f}; | 434 const float kOutputReference[] = {-0.005859f, -0.004120f, -0.002594f}; |
| 434 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100, | 435 RunBitExactnessTest(16000, 1, GainControl::Mode::kAdaptiveDigital, 10, 100, |
| 435 30, true, 0, 100, kStreamAnalogLevelReference, | 436 30, true, 0, 100, kStreamAnalogLevelReference, |
| 436 kOutputReference); | 437 kOutputReference); |
| 437 } | 438 } |
| 438 | 439 |
| 439 } // namespace webrtc | 440 } // namespace webrtc |
| OLD | NEW |