Add FixedGainController and move GainController2 in APM.

The FixedGainController (FGC) applies a fixed gain. It will also
control the limiter. The limiter will be landed over the next several
CLs.

The GainController2 is a 'private submodule' of APM. It will control
the new automatic gain controller (AGC). It controls the AGC through
Initialize() and ApplyConfig().

This CL contains

* build changes to make modules/audio_processing/agc2 an independent
  target

* a new MutableFloatAudioFrame which is the audio interface between
  AGC2 and APM

* move of the fixed gain application from GainController2 to
  FixedGainController.

If you are a googler, there is more information in this doc:
https://docs.google.com/document/d/1RV2Doet3MZtUPAHVva61Vjo20iyd1bmmm3aR8znWpzo/edit#

Bug: webrtc:7949
Change-Id: Ief95cbbce83c3aafe54638fd2ab881c9fb8bdc3a
Reviewed-on: https://webrtc-review.googlesource.com/50440
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Oskar Sundbom <ossu@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22046}
This commit is contained in:
Alex Loiko
2018-02-16 11:54:07 +01:00
committed by Commit Bot
parent 6df09f6f6a
commit e36e8bbf6d
20 changed files with 510 additions and 87 deletions

View File

@ -16,6 +16,7 @@
#include <vector>
#include "api/array_view.h"
#include "modules/audio_processing/include/audio_frame_view.h"
namespace webrtc {
@ -65,37 +66,6 @@ struct InternalAPMStreamsConfig {
size_t render_output_num_channels = 0;
};
// Class to pass audio data in float** format. This is to avoid
// dependence on AudioBuffer, and avoid problems associated with
// rtc::ArrayView<rtc::ArrayView>.
class FloatAudioFrame {
public:
// |num_channels| and |channel_size| describe the float**
// |audio_samples|. |audio_samples| is assumed to point to a
// two-dimensional |num_channels * channel_size| array of floats.
FloatAudioFrame(const float* const* audio_samples,
size_t num_channels,
size_t channel_size)
: audio_samples_(audio_samples),
num_channels_(num_channels),
channel_size_(channel_size) {}
FloatAudioFrame() = delete;
size_t num_channels() const { return num_channels_; }
rtc::ArrayView<const float> channel(size_t idx) const {
RTC_DCHECK_LE(0, idx);
RTC_DCHECK_LE(idx, num_channels_);
return rtc::ArrayView<const float>(audio_samples_[idx], channel_size_);
}
private:
const float* const* audio_samples_;
size_t num_channels_;
size_t channel_size_;
};
// An interface for recording configuration and input/output streams
// of the Audio Processing Module. The recordings are called
// 'aec-dumps' and are stored in a protobuf format defined in
@ -122,8 +92,10 @@ class AecDump {
// Logs Event::Type STREAM message. To log an input/output pair,
// call the AddCapture* and AddAudioProcessingState methods followed
// by a WriteCaptureStreamMessage call.
virtual void AddCaptureStreamInput(const FloatAudioFrame& src) = 0;
virtual void AddCaptureStreamOutput(const FloatAudioFrame& src) = 0;
virtual void AddCaptureStreamInput(
const AudioFrameView<const float>& src) = 0;
virtual void AddCaptureStreamOutput(
const AudioFrameView<const float>& src) = 0;
virtual void AddCaptureStreamInput(const AudioFrame& frame) = 0;
virtual void AddCaptureStreamOutput(const AudioFrame& frame) = 0;
virtual void AddAudioProcessingState(const AudioProcessingState& state) = 0;
@ -131,7 +103,8 @@ class AecDump {
// Logs Event::Type REVERSE_STREAM message.
virtual void WriteRenderStreamMessage(const AudioFrame& frame) = 0;
virtual void WriteRenderStreamMessage(const FloatAudioFrame& src) = 0;
virtual void WriteRenderStreamMessage(
const AudioFrameView<const float>& src) = 0;
// Logs Event::Type CONFIG message.
virtual void WriteConfig(const InternalAPMConfig& config) = 0;