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..02f4207c9a3bb6ab12729d67bd3a324b0d171784 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,26 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall( |
| } |
| } |
| + if (artificial_nearend_buffer_reader_) { |
| + bool samples_left_to_process = |
|
aleloi
2016/12/08 13:00:55
const
peah-webrtc
2016/12/09 07:19:25
I changed the code to avoid the need for this vari
|
| + artificial_nearend_buffer_reader_->Read(artificial_nearend_buf_.get()); |
| + if (samples_left_to_process) { |
| + if (msg.has_input_data()) { |
| + for (size_t k = 0; k < in_buf_->num_frames(); ++k) { |
| + fwd_frame_.data_[k] += static_cast<int16_t>( |
|
aleloi
2016/12/08 13:00:55
What happens if the frame is stereo? Then frame au
peah-webrtc
2016/12/09 07:19:25
There is another hidden assumption here as well, a
peah-webrtc
2016/12/09 07:19:25
That is a great point! I overcame that problem by
|
| + 32767 * artificial_nearend_buf_->channels()[0][k]); |
|
aleloi
2016/12/08 13:00:55
Can we use a checked_cast + saturated_cast here?
peah-webrtc
2016/12/09 07:19:25
True. Good point!
I added explicit controlled satu
|
| + } |
| + } 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]; |
| + } |
| + } |
| + } |
| + } |
| + } |
| + |
| if (!settings_.stream_delay) { |
| if (msg.has_delay()) { |
| RTC_CHECK_EQ(AudioProcessing::kNoError, |
| @@ -189,6 +214,19 @@ 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) { |
| + 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))); |
| + } |
| + } |
| + |
| webrtc::audioproc::Event event_msg; |
| int num_forward_chunks_processed = 0; |
| const float kOneBykChunksPerSecond = |