| 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 |
| 11 #include <math.h> | 11 #include <math.h> |
| 12 #include <stdio.h> | 12 #include <stdio.h> |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <limits> | 14 #include <limits> |
| 15 #include <queue> | 15 #include <queue> |
| 16 | 16 |
| 17 #include "webrtc/base/arraysize.h" |
| 17 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
| 18 #include "webrtc/common_audio/include/audio_util.h" | 19 #include "webrtc/common_audio/include/audio_util.h" |
| 19 #include "webrtc/common_audio/resampler/include/push_resampler.h" | 20 #include "webrtc/common_audio/resampler/include/push_resampler.h" |
| 20 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" | 21 #include "webrtc/common_audio/resampler/push_sinc_resampler.h" |
| 21 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" | 22 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar
y.h" |
| 22 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h
" | 23 #include "webrtc/modules/audio_processing/beamformer/mock_nonlinear_beamformer.h
" |
| 23 #include "webrtc/modules/audio_processing/common.h" | 24 #include "webrtc/modules/audio_processing/common.h" |
| 24 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 25 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 25 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | 26 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" |
| 26 #include "webrtc/modules/audio_processing/test/test_utils.h" | 27 #include "webrtc/modules/audio_processing/test/test_utils.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 40 namespace webrtc { | 41 namespace webrtc { |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| 43 // TODO(bjornv): This is not feasible until the functionality has been | 44 // TODO(bjornv): This is not feasible until the functionality has been |
| 44 // re-implemented; see comment at the bottom of this file. For now, the user has | 45 // re-implemented; see comment at the bottom of this file. For now, the user has |
| 45 // to hard code the |write_ref_data| value. | 46 // to hard code the |write_ref_data| value. |
| 46 // When false, this will compare the output data with the results stored to | 47 // When false, this will compare the output data with the results stored to |
| 47 // file. This is the typical case. When the file should be updated, it can | 48 // file. This is the typical case. When the file should be updated, it can |
| 48 // be set to true with the command-line switch --write_ref_data. | 49 // be set to true with the command-line switch --write_ref_data. |
| 49 bool write_ref_data = false; | 50 bool write_ref_data = false; |
| 50 const int kChannels[] = {1, 2}; | 51 const google::protobuf::int32 kChannels[] = {1, 2}; |
| 51 const size_t kChannelsSize = sizeof(kChannels) / sizeof(*kChannels); | |
| 52 | |
| 53 const int kSampleRates[] = {8000, 16000, 32000, 48000}; | 52 const int kSampleRates[] = {8000, 16000, 32000, 48000}; |
| 54 const size_t kSampleRatesSize = sizeof(kSampleRates) / sizeof(*kSampleRates); | |
| 55 | 53 |
| 56 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) | 54 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) |
| 57 // AECM doesn't support super-wb. | 55 // AECM doesn't support super-wb. |
| 58 const int kProcessSampleRates[] = {8000, 16000}; | 56 const int kProcessSampleRates[] = {8000, 16000}; |
| 59 #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 57 #elif defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) |
| 60 const int kProcessSampleRates[] = {8000, 16000, 32000, 48000}; | 58 const int kProcessSampleRates[] = {8000, 16000, 32000, 48000}; |
| 61 #endif | 59 #endif |
| 62 const size_t kProcessSampleRatesSize = sizeof(kProcessSampleRates) / | |
| 63 sizeof(*kProcessSampleRates); | |
| 64 | 60 |
| 65 void ConvertToFloat(const int16_t* int_data, ChannelBuffer<float>* cb) { | 61 void ConvertToFloat(const int16_t* int_data, ChannelBuffer<float>* cb) { |
| 66 ChannelBuffer<int16_t> cb_int(cb->num_frames(), | 62 ChannelBuffer<int16_t> cb_int(cb->num_frames(), |
| 67 cb->num_channels()); | 63 cb->num_channels()); |
| 68 Deinterleave(int_data, | 64 Deinterleave(int_data, |
| 69 cb->num_frames(), | 65 cb->num_frames(), |
| 70 cb->num_channels(), | 66 cb->num_channels(), |
| 71 cb_int.channels()); | 67 cb_int.channels()); |
| 72 for (int i = 0; i < cb->num_channels(); ++i) { | 68 for (size_t i = 0; i < cb->num_channels(); ++i) { |
| 73 S16ToFloat(cb_int.channels()[i], | 69 S16ToFloat(cb_int.channels()[i], |
| 74 cb->num_frames(), | 70 cb->num_frames(), |
| 75 cb->channels()[i]); | 71 cb->channels()[i]); |
| 76 } | 72 } |
| 77 } | 73 } |
| 78 | 74 |
| 79 void ConvertToFloat(const AudioFrame& frame, ChannelBuffer<float>* cb) { | 75 void ConvertToFloat(const AudioFrame& frame, ChannelBuffer<float>* cb) { |
| 80 ConvertToFloat(frame.data_, cb); | 76 ConvertToFloat(frame.data_, cb); |
| 81 } | 77 } |
| 82 | 78 |
| 83 // Number of channels including the keyboard channel. | 79 // Number of channels including the keyboard channel. |
| 84 int TotalChannelsFromLayout(AudioProcessing::ChannelLayout layout) { | 80 size_t TotalChannelsFromLayout(AudioProcessing::ChannelLayout layout) { |
| 85 switch (layout) { | 81 switch (layout) { |
| 86 case AudioProcessing::kMono: | 82 case AudioProcessing::kMono: |
| 87 return 1; | 83 return 1; |
| 88 case AudioProcessing::kMonoAndKeyboard: | 84 case AudioProcessing::kMonoAndKeyboard: |
| 89 case AudioProcessing::kStereo: | 85 case AudioProcessing::kStereo: |
| 90 return 2; | 86 return 2; |
| 91 case AudioProcessing::kStereoAndKeyboard: | 87 case AudioProcessing::kStereoAndKeyboard: |
| 92 return 3; | 88 return 3; |
| 93 } | 89 } |
| 94 assert(false); | 90 assert(false); |
| 95 return -1; | 91 return 0; |
| 96 } | 92 } |
| 97 | 93 |
| 98 int TruncateToMultipleOf10(int value) { | 94 int TruncateToMultipleOf10(int value) { |
| 99 return (value / 10) * 10; | 95 return (value / 10) * 10; |
| 100 } | 96 } |
| 101 | 97 |
| 102 void MixStereoToMono(const float* stereo, float* mono, | 98 void MixStereoToMono(const float* stereo, float* mono, |
| 103 int samples_per_channel) { | 99 size_t samples_per_channel) { |
| 104 for (int i = 0; i < samples_per_channel; ++i) | 100 for (size_t i = 0; i < samples_per_channel; ++i) |
| 105 mono[i] = (stereo[i * 2] + stereo[i * 2 + 1]) / 2; | 101 mono[i] = (stereo[i * 2] + stereo[i * 2 + 1]) / 2; |
| 106 } | 102 } |
| 107 | 103 |
| 108 void MixStereoToMono(const int16_t* stereo, int16_t* mono, | 104 void MixStereoToMono(const int16_t* stereo, int16_t* mono, |
| 109 int samples_per_channel) { | 105 size_t samples_per_channel) { |
| 110 for (int i = 0; i < samples_per_channel; ++i) | 106 for (size_t i = 0; i < samples_per_channel; ++i) |
| 111 mono[i] = (stereo[i * 2] + stereo[i * 2 + 1]) >> 1; | 107 mono[i] = (stereo[i * 2] + stereo[i * 2 + 1]) >> 1; |
| 112 } | 108 } |
| 113 | 109 |
| 114 void CopyLeftToRightChannel(int16_t* stereo, int samples_per_channel) { | 110 void CopyLeftToRightChannel(int16_t* stereo, size_t samples_per_channel) { |
| 115 for (int i = 0; i < samples_per_channel; i++) { | 111 for (size_t i = 0; i < samples_per_channel; i++) { |
| 116 stereo[i * 2 + 1] = stereo[i * 2]; | 112 stereo[i * 2 + 1] = stereo[i * 2]; |
| 117 } | 113 } |
| 118 } | 114 } |
| 119 | 115 |
| 120 void VerifyChannelsAreEqual(int16_t* stereo, int samples_per_channel) { | 116 void VerifyChannelsAreEqual(int16_t* stereo, size_t samples_per_channel) { |
| 121 for (int i = 0; i < samples_per_channel; i++) { | 117 for (size_t i = 0; i < samples_per_channel; i++) { |
| 122 EXPECT_EQ(stereo[i * 2 + 1], stereo[i * 2]); | 118 EXPECT_EQ(stereo[i * 2 + 1], stereo[i * 2]); |
| 123 } | 119 } |
| 124 } | 120 } |
| 125 | 121 |
| 126 void SetFrameTo(AudioFrame* frame, int16_t value) { | 122 void SetFrameTo(AudioFrame* frame, int16_t value) { |
| 127 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; | 123 for (size_t i = 0; i < frame->samples_per_channel_ * frame->num_channels_; |
| 128 ++i) { | 124 ++i) { |
| 129 frame->data_[i] = value; | 125 frame->data_[i] = value; |
| 130 } | 126 } |
| 131 } | 127 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 EXPECT_NOERR(ap->voice_detection()->Enable(true)); | 180 EXPECT_NOERR(ap->voice_detection()->Enable(true)); |
| 185 } | 181 } |
| 186 | 182 |
| 187 // These functions are only used by ApmTest.Process. | 183 // These functions are only used by ApmTest.Process. |
| 188 template <class T> | 184 template <class T> |
| 189 T AbsValue(T a) { | 185 T AbsValue(T a) { |
| 190 return a > 0 ? a: -a; | 186 return a > 0 ? a: -a; |
| 191 } | 187 } |
| 192 | 188 |
| 193 int16_t MaxAudioFrame(const AudioFrame& frame) { | 189 int16_t MaxAudioFrame(const AudioFrame& frame) { |
| 194 const int length = frame.samples_per_channel_ * frame.num_channels_; | 190 const size_t length = frame.samples_per_channel_ * frame.num_channels_; |
| 195 int16_t max_data = AbsValue(frame.data_[0]); | 191 int16_t max_data = AbsValue(frame.data_[0]); |
| 196 for (int i = 1; i < length; i++) { | 192 for (size_t i = 1; i < length; i++) { |
| 197 max_data = std::max(max_data, AbsValue(frame.data_[i])); | 193 max_data = std::max(max_data, AbsValue(frame.data_[i])); |
| 198 } | 194 } |
| 199 | 195 |
| 200 return max_data; | 196 return max_data; |
| 201 } | 197 } |
| 202 | 198 |
| 203 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 199 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) |
| 204 void TestStats(const AudioProcessing::Statistic& test, | 200 void TestStats(const AudioProcessing::Statistic& test, |
| 205 const audioproc::Test::Statistic& reference) { | 201 const audioproc::Test::Statistic& reference) { |
| 206 EXPECT_EQ(reference.instant(), test.instant); | 202 EXPECT_EQ(reference.instant(), test.instant); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 244 |
| 249 // Temporary filenames unique to this process. Used to be able to run these | 245 // Temporary filenames unique to this process. Used to be able to run these |
| 250 // tests in parallel as each process needs to be running in isolation they can't | 246 // tests in parallel as each process needs to be running in isolation they can't |
| 251 // have competing filenames. | 247 // have competing filenames. |
| 252 std::map<std::string, std::string> temp_filenames; | 248 std::map<std::string, std::string> temp_filenames; |
| 253 | 249 |
| 254 std::string OutputFilePath(std::string name, | 250 std::string OutputFilePath(std::string name, |
| 255 int input_rate, | 251 int input_rate, |
| 256 int output_rate, | 252 int output_rate, |
| 257 int reverse_rate, | 253 int reverse_rate, |
| 258 int num_input_channels, | 254 size_t num_input_channels, |
| 259 int num_output_channels, | 255 size_t num_output_channels, |
| 260 int num_reverse_channels) { | 256 size_t num_reverse_channels) { |
| 261 std::ostringstream ss; | 257 std::ostringstream ss; |
| 262 ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 | 258 ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 |
| 263 << "_r" << num_reverse_channels << "_" << reverse_rate / 1000 << "_"; | 259 << "_r" << num_reverse_channels << "_" << reverse_rate / 1000 << "_"; |
| 264 if (num_output_channels == 1) { | 260 if (num_output_channels == 1) { |
| 265 ss << "mono"; | 261 ss << "mono"; |
| 266 } else if (num_output_channels == 2) { | 262 } else if (num_output_channels == 2) { |
| 267 ss << "stereo"; | 263 ss << "stereo"; |
| 268 } else { | 264 } else { |
| 269 assert(false); | 265 assert(false); |
| 270 } | 266 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 331 |
| 336 // Used to select between int and float interface tests. | 332 // Used to select between int and float interface tests. |
| 337 enum Format { | 333 enum Format { |
| 338 kIntFormat, | 334 kIntFormat, |
| 339 kFloatFormat | 335 kFloatFormat |
| 340 }; | 336 }; |
| 341 | 337 |
| 342 void Init(int sample_rate_hz, | 338 void Init(int sample_rate_hz, |
| 343 int output_sample_rate_hz, | 339 int output_sample_rate_hz, |
| 344 int reverse_sample_rate_hz, | 340 int reverse_sample_rate_hz, |
| 345 int num_reverse_channels, | 341 size_t num_reverse_channels, |
| 346 int num_input_channels, | 342 size_t num_input_channels, |
| 347 int num_output_channels, | 343 size_t num_output_channels, |
| 348 bool open_output_file); | 344 bool open_output_file); |
| 349 void Init(AudioProcessing* ap); | 345 void Init(AudioProcessing* ap); |
| 350 void EnableAllComponents(); | 346 void EnableAllComponents(); |
| 351 bool ReadFrame(FILE* file, AudioFrame* frame); | 347 bool ReadFrame(FILE* file, AudioFrame* frame); |
| 352 bool ReadFrame(FILE* file, AudioFrame* frame, ChannelBuffer<float>* cb); | 348 bool ReadFrame(FILE* file, AudioFrame* frame, ChannelBuffer<float>* cb); |
| 353 void ReadFrameWithRewind(FILE* file, AudioFrame* frame); | 349 void ReadFrameWithRewind(FILE* file, AudioFrame* frame); |
| 354 void ReadFrameWithRewind(FILE* file, AudioFrame* frame, | 350 void ReadFrameWithRewind(FILE* file, AudioFrame* frame, |
| 355 ChannelBuffer<float>* cb); | 351 ChannelBuffer<float>* cb); |
| 356 void ProcessWithDefaultStreamParameters(AudioFrame* frame); | 352 void ProcessWithDefaultStreamParameters(AudioFrame* frame); |
| 357 void ProcessDelayVerificationTest(int delay_ms, int system_delay_ms, | 353 void ProcessDelayVerificationTest(int delay_ms, int system_delay_ms, |
| 358 int delay_min, int delay_max); | 354 int delay_min, int delay_max); |
| 359 void TestChangingChannelsInt16Interface( | 355 void TestChangingChannelsInt16Interface( |
| 360 int num_channels, | 356 size_t num_channels, |
| 361 AudioProcessing::Error expected_return); | 357 AudioProcessing::Error expected_return); |
| 362 void TestChangingForwardChannels(int num_in_channels, | 358 void TestChangingForwardChannels(size_t num_in_channels, |
| 363 int num_out_channels, | 359 size_t num_out_channels, |
| 364 AudioProcessing::Error expected_return); | 360 AudioProcessing::Error expected_return); |
| 365 void TestChangingReverseChannels(int num_rev_channels, | 361 void TestChangingReverseChannels(size_t num_rev_channels, |
| 366 AudioProcessing::Error expected_return); | 362 AudioProcessing::Error expected_return); |
| 367 void RunQuantizedVolumeDoesNotGetStuckTest(int sample_rate); | 363 void RunQuantizedVolumeDoesNotGetStuckTest(int sample_rate); |
| 368 void RunManualVolumeChangeIsPossibleTest(int sample_rate); | 364 void RunManualVolumeChangeIsPossibleTest(int sample_rate); |
| 369 void StreamParametersTest(Format format); | 365 void StreamParametersTest(Format format); |
| 370 int ProcessStreamChooser(Format format); | 366 int ProcessStreamChooser(Format format); |
| 371 int AnalyzeReverseStreamChooser(Format format); | 367 int AnalyzeReverseStreamChooser(Format format); |
| 372 void ProcessDebugDump(const std::string& in_filename, | 368 void ProcessDebugDump(const std::string& in_filename, |
| 373 const std::string& out_filename, | 369 const std::string& out_filename, |
| 374 Format format); | 370 Format format); |
| 375 void VerifyDebugDumpTest(Format format); | 371 void VerifyDebugDumpTest(Format format); |
| 376 | 372 |
| 377 const std::string output_path_; | 373 const std::string output_path_; |
| 378 const std::string ref_path_; | 374 const std::string ref_path_; |
| 379 const std::string ref_filename_; | 375 const std::string ref_filename_; |
| 380 rtc::scoped_ptr<AudioProcessing> apm_; | 376 rtc::scoped_ptr<AudioProcessing> apm_; |
| 381 AudioFrame* frame_; | 377 AudioFrame* frame_; |
| 382 AudioFrame* revframe_; | 378 AudioFrame* revframe_; |
| 383 rtc::scoped_ptr<ChannelBuffer<float> > float_cb_; | 379 rtc::scoped_ptr<ChannelBuffer<float> > float_cb_; |
| 384 rtc::scoped_ptr<ChannelBuffer<float> > revfloat_cb_; | 380 rtc::scoped_ptr<ChannelBuffer<float> > revfloat_cb_; |
| 385 int output_sample_rate_hz_; | 381 int output_sample_rate_hz_; |
| 386 int num_output_channels_; | 382 size_t num_output_channels_; |
| 387 FILE* far_file_; | 383 FILE* far_file_; |
| 388 FILE* near_file_; | 384 FILE* near_file_; |
| 389 FILE* out_file_; | 385 FILE* out_file_; |
| 390 }; | 386 }; |
| 391 | 387 |
| 392 ApmTest::ApmTest() | 388 ApmTest::ApmTest() |
| 393 : output_path_(test::OutputPath()), | 389 : output_path_(test::OutputPath()), |
| 394 ref_path_(test::ProjectRootPath() + "data/audio_processing/"), | 390 ref_path_(test::ProjectRootPath() + "data/audio_processing/"), |
| 395 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) | 391 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) |
| 396 ref_filename_(ref_path_ + "output_data_fixed.pb"), | 392 ref_filename_(ref_path_ + "output_data_fixed.pb"), |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 ASSERT_EQ(kNoErr, | 455 ASSERT_EQ(kNoErr, |
| 460 ap->Initialize( | 456 ap->Initialize( |
| 461 {{{frame_->sample_rate_hz_, frame_->num_channels_}, | 457 {{{frame_->sample_rate_hz_, frame_->num_channels_}, |
| 462 {output_sample_rate_hz_, num_output_channels_}, | 458 {output_sample_rate_hz_, num_output_channels_}, |
| 463 {revframe_->sample_rate_hz_, revframe_->num_channels_}}})); | 459 {revframe_->sample_rate_hz_, revframe_->num_channels_}}})); |
| 464 } | 460 } |
| 465 | 461 |
| 466 void ApmTest::Init(int sample_rate_hz, | 462 void ApmTest::Init(int sample_rate_hz, |
| 467 int output_sample_rate_hz, | 463 int output_sample_rate_hz, |
| 468 int reverse_sample_rate_hz, | 464 int reverse_sample_rate_hz, |
| 469 int num_input_channels, | 465 size_t num_input_channels, |
| 470 int num_output_channels, | 466 size_t num_output_channels, |
| 471 int num_reverse_channels, | 467 size_t num_reverse_channels, |
| 472 bool open_output_file) { | 468 bool open_output_file) { |
| 473 SetContainerFormat(sample_rate_hz, num_input_channels, frame_, &float_cb_); | 469 SetContainerFormat(sample_rate_hz, num_input_channels, frame_, &float_cb_); |
| 474 output_sample_rate_hz_ = output_sample_rate_hz; | 470 output_sample_rate_hz_ = output_sample_rate_hz; |
| 475 num_output_channels_ = num_output_channels; | 471 num_output_channels_ = num_output_channels; |
| 476 | 472 |
| 477 SetContainerFormat(reverse_sample_rate_hz, num_reverse_channels, revframe_, | 473 SetContainerFormat(reverse_sample_rate_hz, num_reverse_channels, revframe_, |
| 478 &revfloat_cb_); | 474 &revfloat_cb_); |
| 479 Init(apm_.get()); | 475 Init(apm_.get()); |
| 480 | 476 |
| 481 if (far_file_) { | 477 if (far_file_) { |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 796 // Low limit of 0 ms. | 792 // Low limit of 0 ms. |
| 797 apm_->set_delay_offset_ms(-50); | 793 apm_->set_delay_offset_ms(-50); |
| 798 EXPECT_EQ(-50, apm_->delay_offset_ms()); | 794 EXPECT_EQ(-50, apm_->delay_offset_ms()); |
| 799 EXPECT_EQ(apm_->kBadStreamParameterWarning, apm_->set_stream_delay_ms(20)); | 795 EXPECT_EQ(apm_->kBadStreamParameterWarning, apm_->set_stream_delay_ms(20)); |
| 800 EXPECT_EQ(0, apm_->stream_delay_ms()); | 796 EXPECT_EQ(0, apm_->stream_delay_ms()); |
| 801 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); | 797 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(100)); |
| 802 EXPECT_EQ(50, apm_->stream_delay_ms()); | 798 EXPECT_EQ(50, apm_->stream_delay_ms()); |
| 803 } | 799 } |
| 804 | 800 |
| 805 void ApmTest::TestChangingChannelsInt16Interface( | 801 void ApmTest::TestChangingChannelsInt16Interface( |
| 806 int num_channels, | 802 size_t num_channels, |
| 807 AudioProcessing::Error expected_return) { | 803 AudioProcessing::Error expected_return) { |
| 808 frame_->num_channels_ = num_channels; | 804 frame_->num_channels_ = num_channels; |
| 809 EXPECT_EQ(expected_return, apm_->ProcessStream(frame_)); | 805 EXPECT_EQ(expected_return, apm_->ProcessStream(frame_)); |
| 810 EXPECT_EQ(expected_return, apm_->AnalyzeReverseStream(frame_)); | 806 EXPECT_EQ(expected_return, apm_->AnalyzeReverseStream(frame_)); |
| 811 } | 807 } |
| 812 | 808 |
| 813 void ApmTest::TestChangingForwardChannels( | 809 void ApmTest::TestChangingForwardChannels( |
| 814 int num_in_channels, | 810 size_t num_in_channels, |
| 815 int num_out_channels, | 811 size_t num_out_channels, |
| 816 AudioProcessing::Error expected_return) { | 812 AudioProcessing::Error expected_return) { |
| 817 const StreamConfig input_stream = {frame_->sample_rate_hz_, num_in_channels}; | 813 const StreamConfig input_stream = {frame_->sample_rate_hz_, num_in_channels}; |
| 818 const StreamConfig output_stream = {output_sample_rate_hz_, num_out_channels}; | 814 const StreamConfig output_stream = {output_sample_rate_hz_, num_out_channels}; |
| 819 | 815 |
| 820 EXPECT_EQ(expected_return, | 816 EXPECT_EQ(expected_return, |
| 821 apm_->ProcessStream(float_cb_->channels(), input_stream, | 817 apm_->ProcessStream(float_cb_->channels(), input_stream, |
| 822 output_stream, float_cb_->channels())); | 818 output_stream, float_cb_->channels())); |
| 823 } | 819 } |
| 824 | 820 |
| 825 void ApmTest::TestChangingReverseChannels( | 821 void ApmTest::TestChangingReverseChannels( |
| 826 int num_rev_channels, | 822 size_t num_rev_channels, |
| 827 AudioProcessing::Error expected_return) { | 823 AudioProcessing::Error expected_return) { |
| 828 const ProcessingConfig processing_config = { | 824 const ProcessingConfig processing_config = { |
| 829 {{ frame_->sample_rate_hz_, apm_->num_input_channels() }, | 825 {{ frame_->sample_rate_hz_, apm_->num_input_channels() }, |
| 830 { output_sample_rate_hz_, apm_->num_output_channels() }, | 826 { output_sample_rate_hz_, apm_->num_output_channels() }, |
| 831 { frame_->sample_rate_hz_, num_rev_channels }}}; | 827 { frame_->sample_rate_hz_, num_rev_channels }}}; |
| 832 | 828 |
| 833 EXPECT_EQ(expected_return, | 829 EXPECT_EQ(expected_return, |
| 834 apm_->AnalyzeReverseStream(float_cb_->channels(), | 830 apm_->AnalyzeReverseStream(float_cb_->channels(), |
| 835 processing_config.reverse_stream())); | 831 processing_config.reverse_stream())); |
| 836 } | 832 } |
| 837 | 833 |
| 838 TEST_F(ApmTest, ChannelsInt16Interface) { | 834 TEST_F(ApmTest, ChannelsInt16Interface) { |
| 839 // Testing number of invalid and valid channels. | 835 // Testing number of invalid and valid channels. |
| 840 Init(16000, 16000, 16000, 4, 4, 4, false); | 836 Init(16000, 16000, 16000, 4, 4, 4, false); |
| 841 | 837 |
| 842 TestChangingChannelsInt16Interface(0, apm_->kBadNumberChannelsError); | 838 TestChangingChannelsInt16Interface(0, apm_->kBadNumberChannelsError); |
| 843 | 839 |
| 844 for (int i = 1; i < 4; i++) { | 840 for (size_t i = 1; i < 4; i++) { |
| 845 TestChangingChannelsInt16Interface(i, kNoErr); | 841 TestChangingChannelsInt16Interface(i, kNoErr); |
| 846 EXPECT_EQ(i, apm_->num_input_channels()); | 842 EXPECT_EQ(i, apm_->num_input_channels()); |
| 847 // We always force the number of reverse channels used for processing to 1. | 843 // We always force the number of reverse channels used for processing to 1. |
| 848 EXPECT_EQ(1, apm_->num_reverse_channels()); | 844 EXPECT_EQ(1, apm_->num_reverse_channels()); |
| 849 } | 845 } |
| 850 } | 846 } |
| 851 | 847 |
| 852 TEST_F(ApmTest, Channels) { | 848 TEST_F(ApmTest, Channels) { |
| 853 // Testing number of invalid and valid channels. | 849 // Testing number of invalid and valid channels. |
| 854 Init(16000, 16000, 16000, 4, 4, 4, false); | 850 Init(16000, 16000, 16000, 4, 4, 4, false); |
| 855 | 851 |
| 856 TestChangingForwardChannels(0, 1, apm_->kBadNumberChannelsError); | 852 TestChangingForwardChannels(0, 1, apm_->kBadNumberChannelsError); |
| 857 TestChangingReverseChannels(0, apm_->kBadNumberChannelsError); | 853 TestChangingReverseChannels(0, apm_->kBadNumberChannelsError); |
| 858 | 854 |
| 859 for (int i = 1; i < 4; ++i) { | 855 for (size_t i = 1; i < 4; ++i) { |
| 860 for (int j = 0; j < 1; ++j) { | 856 for (size_t j = 0; j < 1; ++j) { |
| 861 // Output channels much be one or match input channels. | 857 // Output channels much be one or match input channels. |
| 862 if (j == 1 || i == j) { | 858 if (j == 1 || i == j) { |
| 863 TestChangingForwardChannels(i, j, kNoErr); | 859 TestChangingForwardChannels(i, j, kNoErr); |
| 864 TestChangingReverseChannels(i, kNoErr); | 860 TestChangingReverseChannels(i, kNoErr); |
| 865 | 861 |
| 866 EXPECT_EQ(i, apm_->num_input_channels()); | 862 EXPECT_EQ(i, apm_->num_input_channels()); |
| 867 EXPECT_EQ(j, apm_->num_output_channels()); | 863 EXPECT_EQ(j, apm_->num_output_channels()); |
| 868 // The number of reverse channels used for processing to is always 1. | 864 // The number of reverse channels used for processing to is always 1. |
| 869 EXPECT_EQ(1, apm_->num_reverse_channels()); | 865 EXPECT_EQ(1, apm_->num_reverse_channels()); |
| 870 } else { | 866 } else { |
| 871 TestChangingForwardChannels(i, j, | 867 TestChangingForwardChannels(i, j, |
| 872 AudioProcessing::kBadNumberChannelsError); | 868 AudioProcessing::kBadNumberChannelsError); |
| 873 } | 869 } |
| 874 } | 870 } |
| 875 } | 871 } |
| 876 } | 872 } |
| 877 | 873 |
| 878 TEST_F(ApmTest, SampleRatesInt) { | 874 TEST_F(ApmTest, SampleRatesInt) { |
| 879 // Testing invalid sample rates | 875 // Testing invalid sample rates |
| 880 SetContainerFormat(10000, 2, frame_, &float_cb_); | 876 SetContainerFormat(10000, 2, frame_, &float_cb_); |
| 881 EXPECT_EQ(apm_->kBadSampleRateError, ProcessStreamChooser(kIntFormat)); | 877 EXPECT_EQ(apm_->kBadSampleRateError, ProcessStreamChooser(kIntFormat)); |
| 882 // Testing valid sample rates | 878 // Testing valid sample rates |
| 883 int fs[] = {8000, 16000, 32000, 48000}; | 879 int fs[] = {8000, 16000, 32000, 48000}; |
| 884 for (size_t i = 0; i < sizeof(fs) / sizeof(*fs); i++) { | 880 for (size_t i = 0; i < arraysize(fs); i++) { |
| 885 SetContainerFormat(fs[i], 2, frame_, &float_cb_); | 881 SetContainerFormat(fs[i], 2, frame_, &float_cb_); |
| 886 EXPECT_NOERR(ProcessStreamChooser(kIntFormat)); | 882 EXPECT_NOERR(ProcessStreamChooser(kIntFormat)); |
| 887 EXPECT_EQ(fs[i], apm_->input_sample_rate_hz()); | 883 EXPECT_EQ(fs[i], apm_->input_sample_rate_hz()); |
| 888 } | 884 } |
| 889 } | 885 } |
| 890 | 886 |
| 891 TEST_F(ApmTest, EchoCancellation) { | 887 TEST_F(ApmTest, EchoCancellation) { |
| 892 EXPECT_EQ(apm_->kNoError, | 888 EXPECT_EQ(apm_->kNoError, |
| 893 apm_->echo_cancellation()->enable_drift_compensation(true)); | 889 apm_->echo_cancellation()->enable_drift_compensation(true)); |
| 894 EXPECT_TRUE(apm_->echo_cancellation()->is_drift_compensation_enabled()); | 890 EXPECT_TRUE(apm_->echo_cancellation()->is_drift_compensation_enabled()); |
| 895 EXPECT_EQ(apm_->kNoError, | 891 EXPECT_EQ(apm_->kNoError, |
| 896 apm_->echo_cancellation()->enable_drift_compensation(false)); | 892 apm_->echo_cancellation()->enable_drift_compensation(false)); |
| 897 EXPECT_FALSE(apm_->echo_cancellation()->is_drift_compensation_enabled()); | 893 EXPECT_FALSE(apm_->echo_cancellation()->is_drift_compensation_enabled()); |
| 898 | 894 |
| 899 EchoCancellation::SuppressionLevel level[] = { | 895 EchoCancellation::SuppressionLevel level[] = { |
| 900 EchoCancellation::kLowSuppression, | 896 EchoCancellation::kLowSuppression, |
| 901 EchoCancellation::kModerateSuppression, | 897 EchoCancellation::kModerateSuppression, |
| 902 EchoCancellation::kHighSuppression, | 898 EchoCancellation::kHighSuppression, |
| 903 }; | 899 }; |
| 904 for (size_t i = 0; i < sizeof(level)/sizeof(*level); i++) { | 900 for (size_t i = 0; i < arraysize(level); i++) { |
| 905 EXPECT_EQ(apm_->kNoError, | 901 EXPECT_EQ(apm_->kNoError, |
| 906 apm_->echo_cancellation()->set_suppression_level(level[i])); | 902 apm_->echo_cancellation()->set_suppression_level(level[i])); |
| 907 EXPECT_EQ(level[i], | 903 EXPECT_EQ(level[i], |
| 908 apm_->echo_cancellation()->suppression_level()); | 904 apm_->echo_cancellation()->suppression_level()); |
| 909 } | 905 } |
| 910 | 906 |
| 911 EchoCancellation::Metrics metrics; | 907 EchoCancellation::Metrics metrics; |
| 912 EXPECT_EQ(apm_->kNotEnabledError, | 908 EXPECT_EQ(apm_->kNotEnabledError, |
| 913 apm_->echo_cancellation()->GetMetrics(&metrics)); | 909 apm_->echo_cancellation()->GetMetrics(&metrics)); |
| 914 | 910 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 // buffer is 66 ms in 8 kHz. | 967 // buffer is 66 ms in 8 kHz. |
| 972 // | 968 // |
| 973 // It is known that for 16 kHz (and 32 kHz) sampling frequency there is an | 969 // It is known that for 16 kHz (and 32 kHz) sampling frequency there is an |
| 974 // additional stuffing of 8 ms on the fly, but it seems to have no impact on | 970 // additional stuffing of 8 ms on the fly, but it seems to have no impact on |
| 975 // delay estimation. This should be noted though. In case of test failure, | 971 // delay estimation. This should be noted though. In case of test failure, |
| 976 // this could be the cause. | 972 // this could be the cause. |
| 977 const int kSystemDelayMs = 66; | 973 const int kSystemDelayMs = 66; |
| 978 // Test a couple of corner cases and verify that the estimated delay is | 974 // Test a couple of corner cases and verify that the estimated delay is |
| 979 // within a valid region (set to +-1.5 blocks). Note that these cases are | 975 // within a valid region (set to +-1.5 blocks). Note that these cases are |
| 980 // sampling frequency dependent. | 976 // sampling frequency dependent. |
| 981 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { | 977 for (size_t i = 0; i < arraysize(kProcessSampleRates); i++) { |
| 982 Init(kProcessSampleRates[i], | 978 Init(kProcessSampleRates[i], |
| 983 kProcessSampleRates[i], | 979 kProcessSampleRates[i], |
| 984 kProcessSampleRates[i], | 980 kProcessSampleRates[i], |
| 985 2, | 981 2, |
| 986 2, | 982 2, |
| 987 2, | 983 2, |
| 988 false); | 984 false); |
| 989 // Sampling frequency dependent variables. | 985 // Sampling frequency dependent variables. |
| 990 const int num_ms_per_block = | 986 const int num_ms_per_block = |
| 991 std::max(4, static_cast<int>(640 / frame_->samples_per_channel_)); | 987 std::max(4, static_cast<int>(640 / frame_->samples_per_channel_)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1043 EXPECT_TRUE(apm_->echo_control_mobile()->is_enabled()); | 1039 EXPECT_TRUE(apm_->echo_control_mobile()->is_enabled()); |
| 1044 | 1040 |
| 1045 // Toggle routing modes | 1041 // Toggle routing modes |
| 1046 EchoControlMobile::RoutingMode mode[] = { | 1042 EchoControlMobile::RoutingMode mode[] = { |
| 1047 EchoControlMobile::kQuietEarpieceOrHeadset, | 1043 EchoControlMobile::kQuietEarpieceOrHeadset, |
| 1048 EchoControlMobile::kEarpiece, | 1044 EchoControlMobile::kEarpiece, |
| 1049 EchoControlMobile::kLoudEarpiece, | 1045 EchoControlMobile::kLoudEarpiece, |
| 1050 EchoControlMobile::kSpeakerphone, | 1046 EchoControlMobile::kSpeakerphone, |
| 1051 EchoControlMobile::kLoudSpeakerphone, | 1047 EchoControlMobile::kLoudSpeakerphone, |
| 1052 }; | 1048 }; |
| 1053 for (size_t i = 0; i < sizeof(mode)/sizeof(*mode); i++) { | 1049 for (size_t i = 0; i < arraysize(mode); i++) { |
| 1054 EXPECT_EQ(apm_->kNoError, | 1050 EXPECT_EQ(apm_->kNoError, |
| 1055 apm_->echo_control_mobile()->set_routing_mode(mode[i])); | 1051 apm_->echo_control_mobile()->set_routing_mode(mode[i])); |
| 1056 EXPECT_EQ(mode[i], | 1052 EXPECT_EQ(mode[i], |
| 1057 apm_->echo_control_mobile()->routing_mode()); | 1053 apm_->echo_control_mobile()->routing_mode()); |
| 1058 } | 1054 } |
| 1059 // Turn comfort noise off/on | 1055 // Turn comfort noise off/on |
| 1060 EXPECT_EQ(apm_->kNoError, | 1056 EXPECT_EQ(apm_->kNoError, |
| 1061 apm_->echo_control_mobile()->enable_comfort_noise(false)); | 1057 apm_->echo_control_mobile()->enable_comfort_noise(false)); |
| 1062 EXPECT_FALSE(apm_->echo_control_mobile()->is_comfort_noise_enabled()); | 1058 EXPECT_FALSE(apm_->echo_control_mobile()->is_comfort_noise_enabled()); |
| 1063 EXPECT_EQ(apm_->kNoError, | 1059 EXPECT_EQ(apm_->kNoError, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1108 // Testing gain modes | 1104 // Testing gain modes |
| 1109 EXPECT_EQ(apm_->kNoError, | 1105 EXPECT_EQ(apm_->kNoError, |
| 1110 apm_->gain_control()->set_mode( | 1106 apm_->gain_control()->set_mode( |
| 1111 apm_->gain_control()->mode())); | 1107 apm_->gain_control()->mode())); |
| 1112 | 1108 |
| 1113 GainControl::Mode mode[] = { | 1109 GainControl::Mode mode[] = { |
| 1114 GainControl::kAdaptiveAnalog, | 1110 GainControl::kAdaptiveAnalog, |
| 1115 GainControl::kAdaptiveDigital, | 1111 GainControl::kAdaptiveDigital, |
| 1116 GainControl::kFixedDigital | 1112 GainControl::kFixedDigital |
| 1117 }; | 1113 }; |
| 1118 for (size_t i = 0; i < sizeof(mode)/sizeof(*mode); i++) { | 1114 for (size_t i = 0; i < arraysize(mode); i++) { |
| 1119 EXPECT_EQ(apm_->kNoError, | 1115 EXPECT_EQ(apm_->kNoError, |
| 1120 apm_->gain_control()->set_mode(mode[i])); | 1116 apm_->gain_control()->set_mode(mode[i])); |
| 1121 EXPECT_EQ(mode[i], apm_->gain_control()->mode()); | 1117 EXPECT_EQ(mode[i], apm_->gain_control()->mode()); |
| 1122 } | 1118 } |
| 1123 // Testing invalid target levels | 1119 // Testing invalid target levels |
| 1124 EXPECT_EQ(apm_->kBadParameterError, | 1120 EXPECT_EQ(apm_->kBadParameterError, |
| 1125 apm_->gain_control()->set_target_level_dbfs(-3)); | 1121 apm_->gain_control()->set_target_level_dbfs(-3)); |
| 1126 EXPECT_EQ(apm_->kBadParameterError, | 1122 EXPECT_EQ(apm_->kBadParameterError, |
| 1127 apm_->gain_control()->set_target_level_dbfs(-40)); | 1123 apm_->gain_control()->set_target_level_dbfs(-40)); |
| 1128 // Testing valid target levels | 1124 // Testing valid target levels |
| 1129 EXPECT_EQ(apm_->kNoError, | 1125 EXPECT_EQ(apm_->kNoError, |
| 1130 apm_->gain_control()->set_target_level_dbfs( | 1126 apm_->gain_control()->set_target_level_dbfs( |
| 1131 apm_->gain_control()->target_level_dbfs())); | 1127 apm_->gain_control()->target_level_dbfs())); |
| 1132 | 1128 |
| 1133 int level_dbfs[] = {0, 6, 31}; | 1129 int level_dbfs[] = {0, 6, 31}; |
| 1134 for (size_t i = 0; i < sizeof(level_dbfs)/sizeof(*level_dbfs); i++) { | 1130 for (size_t i = 0; i < arraysize(level_dbfs); i++) { |
| 1135 EXPECT_EQ(apm_->kNoError, | 1131 EXPECT_EQ(apm_->kNoError, |
| 1136 apm_->gain_control()->set_target_level_dbfs(level_dbfs[i])); | 1132 apm_->gain_control()->set_target_level_dbfs(level_dbfs[i])); |
| 1137 EXPECT_EQ(level_dbfs[i], apm_->gain_control()->target_level_dbfs()); | 1133 EXPECT_EQ(level_dbfs[i], apm_->gain_control()->target_level_dbfs()); |
| 1138 } | 1134 } |
| 1139 | 1135 |
| 1140 // Testing invalid compression gains | 1136 // Testing invalid compression gains |
| 1141 EXPECT_EQ(apm_->kBadParameterError, | 1137 EXPECT_EQ(apm_->kBadParameterError, |
| 1142 apm_->gain_control()->set_compression_gain_db(-1)); | 1138 apm_->gain_control()->set_compression_gain_db(-1)); |
| 1143 EXPECT_EQ(apm_->kBadParameterError, | 1139 EXPECT_EQ(apm_->kBadParameterError, |
| 1144 apm_->gain_control()->set_compression_gain_db(100)); | 1140 apm_->gain_control()->set_compression_gain_db(100)); |
| 1145 | 1141 |
| 1146 // Testing valid compression gains | 1142 // Testing valid compression gains |
| 1147 EXPECT_EQ(apm_->kNoError, | 1143 EXPECT_EQ(apm_->kNoError, |
| 1148 apm_->gain_control()->set_compression_gain_db( | 1144 apm_->gain_control()->set_compression_gain_db( |
| 1149 apm_->gain_control()->compression_gain_db())); | 1145 apm_->gain_control()->compression_gain_db())); |
| 1150 | 1146 |
| 1151 int gain_db[] = {0, 10, 90}; | 1147 int gain_db[] = {0, 10, 90}; |
| 1152 for (size_t i = 0; i < sizeof(gain_db)/sizeof(*gain_db); i++) { | 1148 for (size_t i = 0; i < arraysize(gain_db); i++) { |
| 1153 EXPECT_EQ(apm_->kNoError, | 1149 EXPECT_EQ(apm_->kNoError, |
| 1154 apm_->gain_control()->set_compression_gain_db(gain_db[i])); | 1150 apm_->gain_control()->set_compression_gain_db(gain_db[i])); |
| 1155 EXPECT_EQ(gain_db[i], apm_->gain_control()->compression_gain_db()); | 1151 EXPECT_EQ(gain_db[i], apm_->gain_control()->compression_gain_db()); |
| 1156 } | 1152 } |
| 1157 | 1153 |
| 1158 // Testing limiter off/on | 1154 // Testing limiter off/on |
| 1159 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->enable_limiter(false)); | 1155 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->enable_limiter(false)); |
| 1160 EXPECT_FALSE(apm_->gain_control()->is_limiter_enabled()); | 1156 EXPECT_FALSE(apm_->gain_control()->is_limiter_enabled()); |
| 1161 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->enable_limiter(true)); | 1157 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->enable_limiter(true)); |
| 1162 EXPECT_TRUE(apm_->gain_control()->is_limiter_enabled()); | 1158 EXPECT_TRUE(apm_->gain_control()->is_limiter_enabled()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1173 EXPECT_EQ(apm_->kBadParameterError, | 1169 EXPECT_EQ(apm_->kBadParameterError, |
| 1174 apm_->gain_control()->set_analog_level_limits(512, 255)); | 1170 apm_->gain_control()->set_analog_level_limits(512, 255)); |
| 1175 | 1171 |
| 1176 // Testing valid level limits | 1172 // Testing valid level limits |
| 1177 EXPECT_EQ(apm_->kNoError, | 1173 EXPECT_EQ(apm_->kNoError, |
| 1178 apm_->gain_control()->set_analog_level_limits( | 1174 apm_->gain_control()->set_analog_level_limits( |
| 1179 apm_->gain_control()->analog_level_minimum(), | 1175 apm_->gain_control()->analog_level_minimum(), |
| 1180 apm_->gain_control()->analog_level_maximum())); | 1176 apm_->gain_control()->analog_level_maximum())); |
| 1181 | 1177 |
| 1182 int min_level[] = {0, 255, 1024}; | 1178 int min_level[] = {0, 255, 1024}; |
| 1183 for (size_t i = 0; i < sizeof(min_level)/sizeof(*min_level); i++) { | 1179 for (size_t i = 0; i < arraysize(min_level); i++) { |
| 1184 EXPECT_EQ(apm_->kNoError, | 1180 EXPECT_EQ(apm_->kNoError, |
| 1185 apm_->gain_control()->set_analog_level_limits(min_level[i], 1024)); | 1181 apm_->gain_control()->set_analog_level_limits(min_level[i], 1024)); |
| 1186 EXPECT_EQ(min_level[i], apm_->gain_control()->analog_level_minimum()); | 1182 EXPECT_EQ(min_level[i], apm_->gain_control()->analog_level_minimum()); |
| 1187 } | 1183 } |
| 1188 | 1184 |
| 1189 int max_level[] = {0, 1024, 65535}; | 1185 int max_level[] = {0, 1024, 65535}; |
| 1190 for (size_t i = 0; i < sizeof(min_level)/sizeof(*min_level); i++) { | 1186 for (size_t i = 0; i < arraysize(min_level); i++) { |
| 1191 EXPECT_EQ(apm_->kNoError, | 1187 EXPECT_EQ(apm_->kNoError, |
| 1192 apm_->gain_control()->set_analog_level_limits(0, max_level[i])); | 1188 apm_->gain_control()->set_analog_level_limits(0, max_level[i])); |
| 1193 EXPECT_EQ(max_level[i], apm_->gain_control()->analog_level_maximum()); | 1189 EXPECT_EQ(max_level[i], apm_->gain_control()->analog_level_maximum()); |
| 1194 } | 1190 } |
| 1195 | 1191 |
| 1196 // TODO(ajm): stream_is_saturated() and stream_analog_level() | 1192 // TODO(ajm): stream_is_saturated() and stream_analog_level() |
| 1197 | 1193 |
| 1198 // Turn AGC off | 1194 // Turn AGC off |
| 1199 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false)); | 1195 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(false)); |
| 1200 EXPECT_FALSE(apm_->gain_control()->is_enabled()); | 1196 EXPECT_FALSE(apm_->gain_control()->is_enabled()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1219 out_analog_level = apm_->gain_control()->stream_analog_level(); | 1215 out_analog_level = apm_->gain_control()->stream_analog_level(); |
| 1220 } | 1216 } |
| 1221 | 1217 |
| 1222 // Ensure the AGC is still able to reach the maximum. | 1218 // Ensure the AGC is still able to reach the maximum. |
| 1223 EXPECT_EQ(255, out_analog_level); | 1219 EXPECT_EQ(255, out_analog_level); |
| 1224 } | 1220 } |
| 1225 | 1221 |
| 1226 // Verifies that despite volume slider quantization, the AGC can continue to | 1222 // Verifies that despite volume slider quantization, the AGC can continue to |
| 1227 // increase its volume. | 1223 // increase its volume. |
| 1228 TEST_F(ApmTest, QuantizedVolumeDoesNotGetStuck) { | 1224 TEST_F(ApmTest, QuantizedVolumeDoesNotGetStuck) { |
| 1229 for (size_t i = 0; i < kSampleRatesSize; ++i) { | 1225 for (size_t i = 0; i < arraysize(kSampleRates); ++i) { |
| 1230 RunQuantizedVolumeDoesNotGetStuckTest(kSampleRates[i]); | 1226 RunQuantizedVolumeDoesNotGetStuckTest(kSampleRates[i]); |
| 1231 } | 1227 } |
| 1232 } | 1228 } |
| 1233 | 1229 |
| 1234 void ApmTest::RunManualVolumeChangeIsPossibleTest(int sample_rate) { | 1230 void ApmTest::RunManualVolumeChangeIsPossibleTest(int sample_rate) { |
| 1235 Init(sample_rate, sample_rate, sample_rate, 2, 2, 2, false); | 1231 Init(sample_rate, sample_rate, sample_rate, 2, 2, 2, false); |
| 1236 EXPECT_EQ(apm_->kNoError, | 1232 EXPECT_EQ(apm_->kNoError, |
| 1237 apm_->gain_control()->set_mode(GainControl::kAdaptiveAnalog)); | 1233 apm_->gain_control()->set_mode(GainControl::kAdaptiveAnalog)); |
| 1238 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true)); | 1234 EXPECT_EQ(apm_->kNoError, apm_->gain_control()->Enable(true)); |
| 1239 | 1235 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1264 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 1260 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); |
| 1265 out_analog_level = apm_->gain_control()->stream_analog_level(); | 1261 out_analog_level = apm_->gain_control()->stream_analog_level(); |
| 1266 // Check that AGC respected the manually adjusted volume. | 1262 // Check that AGC respected the manually adjusted volume. |
| 1267 EXPECT_LT(out_analog_level, highest_level_reached); | 1263 EXPECT_LT(out_analog_level, highest_level_reached); |
| 1268 } | 1264 } |
| 1269 // Check that the volume was still raised. | 1265 // Check that the volume was still raised. |
| 1270 EXPECT_GT(out_analog_level, 100); | 1266 EXPECT_GT(out_analog_level, 100); |
| 1271 } | 1267 } |
| 1272 | 1268 |
| 1273 TEST_F(ApmTest, ManualVolumeChangeIsPossible) { | 1269 TEST_F(ApmTest, ManualVolumeChangeIsPossible) { |
| 1274 for (size_t i = 0; i < kSampleRatesSize; ++i) { | 1270 for (size_t i = 0; i < arraysize(kSampleRates); ++i) { |
| 1275 RunManualVolumeChangeIsPossibleTest(kSampleRates[i]); | 1271 RunManualVolumeChangeIsPossibleTest(kSampleRates[i]); |
| 1276 } | 1272 } |
| 1277 } | 1273 } |
| 1278 | 1274 |
| 1279 #if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) | 1275 #if !defined(WEBRTC_ANDROID) && !defined(WEBRTC_IOS) |
| 1280 TEST_F(ApmTest, AgcOnlyAdaptsWhenTargetSignalIsPresent) { | 1276 TEST_F(ApmTest, AgcOnlyAdaptsWhenTargetSignalIsPresent) { |
| 1281 const int kSampleRateHz = 16000; | 1277 const int kSampleRateHz = 16000; |
| 1282 const int kSamplesPerChannel = | 1278 const size_t kSamplesPerChannel = |
| 1283 AudioProcessing::kChunkSizeMs * kSampleRateHz / 1000; | 1279 static_cast<size_t>(AudioProcessing::kChunkSizeMs * kSampleRateHz / 1000); |
| 1284 const int kNumInputChannels = 2; | 1280 const size_t kNumInputChannels = 2; |
| 1285 const int kNumOutputChannels = 1; | 1281 const size_t kNumOutputChannels = 1; |
| 1286 const int kNumChunks = 700; | 1282 const size_t kNumChunks = 700; |
| 1287 const float kScaleFactor = 0.25f; | 1283 const float kScaleFactor = 0.25f; |
| 1288 Config config; | 1284 Config config; |
| 1289 std::vector<webrtc::Point> geometry; | 1285 std::vector<webrtc::Point> geometry; |
| 1290 geometry.push_back(webrtc::Point(0.f, 0.f, 0.f)); | 1286 geometry.push_back(webrtc::Point(0.f, 0.f, 0.f)); |
| 1291 geometry.push_back(webrtc::Point(0.05f, 0.f, 0.f)); | 1287 geometry.push_back(webrtc::Point(0.05f, 0.f, 0.f)); |
| 1292 config.Set<Beamforming>(new Beamforming(true, geometry)); | 1288 config.Set<Beamforming>(new Beamforming(true, geometry)); |
| 1293 testing::NiceMock<MockNonlinearBeamformer>* beamformer = | 1289 testing::NiceMock<MockNonlinearBeamformer>* beamformer = |
| 1294 new testing::NiceMock<MockNonlinearBeamformer>(geometry); | 1290 new testing::NiceMock<MockNonlinearBeamformer>(geometry); |
| 1295 rtc::scoped_ptr<AudioProcessing> apm( | 1291 rtc::scoped_ptr<AudioProcessing> apm( |
| 1296 AudioProcessing::Create(config, beamformer)); | 1292 AudioProcessing::Create(config, beamformer)); |
| 1297 EXPECT_EQ(kNoErr, apm->gain_control()->Enable(true)); | 1293 EXPECT_EQ(kNoErr, apm->gain_control()->Enable(true)); |
| 1298 ChannelBuffer<float> src_buf(kSamplesPerChannel, kNumInputChannels); | 1294 ChannelBuffer<float> src_buf(kSamplesPerChannel, kNumInputChannels); |
| 1299 ChannelBuffer<float> dest_buf(kSamplesPerChannel, kNumOutputChannels); | 1295 ChannelBuffer<float> dest_buf(kSamplesPerChannel, kNumOutputChannels); |
| 1300 const int max_length = kSamplesPerChannel * std::max(kNumInputChannels, | 1296 const size_t max_length = kSamplesPerChannel * std::max(kNumInputChannels, |
| 1301 kNumOutputChannels); | 1297 kNumOutputChannels); |
| 1302 rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]); | 1298 rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]); |
| 1303 rtc::scoped_ptr<float[]> float_data(new float[max_length]); | 1299 rtc::scoped_ptr<float[]> float_data(new float[max_length]); |
| 1304 std::string filename = ResourceFilePath("far", kSampleRateHz); | 1300 std::string filename = ResourceFilePath("far", kSampleRateHz); |
| 1305 FILE* far_file = fopen(filename.c_str(), "rb"); | 1301 FILE* far_file = fopen(filename.c_str(), "rb"); |
| 1306 ASSERT_TRUE(far_file != NULL) << "Could not open file " << filename << "\n"; | 1302 ASSERT_TRUE(far_file != NULL) << "Could not open file " << filename << "\n"; |
| 1307 const int kDefaultVolume = apm->gain_control()->stream_analog_level(); | 1303 const int kDefaultVolume = apm->gain_control()->stream_analog_level(); |
| 1308 const int kDefaultCompressionGain = | 1304 const int kDefaultCompressionGain = |
| 1309 apm->gain_control()->compression_gain_db(); | 1305 apm->gain_control()->compression_gain_db(); |
| 1310 bool is_target = false; | 1306 bool is_target = false; |
| 1311 EXPECT_CALL(*beamformer, is_target_present()) | 1307 EXPECT_CALL(*beamformer, is_target_present()) |
| 1312 .WillRepeatedly(testing::ReturnPointee(&is_target)); | 1308 .WillRepeatedly(testing::ReturnPointee(&is_target)); |
| 1313 for (int i = 0; i < kNumChunks; ++i) { | 1309 for (size_t i = 0; i < kNumChunks; ++i) { |
| 1314 ASSERT_TRUE(ReadChunk(far_file, | 1310 ASSERT_TRUE(ReadChunk(far_file, |
| 1315 int_data.get(), | 1311 int_data.get(), |
| 1316 float_data.get(), | 1312 float_data.get(), |
| 1317 &src_buf)); | 1313 &src_buf)); |
| 1318 for (int j = 0; j < kNumInputChannels; ++j) { | 1314 for (size_t j = 0; j < kNumInputChannels; ++j) { |
| 1319 for (int k = 0; k < kSamplesPerChannel; ++k) { | 1315 for (size_t k = 0; k < kSamplesPerChannel; ++k) { |
| 1320 src_buf.channels()[j][k] *= kScaleFactor; | 1316 src_buf.channels()[j][k] *= kScaleFactor; |
| 1321 } | 1317 } |
| 1322 } | 1318 } |
| 1323 EXPECT_EQ(kNoErr, | 1319 EXPECT_EQ(kNoErr, |
| 1324 apm->ProcessStream(src_buf.channels(), | 1320 apm->ProcessStream(src_buf.channels(), |
| 1325 src_buf.num_frames(), | 1321 src_buf.num_frames(), |
| 1326 kSampleRateHz, | 1322 kSampleRateHz, |
| 1327 LayoutFromChannels(src_buf.num_channels()), | 1323 LayoutFromChannels(src_buf.num_channels()), |
| 1328 kSampleRateHz, | 1324 kSampleRateHz, |
| 1329 LayoutFromChannels(dest_buf.num_channels()), | 1325 LayoutFromChannels(dest_buf.num_channels()), |
| 1330 dest_buf.channels())); | 1326 dest_buf.channels())); |
| 1331 } | 1327 } |
| 1332 EXPECT_EQ(kDefaultVolume, | 1328 EXPECT_EQ(kDefaultVolume, |
| 1333 apm->gain_control()->stream_analog_level()); | 1329 apm->gain_control()->stream_analog_level()); |
| 1334 EXPECT_EQ(kDefaultCompressionGain, | 1330 EXPECT_EQ(kDefaultCompressionGain, |
| 1335 apm->gain_control()->compression_gain_db()); | 1331 apm->gain_control()->compression_gain_db()); |
| 1336 rewind(far_file); | 1332 rewind(far_file); |
| 1337 is_target = true; | 1333 is_target = true; |
| 1338 for (int i = 0; i < kNumChunks; ++i) { | 1334 for (size_t i = 0; i < kNumChunks; ++i) { |
| 1339 ASSERT_TRUE(ReadChunk(far_file, | 1335 ASSERT_TRUE(ReadChunk(far_file, |
| 1340 int_data.get(), | 1336 int_data.get(), |
| 1341 float_data.get(), | 1337 float_data.get(), |
| 1342 &src_buf)); | 1338 &src_buf)); |
| 1343 for (int j = 0; j < kNumInputChannels; ++j) { | 1339 for (int j = 0; j < kNumInputChannels; ++j) { |
| 1344 for (int k = 0; k < kSamplesPerChannel; ++k) { | 1340 for (int k = 0; k < kSamplesPerChannel; ++k) { |
| 1345 src_buf.channels()[j][k] *= kScaleFactor; | 1341 src_buf.channels()[j][k] *= kScaleFactor; |
| 1346 } | 1342 } |
| 1347 } | 1343 } |
| 1348 EXPECT_EQ(kNoErr, | 1344 EXPECT_EQ(kNoErr, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1363 #endif | 1359 #endif |
| 1364 | 1360 |
| 1365 TEST_F(ApmTest, NoiseSuppression) { | 1361 TEST_F(ApmTest, NoiseSuppression) { |
| 1366 // Test valid suppression levels. | 1362 // Test valid suppression levels. |
| 1367 NoiseSuppression::Level level[] = { | 1363 NoiseSuppression::Level level[] = { |
| 1368 NoiseSuppression::kLow, | 1364 NoiseSuppression::kLow, |
| 1369 NoiseSuppression::kModerate, | 1365 NoiseSuppression::kModerate, |
| 1370 NoiseSuppression::kHigh, | 1366 NoiseSuppression::kHigh, |
| 1371 NoiseSuppression::kVeryHigh | 1367 NoiseSuppression::kVeryHigh |
| 1372 }; | 1368 }; |
| 1373 for (size_t i = 0; i < sizeof(level)/sizeof(*level); i++) { | 1369 for (size_t i = 0; i < arraysize(level); i++) { |
| 1374 EXPECT_EQ(apm_->kNoError, | 1370 EXPECT_EQ(apm_->kNoError, |
| 1375 apm_->noise_suppression()->set_level(level[i])); | 1371 apm_->noise_suppression()->set_level(level[i])); |
| 1376 EXPECT_EQ(level[i], apm_->noise_suppression()->level()); | 1372 EXPECT_EQ(level[i], apm_->noise_suppression()->level()); |
| 1377 } | 1373 } |
| 1378 | 1374 |
| 1379 // Turn NS on/off | 1375 // Turn NS on/off |
| 1380 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(true)); | 1376 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(true)); |
| 1381 EXPECT_TRUE(apm_->noise_suppression()->is_enabled()); | 1377 EXPECT_TRUE(apm_->noise_suppression()->is_enabled()); |
| 1382 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(false)); | 1378 EXPECT_EQ(apm_->kNoError, apm_->noise_suppression()->Enable(false)); |
| 1383 EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); | 1379 EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1465 apm_->voice_detection()->set_stream_has_voice(false)); | 1461 apm_->voice_detection()->set_stream_has_voice(false)); |
| 1466 EXPECT_FALSE(apm_->voice_detection()->stream_has_voice()); | 1462 EXPECT_FALSE(apm_->voice_detection()->stream_has_voice()); |
| 1467 | 1463 |
| 1468 // Test valid likelihoods | 1464 // Test valid likelihoods |
| 1469 VoiceDetection::Likelihood likelihood[] = { | 1465 VoiceDetection::Likelihood likelihood[] = { |
| 1470 VoiceDetection::kVeryLowLikelihood, | 1466 VoiceDetection::kVeryLowLikelihood, |
| 1471 VoiceDetection::kLowLikelihood, | 1467 VoiceDetection::kLowLikelihood, |
| 1472 VoiceDetection::kModerateLikelihood, | 1468 VoiceDetection::kModerateLikelihood, |
| 1473 VoiceDetection::kHighLikelihood | 1469 VoiceDetection::kHighLikelihood |
| 1474 }; | 1470 }; |
| 1475 for (size_t i = 0; i < sizeof(likelihood)/sizeof(*likelihood); i++) { | 1471 for (size_t i = 0; i < arraysize(likelihood); i++) { |
| 1476 EXPECT_EQ(apm_->kNoError, | 1472 EXPECT_EQ(apm_->kNoError, |
| 1477 apm_->voice_detection()->set_likelihood(likelihood[i])); | 1473 apm_->voice_detection()->set_likelihood(likelihood[i])); |
| 1478 EXPECT_EQ(likelihood[i], apm_->voice_detection()->likelihood()); | 1474 EXPECT_EQ(likelihood[i], apm_->voice_detection()->likelihood()); |
| 1479 } | 1475 } |
| 1480 | 1476 |
| 1481 /* TODO(bjornv): Enable once VAD supports other frame lengths than 10 ms | 1477 /* TODO(bjornv): Enable once VAD supports other frame lengths than 10 ms |
| 1482 // Test invalid frame sizes | 1478 // Test invalid frame sizes |
| 1483 EXPECT_EQ(apm_->kBadParameterError, | 1479 EXPECT_EQ(apm_->kBadParameterError, |
| 1484 apm_->voice_detection()->set_frame_size_ms(12)); | 1480 apm_->voice_detection()->set_frame_size_ms(12)); |
| 1485 | 1481 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1497 EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(false)); | 1493 EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(false)); |
| 1498 EXPECT_FALSE(apm_->voice_detection()->is_enabled()); | 1494 EXPECT_FALSE(apm_->voice_detection()->is_enabled()); |
| 1499 | 1495 |
| 1500 // Test that AudioFrame activity is maintained when VAD is disabled. | 1496 // Test that AudioFrame activity is maintained when VAD is disabled. |
| 1501 EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(false)); | 1497 EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(false)); |
| 1502 AudioFrame::VADActivity activity[] = { | 1498 AudioFrame::VADActivity activity[] = { |
| 1503 AudioFrame::kVadActive, | 1499 AudioFrame::kVadActive, |
| 1504 AudioFrame::kVadPassive, | 1500 AudioFrame::kVadPassive, |
| 1505 AudioFrame::kVadUnknown | 1501 AudioFrame::kVadUnknown |
| 1506 }; | 1502 }; |
| 1507 for (size_t i = 0; i < sizeof(activity)/sizeof(*activity); i++) { | 1503 for (size_t i = 0; i < arraysize(activity); i++) { |
| 1508 frame_->vad_activity_ = activity[i]; | 1504 frame_->vad_activity_ = activity[i]; |
| 1509 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 1505 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); |
| 1510 EXPECT_EQ(activity[i], frame_->vad_activity_); | 1506 EXPECT_EQ(activity[i], frame_->vad_activity_); |
| 1511 } | 1507 } |
| 1512 | 1508 |
| 1513 // Test that AudioFrame activity is set when VAD is enabled. | 1509 // Test that AudioFrame activity is set when VAD is enabled. |
| 1514 EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(true)); | 1510 EXPECT_EQ(apm_->kNoError, apm_->voice_detection()->Enable(true)); |
| 1515 frame_->vad_activity_ = AudioFrame::kVadUnknown; | 1511 frame_->vad_activity_ = AudioFrame::kVadUnknown; |
| 1516 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 1512 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); |
| 1517 EXPECT_NE(AudioFrame::kVadUnknown, frame_->vad_activity_); | 1513 EXPECT_NE(AudioFrame::kVadUnknown, frame_->vad_activity_); |
| 1518 | 1514 |
| 1519 // TODO(bjornv): Add tests for streamed voice; stream_has_voice() | 1515 // TODO(bjornv): Add tests for streamed voice; stream_has_voice() |
| 1520 } | 1516 } |
| 1521 | 1517 |
| 1522 TEST_F(ApmTest, AllProcessingDisabledByDefault) { | 1518 TEST_F(ApmTest, AllProcessingDisabledByDefault) { |
| 1523 EXPECT_FALSE(apm_->echo_cancellation()->is_enabled()); | 1519 EXPECT_FALSE(apm_->echo_cancellation()->is_enabled()); |
| 1524 EXPECT_FALSE(apm_->echo_control_mobile()->is_enabled()); | 1520 EXPECT_FALSE(apm_->echo_control_mobile()->is_enabled()); |
| 1525 EXPECT_FALSE(apm_->gain_control()->is_enabled()); | 1521 EXPECT_FALSE(apm_->gain_control()->is_enabled()); |
| 1526 EXPECT_FALSE(apm_->high_pass_filter()->is_enabled()); | 1522 EXPECT_FALSE(apm_->high_pass_filter()->is_enabled()); |
| 1527 EXPECT_FALSE(apm_->level_estimator()->is_enabled()); | 1523 EXPECT_FALSE(apm_->level_estimator()->is_enabled()); |
| 1528 EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); | 1524 EXPECT_FALSE(apm_->noise_suppression()->is_enabled()); |
| 1529 EXPECT_FALSE(apm_->voice_detection()->is_enabled()); | 1525 EXPECT_FALSE(apm_->voice_detection()->is_enabled()); |
| 1530 } | 1526 } |
| 1531 | 1527 |
| 1532 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { | 1528 TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { |
| 1533 for (size_t i = 0; i < kSampleRatesSize; i++) { | 1529 for (size_t i = 0; i < arraysize(kSampleRates); i++) { |
| 1534 Init(kSampleRates[i], kSampleRates[i], kSampleRates[i], 2, 2, 2, false); | 1530 Init(kSampleRates[i], kSampleRates[i], kSampleRates[i], 2, 2, 2, false); |
| 1535 SetFrameTo(frame_, 1000, 2000); | 1531 SetFrameTo(frame_, 1000, 2000); |
| 1536 AudioFrame frame_copy; | 1532 AudioFrame frame_copy; |
| 1537 frame_copy.CopyFrom(*frame_); | 1533 frame_copy.CopyFrom(*frame_); |
| 1538 for (int j = 0; j < 1000; j++) { | 1534 for (int j = 0; j < 1000; j++) { |
| 1539 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 1535 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); |
| 1540 EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); | 1536 EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); |
| 1541 } | 1537 } |
| 1542 } | 1538 } |
| 1543 } | 1539 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1560 sample_rate, LayoutFromChannels(1), &dest_channels)); | 1556 sample_rate, LayoutFromChannels(1), &dest_channels)); |
| 1561 | 1557 |
| 1562 for (size_t i = 0; i < kSamples; ++i) { | 1558 for (size_t i = 0; i < kSamples; ++i) { |
| 1563 EXPECT_EQ(src[i], dest[i]); | 1559 EXPECT_EQ(src[i], dest[i]); |
| 1564 } | 1560 } |
| 1565 } | 1561 } |
| 1566 | 1562 |
| 1567 TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) { | 1563 TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) { |
| 1568 EnableAllComponents(); | 1564 EnableAllComponents(); |
| 1569 | 1565 |
| 1570 for (size_t i = 0; i < kProcessSampleRatesSize; i++) { | 1566 for (size_t i = 0; i < arraysize(kProcessSampleRates); i++) { |
| 1571 Init(kProcessSampleRates[i], | 1567 Init(kProcessSampleRates[i], |
| 1572 kProcessSampleRates[i], | 1568 kProcessSampleRates[i], |
| 1573 kProcessSampleRates[i], | 1569 kProcessSampleRates[i], |
| 1574 2, | 1570 2, |
| 1575 2, | 1571 2, |
| 1576 2, | 1572 2, |
| 1577 false); | 1573 false); |
| 1578 int analog_level = 127; | 1574 int analog_level = 127; |
| 1579 ASSERT_EQ(0, feof(far_file_)); | 1575 ASSERT_EQ(0, feof(far_file_)); |
| 1580 ASSERT_EQ(0, feof(near_file_)); | 1576 ASSERT_EQ(0, feof(near_file_)); |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1896 EnableAllComponents(); | 1892 EnableAllComponents(); |
| 1897 EnableAllAPComponents(fapm.get()); | 1893 EnableAllAPComponents(fapm.get()); |
| 1898 for (int i = 0; i < ref_data.test_size(); i++) { | 1894 for (int i = 0; i < ref_data.test_size(); i++) { |
| 1899 printf("Running test %d of %d...\n", i + 1, ref_data.test_size()); | 1895 printf("Running test %d of %d...\n", i + 1, ref_data.test_size()); |
| 1900 | 1896 |
| 1901 audioproc::Test* test = ref_data.mutable_test(i); | 1897 audioproc::Test* test = ref_data.mutable_test(i); |
| 1902 // TODO(ajm): Restore downmixing test cases. | 1898 // TODO(ajm): Restore downmixing test cases. |
| 1903 if (test->num_input_channels() != test->num_output_channels()) | 1899 if (test->num_input_channels() != test->num_output_channels()) |
| 1904 continue; | 1900 continue; |
| 1905 | 1901 |
| 1906 const int num_render_channels = test->num_reverse_channels(); | 1902 const size_t num_render_channels = |
| 1907 const int num_input_channels = test->num_input_channels(); | 1903 static_cast<size_t>(test->num_reverse_channels()); |
| 1908 const int num_output_channels = test->num_output_channels(); | 1904 const size_t num_input_channels = |
| 1909 const int samples_per_channel = test->sample_rate() * | 1905 static_cast<size_t>(test->num_input_channels()); |
| 1910 AudioProcessing::kChunkSizeMs / 1000; | 1906 const size_t num_output_channels = |
| 1907 static_cast<size_t>(test->num_output_channels()); |
| 1908 const size_t samples_per_channel = static_cast<size_t>( |
| 1909 test->sample_rate() * AudioProcessing::kChunkSizeMs / 1000); |
| 1911 | 1910 |
| 1912 Init(test->sample_rate(), test->sample_rate(), test->sample_rate(), | 1911 Init(test->sample_rate(), test->sample_rate(), test->sample_rate(), |
| 1913 num_input_channels, num_output_channels, num_render_channels, true); | 1912 num_input_channels, num_output_channels, num_render_channels, true); |
| 1914 Init(fapm.get()); | 1913 Init(fapm.get()); |
| 1915 | 1914 |
| 1916 ChannelBuffer<int16_t> output_cb(samples_per_channel, num_input_channels); | 1915 ChannelBuffer<int16_t> output_cb(samples_per_channel, num_input_channels); |
| 1917 ChannelBuffer<int16_t> output_int16(samples_per_channel, | 1916 ChannelBuffer<int16_t> output_int16(samples_per_channel, |
| 1918 num_input_channels); | 1917 num_input_channels); |
| 1919 | 1918 |
| 1920 int analog_level = 127; | 1919 int analog_level = 127; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1941 output_int16.channels()); | 1940 output_int16.channels()); |
| 1942 | 1941 |
| 1943 EXPECT_NOERR(fapm->ProcessStream( | 1942 EXPECT_NOERR(fapm->ProcessStream( |
| 1944 float_cb_->channels(), | 1943 float_cb_->channels(), |
| 1945 samples_per_channel, | 1944 samples_per_channel, |
| 1946 test->sample_rate(), | 1945 test->sample_rate(), |
| 1947 LayoutFromChannels(num_input_channels), | 1946 LayoutFromChannels(num_input_channels), |
| 1948 test->sample_rate(), | 1947 test->sample_rate(), |
| 1949 LayoutFromChannels(num_output_channels), | 1948 LayoutFromChannels(num_output_channels), |
| 1950 float_cb_->channels())); | 1949 float_cb_->channels())); |
| 1951 for (int j = 0; j < num_output_channels; ++j) { | 1950 for (size_t j = 0; j < num_output_channels; ++j) { |
| 1952 FloatToS16(float_cb_->channels()[j], | 1951 FloatToS16(float_cb_->channels()[j], |
| 1953 samples_per_channel, | 1952 samples_per_channel, |
| 1954 output_cb.channels()[j]); | 1953 output_cb.channels()[j]); |
| 1955 float variance = 0; | 1954 float variance = 0; |
| 1956 float snr = ComputeSNR(output_int16.channels()[j], | 1955 float snr = ComputeSNR(output_int16.channels()[j], |
| 1957 output_cb.channels()[j], | 1956 output_cb.channels()[j], |
| 1958 samples_per_channel, &variance); | 1957 samples_per_channel, &variance); |
| 1959 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) | 1958 #if defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) |
| 1960 // There are a few chunks in the fixed-point profile that give low SNR. | 1959 // There are a few chunks in the fixed-point profile that give low SNR. |
| 1961 // Listening confirmed the difference is acceptable. | 1960 // Listening confirmed the difference is acceptable. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1992 // of enabled components. | 1991 // of enabled components. |
| 1993 | 1992 |
| 1994 TEST_F(ApmTest, Process) { | 1993 TEST_F(ApmTest, Process) { |
| 1995 GOOGLE_PROTOBUF_VERIFY_VERSION; | 1994 GOOGLE_PROTOBUF_VERIFY_VERSION; |
| 1996 audioproc::OutputData ref_data; | 1995 audioproc::OutputData ref_data; |
| 1997 | 1996 |
| 1998 if (!write_ref_data) { | 1997 if (!write_ref_data) { |
| 1999 OpenFileAndReadMessage(ref_filename_, &ref_data); | 1998 OpenFileAndReadMessage(ref_filename_, &ref_data); |
| 2000 } else { | 1999 } else { |
| 2001 // Write the desired tests to the protobuf reference file. | 2000 // Write the desired tests to the protobuf reference file. |
| 2002 for (size_t i = 0; i < kChannelsSize; i++) { | 2001 for (size_t i = 0; i < arraysize(kChannels); i++) { |
| 2003 for (size_t j = 0; j < kChannelsSize; j++) { | 2002 for (size_t j = 0; j < arraysize(kChannels); j++) { |
| 2004 for (size_t l = 0; l < kProcessSampleRatesSize; l++) { | 2003 for (size_t l = 0; l < arraysize(kProcessSampleRates); l++) { |
| 2005 audioproc::Test* test = ref_data.add_test(); | 2004 audioproc::Test* test = ref_data.add_test(); |
| 2006 test->set_num_reverse_channels(kChannels[i]); | 2005 test->set_num_reverse_channels(kChannels[i]); |
| 2007 test->set_num_input_channels(kChannels[j]); | 2006 test->set_num_input_channels(kChannels[j]); |
| 2008 test->set_num_output_channels(kChannels[j]); | 2007 test->set_num_output_channels(kChannels[j]); |
| 2009 test->set_sample_rate(kProcessSampleRates[l]); | 2008 test->set_sample_rate(kProcessSampleRates[l]); |
| 2010 test->set_use_aec_extended_filter(false); | 2009 test->set_use_aec_extended_filter(false); |
| 2011 } | 2010 } |
| 2012 } | 2011 } |
| 2013 } | 2012 } |
| 2014 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 2013 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 2035 config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | 2034 config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); |
| 2036 config.Set<ExtendedFilter>( | 2035 config.Set<ExtendedFilter>( |
| 2037 new ExtendedFilter(test->use_aec_extended_filter())); | 2036 new ExtendedFilter(test->use_aec_extended_filter())); |
| 2038 apm_.reset(AudioProcessing::Create(config)); | 2037 apm_.reset(AudioProcessing::Create(config)); |
| 2039 | 2038 |
| 2040 EnableAllComponents(); | 2039 EnableAllComponents(); |
| 2041 | 2040 |
| 2042 Init(test->sample_rate(), | 2041 Init(test->sample_rate(), |
| 2043 test->sample_rate(), | 2042 test->sample_rate(), |
| 2044 test->sample_rate(), | 2043 test->sample_rate(), |
| 2045 test->num_input_channels(), | 2044 static_cast<size_t>(test->num_input_channels()), |
| 2046 test->num_output_channels(), | 2045 static_cast<size_t>(test->num_output_channels()), |
| 2047 test->num_reverse_channels(), | 2046 static_cast<size_t>(test->num_reverse_channels()), |
| 2048 true); | 2047 true); |
| 2049 | 2048 |
| 2050 int frame_count = 0; | 2049 int frame_count = 0; |
| 2051 int has_echo_count = 0; | 2050 int has_echo_count = 0; |
| 2052 int has_voice_count = 0; | 2051 int has_voice_count = 0; |
| 2053 int is_saturated_count = 0; | 2052 int is_saturated_count = 0; |
| 2054 int analog_level = 127; | 2053 int analog_level = 127; |
| 2055 int analog_level_average = 0; | 2054 int analog_level_average = 0; |
| 2056 int max_output_average = 0; | 2055 int max_output_average = 0; |
| 2057 float ns_speech_prob_average = 0.0f; | 2056 float ns_speech_prob_average = 0.0f; |
| 2058 | 2057 |
| 2059 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) { | 2058 while (ReadFrame(far_file_, revframe_) && ReadFrame(near_file_, frame_)) { |
| 2060 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); | 2059 EXPECT_EQ(apm_->kNoError, apm_->AnalyzeReverseStream(revframe_)); |
| 2061 | 2060 |
| 2062 frame_->vad_activity_ = AudioFrame::kVadUnknown; | 2061 frame_->vad_activity_ = AudioFrame::kVadUnknown; |
| 2063 | 2062 |
| 2064 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0)); | 2063 EXPECT_EQ(apm_->kNoError, apm_->set_stream_delay_ms(0)); |
| 2065 apm_->echo_cancellation()->set_stream_drift_samples(0); | 2064 apm_->echo_cancellation()->set_stream_drift_samples(0); |
| 2066 EXPECT_EQ(apm_->kNoError, | 2065 EXPECT_EQ(apm_->kNoError, |
| 2067 apm_->gain_control()->set_stream_analog_level(analog_level)); | 2066 apm_->gain_control()->set_stream_analog_level(analog_level)); |
| 2068 | 2067 |
| 2069 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 2068 EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); |
| 2070 | 2069 |
| 2071 // Ensure the frame was downmixed properly. | 2070 // Ensure the frame was downmixed properly. |
| 2072 EXPECT_EQ(test->num_output_channels(), frame_->num_channels_); | 2071 EXPECT_EQ(static_cast<size_t>(test->num_output_channels()), |
| 2072 frame_->num_channels_); |
| 2073 | 2073 |
| 2074 max_output_average += MaxAudioFrame(*frame_); | 2074 max_output_average += MaxAudioFrame(*frame_); |
| 2075 | 2075 |
| 2076 if (apm_->echo_cancellation()->stream_has_echo()) { | 2076 if (apm_->echo_cancellation()->stream_has_echo()) { |
| 2077 has_echo_count++; | 2077 has_echo_count++; |
| 2078 } | 2078 } |
| 2079 | 2079 |
| 2080 analog_level = apm_->gain_control()->stream_analog_level(); | 2080 analog_level = apm_->gain_control()->stream_analog_level(); |
| 2081 analog_level_average += analog_level; | 2081 analog_level_average += analog_level; |
| 2082 if (apm_->gain_control()->stream_is_saturated()) { | 2082 if (apm_->gain_control()->stream_is_saturated()) { |
| 2083 is_saturated_count++; | 2083 is_saturated_count++; |
| 2084 } | 2084 } |
| 2085 if (apm_->voice_detection()->stream_has_voice()) { | 2085 if (apm_->voice_detection()->stream_has_voice()) { |
| 2086 has_voice_count++; | 2086 has_voice_count++; |
| 2087 EXPECT_EQ(AudioFrame::kVadActive, frame_->vad_activity_); | 2087 EXPECT_EQ(AudioFrame::kVadActive, frame_->vad_activity_); |
| 2088 } else { | 2088 } else { |
| 2089 EXPECT_EQ(AudioFrame::kVadPassive, frame_->vad_activity_); | 2089 EXPECT_EQ(AudioFrame::kVadPassive, frame_->vad_activity_); |
| 2090 } | 2090 } |
| 2091 | 2091 |
| 2092 ns_speech_prob_average += apm_->noise_suppression()->speech_probability(); | 2092 ns_speech_prob_average += apm_->noise_suppression()->speech_probability(); |
| 2093 | 2093 |
| 2094 size_t frame_size = frame_->samples_per_channel_ * frame_->num_channels_; | 2094 size_t frame_size = frame_->samples_per_channel_ * frame_->num_channels_; |
| 2095 size_t write_count = fwrite(frame_->data_, | 2095 size_t write_count = fwrite(frame_->data_, |
| 2096 sizeof(int16_t), | 2096 sizeof(int16_t), |
| 2097 frame_size, | 2097 frame_size, |
| 2098 out_file_); | 2098 out_file_); |
| 2099 ASSERT_EQ(frame_size, write_count); | 2099 ASSERT_EQ(frame_size, write_count); |
| 2100 | 2100 |
| 2101 // Reset in case of downmixing. | 2101 // Reset in case of downmixing. |
| 2102 frame_->num_channels_ = test->num_input_channels(); | 2102 frame_->num_channels_ = static_cast<size_t>(test->num_input_channels()); |
| 2103 frame_count++; | 2103 frame_count++; |
| 2104 } | 2104 } |
| 2105 max_output_average /= frame_count; | 2105 max_output_average /= frame_count; |
| 2106 analog_level_average /= frame_count; | 2106 analog_level_average /= frame_count; |
| 2107 ns_speech_prob_average /= frame_count; | 2107 ns_speech_prob_average /= frame_count; |
| 2108 | 2108 |
| 2109 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 2109 #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) |
| 2110 EchoCancellation::Metrics echo_metrics; | 2110 EchoCancellation::Metrics echo_metrics; |
| 2111 EXPECT_EQ(apm_->kNoError, | 2111 EXPECT_EQ(apm_->kNoError, |
| 2112 apm_->echo_cancellation()->GetMetrics(&echo_metrics)); | 2112 apm_->echo_cancellation()->GetMetrics(&echo_metrics)); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2221 TEST_F(ApmTest, NoErrorsWithKeyboardChannel) { | 2221 TEST_F(ApmTest, NoErrorsWithKeyboardChannel) { |
| 2222 struct ChannelFormat { | 2222 struct ChannelFormat { |
| 2223 AudioProcessing::ChannelLayout in_layout; | 2223 AudioProcessing::ChannelLayout in_layout; |
| 2224 AudioProcessing::ChannelLayout out_layout; | 2224 AudioProcessing::ChannelLayout out_layout; |
| 2225 }; | 2225 }; |
| 2226 ChannelFormat cf[] = { | 2226 ChannelFormat cf[] = { |
| 2227 {AudioProcessing::kMonoAndKeyboard, AudioProcessing::kMono}, | 2227 {AudioProcessing::kMonoAndKeyboard, AudioProcessing::kMono}, |
| 2228 {AudioProcessing::kStereoAndKeyboard, AudioProcessing::kMono}, | 2228 {AudioProcessing::kStereoAndKeyboard, AudioProcessing::kMono}, |
| 2229 {AudioProcessing::kStereoAndKeyboard, AudioProcessing::kStereo}, | 2229 {AudioProcessing::kStereoAndKeyboard, AudioProcessing::kStereo}, |
| 2230 }; | 2230 }; |
| 2231 size_t channel_format_size = sizeof(cf) / sizeof(*cf); | |
| 2232 | 2231 |
| 2233 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create()); | 2232 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create()); |
| 2234 // Enable one component just to ensure some processing takes place. | 2233 // Enable one component just to ensure some processing takes place. |
| 2235 ap->noise_suppression()->Enable(true); | 2234 ap->noise_suppression()->Enable(true); |
| 2236 for (size_t i = 0; i < channel_format_size; ++i) { | 2235 for (size_t i = 0; i < arraysize(cf); ++i) { |
| 2237 const int in_rate = 44100; | 2236 const int in_rate = 44100; |
| 2238 const int out_rate = 48000; | 2237 const int out_rate = 48000; |
| 2239 ChannelBuffer<float> in_cb(SamplesFromRate(in_rate), | 2238 ChannelBuffer<float> in_cb(SamplesFromRate(in_rate), |
| 2240 TotalChannelsFromLayout(cf[i].in_layout)); | 2239 TotalChannelsFromLayout(cf[i].in_layout)); |
| 2241 ChannelBuffer<float> out_cb(SamplesFromRate(out_rate), | 2240 ChannelBuffer<float> out_cb(SamplesFromRate(out_rate), |
| 2242 ChannelsFromLayout(cf[i].out_layout)); | 2241 ChannelsFromLayout(cf[i].out_layout)); |
| 2243 | 2242 |
| 2244 // Run over a few chunks. | 2243 // Run over a few chunks. |
| 2245 for (int j = 0; j < 10; ++j) { | 2244 for (int j = 0; j < 10; ++j) { |
| 2246 EXPECT_NOERR(ap->ProcessStream( | 2245 EXPECT_NOERR(ap->ProcessStream( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2314 : input_rate_(std::tr1::get<0>(GetParam())), | 2313 : input_rate_(std::tr1::get<0>(GetParam())), |
| 2315 output_rate_(std::tr1::get<1>(GetParam())), | 2314 output_rate_(std::tr1::get<1>(GetParam())), |
| 2316 reverse_rate_(std::tr1::get<2>(GetParam())), | 2315 reverse_rate_(std::tr1::get<2>(GetParam())), |
| 2317 expected_snr_(std::tr1::get<3>(GetParam())) {} | 2316 expected_snr_(std::tr1::get<3>(GetParam())) {} |
| 2318 | 2317 |
| 2319 virtual ~AudioProcessingTest() {} | 2318 virtual ~AudioProcessingTest() {} |
| 2320 | 2319 |
| 2321 static void SetUpTestCase() { | 2320 static void SetUpTestCase() { |
| 2322 // Create all needed output reference files. | 2321 // Create all needed output reference files. |
| 2323 const int kNativeRates[] = {8000, 16000, 32000, 48000}; | 2322 const int kNativeRates[] = {8000, 16000, 32000, 48000}; |
| 2324 const size_t kNativeRatesSize = | 2323 const size_t kNumChannels[] = {1, 2}; |
| 2325 sizeof(kNativeRates) / sizeof(*kNativeRates); | 2324 for (size_t i = 0; i < arraysize(kNativeRates); ++i) { |
| 2326 const int kNumChannels[] = {1, 2}; | 2325 for (size_t j = 0; j < arraysize(kNumChannels); ++j) { |
| 2327 const size_t kNumChannelsSize = | 2326 for (size_t k = 0; k < arraysize(kNumChannels); ++k) { |
| 2328 sizeof(kNumChannels) / sizeof(*kNumChannels); | |
| 2329 for (size_t i = 0; i < kNativeRatesSize; ++i) { | |
| 2330 for (size_t j = 0; j < kNumChannelsSize; ++j) { | |
| 2331 for (size_t k = 0; k < kNumChannelsSize; ++k) { | |
| 2332 // The reference files always have matching input and output channels. | 2327 // The reference files always have matching input and output channels. |
| 2333 ProcessFormat(kNativeRates[i], | 2328 ProcessFormat(kNativeRates[i], |
| 2334 kNativeRates[i], | 2329 kNativeRates[i], |
| 2335 kNativeRates[i], | 2330 kNativeRates[i], |
| 2336 kNumChannels[j], | 2331 kNumChannels[j], |
| 2337 kNumChannels[j], | 2332 kNumChannels[j], |
| 2338 kNumChannels[k], | 2333 kNumChannels[k], |
| 2339 "ref"); | 2334 "ref"); |
| 2340 } | 2335 } |
| 2341 } | 2336 } |
| 2342 } | 2337 } |
| 2343 } | 2338 } |
| 2344 | 2339 |
| 2345 static void TearDownTestCase() { | 2340 static void TearDownTestCase() { |
| 2346 ClearTempFiles(); | 2341 ClearTempFiles(); |
| 2347 } | 2342 } |
| 2348 // Runs a process pass on files with the given parameters and dumps the output | 2343 // Runs a process pass on files with the given parameters and dumps the output |
| 2349 // to a file specified with |output_file_prefix|. | 2344 // to a file specified with |output_file_prefix|. |
| 2350 static void ProcessFormat(int input_rate, | 2345 static void ProcessFormat(int input_rate, |
| 2351 int output_rate, | 2346 int output_rate, |
| 2352 int reverse_rate, | 2347 int reverse_rate, |
| 2353 int num_input_channels, | 2348 size_t num_input_channels, |
| 2354 int num_output_channels, | 2349 size_t num_output_channels, |
| 2355 int num_reverse_channels, | 2350 size_t num_reverse_channels, |
| 2356 std::string output_file_prefix) { | 2351 std::string output_file_prefix) { |
| 2357 Config config; | 2352 Config config; |
| 2358 config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | 2353 config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); |
| 2359 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); | 2354 rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); |
| 2360 EnableAllAPComponents(ap.get()); | 2355 EnableAllAPComponents(ap.get()); |
| 2361 ap->Initialize({{{input_rate, num_input_channels}, | 2356 ap->Initialize({{{input_rate, num_input_channels}, |
| 2362 {output_rate, num_output_channels}, | 2357 {output_rate, num_output_channels}, |
| 2363 {reverse_rate, num_reverse_channels}}}); | 2358 {reverse_rate, num_reverse_channels}}}); |
| 2364 | 2359 |
| 2365 FILE* far_file = fopen(ResourceFilePath("far", reverse_rate).c_str(), "rb"); | 2360 FILE* far_file = fopen(ResourceFilePath("far", reverse_rate).c_str(), "rb"); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 int num_reverse; | 2438 int num_reverse; |
| 2444 }; | 2439 }; |
| 2445 ChannelFormat cf[] = { | 2440 ChannelFormat cf[] = { |
| 2446 {1, 1, 1}, | 2441 {1, 1, 1}, |
| 2447 {1, 1, 2}, | 2442 {1, 1, 2}, |
| 2448 {2, 1, 1}, | 2443 {2, 1, 1}, |
| 2449 {2, 1, 2}, | 2444 {2, 1, 2}, |
| 2450 {2, 2, 1}, | 2445 {2, 2, 1}, |
| 2451 {2, 2, 2}, | 2446 {2, 2, 2}, |
| 2452 }; | 2447 }; |
| 2453 size_t channel_format_size = sizeof(cf) / sizeof(*cf); | |
| 2454 | 2448 |
| 2455 for (size_t i = 0; i < channel_format_size; ++i) { | 2449 for (size_t i = 0; i < arraysize(cf); ++i) { |
| 2456 ProcessFormat(input_rate_, | 2450 ProcessFormat(input_rate_, |
| 2457 output_rate_, | 2451 output_rate_, |
| 2458 reverse_rate_, | 2452 reverse_rate_, |
| 2459 cf[i].num_input, | 2453 cf[i].num_input, |
| 2460 cf[i].num_output, | 2454 cf[i].num_output, |
| 2461 cf[i].num_reverse, | 2455 cf[i].num_reverse, |
| 2462 "out"); | 2456 "out"); |
| 2463 int min_ref_rate = std::min(input_rate_, output_rate_); | 2457 int min_ref_rate = std::min(input_rate_, output_rate_); |
| 2464 int ref_rate; | 2458 int ref_rate; |
| 2465 | 2459 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2681 std::tr1::make_tuple(16000, 16000, 32000, 40), | 2675 std::tr1::make_tuple(16000, 16000, 32000, 40), |
| 2682 std::tr1::make_tuple(16000, 16000, 16000, 0))); | 2676 std::tr1::make_tuple(16000, 16000, 16000, 0))); |
| 2683 #endif | 2677 #endif |
| 2684 | 2678 |
| 2685 // TODO(henrike): re-implement functionality lost when removing the old main | 2679 // TODO(henrike): re-implement functionality lost when removing the old main |
| 2686 // function. See | 2680 // function. See |
| 2687 // https://code.google.com/p/webrtc/issues/detail?id=1981 | 2681 // https://code.google.com/p/webrtc/issues/detail?id=1981 |
| 2688 | 2682 |
| 2689 } // namespace | 2683 } // namespace |
| 2690 } // namespace webrtc | 2684 } // namespace webrtc |
| OLD | NEW |