Bump to WebRTC M120 release

Some API deprecation -- ExperimentalAgc and ExperimentalNs are gone.
We're continuing to carry iSAC even though it's gone upstream, but maybe
we'll want to drop that soon.
This commit is contained in:
Arun Raghavan
2023-12-12 10:42:58 -05:00
parent 9a202fb8c2
commit c6abf6cd3f
479 changed files with 20900 additions and 11996 deletions

View File

@ -50,7 +50,6 @@ if (rtc_include_tests) {
sources = [ "cascaded_biquad_filter_unittest.cc" ]
deps = [
":cascaded_biquad_filter",
"../../../rtc_base:rtc_base_approved",
"../../../test:test_support",
"//testing/gtest",
]
@ -62,7 +61,6 @@ if (rtc_include_tests) {
sources = [ "delay_estimator_unittest.cc" ]
deps = [
":legacy_delay_estimator",
"../../../rtc_base:rtc_base_approved",
"../../../test:test_support",
"//testing/gtest",
]

View File

@ -99,19 +99,28 @@ void CascadedBiQuadFilter::ApplyBiQuad(rtc::ArrayView<const float> x,
rtc::ArrayView<float> y,
CascadedBiQuadFilter::BiQuad* biquad) {
RTC_DCHECK_EQ(x.size(), y.size());
const auto* c_b = biquad->coefficients.b;
const auto* c_a = biquad->coefficients.a;
auto* m_x = biquad->x;
auto* m_y = biquad->y;
const float c_a_0 = biquad->coefficients.a[0];
const float c_a_1 = biquad->coefficients.a[1];
const float c_b_0 = biquad->coefficients.b[0];
const float c_b_1 = biquad->coefficients.b[1];
const float c_b_2 = biquad->coefficients.b[2];
float m_x_0 = biquad->x[0];
float m_x_1 = biquad->x[1];
float m_y_0 = biquad->y[0];
float m_y_1 = biquad->y[1];
for (size_t k = 0; k < x.size(); ++k) {
const float tmp = x[k];
y[k] = c_b[0] * tmp + c_b[1] * m_x[0] + c_b[2] * m_x[1] - c_a[0] * m_y[0] -
c_a[1] * m_y[1];
m_x[1] = m_x[0];
m_x[0] = tmp;
m_y[1] = m_y[0];
m_y[0] = y[k];
y[k] = c_b_0 * tmp + c_b_1 * m_x_0 + c_b_2 * m_x_1 - c_a_0 * m_y_0 -
c_a_1 * m_y_1;
m_x_1 = m_x_0;
m_x_0 = tmp;
m_y_1 = m_y_0;
m_y_0 = y[k];
}
biquad->x[0] = m_x_0;
biquad->x[1] = m_x_1;
biquad->y[0] = m_y_0;
biquad->y[1] = m_y_1;
}
} // namespace webrtc

View File

@ -55,7 +55,7 @@ static int BitCount(uint32_t u32) {
return ((int)tmp);
}
// Compares the |binary_vector| with all rows of the |binary_matrix| and counts
// Compares the `binary_vector` with all rows of the `binary_matrix` and counts
// per row the number of times they have the same value.
//
// Inputs:
@ -74,7 +74,7 @@ static void BitCountComparison(uint32_t binary_vector,
int32_t* bit_counts) {
int n = 0;
// Compare |binary_vector| with all rows of the |binary_matrix|
// Compare `binary_vector` with all rows of the `binary_matrix`
for (; n < matrix_size; n++) {
bit_counts[n] = (int32_t)BitCount(binary_vector ^ binary_matrix[n]);
}
@ -83,9 +83,9 @@ static void BitCountComparison(uint32_t binary_vector,
// Collects necessary statistics for the HistogramBasedValidation(). This
// function has to be called prior to calling HistogramBasedValidation(). The
// statistics updated and used by the HistogramBasedValidation() are:
// 1. the number of |candidate_hits|, which states for how long we have had the
// same |candidate_delay|
// 2. the |histogram| of candidate delays over time. This histogram is
// 1. the number of `candidate_hits`, which states for how long we have had the
// same `candidate_delay`
// 2. the `histogram` of candidate delays over time. This histogram is
// weighted with respect to a reliability measure and time-varying to cope
// with possible delay shifts.
// For further description see commented code.
@ -93,7 +93,7 @@ static void BitCountComparison(uint32_t binary_vector,
// Inputs:
// - candidate_delay : The delay to validate.
// - valley_depth_q14 : The cost function has a valley/minimum at the
// |candidate_delay| location. |valley_depth_q14| is the
// `candidate_delay` location. `valley_depth_q14` is the
// cost function difference between the minimum and
// maximum locations. The value is in the Q14 domain.
// - valley_level_q14 : Is the cost function value at the minimum, in Q14.
@ -109,37 +109,37 @@ static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self,
int i = 0;
RTC_DCHECK_EQ(self->history_size, self->farend->history_size);
// Reset |candidate_hits| if we have a new candidate.
// Reset `candidate_hits` if we have a new candidate.
if (candidate_delay != self->last_candidate_delay) {
self->candidate_hits = 0;
self->last_candidate_delay = candidate_delay;
}
self->candidate_hits++;
// The |histogram| is updated differently across the bins.
// 1. The |candidate_delay| histogram bin is increased with the
// |valley_depth|, which is a simple measure of how reliable the
// |candidate_delay| is. The histogram is not increased above
// |kHistogramMax|.
// The `histogram` is updated differently across the bins.
// 1. The `candidate_delay` histogram bin is increased with the
// `valley_depth`, which is a simple measure of how reliable the
// `candidate_delay` is. The histogram is not increased above
// `kHistogramMax`.
self->histogram[candidate_delay] += valley_depth;
if (self->histogram[candidate_delay] > kHistogramMax) {
self->histogram[candidate_delay] = kHistogramMax;
}
// 2. The histogram bins in the neighborhood of |candidate_delay| are
// 2. The histogram bins in the neighborhood of `candidate_delay` are
// unaffected. The neighborhood is defined as x + {-2, -1, 0, 1}.
// 3. The histogram bins in the neighborhood of |last_delay| are decreased
// with |decrease_in_last_set|. This value equals the difference between
// the cost function values at the locations |candidate_delay| and
// |last_delay| until we reach |max_hits_for_slow_change| consecutive hits
// at the |candidate_delay|. If we exceed this amount of hits the
// |candidate_delay| is a "potential" candidate and we start decreasing
// these histogram bins more rapidly with |valley_depth|.
// 3. The histogram bins in the neighborhood of `last_delay` are decreased
// with `decrease_in_last_set`. This value equals the difference between
// the cost function values at the locations `candidate_delay` and
// `last_delay` until we reach `max_hits_for_slow_change` consecutive hits
// at the `candidate_delay`. If we exceed this amount of hits the
// `candidate_delay` is a "potential" candidate and we start decreasing
// these histogram bins more rapidly with `valley_depth`.
if (self->candidate_hits < max_hits_for_slow_change) {
decrease_in_last_set =
(self->mean_bit_counts[self->compare_delay] - valley_level_q14) *
kQ14Scaling;
}
// 4. All other bins are decreased with |valley_depth|.
// 4. All other bins are decreased with `valley_depth`.
// TODO(bjornv): Investigate how to make this loop more efficient. Split up
// the loop? Remove parts that doesn't add too much.
for (i = 0; i < self->history_size; ++i) {
@ -157,15 +157,15 @@ static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self,
}
}
// Validates the |candidate_delay|, estimated in WebRtc_ProcessBinarySpectrum(),
// Validates the `candidate_delay`, estimated in WebRtc_ProcessBinarySpectrum(),
// based on a mix of counting concurring hits with a modified histogram
// of recent delay estimates. In brief a candidate is valid (returns 1) if it
// is the most likely according to the histogram. There are a couple of
// exceptions that are worth mentioning:
// 1. If the |candidate_delay| < |last_delay| it can be that we are in a
// 1. If the `candidate_delay` < `last_delay` it can be that we are in a
// non-causal state, breaking a possible echo control algorithm. Hence, we
// open up for a quicker change by allowing the change even if the
// |candidate_delay| is not the most likely one according to the histogram.
// `candidate_delay` is not the most likely one according to the histogram.
// 2. There's a minimum number of hits (kMinRequiredHits) and the histogram
// value has to reached a minimum (kMinHistogramThreshold) to be valid.
// 3. The action is also depending on the filter length used for echo control.
@ -177,7 +177,7 @@ static void UpdateRobustValidationStatistics(BinaryDelayEstimator* self,
// - candidate_delay : The delay to validate.
//
// Return value:
// - is_histogram_valid : 1 - The |candidate_delay| is valid.
// - is_histogram_valid : 1 - The `candidate_delay` is valid.
// 0 - Otherwise.
static int HistogramBasedValidation(const BinaryDelayEstimator* self,
int candidate_delay) {
@ -186,22 +186,22 @@ static int HistogramBasedValidation(const BinaryDelayEstimator* self,
const int delay_difference = candidate_delay - self->last_delay;
int is_histogram_valid = 0;
// The histogram based validation of |candidate_delay| is done by comparing
// the |histogram| at bin |candidate_delay| with a |histogram_threshold|.
// This |histogram_threshold| equals a |fraction| of the |histogram| at bin
// |last_delay|. The |fraction| is a piecewise linear function of the
// |delay_difference| between the |candidate_delay| and the |last_delay|
// The histogram based validation of `candidate_delay` is done by comparing
// the `histogram` at bin `candidate_delay` with a `histogram_threshold`.
// This `histogram_threshold` equals a `fraction` of the `histogram` at bin
// `last_delay`. The `fraction` is a piecewise linear function of the
// `delay_difference` between the `candidate_delay` and the `last_delay`
// allowing for a quicker move if
// i) a potential echo control filter can not handle these large differences.
// ii) keeping |last_delay| instead of updating to |candidate_delay| could
// ii) keeping `last_delay` instead of updating to `candidate_delay` could
// force an echo control into a non-causal state.
// We further require the histogram to have reached a minimum value of
// |kMinHistogramThreshold|. In addition, we also require the number of
// |candidate_hits| to be more than |kMinRequiredHits| to remove spurious
// `kMinHistogramThreshold`. In addition, we also require the number of
// `candidate_hits` to be more than `kMinRequiredHits` to remove spurious
// values.
// Calculate a comparison histogram value (|histogram_threshold|) that is
// depending on the distance between the |candidate_delay| and |last_delay|.
// Calculate a comparison histogram value (`histogram_threshold`) that is
// depending on the distance between the `candidate_delay` and `last_delay`.
// TODO(bjornv): How much can we gain by turning the fraction calculation
// into tables?
if (delay_difference > self->allowed_offset) {
@ -226,9 +226,9 @@ static int HistogramBasedValidation(const BinaryDelayEstimator* self,
return is_histogram_valid;
}
// Performs a robust validation of the |candidate_delay| estimated in
// Performs a robust validation of the `candidate_delay` estimated in
// WebRtc_ProcessBinarySpectrum(). The algorithm takes the
// |is_instantaneous_valid| and the |is_histogram_valid| and combines them
// `is_instantaneous_valid` and the `is_histogram_valid` and combines them
// into a robust validation. The HistogramBasedValidation() has to be called
// prior to this call.
// For further description on how the combination is done, see commented code.
@ -250,18 +250,18 @@ static int RobustValidation(const BinaryDelayEstimator* self,
int is_robust = 0;
// The final robust validation is based on the two algorithms; 1) the
// |is_instantaneous_valid| and 2) the histogram based with result stored in
// |is_histogram_valid|.
// i) Before we actually have a valid estimate (|last_delay| == -2), we say
// `is_instantaneous_valid` and 2) the histogram based with result stored in
// `is_histogram_valid`.
// i) Before we actually have a valid estimate (`last_delay` == -2), we say
// a candidate is valid if either algorithm states so
// (|is_instantaneous_valid| OR |is_histogram_valid|).
// (`is_instantaneous_valid` OR `is_histogram_valid`).
is_robust =
(self->last_delay < 0) && (is_instantaneous_valid || is_histogram_valid);
// ii) Otherwise, we need both algorithms to be certain
// (|is_instantaneous_valid| AND |is_histogram_valid|)
// (`is_instantaneous_valid` AND `is_histogram_valid`)
is_robust |= is_instantaneous_valid && is_histogram_valid;
// iii) With one exception, i.e., the histogram based algorithm can overrule
// the instantaneous one if |is_histogram_valid| = 1 and the histogram
// the instantaneous one if `is_histogram_valid` = 1 and the histogram
// is significantly strong.
is_robust |= is_histogram_valid &&
(self->histogram[candidate_delay] > self->last_delay_histogram);
@ -373,13 +373,13 @@ void WebRtc_SoftResetBinaryDelayEstimatorFarend(
void WebRtc_AddBinaryFarSpectrum(BinaryDelayEstimatorFarend* handle,
uint32_t binary_far_spectrum) {
RTC_DCHECK(handle);
// Shift binary spectrum history and insert current |binary_far_spectrum|.
// Shift binary spectrum history and insert current `binary_far_spectrum`.
memmove(&(handle->binary_far_history[1]), &(handle->binary_far_history[0]),
(handle->history_size - 1) * sizeof(uint32_t));
handle->binary_far_history[0] = binary_far_spectrum;
// Shift history of far-end binary spectrum bit counts and insert bit count
// of current |binary_far_spectrum|.
// of current `binary_far_spectrum`.
memmove(&(handle->far_bit_counts[1]), &(handle->far_bit_counts[0]),
(handle->history_size - 1) * sizeof(int));
handle->far_bit_counts[0] = BitCount(binary_far_spectrum);
@ -402,7 +402,7 @@ void WebRtc_FreeBinaryDelayEstimator(BinaryDelayEstimator* self) {
free(self->histogram);
self->histogram = NULL;
// BinaryDelayEstimator does not have ownership of |farend|, hence we do not
// BinaryDelayEstimator does not have ownership of `farend`, hence we do not
// free the memory here. That should be handled separately by the user.
self->farend = NULL;
@ -454,8 +454,8 @@ int WebRtc_AllocateHistoryBufferMemory(BinaryDelayEstimator* self,
// Only update far-end buffers if we need.
history_size = WebRtc_AllocateFarendBufferMemory(far, history_size);
}
// The extra array element in |mean_bit_counts| and |histogram| is a dummy
// element only used while |last_delay| == -2, i.e., before we have a valid
// The extra array element in `mean_bit_counts` and `histogram` is a dummy
// element only used while `last_delay` == -2, i.e., before we have a valid
// estimate.
self->mean_bit_counts = static_cast<int32_t*>(
realloc(self->mean_bit_counts,
@ -539,36 +539,36 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
}
if (self->near_history_size > 1) {
// If we apply lookahead, shift near-end binary spectrum history. Insert
// current |binary_near_spectrum| and pull out the delayed one.
// current `binary_near_spectrum` and pull out the delayed one.
memmove(&(self->binary_near_history[1]), &(self->binary_near_history[0]),
(self->near_history_size - 1) * sizeof(uint32_t));
self->binary_near_history[0] = binary_near_spectrum;
binary_near_spectrum = self->binary_near_history[self->lookahead];
}
// Compare with delayed spectra and store the |bit_counts| for each delay.
// Compare with delayed spectra and store the `bit_counts` for each delay.
BitCountComparison(binary_near_spectrum, self->farend->binary_far_history,
self->history_size, self->bit_counts);
// Update |mean_bit_counts|, which is the smoothed version of |bit_counts|.
// Update `mean_bit_counts`, which is the smoothed version of `bit_counts`.
for (i = 0; i < self->history_size; i++) {
// |bit_counts| is constrained to [0, 32], meaning we can smooth with a
// `bit_counts` is constrained to [0, 32], meaning we can smooth with a
// factor up to 2^26. We use Q9.
int32_t bit_count = (self->bit_counts[i] << 9); // Q9.
// Update |mean_bit_counts| only when far-end signal has something to
// contribute. If |far_bit_counts| is zero the far-end signal is weak and
// Update `mean_bit_counts` only when far-end signal has something to
// contribute. If `far_bit_counts` is zero the far-end signal is weak and
// we likely have a poor echo condition, hence don't update.
if (self->farend->far_bit_counts[i] > 0) {
// Make number of right shifts piecewise linear w.r.t. |far_bit_counts|.
// Make number of right shifts piecewise linear w.r.t. `far_bit_counts`.
int shifts = kShiftsAtZero;
shifts -= (kShiftsLinearSlope * self->farend->far_bit_counts[i]) >> 4;
WebRtc_MeanEstimatorFix(bit_count, shifts, &(self->mean_bit_counts[i]));
}
}
// Find |candidate_delay|, |value_best_candidate| and |value_worst_candidate|
// of |mean_bit_counts|.
// Find `candidate_delay`, `value_best_candidate` and `value_worst_candidate`
// of `mean_bit_counts`.
for (i = 0; i < self->history_size; i++) {
if (self->mean_bit_counts[i] < value_best_candidate) {
value_best_candidate = self->mean_bit_counts[i];
@ -580,25 +580,25 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
}
valley_depth = value_worst_candidate - value_best_candidate;
// The |value_best_candidate| is a good indicator on the probability of
// |candidate_delay| being an accurate delay (a small |value_best_candidate|
// The `value_best_candidate` is a good indicator on the probability of
// `candidate_delay` being an accurate delay (a small `value_best_candidate`
// means a good binary match). In the following sections we make a decision
// whether to update |last_delay| or not.
// whether to update `last_delay` or not.
// 1) If the difference bit counts between the best and the worst delay
// candidates is too small we consider the situation to be unreliable and
// don't update |last_delay|.
// 2) If the situation is reliable we update |last_delay| if the value of the
// don't update `last_delay`.
// 2) If the situation is reliable we update `last_delay` if the value of the
// best candidate delay has a value less than
// i) an adaptive threshold |minimum_probability|, or
// ii) this corresponding value |last_delay_probability|, but updated at
// i) an adaptive threshold `minimum_probability`, or
// ii) this corresponding value `last_delay_probability`, but updated at
// this time instant.
// Update |minimum_probability|.
// Update `minimum_probability`.
if ((self->minimum_probability > kProbabilityLowerLimit) &&
(valley_depth > kProbabilityMinSpread)) {
// The "hard" threshold can't be lower than 17 (in Q9).
// The valley in the curve also has to be distinct, i.e., the
// difference between |value_worst_candidate| and |value_best_candidate| has
// difference between `value_worst_candidate` and `value_best_candidate` has
// to be large enough.
int32_t threshold = value_best_candidate + kProbabilityOffset;
if (threshold < kProbabilityLowerLimit) {
@ -608,17 +608,17 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
self->minimum_probability = threshold;
}
}
// Update |last_delay_probability|.
// Update `last_delay_probability`.
// We use a Markov type model, i.e., a slowly increasing level over time.
self->last_delay_probability++;
// Validate |candidate_delay|. We have a reliable instantaneous delay
// Validate `candidate_delay`. We have a reliable instantaneous delay
// estimate if
// 1) The valley is distinct enough (|valley_depth| > |kProbabilityOffset|)
// 1) The valley is distinct enough (`valley_depth` > `kProbabilityOffset`)
// and
// 2) The depth of the valley is deep enough
// (|value_best_candidate| < |minimum_probability|)
// (`value_best_candidate` < `minimum_probability`)
// and deeper than the best estimate so far
// (|value_best_candidate| < |last_delay_probability|)
// (`value_best_candidate` < `last_delay_probability`)
valid_candidate = ((valley_depth > kProbabilityOffset) &&
((value_best_candidate < self->minimum_probability) ||
(value_best_candidate < self->last_delay_probability)));
@ -650,7 +650,7 @@ int WebRtc_ProcessBinarySpectrum(BinaryDelayEstimator* self,
(self->histogram[candidate_delay] > kLastHistogramMax
? kLastHistogramMax
: self->histogram[candidate_delay]);
// Adjust the histogram if we made a change to |last_delay|, though it was
// Adjust the histogram if we made a change to `last_delay`, though it was
// not the most likely one according to the histogram.
if (self->histogram[candidate_delay] <
self->histogram[self->compare_delay]) {
@ -680,7 +680,7 @@ float WebRtc_binary_last_delay_quality(BinaryDelayEstimator* self) {
// Simply a linear function of the histogram height at delay estimate.
quality = self->histogram[self->compare_delay] / kHistogramMax;
} else {
// Note that |last_delay_probability| states how deep the minimum of the
// Note that `last_delay_probability` states how deep the minimum of the
// cost function is, so it is rather an error probability.
quality = (float)(kMaxBitCountsQ9 - self->last_delay_probability) /
kMaxBitCountsQ9;

View File

@ -81,7 +81,7 @@ void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self);
//
// Return value:
// - BinaryDelayEstimatorFarend*
// : Created |handle|. If the memory can't be allocated
// : Created `handle`. If the memory can't be allocated
// or if any of the input parameters are invalid NULL
// is returned.
//
@ -159,7 +159,7 @@ BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
BinaryDelayEstimatorFarend* farend,
int max_lookahead);
// Re-allocates |history_size| dependent buffers. The far-end buffers will be
// Re-allocates `history_size` dependent buffers. The far-end buffers will be
// updated at the same time if needed.
//
// Input:
@ -237,7 +237,7 @@ int WebRtc_binary_last_delay(BinaryDelayEstimator* self);
// delay value.
float WebRtc_binary_last_delay_quality(BinaryDelayEstimator* self);
// Updates the |mean_value| recursively with a step size of 2^-|factor|. This
// Updates the `mean_value` recursively with a step size of 2^-`factor`. This
// function is used internally in the Binary Delay Estimator as well as the
// Fixed point wrapper.
//

View File

@ -25,7 +25,7 @@ typedef union {
typedef struct {
// Pointers to mean values of spectrum.
SpectrumType* mean_far_spectrum;
// |mean_far_spectrum| initialization indicator.
// `mean_far_spectrum` initialization indicator.
int far_spectrum_initialized;
int spectrum_size;
@ -37,7 +37,7 @@ typedef struct {
typedef struct {
// Pointers to mean values of spectrum.
SpectrumType* mean_near_spectrum;
// |mean_near_spectrum| initialization indicator.
// `mean_near_spectrum` initialization indicator.
int near_spectrum_initialized;
int spectrum_size;

View File

@ -19,10 +19,10 @@
namespace webrtc {
// Only bit |kBandFirst| through bit |kBandLast| are processed and
// |kBandFirst| - |kBandLast| must be < 32.
enum { kBandFirst = 12 };
enum { kBandLast = 43 };
// Only bit `kBandFirst` through bit `kBandLast` are processed and
// `kBandFirst` - `kBandLast` must be < 32.
constexpr int kBandFirst = 12;
constexpr int kBandLast = 43;
static __inline uint32_t SetBit(uint32_t in, int pos) {
uint32_t mask = (1 << pos);
@ -48,8 +48,8 @@ static void MeanEstimatorFloat(float new_value,
*mean_value += (new_value - *mean_value) * scale;
}
// Computes the binary spectrum by comparing the input |spectrum| with a
// |threshold_spectrum|. Float and fixed point versions.
// Computes the binary spectrum by comparing the input `spectrum` with a
// `threshold_spectrum`. Float and fixed point versions.
//
// Inputs:
// - spectrum : Spectrum of which the binary spectrum should be
@ -69,11 +69,11 @@ static uint32_t BinarySpectrumFix(const uint16_t* spectrum,
RTC_DCHECK_LT(q_domain, 16);
if (!(*threshold_initialized)) {
// Set the |threshold_spectrum| to half the input |spectrum| as starting
// Set the `threshold_spectrum` to half the input `spectrum` as starting
// value. This speeds up the convergence.
for (i = kBandFirst; i <= kBandLast; i++) {
if (spectrum[i] > 0) {
// Convert input spectrum from Q(|q_domain|) to Q15.
// Convert input spectrum from Q(`q_domain`) to Q15.
int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain);
threshold_spectrum[i].int32_ = (spectrum_q15 >> 1);
*threshold_initialized = 1;
@ -81,11 +81,11 @@ static uint32_t BinarySpectrumFix(const uint16_t* spectrum,
}
}
for (i = kBandFirst; i <= kBandLast; i++) {
// Convert input spectrum from Q(|q_domain|) to Q15.
// Convert input spectrum from Q(`q_domain`) to Q15.
int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain);
// Update the |threshold_spectrum|.
// Update the `threshold_spectrum`.
WebRtc_MeanEstimatorFix(spectrum_q15, 6, &(threshold_spectrum[i].int32_));
// Convert |spectrum| at current frequency bin to a binary value.
// Convert `spectrum` at current frequency bin to a binary value.
if (spectrum_q15 > threshold_spectrum[i].int32_) {
out = SetBit(out, i - kBandFirst);
}
@ -102,7 +102,7 @@ static uint32_t BinarySpectrumFloat(const float* spectrum,
const float kScale = 1 / 64.0;
if (!(*threshold_initialized)) {
// Set the |threshold_spectrum| to half the input |spectrum| as starting
// Set the `threshold_spectrum` to half the input `spectrum` as starting
// value. This speeds up the convergence.
for (i = kBandFirst; i <= kBandLast; i++) {
if (spectrum[i] > 0.0f) {
@ -113,9 +113,9 @@ static uint32_t BinarySpectrumFloat(const float* spectrum,
}
for (i = kBandFirst; i <= kBandLast; i++) {
// Update the |threshold_spectrum|.
// Update the `threshold_spectrum`.
MeanEstimatorFloat(spectrum[i], kScale, &(threshold_spectrum[i].float_));
// Convert |spectrum| at current frequency bin to a binary value.
// Convert `spectrum` at current frequency bin to a binary value.
if (spectrum[i] > threshold_spectrum[i].float_) {
out = SetBit(out, i - kBandFirst);
}
@ -219,7 +219,7 @@ int WebRtc_AddFarSpectrumFix(void* handle,
return -1;
}
if (far_q > 15) {
// If |far_q| is larger than 15 we cannot guarantee no wrap around.
// If `far_q` is larger than 15 we cannot guarantee no wrap around.
return -1;
}
@ -433,7 +433,7 @@ int WebRtc_DelayEstimatorProcessFix(void* handle,
return -1;
}
if (near_q > 15) {
// If |near_q| is larger than 15 we cannot guarantee no wrap around.
// If `near_q` is larger than 15 we cannot guarantee no wrap around.
return -1;
}

View File

@ -35,7 +35,7 @@ void WebRtc_FreeDelayEstimatorFarend(void* handle);
// determined together with WebRtc_set_lookahead().
//
// Return value:
// - void* : Created |handle|. If the memory can't be allocated or
// - void* : Created `handle`. If the memory can't be allocated or
// if any of the input parameters are invalid NULL is
// returned.
void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size);
@ -85,13 +85,13 @@ void WebRtc_FreeDelayEstimator(void* handle);
// WebRtc_CreateDelayEstimatorFarend().
//
// Note that WebRtc_CreateDelayEstimator does not take
// ownership of |farend_handle|, which has to be torn
// ownership of `farend_handle`, which has to be torn
// down properly after this instance.
//
// - max_lookahead : Maximum amount of non-causal lookahead allowed. The
// actual amount of lookahead used can be controlled by
// WebRtc_set_lookahead(...). The default |lookahead| is
// set to |max_lookahead| at create time. Use
// WebRtc_set_lookahead(...). The default `lookahead` is
// set to `max_lookahead` at create time. Use
// WebRtc_set_lookahead(...) before start if a different
// value is desired.
//
@ -106,12 +106,12 @@ void WebRtc_FreeDelayEstimator(void* handle);
// estimated.
//
// Note that the effective range of delay estimates is
// [-|lookahead|,... ,|history_size|-|lookahead|)
// where |history_size| is set through
// [-`lookahead`,... ,`history_size`-`lookahead`)
// where `history_size` is set through
// WebRtc_set_history_size().
//
// Return value:
// - void* : Created |handle|. If the memory can't be allocated or
// - void* : Created `handle`. If the memory can't be allocated or
// if any of the input parameters are invalid NULL is
// returned.
void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead);
@ -129,12 +129,12 @@ int WebRtc_InitDelayEstimator(void* handle);
// - actual_shifts : The actual number of shifts performed.
int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift);
// Sets the effective |history_size| used. Valid values from 2. We simply need
// at least two delays to compare to perform an estimate. If |history_size| is
// Sets the effective `history_size` used. Valid values from 2. We simply need
// at least two delays to compare to perform an estimate. If `history_size` is
// changed, buffers are reallocated filling in with zeros if necessary.
// Note that changing the |history_size| affects both buffers in far-end and
// Note that changing the `history_size` affects both buffers in far-end and
// near-end. Hence it is important to change all DelayEstimators that use the
// same reference far-end, to the same |history_size| value.
// same reference far-end, to the same `history_size` value.
// Inputs:
// - handle : Pointer to the delay estimation instance.
// - history_size : Effective history size to be used.
@ -148,8 +148,8 @@ int WebRtc_set_history_size(void* handle, int history_size);
// - handle : Pointer to the delay estimation instance.
int WebRtc_history_size(const void* handle);
// Sets the amount of |lookahead| to use. Valid values are [0, max_lookahead]
// where |max_lookahead| was set at create time through
// Sets the amount of `lookahead` to use. Valid values are [0, max_lookahead]
// where `max_lookahead` was set at create time through
// WebRtc_CreateDelayEstimator(...).
//
// Input:
@ -157,8 +157,8 @@ int WebRtc_history_size(const void* handle);
// - lookahead : The amount of lookahead to be used.
//
// Return value:
// - new_lookahead : The actual amount of lookahead set, unless |handle| is
// a NULL pointer or |lookahead| is invalid, for which an
// - new_lookahead : The actual amount of lookahead set, unless `handle` is
// a NULL pointer or `lookahead` is invalid, for which an
// error is returned.
int WebRtc_set_lookahead(void* handle, int lookahead);
@ -167,12 +167,12 @@ int WebRtc_set_lookahead(void* handle, int lookahead);
// - handle : Pointer to the delay estimation instance.
int WebRtc_lookahead(void* handle);
// Sets the |allowed_offset| used in the robust validation scheme. If the
// Sets the `allowed_offset` used in the robust validation scheme. If the
// delay estimator is used in an echo control component, this parameter is
// related to the filter length. In principle |allowed_offset| should be set to
// related to the filter length. In principle `allowed_offset` should be set to
// the echo control filter length minus the expected echo duration, i.e., the
// delay offset the echo control can handle without quality regression. The
// default value, used if not set manually, is zero. Note that |allowed_offset|
// default value, used if not set manually, is zero. Note that `allowed_offset`
// has to be non-negative.
// Inputs:
// - handle : Pointer to the delay estimation instance.
@ -180,7 +180,7 @@ int WebRtc_lookahead(void* handle);
// the echo control filter can handle.
int WebRtc_set_allowed_offset(void* handle, int allowed_offset);
// Returns the |allowed_offset| in number of partitions.
// Returns the `allowed_offset` in number of partitions.
int WebRtc_get_allowed_offset(const void* handle);
// Enables/Disables a robust validation functionality in the delay estimation.

View File

@ -51,7 +51,7 @@ class Pffft {
// TODO(https://crbug.com/webrtc/9577): Consider adding a factory and making
// the ctor private.
// static std::unique_ptr<Pffft> Create(size_t fft_size,
// FftType fft_type); Ctor. |fft_size| must be a supported size (see
// FftType fft_type); Ctor. `fft_size` must be a supported size (see
// Pffft::IsValidFftSize()). If not supported, the code will crash.
Pffft(size_t fft_size, FftType fft_type);
Pffft(const Pffft&) = delete;
@ -73,9 +73,9 @@ class Pffft {
// Computes the backward fast Fourier transform.
void BackwardTransform(const FloatBuffer& in, FloatBuffer* out, bool ordered);
// Multiplies the frequency components of |fft_x| and |fft_y| and accumulates
// them into |out|. The arrays must have been obtained with
// ForwardTransform(..., /*ordered=*/false) - i.e., |fft_x| and |fft_y| must
// Multiplies the frequency components of `fft_x` and `fft_y` and accumulates
// them into `out`. The arrays must have been obtained with
// ForwardTransform(..., /*ordered=*/false) - i.e., `fft_x` and `fft_y` must
// not be ordered.
void FrequencyDomainConvolve(const FloatBuffer& fft_x,
const FloatBuffer& fft_y,