Chromium Code Reviews| Index: webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc |
| diff --git a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc |
| index 694f2cd90c8f5cc702573a7ad1046b2e9983c151..4c6375fafb59cd7f666fa94e3bd7c785c1602363 100644 |
| --- a/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc |
| +++ b/webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc |
| @@ -62,6 +62,11 @@ bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg, |
| } // namespace |
| +AecDumpBasedSimulator::AecDumpBasedSimulator(const SimulationSettings& settings) |
| + : AudioProcessingSimulator(settings) {} |
| + |
| +AecDumpBasedSimulator::~AecDumpBasedSimulator() = default; |
| + |
| void AecDumpBasedSimulator::PrepareProcessStreamCall( |
| const webrtc::audioproc::Stream& msg, |
| bool* set_stream_analog_level_called) { |
| @@ -96,6 +101,30 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall( |
| } |
| } |
| + if (artificial_nearend_buffer_reader_) { |
| + if (artificial_nearend_buffer_reader_->Read( |
|
hlundin-webrtc
2016/12/09 07:48:26
If the file ends before the rest of the simulation
peah-webrtc
2016/12/09 08:07:51
The intention was actually to do this silently but
hlundin-webrtc
2016/12/09 09:24:26
Good.
|
| + artificial_nearend_buf_.get())) { |
| + if (msg.has_input_data()) { |
| + for (size_t k = 0; k < in_buf_->num_frames(); ++k) { |
| + int32_t tmp = fwd_frame_.data_[k] + |
| + static_cast<int16_t>( |
| + 32767 * artificial_nearend_buf_->channels()[0][k]); |
| + fwd_frame_.data_[k] = |
| + static_cast<int16_t>(std::min(32767, std::max(-32768, tmp))); |
|
hlundin-webrtc
2016/12/09 07:48:26
rtc::saturated_cast<int16_t>(tmp) will do the same
peah-webrtc
2016/12/09 08:07:51
Great! That I did not know. Changed the code to us
|
| + } |
| + } else { |
| + for (int i = 0; i < msg.input_channel_size(); ++i) { |
| + for (size_t k = 0; k < in_buf_->num_frames(); ++k) { |
| + in_buf_->channels()[i][k] += |
| + artificial_nearend_buf_->channels()[0][k]; |
| + in_buf_->channels()[i][k] = std::min( |
| + 32767.f, std::max(-32768.f, in_buf_->channels()[i][k])); |
| + } |
| + } |
| + } |
| + } |
| + } |
| + |
| if (!settings_.stream_delay) { |
| if (msg.has_delay()) { |
| RTC_CHECK_EQ(AudioProcessing::kNoError, |
| @@ -189,6 +218,24 @@ void AecDumpBasedSimulator::Process() { |
| CreateAudioProcessor(); |
| dump_input_file_ = OpenFile(settings_.aec_dump_input_filename->c_str(), "rb"); |
| + if (settings_.artificial_nearend_filename) { |
| + std::unique_ptr<WavReader> artificial_nearend_file( |
| + new WavReader(settings_.artificial_nearend_filename->c_str())); |
| + |
| + if (artificial_nearend_file->num_channels() != 1) { |
|
hlundin-webrtc
2016/12/09 07:48:26
Any point continuing here? Or simply
RTC_DCHECK_EQ
peah-webrtc
2016/12/09 08:07:51
Good point! I added the DCHECK.
Done.
|
| + std::cout << "Only mono files for the artificial nearend are supported, " |
| + "reverted to not using the artificial nearend file"; |
| + } else { |
| + artificial_nearend_buffer_reader_.reset( |
| + new ChannelBufferWavReader(std::move(artificial_nearend_file))); |
| + |
| + artificial_nearend_buf_.reset(new ChannelBuffer<float>( |
| + rtc::CheckedDivExact(artificial_nearend_file->sample_rate(), |
| + kChunksPerSecond), |
| + 1)); |
| + } |
| + } |
| + |
| webrtc::audioproc::Event event_msg; |
| int num_forward_chunks_processed = 0; |
| const float kOneBykChunksPerSecond = |