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

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: Changed DCHECK to CHECK 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..b117dbbebe79dd1657d0d1bf45f08ccacfc7cdf2 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,34 @@ void AecDumpBasedSimulator::PrepareProcessStreamCall(
}
}
+ if (artificial_nearend_buffer_reader_) {
+ if (artificial_nearend_buffer_reader_->Read(
+ artificial_nearend_buf_.get())) {
+ if (msg.has_input_data()) {
+ for (size_t k = 0; k < in_buf_->num_frames(); ++k) {
+ fwd_frame_.data_[k] = rtc::saturated_cast<int16_t>(
+ fwd_frame_.data_[k] +
+ static_cast<int16_t>(32767 *
+ artificial_nearend_buf_->channels()[0][k]));
+ }
+ } 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]));
+ }
+ }
+ }
+ } else {
+ if (!artificial_nearend_eof_reported_) {
+ std::cout << "The artificial nearend file ended before the recording.";
+ artificial_nearend_eof_reported_ = true;
+ }
+ }
+ }
+
if (!settings_.stream_delay) {
if (msg.has_delay()) {
RTC_CHECK_EQ(AudioProcessing::kNoError,
@@ -189,6 +222,22 @@ 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()));
+
+ RTC_CHECK_EQ(1, artificial_nearend_file->num_channels())
+ << "Only mono files for the artificial nearend are supported, "
+ "reverted to not using the artificial nearend file";
+
+ 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 =

Powered by Google App Engine
This is Rietveld 408576698