Remove more traces of keyboard mic support from APM
The 6-parameter Initialize method is removed. The has_keyboard parameter in the StreamConfig constructor is removed together with the underlying member and helper functions. Bug: chromium:1271981, b/217349489 Change-Id: I7259a114a395f74f735a9c06510c0fc0f0f008e3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/250221 Reviewed-by: Sam Zackrisson <saza@google.com> Reviewed-by: Sam Zackrisson <saza@webrtc.org> Auto-Submit: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35908}
This commit is contained in:
parent
bb57e2d7aa
commit
64253a93dc
@ -55,8 +55,7 @@ TEST(AecDumpIntegration,
|
||||
constexpr int kNumSamplesPerChannel = kNumSampleRateHz / 100;
|
||||
std::array<int16_t, kNumSamplesPerChannel * kNumChannels> frame;
|
||||
frame.fill(0.f);
|
||||
webrtc::StreamConfig stream_config(kNumSampleRateHz, kNumChannels,
|
||||
/*has_keyboard=*/false);
|
||||
webrtc::StreamConfig stream_config(kNumSampleRateHz, kNumChannels);
|
||||
|
||||
EXPECT_CALL(*mock_aec_dump.get(), WriteRenderStreamMessage(_, _, _))
|
||||
.Times(Exactly(1));
|
||||
@ -75,8 +74,7 @@ TEST(AecDumpIntegration, CaptureStreamShouldBeLoggedOnceEveryProcessStream) {
|
||||
std::array<int16_t, kNumSamplesPerChannel * kNumChannels> frame;
|
||||
frame.fill(0.f);
|
||||
|
||||
webrtc::StreamConfig stream_config(kNumSampleRateHz, kNumChannels,
|
||||
/*has_keyboard=*/false);
|
||||
webrtc::StreamConfig stream_config(kNumSampleRateHz, kNumChannels);
|
||||
|
||||
EXPECT_CALL(*mock_aec_dump.get(), AddCaptureStreamInput(_, _, _))
|
||||
.Times(AtLeast(1));
|
||||
|
||||
@ -19,7 +19,7 @@ TEST(AudioFrameTest, ConstructFromAudioBuffer) {
|
||||
constexpr int kNumChannels = 2;
|
||||
constexpr float kFloatConstant = 1272.f;
|
||||
constexpr float kIntConstant = 17252;
|
||||
const webrtc::StreamConfig stream_config(kSampleRateHz, kNumChannels, false);
|
||||
const webrtc::StreamConfig stream_config(kSampleRateHz, kNumChannels);
|
||||
webrtc::AudioBuffer buffer(
|
||||
stream_config.sample_rate_hz(), stream_config.num_channels(),
|
||||
stream_config.sample_rate_hz(), stream_config.num_channels(),
|
||||
|
||||
@ -50,20 +50,6 @@ namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
static bool LayoutHasKeyboard(AudioProcessing::ChannelLayout layout) {
|
||||
switch (layout) {
|
||||
case AudioProcessing::kMono:
|
||||
case AudioProcessing::kStereo:
|
||||
return false;
|
||||
case AudioProcessing::kMonoAndKeyboard:
|
||||
case AudioProcessing::kStereoAndKeyboard:
|
||||
return true;
|
||||
}
|
||||
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SampleRateSupportsMultiBand(int sample_rate_hz) {
|
||||
return sample_rate_hz == AudioProcessing::kSampleRate32kHz ||
|
||||
sample_rate_hz == AudioProcessing::kSampleRate48kHz;
|
||||
@ -311,26 +297,6 @@ int AudioProcessingImpl::Initialize() {
|
||||
return kNoError;
|
||||
}
|
||||
|
||||
int AudioProcessingImpl::Initialize(int capture_input_sample_rate_hz,
|
||||
int capture_output_sample_rate_hz,
|
||||
int render_input_sample_rate_hz,
|
||||
ChannelLayout capture_input_layout,
|
||||
ChannelLayout capture_output_layout,
|
||||
ChannelLayout render_input_layout) {
|
||||
const ProcessingConfig processing_config = {
|
||||
{{capture_input_sample_rate_hz, ChannelsFromLayout(capture_input_layout),
|
||||
LayoutHasKeyboard(capture_input_layout)},
|
||||
{capture_output_sample_rate_hz,
|
||||
ChannelsFromLayout(capture_output_layout),
|
||||
LayoutHasKeyboard(capture_output_layout)},
|
||||
{render_input_sample_rate_hz, ChannelsFromLayout(render_input_layout),
|
||||
LayoutHasKeyboard(render_input_layout)},
|
||||
{render_input_sample_rate_hz, ChannelsFromLayout(render_input_layout),
|
||||
LayoutHasKeyboard(render_input_layout)}}};
|
||||
|
||||
return Initialize(processing_config);
|
||||
}
|
||||
|
||||
int AudioProcessingImpl::Initialize(const ProcessingConfig& processing_config) {
|
||||
// Run in a single-threaded manner during initialization.
|
||||
MutexLock lock_render(&mutex_render_);
|
||||
@ -778,7 +744,6 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
|
||||
RecordUnprocessedCaptureStream(src);
|
||||
}
|
||||
|
||||
capture_.keyboard_info.Extract(src, formats_.api_format.input_stream());
|
||||
capture_.capture_audio->CopyFrom(src, formats_.api_format.input_stream());
|
||||
if (capture_.capture_fullband_audio) {
|
||||
capture_.capture_fullband_audio->CopyFrom(
|
||||
@ -1311,8 +1276,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
|
||||
capture_buffer->num_channels(),
|
||||
capture_buffer->split_bands_const(0)[kBand0To8kHz],
|
||||
capture_buffer->num_frames_per_band(),
|
||||
capture_.keyboard_info.keyboard_data,
|
||||
capture_.keyboard_info.num_keyboard_frames, voice_probability,
|
||||
/*reference_data=*/nullptr, /*reference_length=*/0, voice_probability,
|
||||
capture_.key_pressed);
|
||||
}
|
||||
|
||||
@ -2161,17 +2125,6 @@ AudioProcessingImpl::ApmCaptureState::ApmCaptureState()
|
||||
|
||||
AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default;
|
||||
|
||||
void AudioProcessingImpl::ApmCaptureState::KeyboardInfo::Extract(
|
||||
const float* const* data,
|
||||
const StreamConfig& stream_config) {
|
||||
if (stream_config.has_keyboard()) {
|
||||
keyboard_data = data[stream_config.num_channels()];
|
||||
} else {
|
||||
keyboard_data = NULL;
|
||||
}
|
||||
num_keyboard_frames = stream_config.num_frames();
|
||||
}
|
||||
|
||||
AudioProcessingImpl::ApmRenderState::ApmRenderState() = default;
|
||||
|
||||
AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default;
|
||||
|
||||
@ -63,12 +63,6 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||
std::unique_ptr<CustomAudioAnalyzer> capture_analyzer);
|
||||
~AudioProcessingImpl() override;
|
||||
int Initialize() override;
|
||||
int Initialize(int capture_input_sample_rate_hz,
|
||||
int capture_output_sample_rate_hz,
|
||||
int render_sample_rate_hz,
|
||||
ChannelLayout capture_input_layout,
|
||||
ChannelLayout capture_output_layout,
|
||||
ChannelLayout render_input_layout) override;
|
||||
int Initialize(const ProcessingConfig& processing_config) override;
|
||||
void ApplyConfig(const AudioProcessing::Config& config) override;
|
||||
bool CreateAndAttachAecDump(const std::string& file_name,
|
||||
@ -413,10 +407,10 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||
struct ApmFormatState {
|
||||
ApmFormatState()
|
||||
: // Format of processing streams at input/output call sites.
|
||||
api_format({{{kSampleRate16kHz, 1, false},
|
||||
{kSampleRate16kHz, 1, false},
|
||||
{kSampleRate16kHz, 1, false},
|
||||
{kSampleRate16kHz, 1, false}}}),
|
||||
api_format({{{kSampleRate16kHz, 1},
|
||||
{kSampleRate16kHz, 1},
|
||||
{kSampleRate16kHz, 1},
|
||||
{kSampleRate16kHz, 1}}}),
|
||||
render_processing_format(kSampleRate16kHz, 1) {}
|
||||
ProcessingConfig api_format;
|
||||
StreamConfig render_processing_format;
|
||||
@ -463,11 +457,6 @@ class AudioProcessingImpl : public AudioProcessing {
|
||||
int playout_volume;
|
||||
int prev_playout_volume;
|
||||
AudioProcessingStats stats;
|
||||
struct KeyboardInfo {
|
||||
void Extract(const float* const* data, const StreamConfig& stream_config);
|
||||
size_t num_keyboard_frames = 0;
|
||||
const float* keyboard_data = nullptr;
|
||||
} keyboard_info;
|
||||
int cached_stream_analog_level_ = 0;
|
||||
} capture_ RTC_GUARDED_BY(mutex_capture_);
|
||||
|
||||
|
||||
@ -607,8 +607,7 @@ void CaptureProcessor::PrepareFrame() {
|
||||
|
||||
// Prepare the audio data.
|
||||
StreamConfig input_stream_config(frame_data_.input_sample_rate_hz,
|
||||
frame_data_.input_number_of_channels,
|
||||
/*has_keyboard=*/false);
|
||||
frame_data_.input_number_of_channels);
|
||||
|
||||
PopulateAudioFrame(kCaptureInputFixLevel, input_stream_config.num_channels(),
|
||||
input_stream_config.num_frames(), frame_data_.frame,
|
||||
@ -632,11 +631,9 @@ void CaptureProcessor::CallApmCaptureSide() {
|
||||
|
||||
// Call the specified capture side API processing method.
|
||||
StreamConfig input_stream_config(frame_data_.input_sample_rate_hz,
|
||||
frame_data_.input_number_of_channels,
|
||||
/*has_keyboard=*/false);
|
||||
frame_data_.input_number_of_channels);
|
||||
StreamConfig output_stream_config(frame_data_.output_sample_rate_hz,
|
||||
frame_data_.output_number_of_channels,
|
||||
/*has_keyboard=*/false);
|
||||
frame_data_.output_number_of_channels);
|
||||
int result = AudioProcessing::kNoError;
|
||||
switch (test_config_->capture_api_function) {
|
||||
case CaptureApiImpl::ProcessStreamImplInteger:
|
||||
@ -847,8 +844,7 @@ void RenderProcessor::PrepareFrame() {
|
||||
|
||||
// Prepare the audio data.
|
||||
StreamConfig input_stream_config(frame_data_.input_sample_rate_hz,
|
||||
frame_data_.input_number_of_channels,
|
||||
/*has_keyboard=*/false);
|
||||
frame_data_.input_number_of_channels);
|
||||
|
||||
PopulateAudioFrame(kRenderInputFixLevel, input_stream_config.num_channels(),
|
||||
input_stream_config.num_frames(), frame_data_.frame,
|
||||
@ -866,11 +862,9 @@ void RenderProcessor::CallApmRenderSide() {
|
||||
|
||||
// Call the specified render side API processing method.
|
||||
StreamConfig input_stream_config(frame_data_.input_sample_rate_hz,
|
||||
frame_data_.input_number_of_channels,
|
||||
/*has_keyboard=*/false);
|
||||
frame_data_.input_number_of_channels);
|
||||
StreamConfig output_stream_config(frame_data_.output_sample_rate_hz,
|
||||
frame_data_.output_number_of_channels,
|
||||
/*has_keyboard=*/false);
|
||||
frame_data_.output_number_of_channels);
|
||||
int result = AudioProcessing::kNoError;
|
||||
switch (test_config_->render_api_function) {
|
||||
case RenderApiImpl::ProcessReverseStreamImplInteger:
|
||||
|
||||
@ -142,7 +142,7 @@ TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) {
|
||||
constexpr size_t kMaxNumChannels = 2;
|
||||
std::array<int16_t, kMaxNumChannels * kMaxSampleRateHz / 100> frame;
|
||||
frame.fill(0);
|
||||
StreamConfig config(16000, 1, /*has_keyboard=*/false);
|
||||
StreamConfig config(16000, 1);
|
||||
// Call with the default parameters; there should be an init.
|
||||
EXPECT_CALL(mock, InitializeLocked).Times(0);
|
||||
EXPECT_NOERR(mock.ProcessStream(frame.data(), config, config, frame.data()));
|
||||
@ -150,13 +150,13 @@ TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) {
|
||||
mock.ProcessReverseStream(frame.data(), config, config, frame.data()));
|
||||
|
||||
// New sample rate. (Only impacts ProcessStream).
|
||||
config = StreamConfig(32000, 1, /*has_keyboard=*/false);
|
||||
config = StreamConfig(32000, 1);
|
||||
EXPECT_CALL(mock, InitializeLocked).Times(1);
|
||||
EXPECT_NOERR(mock.ProcessStream(frame.data(), config, config, frame.data()));
|
||||
|
||||
// New number of channels.
|
||||
// TODO(peah): Investigate why this causes 2 inits.
|
||||
config = StreamConfig(32000, 2, /*has_keyboard=*/false);
|
||||
config = StreamConfig(32000, 2);
|
||||
EXPECT_CALL(mock, InitializeLocked).Times(2);
|
||||
EXPECT_NOERR(mock.ProcessStream(frame.data(), config, config, frame.data()));
|
||||
// ProcessStream sets num_channels_ == num_output_channels.
|
||||
@ -164,7 +164,7 @@ TEST(AudioProcessingImplTest, AudioParameterChangeTriggersInit) {
|
||||
mock.ProcessReverseStream(frame.data(), config, config, frame.data()));
|
||||
|
||||
// A new sample rate passed to ProcessReverseStream should cause an init.
|
||||
config = StreamConfig(16000, 2, /*has_keyboard=*/false);
|
||||
config = StreamConfig(16000, 2);
|
||||
EXPECT_CALL(mock, InitializeLocked).Times(1);
|
||||
EXPECT_NOERR(
|
||||
mock.ProcessReverseStream(frame.data(), config, config, frame.data()));
|
||||
@ -183,7 +183,7 @@ TEST(AudioProcessingImplTest, UpdateCapturePreGainRuntimeSetting) {
|
||||
constexpr size_t kNumChannels = 2;
|
||||
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig config(kSampleRateHz, kNumChannels, /*has_keyboard=*/false);
|
||||
StreamConfig config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
apm->ProcessStream(frame.data(), config, config, frame.data());
|
||||
EXPECT_EQ(frame[100], kAudioLevel)
|
||||
@ -216,7 +216,7 @@ TEST(AudioProcessingImplTest,
|
||||
constexpr size_t kNumChannels = 2;
|
||||
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig config(kSampleRateHz, kNumChannels, /*has_keyboard=*/false);
|
||||
StreamConfig config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
apm->ProcessStream(frame.data(), config, config, frame.data());
|
||||
EXPECT_EQ(frame[100], kAudioLevel)
|
||||
@ -249,7 +249,7 @@ TEST(AudioProcessingImplTest,
|
||||
constexpr size_t kNumChannels = 2;
|
||||
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig config(kSampleRateHz, kNumChannels, /*has_keyboard=*/false);
|
||||
StreamConfig config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
apm->ProcessStream(frame.data(), config, config, frame.data());
|
||||
EXPECT_EQ(frame[100], kAudioLevel)
|
||||
@ -284,7 +284,7 @@ TEST(AudioProcessingImplTest, EchoControllerObservesSetCaptureUsageChange) {
|
||||
constexpr int kSampleRateHz = 48000;
|
||||
constexpr int kNumChannels = 2;
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig config(kSampleRateHz, kNumChannels, /*has_keyboard=*/false);
|
||||
StreamConfig config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
|
||||
MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext();
|
||||
@ -373,7 +373,7 @@ TEST(AudioProcessingImplTest,
|
||||
constexpr size_t kSampleRateHz = 48000;
|
||||
constexpr size_t kNumChannels = 2;
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig config(kSampleRateHz, kNumChannels, /*has_keyboard=*/false);
|
||||
StreamConfig config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
|
||||
MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext();
|
||||
@ -416,7 +416,7 @@ TEST(AudioProcessingImplTest,
|
||||
constexpr size_t kSampleRateHz = 48000;
|
||||
constexpr size_t kNumChannels = 2;
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig config(kSampleRateHz, kNumChannels, /*has_keyboard=*/false);
|
||||
StreamConfig config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
|
||||
MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext();
|
||||
@ -460,8 +460,7 @@ TEST(AudioProcessingImplTest,
|
||||
constexpr size_t kSampleRateHz = 48000;
|
||||
constexpr size_t kNumChannels = 2;
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig stream_config(kSampleRateHz, kNumChannels,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig stream_config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
|
||||
MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext();
|
||||
@ -503,8 +502,7 @@ TEST(AudioProcessingImplTest, EchoControllerObservesPlayoutVolumeChange) {
|
||||
constexpr size_t kSampleRateHz = 48000;
|
||||
constexpr size_t kNumChannels = 2;
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig stream_config(kSampleRateHz, kNumChannels,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig stream_config(kSampleRateHz, kNumChannels);
|
||||
frame.fill(kAudioLevel);
|
||||
|
||||
MockEchoControl* echo_control_mock = echo_control_factory_ptr->GetNext();
|
||||
@ -561,16 +559,15 @@ TEST(AudioProcessingImplTest, RenderPreProcessorBeforeEchoDetector) {
|
||||
constexpr size_t kNumChannels = 1;
|
||||
// Explicitly initialize APM to ensure no render frames are discarded.
|
||||
const ProcessingConfig processing_config = {{
|
||||
{kSampleRateHz, kNumChannels, /*has_keyboard=*/false},
|
||||
{kSampleRateHz, kNumChannels, /*has_keyboard=*/false},
|
||||
{kSampleRateHz, kNumChannels, /*has_keyboard=*/false},
|
||||
{kSampleRateHz, kNumChannels, /*has_keyboard=*/false},
|
||||
{kSampleRateHz, kNumChannels},
|
||||
{kSampleRateHz, kNumChannels},
|
||||
{kSampleRateHz, kNumChannels},
|
||||
{kSampleRateHz, kNumChannels},
|
||||
}};
|
||||
apm->Initialize(processing_config);
|
||||
|
||||
std::array<int16_t, kNumChannels * kSampleRateHz / 100> frame;
|
||||
StreamConfig stream_config(kSampleRateHz, kNumChannels,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig stream_config(kSampleRateHz, kNumChannels);
|
||||
|
||||
constexpr float kAudioLevelFloat = static_cast<float>(kAudioLevel);
|
||||
constexpr float kExpectedPreprocessedAudioLevel =
|
||||
@ -626,8 +623,7 @@ TEST(ApmWithSubmodulesExcludedTest, BitexactWithDisabledModules) {
|
||||
float* channel_pointers[] = {buffer.data()};
|
||||
float* channel_pointers_reference[] = {buffer_reference.data()};
|
||||
StreamConfig stream_config(/*sample_rate_hz=*/kSampleRateHz,
|
||||
/*num_channels=*/kNumChannels,
|
||||
/*has_keyboard=*/false);
|
||||
/*num_channels=*/kNumChannels);
|
||||
Random random_generator(2341U);
|
||||
constexpr int kFramesToProcessPerConfiguration = 10;
|
||||
|
||||
@ -667,8 +663,7 @@ TEST(ApmWithSubmodulesExcludedTest, ReinitializeTransientSuppressor) {
|
||||
constexpr int kFramesToProcessPerConfiguration = 3;
|
||||
|
||||
StreamConfig initial_stream_config(/*sample_rate_hz=*/16000,
|
||||
/*num_channels=*/1,
|
||||
/*has_keyboard=*/false);
|
||||
/*num_channels=*/1);
|
||||
for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) {
|
||||
RandomizeSampleVector(&random_generator, buffer);
|
||||
EXPECT_EQ(apm->ProcessStream(channel_pointers, initial_stream_config,
|
||||
@ -677,8 +672,7 @@ TEST(ApmWithSubmodulesExcludedTest, ReinitializeTransientSuppressor) {
|
||||
}
|
||||
|
||||
StreamConfig stereo_stream_config(/*sample_rate_hz=*/16000,
|
||||
/*num_channels=*/2,
|
||||
/*has_keyboard=*/false);
|
||||
/*num_channels=*/2);
|
||||
for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) {
|
||||
RandomizeSampleVector(&random_generator, buffer);
|
||||
EXPECT_EQ(apm->ProcessStream(channel_pointers, stereo_stream_config,
|
||||
@ -687,8 +681,7 @@ TEST(ApmWithSubmodulesExcludedTest, ReinitializeTransientSuppressor) {
|
||||
}
|
||||
|
||||
StreamConfig high_sample_rate_stream_config(/*sample_rate_hz=*/48000,
|
||||
/*num_channels=*/1,
|
||||
/*has_keyboard=*/false);
|
||||
/*num_channels=*/2);
|
||||
for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) {
|
||||
RandomizeSampleVector(&random_generator, buffer);
|
||||
EXPECT_EQ(
|
||||
@ -696,16 +689,6 @@ TEST(ApmWithSubmodulesExcludedTest, ReinitializeTransientSuppressor) {
|
||||
high_sample_rate_stream_config, channel_pointers),
|
||||
kNoErr);
|
||||
}
|
||||
|
||||
StreamConfig keyboard_stream_config(/*sample_rate_hz=*/16000,
|
||||
/*num_channels=*/1,
|
||||
/*has_keyboard=*/true);
|
||||
for (int i = 0; i < kFramesToProcessPerConfiguration; ++i) {
|
||||
RandomizeSampleVector(&random_generator, buffer);
|
||||
EXPECT_EQ(apm->ProcessStream(channel_pointers, keyboard_stream_config,
|
||||
keyboard_stream_config, channel_pointers),
|
||||
kNoErr);
|
||||
}
|
||||
}
|
||||
|
||||
// Disable transient suppressor creation and run APM in ways that should trigger
|
||||
@ -724,8 +707,7 @@ TEST(ApmWithSubmodulesExcludedTest, ToggleTransientSuppressor) {
|
||||
Random random_generator(2341U);
|
||||
constexpr int kFramesToProcessPerConfiguration = 3;
|
||||
StreamConfig stream_config(/*sample_rate_hz=*/16000,
|
||||
/*num_channels=*/1,
|
||||
/*has_keyboard=*/false);
|
||||
/*num_channels=*/1);
|
||||
|
||||
AudioProcessing::Config config = apm->GetConfig();
|
||||
config.transient_suppression.enabled = true;
|
||||
|
||||
@ -343,7 +343,6 @@ class TimedThreadApiProcessor {
|
||||
frame_data_.input_stream_config.set_sample_rate_hz(
|
||||
simulation_config_->sample_rate_hz);
|
||||
frame_data_.input_stream_config.set_num_channels(num_channels_);
|
||||
frame_data_.input_stream_config.set_has_keyboard(false);
|
||||
populate_audio_frame(input_level_, num_channels_,
|
||||
(simulation_config_->sample_rate_hz *
|
||||
AudioProcessing::kChunkSizeMs / 1000),
|
||||
@ -353,7 +352,6 @@ class TimedThreadApiProcessor {
|
||||
frame_data_.output_stream_config.set_sample_rate_hz(
|
||||
simulation_config_->sample_rate_hz);
|
||||
frame_data_.output_stream_config.set_num_channels(1);
|
||||
frame_data_.output_stream_config.set_has_keyboard(false);
|
||||
}
|
||||
|
||||
bool ReadyToProcess() {
|
||||
|
||||
@ -95,21 +95,6 @@ void ConvertToFloat(const Int16FrameData& frame, ChannelBuffer<float>* cb) {
|
||||
ConvertToFloat(frame.data.data(), cb);
|
||||
}
|
||||
|
||||
// Number of channels including the keyboard channel.
|
||||
size_t TotalChannelsFromLayout(AudioProcessing::ChannelLayout layout) {
|
||||
switch (layout) {
|
||||
case AudioProcessing::kMono:
|
||||
return 1;
|
||||
case AudioProcessing::kMonoAndKeyboard:
|
||||
case AudioProcessing::kStereo:
|
||||
return 2;
|
||||
case AudioProcessing::kStereoAndKeyboard:
|
||||
return 3;
|
||||
}
|
||||
RTC_DCHECK_NOTREACHED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MixStereoToMono(const float* stereo,
|
||||
float* mono,
|
||||
size_t samples_per_channel) {
|
||||
@ -1885,44 +1870,6 @@ TEST_F(ApmTest, Process) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(ApmTest, NoErrorsWithKeyboardChannel) {
|
||||
struct ChannelFormat {
|
||||
AudioProcessing::ChannelLayout in_layout;
|
||||
AudioProcessing::ChannelLayout out_layout;
|
||||
};
|
||||
ChannelFormat cf[] = {
|
||||
{AudioProcessing::kMonoAndKeyboard, AudioProcessing::kMono},
|
||||
{AudioProcessing::kStereoAndKeyboard, AudioProcessing::kMono},
|
||||
{AudioProcessing::kStereoAndKeyboard, AudioProcessing::kStereo},
|
||||
};
|
||||
|
||||
rtc::scoped_refptr<AudioProcessing> ap =
|
||||
AudioProcessingBuilderForTesting().Create();
|
||||
// Enable one component just to ensure some processing takes place.
|
||||
AudioProcessing::Config config;
|
||||
config.noise_suppression.enabled = true;
|
||||
ap->ApplyConfig(config);
|
||||
for (size_t i = 0; i < arraysize(cf); ++i) {
|
||||
const int in_rate = 44100;
|
||||
const int out_rate = 48000;
|
||||
ChannelBuffer<float> in_cb(SamplesFromRate(in_rate),
|
||||
TotalChannelsFromLayout(cf[i].in_layout));
|
||||
ChannelBuffer<float> out_cb(SamplesFromRate(out_rate),
|
||||
ChannelsFromLayout(cf[i].out_layout));
|
||||
bool has_keyboard = cf[i].in_layout == AudioProcessing::kMonoAndKeyboard ||
|
||||
cf[i].in_layout == AudioProcessing::kStereoAndKeyboard;
|
||||
StreamConfig in_sc(in_rate, ChannelsFromLayout(cf[i].in_layout),
|
||||
has_keyboard);
|
||||
StreamConfig out_sc(out_rate, ChannelsFromLayout(cf[i].out_layout));
|
||||
|
||||
// Run over a few chunks.
|
||||
for (int j = 0; j < 10; ++j) {
|
||||
EXPECT_NOERR(ap->ProcessStream(in_cb.channels(), in_sc, out_sc,
|
||||
out_cb.channels()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compares the reference and test arrays over a region around the expected
|
||||
// delay. Finds the highest SNR in that region and adds the variance and squared
|
||||
// error results to the supplied accumulators.
|
||||
@ -2443,7 +2390,6 @@ void RunApmRateAndChannelTest(
|
||||
std::vector<float*>* frame_data) {
|
||||
cfg->set_sample_rate_hz(sample_rate_hz);
|
||||
cfg->set_num_channels(num_channels);
|
||||
cfg->set_has_keyboard(false);
|
||||
|
||||
size_t max_frame_size = ceil(sample_rate_hz / 100.f);
|
||||
channels_data->resize(num_channels * max_frame_size);
|
||||
|
||||
@ -68,7 +68,7 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
&echo_control_mobile);
|
||||
|
||||
const int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
|
||||
const StreamConfig render_config(sample_rate_hz, num_channels, false);
|
||||
const StreamConfig render_config(sample_rate_hz, num_channels);
|
||||
AudioBuffer render_buffer(
|
||||
render_config.sample_rate_hz(), render_config.num_channels(),
|
||||
render_config.sample_rate_hz(), 1, render_config.sample_rate_hz(), 1);
|
||||
@ -76,7 +76,7 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
test::GetApmRenderTestVectorFileName(sample_rate_hz));
|
||||
std::vector<float> render_input(samples_per_channel * num_channels);
|
||||
|
||||
const StreamConfig capture_config(sample_rate_hz, num_channels, false);
|
||||
const StreamConfig capture_config(sample_rate_hz, num_channels);
|
||||
AudioBuffer capture_buffer(
|
||||
capture_config.sample_rate_hz(), capture_config.num_channels(),
|
||||
capture_config.sample_rate_hz(), 1, capture_config.sample_rate_hz(), 1);
|
||||
|
||||
@ -77,7 +77,7 @@ void RunBitExactnessTest(int sample_rate_hz,
|
||||
analog_level_max, &gain_controller);
|
||||
|
||||
const int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
|
||||
const StreamConfig render_config(sample_rate_hz, num_channels, false);
|
||||
const StreamConfig render_config(sample_rate_hz, num_channels);
|
||||
AudioBuffer render_buffer(
|
||||
render_config.sample_rate_hz(), render_config.num_channels(),
|
||||
render_config.sample_rate_hz(), 1, render_config.sample_rate_hz(), 1);
|
||||
@ -85,7 +85,7 @@ void RunBitExactnessTest(int sample_rate_hz,
|
||||
test::GetApmRenderTestVectorFileName(sample_rate_hz));
|
||||
std::vector<float> render_input(samples_per_channel * num_channels);
|
||||
|
||||
const StreamConfig capture_config(sample_rate_hz, num_channels, false);
|
||||
const StreamConfig capture_config(sample_rate_hz, num_channels);
|
||||
AudioBuffer capture_buffer(
|
||||
capture_config.sample_rate_hz(), capture_config.num_channels(),
|
||||
capture_config.sample_rate_hz(), 1, capture_config.sample_rate_hz(), 1);
|
||||
|
||||
@ -258,8 +258,7 @@ TEST(GainController2, CheckFinalGainWithAdaptiveDigitalController) {
|
||||
test::InputAudioFile input_file(
|
||||
test::GetApmCaptureTestVectorFileName(kSampleRateHz),
|
||||
/*loop_at_end=*/true);
|
||||
const StreamConfig stream_config(kSampleRateHz, kStereo,
|
||||
/*has_keyboard=*/false);
|
||||
const StreamConfig stream_config(kSampleRateHz, kStereo);
|
||||
|
||||
// Init buffers.
|
||||
constexpr int kFrameDurationMs = 10;
|
||||
|
||||
@ -75,7 +75,7 @@ void RunBitexactnessTest(int num_channels,
|
||||
bool use_audio_buffer_interface,
|
||||
const std::vector<float>& input,
|
||||
const std::vector<float>& reference) {
|
||||
const StreamConfig stream_config(16000, num_channels, false);
|
||||
const StreamConfig stream_config(16000, num_channels);
|
||||
HighPassFilter high_pass_filter(16000, num_channels);
|
||||
|
||||
std::vector<float> output;
|
||||
@ -131,8 +131,8 @@ std::vector<float> CreateVector(const rtc::ArrayView<const float>& array_view) {
|
||||
} // namespace
|
||||
|
||||
TEST(HighPassFilterAccuracyTest, ResetWithAudioBufferInterface) {
|
||||
const StreamConfig stream_config_stereo(16000, 2, false);
|
||||
const StreamConfig stream_config_mono(16000, 1, false);
|
||||
const StreamConfig stream_config_stereo(16000, 2);
|
||||
const StreamConfig stream_config_mono(16000, 1);
|
||||
std::vector<float> x_mono(160, 1.f);
|
||||
std::vector<float> x_stereo(320, 1.f);
|
||||
HighPassFilter hpf(16000, 1);
|
||||
@ -147,8 +147,8 @@ TEST(HighPassFilterAccuracyTest, ResetWithAudioBufferInterface) {
|
||||
}
|
||||
|
||||
TEST(HighPassFilterAccuracyTest, ResetWithVectorInterface) {
|
||||
const StreamConfig stream_config_stereo(16000, 2, false);
|
||||
const StreamConfig stream_config_mono(16000, 1, false);
|
||||
const StreamConfig stream_config_stereo(16000, 2);
|
||||
const StreamConfig stream_config_mono(16000, 1);
|
||||
std::vector<float> x_mono(160, 1.f);
|
||||
std::vector<float> x_stereo(320, 1.f);
|
||||
HighPassFilter hpf(16000, 1);
|
||||
|
||||
@ -20,10 +20,8 @@ int ProcessAudioFrame(AudioProcessing* ap, AudioFrame* frame) {
|
||||
return AudioProcessing::Error::kNullPointerError;
|
||||
}
|
||||
|
||||
StreamConfig input_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig output_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig input_config(frame->sample_rate_hz_, frame->num_channels_);
|
||||
StreamConfig output_config(frame->sample_rate_hz_, frame->num_channels_);
|
||||
RTC_DCHECK_EQ(frame->samples_per_channel(), input_config.num_frames());
|
||||
|
||||
int result = ap->ProcessStream(frame->data(), input_config, output_config,
|
||||
@ -57,10 +55,8 @@ int ProcessReverseAudioFrame(AudioProcessing* ap, AudioFrame* frame) {
|
||||
return AudioProcessing::Error::kBadNumberChannelsError;
|
||||
}
|
||||
|
||||
StreamConfig input_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig output_config(frame->sample_rate_hz_, frame->num_channels_,
|
||||
/*has_keyboard=*/false);
|
||||
StreamConfig input_config(frame->sample_rate_hz_, frame->num_channels_);
|
||||
StreamConfig output_config(frame->sample_rate_hz_, frame->num_channels_);
|
||||
|
||||
int result = ap->ProcessReverseStream(frame->data(), input_config,
|
||||
output_config, frame->mutable_data());
|
||||
|
||||
@ -530,16 +530,6 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
|
||||
// number of channels as the input.
|
||||
virtual int Initialize(const ProcessingConfig& processing_config) = 0;
|
||||
|
||||
// Initialize with unpacked parameters. See Initialize() above for details.
|
||||
//
|
||||
// TODO(mgraczyk): Remove once clients are updated to use the new interface.
|
||||
virtual int Initialize(int capture_input_sample_rate_hz,
|
||||
int capture_output_sample_rate_hz,
|
||||
int render_sample_rate_hz,
|
||||
ChannelLayout capture_input_layout,
|
||||
ChannelLayout capture_output_layout,
|
||||
ChannelLayout render_input_layout) = 0;
|
||||
|
||||
// TODO(peah): This method is a temporary solution used to take control
|
||||
// over the parameters in the audio processing module and is likely to change.
|
||||
virtual void ApplyConfig(const Config& config) = 0;
|
||||
@ -797,23 +787,11 @@ class RTC_EXPORT AudioProcessingBuilder {
|
||||
class StreamConfig {
|
||||
public:
|
||||
// sample_rate_hz: The sampling rate of the stream.
|
||||
//
|
||||
// num_channels: The number of audio channels in the stream, excluding the
|
||||
// keyboard channel if it is present. When passing a
|
||||
// StreamConfig with an array of arrays T*[N],
|
||||
//
|
||||
// N == {num_channels + 1 if has_keyboard
|
||||
// {num_channels if !has_keyboard
|
||||
//
|
||||
// has_keyboard: True if the stream has a keyboard channel. When has_keyboard
|
||||
// is true, the last channel in any corresponding list of
|
||||
// channels is the keyboard channel.
|
||||
// num_channels: The number of audio channels in the stream.
|
||||
StreamConfig(int sample_rate_hz = 0,
|
||||
size_t num_channels = 0,
|
||||
bool has_keyboard = false)
|
||||
size_t num_channels = 0)
|
||||
: sample_rate_hz_(sample_rate_hz),
|
||||
num_channels_(num_channels),
|
||||
has_keyboard_(has_keyboard),
|
||||
num_frames_(calculate_frames(sample_rate_hz)) {}
|
||||
|
||||
void set_sample_rate_hz(int value) {
|
||||
@ -821,22 +799,18 @@ class StreamConfig {
|
||||
num_frames_ = calculate_frames(value);
|
||||
}
|
||||
void set_num_channels(size_t value) { num_channels_ = value; }
|
||||
void set_has_keyboard(bool value) { has_keyboard_ = value; }
|
||||
|
||||
int sample_rate_hz() const { return sample_rate_hz_; }
|
||||
|
||||
// The number of channels in the stream, not including the keyboard channel if
|
||||
// present.
|
||||
// The number of channels in the stream.
|
||||
size_t num_channels() const { return num_channels_; }
|
||||
|
||||
bool has_keyboard() const { return has_keyboard_; }
|
||||
size_t num_frames() const { return num_frames_; }
|
||||
size_t num_samples() const { return num_channels_ * num_frames_; }
|
||||
|
||||
bool operator==(const StreamConfig& other) const {
|
||||
return sample_rate_hz_ == other.sample_rate_hz_ &&
|
||||
num_channels_ == other.num_channels_ &&
|
||||
has_keyboard_ == other.has_keyboard_;
|
||||
num_channels_ == other.num_channels_;
|
||||
}
|
||||
|
||||
bool operator!=(const StreamConfig& other) const { return !(*this == other); }
|
||||
@ -849,7 +823,6 @@ class StreamConfig {
|
||||
|
||||
int sample_rate_hz_;
|
||||
size_t num_channels_;
|
||||
bool has_keyboard_;
|
||||
size_t num_frames_;
|
||||
};
|
||||
|
||||
|
||||
@ -95,15 +95,6 @@ class MockAudioProcessing : public AudioProcessing {
|
||||
virtual ~MockAudioProcessing() {}
|
||||
|
||||
MOCK_METHOD(int, Initialize, (), (override));
|
||||
MOCK_METHOD(int,
|
||||
Initialize,
|
||||
(int capture_input_sample_rate_hz,
|
||||
int capture_output_sample_rate_hz,
|
||||
int render_sample_rate_hz,
|
||||
ChannelLayout capture_input_layout,
|
||||
ChannelLayout capture_output_layout,
|
||||
ChannelLayout render_input_layout),
|
||||
(override));
|
||||
MOCK_METHOD(int,
|
||||
Initialize,
|
||||
(const ProcessingConfig& processing_config),
|
||||
|
||||
@ -38,7 +38,7 @@ struct Int16Frame {
|
||||
samples_per_channel =
|
||||
rtc::CheckedDivExact(sample_rate_hz, kChunksPerSecond);
|
||||
this->num_channels = num_channels;
|
||||
config = StreamConfig(sample_rate_hz, num_channels, /*has_keyboard=*/false);
|
||||
config = StreamConfig(sample_rate_hz, num_channels);
|
||||
data.resize(num_channels * samples_per_channel);
|
||||
}
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ void SimulatorBuffers::CreateConfigAndBuffer(
|
||||
std::vector<float*>* buffer_data,
|
||||
std::vector<float>* buffer_data_samples) {
|
||||
int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
|
||||
*config = StreamConfig(sample_rate_hz, num_channels, false);
|
||||
*config = StreamConfig(sample_rate_hz, num_channels);
|
||||
buffer->reset(
|
||||
new AudioBuffer(config->sample_rate_hz(), config->num_channels(),
|
||||
config->sample_rate_hz(), config->num_channels(),
|
||||
|
||||
@ -42,7 +42,7 @@ void RunBitexactnessTest(int sample_rate_hz,
|
||||
VoiceDetection::kLowLikelihood);
|
||||
|
||||
int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
|
||||
const StreamConfig capture_config(sample_rate_hz, num_channels, false);
|
||||
const StreamConfig capture_config(sample_rate_hz, num_channels);
|
||||
AudioBuffer capture_buffer(
|
||||
capture_config.sample_rate_hz(), capture_config.num_channels(),
|
||||
capture_config.sample_rate_hz(), capture_config.num_channels(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user