| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#ifndef MODULES_AUDIO_PROCESSING_AEC3_ECHO_AUDIBILITY_H_ |
| 12 |
#define MODULES_AUDIO_PROCESSING_AEC3_ECHO_AUDIBILITY_H_ |
| 13 |
|
| 14 |
#include <stddef.h> |
| 15 |
|
| 16 |
#include "absl/types/optional.h" |
| 17 |
#include "api/array_view.h" |
| 18 |
#include "modules/audio_processing/aec3/block_buffer.h" |
| 19 |
#include "modules/audio_processing/aec3/render_buffer.h" |
| 20 |
#include "modules/audio_processing/aec3/spectrum_buffer.h" |
| 21 |
#include "modules/audio_processing/aec3/stationarity_estimator.h" |
| 22 |
#include "rtc_base/constructor_magic.h" |
| 23 |
|
| 24 |
namespace webrtc { |
| 25 |
|
| 26 |
class EchoAudibility { |
| 27 |
public: |
| 28 |
explicit EchoAudibility(bool use_render_stationarity_at_init); |
| 29 |
~EchoAudibility(); |
| 30 |
|
| 31 |
EchoAudibility(const EchoAudibility&) = delete; |
| 32 |
EchoAudibility& operator=(const EchoAudibility&) = delete; |
| 33 |
|
| 34 |
|
| 35 |
void Update(const RenderBuffer& render_buffer, |
| 36 |
rtc::ArrayView<const float> average_reverb, |
| 37 |
int min_channel_delay_blocks, |
| 38 |
bool external_delay_seen); |
| 39 |
|
| 40 |
void GetResidualEchoScaling(bool filter_has_had_time_to_converge, |
| 41 |
rtc::ArrayView<float> residual_scaling) const { |
| 42 |
for (size_t band = 0; band < residual_scaling.size(); ++band) { |
| 43 |
if (render_stationarity_.IsBandStationary(band) && |
| 44 |
(filter_has_had_time_to_converge || |
| 45 |
use_render_stationarity_at_init_)) { |
| 46 |
residual_scaling[band] = 0.f; |
| 47 |
} else { |
| 48 |
residual_scaling[band] = 1.0f; |
| 49 |
} |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
|
| 54 |
bool IsBlockStationary() const { |
| 55 |
return render_stationarity_.IsBlockStationary(); |
| 56 |
} |
| 57 |
|
| 58 |
private: |
| 59 |
|
| 60 |
void Reset(); |
| 61 |
|
| 62 |
|
| 63 |
void UpdateRenderStationarityFlags(const RenderBuffer& render_buffer, |
| 64 |
rtc::ArrayView<const float> average_reverb, |
| 65 |
int delay_blocks); |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
void UpdateRenderNoiseEstimator(const SpectrumBuffer& spectrum_buffer, |
| 70 |
const BlockBuffer& block_buffer, |
| 71 |
bool external_delay_seen); |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
bool IsRenderTooLow(const BlockBuffer& block_buffer); |
| 76 |
|
| 77 |
absl::optional<int> render_spectrum_write_prev_; |
| 78 |
int render_block_write_prev_; |
| 79 |
bool non_zero_render_seen_; |
| 80 |
const bool use_render_stationarity_at_init_; |
| 81 |
StationarityEstimator render_stationarity_; |
| 82 |
}; |
| 83 |
|
| 84 |
} |
| 85 |
|
| 86 |
#endif |