Chromium Code Reviews| Index: webrtc/modules/audio_processing/test/audio_processing_unittest.cc | 
| diff --git a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc | 
| index 3030182676a262ee03a3258829849c47cbe41c21..f059552f9c43b89708a2a6cc18cac49db6e79a0a 100644 | 
| --- a/webrtc/modules/audio_processing/test/audio_processing_unittest.cc | 
| +++ b/webrtc/modules/audio_processing/test/audio_processing_unittest.cc | 
| @@ -62,6 +62,8 @@ const int kProcessSampleRates[] = {8000, 16000, 32000, 48000}; | 
| const size_t kProcessSampleRatesSize = sizeof(kProcessSampleRates) / | 
| sizeof(*kProcessSampleRates); | 
| +enum StreamDirection { kFwd = 0, kRev }; | 
| 
 
aluebs-webrtc
2015/08/10 19:14:18
How about spelling these out: kForward and kRevers
 
ekm
2015/08/11 23:59:36
Done.
 
 | 
| + | 
| void ConvertToFloat(const int16_t* int_data, ChannelBuffer<float>* cb) { | 
| ChannelBuffer<int16_t> cb_int(cb->num_frames(), | 
| cb->num_channels()); | 
| @@ -252,13 +254,16 @@ std::map<std::string, std::string> temp_filenames; | 
| std::string OutputFilePath(std::string name, | 
| int input_rate, | 
| int output_rate, | 
| - int reverse_rate, | 
| + int reverse_input_rate, | 
| + int reverse_output_rate, | 
| int num_input_channels, | 
| int num_output_channels, | 
| - int num_reverse_channels) { | 
| + int num_reverse_input_channels, | 
| + int num_reverse_output_channels, | 
| + StreamDirection file_direction) { | 
| std::ostringstream ss; | 
| - ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 | 
| - << "_r" << num_reverse_channels << "_" << reverse_rate / 1000 << "_"; | 
| + ss << name << "_i" << num_input_channels << "_" << input_rate / 1000 << "_ir" | 
| + << num_reverse_input_channels << "_" << reverse_input_rate / 1000 << "_"; | 
| if (num_output_channels == 1) { | 
| ss << "mono"; | 
| } else if (num_output_channels == 2) { | 
| @@ -266,7 +271,16 @@ std::string OutputFilePath(std::string name, | 
| } else { | 
| assert(false); | 
| } | 
| - ss << output_rate / 1000 << "_pcm"; | 
| + ss << output_rate / 1000; | 
| + if (num_reverse_output_channels == 1) { | 
| + ss << "_rmono"; | 
| + } else if (num_reverse_output_channels == 2) { | 
| + ss << "_rstereo"; | 
| + } else { | 
| + assert(false); | 
| + } | 
| + ss << reverse_output_rate / 1000; | 
| + ss << "_d" << file_direction << "_pcm"; | 
| std::string filename = ss.str(); | 
| if (temp_filenames[filename].empty()) | 
| @@ -340,9 +354,9 @@ class ApmTest : public ::testing::Test { | 
| void Init(int sample_rate_hz, | 
| int output_sample_rate_hz, | 
| int reverse_sample_rate_hz, | 
| - int num_reverse_channels, | 
| int num_input_channels, | 
| int num_output_channels, | 
| + int num_reverse_channels, | 
| bool open_output_file); | 
| void Init(AudioProcessing* ap); | 
| void EnableAllComponents(); | 
| @@ -458,6 +472,7 @@ void ApmTest::Init(AudioProcessing* ap) { | 
| ap->Initialize( | 
| {{{frame_->sample_rate_hz_, frame_->num_channels_}, | 
| {output_sample_rate_hz_, num_output_channels_}, | 
| + {revframe_->sample_rate_hz_, revframe_->num_channels_}, | 
| {revframe_->sample_rate_hz_, revframe_->num_channels_}}})); | 
| } | 
| @@ -496,13 +511,10 @@ void ApmTest::Init(int sample_rate_hz, | 
| if (out_file_) { | 
| ASSERT_EQ(0, fclose(out_file_)); | 
| } | 
| - filename = OutputFilePath("out", | 
| - sample_rate_hz, | 
| - output_sample_rate_hz, | 
| - reverse_sample_rate_hz, | 
| - num_input_channels, | 
| - num_output_channels, | 
| - num_reverse_channels); | 
| + filename = OutputFilePath("out", sample_rate_hz, output_sample_rate_hz, | 
| + reverse_sample_rate_hz, reverse_sample_rate_hz, | 
| + num_input_channels, num_output_channels, | 
| + num_reverse_channels, num_reverse_channels, kFwd); | 
| out_file_ = fopen(filename.c_str(), "wb"); | 
| ASSERT_TRUE(out_file_ != NULL) << "Could not open file " << | 
| filename << "\n"; | 
| @@ -819,13 +831,16 @@ void ApmTest::TestChangingReverseChannels( | 
| int num_rev_channels, | 
| AudioProcessing::Error expected_return) { | 
| const ProcessingConfig processing_config = { | 
| - {{ frame_->sample_rate_hz_, apm_->num_input_channels() }, | 
| - { output_sample_rate_hz_, apm_->num_output_channels() }, | 
| - { frame_->sample_rate_hz_, num_rev_channels }}}; | 
| + {{frame_->sample_rate_hz_, apm_->num_input_channels()}, | 
| + {output_sample_rate_hz_, apm_->num_output_channels()}, | 
| + {frame_->sample_rate_hz_, num_rev_channels}, | 
| + {frame_->sample_rate_hz_, num_rev_channels}}}; | 
| - EXPECT_EQ(expected_return, | 
| - apm_->AnalyzeReverseStream(float_cb_->channels(), | 
| - processing_config.reverse_stream())); | 
| + EXPECT_EQ( | 
| + expected_return, | 
| + apm_->ProcessReverseStream( | 
| + float_cb_->channels(), processing_config.reverse_input_stream(), | 
| + processing_config.reverse_output_stream(), float_cb_->channels())); | 
| } | 
| TEST_F(ApmTest, ChannelsInt16Interface) { | 
| @@ -1531,6 +1546,8 @@ TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabled) { | 
| for (int j = 0; j < 1000; j++) { | 
| EXPECT_EQ(apm_->kNoError, apm_->ProcessStream(frame_)); | 
| EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); | 
| + EXPECT_EQ(apm_->kNoError, apm_->ProcessReverseStream(frame_)); | 
| + EXPECT_TRUE(FrameDataAreEqual(*frame_, frame_copy)); | 
| } | 
| } | 
| } | 
| @@ -1555,6 +1572,19 @@ TEST_F(ApmTest, NoProcessingWhenAllComponentsDisabledFloat) { | 
| for (size_t i = 0; i < kSamples; ++i) { | 
| EXPECT_EQ(src[i], dest[i]); | 
| } | 
| + | 
| + // Same for ProcessReverseStream. | 
| + float rev_dest[kSamples] = {}; | 
| + auto rev_dest_channels = &rev_dest[0]; | 
| + | 
| + StreamConfig input_stream = {sample_rate, 1}; | 
| + StreamConfig output_stream = {sample_rate, 1}; | 
| + EXPECT_NOERR(apm_->ProcessReverseStream(&src_channels, input_stream, | 
| + output_stream, &rev_dest_channels)); | 
| + | 
| + for (size_t i = 0; i < kSamples; ++i) { | 
| + EXPECT_EQ(src[i], rev_dest[i]); | 
| + } | 
| } | 
| TEST_F(ApmTest, IdenticalInputChannelsResultInIdenticalOutputChannels) { | 
| @@ -2299,15 +2329,18 @@ void UpdateBestSNR(const float* ref, | 
| // Due to the resampling distortion, we don't expect identical results, but | 
| // enforce SNR thresholds which vary depending on the format. 0 is a special | 
| // case SNR which corresponds to inf, or zero error. | 
| -typedef std::tr1::tuple<int, int, int, double> AudioProcessingTestData; | 
| +typedef std::tr1::tuple<int, int, int, int, double, double> | 
| + AudioProcessingTestData; | 
| class AudioProcessingTest | 
| : public testing::TestWithParam<AudioProcessingTestData> { | 
| public: | 
| AudioProcessingTest() | 
| : input_rate_(std::tr1::get<0>(GetParam())), | 
| output_rate_(std::tr1::get<1>(GetParam())), | 
| - reverse_rate_(std::tr1::get<2>(GetParam())), | 
| - expected_snr_(std::tr1::get<3>(GetParam())) {} | 
| + reverse_input_rate_(std::tr1::get<2>(GetParam())), | 
| + reverse_output_rate_(std::tr1::get<3>(GetParam())), | 
| + expected_snr_(std::tr1::get<4>(GetParam())), | 
| + expected_reverse_snr_(std::tr1::get<5>(GetParam())) {} | 
| virtual ~AudioProcessingTest() {} | 
| @@ -2319,17 +2352,16 @@ class AudioProcessingTest | 
| const int kNumChannels[] = {1, 2}; | 
| const size_t kNumChannelsSize = | 
| sizeof(kNumChannels) / sizeof(*kNumChannels); | 
| - for (size_t i = 0; i < kNativeRatesSize; ++i) { | 
| - for (size_t j = 0; j < kNumChannelsSize; ++j) { | 
| - for (size_t k = 0; k < kNumChannelsSize; ++k) { | 
| + for (auto file_direction : {kFwd, kRev}) { | 
| + for (size_t i = 0; i < kNativeRatesSize; ++i) { | 
| + for (size_t j = 0; j < kNumChannelsSize; ++j) { | 
| + for (size_t k = 0; k < kNumChannelsSize; ++k) { | 
| // The reference files always have matching input and output channels. | 
| - ProcessFormat(kNativeRates[i], | 
| - kNativeRates[i], | 
| - kNativeRates[i], | 
| - kNumChannels[j], | 
| - kNumChannels[j], | 
| - kNumChannels[k], | 
| - "ref"); | 
| + ProcessFormat(kNativeRates[i], kNativeRates[i], kNativeRates[i], | 
| + kNativeRates[i], kNumChannels[j], kNumChannels[j], | 
| + kNumChannels[k], kNumChannels[k], "ref", | 
| + file_direction); | 
| + } | 
| } | 
| } | 
| } | 
| @@ -2338,59 +2370,68 @@ class AudioProcessingTest | 
| static void TearDownTestCase() { | 
| ClearTempFiles(); | 
| } | 
| + | 
| // Runs a process pass on files with the given parameters and dumps the output | 
| - // to a file specified with |output_file_prefix|. | 
| + // to a file specified with |output_file_prefix|. |file_direction| indicates | 
| + // whether the forward or reverse output should be dumped. | 
| static void ProcessFormat(int input_rate, | 
| int output_rate, | 
| - int reverse_rate, | 
| + int reverse_input_rate, | 
| + int reverse_output_rate, | 
| int num_input_channels, | 
| int num_output_channels, | 
| - int num_reverse_channels, | 
| - std::string output_file_prefix) { | 
| + int num_reverse_input_channels, | 
| + int num_reverse_output_channels, | 
| + std::string output_file_prefix, | 
| + StreamDirection file_direction) { | 
| Config config; | 
| config.Set<ExperimentalAgc>(new ExperimentalAgc(false)); | 
| rtc::scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(config)); | 
| EnableAllAPComponents(ap.get()); | 
| - ap->Initialize({{{input_rate, num_input_channels}, | 
| - {output_rate, num_output_channels}, | 
| - {reverse_rate, num_reverse_channels}}}); | 
| - FILE* far_file = fopen(ResourceFilePath("far", reverse_rate).c_str(), "rb"); | 
| + ProcessingConfig processing_config = { | 
| + {{input_rate, num_input_channels}, | 
| + {output_rate, num_output_channels}, | 
| + {reverse_input_rate, num_reverse_input_channels}, | 
| + {reverse_output_rate, num_reverse_output_channels}}}; | 
| + ap->Initialize(processing_config); | 
| + | 
| + FILE* far_file = | 
| + fopen(ResourceFilePath("far", reverse_input_rate).c_str(), "rb"); | 
| FILE* near_file = fopen(ResourceFilePath("near", input_rate).c_str(), "rb"); | 
| - FILE* out_file = fopen(OutputFilePath(output_file_prefix, | 
| - input_rate, | 
| - output_rate, | 
| - reverse_rate, | 
| - num_input_channels, | 
| - num_output_channels, | 
| - num_reverse_channels).c_str(), "wb"); | 
| + FILE* out_file = | 
| + fopen(OutputFilePath( | 
| + output_file_prefix, input_rate, output_rate, | 
| + reverse_input_rate, reverse_output_rate, num_input_channels, | 
| + num_output_channels, num_reverse_input_channels, | 
| + num_reverse_output_channels, file_direction).c_str(), | 
| + "wb"); | 
| ASSERT_TRUE(far_file != NULL); | 
| ASSERT_TRUE(near_file != NULL); | 
| ASSERT_TRUE(out_file != NULL); | 
| ChannelBuffer<float> fwd_cb(SamplesFromRate(input_rate), | 
| num_input_channels); | 
| - ChannelBuffer<float> rev_cb(SamplesFromRate(reverse_rate), | 
| - num_reverse_channels); | 
| + ChannelBuffer<float> rev_cb(SamplesFromRate(reverse_input_rate), | 
| + num_reverse_input_channels); | 
| ChannelBuffer<float> out_cb(SamplesFromRate(output_rate), | 
| num_output_channels); | 
| + ChannelBuffer<float> rev_out_cb(SamplesFromRate(reverse_output_rate), | 
| + num_reverse_output_channels); | 
| // Temporary buffers. | 
| const int max_length = | 
| - 2 * std::max(out_cb.num_frames(), | 
| - std::max(fwd_cb.num_frames(), | 
| - rev_cb.num_frames())); | 
| + 2 * std::max(std::max(out_cb.num_frames(), rev_out_cb.num_frames()), | 
| + std::max(fwd_cb.num_frames(), rev_cb.num_frames())); | 
| rtc::scoped_ptr<float[]> float_data(new float[max_length]); | 
| rtc::scoped_ptr<int16_t[]> int_data(new int16_t[max_length]); | 
| int analog_level = 127; | 
| while (ReadChunk(far_file, int_data.get(), float_data.get(), &rev_cb) && | 
| ReadChunk(near_file, int_data.get(), float_data.get(), &fwd_cb)) { | 
| - EXPECT_NOERR(ap->AnalyzeReverseStream( | 
| - rev_cb.channels(), | 
| - rev_cb.num_frames(), | 
| - reverse_rate, | 
| - LayoutFromChannels(num_reverse_channels))); | 
| + EXPECT_NOERR(ap->ProcessReverseStream( | 
| + rev_cb.channels(), processing_config.reverse_input_stream(), | 
| + processing_config.reverse_output_stream(), rev_out_cb.channels())); | 
| EXPECT_NOERR(ap->set_stream_delay_ms(0)); | 
| ap->echo_cancellation()->set_stream_drift_samples(0); | 
| @@ -2405,12 +2446,12 @@ class AudioProcessingTest | 
| LayoutFromChannels(num_output_channels), | 
| out_cb.channels())); | 
| - Interleave(out_cb.channels(), | 
| - out_cb.num_frames(), | 
| - out_cb.num_channels(), | 
| - float_data.get()); | 
| + ChannelBuffer<float>* cb_write = file_direction ? &rev_out_cb : &out_cb; | 
| 
 
Andrew MacDonald
2015/08/10 19:24:05
nit: could make this a const reference.
 
ekm
2015/08/11 23:59:36
Removed.
 
 | 
| + Interleave(cb_write->channels(), cb_write->num_frames(), | 
| + cb_write->num_channels(), float_data.get()); | 
| + int out_length = cb_write->num_channels() * cb_write->num_frames(); | 
| + | 
| // Dump output to file. | 
| - int out_length = out_cb.num_channels() * out_cb.num_frames(); | 
| ASSERT_EQ(static_cast<size_t>(out_length), | 
| fwrite(float_data.get(), sizeof(float_data[0]), | 
| out_length, out_file)); | 
| @@ -2425,35 +2466,52 @@ class AudioProcessingTest | 
| protected: | 
| int input_rate_; | 
| int output_rate_; | 
| - int reverse_rate_; | 
| + int reverse_input_rate_; | 
| + int reverse_output_rate_; | 
| double expected_snr_; | 
| + double expected_reverse_snr_; | 
| }; | 
| TEST_P(AudioProcessingTest, Formats) { | 
| struct ChannelFormat { | 
| int num_input; | 
| int num_output; | 
| - int num_reverse; | 
| + int num_reverse_input; | 
| + int num_reverse_output; | 
| }; | 
| ChannelFormat cf[] = { | 
| - {1, 1, 1}, | 
| - {1, 1, 2}, | 
| - {2, 1, 1}, | 
| - {2, 1, 2}, | 
| - {2, 2, 1}, | 
| - {2, 2, 2}, | 
| + {1, 1, 1, 1}, | 
| + {1, 1, 2, 1}, | 
| + {2, 1, 1, 1}, | 
| + {2, 1, 2, 1}, | 
| + {2, 2, 1, 1}, | 
| + {2, 2, 2, 2}, | 
| 
 
aluebs-webrtc
2015/08/10 19:14:18
If this is supposed to be an exhaustive list, you
 
Andrew MacDonald
2015/08/10 19:30:51
Right, I don't think there's a lot of value in mak
 
ekm
2015/08/11 23:59:36
Acknowledged.
 
 | 
| }; | 
| size_t channel_format_size = sizeof(cf) / sizeof(*cf); | 
| + for (auto file_direction : {kFwd, kRev}) { | 
| 
 
ekm
2015/08/07 06:06:00
The following 124 lines should be indented, but co
 
aluebs-webrtc
2015/08/10 19:14:18
Thanks :)
Just remember to change it before landin
 
Andrew MacDonald
2015/08/10 19:24:05
Nice, thanks.
This looks pretty good, but I see o
 
ekm
2015/08/11 23:59:36
Done. Yep, switched up ProcessFormat to write both
 
 | 
| for (size_t i = 0; i < channel_format_size; ++i) { | 
| - ProcessFormat(input_rate_, | 
| - output_rate_, | 
| - reverse_rate_, | 
| - cf[i].num_input, | 
| - cf[i].num_output, | 
| - cf[i].num_reverse, | 
| - "out"); | 
| - int min_ref_rate = std::min(input_rate_, output_rate_); | 
| + ProcessFormat(input_rate_, output_rate_, reverse_input_rate_, | 
| + reverse_output_rate_, cf[i].num_input, cf[i].num_output, | 
| + cf[i].num_reverse_input, cf[i].num_reverse_output, "out", | 
| + file_direction); | 
| + int in_rate, out_rate, in_num, out_num; | 
| + double expected_snr; | 
| + if (file_direction == kFwd) { | 
| + in_rate = input_rate_; | 
| + out_rate = output_rate_; | 
| + in_num = cf[i].num_input; | 
| + out_num = cf[i].num_output; | 
| + expected_snr = expected_snr_; | 
| + } else { | 
| + in_rate = reverse_input_rate_; | 
| + out_rate = reverse_output_rate_; | 
| + in_num = cf[i].num_reverse_input; | 
| + out_num = cf[i].num_reverse_output; | 
| + expected_snr = expected_reverse_snr_; | 
| + } | 
| 
 
aluebs-webrtc
2015/08/10 19:14:18
I think it is clearer to declare and define each v
 
ekm
2015/08/11 23:59:36
Done.
 
 | 
| + | 
| + int min_ref_rate = std::min(in_rate, out_rate); | 
| int ref_rate; | 
| if (min_ref_rate > 32000) { | 
| @@ -2466,29 +2524,28 @@ TEST_P(AudioProcessingTest, Formats) { | 
| ref_rate = 8000; | 
| } | 
| #ifdef WEBRTC_AUDIOPROC_FIXED_PROFILE | 
| - ref_rate = std::min(ref_rate, 16000); | 
| + if (file_direction == kFwd) { | 
| + ref_rate = std::min(ref_rate, 16000); | 
| + } | 
| #endif | 
| - | 
| - FILE* out_file = fopen(OutputFilePath("out", | 
| - input_rate_, | 
| - output_rate_, | 
| - reverse_rate_, | 
| - cf[i].num_input, | 
| - cf[i].num_output, | 
| - cf[i].num_reverse).c_str(), "rb"); | 
| + FILE* out_file = fopen( | 
| + OutputFilePath("out", input_rate_, output_rate_, reverse_input_rate_, | 
| + reverse_output_rate_, cf[i].num_input, | 
| + cf[i].num_output, cf[i].num_reverse_input, | 
| + cf[i].num_reverse_output, file_direction).c_str(), | 
| + "rb"); | 
| // The reference files always have matching input and output channels. | 
| - FILE* ref_file = fopen(OutputFilePath("ref", | 
| - ref_rate, | 
| - ref_rate, | 
| - ref_rate, | 
| - cf[i].num_output, | 
| - cf[i].num_output, | 
| - cf[i].num_reverse).c_str(), "rb"); | 
| + FILE* ref_file = fopen( | 
| + OutputFilePath("ref", ref_rate, ref_rate, ref_rate, ref_rate, | 
| + cf[i].num_output, cf[i].num_output, | 
| + cf[i].num_reverse_output, cf[i].num_reverse_output, | 
| + file_direction).c_str(), | 
| + "rb"); | 
| ASSERT_TRUE(out_file != NULL); | 
| ASSERT_TRUE(ref_file != NULL); | 
| - const int ref_length = SamplesFromRate(ref_rate) * cf[i].num_output; | 
| - const int out_length = SamplesFromRate(output_rate_) * cf[i].num_output; | 
| + const int ref_length = SamplesFromRate(ref_rate) * out_num; | 
| + const int out_length = SamplesFromRate(out_rate) * out_num; | 
| // Data from the reference file. | 
| rtc::scoped_ptr<float[]> ref_data(new float[ref_length]); | 
| // Data from the output file. | 
| @@ -2498,181 +2555,181 @@ TEST_P(AudioProcessingTest, Formats) { | 
| rtc::scoped_ptr<float[]> cmp_data(new float[ref_length]); | 
| PushResampler<float> resampler; | 
| - resampler.InitializeIfNeeded(output_rate_, ref_rate, cf[i].num_output); | 
| + resampler.InitializeIfNeeded(out_rate, ref_rate, out_num); | 
| // Compute the resampling delay of the output relative to the reference, | 
| // to find the region over which we should search for the best SNR. | 
| float expected_delay_sec = 0; | 
| - if (input_rate_ != ref_rate) { | 
| + if (in_rate != ref_rate) { | 
| // Input resampling delay. | 
| expected_delay_sec += | 
| - PushSincResampler::AlgorithmicDelaySeconds(input_rate_); | 
| + PushSincResampler::AlgorithmicDelaySeconds(in_rate); | 
| } | 
| - if (output_rate_ != ref_rate) { | 
| + if (out_rate != ref_rate) { | 
| // Output resampling delay. | 
| expected_delay_sec += | 
| PushSincResampler::AlgorithmicDelaySeconds(ref_rate); | 
| - // Delay of converting the output back to its processing rate for testing. | 
| + // Delay of converting the output back to its processing rate for | 
| + // testing. | 
| expected_delay_sec += | 
| - PushSincResampler::AlgorithmicDelaySeconds(output_rate_); | 
| + PushSincResampler::AlgorithmicDelaySeconds(out_rate); | 
| } | 
| - int expected_delay = floor(expected_delay_sec * ref_rate + 0.5f) * | 
| - cf[i].num_output; | 
| + int expected_delay = | 
| + floor(expected_delay_sec * ref_rate + 0.5f) * out_num; | 
| double variance = 0; | 
| double sq_error = 0; | 
| while (fread(out_data.get(), sizeof(out_data[0]), out_length, out_file) && | 
| fread(ref_data.get(), sizeof(ref_data[0]), ref_length, ref_file)) { | 
| float* out_ptr = out_data.get(); | 
| - if (output_rate_ != ref_rate) { | 
| - // Resample the output back to its internal processing rate if necssary. | 
| - ASSERT_EQ(ref_length, resampler.Resample(out_ptr, | 
| - out_length, | 
| - cmp_data.get(), | 
| - ref_length)); | 
| + if (out_rate != ref_rate) { | 
| + // Resample the output back to its internal processing rate if | 
| + // necssary. | 
| + ASSERT_EQ(ref_length, resampler.Resample(out_ptr, out_length, | 
| + cmp_data.get(), ref_length)); | 
| out_ptr = cmp_data.get(); | 
| } | 
| - // Update the |sq_error| and |variance| accumulators with the highest SNR | 
| + // Update the |sq_error| and |variance| accumulators with the highest | 
| + // SNR | 
| // of reference vs output. | 
| 
 
Andrew MacDonald
2015/08/10 19:24:05
Move to previous line.
 
ekm
2015/08/11 23:59:36
Done.
 
 | 
| - UpdateBestSNR(ref_data.get(), | 
| - out_ptr, | 
| - ref_length, | 
| - expected_delay, | 
| - &variance, | 
| - &sq_error); | 
| + UpdateBestSNR(ref_data.get(), out_ptr, ref_length, expected_delay, | 
| + &variance, &sq_error); | 
| } | 
| - std::cout << "(" << input_rate_ << ", " | 
| - << output_rate_ << ", " | 
| - << reverse_rate_ << ", " | 
| - << cf[i].num_input << ", " | 
| - << cf[i].num_output << ", " | 
| - << cf[i].num_reverse << "): "; | 
| + std::cout << "(" << input_rate_ << ", " << output_rate_ << ", " | 
| + << reverse_input_rate_ << ", " << reverse_output_rate_ << ", " | 
| + << cf[i].num_input << ", " << cf[i].num_output << ", " | 
| + << cf[i].num_reverse_input << ", " << cf[i].num_reverse_output | 
| + << ", " << file_direction << "): "; | 
| if (sq_error > 0) { | 
| double snr = 10 * log10(variance / sq_error); | 
| - EXPECT_GE(snr, expected_snr_); | 
| - EXPECT_NE(0, expected_snr_); | 
| + EXPECT_GE(snr, expected_snr); | 
| + EXPECT_NE(0, expected_snr); | 
| std::cout << "SNR=" << snr << " dB" << std::endl; | 
| } else { | 
| - EXPECT_EQ(expected_snr_, 0); | 
| - std::cout << "SNR=" << "inf dB" << std::endl; | 
| + EXPECT_EQ(expected_snr, 0); | 
| + std::cout << "SNR=" | 
| + << "inf dB" << std::endl; | 
| } | 
| - fclose(out_file); | 
| - fclose(ref_file); | 
| + fclose(out_file); | 
| + fclose(ref_file); | 
| + } | 
| } | 
| } | 
| #if defined(WEBRTC_AUDIOPROC_FLOAT_PROFILE) | 
| INSTANTIATE_TEST_CASE_P( | 
| - CommonFormats, AudioProcessingTest, testing::Values( | 
| - std::tr1::make_tuple(48000, 48000, 48000, 0), | 
| - std::tr1::make_tuple(48000, 48000, 32000, 40), | 
| - std::tr1::make_tuple(48000, 48000, 16000, 40), | 
| - std::tr1::make_tuple(48000, 44100, 48000, 20), | 
| - std::tr1::make_tuple(48000, 44100, 32000, 20), | 
| - std::tr1::make_tuple(48000, 44100, 16000, 20), | 
| - std::tr1::make_tuple(48000, 32000, 48000, 30), | 
| - std::tr1::make_tuple(48000, 32000, 32000, 30), | 
| - std::tr1::make_tuple(48000, 32000, 16000, 30), | 
| - std::tr1::make_tuple(48000, 16000, 48000, 25), | 
| - std::tr1::make_tuple(48000, 16000, 32000, 25), | 
| - std::tr1::make_tuple(48000, 16000, 16000, 25), | 
| - | 
| - std::tr1::make_tuple(44100, 48000, 48000, 30), | 
| - std::tr1::make_tuple(44100, 48000, 32000, 30), | 
| - std::tr1::make_tuple(44100, 48000, 16000, 30), | 
| - std::tr1::make_tuple(44100, 44100, 48000, 20), | 
| - std::tr1::make_tuple(44100, 44100, 32000, 20), | 
| - std::tr1::make_tuple(44100, 44100, 16000, 20), | 
| - std::tr1::make_tuple(44100, 32000, 48000, 30), | 
| - std::tr1::make_tuple(44100, 32000, 32000, 30), | 
| - std::tr1::make_tuple(44100, 32000, 16000, 30), | 
| - std::tr1::make_tuple(44100, 16000, 48000, 25), | 
| - std::tr1::make_tuple(44100, 16000, 32000, 25), | 
| - std::tr1::make_tuple(44100, 16000, 16000, 25), | 
| - | 
| - std::tr1::make_tuple(32000, 48000, 48000, 30), | 
| - std::tr1::make_tuple(32000, 48000, 32000, 35), | 
| - std::tr1::make_tuple(32000, 48000, 16000, 30), | 
| - std::tr1::make_tuple(32000, 44100, 48000, 20), | 
| - std::tr1::make_tuple(32000, 44100, 32000, 20), | 
| - std::tr1::make_tuple(32000, 44100, 16000, 20), | 
| - std::tr1::make_tuple(32000, 32000, 48000, 40), | 
| - std::tr1::make_tuple(32000, 32000, 32000, 0), | 
| - std::tr1::make_tuple(32000, 32000, 16000, 40), | 
| - std::tr1::make_tuple(32000, 16000, 48000, 25), | 
| - std::tr1::make_tuple(32000, 16000, 32000, 25), | 
| - std::tr1::make_tuple(32000, 16000, 16000, 25), | 
| - | 
| - std::tr1::make_tuple(16000, 48000, 48000, 25), | 
| - std::tr1::make_tuple(16000, 48000, 32000, 25), | 
| - std::tr1::make_tuple(16000, 48000, 16000, 25), | 
| - std::tr1::make_tuple(16000, 44100, 48000, 15), | 
| - std::tr1::make_tuple(16000, 44100, 32000, 15), | 
| - std::tr1::make_tuple(16000, 44100, 16000, 15), | 
| - std::tr1::make_tuple(16000, 32000, 48000, 25), | 
| - std::tr1::make_tuple(16000, 32000, 32000, 25), | 
| - std::tr1::make_tuple(16000, 32000, 16000, 25), | 
| - std::tr1::make_tuple(16000, 16000, 48000, 40), | 
| - std::tr1::make_tuple(16000, 16000, 32000, 50), | 
| - std::tr1::make_tuple(16000, 16000, 16000, 0))); | 
| + CommonFormats, | 
| + AudioProcessingTest, | 
| + testing::Values(std::tr1::make_tuple(48000, 48000, 48000, 48000, 0, 0), | 
| + std::tr1::make_tuple(48000, 48000, 32000, 48000, 40, 30), | 
| + std::tr1::make_tuple(48000, 48000, 16000, 48000, 40, 20), | 
| + std::tr1::make_tuple(48000, 44100, 48000, 44100, 20, 20), | 
| + std::tr1::make_tuple(48000, 44100, 32000, 44100, 20, 15), | 
| + std::tr1::make_tuple(48000, 44100, 16000, 44100, 20, 15), | 
| + std::tr1::make_tuple(48000, 32000, 48000, 32000, 30, 35), | 
| + std::tr1::make_tuple(48000, 32000, 32000, 32000, 30, 0), | 
| + std::tr1::make_tuple(48000, 32000, 16000, 32000, 30, 20), | 
| + std::tr1::make_tuple(48000, 16000, 48000, 16000, 25, 20), | 
| + std::tr1::make_tuple(48000, 16000, 32000, 16000, 25, 20), | 
| + std::tr1::make_tuple(48000, 16000, 16000, 16000, 25, 0), | 
| + | 
| + std::tr1::make_tuple(44100, 48000, 48000, 48000, 30, 0), | 
| + std::tr1::make_tuple(44100, 48000, 32000, 48000, 30, 30), | 
| + std::tr1::make_tuple(44100, 48000, 16000, 48000, 30, 20), | 
| + std::tr1::make_tuple(44100, 44100, 48000, 44100, 20, 20), | 
| + std::tr1::make_tuple(44100, 44100, 32000, 44100, 20, 15), | 
| + std::tr1::make_tuple(44100, 44100, 16000, 44100, 20, 15), | 
| + std::tr1::make_tuple(44100, 32000, 48000, 32000, 30, 35), | 
| + std::tr1::make_tuple(44100, 32000, 32000, 32000, 30, 0), | 
| + std::tr1::make_tuple(44100, 32000, 16000, 32000, 30, 20), | 
| + std::tr1::make_tuple(44100, 16000, 48000, 16000, 25, 20), | 
| + std::tr1::make_tuple(44100, 16000, 32000, 16000, 25, 20), | 
| + std::tr1::make_tuple(44100, 16000, 16000, 16000, 25, 0), | 
| + | 
| + std::tr1::make_tuple(32000, 48000, 48000, 48000, 30, 0), | 
| + std::tr1::make_tuple(32000, 48000, 32000, 48000, 35, 30), | 
| + std::tr1::make_tuple(32000, 48000, 16000, 48000, 30, 20), | 
| + std::tr1::make_tuple(32000, 44100, 48000, 44100, 20, 20), | 
| + std::tr1::make_tuple(32000, 44100, 32000, 44100, 20, 15), | 
| + std::tr1::make_tuple(32000, 44100, 16000, 44100, 20, 15), | 
| + std::tr1::make_tuple(32000, 32000, 48000, 32000, 40, 35), | 
| + std::tr1::make_tuple(32000, 32000, 32000, 32000, 0, 0), | 
| + std::tr1::make_tuple(32000, 32000, 16000, 32000, 40, 20), | 
| + std::tr1::make_tuple(32000, 16000, 48000, 16000, 25, 20), | 
| + std::tr1::make_tuple(32000, 16000, 32000, 16000, 25, 20), | 
| + std::tr1::make_tuple(32000, 16000, 16000, 16000, 25, 0), | 
| + | 
| + std::tr1::make_tuple(16000, 48000, 48000, 48000, 25, 0), | 
| + std::tr1::make_tuple(16000, 48000, 32000, 48000, 25, 30), | 
| + std::tr1::make_tuple(16000, 48000, 16000, 48000, 25, 20), | 
| + std::tr1::make_tuple(16000, 44100, 48000, 44100, 15, 20), | 
| + std::tr1::make_tuple(16000, 44100, 32000, 44100, 15, 15), | 
| + std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), | 
| + std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), | 
| + std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), | 
| + std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), | 
| + std::tr1::make_tuple(16000, 16000, 48000, 16000, 40, 20), | 
| + std::tr1::make_tuple(16000, 16000, 32000, 16000, 50, 20), | 
| + std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); | 
| #elif defined(WEBRTC_AUDIOPROC_FIXED_PROFILE) | 
| INSTANTIATE_TEST_CASE_P( | 
| - CommonFormats, AudioProcessingTest, testing::Values( | 
| - std::tr1::make_tuple(48000, 48000, 48000, 20), | 
| - std::tr1::make_tuple(48000, 48000, 32000, 20), | 
| - std::tr1::make_tuple(48000, 48000, 16000, 20), | 
| - std::tr1::make_tuple(48000, 44100, 48000, 15), | 
| - std::tr1::make_tuple(48000, 44100, 32000, 15), | 
| - std::tr1::make_tuple(48000, 44100, 16000, 15), | 
| - std::tr1::make_tuple(48000, 32000, 48000, 20), | 
| - std::tr1::make_tuple(48000, 32000, 32000, 20), | 
| - std::tr1::make_tuple(48000, 32000, 16000, 20), | 
| - std::tr1::make_tuple(48000, 16000, 48000, 20), | 
| - std::tr1::make_tuple(48000, 16000, 32000, 20), | 
| - std::tr1::make_tuple(48000, 16000, 16000, 20), | 
| - | 
| - std::tr1::make_tuple(44100, 48000, 48000, 20), | 
| - std::tr1::make_tuple(44100, 48000, 32000, 20), | 
| - std::tr1::make_tuple(44100, 48000, 16000, 20), | 
| - std::tr1::make_tuple(44100, 44100, 48000, 15), | 
| - std::tr1::make_tuple(44100, 44100, 32000, 15), | 
| - std::tr1::make_tuple(44100, 44100, 16000, 15), | 
| - std::tr1::make_tuple(44100, 32000, 48000, 20), | 
| - std::tr1::make_tuple(44100, 32000, 32000, 20), | 
| - std::tr1::make_tuple(44100, 32000, 16000, 20), | 
| - std::tr1::make_tuple(44100, 16000, 48000, 20), | 
| - std::tr1::make_tuple(44100, 16000, 32000, 20), | 
| - std::tr1::make_tuple(44100, 16000, 16000, 20), | 
| - | 
| - std::tr1::make_tuple(32000, 48000, 48000, 20), | 
| - std::tr1::make_tuple(32000, 48000, 32000, 20), | 
| - std::tr1::make_tuple(32000, 48000, 16000, 20), | 
| - std::tr1::make_tuple(32000, 44100, 48000, 15), | 
| - std::tr1::make_tuple(32000, 44100, 32000, 15), | 
| - std::tr1::make_tuple(32000, 44100, 16000, 15), | 
| - std::tr1::make_tuple(32000, 32000, 48000, 20), | 
| - std::tr1::make_tuple(32000, 32000, 32000, 20), | 
| - std::tr1::make_tuple(32000, 32000, 16000, 20), | 
| - std::tr1::make_tuple(32000, 16000, 48000, 20), | 
| - std::tr1::make_tuple(32000, 16000, 32000, 20), | 
| - std::tr1::make_tuple(32000, 16000, 16000, 20), | 
| - | 
| - std::tr1::make_tuple(16000, 48000, 48000, 25), | 
| - std::tr1::make_tuple(16000, 48000, 32000, 25), | 
| - std::tr1::make_tuple(16000, 48000, 16000, 25), | 
| - std::tr1::make_tuple(16000, 44100, 48000, 15), | 
| - std::tr1::make_tuple(16000, 44100, 32000, 15), | 
| - std::tr1::make_tuple(16000, 44100, 16000, 15), | 
| - std::tr1::make_tuple(16000, 32000, 48000, 25), | 
| - std::tr1::make_tuple(16000, 32000, 32000, 25), | 
| - std::tr1::make_tuple(16000, 32000, 16000, 25), | 
| - std::tr1::make_tuple(16000, 16000, 48000, 35), | 
| - std::tr1::make_tuple(16000, 16000, 32000, 40), | 
| - std::tr1::make_tuple(16000, 16000, 16000, 0))); | 
| + CommonFormats, | 
| + AudioProcessingTest, | 
| + testing::Values(std::tr1::make_tuple(48000, 48000, 48000, 48000, 20, 0), | 
| + std::tr1::make_tuple(48000, 48000, 32000, 48000, 20, 30), | 
| + std::tr1::make_tuple(48000, 48000, 16000, 48000, 20, 20), | 
| + std::tr1::make_tuple(48000, 44100, 48000, 44100, 15, 20), | 
| + std::tr1::make_tuple(48000, 44100, 32000, 44100, 15, 15), | 
| + std::tr1::make_tuple(48000, 44100, 16000, 44100, 15, 15), | 
| + std::tr1::make_tuple(48000, 32000, 48000, 32000, 20, 35), | 
| + std::tr1::make_tuple(48000, 32000, 32000, 32000, 20, 0), | 
| + std::tr1::make_tuple(48000, 32000, 16000, 32000, 20, 20), | 
| + std::tr1::make_tuple(48000, 16000, 48000, 16000, 20, 20), | 
| + std::tr1::make_tuple(48000, 16000, 32000, 16000, 20, 20), | 
| + std::tr1::make_tuple(48000, 16000, 16000, 16000, 20, 0), | 
| + | 
| + std::tr1::make_tuple(44100, 48000, 48000, 48000, 20, 0), | 
| + std::tr1::make_tuple(44100, 48000, 32000, 48000, 20, 30), | 
| + std::tr1::make_tuple(44100, 48000, 16000, 48000, 20, 20), | 
| + std::tr1::make_tuple(44100, 44100, 48000, 44100, 15, 20), | 
| + std::tr1::make_tuple(44100, 44100, 32000, 44100, 15, 15), | 
| + std::tr1::make_tuple(44100, 44100, 16000, 44100, 15, 15), | 
| + std::tr1::make_tuple(44100, 32000, 48000, 32000, 20, 35), | 
| + std::tr1::make_tuple(44100, 32000, 32000, 32000, 20, 0), | 
| + std::tr1::make_tuple(44100, 32000, 16000, 32000, 20, 20), | 
| + std::tr1::make_tuple(44100, 16000, 48000, 16000, 20, 20), | 
| + std::tr1::make_tuple(44100, 16000, 32000, 16000, 20, 20), | 
| + std::tr1::make_tuple(44100, 16000, 16000, 16000, 20, 0), | 
| + | 
| + std::tr1::make_tuple(32000, 48000, 48000, 48000, 20, 0), | 
| + std::tr1::make_tuple(32000, 48000, 32000, 48000, 20, 30), | 
| + std::tr1::make_tuple(32000, 48000, 16000, 48000, 20, 20), | 
| + std::tr1::make_tuple(32000, 44100, 48000, 44100, 15, 20), | 
| + std::tr1::make_tuple(32000, 44100, 32000, 44100, 15, 15), | 
| + std::tr1::make_tuple(32000, 44100, 16000, 44100, 15, 15), | 
| + std::tr1::make_tuple(32000, 32000, 48000, 32000, 20, 35), | 
| + std::tr1::make_tuple(32000, 32000, 32000, 32000, 20, 0), | 
| + std::tr1::make_tuple(32000, 32000, 16000, 32000, 20, 20), | 
| + std::tr1::make_tuple(32000, 16000, 48000, 16000, 20, 20), | 
| + std::tr1::make_tuple(32000, 16000, 32000, 16000, 20, 20), | 
| + std::tr1::make_tuple(32000, 16000, 16000, 16000, 20, 0), | 
| + | 
| + std::tr1::make_tuple(16000, 48000, 48000, 48000, 25, 0), | 
| + std::tr1::make_tuple(16000, 48000, 32000, 48000, 25, 30), | 
| + std::tr1::make_tuple(16000, 48000, 16000, 48000, 25, 20), | 
| + std::tr1::make_tuple(16000, 44100, 48000, 44100, 15, 20), | 
| + std::tr1::make_tuple(16000, 44100, 32000, 44100, 15, 15), | 
| + std::tr1::make_tuple(16000, 44100, 16000, 44100, 15, 15), | 
| + std::tr1::make_tuple(16000, 32000, 48000, 32000, 25, 35), | 
| + std::tr1::make_tuple(16000, 32000, 32000, 32000, 25, 0), | 
| + std::tr1::make_tuple(16000, 32000, 16000, 32000, 25, 20), | 
| + std::tr1::make_tuple(16000, 16000, 48000, 16000, 35, 20), | 
| + std::tr1::make_tuple(16000, 16000, 32000, 16000, 40, 20), | 
| + std::tr1::make_tuple(16000, 16000, 16000, 16000, 0, 0))); | 
| 
 
aluebs-webrtc
2015/08/10 19:14:18
Here I have the same question about making them ex
 
Andrew MacDonald
2015/08/10 19:30:51
Right, it's not supposed to be exhaustive. It look
 
ekm
2015/08/11 23:59:36
Acknowledged.
 
 | 
| #endif | 
| // TODO(henrike): re-implement functionality lost when removing the old main |