2017-02-23 05:16:26 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2017 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_
|
2017-02-23 05:16:26 -08:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
2017-02-23 05:16:26 -08:00
|
|
|
#include <array>
|
|
|
|
|
|
2017-12-01 23:01:44 +01:00
|
|
|
#include "api/array_view.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_processing/aec3/aec3_common.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/constructor_magic.h"
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Estimates the echo return loss based on the signal spectra.
|
|
|
|
|
class ErlEstimator {
|
|
|
|
|
public:
|
2018-10-04 15:37:54 +02:00
|
|
|
explicit ErlEstimator(size_t startup_phase_length_blocks_);
|
2017-02-23 05:16:26 -08:00
|
|
|
~ErlEstimator();
|
|
|
|
|
|
2018-10-04 15:37:54 +02:00
|
|
|
// Resets the ERL estimation.
|
|
|
|
|
void Reset();
|
|
|
|
|
|
2017-02-23 05:16:26 -08:00
|
|
|
// Updates the ERL estimate.
|
2018-10-04 15:37:54 +02:00
|
|
|
void Update(bool converged_filter,
|
|
|
|
|
rtc::ArrayView<const float> render_spectrum,
|
2017-12-01 23:01:44 +01:00
|
|
|
rtc::ArrayView<const float> capture_spectrum);
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
// Returns the most recent ERL estimate.
|
|
|
|
|
const std::array<float, kFftLengthBy2Plus1>& Erl() const { return erl_; }
|
2017-11-16 09:31:27 +01:00
|
|
|
float ErlTimeDomain() const { return erl_time_domain_; }
|
2017-02-23 05:16:26 -08:00
|
|
|
|
|
|
|
|
private:
|
2018-10-04 15:37:54 +02:00
|
|
|
const size_t startup_phase_length_blocks__;
|
2017-02-23 05:16:26 -08:00
|
|
|
std::array<float, kFftLengthBy2Plus1> erl_;
|
|
|
|
|
std::array<int, kFftLengthBy2Minus1> hold_counters_;
|
2017-11-16 09:31:27 +01:00
|
|
|
float erl_time_domain_;
|
|
|
|
|
int hold_counter_time_domain_;
|
2018-10-04 15:37:54 +02:00
|
|
|
size_t blocks_since_reset_ = 0;
|
2017-02-23 05:16:26 -08:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(ErlEstimator);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AEC3_ERL_ESTIMATOR_H_
|