Add support to audioproc_f to generate a custom call order file.
This adds a flag to audioproc_f to generate a custom call order file from an AEC dump. This file can be used to get more realism when simulating with wav-files. Bug: webrtc:10393 Change-Id: I245533d18affaab2f6cef53138332d7d83c71822 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126782 Commit-Queue: Ivo Creusen <ivoc@webrtc.org> Reviewed-by: Per Åhgren <peah@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27104}
This commit is contained in:
@ -10,6 +10,7 @@
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "modules/audio_processing/echo_cancellation_impl.h"
|
||||
#include "modules/audio_processing/echo_control_mobile_impl.h"
|
||||
#include "modules/audio_processing/test/aec_dump_based_simulator.h"
|
||||
@ -69,7 +70,9 @@ bool VerifyFloatBitExactness(const webrtc::audioproc::Stream& msg,
|
||||
AecDumpBasedSimulator::AecDumpBasedSimulator(
|
||||
const SimulationSettings& settings,
|
||||
std::unique_ptr<AudioProcessingBuilder> ap_builder)
|
||||
: AudioProcessingSimulator(settings, std::move(ap_builder)) {}
|
||||
: AudioProcessingSimulator(settings, std::move(ap_builder)) {
|
||||
MaybeOpenCallOrderFile();
|
||||
}
|
||||
|
||||
AecDumpBasedSimulator::~AecDumpBasedSimulator() = default;
|
||||
|
||||
@ -474,6 +477,7 @@ void AecDumpBasedSimulator::HandleMessage(const webrtc::audioproc::Init& msg) {
|
||||
RTC_CHECK(msg.has_num_input_channels());
|
||||
RTC_CHECK(msg.has_num_reverse_channels());
|
||||
RTC_CHECK(msg.has_reverse_sample_rate());
|
||||
MaybeOpenCallOrderFile();
|
||||
|
||||
if (settings_.use_verbose_logging) {
|
||||
std::cout << "Init at frame:" << std::endl;
|
||||
@ -525,6 +529,9 @@ void AecDumpBasedSimulator::HandleMessage(const webrtc::audioproc::Init& msg) {
|
||||
|
||||
void AecDumpBasedSimulator::HandleMessage(
|
||||
const webrtc::audioproc::Stream& msg) {
|
||||
if (call_order_output_file_) {
|
||||
*call_order_output_file_ << "c";
|
||||
}
|
||||
PrepareProcessStreamCall(msg);
|
||||
ProcessStream(interface_used_ == InterfaceType::kFixedInterface);
|
||||
VerifyProcessStreamBitExactness(msg);
|
||||
@ -532,6 +539,9 @@ void AecDumpBasedSimulator::HandleMessage(
|
||||
|
||||
void AecDumpBasedSimulator::HandleMessage(
|
||||
const webrtc::audioproc::ReverseStream& msg) {
|
||||
if (call_order_output_file_) {
|
||||
*call_order_output_file_ << "r";
|
||||
}
|
||||
PrepareReverseProcessStreamCall(msg);
|
||||
ProcessReverseStream(interface_used_ == InterfaceType::kFixedInterface);
|
||||
}
|
||||
@ -542,5 +552,16 @@ void AecDumpBasedSimulator::HandleMessage(
|
||||
ReplayRuntimeSetting(ap_.get(), msg);
|
||||
}
|
||||
|
||||
void AecDumpBasedSimulator::MaybeOpenCallOrderFile() {
|
||||
if (settings_.call_order_output_filename.has_value()) {
|
||||
const std::string filename = settings_.store_intermediate_output
|
||||
? *settings_.call_order_output_filename +
|
||||
"_" +
|
||||
std::to_string(output_reset_counter_)
|
||||
: *settings_.call_order_output_filename;
|
||||
call_order_output_file_ = absl::make_unique<std::ofstream>(filename);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
|
@ -11,6 +11,9 @@
|
||||
#ifndef MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_
|
||||
#define MODULES_AUDIO_PROCESSING_TEST_AEC_DUMP_BASED_SIMULATOR_H_
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
#include "modules/audio_processing/test/audio_processing_simulator.h"
|
||||
|
||||
#include "rtc_base/constructor_magic.h"
|
||||
@ -47,7 +50,7 @@ class AecDumpBasedSimulator final : public AudioProcessingSimulator {
|
||||
void PrepareReverseProcessStreamCall(
|
||||
const webrtc::audioproc::ReverseStream& msg);
|
||||
void VerifyProcessStreamBitExactness(const webrtc::audioproc::Stream& msg);
|
||||
|
||||
void MaybeOpenCallOrderFile();
|
||||
enum InterfaceType {
|
||||
kFixedInterface,
|
||||
kFloatInterface,
|
||||
@ -59,7 +62,7 @@ class AecDumpBasedSimulator final : public AudioProcessingSimulator {
|
||||
std::unique_ptr<ChannelBufferWavReader> artificial_nearend_buffer_reader_;
|
||||
bool artificial_nearend_eof_reported_ = false;
|
||||
InterfaceType interface_used_ = InterfaceType::kNotSpecified;
|
||||
|
||||
std::unique_ptr<std::ofstream> call_order_output_file_;
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(AecDumpBasedSimulator);
|
||||
};
|
||||
|
||||
|
@ -96,7 +96,8 @@ struct SimulationSettings {
|
||||
bool print_aec_parameter_values = false;
|
||||
bool dump_internal_data = false;
|
||||
absl::optional<std::string> dump_internal_data_output_dir;
|
||||
absl::optional<std::string> custom_call_order_filename;
|
||||
absl::optional<std::string> call_order_input_filename;
|
||||
absl::optional<std::string> call_order_output_filename;
|
||||
absl::optional<std::string> aec_settings_filename;
|
||||
};
|
||||
|
||||
@ -183,12 +184,14 @@ class AudioProcessingSimulator {
|
||||
bool bitexact_output_ = true;
|
||||
int aec_dump_mic_level_ = 0;
|
||||
|
||||
protected:
|
||||
size_t output_reset_counter_ = 0;
|
||||
|
||||
private:
|
||||
void SetupOutput();
|
||||
|
||||
size_t num_process_stream_calls_ = 0;
|
||||
size_t num_reverse_process_stream_calls_ = 0;
|
||||
size_t output_reset_counter_ = 0;
|
||||
std::unique_ptr<ChannelBufferWavWriter> buffer_writer_;
|
||||
std::unique_ptr<ChannelBufferWavWriter> reverse_buffer_writer_;
|
||||
TickIntervalStats proc_time_;
|
||||
|
@ -206,6 +206,10 @@ WEBRTC_DEFINE_bool(store_intermediate_output,
|
||||
WEBRTC_DEFINE_string(custom_call_order_file,
|
||||
"",
|
||||
"Custom process API call order file");
|
||||
WEBRTC_DEFINE_string(
|
||||
output_custom_call_order_file,
|
||||
"",
|
||||
"Generate custom process API call order file from AEC dump");
|
||||
WEBRTC_DEFINE_bool(print_aec_parameter_values,
|
||||
false,
|
||||
"Print parameter values used in AEC in JSON-format");
|
||||
@ -339,7 +343,9 @@ SimulationSettings CreateSettings() {
|
||||
SetSettingIfSpecified(FLAG_stream_drift_samples,
|
||||
&settings.stream_drift_samples);
|
||||
SetSettingIfSpecified(FLAG_custom_call_order_file,
|
||||
&settings.custom_call_order_filename);
|
||||
&settings.call_order_input_filename);
|
||||
SetSettingIfSpecified(FLAG_output_custom_call_order_file,
|
||||
&settings.call_order_output_filename);
|
||||
SetSettingIfSpecified(FLAG_aec_settings, &settings.aec_settings_filename);
|
||||
settings.initial_mic_level = FLAG_initial_mic_level;
|
||||
settings.simulate_mic_gain = FLAG_simulate_mic_gain;
|
||||
@ -454,7 +460,7 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
|
||||
"aecdump\n");
|
||||
|
||||
ReportConditionalErrorAndExit(
|
||||
settings.custom_call_order_filename && settings.aec_dump_input_filename,
|
||||
settings.call_order_input_filename && settings.aec_dump_input_filename,
|
||||
"Error: --custom_call_order_file cannot be used when operating on an "
|
||||
"aecdump\n");
|
||||
|
||||
@ -514,6 +520,11 @@ void PerformBasicParameterSanityChecks(const SimulationSettings& settings) {
|
||||
!settings.dump_internal_data &&
|
||||
settings.dump_internal_data_output_dir.has_value(),
|
||||
"Error: --dump_data_output_dir cannot be set without --dump_data.\n");
|
||||
|
||||
ReportConditionalErrorAndExit(
|
||||
!settings.aec_dump_input_filename &&
|
||||
settings.call_order_output_filename.has_value(),
|
||||
"Error: --output_custom_call_order_file needs an AEC dump input file.\n");
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -88,9 +88,9 @@ void WavBasedSimulator::PrepareReverseProcessStreamCall() {
|
||||
}
|
||||
|
||||
void WavBasedSimulator::Process() {
|
||||
if (settings_.custom_call_order_filename) {
|
||||
if (settings_.call_order_input_filename) {
|
||||
call_chain_ = WavBasedSimulator::GetCustomEventChain(
|
||||
*settings_.custom_call_order_filename);
|
||||
*settings_.call_order_input_filename);
|
||||
} else {
|
||||
call_chain_ = WavBasedSimulator::GetDefaultEventChain();
|
||||
}
|
||||
|
Reference in New Issue
Block a user