xref: /aosp_15_r20/external/webrtc/api/audio/echo_canceller3_config.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1*d9f75844SAndroid Build Coastguard Worker /*
2*d9f75844SAndroid Build Coastguard Worker  *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3*d9f75844SAndroid Build Coastguard Worker  *
4*d9f75844SAndroid Build Coastguard Worker  *  Use of this source code is governed by a BSD-style license
5*d9f75844SAndroid Build Coastguard Worker  *  that can be found in the LICENSE file in the root of the source
6*d9f75844SAndroid Build Coastguard Worker  *  tree. An additional intellectual property rights grant can be found
7*d9f75844SAndroid Build Coastguard Worker  *  in the file PATENTS.  All contributing project authors may
8*d9f75844SAndroid Build Coastguard Worker  *  be found in the AUTHORS file in the root of the source tree.
9*d9f75844SAndroid Build Coastguard Worker  */
10*d9f75844SAndroid Build Coastguard Worker #include "api/audio/echo_canceller3_config.h"
11*d9f75844SAndroid Build Coastguard Worker 
12*d9f75844SAndroid Build Coastguard Worker #include <algorithm>
13*d9f75844SAndroid Build Coastguard Worker #include <cmath>
14*d9f75844SAndroid Build Coastguard Worker 
15*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/checks.h"
16*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/numerics/safe_minmax.h"
17*d9f75844SAndroid Build Coastguard Worker 
18*d9f75844SAndroid Build Coastguard Worker namespace webrtc {
19*d9f75844SAndroid Build Coastguard Worker namespace {
Limit(float * value,float min,float max)20*d9f75844SAndroid Build Coastguard Worker bool Limit(float* value, float min, float max) {
21*d9f75844SAndroid Build Coastguard Worker   float clamped = rtc::SafeClamp(*value, min, max);
22*d9f75844SAndroid Build Coastguard Worker   clamped = std::isfinite(clamped) ? clamped : min;
23*d9f75844SAndroid Build Coastguard Worker   bool res = *value == clamped;
24*d9f75844SAndroid Build Coastguard Worker   *value = clamped;
25*d9f75844SAndroid Build Coastguard Worker   return res;
26*d9f75844SAndroid Build Coastguard Worker }
27*d9f75844SAndroid Build Coastguard Worker 
Limit(size_t * value,size_t min,size_t max)28*d9f75844SAndroid Build Coastguard Worker bool Limit(size_t* value, size_t min, size_t max) {
29*d9f75844SAndroid Build Coastguard Worker   size_t clamped = rtc::SafeClamp(*value, min, max);
30*d9f75844SAndroid Build Coastguard Worker   bool res = *value == clamped;
31*d9f75844SAndroid Build Coastguard Worker   *value = clamped;
32*d9f75844SAndroid Build Coastguard Worker   return res;
33*d9f75844SAndroid Build Coastguard Worker }
34*d9f75844SAndroid Build Coastguard Worker 
Limit(int * value,int min,int max)35*d9f75844SAndroid Build Coastguard Worker bool Limit(int* value, int min, int max) {
36*d9f75844SAndroid Build Coastguard Worker   int clamped = rtc::SafeClamp(*value, min, max);
37*d9f75844SAndroid Build Coastguard Worker   bool res = *value == clamped;
38*d9f75844SAndroid Build Coastguard Worker   *value = clamped;
39*d9f75844SAndroid Build Coastguard Worker   return res;
40*d9f75844SAndroid Build Coastguard Worker }
41*d9f75844SAndroid Build Coastguard Worker 
FloorLimit(size_t * value,size_t min)42*d9f75844SAndroid Build Coastguard Worker bool FloorLimit(size_t* value, size_t min) {
43*d9f75844SAndroid Build Coastguard Worker   size_t clamped = *value >= min ? *value : min;
44*d9f75844SAndroid Build Coastguard Worker   bool res = *value == clamped;
45*d9f75844SAndroid Build Coastguard Worker   *value = clamped;
46*d9f75844SAndroid Build Coastguard Worker   return res;
47*d9f75844SAndroid Build Coastguard Worker }
48*d9f75844SAndroid Build Coastguard Worker 
49*d9f75844SAndroid Build Coastguard Worker }  // namespace
50*d9f75844SAndroid Build Coastguard Worker 
51*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::EchoCanceller3Config() = default;
52*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::EchoCanceller3Config(const EchoCanceller3Config& e) =
53*d9f75844SAndroid Build Coastguard Worker     default;
54*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config& EchoCanceller3Config::operator=(
55*d9f75844SAndroid Build Coastguard Worker     const EchoCanceller3Config& e) = default;
56*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Delay::Delay() = default;
57*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Delay::Delay(const EchoCanceller3Config::Delay& e) =
58*d9f75844SAndroid Build Coastguard Worker     default;
59*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Delay& EchoCanceller3Config::Delay::operator=(
60*d9f75844SAndroid Build Coastguard Worker     const Delay& e) = default;
61*d9f75844SAndroid Build Coastguard Worker 
62*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::EchoModel::EchoModel() = default;
63*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::EchoModel::EchoModel(
64*d9f75844SAndroid Build Coastguard Worker     const EchoCanceller3Config::EchoModel& e) = default;
65*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::EchoModel& EchoCanceller3Config::EchoModel::operator=(
66*d9f75844SAndroid Build Coastguard Worker     const EchoModel& e) = default;
67*d9f75844SAndroid Build Coastguard Worker 
68*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::Suppressor() = default;
69*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::Suppressor(
70*d9f75844SAndroid Build Coastguard Worker     const EchoCanceller3Config::Suppressor& e) = default;
71*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor& EchoCanceller3Config::Suppressor::operator=(
72*d9f75844SAndroid Build Coastguard Worker     const Suppressor& e) = default;
73*d9f75844SAndroid Build Coastguard Worker 
MaskingThresholds(float enr_transparent,float enr_suppress,float emr_transparent)74*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::MaskingThresholds::MaskingThresholds(
75*d9f75844SAndroid Build Coastguard Worker     float enr_transparent,
76*d9f75844SAndroid Build Coastguard Worker     float enr_suppress,
77*d9f75844SAndroid Build Coastguard Worker     float emr_transparent)
78*d9f75844SAndroid Build Coastguard Worker     : enr_transparent(enr_transparent),
79*d9f75844SAndroid Build Coastguard Worker       enr_suppress(enr_suppress),
80*d9f75844SAndroid Build Coastguard Worker       emr_transparent(emr_transparent) {}
81*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::MaskingThresholds::MaskingThresholds(
82*d9f75844SAndroid Build Coastguard Worker     const EchoCanceller3Config::Suppressor::MaskingThresholds& e) = default;
83*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::MaskingThresholds&
84*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::MaskingThresholds::operator=(
85*d9f75844SAndroid Build Coastguard Worker     const MaskingThresholds& e) = default;
86*d9f75844SAndroid Build Coastguard Worker 
Tuning(MaskingThresholds mask_lf,MaskingThresholds mask_hf,float max_inc_factor,float max_dec_factor_lf)87*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::Tuning::Tuning(MaskingThresholds mask_lf,
88*d9f75844SAndroid Build Coastguard Worker                                                  MaskingThresholds mask_hf,
89*d9f75844SAndroid Build Coastguard Worker                                                  float max_inc_factor,
90*d9f75844SAndroid Build Coastguard Worker                                                  float max_dec_factor_lf)
91*d9f75844SAndroid Build Coastguard Worker     : mask_lf(mask_lf),
92*d9f75844SAndroid Build Coastguard Worker       mask_hf(mask_hf),
93*d9f75844SAndroid Build Coastguard Worker       max_inc_factor(max_inc_factor),
94*d9f75844SAndroid Build Coastguard Worker       max_dec_factor_lf(max_dec_factor_lf) {}
95*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::Tuning::Tuning(
96*d9f75844SAndroid Build Coastguard Worker     const EchoCanceller3Config::Suppressor::Tuning& e) = default;
97*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::Tuning&
98*d9f75844SAndroid Build Coastguard Worker EchoCanceller3Config::Suppressor::Tuning::operator=(const Tuning& e) = default;
99*d9f75844SAndroid Build Coastguard Worker 
Validate(EchoCanceller3Config * config)100*d9f75844SAndroid Build Coastguard Worker bool EchoCanceller3Config::Validate(EchoCanceller3Config* config) {
101*d9f75844SAndroid Build Coastguard Worker   RTC_DCHECK(config);
102*d9f75844SAndroid Build Coastguard Worker   EchoCanceller3Config* c = config;
103*d9f75844SAndroid Build Coastguard Worker   bool res = true;
104*d9f75844SAndroid Build Coastguard Worker 
105*d9f75844SAndroid Build Coastguard Worker   if (c->delay.down_sampling_factor != 4 &&
106*d9f75844SAndroid Build Coastguard Worker       c->delay.down_sampling_factor != 8) {
107*d9f75844SAndroid Build Coastguard Worker     c->delay.down_sampling_factor = 4;
108*d9f75844SAndroid Build Coastguard Worker     res = false;
109*d9f75844SAndroid Build Coastguard Worker   }
110*d9f75844SAndroid Build Coastguard Worker 
111*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.default_delay, 0, 5000);
112*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.num_filters, 0, 5000);
113*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.delay_headroom_samples, 0, 5000);
114*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.hysteresis_limit_blocks, 0, 5000);
115*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.fixed_capture_delay_samples, 0, 5000);
116*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.delay_estimate_smoothing, 0.f, 1.f);
117*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.delay_candidate_detection_threshold, 0.f, 1.f);
118*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.delay_selection_thresholds.initial, 1, 250);
119*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->delay.delay_selection_thresholds.converged, 1, 250);
120*d9f75844SAndroid Build Coastguard Worker 
121*d9f75844SAndroid Build Coastguard Worker   res = res & FloorLimit(&c->filter.refined.length_blocks, 1);
122*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined.leakage_converged, 0.f, 1000.f);
123*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined.leakage_diverged, 0.f, 1000.f);
124*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined.error_floor, 0.f, 1000.f);
125*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined.error_ceil, 0.f, 100000000.f);
126*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined.noise_gate, 0.f, 100000000.f);
127*d9f75844SAndroid Build Coastguard Worker 
128*d9f75844SAndroid Build Coastguard Worker   res = res & FloorLimit(&c->filter.refined_initial.length_blocks, 1);
129*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined_initial.leakage_converged, 0.f, 1000.f);
130*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined_initial.leakage_diverged, 0.f, 1000.f);
131*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined_initial.error_floor, 0.f, 1000.f);
132*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined_initial.error_ceil, 0.f, 100000000.f);
133*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.refined_initial.noise_gate, 0.f, 100000000.f);
134*d9f75844SAndroid Build Coastguard Worker 
135*d9f75844SAndroid Build Coastguard Worker   if (c->filter.refined.length_blocks <
136*d9f75844SAndroid Build Coastguard Worker       c->filter.refined_initial.length_blocks) {
137*d9f75844SAndroid Build Coastguard Worker     c->filter.refined_initial.length_blocks = c->filter.refined.length_blocks;
138*d9f75844SAndroid Build Coastguard Worker     res = false;
139*d9f75844SAndroid Build Coastguard Worker   }
140*d9f75844SAndroid Build Coastguard Worker 
141*d9f75844SAndroid Build Coastguard Worker   res = res & FloorLimit(&c->filter.coarse.length_blocks, 1);
142*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.coarse.rate, 0.f, 1.f);
143*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.coarse.noise_gate, 0.f, 100000000.f);
144*d9f75844SAndroid Build Coastguard Worker 
145*d9f75844SAndroid Build Coastguard Worker   res = res & FloorLimit(&c->filter.coarse_initial.length_blocks, 1);
146*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.coarse_initial.rate, 0.f, 1.f);
147*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.coarse_initial.noise_gate, 0.f, 100000000.f);
148*d9f75844SAndroid Build Coastguard Worker 
149*d9f75844SAndroid Build Coastguard Worker   if (c->filter.coarse.length_blocks < c->filter.coarse_initial.length_blocks) {
150*d9f75844SAndroid Build Coastguard Worker     c->filter.coarse_initial.length_blocks = c->filter.coarse.length_blocks;
151*d9f75844SAndroid Build Coastguard Worker     res = false;
152*d9f75844SAndroid Build Coastguard Worker   }
153*d9f75844SAndroid Build Coastguard Worker 
154*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.config_change_duration_blocks, 0, 100000);
155*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.initial_state_seconds, 0.f, 100.f);
156*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->filter.coarse_reset_hangover_blocks, 0, 250000);
157*d9f75844SAndroid Build Coastguard Worker 
158*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->erle.min, 1.f, 100000.f);
159*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->erle.max_l, 1.f, 100000.f);
160*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->erle.max_h, 1.f, 100000.f);
161*d9f75844SAndroid Build Coastguard Worker   if (c->erle.min > c->erle.max_l || c->erle.min > c->erle.max_h) {
162*d9f75844SAndroid Build Coastguard Worker     c->erle.min = std::min(c->erle.max_l, c->erle.max_h);
163*d9f75844SAndroid Build Coastguard Worker     res = false;
164*d9f75844SAndroid Build Coastguard Worker   }
165*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->erle.num_sections, 1, c->filter.refined.length_blocks);
166*d9f75844SAndroid Build Coastguard Worker 
167*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->ep_strength.default_gain, 0.f, 1000000.f);
168*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->ep_strength.default_len, -1.f, 1.f);
169*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->ep_strength.nearend_len, -1.0f, 1.0f);
170*d9f75844SAndroid Build Coastguard Worker 
171*d9f75844SAndroid Build Coastguard Worker   res =
172*d9f75844SAndroid Build Coastguard Worker       res & Limit(&c->echo_audibility.low_render_limit, 0.f, 32768.f * 32768.f);
173*d9f75844SAndroid Build Coastguard Worker   res = res &
174*d9f75844SAndroid Build Coastguard Worker         Limit(&c->echo_audibility.normal_render_limit, 0.f, 32768.f * 32768.f);
175*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_audibility.floor_power, 0.f, 32768.f * 32768.f);
176*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_audibility.audibility_threshold_lf, 0.f,
177*d9f75844SAndroid Build Coastguard Worker                     32768.f * 32768.f);
178*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_audibility.audibility_threshold_mf, 0.f,
179*d9f75844SAndroid Build Coastguard Worker                     32768.f * 32768.f);
180*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_audibility.audibility_threshold_hf, 0.f,
181*d9f75844SAndroid Build Coastguard Worker                     32768.f * 32768.f);
182*d9f75844SAndroid Build Coastguard Worker 
183*d9f75844SAndroid Build Coastguard Worker   res = res &
184*d9f75844SAndroid Build Coastguard Worker         Limit(&c->render_levels.active_render_limit, 0.f, 32768.f * 32768.f);
185*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->render_levels.poor_excitation_render_limit, 0.f,
186*d9f75844SAndroid Build Coastguard Worker                     32768.f * 32768.f);
187*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->render_levels.poor_excitation_render_limit_ds8, 0.f,
188*d9f75844SAndroid Build Coastguard Worker                     32768.f * 32768.f);
189*d9f75844SAndroid Build Coastguard Worker 
190*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.noise_floor_hold, 0, 1000);
191*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.min_noise_floor_power, 0, 2000000.f);
192*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.stationary_gate_slope, 0, 1000000.f);
193*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.noise_gate_power, 0, 1000000.f);
194*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.noise_gate_slope, 0, 1000000.f);
195*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.render_pre_window_size, 0, 100);
196*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->echo_model.render_post_window_size, 0, 100);
197*d9f75844SAndroid Build Coastguard Worker 
198*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->comfort_noise.noise_floor_dbfs, -200.f, 0.f);
199*d9f75844SAndroid Build Coastguard Worker 
200*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.nearend_average_blocks, 1, 5000);
201*d9f75844SAndroid Build Coastguard Worker 
202*d9f75844SAndroid Build Coastguard Worker   res = res &
203*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.normal_tuning.mask_lf.enr_transparent, 0.f, 100.f);
204*d9f75844SAndroid Build Coastguard Worker   res = res &
205*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.normal_tuning.mask_lf.enr_suppress, 0.f, 100.f);
206*d9f75844SAndroid Build Coastguard Worker   res = res &
207*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.normal_tuning.mask_lf.emr_transparent, 0.f, 100.f);
208*d9f75844SAndroid Build Coastguard Worker   res = res &
209*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.normal_tuning.mask_hf.enr_transparent, 0.f, 100.f);
210*d9f75844SAndroid Build Coastguard Worker   res = res &
211*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.normal_tuning.mask_hf.enr_suppress, 0.f, 100.f);
212*d9f75844SAndroid Build Coastguard Worker   res = res &
213*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.normal_tuning.mask_hf.emr_transparent, 0.f, 100.f);
214*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.normal_tuning.max_inc_factor, 0.f, 100.f);
215*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.normal_tuning.max_dec_factor_lf, 0.f, 100.f);
216*d9f75844SAndroid Build Coastguard Worker 
217*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.nearend_tuning.mask_lf.enr_transparent, 0.f,
218*d9f75844SAndroid Build Coastguard Worker                     100.f);
219*d9f75844SAndroid Build Coastguard Worker   res = res &
220*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.nearend_tuning.mask_lf.enr_suppress, 0.f, 100.f);
221*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.nearend_tuning.mask_lf.emr_transparent, 0.f,
222*d9f75844SAndroid Build Coastguard Worker                     100.f);
223*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.nearend_tuning.mask_hf.enr_transparent, 0.f,
224*d9f75844SAndroid Build Coastguard Worker                     100.f);
225*d9f75844SAndroid Build Coastguard Worker   res = res &
226*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.nearend_tuning.mask_hf.enr_suppress, 0.f, 100.f);
227*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.nearend_tuning.mask_hf.emr_transparent, 0.f,
228*d9f75844SAndroid Build Coastguard Worker                     100.f);
229*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.nearend_tuning.max_inc_factor, 0.f, 100.f);
230*d9f75844SAndroid Build Coastguard Worker   res =
231*d9f75844SAndroid Build Coastguard Worker       res & Limit(&c->suppressor.nearend_tuning.max_dec_factor_lf, 0.f, 100.f);
232*d9f75844SAndroid Build Coastguard Worker 
233*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.last_permanent_lf_smoothing_band, 0, 64);
234*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.last_lf_smoothing_band, 0, 64);
235*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.last_lf_band, 0, 63);
236*d9f75844SAndroid Build Coastguard Worker   res = res &
237*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.first_hf_band, c->suppressor.last_lf_band + 1, 64);
238*d9f75844SAndroid Build Coastguard Worker 
239*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.dominant_nearend_detection.enr_threshold,
240*d9f75844SAndroid Build Coastguard Worker                     0.f, 1000000.f);
241*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.dominant_nearend_detection.snr_threshold,
242*d9f75844SAndroid Build Coastguard Worker                     0.f, 1000000.f);
243*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.dominant_nearend_detection.hold_duration, 0,
244*d9f75844SAndroid Build Coastguard Worker                     10000);
245*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.dominant_nearend_detection.trigger_threshold,
246*d9f75844SAndroid Build Coastguard Worker                     0, 10000);
247*d9f75844SAndroid Build Coastguard Worker 
248*d9f75844SAndroid Build Coastguard Worker   res = res &
249*d9f75844SAndroid Build Coastguard Worker         Limit(&c->suppressor.subband_nearend_detection.nearend_average_blocks,
250*d9f75844SAndroid Build Coastguard Worker               1, 1024);
251*d9f75844SAndroid Build Coastguard Worker   res =
252*d9f75844SAndroid Build Coastguard Worker       res & Limit(&c->suppressor.subband_nearend_detection.subband1.low, 0, 65);
253*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.subband_nearend_detection.subband1.high,
254*d9f75844SAndroid Build Coastguard Worker                     c->suppressor.subband_nearend_detection.subband1.low, 65);
255*d9f75844SAndroid Build Coastguard Worker   res =
256*d9f75844SAndroid Build Coastguard Worker       res & Limit(&c->suppressor.subband_nearend_detection.subband2.low, 0, 65);
257*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.subband_nearend_detection.subband2.high,
258*d9f75844SAndroid Build Coastguard Worker                     c->suppressor.subband_nearend_detection.subband2.low, 65);
259*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.subband_nearend_detection.nearend_threshold,
260*d9f75844SAndroid Build Coastguard Worker                     0.f, 1.e24f);
261*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.subband_nearend_detection.snr_threshold, 0.f,
262*d9f75844SAndroid Build Coastguard Worker                     1.e24f);
263*d9f75844SAndroid Build Coastguard Worker 
264*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.high_bands_suppression.enr_threshold, 0.f,
265*d9f75844SAndroid Build Coastguard Worker                     1000000.f);
266*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.high_bands_suppression.max_gain_during_echo,
267*d9f75844SAndroid Build Coastguard Worker                     0.f, 1.f);
268*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.high_bands_suppression
269*d9f75844SAndroid Build Coastguard Worker                          .anti_howling_activation_threshold,
270*d9f75844SAndroid Build Coastguard Worker                     0.f, 32768.f * 32768.f);
271*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.high_bands_suppression.anti_howling_gain,
272*d9f75844SAndroid Build Coastguard Worker                     0.f, 1.f);
273*d9f75844SAndroid Build Coastguard Worker 
274*d9f75844SAndroid Build Coastguard Worker   res = res & Limit(&c->suppressor.floor_first_increase, 0.f, 1000000.f);
275*d9f75844SAndroid Build Coastguard Worker 
276*d9f75844SAndroid Build Coastguard Worker   return res;
277*d9f75844SAndroid Build Coastguard Worker }
278*d9f75844SAndroid Build Coastguard Worker }  // namespace webrtc
279