Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Unified Diff: webrtc/modules/audio_processing/test/aec_dump_based_simulator.cc

Issue 2562593003: Add an optional artificial nearend signal for aecdump call recreation (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f110af7de82d7b497671d491ca165d2dcb44c6d1 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 =
+ 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_[0] += static_cast<int16_t>(
+ 32767 * artificial_nearend_buf_->channels()[0][k]);
ivoc 2016/12/08 10:55:19 Shouldn't this be fwd_frame_.data[k]? Also, why is
peah-webrtc 2016/12/08 12:02:26 Great find (I probably have not used this yet with
ivoc 2016/12/08 12:13:24 I see, that makes sense. I think this code can cau
peah-webrtc 2016/12/09 07:19:25 You are fully correct! I added explicit controlled
+ }
+ } 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 =

Powered by Google App Engine
This is Rietveld 408576698