Revert of Added functionality for specifying the initial signal level to use for the gain estimation in the l… (patchset #8 id:160001 of https://codereview.webrtc.org/2254973003/ )

Reason for revert:
This caused build breakage due to upstream dependencies.

These dependencies need to be resolved before landing the CL.

Original issue's description:
> This CL adds functionality in the level controller to
> receive a signal level to use initially, instead of the
> default initial signal level.
>
> BUG=
>
> Committed: https://crrev.com/57fec1d828113241186e78710ec5e851cc1a0e81
> Cr-Commit-Position: refs/heads/master@{#13931}

TBR=henrik.lundin@webrtc.org,aleloi@webrtc.org,solenberg@webrtc.org,henrika@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=

Review-Url: https://codereview.webrtc.org/2283793002
Cr-Commit-Position: refs/heads/master@{#13936}
This commit is contained in:
peah 2016-08-26 06:20:22 -07:00 committed by Commit bot
parent fe1d191e58
commit 7d67e45104
11 changed files with 15 additions and 73 deletions

View File

@ -93,7 +93,6 @@ class FakeAudioProcessing : public webrtc::AudioProcessing {
WEBRTC_STUB_CONST(stream_delay_ms, ());
WEBRTC_BOOL_STUB_CONST(was_stream_delay_set, ());
WEBRTC_VOID_STUB(set_stream_key_pressed, (bool key_pressed));
WEBRTC_VOID_STUB(SetLevelControllerInitialLevel, (float level));
WEBRTC_VOID_STUB(set_delay_offset_ms, (int offset));
WEBRTC_STUB_CONST(delay_offset_ms, ());
WEBRTC_STUB(StartDebugRecording,

View File

@ -992,11 +992,6 @@ void AudioProcessingImpl::set_stream_key_pressed(bool key_pressed) {
capture_.key_pressed = key_pressed;
}
void AudioProcessingImpl::SetLevelControllerInitialLevel(float level) {
rtc::CritScope cs(&crit_capture_);
private_submodules_->level_controller->SetInitialLevel(level);
}
void AudioProcessingImpl::set_delay_offset_ms(int offset) {
rtc::CritScope cs(&crit_capture_);
capture_.delay_offset_ms = offset;

View File

@ -82,7 +82,6 @@ class AudioProcessingImpl : public AudioProcessing {
void set_delay_offset_ms(int offset) override;
int delay_offset_ms() const override;
void set_stream_key_pressed(bool key_pressed) override;
void SetLevelControllerInitialLevel(float level) override;
// Render-side exclusive methods possibly running APM in a
// multi-threaded manner. Acquire the render lock.

View File

@ -410,11 +410,6 @@ class AudioProcessing {
// with this chunk of audio.
virtual void set_stream_key_pressed(bool key_pressed) = 0;
// Sets the initial peak level to use inside the level controller in order
// to compute the signal gain. The unit for the peak level is dBFS and
// the allowed range is [-100, 0].
virtual void SetLevelControllerInitialLevel(float level) = 0;
// Sets a delay |offset| in ms to add to the values passed in through
// set_stream_delay_ms(). May be positive or negative.
//

View File

@ -42,12 +42,10 @@ void GainSelector::Initialize(int sample_rate_hz) {
float GainSelector::GetNewGain(float peak_level,
float noise_energy,
float saturating_gain,
bool gain_jumpstart,
SignalClassifier::SignalType signal_type) {
RTC_DCHECK_LT(0.f, peak_level);
if (signal_type == SignalClassifier::SignalType::kHighlyNonStationary ||
gain_jumpstart) {
if (signal_type == SignalClassifier::SignalType::kHighlyNonStationary) {
highly_nonstationary_signal_hold_counter_ = 100;
} else {
highly_nonstationary_signal_hold_counter_ =

View File

@ -24,7 +24,6 @@ class GainSelector {
float GetNewGain(float peak_level,
float noise_energy,
float saturating_gain,
bool gain_jumpstart,
SignalClassifier::SignalType signal_type);
private:

View File

@ -155,11 +155,6 @@ LevelController::LevelController()
LevelController::~LevelController() {}
void LevelController::SetInitialLevel(float level) {
peak_level_estimator_.SetInitialPeakLevel(level);
gain_jumpstart_ = true;
}
void LevelController::Initialize(int sample_rate_hz) {
RTC_DCHECK(sample_rate_hz == AudioProcessing::kSampleRate8kHz ||
sample_rate_hz == AudioProcessing::kSampleRate16kHz ||
@ -211,11 +206,8 @@ void LevelController::Process(AudioBuffer* audio) {
float saturating_gain = saturating_gain_estimator_.GetGain();
// Compute the new gain to apply.
last_gain_ = gain_selector_.GetNewGain(
peak_level, noise_energy, saturating_gain, gain_jumpstart_, signal_type);
// Unflag the jumpstart of the gain as it should only happen once.
gain_jumpstart_ = false;
last_gain_ = gain_selector_.GetNewGain(peak_level, noise_energy,
saturating_gain, signal_type);
// Apply the gain to the signal.
int num_saturations = gain_applier_.Process(last_gain_, audio);

View File

@ -38,11 +38,6 @@ class LevelController {
void Process(AudioBuffer* audio);
float GetLastGain() { return last_gain_; }
// Sets the initial peak level to use inside the level controller in order
// to compute the signal gain. The unit for the peak level is dBFS and
// the allowed range is [-100, 0].
void SetInitialLevel(float level);
private:
class Metrics {
public:
@ -76,7 +71,6 @@ class LevelController {
float dc_level_[2];
float dc_forgetting_factor_;
float last_gain_;
bool gain_jumpstart_ = false;
RTC_DISALLOW_COPY_AND_ASSIGN(LevelController);
};

View File

@ -12,7 +12,6 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "webrtc/base/array_view.h"
#include "webrtc/base/optional.h"
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/modules/audio_processing/include/audio_processing.h"
#include "webrtc/modules/audio_processing/level_controller/level_controller.h"
@ -28,13 +27,9 @@ const int kNumFramesToProcess = 1000;
// any errors.
void RunBitexactnessTest(int sample_rate_hz,
size_t num_channels,
rtc::Optional<float> initial_level,
rtc::ArrayView<const float> output_reference) {
LevelController level_controller;
level_controller.Initialize(sample_rate_hz);
if (initial_level) {
level_controller.SetInitialLevel(*initial_level);
}
int samples_per_channel = rtc::CheckedDivExact(sample_rate_hz, 100);
const StreamConfig capture_config(sample_rate_hz, num_channels, false);
@ -76,19 +71,19 @@ void RunBitexactnessTest(int sample_rate_hz,
TEST(LevelControlBitExactnessTest, DISABLED_Mono8kHz) {
const float kOutputReference[] = {-0.013939f, -0.012154f, -0.009054f};
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 1,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Mono16kHz) {
const float kOutputReference[] = {-0.013706f, -0.013215f, -0.013018f};
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 1,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Mono32kHz) {
const float kOutputReference[] = {-0.014495f, -0.016425f, -0.016085f};
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 1,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
// TODO(peah): Investigate why this particular testcase differ between Android
@ -101,41 +96,35 @@ TEST(LevelControlBitExactnessTest, DISABLED_Mono48kHz) {
const float kOutputReference[] = {-0.015949f, -0.016957f, -0.019478f};
#endif
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo8kHz) {
const float kOutputReference[] = {-0.014063f, -0.008450f, -0.012159f,
-0.051967f, -0.023202f, -0.047858f};
RunBitexactnessTest(AudioProcessing::kSampleRate8kHz, 2,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo16kHz) {
const float kOutputReference[] = {-0.012714f, -0.005896f, -0.012220f,
-0.053306f, -0.024549f, -0.051527f};
RunBitexactnessTest(AudioProcessing::kSampleRate16kHz, 2,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo32kHz) {
const float kOutputReference[] = {-0.011737f, -0.007018f, -0.013446f,
-0.053505f, -0.026292f, -0.056221f};
RunBitexactnessTest(AudioProcessing::kSampleRate32kHz, 2,
rtc::Optional<float>(), kOutputReference);
kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_Stereo48kHz) {
const float kOutputReference[] = {-0.010643f, -0.006334f, -0.011377f,
-0.049088f, -0.023600f, -0.050465f};
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 2,
rtc::Optional<float>(), kOutputReference);
}
TEST(LevelControlBitExactnessTest, DISABLED_MonoInitial48kHz) {
const float kOutputReference[] = {-0.013753f, -0.014623f, -0.016797f};
RunBitexactnessTest(AudioProcessing::kSampleRate48kHz, 1,
rtc::Optional<float>(2000), kOutputReference);
kOutputReference);
}

View File

@ -13,14 +13,10 @@
#include <algorithm>
#include "webrtc/modules/audio_processing/audio_buffer.h"
#include "webrtc/modules/audio_processing/level_controller/lc_constants.h"
#include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
namespace webrtc {
namespace {
const float kMinLevel = 30.f;
} // namespace
PeakLevelEstimator::PeakLevelEstimator() {
Initialize();
@ -29,26 +25,15 @@ PeakLevelEstimator::PeakLevelEstimator() {
PeakLevelEstimator::~PeakLevelEstimator() {}
void PeakLevelEstimator::Initialize() {
peak_level_ = initial_peak_level_;
peak_level_ = kTargetLcPeakLevel;
hold_counter_ = 0;
initialization_phase_ = true;
}
void PeakLevelEstimator::SetInitialPeakLevel(float level) {
RTC_DCHECK_LE(-100.f, level);
RTC_DCHECK_GE(0.f, level);
float linear_level = std::pow(10.f, level / 20.f) * 32768.f;
// Limit the supplied level to the level range used internally.
initial_peak_level_ = std::max(linear_level, kMinLevel);
Initialize();
}
float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
float frame_peak_level) {
if (frame_peak_level == 0) {
RTC_DCHECK_LE(kMinLevel, peak_level_);
RTC_DCHECK_LE(30.f, peak_level_);
return peak_level_;
}
@ -72,7 +57,7 @@ float PeakLevelEstimator::Analyze(SignalClassifier::SignalType signal_type,
}
}
peak_level_ = std::max(peak_level_, kMinLevel);
peak_level_ = std::max(peak_level_, 30.f);
return peak_level_;
}

View File

@ -12,7 +12,6 @@
#define WEBRTC_MODULES_AUDIO_PROCESSING_LEVEL_CONTROLLER_PEAK_LEVEL_ESTIMATOR_H_
#include "webrtc/base/constructormagic.h"
#include "webrtc/modules/audio_processing/level_controller/lc_constants.h"
#include "webrtc/modules/audio_processing/level_controller/signal_classifier.h"
namespace webrtc {
@ -24,11 +23,9 @@ class PeakLevelEstimator {
void Initialize();
float Analyze(SignalClassifier::SignalType signal_type,
float frame_peak_level);
void SetInitialPeakLevel(float level);
private:
float peak_level_;
float initial_peak_level_ = kTargetLcPeakLevel;
int hold_counter_;
bool initialization_phase_;