Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 | 55 |
| 56 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) | 56 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) |
| 57 // AECM doesn't support super-wb. | 57 // AECM doesn't support super-wb. |
| 58 const int kProcessSampleRates[] = {8000, 16000}; | 58 const int kProcessSampleRates[] = {8000, 16000}; |
| 59 #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 59 #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) |
| 60 const int kProcessSampleRates[] = {8000, 16000, 32000, 48000}; | 60 const int kProcessSampleRates[] = {8000, 16000, 32000, 48000}; |
| 61 #endif | 61 #endif |
| 62 const size_t kProcessSampleRatesSize = sizeof(kProcessSampleRates) / | 62 const size_t kProcessSampleRatesSize = sizeof(kProcessSampleRates) / |
| 63 sizeof(*kProcessSampleRates); | 63 sizeof(*kProcessSampleRates); |
| 64 | 64 |
| 65 enum StreamDirection { kForward = 0, kReverse }; | |
| 66 | |
| 65 void ConvertToFloat(const int16_t* int_data, ChannelBuffer<float>* cb) { | 67 void ConvertToFloat(const int16_t* int_data, ChannelBuffer<float>* cb) { |
| 66 ChannelBuffer<int16_t> cb_int(cb->num_frames(), | 68 ChannelBuffer<int16_t> cb_int(cb->num_frames(), |
| 67 cb->num_channels()); | 69 cb->num_channels()); |
| 68 Deinterleave(int_data, | 70 Deinterleave(int_data, |
| 69 cb->num_frames(), | 71 cb->num_frames(), |
| 70 cb->num_channels(), | 72 cb->num_channels(), |
| 71 cb_int.channels()); | 73 cb_int.channels()); |
| 72 for (int i = 0; i < cb->num_channels(); ++i) { | 74 for (int i = 0; i < cb->num_channels(); ++i) { |
| 73 S16ToFloat(cb_int.channels()[i], | 75 S16ToFloat(cb_int.channels()[i], |
| 74 cb->num_frames(), | 76 cb->num_frames(), |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 } | 247 } |
| 246 | 248 |
| 247 // Temporary filenames unique to this process. Used to be able to run these | 249 // Temporary filenames unique to this process. Used to be able to run these |
| 248 // tests in parallel as each process needs to be running in isolation they can't | 250 // tests in parallel as each process needs to be running in isolation they can't |
| 249 // have competing filenames. | 251 // have competing filenames. |
| 250 std::map<std::string, std::string> temp_filenames; | 252 std::map<std::string, std::string> temp_filenames; |
| 251 | 253 |
| 252 std::string OutputFilePath(std::string name, | 254 std::string OutputFilePath(std::string name, |
| 253 int input_rate, | 255 int input_rate, |
| 254 int output_rate, | 256 int output_rate, |
| 255 int reverse_rate, | 257 int reverse_input_rate, |
| 258 int reverse_output_rate, | |
| 256 int num_input_channels, | 259 int num_input_channels, |
| 257 int num_output_channels, | 260 int num_output_channels, |
| 258 int num_reverse_channels) { | 261 int num_reverse_input_channels, |
| 262 int num_reverse_output_channels, | |
| 263 StreamDirection file_direction) { | |
| 259 std::ostringstream ss; | 264 std::ostringstream ss; |
| 260 ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 | 265 ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 << "_ir" |
| 261 << "_r" << num_reverse_channels << "_" << reverse_rate / 1000 << "_"; | 266 << num_reverse_input_channels << "_" << reverse_input_rate / 1000 << "_"; |
| 262 if (num_output_channels == 1) { | 267 if (num_output_channels == 1) { |
| 263 ss << "mono"; | 268 ss << "mono"; |
| 264 } else if (num_output_channels == 2) { | 269 } else if (num_output_channels == 2) { |
| 265 ss << "stereo"; | 270 ss << "stereo"; |
| 266 } else { | 271 } else { |
| 267 assert(false); | 272 assert(false); |
| 268 } | 273 } |
| 269 ss << output_rate / 1000 << "_pcm"; | 274 ss << output_rate / 1000; |
| 275 if (num_reverse_output_channels == 1) { | |
| 276 ss << "_rmono"; | |
| 277 } else if (num_reverse_output_channels == 2) { | |
| 278 ss << "_rstereo"; | |
| 279 } else { | |
| 280 assert(false); | |
| 281 } | |
| 282 ss << reverse_output_rate / 1000; | |
| 283 ss << "_d" << file_direction << "_pcm"; | |
| 270 | 284 |
| 271 std::string filename = ss.str(); | 285 std::string filename = ss.str(); |
| 272 if (temp_filenames[filename].empty()) | 286 if (temp_filenames[filename].empty()) |
| 273 temp_filenames[filename] = test::TempFilename(test::OutputPath(), filename); | 287 temp_filenames[filename] = test::TempFilename(test::OutputPath(), filename); |
| 274 return temp_filenames[filename]; | 288 return temp_filenames[filename]; |
| 275 } | 289 } |
| 276 | 290 |
| 277 void ClearTempFiles() { | 291 void ClearTempFiles() { |
| 278 for (auto& kv : temp_filenames) | 292 for (auto& kv : temp_filenames) |
| 279 remove(kv.second.c_str()); | 293 remove(kv.second.c_str()); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 333 | 347 |
| 334 // Used to select between int and float interface tests. | 348 // Used to select between int and float interface tests. |
| 335 enum Format { | 349 enum Format { |
| 336 kIntFormat, | 350 kIntFormat, |
| 337 kFloatFormat | 351 kFloatFormat |
| 338 }; | 352 }; |
| 339 | 353 |
| 340 void Init(int sample_rate_hz, | 354 void Init(int sample_rate_hz, |
| 341 int output_sample_rate_hz, | 355 int output_sample_rate_hz, |
| 342 int reverse_sample_rate_hz, | 356 int reverse_sample_rate_hz, |
| 343 int num_reverse_channels, | |
| 344 int num_input_channels, | 357 int num_input_channels, |
| 345 int num_output_channels, | 358 int num_output_channels, |
| 359 int num_reverse_channels, | |
| 346 bool open_output_file); | 360 bool open_output_file); |
| 347 void Init(AudioProcessing* ap); | 361 void Init(AudioProcessing* ap); |
| 348 void EnableAllComponents(); | 362 void EnableAllComponents(); |
| 349 bool ReadFrame(FILE* file, AudioFrame* frame); | 363 bool ReadFrame(FILE* file, AudioFrame* frame); |
| 350 bool ReadFrame(FILE* file, AudioFrame* frame, ChannelBuffer<float>* cb); | 364 bool ReadFrame(FILE* file, AudioFrame* frame, ChannelBuffer<float>* cb); |
| 351 void ReadFrameWithRewind(FILE* file, AudioFrame* frame); | 365 void ReadFrameWithRewind(FILE* file, AudioFrame* frame); |
| 352 void ReadFrameWithRewind(FILE* file, AudioFrame* frame, | 366 void ReadFrameWithRewind(FILE* file, AudioFrame* frame, |
| 353 ChannelBuffer<float>* cb); | 367 ChannelBuffer<float>* cb); |
| 354 void ProcessWithDefaultStreamParameters(AudioFrame* frame); | 368 void ProcessWithDefaultStreamParameters(AudioFrame* frame); |
| 355 void ProcessDelayVerificationTest(int delay_ms, int system_delay_ms, | 369 void ProcessDelayVerificationTest(int delay_ms, int system_delay_ms, |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 ASSERT_EQ(0, fclose(out_file_)); | 465 ASSERT_EQ(0, fclose(out_file_)); |
| 452 } | 466 } |
| 453 out_file_ = NULL; | 467 out_file_ = NULL; |
| 454 } | 468 } |
| 455 | 469 |
| 456 void ApmTest::Init(AudioProcessing* ap) { | 470 void ApmTest::Init(AudioProcessing* ap) { |
| 457 ASSERT_EQ(kNoErr, | 471 ASSERT_EQ(kNoErr, |
| 458 ap->Initialize( | 472 ap->Initialize( |
| 459 {{{frame_->sample_rate_hz_, frame_->num_channels_}, | 473 {{{frame_->sample_rate_hz_, frame_->num_channels_}, |
| 460 {output_sample_rate_hz_, num_output_channels_}, | 474 {output_sample_rate_hz_, num_output_channels_}, |
| 475 {revframe_->sample_rate_hz_, revframe_->num_channels_}, | |
| 461 {revframe_->sample_rate_hz_, revframe_->num_channels_}}})); | 476 {revframe_->sample_rate_hz_, revframe_->num_channels_}}})); |
| 462 } | 477 } |
| 463 | 478 |
| 464 void ApmTest::Init(int sample_rate_hz, | 479 void ApmTest::Init(int sample_rate_hz, |
| 465 int output_sample_rate_hz, | 480 int output_sample_rate_hz, |
| 466 int reverse_sample_rate_hz, | 481 int reverse_sample_rate_hz, |
| 467 int num_input_channels, | 482 int num_input_channels, |
| 468 int num_output_channels, | 483 int num_output_channels, |
| 469 int num_reverse_channels, | 484 int num_reverse_channels, |
| 470 bool open_output_file) { | 485 bool open_output_file) { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 489 } | 504 } |
| 490 filename = ResourceFilePath("near", sample_rate_hz); | 505 filename = ResourceFilePath("near", sample_rate_hz); |
| 491 near_file_ = fopen(filename.c_str(), "rb"); | 506 near_file_ = fopen(filename.c_str(), "rb"); |
| 492 ASSERT_TRUE(near_file_ != NULL) << "Could not open file " << | 507 ASSERT_TRUE(near_file_ != NULL) << "Could not open file " << |
| 493 filename << "\n"; | 508 filename << "\n"; |
| 494 | 509 |
| 495 if (open_output_file) { | 510 if (open_output_file) { |
| 496 if (out_file_) { | 511 if (out_file_) { |
| 497 ASSERT_EQ(0, fclose(out_file_)); | 512 ASSERT_EQ(0, fclose(out_file_)); |
| 498 } | 513 } |
| 499 filename = OutputFilePath("out", | 514 filename = OutputFilePath( |
| 500 sample_rate_hz, | 515 "out", sample_rate_hz, output_sample_rate_hz, reverse_sample_rate_hz, |
| 501 output_sample_rate_hz, | 516 reverse_sample_rate_hz, num_input_channels, num_output_channels, |
| 502 reverse_sample_rate_hz, | 517 num_reverse_channels, num_reverse_channels, kForward); |
| 503 num_input_channels, | |
| 504 num_output_channels, | |
| 505 num_reverse_channels); | |
| 506 out_file_ = fopen(filename.c_str(), "wb"); | 518 out_file_ = fopen(filename.c_str(), "wb"); |
| 507 ASSERT_TRUE(out_file_ != NULL) << "Could not open file " << | 519 ASSERT_TRUE(out_file_ != NULL) << "Could not open file " << |
| 508 filename << "\n"; | 520 filename << "\n"; |
| 509 } | 521 } |
| 510 } | 522 } |
| 511 | 523 |
| 512 void ApmTest::EnableAllComponents() { | 524 void ApmTest::EnableAllComponents() { |
| 513 EnableAllAPComponents(apm_.get()); | 525 EnableAllAPComponents(apm_.get()); |
| 514 } | 526 } |
| 515 | 527 |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 | 824 |
| 813 EXPECT_EQ(expected_return, | 825 EXPECT_EQ(expected_return, |
| 814 apm_->ProcessStream(float_cb_->channels(), input_stream, | 826 apm_->ProcessStream(float_cb_->channels(), input_stream, |
| 815 output_stream, float_cb_->channels())); | 827 output_stream, float_cb_->channels())); |
| 816 } | 828 } |
| 817 | 829 |
| 818 void ApmTest::TestChangingReverseChannels( | 830 void ApmTest::TestChangingReverseChannels( |
| 819 int num_rev_channels, | 831 int num_rev_channels, |
| 820 AudioProcessing::Error expected_return) { | 832 AudioProcessing::Error expected_return) { |
| 821 const ProcessingConfig processing_config = { | 833 const ProcessingConfig processing_config = { |
| 822 {{ frame_->sample_rate_hz_, apm_->num_input_channels() }, | 834 {{frame_->sample_rate_hz_, apm_->num_input_channels()}, |
| 823 { output_sample_rate_hz_, apm_->num_output_channels() }, | 835 {output_sample_rate_hz_, apm_->num_output_channels()}, |
| 824 { frame_->sample_rate_hz_, num_rev_channels }}}; | 836 {frame_->sample_rate_hz_, num_rev_channels}, |
| 837 {frame_->sample_rate_hz_, num_rev_channels}}}; | |
| 825 | 838 |
| 826 EXPECT_EQ(expected_return, | 839 EXPECT_EQ( |
| 827 apm_->AnalyzeReverseStream(float_cb_->channels(), | 840 expected_return, |
| 828 processing_config.reverse_stream())); | 841 apm_->ProcessReverseStream( |
| 842 float_cb_->channels(), processing_config.reverse_input_stream(), | |
| 843 processing_config.reverse_output_stream(), float_cb_->channels())); | |
| 829 } | 844 } |
| 830 | 845 |
| 831 TEST_F(ApmTest, ChannelsInt16Interface) { | 846 TEST_F(ApmTest, ChannelsInt16Interface) { |
| 832 // Testing number of invalid and valid channels. | 847 // Testing number of invalid and valid channels. |
| 833 Init(16000, 16000, 16000, 4, 4, 4, false); | 848 Init(16000, 16000, 16000, 4, 4, 4, false); |
| 834 | 849 |
| 835 TestChangingChannelsInt16Interface(0, apm_->kBadNumberChannelsError); | 850 TestChangingChannelsInt16Interface(0, apm_->kBadNumberChannelsError); |
| 836 | 851 |
| 837 for (int i = 1; i < 4; i++) { | 852 for (int i = 1; i < 4; i++) { |
| 838 TestChangingChannelsInt16Interface(i, kNoErr); | 853 TestChangingChannelsInt16Interface(i, kNoErr); |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1524 | 1539 |
| 1525 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { | 1540 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { |
| 1526 for (size_t i = 0; i < kSampleRatesSize; i++) { | 1541 for (size_t i = 0; i < kSampleRatesSize; i++) { |
| 1527 Init(kSampleRates[i], kSampleRates[i], kSampleRates[i], 2, 2, 2, false); | 1542 Init(kSampleRates[i], kSampleRates[i], kSampleRates[i], 2, 2, 2, false); |
| 1528 SetFrameTo(frame_, 1000, 2000); | 1543 SetFrameTo(frame_, 1000, 2000); |
| 1529 AudioFrame frame_copy; | 1544 AudioFrame frame_copy; |
| 1530 frame_copy.CopyFrom(*frame_); | 1545 frame_copy.CopyFrom(*frame_); |
| 1531 for (int j = 0; j < 1000; j++) { | 1546 for (int j = 0; j < 1000; j++) { |
| 1532 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 1547 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); |
| 1533 EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); | 1548 EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); |
| 1549 EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(frame_)); | |
| 1550 EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); | |
| 1534 } | 1551 } |
| 1535 } | 1552 } |
| 1536 } | 1553 } |
| 1537 | 1554 |
| 1538 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabledFloat) { | 1555 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabledFloat) { |
| 1539 // Test that ProcessStream copies input to output even with no processing. | 1556 // Test that ProcessStream copies input to output even with no processing. |
| 1540 const size_t kSamples = 80; | 1557 const size_t kSamples = 80; |
| 1541 const int sample_rate = 8000; | 1558 const int sample_rate = 8000; |
| 1542 const float src[kSamples] = { | 1559 const float src[kSamples] = { |
| 1543 -1.0f, 0.0f, 1.0f | 1560 -1.0f, 0.0f, 1.0f |
| 1544 }; | 1561 }; |
| 1545 float dest[kSamples] = {}; | 1562 float dest[kSamples] = {}; |
| 1546 | 1563 |
| 1547 auto src_channels = &src[0]; | 1564 auto src_channels = &src[0]; |
| 1548 auto dest_channels = &dest[0]; | 1565 auto dest_channels = &dest[0]; |
| 1549 | 1566 |
| 1550 apm_.reset(AudioProcessing::Create()); | 1567 apm_.reset(AudioProcessing::Create()); |
| 1551 EXPECT_NOERR(apm_->ProcessStream( | 1568 EXPECT_NOERR(apm_->ProcessStream( |
| 1552 &src_channels, kSamples, sample_rate, LayoutFromChannels(1), | 1569 &src_channels, kSamples, sample_rate, LayoutFromChannels(1), |
| 1553 sample_rate, LayoutFromChannels(1), &dest_channels)); | 1570 sample_rate, LayoutFromChannels(1), &dest_channels)); |
| 1554 | 1571 |
| 1555 for (size_t i = 0; i < kSamples; ++i) { | 1572 for (size_t i = 0; i < kSamples; ++i) { |
| 1556 EXPECT_EQ(src[i], dest[i]); | 1573 EXPECT_EQ(src[i], dest[i]); |
| 1557 } | 1574 } |
| 1575 | |
| 1576 // Same for ProcessReverseStream. | |
| 1577 float rev_dest[kSamples] = {}; | |
| 1578 auto rev_dest_channels = &rev_dest[0]; | |
| 1579 | |
| 1580 StreamConfig input_stream = {sample_rate, 1}; | |
| 1581 StreamConfig output_stream = {sample_rate, 1}; | |
| 1582 EXPECT_NOERR(apm_->ProcessReverseStream(&src_channels, input_stream, | |
| 1583 output_stream, &rev_dest_channels)); | |
| 1584 | |
| 1585 for (size_t i = 0; i < kSamples; ++i) { | |
| 1586 EXPECT_EQ(src[i], rev_dest[i]); | |
| 1587 } | |
| 1558 } | 1588 } |
| 1559 | 1589 |
| 1560 TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) { | 1590 TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) { |
| 1561 EnableAllComponents(); | 1591 EnableAllComponents(); |
| 1562 | 1592 |
| 1563 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { | 1593 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { |
| 1564 Init(kProcessSampleRates[i], | 1594 Init(kProcessSampleRates[i], |
| 1565 kProcessSampleRates[i], | 1595 kProcessSampleRates[i], |
| 1566 kProcessSampleRates[i], | 1596 kProcessSampleRates[i], |
| 1567 2, | 1597 2, |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2292 // assumed to be correct, as the used parameters are verified by other tests | 2322 // assumed to be correct, as the used parameters are verified by other tests |
| 2293 // in this collection. Primarily the reference files are all produced at | 2323 // in this collection. Primarily the reference files are all produced at |
| 2294 // "native" rates which do not involve any resampling. | 2324 // "native" rates which do not involve any resampling. |
| 2295 | 2325 |
| 2296 // Each test pass produces an output file with a particular format. The output | 2326 // Each test pass produces an output file with a particular format. The output |
| 2297 // is matched against the reference file closest to its internal processing | 2327 // is matched against the reference file closest to its internal processing |
| 2298 // format. If necessary the output is resampled back to its process format. | 2328 // format. If necessary the output is resampled back to its process format. |
| 2299 // Due to the resampling distortion, we don't expect identical results, but | 2329 // Due to the resampling distortion, we don't expect identical results, but |
| 2300 // enforce SNR thresholds which vary depending on the format. 0 is a special | 2330 // enforce SNR thresholds which vary depending on the format. 0 is a special |
| 2301 // case SNR which corresponds to inf, or zero error. | 2331 // case SNR which corresponds to inf, or zero error. |
| 2302 typedef std::tr1::tuple<int, int, int, double> AudioProcessingTestData; | 2332 typedef std::tr1::tuple<int, int, int, int, double, double> |
| 2333 AudioProcessingTestData; | |
| 2303 class AudioProcessingTest | 2334 class AudioProcessingTest |
| 2304 : public testing::TestWithParam<AudioProcessingTestData> { | 2335 : public testing::TestWithParam<AudioProcessingTestData> { |
| 2305 public: | 2336 public: |
| 2306 AudioProcessingTest() | 2337 AudioProcessingTest() |
| 2307 : input_rate_(std::tr1::get<0>(GetParam())), | 2338 : input_rate_(std::tr1::get<0>(GetParam())), |
| 2308 output_rate_(std::tr1::get<1>(GetParam())), | 2339 output_rate_(std::tr1::get<1>(GetParam())), |
| 2309 reverse_rate_(std::tr1::get<2>(GetParam())), | 2340 reverse_input_rate_(std::tr1::get<2>(GetParam())), |
| 2310 expected_snr_(std::tr1::get<3>(GetParam())) {} | 2341 reverse_output_rate_(std::tr1::get<3>(GetParam())), |
| 2342 expected_snr_(std::tr1::get<4>(GetParam())), | |
| 2343 expected_reverse_snr_(std::tr1::get<5>(GetParam())) {} | |
| 2311 | 2344 |
| 2312 virtual ~AudioProcessingTest() {} | 2345 virtual ~AudioProcessingTest() {} |
| 2313 | 2346 |
| 2314 static void SetUpTestCase() { | 2347 static void SetUpTestCase() { |
| 2315 // Create all needed output reference files. | 2348 // Create all needed output reference files. |
| 2316 const int kNativeRates[] = {8000, 16000, 32000, 48000}; | 2349 const int kNativeRates[] = {8000, 16000, 32000, 48000}; |
| 2317 const size_t kNativeRatesSize = | 2350 const size_t kNativeRatesSize = |
| 2318 sizeof(kNativeRates) / sizeof(*kNativeRates); | 2351 sizeof(kNativeRates) / sizeof(*kNativeRates); |
| 2319 const int kNumChannels[] = {1, 2}; | 2352 const int kNumChannels[] = {1, 2}; |
| 2320 const size_t kNumChannelsSize = | 2353 const size_t kNumChannelsSize = |
| 2321 sizeof(kNumChannels) / sizeof(*kNumChannels); | 2354 sizeof(kNumChannels) / sizeof(*kNumChannels); |
| 2322 for (size_t i = 0; i < kNativeRatesSize; ++i) { | 2355 for (size_t i = 0; i < kNativeRatesSize; ++i) { |
| 2323 for (size_t j = 0; j < kNumChannelsSize; ++j) { | 2356 for (size_t j = 0; j < kNumChannelsSize; ++j) { |
| 2324 for (size_t k = 0; k < kNumChannelsSize; ++k) { | 2357 for (size_t k = 0; k < kNumChannelsSize; ++k) { |
| 2325 // The reference files always have matching input and output channels. | 2358 // The reference files always have matching input and output channels. |
| 2326 ProcessFormat(kNativeRates[i], | 2359 ProcessFormat(kNativeRates[i], kNativeRates[i], kNativeRates[i], |
| 2327 kNativeRates[i], | 2360 kNativeRates[i], kNumChannels[j], kNumChannels[j], |
| 2328 kNativeRates[i], | 2361 kNumChannels[k], kNumChannels[k], "ref"); |
| 2329 kNumChannels[j], | |
| 2330 kNumChannels[j], | |
| 2331 kNumChannels[k], | |
| 2332 "ref"); | |
| 2333 } | 2362 } |
| 2334 } | 2363 } |
| 2335 } | 2364 } |
| 2336 } | 2365 } |
| 2337 | 2366 |
| 2338 static void TearDownTestCase() { | 2367 static void TearDownTestCase() { |
| 2339 ClearTempFiles(); | 2368 ClearTempFiles(); |
| 2340 } | 2369 } |
| 2370 | |
| 2341 // Runs a process pass on files with the given parameters and dumps the output | 2371 // Runs a process pass on files with the given parameters and dumps the output |
| 2342 // to a file specified with |output_file_prefix|. | 2372 // to a file specified with |output_file_prefix|. Both forward and reverse |
| 2373 // output streams are dumped. | |
| 2343 static void ProcessFormat(int input_rate, | 2374 static void ProcessFormat(int input_rate, |
| 2344 int output_rate, | 2375 int output_rate, |
| 2345 int reverse_rate, | 2376 int reverse_input_rate, |
| 2377 int reverse_output_rate, | |
| 2346 int num_input_channels, | 2378 int num_input_channels, |
| 2347 int num_output_channels, | 2379 int num_output_channels, |
| 2348 int num_reverse_channels, | 2380 int num_reverse_input_channels, |
| 2381 int num_reverse_output_channels, | |
| 2349 std::string output_file_prefix) { | 2382 std::string output_file_prefix) { |
| 2350 Config config; | 2383 Config config; |
| 2351 config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | 2384 config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); |
| 2352 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); | 2385 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); |
| 2353 EnableAllAPComponents(ap.get()); | 2386 EnableAllAPComponents(ap.get()); |
| 2354 ap->Initialize({{{input_rate, num_input_channels}, | |
| 2355 {output_rate, num_output_channels}, | |
| 2356 {reverse_rate, num_reverse_channels}}}); | |
| 2357 | 2387 |
| 2358 FILE* far_file = fopen(ResourceFilePath("far", reverse_rate).c_str(), "rb"); | 2388 ProcessingConfig processing_config = { |
| 2389 {{input_rate, num_input_channels}, | |
| 2390 {output_rate, num_output_channels}, | |
| 2391 {reverse_input_rate, num_reverse_input_channels}, | |
| 2392 {reverse_output_rate, num_reverse_output_channels}}}; | |
| 2393 ap->Initialize(processing_config); | |
| 2394 | |
| 2395 FILE* far_file = | |
| 2396 fopen(ResourceFilePath("far", reverse_input_rate).c_str(), "rb"); | |
| 2359 FILE* near_file = fopen(ResourceFilePath("near", input_rate).c_str(), "rb"); | 2397 FILE* near_file = fopen(ResourceFilePath("near", input_rate).c_str(), "rb"); |
| 2360 FILE* out_file = fopen(OutputFilePath(output_file_prefix, | 2398 FILE* out_file = |
| 2361 input_rate, | 2399 fopen(OutputFilePath(output_file_prefix, input_rate, output_rate, |
| 2362 output_rate, | 2400 reverse_input_rate, reverse_output_rate, |
| 2363 reverse_rate, | 2401 num_input_channels, num_output_channels, |
| 2364 num_input_channels, | 2402 num_reverse_input_channels, |
| 2365 num_output_channels, | 2403 num_reverse_output_channels, kForward).c_str(), |
| 2366 num_reverse_channels).c_str(), "wb"); | 2404 "wb"); |
| 2405 FILE* rev_out_file = | |
| 2406 fopen(OutputFilePath(output_file_prefix, input_rate, output_rate, | |
| 2407 reverse_input_rate, reverse_output_rate, | |
| 2408 num_input_channels, num_output_channels, | |
| 2409 num_reverse_input_channels, | |
| 2410 num_reverse_output_channels, kReverse).c_str(), | |
| 2411 "wb"); | |
| 2367 ASSERT_TRUE(far_file != NULL); | 2412 ASSERT_TRUE(far_file != NULL); |
| 2368 ASSERT_TRUE(near_file != NULL); | 2413 ASSERT_TRUE(near_file != NULL); |
| 2369 ASSERT_TRUE(out_file != NULL); | 2414 ASSERT_TRUE(out_file != NULL); |
| 2415 ASSERT_TRUE(rev_out_file != NULL); | |
| 2370 | 2416 |
| 2371 ChannelBuffer<float> fwd_cb(SamplesFromRate(input_rate), | 2417 ChannelBuffer<float> fwd_cb(SamplesFromRate(input_rate), |
| 2372 num_input_channels); | 2418 num_input_channels); |
| 2373 ChannelBuffer<float> rev_cb(SamplesFromRate(reverse_rate), | 2419 ChannelBuffer<float> rev_cb(SamplesFromRate(reverse_input_rate), |
| 2374 num_reverse_channels); | 2420 num_reverse_input_channels); |
| 2375 ChannelBuffer<float> out_cb(SamplesFromRate(output_rate), | 2421 ChannelBuffer<float> out_cb(SamplesFromRate(output_rate), |
| 2376 num_output_channels); | 2422 num_output_channels); |
| 2423 ChannelBuffer<float> rev_out_cb(SamplesFromRate(reverse_output_rate), | |
| 2424 num_reverse_output_channels); | |
| 2377 | 2425 |
| 2378 // Temporary buffers. | 2426 // Temporary buffers. |
| 2379 const int max_length = | 2427 const int max_length = |
| 2380 2 * std::max(out_cb.num_frames(), | 2428 2 * std::max(std::max(out_cb.num_frames(), rev_out_cb.num_frames()), |
| 2381 std::max(fwd_cb.num_frames(), | 2429 std::max(fwd_cb.num_frames(), rev_cb.num_frames())); |
| 2382 rev_cb.num_frames())); | |
| 2383 rtc::scoped_ptr<float[]> float_data(new float[max_length]); | 2430 rtc::scoped_ptr<float[]> float_data(new float[max_length]); |
| 2384 rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]); | 2431 rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]); |
| 2385 | 2432 |
| 2386 int analog_level = 127; | 2433 int analog_level = 127; |
| 2387 while (ReadChunk(far_file, int_data.get(), float_data.get(), &rev_cb) && | 2434 while (ReadChunk(far_file, int_data.get(), float_data.get(), &rev_cb) && |
| 2388 ReadChunk(near_file, int_data.get(), float_data.get(), &fwd_cb)) { | 2435 ReadChunk(near_file, int_data.get(), float_data.get(), &fwd_cb)) { |
| 2389 EXPECT_NOERR(ap->AnalyzeReverseStream( | 2436 EXPECT_NOERR(ap->ProcessReverseStream( |
| 2390 rev_cb.channels(), | 2437 rev_cb.channels(), processing_config.reverse_input_stream(), |
| 2391 rev_cb.num_frames(), | 2438 processing_config.reverse_output_stream(), rev_out_cb.channels())); |
| 2392 reverse_rate, | |
| 2393 LayoutFromChannels(num_reverse_channels))); | |
| 2394 | 2439 |
| 2395 EXPECT_NOERR(ap->set_stream_delay_ms(0)); | 2440 EXPECT_NOERR(ap->set_stream_delay_ms(0)); |
| 2396 ap->echo_cancellation()->set_stream_drift_samples(0); | 2441 ap->echo_cancellation()->set_stream_drift_samples(0); |
| 2397 EXPECT_NOERR(ap->gain_control()->set_stream_analog_level(analog_level)); | 2442 EXPECT_NOERR(ap->gain_control()->set_stream_analog_level(analog_level)); |
| 2398 | 2443 |
| 2399 EXPECT_NOERR(ap->ProcessStream( | 2444 EXPECT_NOERR(ap->ProcessStream( |
| 2400 fwd_cb.channels(), | 2445 fwd_cb.channels(), |
| 2401 fwd_cb.num_frames(), | 2446 fwd_cb.num_frames(), |
| 2402 input_rate, | 2447 input_rate, |
| 2403 LayoutFromChannels(num_input_channels), | 2448 LayoutFromChannels(num_input_channels), |
| 2404 output_rate, | 2449 output_rate, |
| 2405 LayoutFromChannels(num_output_channels), | 2450 LayoutFromChannels(num_output_channels), |
| 2406 out_cb.channels())); | 2451 out_cb.channels())); |
| 2407 | 2452 |
| 2408 Interleave(out_cb.channels(), | 2453 // Dump forward output to file. |
| 2409 out_cb.num_frames(), | 2454 Interleave(out_cb.channels(), out_cb.num_frames(), out_cb.num_channels(), |
| 2410 out_cb.num_channels(), | |
| 2411 float_data.get()); | 2455 float_data.get()); |
| 2412 // Dump output to file. | |
| 2413 int out_length = out_cb.num_channels() * out_cb.num_frames(); | 2456 int out_length = out_cb.num_channels() * out_cb.num_frames(); |
| 2457 | |
| 2414 ASSERT_EQ(static_cast<size_t>(out_length), | 2458 ASSERT_EQ(static_cast<size_t>(out_length), |
| 2415 fwrite(float_data.get(), sizeof(float_data[0]), | 2459 fwrite(float_data.get(), sizeof(float_data[0]), |
| 2416 out_length, out_file)); | 2460 out_length, out_file)); |
| 2417 | 2461 |
| 2462 // Dump reverse output to file. | |
| 2463 Interleave(rev_out_cb.channels(), rev_out_cb.num_frames(), | |
| 2464 rev_out_cb.num_channels(), float_data.get()); | |
| 2465 int rev_out_length = rev_out_cb.num_channels() * rev_out_cb.num_frames(); | |
| 2466 | |
| 2467 ASSERT_EQ(static_cast<size_t>(rev_out_length), | |
| 2468 fwrite(float_data.get(), sizeof(float_data[0]), rev_out_length, | |
| 2469 rev_out_file)); | |
| 2470 | |
| 2418 analog_level = ap->gain_control()->stream_analog_level(); | 2471 analog_level = ap->gain_control()->stream_analog_level(); |
| 2419 } | 2472 } |
| 2420 fclose(far_file); | 2473 fclose(far_file); |
| 2421 fclose(near_file); | 2474 fclose(near_file); |
| 2422 fclose(out_file); | 2475 fclose(out_file); |
| 2476 fclose(rev_out_file); | |
| 2423 } | 2477 } |
| 2424 | 2478 |
| 2425 protected: | 2479 protected: |
| 2426 int input_rate_; | 2480 int input_rate_; |
| 2427 int output_rate_; | 2481 int output_rate_; |
| 2428 int reverse_rate_; | 2482 int reverse_input_rate_; |
| 2483 int reverse_output_rate_; | |
| 2429 double expected_snr_; | 2484 double expected_snr_; |
| 2485 double expected_reverse_snr_; | |
| 2430 }; | 2486 }; |
| 2431 | 2487 |
| 2432 TEST_P(AudioProcessingTest, Formats) { | 2488 TEST_P(AudioProcessingTest, Formats) { |
| 2433 struct ChannelFormat { | 2489 struct ChannelFormat { |
| 2434 int num_input; | 2490 int num_input; |
| 2435 int num_output; | 2491 int num_output; |
| 2436 int num_reverse; | 2492 int num_reverse_input; |
| 2493 int num_reverse_output; | |
| 2437 }; | 2494 }; |
| 2438 ChannelFormat cf[] = { | 2495 ChannelFormat cf[] = { |
| 2439 {1, 1, 1}, | 2496 {1, 1, 1, 1}, |
| 2440 {1, 1, 2}, | 2497 {1, 1, 2, 1}, |
| 2441 {2, 1, 1}, | 2498 {2, 1, 1, 1}, |
| 2442 {2, 1, 2}, | 2499 {2, 1, 2, 1}, |
| 2443 {2, 2, 1}, | 2500 {2, 2, 1, 1}, |
| 2444 {2, 2, 2}, | 2501 {2, 2, 2, 2}, |
| 2445 }; | 2502 }; |
| 2446 size_t channel_format_size = sizeof(cf) / sizeof(*cf); | 2503 size_t channel_format_size = sizeof(cf) / sizeof(*cf); |
| 2447 | 2504 |
| 2448 for (size_t i = 0; i < channel_format_size; ++i) { | 2505 for (size_t i = 0; i < channel_format_size; ++i) { |
| 2449 ProcessFormat(input_rate_, | 2506 ProcessFormat(input_rate_, output_rate_, reverse_input_rate_, |
| 2450 output_rate_, | 2507 reverse_output_rate_, cf[i].num_input, cf[i].num_output, |
| 2451 reverse_rate_, | 2508 cf[i].num_reverse_input, cf[i].num_reverse_output, "out"); |
| 2452 cf[i].num_input, | 2509 for (auto file_direction : {kForward, kReverse}) { |
| 2453 cf[i].num_output, | 2510 int in_rate = file_direction ? reverse_input_rate_ : input_rate_; |
|
Andrew MacDonald
2015/08/12 19:47:45
You can make these const now.
If it makes things
ekm
2015/08/13 01:29:22
Done.
Decided against extracting to a function.
| |
| 2454 cf[i].num_reverse, | 2511 int out_rate = file_direction ? reverse_output_rate_ : output_rate_; |
| 2455 "out"); | 2512 int out_num = |
| 2456 int min_ref_rate = std::min(input_rate_, output_rate_); | 2513 file_direction ? cf[i].num_reverse_output : cf[i].num_output; |
| 2514 double expected_snr = | |
| 2515 file_direction ? expected_reverse_snr_ : expected_snr_; | |
| 2516 | |
| 2517 int min_ref_rate = std::min(in_rate, out_rate); | |
| 2457 int ref_rate; | 2518 int ref_rate; |
| 2458 | 2519 |
| 2459 if (min_ref_rate > 32000) { | 2520 if (min_ref_rate > 32000) { |
| 2460 ref_rate = 48000; | 2521 ref_rate = 48000; |
| 2461 } else if (min_ref_rate > 16000) { | 2522 } else if (min_ref_rate > 16000) { |
| 2462 ref_rate = 32000; | 2523 ref_rate = 32000; |
| 2463 } else if (min_ref_rate > 8000) { | 2524 } else if (min_ref_rate > 8000) { |
| 2464 ref_rate = 16000; | 2525 ref_rate = 16000; |
| 2465 } else { | 2526 } else { |
| 2466 ref_rate = 8000; | 2527 ref_rate = 8000; |
| 2467 } | 2528 } |
| 2468 #ifdef WEBRTC_AUDIOPROC_FIXED_PROFILE | 2529 #ifdef WEBRTC_AUDIOPROC_FIXED_PROFILE |
| 2469 ref_rate = std::min(ref_rate, 16000); | 2530 if (file_direction == kForward) { |
| 2531 ref_rate = std::min(ref_rate, 16000); | |
| 2532 } | |
| 2470 #endif | 2533 #endif |
| 2471 | 2534 FILE* out_file = fopen( |
| 2472 FILE* out_file = fopen(OutputFilePath("out", | 2535 OutputFilePath("out", input_rate_, output_rate_, reverse_input_rate_, |
| 2473 input_rate_, | 2536 reverse_output_rate_, cf[i].num_input, |
| 2474 output_rate_, | 2537 cf[i].num_output, cf[i].num_reverse_input, |
| 2475 reverse_rate_, | 2538 cf[i].num_reverse_output, file_direction).c_str(), |
| 2476 cf[i].num_input, | 2539 "rb"); |
| 2477 cf[i].num_output, | |
| 2478 cf[i].num_reverse).c_str(), "rb"); | |
| 2479 // The reference files always have matching input and output channels. | 2540 // The reference files always have matching input and output channels. |
| 2480 FILE* ref_file = fopen(OutputFilePath("ref", | 2541 FILE* ref_file = fopen( |
| 2481 ref_rate, | 2542 OutputFilePath("ref", ref_rate, ref_rate, ref_rate, ref_rate, |
| 2482 ref_rate, | 2543 cf[i].num_output, cf[i].num_output, |
| 2483 ref_rate, | 2544 cf[i].num_reverse_output, cf[i].num_reverse_output, |
| 2484 cf[i].num_output, | 2545 file_direction).c_str(), |
| 2485 cf[i].num_output, | 2546 "rb"); |
| 2486 cf[i].num_reverse).c_str(), "rb"); | |
| 2487 ASSERT_TRUE(out_file != NULL); | 2547 ASSERT_TRUE(out_file != NULL); |
| 2488 ASSERT_TRUE(ref_file != NULL); | 2548 ASSERT_TRUE(ref_file != NULL); |
| 2489 | 2549 |
| 2490 const int ref_length = SamplesFromRate(ref_rate) * cf[i].num_output; | 2550 const int ref_length = SamplesFromRate(ref_rate) * out_num; |
| 2491 const int out_length = SamplesFromRate(output_rate_) * cf[i].num_output; | 2551 const int out_length = SamplesFromRate(out_rate) * out_num; |
| 2492 // Data from the reference file. | 2552 // Data from the reference file. |
| 2493 rtc::scoped_ptr<float[]> ref_data(new float[ref_length]); | 2553 rtc::scoped_ptr<float[]> ref_data(new float[ref_length]); |
| 2494 // Data from the output file. | 2554 // Data from the output file. |
| 2495 rtc::scoped_ptr<float[]> out_data(new float[out_length]); | 2555 rtc::scoped_ptr<float[]> out_data(new float[out_length]); |
| 2496 // Data from the resampled output, in case the reference and output rates | 2556 // Data from the resampled output, in case the reference and output rates |
| 2497 // don't match. | 2557 // don't match. |
| 2498 rtc::scoped_ptr<float[]> cmp_data(new float[ref_length]); | 2558 rtc::scoped_ptr<float[]> cmp_data(new float[ref_length]); |
| 2499 | 2559 |
| 2500 PushResampler<float> resampler; | 2560 PushResampler<float> resampler; |
| 2501 resampler.InitializeIfNeeded(output_rate_, ref_rate, cf[i].num_output); | 2561 resampler.InitializeIfNeeded(out_rate, ref_rate, out_num); |
| 2502 | 2562 |
| 2503 // Compute the resampling delay of the output relative to the reference, | 2563 // Compute the resampling delay of the output relative to the reference, |
| 2504 // to find the region over which we should search for the best SNR. | 2564 // to find the region over which we should search for the best SNR. |
| 2505 float expected_delay_sec = 0; | 2565 float expected_delay_sec = 0; |
| 2506 if (input_rate_ != ref_rate) { | 2566 if (in_rate != ref_rate) { |
| 2507 // Input resampling delay. | 2567 // Input resampling delay. |
| 2508 expected_delay_sec += | 2568 expected_delay_sec += PushSincResampler::AlgorithmicDelaySeconds(in_rate); |
| 2509 PushSincResampler::AlgorithmicDelaySeconds(input_rate_); | |
| 2510 } | 2569 } |
| 2511 if (output_rate_ != ref_rate) { | 2570 if (out_rate != ref_rate) { |
| 2512 // Output resampling delay. | 2571 // Output resampling delay. |
| 2513 expected_delay_sec += | 2572 expected_delay_sec += |
| 2514 PushSincResampler::AlgorithmicDelaySeconds(ref_rate); | 2573 PushSincResampler::AlgorithmicDelaySeconds(ref_rate); |
| 2515 // Delay of converting the output back to its processing rate for testing. | 2574 // Delay of converting the output back to its processing rate for |
| 2575 // testing. | |
| 2516 expected_delay_sec += | 2576 expected_delay_sec += |
| 2517 PushSincResampler::AlgorithmicDelaySeconds(output_rate_); | 2577 PushSincResampler::AlgorithmicDelaySeconds(out_rate); |
| 2518 } | 2578 } |
| 2519 int expected_delay = floor(expected_delay_sec * ref_rate + 0.5f) * | 2579 int expected_delay = floor(expected_delay_sec * ref_rate + 0.5f) * out_num; |
| 2520 cf[i].num_output; | |
| 2521 | 2580 |
| 2522 double variance = 0; | 2581 double variance = 0; |
| 2523 double sq_error = 0; | 2582 double sq_error = 0; |
| 2524 while (fread(out_data.get(), sizeof(out_data[0]), out_length, out_file) && | 2583 while (fread(out_data.get(), sizeof(out_data[0]), out_length, out_file) && |
| 2525 fread(ref_data.get(), sizeof(ref_data[0]), ref_length, ref_file)) { | 2584 fread(ref_data.get(), sizeof(ref_data[0]), ref_length, ref_file)) { |
| 2526 float* out_ptr = out_data.get(); | 2585 float* out_ptr = out_data.get(); |
| 2527 if (output_rate_ != ref_rate) { | 2586 if (out_rate != ref_rate) { |
| 2528 // Resample the output back to its internal processing rate if necssary. | 2587 // Resample the output back to its internal processing rate if |
| 2529 ASSERT_EQ(ref_length, resampler.Resample(out_ptr, | 2588 // necssary. |
| 2530 out_length, | 2589 ASSERT_EQ(ref_length, resampler.Resample(out_ptr, out_length, |
| 2531 cmp_data.get(), | 2590 cmp_data.get(), ref_length)); |
| 2532 ref_length)); | |
| 2533 out_ptr = cmp_data.get(); | 2591 out_ptr = cmp_data.get(); |
| 2534 } | 2592 } |
| 2535 | 2593 |
| 2536 // Update the |sq_error| and |variance| accumulators with the highest SNR | 2594 // Update the |sq_error| and |variance| accumulators with the highest |
| 2537 // of reference vs output. | 2595 // SNR of reference vs output. |
| 2538 UpdateBestSNR(ref_data.get(), | 2596 UpdateBestSNR(ref_data.get(), out_ptr, ref_length, expected_delay, |
| 2539 out_ptr, | 2597 &variance, &sq_error); |
| 2540 ref_length, | |
| 2541 expected_delay, | |
| 2542 &variance, | |
| 2543 &sq_error); | |
| 2544 } | 2598 } |
| 2545 | 2599 |
| 2546 std::cout << "(" << input_rate_ << ", " | 2600 std::cout << "(" << input_rate_ << ", " << output_rate_ << ", " |
| 2547 << output_rate_ << ", " | 2601 << reverse_input_rate_ << ", " << reverse_output_rate_ << ", " |
| 2548 << reverse_rate_ << ", " | 2602 << cf[i].num_input << ", " << cf[i].num_output << ", " |
| 2549 << cf[i].num_input << ", " | 2603 << cf[i].num_reverse_input << ", " << cf[i].num_reverse_output |
| 2550 << cf[i].num_output << ", " | 2604 << ", " << file_direction << "): "; |
| 2551 << cf[i].num_reverse << "): "; | |
| 2552 if (sq_error > 0) { | 2605 if (sq_error > 0) { |
| 2553 double snr = 10 * log10(variance / sq_error); | 2606 double snr = 10 * log10(variance / sq_error); |
| 2554 EXPECT_GE(snr, expected_snr_); | 2607 EXPECT_GE(snr, expected_snr); |
| 2555 EXPECT_NE(0, expected_snr_); | 2608 EXPECT_NE(0, expected_snr); |
| 2556 std::cout << "SNR=" << snr << " dB" << std::endl; | 2609 std::cout << "SNR=" << snr << " dB" << std::endl; |
| 2557 } else { | 2610 } else { |
| 2558 EXPECT_EQ(expected_snr_, 0); | 2611 EXPECT_EQ(expected_snr, 0); |
| 2559 std::cout << "SNR=" << "inf dB" << std::endl; | 2612 std::cout << "SNR=" |
| 2613 << "inf dB" << std::endl; | |
| 2560 } | 2614 } |
| 2561 | 2615 |
| 2562 fclose(out_file); | 2616 fclose(out_file); |
| 2563 fclose(ref_file); | 2617 fclose(ref_file); |
| 2564 } | 2618 } |
| 2619 } | |
| 2565 } | 2620 } |
| 2566 | 2621 |
| 2567 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 2622 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) |
| 2568 INSTANTIATE_TEST_CASE_P( | 2623 INSTANTIATE_TEST_CASE_P( |
| 2569 CommonFormats, AudioProcessingTest, testing::Values( | 2624 CommonFormats, |
| 2570 std::tr1::make_tuple(48000, 48000, 48000, 0), | 2625 AudioProcessingTest, |
| 2571 std::tr1::make_tuple(48000, 48000, 32000, 40), | 2626 testing::Values(std::tr1::make_tuple(48000, 48000, 48000, 48000, 0, 0), |
| 2572 std::tr1::make_tuple(48000, 48000, 16000, 40), | 2627 std::tr1::make_tuple(48000, 48000, 32000, 48000, 40, 30), |
| 2573 std::tr1::make_tuple(48000, 44100, 48000, 20), | 2628 std::tr1::make_tuple(48000, 48000, 16000, 48000, 40, 20), |
| 2574 std::tr1::make_tuple(48000, 44100, 32000, 20), | 2629 std::tr1::make_tuple(48000, 44100, 48000, 44100, 20, 20), |
| 2575 std::tr1::make_tuple(48000, 44100, 16000, 20), | 2630 std::tr1::make_tuple(48000, 44100, 32000, 44100, 20, 15), |
| 2576 std::tr1::make_tuple(48000, 32000, 48000, 30), | 2631 std::tr1::make_tuple(48000, 44100, 16000, 44100, 20, 15), |
| 2577 std::tr1::make_tuple(48000, 32000, 32000, 30), | 2632 std::tr1::make_tuple(48000, 32000, 48000, 32000, 30, 35), |
| 2578 std::tr1::make_tuple(48000, 32000, 16000, 30), | 2633 std::tr1::make_tuple(48000, 32000, 32000, 32000, 30, 0), |
| 2579 std::tr1::make_tuple(48000, 16000, 48000, 25), | 2634 std::tr1::make_tuple(48000, 32000, 16000, 32000, 30, 20), |
| 2580 std::tr1::make_tuple(48000, 16000, 32000, 25), | 2635 std::tr1::make_tuple(48000, 16000, 48000, 16000, 25, 20), |
| 2581 std::tr1::make_tuple(48000, 16000, 16000, 25), | 2636 std::tr1::make_tuple(48000, 16000, 32000, 16000, 25, 20), |
| 2637 std::tr1::make_tuple(48000, 16000, 16000, 16000, 25, 0), | |
| 2582 | 2638 |
| 2583 std::tr1::make_tuple(44100, 48000, 48000, 30), | 2639 std::tr1::make_tuple(44100, 48000, 48000, 48000, 30, 0), |
| 2584 std::tr1::make_tuple(44100, 48000, 32000, 30), | 2640 std::tr1::make_tuple(44100, 48000, 32000, 48000, 30, 30), |
| 2585 std::tr1::make_tuple(44100, 48000, 16000, 30), | 2641 std::tr1::make_tuple(44100, 48000, 16000, 48000, 30, 20), |
| 2586 std::tr1::make_tuple(44100, 44100, 48000, 20), | 2642 std::tr1::make_tuple(44100, 44100, 48000, 44100, 20, 20), |
| 2587 std::tr1::make_tuple(44100, 44100, 32000, 20), | 2643 std::tr1::make_tuple(44100, 44100, 32000, 44100, 20, 15), |
| 2588 std::tr1::make_tuple(44100, 44100, 16000, 20), | 2644 std::tr1::make_tuple(44100, 44100, 16000, 44100, 20, 15), |
| 2589 std::tr1::make_tuple(44100, 32000, 48000, 30), | 2645 std::tr1::make_tuple(44100, 32000, 48000, 32000, 30, 35), |
| 2590 std::tr1::make_tuple(44100, 32000, 32000, 30), | 2646 std::tr1::make_tuple(44100, 32000, 32000, 32000, 30, 0), |
| 2591 std::tr1::make_tuple(44100, 32000, 16000, 30), | 2647 std::tr1::make_tuple(44100, 32000, 16000, 32000, 30, 20), |
| 2592 std::tr1::make_tuple(44100, 16000, 48000, 25), | 2648 std::tr1::make_tuple(44100, 16000, 48000, 16000, 25, 20), |
| 2593 std::tr1::make_tuple(44100, 16000, 32000, 25), | 2649 std::tr1::make_tuple(44100, 16000, 32000, 16000, 25, 20), |
| 2594 std::tr1::make_tuple(44100, 16000, 16000, 25), | 2650 std::tr1::make_tuple(44100, 16000, 16000, 16000, 25, 0), |
| 2595 | 2651 |
| 2596 std::tr1::make_tuple(32000, 48000, 48000, 30), | 2652 std::tr1::make_tuple(32000, 48000, 48000, 48000, 30, 0), |
| 2597 std::tr1::make_tuple(32000, 48000, 32000, 35), | 2653 std::tr1::make_tuple(32000, 48000, 32000, 48000, 35, 30), |
| 2598 std::tr1::make_tuple(32000, 48000, 16000, 30), | 2654 std::tr1::make_tuple(32000, 48000, 16000, 48000, 30, 20), |
| 2599 std::tr1::make_tuple(32000, 44100, 48000, 20), | 2655 std::tr1::make_tuple(32000, 44100, 48000, 44100, 20, 20), |
| 2600 std::tr1::make_tuple(32000, 44100, 32000, 20), | 2656 std::tr1::make_tuple(32000, 44100, 32000, 44100, 20, 15), |
| 2601 std::tr1::make_tuple(32000, 44100, 16000, 20), | 2657 std::tr1::make_tuple(32000, 44100, 16000, 44100, 20, 15), |
| 2602 std::tr1::make_tuple(32000, 32000, 48000, 40), | 2658 std::tr1::make_tuple(32000, 32000, 48000, 32000, 40, 35), |
| 2603 std::tr1::make_tuple(32000, 32000, 32000, 0), | 2659 std::tr1::make_tuple(32000, 32000, 32000, 32000, 0, 0), |
| 2604 std::tr1::make_tuple(32000, 32000, 16000, 40), | 2660 std::tr1::make_tuple(32000, 32000, 16000, 32000, 40, 20), |
| 2605 std::tr1::make_tuple(32000, 16000, 48000, 25), | 2661 std::tr1::make_tuple(32000, 16000, 48000, 16000, 25, 20), |
| 2606 std::tr1::make_tuple(32000, 16000, 32000, 25), | 2662 std::tr1::make_tuple(32000, 16000, 32000, 16000, 25, 20), |
| 2607 std::tr1::make_tuple(32000, 16000, 16000, 25), | 2663 std::tr1::make_tuple(32000, 16000, 16000, 16000, 25, 0), |
| 2608 | 2664 |
| 2609 std::tr1::make_tuple(16000, 48000, 48000, 25), | 2665 std::tr1::make_tuple(16000, 48000, 48000, 48000, 25, 0), |
| 2610 std::tr1::make_tuple(16000, 48000, 32000, 25), | 2666 std::tr1::make_tuple(16000, 48000, 32000, 48000, 25, 30), |
| 2611 std::tr1::make_tuple(16000, 48000, 16000, 25), | 2667 std::tr1::make_tuple(16000, 48000, 16000, 48000, 25, 20), |
| 2612 std::tr1::make_tuple(16000, 44100, 48000, 15), | 2668 std::tr1::make_tuple(16000, 44100, 48000, 44100, 15, 20), |
| 2613 std::tr1::make_tuple(16000, 44100, 32000, 15), | 2669 std::tr1::make_tuple(16000, 44100, 32000, 44100, 15, 15), |
| 2614 std::tr1::make_tuple(16000, 44100, 16000, 15), | 2670 std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), |
| 2615 std::tr1::make_tuple(16000, 32000, 48000, 25), | 2671 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), |
| 2616 std::tr1::make_tuple(16000, 32000, 32000, 25), | 2672 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), |
| 2617 std::tr1::make_tuple(16000, 32000, 16000, 25), | 2673 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), |
| 2618 std::tr1::make_tuple(16000, 16000, 48000, 40), | 2674 std::tr1::make_tuple(16000, 16000, 48000, 16000, 40, 20), |
| 2619 std::tr1::make_tuple(16000, 16000, 32000, 50), | 2675 std::tr1::make_tuple(16000, 16000, 32000, 16000, 50, 20), |
| 2620 std::tr1::make_tuple(16000, 16000, 16000, 0))); | 2676 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); |
| 2621 | 2677 |
| 2622 #elif defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) | 2678 #elif defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) |
| 2623 INSTANTIATE_TEST_CASE_P( | 2679 INSTANTIATE_TEST_CASE_P( |
| 2624 CommonFormats, AudioProcessingTest, testing::Values( | 2680 CommonFormats, |
| 2625 std::tr1::make_tuple(48000, 48000, 48000, 20), | 2681 AudioProcessingTest, |
| 2626 std::tr1::make_tuple(48000, 48000, 32000, 20), | 2682 testing::Values(std::tr1::make_tuple(48000, 48000, 48000, 48000, 20, 0), |
| 2627 std::tr1::make_tuple(48000, 48000, 16000, 20), | 2683 std::tr1::make_tuple(48000, 48000, 32000, 48000, 20, 30), |
| 2628 std::tr1::make_tuple(48000, 44100, 48000, 15), | 2684 std::tr1::make_tuple(48000, 48000, 16000, 48000, 20, 20), |
| 2629 std::tr1::make_tuple(48000, 44100, 32000, 15), | 2685 std::tr1::make_tuple(48000, 44100, 48000, 44100, 15, 20), |
| 2630 std::tr1::make_tuple(48000, 44100, 16000, 15), | 2686 std::tr1::make_tuple(48000, 44100, 32000, 44100, 15, 15), |
| 2631 std::tr1::make_tuple(48000, 32000, 48000, 20), | 2687 std::tr1::make_tuple(48000, 44100, 16000, 44100, 15, 15), |
| 2632 std::tr1::make_tuple(48000, 32000, 32000, 20), | 2688 std::tr1::make_tuple(48000, 32000, 48000, 32000, 20, 35), |
| 2633 std::tr1::make_tuple(48000, 32000, 16000, 20), | 2689 std::tr1::make_tuple(48000, 32000, 32000, 32000, 20, 0), |
| 2634 std::tr1::make_tuple(48000, 16000, 48000, 20), | 2690 std::tr1::make_tuple(48000, 32000, 16000, 32000, 20, 20), |
| 2635 std::tr1::make_tuple(48000, 16000, 32000, 20), | 2691 std::tr1::make_tuple(48000, 16000, 48000, 16000, 20, 20), |
| 2636 std::tr1::make_tuple(48000, 16000, 16000, 20), | 2692 std::tr1::make_tuple(48000, 16000, 32000, 16000, 20, 20), |
| 2693 std::tr1::make_tuple(48000, 16000, 16000, 16000, 20, 0), | |
| 2637 | 2694 |
| 2638 std::tr1::make_tuple(44100, 48000, 48000, 20), | 2695 std::tr1::make_tuple(44100, 48000, 48000, 48000, 20, 0), |
| 2639 std::tr1::make_tuple(44100, 48000, 32000, 20), | 2696 std::tr1::make_tuple(44100, 48000, 32000, 48000, 20, 30), |
| 2640 std::tr1::make_tuple(44100, 48000, 16000, 20), | 2697 std::tr1::make_tuple(44100, 48000, 16000, 48000, 20, 20), |
| 2641 std::tr1::make_tuple(44100, 44100, 48000, 15), | 2698 std::tr1::make_tuple(44100, 44100, 48000, 44100, 15, 20), |
| 2642 std::tr1::make_tuple(44100, 44100, 32000, 15), | 2699 std::tr1::make_tuple(44100, 44100, 32000, 44100, 15, 15), |
| 2643 std::tr1::make_tuple(44100, 44100, 16000, 15), | 2700 std::tr1::make_tuple(44100, 44100, 16000, 44100, 15, 15), |
| 2644 std::tr1::make_tuple(44100, 32000, 48000, 20), | 2701 std::tr1::make_tuple(44100, 32000, 48000, 32000, 20, 35), |
| 2645 std::tr1::make_tuple(44100, 32000, 32000, 20), | 2702 std::tr1::make_tuple(44100, 32000, 32000, 32000, 20, 0), |
| 2646 std::tr1::make_tuple(44100, 32000, 16000, 20), | 2703 std::tr1::make_tuple(44100, 32000, 16000, 32000, 20, 20), |
| 2647 std::tr1::make_tuple(44100, 16000, 48000, 20), | 2704 std::tr1::make_tuple(44100, 16000, 48000, 16000, 20, 20), |
| 2648 std::tr1::make_tuple(44100, 16000, 32000, 20), | 2705 std::tr1::make_tuple(44100, 16000, 32000, 16000, 20, 20), |
| 2649 std::tr1::make_tuple(44100, 16000, 16000, 20), | 2706 std::tr1::make_tuple(44100, 16000, 16000, 16000, 20, 0), |
| 2650 | 2707 |
| 2651 std::tr1::make_tuple(32000, 48000, 48000, 20), | 2708 std::tr1::make_tuple(32000, 48000, 48000, 48000, 20, 0), |
| 2652 std::tr1::make_tuple(32000, 48000, 32000, 20), | 2709 std::tr1::make_tuple(32000, 48000, 32000, 48000, 20, 30), |
| 2653 std::tr1::make_tuple(32000, 48000, 16000, 20), | 2710 std::tr1::make_tuple(32000, 48000, 16000, 48000, 20, 20), |
| 2654 std::tr1::make_tuple(32000, 44100, 48000, 15), | 2711 std::tr1::make_tuple(32000, 44100, 48000, 44100, 15, 20), |
| 2655 std::tr1::make_tuple(32000, 44100, 32000, 15), | 2712 std::tr1::make_tuple(32000, 44100, 32000, 44100, 15, 15), |
| 2656 std::tr1::make_tuple(32000, 44100, 16000, 15), | 2713 std::tr1::make_tuple(32000, 44100, 16000, 44100, 15, 15), |
| 2657 std::tr1::make_tuple(32000, 32000, 48000, 20), | 2714 std::tr1::make_tuple(32000, 32000, 48000, 32000, 20, 35), |
| 2658 std::tr1::make_tuple(32000, 32000, 32000, 20), | 2715 std::tr1::make_tuple(32000, 32000, 32000, 32000, 20, 0), |
| 2659 std::tr1::make_tuple(32000, 32000, 16000, 20), | 2716 std::tr1::make_tuple(32000, 32000, 16000, 32000, 20, 20), |
| 2660 std::tr1::make_tuple(32000, 16000, 48000, 20), | 2717 std::tr1::make_tuple(32000, 16000, 48000, 16000, 20, 20), |
| 2661 std::tr1::make_tuple(32000, 16000, 32000, 20), | 2718 std::tr1::make_tuple(32000, 16000, 32000, 16000, 20, 20), |
| 2662 std::tr1::make_tuple(32000, 16000, 16000, 20), | 2719 std::tr1::make_tuple(32000, 16000, 16000, 16000, 20, 0), |
| 2663 | 2720 |
| 2664 std::tr1::make_tuple(16000, 48000, 48000, 25), | 2721 std::tr1::make_tuple(16000, 48000, 48000, 48000, 25, 0), |
| 2665 std::tr1::make_tuple(16000, 48000, 32000, 25), | 2722 std::tr1::make_tuple(16000, 48000, 32000, 48000, 25, 30), |
| 2666 std::tr1::make_tuple(16000, 48000, 16000, 25), | 2723 std::tr1::make_tuple(16000, 48000, 16000, 48000, 25, 20), |
| 2667 std::tr1::make_tuple(16000, 44100, 48000, 15), | 2724 std::tr1::make_tuple(16000, 44100, 48000, 44100, 15, 20), |
| 2668 std::tr1::make_tuple(16000, 44100, 32000, 15), | 2725 std::tr1::make_tuple(16000, 44100, 32000, 44100, 15, 15), |
| 2669 std::tr1::make_tuple(16000, 44100, 16000, 15), | 2726 std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), |
| 2670 std::tr1::make_tuple(16000, 32000, 48000, 25), | 2727 std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), |
| 2671 std::tr1::make_tuple(16000, 32000, 32000, 25), | 2728 std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), |
| 2672 std::tr1::make_tuple(16000, 32000, 16000, 25), | 2729 std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), |
| 2673 std::tr1::make_tuple(16000, 16000, 48000, 35), | 2730 std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), |
| 2674 std::tr1::make_tuple(16000, 16000, 32000, 40), | 2731 std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20), |
| 2675 std::tr1::make_tuple(16000, 16000, 16000, 0))); | 2732 std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); |
| 2676 #endif | 2733 #endif |
| 2677 | 2734 |
| 2678 // TODO(henrike): re-implement functionality lost when removing the old main | 2735 // TODO(henrike): re-implement functionality lost when removing the old main |
| 2679 // function. See | 2736 // function. See |
| 2680 // https://code.google.com/p/webrtc/issues/detail?id=1981 | 2737 // https://code.google.com/p/webrtc/issues/detail?id=1981 |
| 2681 | 2738 |
| 2682 } // namespace | 2739 } // namespace |
| 2683 } // namespace webrtc | 2740 } // namespace webrtc |
| OLD | NEW |