Use backticks not vertical bars to denote variables in comments for /modules/audio_processing

Bug: webrtc:12338
Change-Id: I85bff694dd2ead83c939c4d1945eff82e1296001
No-Presubmit: True
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/227161
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34690}
This commit is contained in:
Artem Titov 2021-07-28 20:50:03 +02:00 committed by WebRTC LUCI CQ
parent dc6801c618
commit 0b489303d2
102 changed files with 483 additions and 483 deletions

View file

@ -26,10 +26,10 @@ namespace webrtc {
class RTC_EXPORT AecDumpFactory { class RTC_EXPORT AecDumpFactory {
public: public:
// The |worker_queue| may not be null and must outlive the created // The `worker_queue` may not be null and must outlive the created
// AecDump instance. |max_log_size_bytes == -1| means the log size // AecDump instance. |max_log_size_bytes == -1| means the log size
// will be unlimited. |handle| may not be null. The AecDump takes // will be unlimited. `handle` may not be null. The AecDump takes
// responsibility for |handle| and closes it in the destructor. A // responsibility for `handle` and closes it in the destructor. A
// non-null return value indicates that the file has been // non-null return value indicates that the file has been
// sucessfully opened. // sucessfully opened.
static std::unique_ptr<AecDump> Create(webrtc::FileWrapper file, static std::unique_ptr<AecDump> Create(webrtc::FileWrapper file,

View file

@ -124,7 +124,7 @@ const int16_t WebRtcAecm_kSinTable[] = {
-1140, -998, -856, -713, -571, -428, -285, -142}; -1140, -998, -856, -713, -571, -428, -285, -142};
// Moves the pointer to the next entry and inserts |far_spectrum| and // Moves the pointer to the next entry and inserts `far_spectrum` and
// corresponding Q-domain in its buffer. // corresponding Q-domain in its buffer.
// //
// Inputs: // Inputs:
@ -574,7 +574,7 @@ int WebRtcAecm_ProcessFrame(AecmCore* aecm,
// Obtain an output frame. // Obtain an output frame.
WebRtc_ReadBuffer(aecm->outFrameBuf, (void**)&out_ptr, out, FRAME_LEN); WebRtc_ReadBuffer(aecm->outFrameBuf, (void**)&out_ptr, out, FRAME_LEN);
if (out_ptr != out) { if (out_ptr != out) {
// ReadBuffer() hasn't copied to |out| in this case. // ReadBuffer() hasn't copied to `out` in this case.
memcpy(out, out_ptr, FRAME_LEN * sizeof(int16_t)); memcpy(out, out_ptr, FRAME_LEN * sizeof(int16_t));
} }
@ -616,22 +616,22 @@ int16_t WebRtcAecm_AsymFilt(const int16_t filtOld,
// ExtractFractionPart(a, zeros) // ExtractFractionPart(a, zeros)
// //
// returns the fraction part of |a|, with |zeros| number of leading zeros, as an // returns the fraction part of `a`, with `zeros` number of leading zeros, as an
// int16_t scaled to Q8. There is no sanity check of |a| in the sense that the // int16_t scaled to Q8. There is no sanity check of `a` in the sense that the
// number of zeros match. // number of zeros match.
static int16_t ExtractFractionPart(uint32_t a, int zeros) { static int16_t ExtractFractionPart(uint32_t a, int zeros) {
return (int16_t)(((a << zeros) & 0x7FFFFFFF) >> 23); return (int16_t)(((a << zeros) & 0x7FFFFFFF) >> 23);
} }
// Calculates and returns the log of |energy| in Q8. The input |energy| is // Calculates and returns the log of `energy` in Q8. The input `energy` is
// supposed to be in Q(|q_domain|). // supposed to be in Q(`q_domain`).
static int16_t LogOfEnergyInQ8(uint32_t energy, int q_domain) { static int16_t LogOfEnergyInQ8(uint32_t energy, int q_domain) {
static const int16_t kLogLowValue = PART_LEN_SHIFT << 7; static const int16_t kLogLowValue = PART_LEN_SHIFT << 7;
int16_t log_energy_q8 = kLogLowValue; int16_t log_energy_q8 = kLogLowValue;
if (energy > 0) { if (energy > 0) {
int zeros = WebRtcSpl_NormU32(energy); int zeros = WebRtcSpl_NormU32(energy);
int16_t frac = ExtractFractionPart(energy, zeros); int16_t frac = ExtractFractionPart(energy, zeros);
// log2 of |energy| in Q8. // log2 of `energy` in Q8.
log_energy_q8 += ((31 - zeros) << 8) + frac - (q_domain << 8); log_energy_q8 += ((31 - zeros) << 8) + frac - (q_domain << 8);
} }
return log_energy_q8; return log_energy_q8;

View file

@ -58,7 +58,7 @@ typedef struct {
void* delay_estimator; void* delay_estimator;
uint16_t currentDelay; uint16_t currentDelay;
// Far end history variables // Far end history variables
// TODO(bjornv): Replace |far_history| with ring_buffer. // TODO(bjornv): Replace `far_history` with ring_buffer.
uint16_t far_history[PART_LEN1 * MAX_DELAY]; uint16_t far_history[PART_LEN1 * MAX_DELAY];
int far_history_pos; int far_history_pos;
int far_q_domains[MAX_DELAY]; int far_q_domains[MAX_DELAY];
@ -271,7 +271,7 @@ void WebRtcAecm_FetchFarFrame(AecmCore* const aecm,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// WebRtcAecm_UpdateFarHistory() // WebRtcAecm_UpdateFarHistory()
// //
// Moves the pointer to the next entry and inserts |far_spectrum| and // Moves the pointer to the next entry and inserts `far_spectrum` and
// corresponding Q-domain in its buffer. // corresponding Q-domain in its buffer.
// //
// Inputs: // Inputs:

View file

@ -98,7 +98,7 @@ static void ComfortNoise(AecmCore* aecm,
// Track the minimum. // Track the minimum.
if (aecm->noiseEst[i] < (1 << minTrackShift)) { if (aecm->noiseEst[i] < (1 << minTrackShift)) {
// For small values, decrease noiseEst[i] every // For small values, decrease noiseEst[i] every
// |kNoiseEstIncCount| block. The regular approach below can not // `kNoiseEstIncCount` block. The regular approach below can not
// go further down due to truncation. // go further down due to truncation.
aecm->noiseEstTooHighCtr[i]++; aecm->noiseEstTooHighCtr[i]++;
if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) { if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) {
@ -125,7 +125,7 @@ static void ComfortNoise(AecmCore* aecm,
aecm->noiseEst[i] >>= 11; aecm->noiseEst[i] >>= 11;
} else { } else {
// Make incremental increases based on size every // Make incremental increases based on size every
// |kNoiseEstIncCount| block // `kNoiseEstIncCount` block
aecm->noiseEstTooLowCtr[i]++; aecm->noiseEstTooLowCtr[i]++;
if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) { if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) {
aecm->noiseEst[i] += (aecm->noiseEst[i] >> 9) + 1; aecm->noiseEst[i] += (aecm->noiseEst[i] >> 9) + 1;
@ -181,7 +181,7 @@ static void WindowAndFFT(AecmCore* aecm,
// FFT of signal // FFT of signal
for (i = 0; i < PART_LEN; i++) { for (i = 0; i < PART_LEN; i++) {
// Window time domain signal and insert into real part of // Window time domain signal and insert into real part of
// transformation array |fft| // transformation array `fft`
int16_t scaled_time_signal = time_signal[i] * (1 << time_signal_scaling); int16_t scaled_time_signal = time_signal[i] * (1 << time_signal_scaling);
fft[i] = (int16_t)((scaled_time_signal * WebRtcAecm_kSqrtHanning[i]) >> 14); fft[i] = (int16_t)((scaled_time_signal * WebRtcAecm_kSqrtHanning[i]) >> 14);
scaled_time_signal = time_signal[i + PART_LEN] * (1 << time_signal_scaling); scaled_time_signal = time_signal[i + PART_LEN] * (1 << time_signal_scaling);
@ -204,8 +204,8 @@ static void InverseFFTAndWindow(AecmCore* aecm,
const int16_t* nearendClean) { const int16_t* nearendClean) {
int i, j, outCFFT; int i, j, outCFFT;
int32_t tmp32no1; int32_t tmp32no1;
// Reuse |efw| for the inverse FFT output after transferring // Reuse `efw` for the inverse FFT output after transferring
// the contents to |fft|. // the contents to `fft`.
int16_t* ifft_out = (int16_t*)efw; int16_t* ifft_out = (int16_t*)efw;
// Synthesis // Synthesis
@ -312,7 +312,7 @@ static int TimeToFrequencyDomain(AecmCore* aecm,
} else { } else {
// Approximation for magnitude of complex fft output // Approximation for magnitude of complex fft output
// magn = sqrt(real^2 + imag^2) // magn = sqrt(real^2 + imag^2)
// magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|) // magn ~= alpha * max(`imag`,`real`) + beta * min(`imag`,`real`)
// //
// The parameters alpha and beta are stored in Q15 // The parameters alpha and beta are stored in Q15
@ -541,7 +541,7 @@ int RTC_NO_SANITIZE("signed-integer-overflow") // bugs.webrtc.org/8200
} }
zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]); zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]);
RTC_DCHECK_GE(zeros16, 0); // |zeros16| is a norm, hence non-negative. RTC_DCHECK_GE(zeros16, 0); // `zeros16` is a norm, hence non-negative.
dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld; dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld;
if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) { if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) {
tmp16no1 = aecm->nearFilt[i] * (1 << zeros16); tmp16no1 = aecm->nearFilt[i] * (1 << zeros16);

View file

@ -822,7 +822,7 @@ static int TimeToFrequencyDomain(AecmCore* aecm,
} else { } else {
// Approximation for magnitude of complex fft output // Approximation for magnitude of complex fft output
// magn = sqrt(real^2 + imag^2) // magn = sqrt(real^2 + imag^2)
// magn ~= alpha * max(|imag|,|real|) + beta * min(|imag|,|real|) // magn ~= alpha * max(`imag`,`real`) + beta * min(`imag`,`real`)
// //
// The parameters alpha and beta are stored in Q15 // The parameters alpha and beta are stored in Q15
tmp16no1 = WEBRTC_SPL_ABS_W16(freq_signal[i].real); tmp16no1 = WEBRTC_SPL_ABS_W16(freq_signal[i].real);
@ -1106,7 +1106,7 @@ int WebRtcAecm_ProcessBlock(AecmCore* aecm,
} }
zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]); zeros16 = WebRtcSpl_NormW16(aecm->nearFilt[i]);
RTC_DCHECK_GE(zeros16, 0); // |zeros16| is a norm, hence non-negative. RTC_DCHECK_GE(zeros16, 0); // `zeros16` is a norm, hence non-negative.
dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld; dfa_clean_q_domain_diff = aecm->dfaCleanQDomain - aecm->dfaCleanQDomainOld;
if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) { if (zeros16 < dfa_clean_q_domain_diff && aecm->nearFilt[i]) {
tmp16no1 = aecm->nearFilt[i] << zeros16; tmp16no1 = aecm->nearFilt[i] << zeros16;
@ -1411,7 +1411,7 @@ static void ComfortNoise(AecmCore* aecm,
// Track the minimum. // Track the minimum.
if (tnoise < (1 << minTrackShift)) { if (tnoise < (1 << minTrackShift)) {
// For small values, decrease noiseEst[i] every // For small values, decrease noiseEst[i] every
// |kNoiseEstIncCount| block. The regular approach below can not // `kNoiseEstIncCount` block. The regular approach below can not
// go further down due to truncation. // go further down due to truncation.
aecm->noiseEstTooHighCtr[i]++; aecm->noiseEstTooHighCtr[i]++;
if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) { if (aecm->noiseEstTooHighCtr[i] >= kNoiseEstIncCount) {
@ -1442,7 +1442,7 @@ static void ComfortNoise(AecmCore* aecm,
: "hi", "lo"); : "hi", "lo");
} else { } else {
// Make incremental increases based on size every // Make incremental increases based on size every
// |kNoiseEstIncCount| block // `kNoiseEstIncCount` block
aecm->noiseEstTooLowCtr[i]++; aecm->noiseEstTooLowCtr[i]++;
if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) { if (aecm->noiseEstTooLowCtr[i] >= kNoiseEstIncCount) {
__asm __volatile( __asm __volatile(
@ -1484,7 +1484,7 @@ static void ComfortNoise(AecmCore* aecm,
// Track the minimum. // Track the minimum.
if (tnoise1 < (1 << minTrackShift)) { if (tnoise1 < (1 << minTrackShift)) {
// For small values, decrease noiseEst[i] every // For small values, decrease noiseEst[i] every
// |kNoiseEstIncCount| block. The regular approach below can not // `kNoiseEstIncCount` block. The regular approach below can not
// go further down due to truncation. // go further down due to truncation.
aecm->noiseEstTooHighCtr[i + 1]++; aecm->noiseEstTooHighCtr[i + 1]++;
if (aecm->noiseEstTooHighCtr[i + 1] >= kNoiseEstIncCount) { if (aecm->noiseEstTooHighCtr[i + 1] >= kNoiseEstIncCount) {
@ -1515,7 +1515,7 @@ static void ComfortNoise(AecmCore* aecm,
: "hi", "lo"); : "hi", "lo");
} else { } else {
// Make incremental increases based on size every // Make incremental increases based on size every
// |kNoiseEstIncCount| block // `kNoiseEstIncCount` block
aecm->noiseEstTooLowCtr[i + 1]++; aecm->noiseEstTooLowCtr[i + 1]++;
if (aecm->noiseEstTooLowCtr[i + 1] >= kNoiseEstIncCount) { if (aecm->noiseEstTooLowCtr[i + 1] >= kNoiseEstIncCount) {
__asm __volatile( __asm __volatile(

View file

@ -24,13 +24,13 @@ class Agc {
Agc(); Agc();
virtual ~Agc(); virtual ~Agc();
// |audio| must be mono; in a multi-channel stream, provide the first (usually // `audio` must be mono; in a multi-channel stream, provide the first (usually
// left) channel. // left) channel.
virtual void Process(const int16_t* audio, size_t length, int sample_rate_hz); virtual void Process(const int16_t* audio, size_t length, int sample_rate_hz);
// Retrieves the difference between the target RMS level and the current // Retrieves the difference between the target RMS level and the current
// signal RMS level in dB. Returns true if an update is available and false // signal RMS level in dB. Returns true if an update is available and false
// otherwise, in which case |error| should be ignored and no action taken. // otherwise, in which case `error` should be ignored and no action taken.
virtual bool GetRmsErrorDb(int* error); virtual bool GetRmsErrorDb(int* error);
virtual void Reset(); virtual void Reset();

View file

@ -280,7 +280,7 @@ void MonoAgc::SetLevel(int new_level) {
void MonoAgc::SetMaxLevel(int level) { void MonoAgc::SetMaxLevel(int level) {
RTC_DCHECK_GE(level, clipped_level_min_); RTC_DCHECK_GE(level, clipped_level_min_);
max_level_ = level; max_level_ = level;
// Scale the |kSurplusCompressionGain| linearly across the restricted // Scale the `kSurplusCompressionGain` linearly across the restricted
// level range. // level range.
max_compression_gain_ = max_compression_gain_ =
kMaxCompressionGain + std::floor((1.f * kMaxMicLevel - max_level_) / kMaxCompressionGain + std::floor((1.f * kMaxMicLevel - max_level_) /
@ -307,7 +307,7 @@ int MonoAgc::CheckVolumeAndReset() {
int level = stream_analog_level_; int level = stream_analog_level_;
// Reasons for taking action at startup: // Reasons for taking action at startup:
// 1) A person starting a call is expected to be heard. // 1) A person starting a call is expected to be heard.
// 2) Independent of interpretation of |level| == 0 we should raise it so the // 2) Independent of interpretation of `level` == 0 we should raise it so the
// AGC can do its job properly. // AGC can do its job properly.
if (level == 0 && !startup_) { if (level == 0 && !startup_) {
RTC_DLOG(LS_INFO) RTC_DLOG(LS_INFO)

View file

@ -112,7 +112,7 @@ class AgcManagerDirect final {
FRIEND_TEST_ALL_PREFIXES(AgcManagerDirectStandaloneTest, FRIEND_TEST_ALL_PREFIXES(AgcManagerDirectStandaloneTest,
EnableClippingPredictorLowersVolume); EnableClippingPredictorLowersVolume);
// Dependency injection for testing. Don't delete |agc| as the memory is owned // Dependency injection for testing. Don't delete `agc` as the memory is owned
// by the manager. // by the manager.
AgcManagerDirect( AgcManagerDirect(
Agc* agc, Agc* agc,
@ -196,7 +196,7 @@ class MonoAgc {
// Set the maximum level the AGC is allowed to apply. Also updates the // Set the maximum level the AGC is allowed to apply. Also updates the
// maximum compression gain to compensate. The level must be at least // maximum compression gain to compensate. The level must be at least
// |kClippedLevelMin|. // `kClippedLevelMin`.
void SetMaxLevel(int level); void SetMaxLevel(int level);
int CheckVolumeAndReset(); int CheckVolumeAndReset();

View file

@ -20,12 +20,12 @@ namespace webrtc {
// Recommended to be enabled on the client-side. // Recommended to be enabled on the client-side.
class GainControl { class GainControl {
public: public:
// When an analog mode is set, this must be called prior to |ProcessStream()| // When an analog mode is set, this must be called prior to `ProcessStream()`
// to pass the current analog level from the audio HAL. Must be within the // to pass the current analog level from the audio HAL. Must be within the
// range provided to |set_analog_level_limits()|. // range provided to `set_analog_level_limits()`.
virtual int set_stream_analog_level(int level) = 0; virtual int set_stream_analog_level(int level) = 0;
// When an analog mode is set, this should be called after |ProcessStream()| // When an analog mode is set, this should be called after `ProcessStream()`
// to obtain the recommended new analog level for the audio HAL. It is the // to obtain the recommended new analog level for the audio HAL. It is the
// users responsibility to apply this level. // users responsibility to apply this level.
virtual int stream_analog_level() const = 0; virtual int stream_analog_level() const = 0;
@ -33,7 +33,7 @@ class GainControl {
enum Mode { enum Mode {
// Adaptive mode intended for use if an analog volume control is available // Adaptive mode intended for use if an analog volume control is available
// on the capture device. It will require the user to provide coupling // on the capture device. It will require the user to provide coupling
// between the OS mixer controls and AGC through the |stream_analog_level()| // between the OS mixer controls and AGC through the `stream_analog_level()`
// functions. // functions.
// //
// It consists of an analog gain prescription for the audio device and a // It consists of an analog gain prescription for the audio device and a
@ -61,7 +61,7 @@ class GainControl {
virtual int set_mode(Mode mode) = 0; virtual int set_mode(Mode mode) = 0;
virtual Mode mode() const = 0; virtual Mode mode() const = 0;
// Sets the target peak |level| (or envelope) of the AGC in dBFs (decibels // Sets the target peak `level` (or envelope) of the AGC in dBFs (decibels
// from digital full-scale). The convention is to use positive values. For // from digital full-scale). The convention is to use positive values. For
// instance, passing in a value of 3 corresponds to -3 dBFs, or a target // instance, passing in a value of 3 corresponds to -3 dBFs, or a target
// level 3 dB below full-scale. Limited to [0, 31]. // level 3 dB below full-scale. Limited to [0, 31].
@ -71,7 +71,7 @@ class GainControl {
virtual int set_target_level_dbfs(int level) = 0; virtual int set_target_level_dbfs(int level) = 0;
virtual int target_level_dbfs() const = 0; virtual int target_level_dbfs() const = 0;
// Sets the maximum |gain| the digital compression stage may apply, in dB. A // Sets the maximum `gain` the digital compression stage may apply, in dB. A
// higher number corresponds to greater compression, while a value of 0 will // higher number corresponds to greater compression, while a value of 0 will
// leave the signal uncompressed. Limited to [0, 90]. // leave the signal uncompressed. Limited to [0, 90].
virtual int set_compression_gain_db(int gain) = 0; virtual int set_compression_gain_db(int gain) = 0;
@ -83,7 +83,7 @@ class GainControl {
virtual int enable_limiter(bool enable) = 0; virtual int enable_limiter(bool enable) = 0;
virtual bool is_limiter_enabled() const = 0; virtual bool is_limiter_enabled() const = 0;
// Sets the |minimum| and |maximum| analog levels of the audio capture device. // Sets the `minimum` and `maximum` analog levels of the audio capture device.
// Must be set if and only if an analog mode is used. Limited to [0, 65535]. // Must be set if and only if an analog mode is used. Limited to [0, 65535].
virtual int set_analog_level_limits(int minimum, int maximum) = 0; virtual int set_analog_level_limits(int minimum, int maximum) = 0;
virtual int analog_level_minimum() const = 0; virtual int analog_level_minimum() const = 0;

View file

@ -160,7 +160,7 @@ int WebRtcAgc_AddMic(void* state,
/* apply slowly varying digital gain */ /* apply slowly varying digital gain */
if (stt->micVol > stt->maxAnalog) { if (stt->micVol > stt->maxAnalog) {
/* |maxLevel| is strictly >= |micVol|, so this condition should be /* `maxLevel` is strictly >= `micVol`, so this condition should be
* satisfied here, ensuring there is no divide-by-zero. */ * satisfied here, ensuring there is no divide-by-zero. */
RTC_DCHECK_GT(stt->maxLevel, stt->maxAnalog); RTC_DCHECK_GT(stt->maxLevel, stt->maxAnalog);

View file

@ -184,9 +184,9 @@ int32_t WebRtcAgc_CalculateGainTable(int32_t* gainTable, // Q16
numFIX -= (int32_t)logApprox * diffGain; // Q14 numFIX -= (int32_t)logApprox * diffGain; // Q14
// Calculate ratio // Calculate ratio
// Shift |numFIX| as much as possible. // Shift `numFIX` as much as possible.
// Ensure we avoid wrap-around in |den| as well. // Ensure we avoid wrap-around in `den` as well.
if (numFIX > (den >> 8) || -numFIX > (den >> 8)) { // |den| is Q8. if (numFIX > (den >> 8) || -numFIX > (den >> 8)) { // `den` is Q8.
zeros = WebRtcSpl_NormW32(numFIX); zeros = WebRtcSpl_NormW32(numFIX);
} else { } else {
zeros = WebRtcSpl_NormW32(den) + 8; zeros = WebRtcSpl_NormW32(den) + 8;

View file

@ -114,7 +114,7 @@ void LoudnessHistogram::RemoveOldestEntryAndUpdate() {
void LoudnessHistogram::RemoveTransient() { void LoudnessHistogram::RemoveTransient() {
// Don't expect to be here if high-activity region is longer than // Don't expect to be here if high-activity region is longer than
// |kTransientWidthThreshold| or there has not been any transient. // `kTransientWidthThreshold` or there has not been any transient.
RTC_DCHECK_LE(len_high_activity_, kTransientWidthThreshold); RTC_DCHECK_LE(len_high_activity_, kTransientWidthThreshold);
int index = int index =
(buffer_index_ > 0) ? (buffer_index_ - 1) : len_circular_buffer_ - 1; (buffer_index_ > 0) ? (buffer_index_ - 1) : len_circular_buffer_ - 1;

View file

@ -25,7 +25,7 @@ class LoudnessHistogram {
static LoudnessHistogram* Create(); static LoudnessHistogram* Create();
// Create a sliding LoudnessHistogram, i.e. the histogram represents the last // Create a sliding LoudnessHistogram, i.e. the histogram represents the last
// |window_size| samples. // `window_size` samples.
static LoudnessHistogram* Create(int window_size); static LoudnessHistogram* Create(int window_size);
~LoudnessHistogram(); ~LoudnessHistogram();
@ -49,7 +49,7 @@ class LoudnessHistogram {
LoudnessHistogram(); LoudnessHistogram();
explicit LoudnessHistogram(int window); explicit LoudnessHistogram(int window);
// Find the histogram bin associated with the given |rms|. // Find the histogram bin associated with the given `rms`.
int GetBinIndex(double rms); int GetBinIndex(double rms);
void RemoveOldestEntryAndUpdate(); void RemoveOldestEntryAndUpdate();
@ -63,10 +63,10 @@ class LoudnessHistogram {
// Number of times the histogram is updated // Number of times the histogram is updated
int num_updates_; int num_updates_;
// Audio content, this should be equal to the sum of the components of // Audio content, this should be equal to the sum of the components of
// |bin_count_q10_|. // `bin_count_q10_`.
int64_t audio_content_q10_; int64_t audio_content_q10_;
// LoudnessHistogram of input RMS in Q10 with |kHistSize_| bins. In each // LoudnessHistogram of input RMS in Q10 with `kHistSize_` bins. In each
// 'Update(),' we increment the associated histogram-bin with the given // 'Update(),' we increment the associated histogram-bin with the given
// probability. The increment is implemented in Q10 to avoid rounding errors. // probability. The increment is implemented in Q10 to avoid rounding errors.
int64_t bin_count_q10_[kHistSize]; int64_t bin_count_q10_[kHistSize];

View file

@ -15,7 +15,7 @@
namespace webrtc { namespace webrtc {
// Transposed direct form I implementation of a bi-quad filter applied to an // Transposed direct form I implementation of a bi-quad filter applied to an
// input signal |x| to produce an output signal |y|. // input signal `x` to produce an output signal `y`.
void BiQuadFilter::Process(rtc::ArrayView<const float> x, void BiQuadFilter::Process(rtc::ArrayView<const float> x,
rtc::ArrayView<float> y) { rtc::ArrayView<float> y) {
for (size_t k = 0; k < x.size(); ++k) { for (size_t k = 0; k < x.size(); ++k) {

View file

@ -64,7 +64,7 @@ void ExpectNearRelative(rtc::ArrayView<const float> expected,
rtc::ArrayView<const float> computed, rtc::ArrayView<const float> computed,
const float tolerance) { const float tolerance) {
// The relative error is undefined when the expected value is 0. // The relative error is undefined when the expected value is 0.
// When that happens, check the absolute error instead. |safe_den| is used // When that happens, check the absolute error instead. `safe_den` is used
// below to implement such logic. // below to implement such logic.
auto safe_den = [](float x) { return (x == 0.f) ? 1.f : std::fabs(x); }; auto safe_den = [](float x) { return (x == 0.f) ? 1.f : std::fabs(x); };
ASSERT_EQ(expected.size(), computed.size()); ASSERT_EQ(expected.size(), computed.size());

View file

@ -105,7 +105,7 @@ std::vector<double> SampleLimiterRegion(const LimiterDbGainCurve* limiter) {
const auto interval = q.top(); const auto interval = q.top();
q.pop(); q.pop();
// Split |interval| and enqueue. // Split `interval` and enqueue.
double x_split = (interval.x0 + interval.x1) / 2.0; double x_split = (interval.x0 + interval.x1) / 2.0;
q.emplace(interval.x0, x_split, q.emplace(interval.x0, x_split,
LimiterUnderApproximationNegativeError(limiter, interval.x0, LimiterUnderApproximationNegativeError(limiter, interval.x0,
@ -135,7 +135,7 @@ std::vector<double> SampleLimiterRegion(const LimiterDbGainCurve* limiter) {
void PrecomputeKneeApproxParams(const LimiterDbGainCurve* limiter, void PrecomputeKneeApproxParams(const LimiterDbGainCurve* limiter,
test::InterpolatedParameters* parameters) { test::InterpolatedParameters* parameters) {
static_assert(kInterpolatedGainCurveKneePoints > 2, ""); static_assert(kInterpolatedGainCurveKneePoints > 2, "");
// Get |kInterpolatedGainCurveKneePoints| - 1 equally spaced points. // Get `kInterpolatedGainCurveKneePoints` - 1 equally spaced points.
const std::vector<double> points = test::LinSpace( const std::vector<double> points = test::LinSpace(
limiter->knee_start_linear(), limiter->limiter_start_linear(), limiter->knee_start_linear(), limiter->limiter_start_linear(),
kInterpolatedGainCurveKneePoints - 1); kInterpolatedGainCurveKneePoints - 1);

View file

@ -29,8 +29,8 @@ namespace test {
// Knee and beyond-knee regions approximation parameters. // Knee and beyond-knee regions approximation parameters.
// The gain curve is approximated as a piece-wise linear function. // The gain curve is approximated as a piece-wise linear function.
// |approx_params_x_| are the boundaries between adjacent linear pieces, // `approx_params_x_` are the boundaries between adjacent linear pieces,
// |approx_params_m_| and |approx_params_q_| are the slope and the y-intercept // `approx_params_m_` and `approx_params_q_` are the slope and the y-intercept
// values of each piece. // values of each piece.
struct InterpolatedParameters { struct InterpolatedParameters {
std::array<float, kInterpolatedGainCurveTotalPoints> std::array<float, kInterpolatedGainCurveTotalPoints>

View file

@ -26,7 +26,7 @@ constexpr float kInitialFilterStateLevel = 0.f;
constexpr float kAttackFilterConstant = 0.f; constexpr float kAttackFilterConstant = 0.f;
// This is computed from kDecayMs by // This is computed from kDecayMs by
// 10 ** (-1/20 * subframe_duration / kDecayMs). // 10 ** (-1/20 * subframe_duration / kDecayMs).
// |subframe_duration| is |kFrameDurationMs / kSubFramesInFrame|. // `subframe_duration` is |kFrameDurationMs / kSubFramesInFrame|.
// kDecayMs is defined in agc2_testing_common.h // kDecayMs is defined in agc2_testing_common.h
constexpr float kDecayFilterConstant = 0.9998848773724686f; constexpr float kDecayFilterConstant = 0.9998848773724686f;

View file

@ -151,11 +151,11 @@ void InterpolatedGainCurve::UpdateStats(float input_level) const {
} }
// Looks up a gain to apply given a non-negative input level. // Looks up a gain to apply given a non-negative input level.
// The cost of this operation depends on the region in which |input_level| // The cost of this operation depends on the region in which `input_level`
// falls. // falls.
// For the identity and the saturation regions the cost is O(1). // For the identity and the saturation regions the cost is O(1).
// For the other regions, namely knee and limiter, the cost is // For the other regions, namely knee and limiter, the cost is
// O(2 + log2(|LightkInterpolatedGainCurveTotalPoints|), plus O(1) for the // O(2 + log2(`LightkInterpolatedGainCurveTotalPoints`), plus O(1) for the
// linear interpolation (one product and one sum). // linear interpolation (one product and one sum).
float InterpolatedGainCurve::LookUpGainToApply(float input_level) const { float InterpolatedGainCurve::LookUpGainToApply(float input_level) const {
UpdateStats(input_level); UpdateStats(input_level);

View file

@ -31,7 +31,7 @@ class Limiter {
Limiter& operator=(const Limiter& limiter) = delete; Limiter& operator=(const Limiter& limiter) = delete;
~Limiter(); ~Limiter();
// Applies limiter and hard-clipping to |signal|. // Applies limiter and hard-clipping to `signal`.
void Process(AudioFrameView<float> signal); void Process(AudioFrameView<float> signal);
InterpolatedGainCurve::Stats GetGainCurveStats() const; InterpolatedGainCurve::Stats GetGainCurveStats() const;

View file

@ -105,7 +105,7 @@ double LimiterDbGainCurve::GetGainLinear(double input_level_linear) const {
input_level_linear; input_level_linear;
} }
// Computes the first derivative of GetGainLinear() in |x|. // Computes the first derivative of GetGainLinear() in `x`.
double LimiterDbGainCurve::GetGainFirstDerivativeLinear(double x) const { double LimiterDbGainCurve::GetGainFirstDerivativeLinear(double x) const {
// Beyond-knee region only. // Beyond-knee region only.
RTC_CHECK_GE(x, limiter_start_linear_ - 1e-7 * kMaxAbsFloatS16Value); RTC_CHECK_GE(x, limiter_start_linear_ - 1e-7 * kMaxAbsFloatS16Value);

View file

@ -40,7 +40,7 @@ AutoCorrelationCalculator::~AutoCorrelationCalculator() = default;
// [ y_{m-1} ] // [ y_{m-1} ]
// x and y are sub-array of equal length; x is never moved, whereas y slides. // x and y are sub-array of equal length; x is never moved, whereas y slides.
// The cross-correlation between y_0 and x corresponds to the auto-correlation // The cross-correlation between y_0 and x corresponds to the auto-correlation
// for the maximum pitch period. Hence, the first value in |auto_corr| has an // for the maximum pitch period. Hence, the first value in `auto_corr` has an
// inverted lag equal to 0 that corresponds to a lag equal to the maximum // inverted lag equal to 0 that corresponds to a lag equal to the maximum
// pitch period. // pitch period.
void AutoCorrelationCalculator::ComputeOnPitchBuffer( void AutoCorrelationCalculator::ComputeOnPitchBuffer(

View file

@ -31,7 +31,7 @@ class AutoCorrelationCalculator {
~AutoCorrelationCalculator(); ~AutoCorrelationCalculator();
// Computes the auto-correlation coefficients for a target pitch interval. // Computes the auto-correlation coefficients for a target pitch interval.
// |auto_corr| indexes are inverted lags. // `auto_corr` indexes are inverted lags.
void ComputeOnPitchBuffer( void ComputeOnPitchBuffer(
rtc::ArrayView<const float, kBufSize12kHz> pitch_buf, rtc::ArrayView<const float, kBufSize12kHz> pitch_buf,
rtc::ArrayView<float, kNumLags12kHz> auto_corr); rtc::ArrayView<float, kNumLags12kHz> auto_corr);

View file

@ -52,8 +52,8 @@ constexpr int kBufSize12kHz = kBufSize24kHz / 2;
constexpr int kInitialMinPitch12kHz = kInitialMinPitch24kHz / 2; constexpr int kInitialMinPitch12kHz = kInitialMinPitch24kHz / 2;
constexpr int kMaxPitch12kHz = kMaxPitch24kHz / 2; constexpr int kMaxPitch12kHz = kMaxPitch24kHz / 2;
static_assert(kMaxPitch12kHz > kInitialMinPitch12kHz, ""); static_assert(kMaxPitch12kHz > kInitialMinPitch12kHz, "");
// The inverted lags for the pitch interval [|kInitialMinPitch12kHz|, // The inverted lags for the pitch interval [`kInitialMinPitch12kHz`,
// |kMaxPitch12kHz|] are in the range [0, |kNumLags12kHz|]. // `kMaxPitch12kHz`] are in the range [0, `kNumLags12kHz`].
constexpr int kNumLags12kHz = kMaxPitch12kHz - kInitialMinPitch12kHz; constexpr int kNumLags12kHz = kMaxPitch12kHz - kInitialMinPitch12kHz;
// 48 kHz constants. // 48 kHz constants.

View file

@ -55,10 +55,10 @@ bool FeaturesExtractor::CheckSilenceComputeFeatures(
if (use_high_pass_filter_) { if (use_high_pass_filter_) {
std::array<float, kFrameSize10ms24kHz> samples_filtered; std::array<float, kFrameSize10ms24kHz> samples_filtered;
hpf_.Process(samples, samples_filtered); hpf_.Process(samples, samples_filtered);
// Feed buffer with the pre-processed version of |samples|. // Feed buffer with the pre-processed version of `samples`.
pitch_buf_24kHz_.Push(samples_filtered); pitch_buf_24kHz_.Push(samples_filtered);
} else { } else {
// Feed buffer with |samples|. // Feed buffer with `samples`.
pitch_buf_24kHz_.Push(samples); pitch_buf_24kHz_.Push(samples);
} }
// Extract the LP residual. // Extract the LP residual.

View file

@ -33,7 +33,7 @@ class FeaturesExtractor {
void Reset(); void Reset();
// Analyzes the samples, computes the feature vector and returns true if // Analyzes the samples, computes the feature vector and returns true if
// silence is detected (false if not). When silence is detected, // silence is detected (false if not). When silence is detected,
// |feature_vector| is partially written and therefore must not be used to // `feature_vector` is partially written and therefore must not be used to
// feed the VAD RNN. // feed the VAD RNN.
bool CheckSilenceComputeFeatures( bool CheckSilenceComputeFeatures(
rtc::ArrayView<const float, kFrameSize10ms24kHz> samples, rtc::ArrayView<const float, kFrameSize10ms24kHz> samples,

View file

@ -29,7 +29,7 @@ constexpr int ceil(int n, int m) {
} }
// Number of 10 ms frames required to fill a pitch buffer having size // Number of 10 ms frames required to fill a pitch buffer having size
// |kBufSize24kHz|. // `kBufSize24kHz`.
constexpr int kNumTestDataFrames = ceil(kBufSize24kHz, kFrameSize10ms24kHz); constexpr int kNumTestDataFrames = ceil(kBufSize24kHz, kFrameSize10ms24kHz);
// Number of samples for the test data. // Number of samples for the test data.
constexpr int kNumTestDataSize = kNumTestDataFrames * kFrameSize10ms24kHz; constexpr int kNumTestDataSize = kNumTestDataFrames * kFrameSize10ms24kHz;
@ -47,8 +47,8 @@ void CreatePureTone(float amplitude, float freq_hz, rtc::ArrayView<float> dst) {
} }
} }
// Feeds |features_extractor| with |samples| splitting it in 10 ms frames. // Feeds `features_extractor` with `samples` splitting it in 10 ms frames.
// For every frame, the output is written into |feature_vector|. Returns true // For every frame, the output is written into `feature_vector`. Returns true
// if silence is detected in the last frame. // if silence is detected in the last frame.
bool FeedTestData(FeaturesExtractor& features_extractor, bool FeedTestData(FeaturesExtractor& features_extractor,
rtc::ArrayView<const float> samples, rtc::ArrayView<const float> samples,

View file

@ -22,9 +22,9 @@ namespace webrtc {
namespace rnn_vad { namespace rnn_vad {
namespace { namespace {
// Computes auto-correlation coefficients for |x| and writes them in // Computes auto-correlation coefficients for `x` and writes them in
// |auto_corr|. The lag values are in {0, ..., max_lag - 1}, where max_lag // `auto_corr`. The lag values are in {0, ..., max_lag - 1}, where max_lag
// equals the size of |auto_corr|. // equals the size of `auto_corr`.
void ComputeAutoCorrelation( void ComputeAutoCorrelation(
rtc::ArrayView<const float> x, rtc::ArrayView<const float> x,
rtc::ArrayView<float, kNumLpcCoefficients> auto_corr) { rtc::ArrayView<float, kNumLpcCoefficients> auto_corr) {

View file

@ -21,14 +21,14 @@ namespace rnn_vad {
// Linear predictive coding (LPC) inverse filter length. // Linear predictive coding (LPC) inverse filter length.
constexpr int kNumLpcCoefficients = 5; constexpr int kNumLpcCoefficients = 5;
// Given a frame |x|, computes a post-processed version of LPC coefficients // Given a frame `x`, computes a post-processed version of LPC coefficients
// tailored for pitch estimation. // tailored for pitch estimation.
void ComputeAndPostProcessLpcCoefficients( void ComputeAndPostProcessLpcCoefficients(
rtc::ArrayView<const float> x, rtc::ArrayView<const float> x,
rtc::ArrayView<float, kNumLpcCoefficients> lpc_coeffs); rtc::ArrayView<float, kNumLpcCoefficients> lpc_coeffs);
// Computes the LP residual for the input frame |x| and the LPC coefficients // Computes the LP residual for the input frame `x` and the LPC coefficients
// |lpc_coeffs|. |y| and |x| can point to the same array for in-place // `lpc_coeffs`. `y` and `x` can point to the same array for in-place
// computation. // computation.
void ComputeLpResidual( void ComputeLpResidual(
rtc::ArrayView<const float, kNumLpcCoefficients> lpc_coeffs, rtc::ArrayView<const float, kNumLpcCoefficients> lpc_coeffs,

View file

@ -44,7 +44,7 @@ int PitchEstimator::Estimate(
CandidatePitchPeriods pitch_periods = ComputePitchPeriod12kHz( CandidatePitchPeriods pitch_periods = ComputePitchPeriod12kHz(
pitch_buffer_12kHz_view, auto_correlation_12kHz_view, cpu_features_); pitch_buffer_12kHz_view, auto_correlation_12kHz_view, cpu_features_);
// The refinement is done using the pitch buffer that contains 24 kHz samples. // The refinement is done using the pitch buffer that contains 24 kHz samples.
// Therefore, adapt the inverted lags in |pitch_candidates_inv_lags| from 12 // Therefore, adapt the inverted lags in `pitch_candidates_inv_lags` from 12
// to 24 kHz. // to 24 kHz.
pitch_periods.best *= 2; pitch_periods.best *= 2;
pitch_periods.second_best *= 2; pitch_periods.second_best *= 2;

View file

@ -54,18 +54,18 @@ int GetPitchPseudoInterpolationOffset(float prev_auto_correlation,
float next_auto_correlation) { float next_auto_correlation) {
if ((next_auto_correlation - prev_auto_correlation) > if ((next_auto_correlation - prev_auto_correlation) >
0.7f * (curr_auto_correlation - prev_auto_correlation)) { 0.7f * (curr_auto_correlation - prev_auto_correlation)) {
return 1; // |next_auto_correlation| is the largest auto-correlation return 1; // `next_auto_correlation` is the largest auto-correlation
// coefficient. // coefficient.
} else if ((prev_auto_correlation - next_auto_correlation) > } else if ((prev_auto_correlation - next_auto_correlation) >
0.7f * (curr_auto_correlation - next_auto_correlation)) { 0.7f * (curr_auto_correlation - next_auto_correlation)) {
return -1; // |prev_auto_correlation| is the largest auto-correlation return -1; // `prev_auto_correlation` is the largest auto-correlation
// coefficient. // coefficient.
} }
return 0; return 0;
} }
// Refines a pitch period |lag| encoded as lag with pseudo-interpolation. The // Refines a pitch period `lag` encoded as lag with pseudo-interpolation. The
// output sample rate is twice as that of |lag|. // output sample rate is twice as that of `lag`.
int PitchPseudoInterpolationLagPitchBuf( int PitchPseudoInterpolationLagPitchBuf(
int lag, int lag,
rtc::ArrayView<const float, kBufSize24kHz> pitch_buffer, rtc::ArrayView<const float, kBufSize24kHz> pitch_buffer,
@ -217,8 +217,8 @@ int ComputePitchPeriod48kHz(
auto_correlation[best_inverted_lag + 1], auto_correlation[best_inverted_lag + 1],
auto_correlation[best_inverted_lag], auto_correlation[best_inverted_lag],
auto_correlation[best_inverted_lag - 1]); auto_correlation[best_inverted_lag - 1]);
// TODO(bugs.webrtc.org/9076): When retraining, check if |offset| below should // TODO(bugs.webrtc.org/9076): When retraining, check if `offset` below should
// be subtracted since |inverted_lag| is an inverted lag but offset is a lag. // be subtracted since `inverted_lag` is an inverted lag but offset is a lag.
return 2 * best_inverted_lag + offset; return 2 * best_inverted_lag + offset;
} }
@ -359,7 +359,7 @@ CandidatePitchPeriods ComputePitchPeriod12kHz(
} }
} }
} }
// Update |squared_energy_y| for the next inverted lag. // Update `squared_energy_y` for the next inverted lag.
const float y_old = pitch_buffer[inverted_lag]; const float y_old = pitch_buffer[inverted_lag];
const float y_new = pitch_buffer[inverted_lag + kFrameSize20ms12kHz]; const float y_new = pitch_buffer[inverted_lag + kFrameSize20ms12kHz];
denominator -= y_old * y_old; denominator -= y_old * y_old;
@ -458,8 +458,8 @@ PitchInfo ComputeExtendedPitchPeriod48kHz(
initial_pitch.period, /*multiplier=*/1, period_divisor); initial_pitch.period, /*multiplier=*/1, period_divisor);
RTC_DCHECK_GE(alternative_pitch.period, kMinPitch24kHz); RTC_DCHECK_GE(alternative_pitch.period, kMinPitch24kHz);
// When looking at |alternative_pitch.period|, we also look at one of its // When looking at |alternative_pitch.period|, we also look at one of its
// sub-harmonics. |kSubHarmonicMultipliers| is used to know where to look. // sub-harmonics. `kSubHarmonicMultipliers` is used to know where to look.
// |period_divisor| == 2 is a special case since |dual_alternative_period| // `period_divisor` == 2 is a special case since `dual_alternative_period`
// might be greater than the maximum pitch period. // might be greater than the maximum pitch period.
int dual_alternative_period = GetAlternativePitchPeriod( int dual_alternative_period = GetAlternativePitchPeriod(
initial_pitch.period, kSubHarmonicMultipliers[period_divisor - 2], initial_pitch.period, kSubHarmonicMultipliers[period_divisor - 2],
@ -473,7 +473,7 @@ PitchInfo ComputeExtendedPitchPeriod48kHz(
"coincide."; "coincide.";
// Compute an auto-correlation score for the primary pitch candidate // Compute an auto-correlation score for the primary pitch candidate
// |alternative_pitch.period| by also looking at its possible sub-harmonic // |alternative_pitch.period| by also looking at its possible sub-harmonic
// |dual_alternative_period|. // `dual_alternative_period`.
const float xy_primary_period = ComputeAutoCorrelation( const float xy_primary_period = ComputeAutoCorrelation(
kMaxPitch24kHz - alternative_pitch.period, pitch_buffer, vector_math); kMaxPitch24kHz - alternative_pitch.period, pitch_buffer, vector_math);
// TODO(webrtc:10480): Copy `xy_primary_period` if the secondary period is // TODO(webrtc:10480): Copy `xy_primary_period` if the secondary period is

View file

@ -35,7 +35,7 @@ class RingBuffer {
~RingBuffer() = default; ~RingBuffer() = default;
// Set the ring buffer values to zero. // Set the ring buffer values to zero.
void Reset() { buffer_.fill(0); } void Reset() { buffer_.fill(0); }
// Replace the least recently pushed array in the buffer with |new_values|. // Replace the least recently pushed array in the buffer with `new_values`.
void Push(rtc::ArrayView<const T, S> new_values) { void Push(rtc::ArrayView<const T, S> new_values) {
std::memcpy(buffer_.data() + S * tail_, new_values.data(), S * sizeof(T)); std::memcpy(buffer_.data() + S * tail_, new_values.data(), S * sizeof(T));
tail_ += 1; tail_ += 1;
@ -43,7 +43,7 @@ class RingBuffer {
tail_ = 0; tail_ = 0;
} }
// Return an array view onto the array with a given delay. A view on the last // Return an array view onto the array with a given delay. A view on the last
// and least recently push array is returned when |delay| is 0 and N - 1 // and least recently push array is returned when `delay` is 0 and N - 1
// respectively. // respectively.
rtc::ArrayView<const T, S> GetArrayView(int delay) const { rtc::ArrayView<const T, S> GetArrayView(int delay) const {
RTC_DCHECK_LE(0, delay); RTC_DCHECK_LE(0, delay);

View file

@ -32,7 +32,7 @@ std::vector<float> GetScaledParams(rtc::ArrayView<const int8_t> params) {
// TODO(bugs.chromium.org/10480): Hard-code optimized layout and remove this // TODO(bugs.chromium.org/10480): Hard-code optimized layout and remove this
// function to improve setup time. // function to improve setup time.
// Casts and scales |weights| and re-arranges the layout. // Casts and scales `weights` and re-arranges the layout.
std::vector<float> PreprocessWeights(rtc::ArrayView<const int8_t> weights, std::vector<float> PreprocessWeights(rtc::ArrayView<const int8_t> weights,
int output_size) { int output_size) {
if (output_size == 1) { if (output_size == 1) {

View file

@ -24,7 +24,7 @@ constexpr int kNumGruGates = 3; // Update, reset, output.
std::vector<float> PreprocessGruTensor(rtc::ArrayView<const int8_t> tensor_src, std::vector<float> PreprocessGruTensor(rtc::ArrayView<const int8_t> tensor_src,
int output_size) { int output_size) {
// Transpose, cast and scale. // Transpose, cast and scale.
// |n| is the size of the first dimension of the 3-dim tensor |weights|. // `n` is the size of the first dimension of the 3-dim tensor `weights`.
const int n = rtc::CheckedDivExact(rtc::dchecked_cast<int>(tensor_src.size()), const int n = rtc::CheckedDivExact(rtc::dchecked_cast<int>(tensor_src.size()),
output_size * kNumGruGates); output_size * kNumGruGates);
const int stride_src = kNumGruGates * output_size; const int stride_src = kNumGruGates * output_size;

View file

@ -49,7 +49,7 @@ void DumpPerfStats(int num_samples,
// constant below to true in order to write new expected output binary files. // constant below to true in order to write new expected output binary files.
constexpr bool kWriteComputedOutputToFile = false; constexpr bool kWriteComputedOutputToFile = false;
// Avoids that one forgets to set |kWriteComputedOutputToFile| back to false // Avoids that one forgets to set `kWriteComputedOutputToFile` back to false
// when the expected output files are re-exported. // when the expected output files are re-exported.
TEST(RnnVadTest, CheckWriteComputedOutputIsFalse) { TEST(RnnVadTest, CheckWriteComputedOutputIsFalse) {
ASSERT_FALSE(kWriteComputedOutputToFile) ASSERT_FALSE(kWriteComputedOutputToFile)

View file

@ -50,7 +50,7 @@ void TestSequenceBufferPushOp() {
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
chunk[i] = static_cast<T>(i + 1); chunk[i] = static_cast<T>(i + 1);
seq_buf.Push(chunk); seq_buf.Push(chunk);
// With the next Push(), |last| will be moved left by N positions. // With the next Push(), `last` will be moved left by N positions.
const T last = chunk[N - 1]; const T last = chunk[N - 1];
for (int i = 0; i < N; ++i) for (int i = 0; i < N; ++i)
chunk[i] = static_cast<T>(last + i + 1); chunk[i] = static_cast<T>(last + i + 1);

View file

@ -23,7 +23,7 @@ namespace {
// Weights for each FFT coefficient for each Opus band (Nyquist frequency // Weights for each FFT coefficient for each Opus band (Nyquist frequency
// excluded). The size of each band is specified in // excluded). The size of each band is specified in
// |kOpusScaleNumBins24kHz20ms|. // `kOpusScaleNumBins24kHz20ms`.
constexpr std::array<float, kFrameSize20ms24kHz / 2> kOpusBandWeights24kHz20ms = constexpr std::array<float, kFrameSize20ms24kHz / 2> kOpusBandWeights24kHz20ms =
{{ {{
0.f, 0.25f, 0.5f, 0.75f, // Band 0 0.f, 0.25f, 0.5f, 0.75f, // Band 0

View file

@ -50,8 +50,8 @@ class SpectralCorrelator {
~SpectralCorrelator(); ~SpectralCorrelator();
// Computes the band-wise spectral auto-correlations. // Computes the band-wise spectral auto-correlations.
// |x| must: // `x` must:
// - have size equal to |kFrameSize20ms24kHz|; // - have size equal to `kFrameSize20ms24kHz`;
// - be encoded as vectors of interleaved real-complex FFT coefficients // - be encoded as vectors of interleaved real-complex FFT coefficients
// where x[1] = y[1] = 0 (the Nyquist frequency coefficient is omitted). // where x[1] = y[1] = 0 (the Nyquist frequency coefficient is omitted).
void ComputeAutoCorrelation( void ComputeAutoCorrelation(
@ -59,8 +59,8 @@ class SpectralCorrelator {
rtc::ArrayView<float, kOpusBands24kHz> auto_corr) const; rtc::ArrayView<float, kOpusBands24kHz> auto_corr) const;
// Computes the band-wise spectral cross-correlations. // Computes the band-wise spectral cross-correlations.
// |x| and |y| must: // `x` and `y` must:
// - have size equal to |kFrameSize20ms24kHz|; // - have size equal to `kFrameSize20ms24kHz`;
// - be encoded as vectors of interleaved real-complex FFT coefficients where // - be encoded as vectors of interleaved real-complex FFT coefficients where
// x[1] = y[1] = 0 (the Nyquist frequency coefficient is omitted). // x[1] = y[1] = 0 (the Nyquist frequency coefficient is omitted).
void ComputeCrossCorrelation( void ComputeCrossCorrelation(
@ -82,12 +82,12 @@ void ComputeSmoothedLogMagnitudeSpectrum(
// TODO(bugs.webrtc.org/10480): Move to anonymous namespace in // TODO(bugs.webrtc.org/10480): Move to anonymous namespace in
// spectral_features.cc. Creates a DCT table for arrays having size equal to // spectral_features.cc. Creates a DCT table for arrays having size equal to
// |kNumBands|. Declared here for unit testing. // `kNumBands`. Declared here for unit testing.
std::array<float, kNumBands * kNumBands> ComputeDctTable(); std::array<float, kNumBands * kNumBands> ComputeDctTable();
// TODO(bugs.webrtc.org/10480): Move to anonymous namespace in // TODO(bugs.webrtc.org/10480): Move to anonymous namespace in
// spectral_features.cc. Computes DCT for |in| given a pre-computed DCT table. // spectral_features.cc. Computes DCT for `in` given a pre-computed DCT table.
// In-place computation is not allowed and |out| can be smaller than |in| in // In-place computation is not allowed and `out` can be smaller than `in` in
// order to only compute the first DCT coefficients. Declared here for unit // order to only compute the first DCT coefficients. Declared here for unit
// testing. // testing.
void ComputeDct(rtc::ArrayView<const float> in, void ComputeDct(rtc::ArrayView<const float> in,

View file

@ -28,7 +28,7 @@ namespace webrtc {
namespace rnn_vad { namespace rnn_vad {
namespace { namespace {
// Generates the values for the array named |kOpusBandWeights24kHz20ms| in the // Generates the values for the array named `kOpusBandWeights24kHz20ms` in the
// anonymous namespace of the .cc file, which is the array of FFT coefficient // anonymous namespace of the .cc file, which is the array of FFT coefficient
// weights for the Opus scale triangular filters. // weights for the Opus scale triangular filters.
std::vector<float> ComputeTriangularFiltersWeights() { std::vector<float> ComputeTriangularFiltersWeights() {
@ -66,7 +66,7 @@ TEST(RnnVadTest, TestOpusScaleBoundaries) {
// Checks that the computed triangular filters weights for the Opus scale are // Checks that the computed triangular filters weights for the Opus scale are
// monotonic withing each Opus band. This test should only be enabled when // monotonic withing each Opus band. This test should only be enabled when
// ComputeTriangularFiltersWeights() is changed and |kOpusBandWeights24kHz20ms| // ComputeTriangularFiltersWeights() is changed and `kOpusBandWeights24kHz20ms`
// is updated accordingly. // is updated accordingly.
TEST(RnnVadTest, DISABLED_TestOpusScaleWeights) { TEST(RnnVadTest, DISABLED_TestOpusScaleWeights) {
auto weights = ComputeTriangularFiltersWeights(); auto weights = ComputeTriangularFiltersWeights();

View file

@ -46,9 +46,9 @@ class SymmetricMatrixBuffer {
buf_.fill(0); buf_.fill(0);
} }
// Pushes the results from the comparison between the most recent item and // Pushes the results from the comparison between the most recent item and
// those that are still in the ring buffer. The first element in |values| must // those that are still in the ring buffer. The first element in `values` must
// correspond to the comparison between the most recent item and the second // correspond to the comparison between the most recent item and the second
// most recent one in the ring buffer, whereas the last element in |values| // most recent one in the ring buffer, whereas the last element in `values`
// must correspond to the comparison between the most recent item and the // must correspond to the comparison between the most recent item and the
// oldest one in the ring buffer. // oldest one in the ring buffer.
void Push(rtc::ArrayView<T, S - 1> values) { void Push(rtc::ArrayView<T, S - 1> values) {
@ -64,7 +64,7 @@ class SymmetricMatrixBuffer {
} }
} }
// Reads the value that corresponds to comparison of two items in the ring // Reads the value that corresponds to comparison of two items in the ring
// buffer having delay |delay1| and |delay2|. The two arguments must not be // buffer having delay `delay1` and `delay2`. The two arguments must not be
// equal and both must be in {0, ..., S - 1}. // equal and both must be in {0, ..., S - 1}.
T GetValue(int delay1, int delay2) const { T GetValue(int delay1, int delay2) const {
int row = S - 1 - delay1; int row = S - 1 - delay1;

View file

@ -58,17 +58,17 @@ TEST(RnnVadTest, SymmetricMatrixBufferUseCase) {
SCOPED_TRACE(t); SCOPED_TRACE(t);
const int t_removed = ring_buf.GetArrayView(kRingBufSize - 1)[0]; const int t_removed = ring_buf.GetArrayView(kRingBufSize - 1)[0];
ring_buf.Push({&t, 1}); ring_buf.Push({&t, 1});
// The head of the ring buffer is |t|. // The head of the ring buffer is `t`.
ASSERT_EQ(t, ring_buf.GetArrayView(0)[0]); ASSERT_EQ(t, ring_buf.GetArrayView(0)[0]);
// Create the comparisons between |t| and the older elements in the ring // Create the comparisons between `t` and the older elements in the ring
// buffer. // buffer.
std::array<PairType, kRingBufSize - 1> new_comparions; std::array<PairType, kRingBufSize - 1> new_comparions;
for (int i = 0; i < kRingBufSize - 1; ++i) { for (int i = 0; i < kRingBufSize - 1; ++i) {
// Start comparing |t| to the second newest element in the ring buffer. // Start comparing `t` to the second newest element in the ring buffer.
const int delay = i + 1; const int delay = i + 1;
const auto t_prev = ring_buf.GetArrayView(delay)[0]; const auto t_prev = ring_buf.GetArrayView(delay)[0];
ASSERT_EQ(std::max(0, t - delay), t_prev); ASSERT_EQ(std::max(0, t - delay), t_prev);
// Compare the last element |t| with |t_prev|. // Compare the last element `t` with `t_prev`.
new_comparions[i].first = t_prev; new_comparions[i].first = t_prev;
new_comparions[i].second = t; new_comparions[i].second = t;
} }

View file

@ -71,8 +71,8 @@ class AudioBuffer {
// Usage: // Usage:
// channels()[channel][sample]. // channels()[channel][sample].
// Where: // Where:
// 0 <= channel < |buffer_num_channels_| // 0 <= channel < `buffer_num_channels_`
// 0 <= sample < |buffer_num_frames_| // 0 <= sample < `buffer_num_frames_`
float* const* channels() { return data_->channels(); } float* const* channels() { return data_->channels(); }
const float* const* channels_const() const { return data_->channels(); } const float* const* channels_const() const { return data_->channels(); }
@ -80,9 +80,9 @@ class AudioBuffer {
// Usage: // Usage:
// split_bands(channel)[band][sample]. // split_bands(channel)[band][sample].
// Where: // Where:
// 0 <= channel < |buffer_num_channels_| // 0 <= channel < `buffer_num_channels_`
// 0 <= band < |num_bands_| // 0 <= band < `num_bands_`
// 0 <= sample < |num_split_frames_| // 0 <= sample < `num_split_frames_`
const float* const* split_bands_const(size_t channel) const { const float* const* split_bands_const(size_t channel) const {
return split_data_.get() ? split_data_->bands(channel) return split_data_.get() ? split_data_->bands(channel)
: data_->bands(channel); : data_->bands(channel);
@ -96,9 +96,9 @@ class AudioBuffer {
// Usage: // Usage:
// split_channels(band)[channel][sample]. // split_channels(band)[channel][sample].
// Where: // Where:
// 0 <= band < |num_bands_| // 0 <= band < `num_bands_`
// 0 <= channel < |buffer_num_channels_| // 0 <= channel < `buffer_num_channels_`
// 0 <= sample < |num_split_frames_| // 0 <= sample < `num_split_frames_`
const float* const* split_channels_const(Band band) const { const float* const* split_channels_const(Band band) const {
if (split_data_.get()) { if (split_data_.get()) {
return split_data_->channels(band); return split_data_->channels(band);

View file

@ -1325,7 +1325,7 @@ int AudioProcessingImpl::ProcessCaptureStreamLocked() {
capture_.key_pressed); capture_.key_pressed);
} }
// Experimental APM sub-module that analyzes |capture_buffer|. // Experimental APM sub-module that analyzes `capture_buffer`.
if (submodules_.capture_analyzer) { if (submodules_.capture_analyzer) {
submodules_.capture_analyzer->Analyze(capture_buffer); submodules_.capture_analyzer->Analyze(capture_buffer);
} }

View file

@ -169,7 +169,7 @@ class AudioProcessingImpl : public AudioProcessing {
const ApmSubmoduleCreationOverrides& overrides); const ApmSubmoduleCreationOverrides& overrides);
// Class providing thread-safe message pipe functionality for // Class providing thread-safe message pipe functionality for
// |runtime_settings_|. // `runtime_settings_`.
class RuntimeSettingEnqueuer { class RuntimeSettingEnqueuer {
public: public:
explicit RuntimeSettingEnqueuer( explicit RuntimeSettingEnqueuer(
@ -320,8 +320,8 @@ class AudioProcessingImpl : public AudioProcessing {
// Collects configuration settings from public and private // Collects configuration settings from public and private
// submodules to be saved as an audioproc::Config message on the // submodules to be saved as an audioproc::Config message on the
// AecDump if it is attached. If not |forced|, only writes the current // AecDump if it is attached. If not `forced`, only writes the current
// config if it is different from the last saved one; if |forced|, // config if it is different from the last saved one; if `forced`,
// writes the config regardless of the last saved. // writes the config regardless of the last saved.
void WriteAecDumpConfigMessage(bool forced) void WriteAecDumpConfigMessage(bool forced)
RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_capture_); RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_capture_);

View file

@ -321,10 +321,10 @@ void OpenFileAndReadMessage(const std::string& filename, MessageLite* msg) {
// Reads a 10 ms chunk of int16 interleaved audio from the given (assumed // Reads a 10 ms chunk of int16 interleaved audio from the given (assumed
// stereo) file, converts to deinterleaved float (optionally downmixing) and // stereo) file, converts to deinterleaved float (optionally downmixing) and
// returns the result in |cb|. Returns false if the file ended (or on error) and // returns the result in `cb`. Returns false if the file ended (or on error) and
// true otherwise. // true otherwise.
// //
// |int_data| and |float_data| are just temporary space that must be // `int_data` and `float_data` are just temporary space that must be
// sufficiently large to hold the 10 ms chunk. // sufficiently large to hold the 10 ms chunk.
bool ReadChunk(FILE* file, bool ReadChunk(FILE* file,
int16_t* int_data, int16_t* int_data,
@ -596,7 +596,7 @@ void ApmTest::ProcessDelayVerificationTest(int delay_ms,
int system_delay_ms, int system_delay_ms,
int delay_min, int delay_min,
int delay_max) { int delay_max) {
// The |revframe_| and |frame_| should include the proper frame information, // The `revframe_` and `frame_` should include the proper frame information,
// hence can be used for extracting information. // hence can be used for extracting information.
Int16FrameData tmp_frame; Int16FrameData tmp_frame;
std::queue<Int16FrameData*> frame_queue; std::queue<Int16FrameData*> frame_queue;
@ -606,7 +606,7 @@ void ApmTest::ProcessDelayVerificationTest(int delay_ms,
SetFrameTo(&tmp_frame, 0); SetFrameTo(&tmp_frame, 0);
EXPECT_EQ(apm_->kNoError, apm_->Initialize()); EXPECT_EQ(apm_->kNoError, apm_->Initialize());
// Initialize the |frame_queue| with empty frames. // Initialize the `frame_queue` with empty frames.
int frame_delay = delay_ms / 10; int frame_delay = delay_ms / 10;
while (frame_delay < 0) { while (frame_delay < 0) {
Int16FrameData* frame = new Int16FrameData(); Int16FrameData* frame = new Int16FrameData();
@ -1884,7 +1884,7 @@ TEST_F(ApmTest, Process) {
if (!absl::GetFlag(FLAGS_write_apm_ref_data)) { if (!absl::GetFlag(FLAGS_write_apm_ref_data)) {
const int kIntNear = 1; const int kIntNear = 1;
// When running the test on a N7 we get a {2, 6} difference of // When running the test on a N7 we get a {2, 6} difference of
// |has_voice_count| and |max_output_average| is up to 18 higher. // `has_voice_count` and `max_output_average` is up to 18 higher.
// All numbers being consistently higher on N7 compare to ref_data. // All numbers being consistently higher on N7 compare to ref_data.
// TODO(bjornv): If we start getting more of these offsets on Android we // TODO(bjornv): If we start getting more of these offsets on Android we
// should consider a different approach. Either using one slack for all, // should consider a different approach. Either using one slack for all,
@ -2058,7 +2058,7 @@ class AudioProcessingTest
static void TearDownTestSuite() { ClearTempFiles(); } static void TearDownTestSuite() { ClearTempFiles(); }
// Runs a process pass on files with the given parameters and dumps the output // Runs a process pass on files with the given parameters and dumps the output
// to a file specified with |output_file_prefix|. Both forward and reverse // to a file specified with `output_file_prefix`. Both forward and reverse
// output streams are dumped. // output streams are dumped.
static void ProcessFormat(int input_rate, static void ProcessFormat(int input_rate,
int output_rate, int output_rate,
@ -2277,7 +2277,7 @@ TEST_P(AudioProcessingTest, Formats) {
out_ptr = cmp_data.get(); out_ptr = cmp_data.get();
} }
// Update the |sq_error| and |variance| accumulators with the highest // Update the `sq_error` and `variance` accumulators with the highest
// SNR of reference vs output. // SNR of reference vs output.
UpdateBestSNR(ref_data.get(), out_ptr, ref_length, expected_delay, UpdateBestSNR(ref_data.get(), out_ptr, ref_length, expected_delay,
&variance, &sq_error); &variance, &sq_error);

View file

@ -42,7 +42,7 @@ class EchoControlMobileImpl {
kLoudSpeakerphone kLoudSpeakerphone
}; };
// Sets echo control appropriate for the audio routing |mode| on the device. // Sets echo control appropriate for the audio routing `mode` on the device.
// It can and should be updated during a call if the audio routing changes. // It can and should be updated during a call if the audio routing changes.
int set_routing_mode(RoutingMode mode); int set_routing_mode(RoutingMode mode);
RoutingMode routing_mode() const; RoutingMode routing_mode() const;

View file

@ -27,7 +27,7 @@ namespace test {
namespace { namespace {
void SetAudioBufferSamples(float value, AudioBuffer* ab) { void SetAudioBufferSamples(float value, AudioBuffer* ab) {
// Sets all the samples in |ab| to |value|. // Sets all the samples in `ab` to `value`.
for (size_t k = 0; k < ab->num_channels(); ++k) { for (size_t k = 0; k < ab->num_channels(); ++k) {
std::fill(ab->channels()[k], ab->channels()[k] + ab->num_frames(), value); std::fill(ab->channels()[k], ab->channels()[k] + ab->num_frames(), value);
} }

View file

@ -16,21 +16,21 @@ namespace webrtc {
class AudioFrame; class AudioFrame;
class AudioProcessing; class AudioProcessing;
// Processes a 10 ms |frame| of the primary audio stream using the provided // Processes a 10 ms `frame` of the primary audio stream using the provided
// AudioProcessing object. On the client-side, this is the near-end (or // AudioProcessing object. On the client-side, this is the near-end (or
// captured) audio. The |sample_rate_hz_|, |num_channels_|, and // captured) audio. The `sample_rate_hz_`, `num_channels_`, and
// |samples_per_channel_| members of |frame| must be valid. If changed from the // `samples_per_channel_` members of `frame` must be valid. If changed from the
// previous call to this function, it will trigger an initialization of the // previous call to this function, it will trigger an initialization of the
// provided AudioProcessing object. // provided AudioProcessing object.
// The function returns any error codes passed from the AudioProcessing // The function returns any error codes passed from the AudioProcessing
// ProcessStream method. // ProcessStream method.
int ProcessAudioFrame(AudioProcessing* ap, AudioFrame* frame); int ProcessAudioFrame(AudioProcessing* ap, AudioFrame* frame);
// Processes a 10 ms |frame| of the reverse direction audio stream using the // Processes a 10 ms `frame` of the reverse direction audio stream using the
// provided AudioProcessing object. The frame may be modified. On the // provided AudioProcessing object. The frame may be modified. On the
// client-side, this is the far-end (or to be rendered) audio. The // client-side, this is the far-end (or to be rendered) audio. The
// |sample_rate_hz_|, |num_channels_|, and |samples_per_channel_| members of // `sample_rate_hz_`, `num_channels_`, and `samples_per_channel_` members of
// |frame| must be valid. If changed from the previous call to this function, it // `frame` must be valid. If changed from the previous call to this function, it
// will trigger an initialization of the provided AudioProcessing object. // will trigger an initialization of the provided AudioProcessing object.
// The function returns any error codes passed from the AudioProcessing // The function returns any error codes passed from the AudioProcessing
// ProcessReverseStream method. // ProcessReverseStream method.

View file

@ -19,8 +19,8 @@ namespace webrtc {
template <class T> template <class T>
class AudioFrameView { class AudioFrameView {
public: public:
// |num_channels| and |channel_size| describe the T** // `num_channels` and `channel_size` describe the T**
// |audio_samples|. |audio_samples| is assumed to point to a // `audio_samples`. `audio_samples` is assumed to point to a
// two-dimensional |num_channels * channel_size| array of floats. // two-dimensional |num_channels * channel_size| array of floats.
AudioFrameView(T* const* audio_samples, AudioFrameView(T* const* audio_samples,
size_t num_channels, size_t num_channels,

View file

@ -53,7 +53,7 @@ class CustomAudioAnalyzer;
class CustomProcessing; class CustomProcessing;
// Use to enable experimental gain control (AGC). At startup the experimental // Use to enable experimental gain control (AGC). At startup the experimental
// AGC moves the microphone volume up to |startup_min_volume| if the current // AGC moves the microphone volume up to `startup_min_volume` if the current
// microphone volume is set too low. The value is clamped to its operating range // microphone volume is set too low. The value is clamped to its operating range
// [12, 255]. Here, 255 maps to 100%. // [12, 255]. Here, 255 maps to 100%.
// //
@ -99,8 +99,8 @@ struct ExperimentalNs {
// //
// APM operates on two audio streams on a frame-by-frame basis. Frames of the // APM operates on two audio streams on a frame-by-frame basis. Frames of the
// primary stream, on which all processing is applied, are passed to // primary stream, on which all processing is applied, are passed to
// |ProcessStream()|. Frames of the reverse direction stream are passed to // `ProcessStream()`. Frames of the reverse direction stream are passed to
// |ProcessReverseStream()|. On the client-side, this will typically be the // `ProcessReverseStream()`. On the client-side, this will typically be the
// near-end (capture) and far-end (render) streams, respectively. APM should be // near-end (capture) and far-end (render) streams, respectively. APM should be
// placed in the signal chain as close to the audio hardware abstraction layer // placed in the signal chain as close to the audio hardware abstraction layer
// (HAL) as possible. // (HAL) as possible.
@ -264,7 +264,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
bool enabled = false; bool enabled = false;
} transient_suppression; } transient_suppression;
// Enables reporting of |voice_detected| in webrtc::AudioProcessingStats. // Enables reporting of `voice_detected` in webrtc::AudioProcessingStats.
struct VoiceDetection { struct VoiceDetection {
bool enabled = false; bool enabled = false;
} voice_detection; } voice_detection;
@ -377,7 +377,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
// Enables the next generation AGC functionality. This feature replaces the // Enables the next generation AGC functionality. This feature replaces the
// standard methods of gain control in the previous AGC. Enabling this // standard methods of gain control in the previous AGC. Enabling this
// submodule enables an adaptive digital AGC followed by a limiter. By // submodule enables an adaptive digital AGC followed by a limiter. By
// setting |fixed_gain_db|, the limiter can be turned into a compressor that // setting `fixed_gain_db`, the limiter can be turned into a compressor that
// first applies a fixed gain. The adaptive digital AGC can be turned off by // first applies a fixed gain. The adaptive digital AGC can be turned off by
// setting |adaptive_digital_mode=false|. // setting |adaptive_digital_mode=false|.
struct RTC_EXPORT GainController2 { struct RTC_EXPORT GainController2 {
@ -425,7 +425,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
bool enabled = true; bool enabled = true;
} residual_echo_detector; } residual_echo_detector;
// Enables reporting of |output_rms_dbfs| in webrtc::AudioProcessingStats. // Enables reporting of `output_rms_dbfs` in webrtc::AudioProcessingStats.
struct LevelEstimation { struct LevelEstimation {
bool enabled = false; bool enabled = false;
} level_estimation; } level_estimation;
@ -501,7 +501,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
} }
// Creates a runtime setting to notify play-out (aka render) volume changes. // Creates a runtime setting to notify play-out (aka render) volume changes.
// |volume| is the unnormalized volume, the maximum of which // `volume` is the unnormalized volume, the maximum of which
static RuntimeSetting CreatePlayoutVolumeChange(int volume) { static RuntimeSetting CreatePlayoutVolumeChange(int volume) {
return {Type::kPlayoutVolumeChange, volume}; return {Type::kPlayoutVolumeChange, volume};
} }
@ -562,13 +562,13 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
// //
// It is also not necessary to call if the audio parameters (sample // It is also not necessary to call if the audio parameters (sample
// rate and number of channels) have changed. Passing updated parameters // rate and number of channels) have changed. Passing updated parameters
// directly to |ProcessStream()| and |ProcessReverseStream()| is permissible. // directly to `ProcessStream()` and `ProcessReverseStream()` is permissible.
// If the parameters are known at init-time though, they may be provided. // If the parameters are known at init-time though, they may be provided.
// TODO(webrtc:5298): Change to return void. // TODO(webrtc:5298): Change to return void.
virtual int Initialize() = 0; virtual int Initialize() = 0;
// The int16 interfaces require: // The int16 interfaces require:
// - only |NativeRate|s be used // - only `NativeRate`s be used
// - that the input, output and reverse rates must match // - that the input, output and reverse rates must match
// - that |processing_config.output_stream()| matches // - that |processing_config.output_stream()| matches
// |processing_config.input_stream()|. // |processing_config.input_stream()|.
@ -616,7 +616,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
virtual bool PostRuntimeSetting(RuntimeSetting setting) = 0; virtual bool PostRuntimeSetting(RuntimeSetting setting) = 0;
// Accepts and produces a 10 ms frame interleaved 16 bit integer audio as // Accepts and produces a 10 ms frame interleaved 16 bit integer audio as
// specified in |input_config| and |output_config|. |src| and |dest| may use // specified in `input_config` and `output_config`. `src` and `dest` may use
// the same memory, if desired. // the same memory, if desired.
virtual int ProcessStream(const int16_t* const src, virtual int ProcessStream(const int16_t* const src,
const StreamConfig& input_config, const StreamConfig& input_config,
@ -624,35 +624,35 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
int16_t* const dest) = 0; int16_t* const dest) = 0;
// Accepts deinterleaved float audio with the range [-1, 1]. Each element of // Accepts deinterleaved float audio with the range [-1, 1]. Each element of
// |src| points to a channel buffer, arranged according to |input_stream|. At // `src` points to a channel buffer, arranged according to `input_stream`. At
// output, the channels will be arranged according to |output_stream| in // output, the channels will be arranged according to `output_stream` in
// |dest|. // `dest`.
// //
// The output must have one channel or as many channels as the input. |src| // The output must have one channel or as many channels as the input. `src`
// and |dest| may use the same memory, if desired. // and `dest` may use the same memory, if desired.
virtual int ProcessStream(const float* const* src, virtual int ProcessStream(const float* const* src,
const StreamConfig& input_config, const StreamConfig& input_config,
const StreamConfig& output_config, const StreamConfig& output_config,
float* const* dest) = 0; float* const* dest) = 0;
// Accepts and produces a 10 ms frame of interleaved 16 bit integer audio for // Accepts and produces a 10 ms frame of interleaved 16 bit integer audio for
// the reverse direction audio stream as specified in |input_config| and // the reverse direction audio stream as specified in `input_config` and
// |output_config|. |src| and |dest| may use the same memory, if desired. // `output_config`. `src` and `dest` may use the same memory, if desired.
virtual int ProcessReverseStream(const int16_t* const src, virtual int ProcessReverseStream(const int16_t* const src,
const StreamConfig& input_config, const StreamConfig& input_config,
const StreamConfig& output_config, const StreamConfig& output_config,
int16_t* const dest) = 0; int16_t* const dest) = 0;
// Accepts deinterleaved float audio with the range [-1, 1]. Each element of // Accepts deinterleaved float audio with the range [-1, 1]. Each element of
// |data| points to a channel buffer, arranged according to |reverse_config|. // `data` points to a channel buffer, arranged according to `reverse_config`.
virtual int ProcessReverseStream(const float* const* src, virtual int ProcessReverseStream(const float* const* src,
const StreamConfig& input_config, const StreamConfig& input_config,
const StreamConfig& output_config, const StreamConfig& output_config,
float* const* dest) = 0; float* const* dest) = 0;
// Accepts deinterleaved float audio with the range [-1, 1]. Each element // Accepts deinterleaved float audio with the range [-1, 1]. Each element
// of |data| points to a channel buffer, arranged according to // of `data` points to a channel buffer, arranged according to
// |reverse_config|. // `reverse_config`.
virtual int AnalyzeReverseStream(const float* const* data, virtual int AnalyzeReverseStream(const float* const* data,
const StreamConfig& reverse_config) = 0; const StreamConfig& reverse_config) = 0;
@ -675,7 +675,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
// This must be called if and only if echo processing is enabled. // This must be called if and only if echo processing is enabled.
// //
// Sets the |delay| in ms between ProcessReverseStream() receiving a far-end // Sets the `delay` in ms between ProcessReverseStream() receiving a far-end
// frame and ProcessStream() receiving a near-end frame containing the // frame and ProcessStream() receiving a near-end frame containing the
// corresponding echo. On the client-side this can be expressed as // corresponding echo. On the client-side this can be expressed as
// delay = (t_render - t_analyze) + (t_process - t_capture) // delay = (t_render - t_analyze) + (t_process - t_capture)
@ -695,10 +695,10 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
// Creates and attaches an webrtc::AecDump for recording debugging // Creates and attaches an webrtc::AecDump for recording debugging
// information. // information.
// The |worker_queue| may not be null and must outlive the created // The `worker_queue` may not be null and must outlive the created
// AecDump instance. |max_log_size_bytes == -1| means the log size // AecDump instance. |max_log_size_bytes == -1| means the log size
// will be unlimited. |handle| may not be null. The AecDump takes // will be unlimited. `handle` may not be null. The AecDump takes
// responsibility for |handle| and closes it in the destructor. A // responsibility for `handle` and closes it in the destructor. A
// return value of true indicates that the file has been // return value of true indicates that the file has been
// sucessfully opened, while a value of false indicates that // sucessfully opened, while a value of false indicates that
// opening the file failed. // opening the file failed.
@ -726,7 +726,7 @@ class RTC_EXPORT AudioProcessing : public rtc::RefCountInterface {
// Get audio processing statistics. // Get audio processing statistics.
virtual AudioProcessingStats GetStatistics() = 0; virtual AudioProcessingStats GetStatistics() = 0;
// TODO(webrtc:5298) Deprecated variant. The |has_remote_tracks| argument // TODO(webrtc:5298) Deprecated variant. The `has_remote_tracks` argument
// should be set if there are active remote tracks (this would usually be true // should be set if there are active remote tracks (this would usually be true
// during a call). If there are no remote tracks some of the stats will not be // during a call). If there are no remote tracks some of the stats will not be
// set by AudioProcessing, because they only make sense if there is at least // set by AudioProcessing, because they only make sense if there is at least

View file

@ -50,9 +50,9 @@ struct RTC_EXPORT AudioProcessingStats {
// The delay metrics consists of the delay median and standard deviation. It // The delay metrics consists of the delay median and standard deviation. It
// also consists of the fraction of delay estimates that can make the echo // also consists of the fraction of delay estimates that can make the echo
// cancellation perform poorly. The values are aggregated until the first // cancellation perform poorly. The values are aggregated until the first
// call to |GetStatistics()| and afterwards aggregated and updated every // call to `GetStatistics()` and afterwards aggregated and updated every
// second. Note that if there are several clients pulling metrics from // second. Note that if there are several clients pulling metrics from
// |GetStatistics()| during a session the first call from any of them will // `GetStatistics()` during a session the first call from any of them will
// change to one second aggregation window for all. // change to one second aggregation window for all.
absl::optional<int32_t> delay_median_ms; absl::optional<int32_t> delay_median_ms;
absl::optional<int32_t> delay_standard_deviation_ms; absl::optional<int32_t> delay_standard_deviation_ms;
@ -64,7 +64,7 @@ struct RTC_EXPORT AudioProcessingStats {
// The instantaneous delay estimate produced in the AEC. The unit is in // The instantaneous delay estimate produced in the AEC. The unit is in
// milliseconds and the value is the instantaneous value at the time of the // milliseconds and the value is the instantaneous value at the time of the
// call to |GetStatistics()|. // call to `GetStatistics()`.
absl::optional<int32_t> delay_ms; absl::optional<int32_t> delay_ms;
}; };

View file

@ -35,7 +35,7 @@ class LevelEstimator {
// The computation follows: https://tools.ietf.org/html/rfc6465 // The computation follows: https://tools.ietf.org/html/rfc6465
// with the intent that it can provide the RTP audio level indication. // with the intent that it can provide the RTP audio level indication.
// //
// Frames passed to ProcessStream() with an |_energy| of zero are considered // Frames passed to ProcessStream() with an `_energy` of zero are considered
// to have been muted. The RMS of the frame will be interpreted as -127. // to have been muted. The RMS of the frame will be interpreted as -127.
int RMS() { return rms_.Average(); } int RMS() { return rms_.Average(); }

View file

@ -20,7 +20,7 @@ namespace webrtc {
// These overrides are only to be used for testing purposes. // These overrides are only to be used for testing purposes.
// Each flag emulates a preprocessor macro to exclude a submodule of APM from // Each flag emulates a preprocessor macro to exclude a submodule of APM from
// the build, e.g. WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR. If the corresponding // the build, e.g. WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR. If the corresponding
// flag |transient_suppression| is enabled, then the creators will return // flag `transient_suppression` is enabled, then the creators will return
// nullptr instead of a submodule instance, as if the macro had been defined. // nullptr instead of a submodule instance, as if the macro had been defined.
struct ApmSubmoduleCreationOverrides { struct ApmSubmoduleCreationOverrides {
bool transient_suppression = false; bool transient_suppression = false;
@ -29,7 +29,7 @@ struct ApmSubmoduleCreationOverrides {
// Creates a transient suppressor. // Creates a transient suppressor.
// Will instead return nullptr if one of the following is true: // Will instead return nullptr if one of the following is true:
// * WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR is defined // * WEBRTC_EXCLUDE_TRANSIENT_SUPPRESSOR is defined
// * The corresponding override in |overrides| is enabled. // * The corresponding override in `overrides` is enabled.
std::unique_ptr<TransientSuppressor> CreateTransientSuppressor( std::unique_ptr<TransientSuppressor> CreateTransientSuppressor(
const ApmSubmoduleCreationOverrides& overrides); const ApmSubmoduleCreationOverrides& overrides);

View file

@ -51,12 +51,12 @@ class ResidualEchoDetector : public EchoDetector {
private: private:
static int instance_count_; static int instance_count_;
std::unique_ptr<ApmDataDumper> data_dumper_; std::unique_ptr<ApmDataDumper> data_dumper_;
// Keep track if the |Process| function has been previously called. // Keep track if the `Process` function has been previously called.
bool first_process_call_ = true; bool first_process_call_ = true;
// Buffer for storing the power of incoming farend buffers. This is needed for // Buffer for storing the power of incoming farend buffers. This is needed for
// cases where calls to BufferFarend and Process are jittery. // cases where calls to BufferFarend and Process are jittery.
CircularBuffer render_buffer_; CircularBuffer render_buffer_;
// Count how long ago it was that the size of |render_buffer_| was zero. This // Count how long ago it was that the size of `render_buffer_` was zero. This
// value is also reset to zero when clock drift is detected and a value from // value is also reset to zero when clock drift is detected and a value from
// the renderbuffer is discarded, even though the buffer is not actually zero // the renderbuffer is discarded, even though the buffer is not actually zero
// at that point. This is done to avoid repeatedly removing elements in this // at that point. This is done to avoid repeatedly removing elements in this

View file

@ -47,7 +47,7 @@ class RmsLevel {
void Analyze(rtc::ArrayView<const int16_t> data); void Analyze(rtc::ArrayView<const int16_t> data);
void Analyze(rtc::ArrayView<const float> data); void Analyze(rtc::ArrayView<const float> data);
// If all samples with the given |length| have a magnitude of zero, this is // If all samples with the given `length` have a magnitude of zero, this is
// a shortcut to avoid some computation. // a shortcut to avoid some computation.
void AnalyzeMuted(size_t length); void AnalyzeMuted(size_t length);
@ -62,7 +62,7 @@ class RmsLevel {
Levels AverageAndPeak(); Levels AverageAndPeak();
private: private:
// Compares |block_size| with |block_size_|. If they are different, calls // Compares `block_size` with `block_size_`. If they are different, calls
// Reset() and stores the new size. // Reset() and stores the new size.
void CheckBlockSize(size_t block_size); void CheckBlockSize(size_t block_size);

View file

@ -206,7 +206,7 @@ void AudioProcessingSimulator::ProcessStream(bool fixed_interface) {
if (settings_.simulate_mic_gain) { if (settings_.simulate_mic_gain) {
if (settings_.aec_dump_input_filename) { if (settings_.aec_dump_input_filename) {
// When the analog gain is simulated and an AEC dump is used as input, set // When the analog gain is simulated and an AEC dump is used as input, set
// the undo level to |aec_dump_mic_level_| to virtually restore the // the undo level to `aec_dump_mic_level_` to virtually restore the
// unmodified microphone signal level. // unmodified microphone signal level.
fake_recording_device_.SetUndoMicLevel(aec_dump_mic_level_); fake_recording_device_.SetUndoMicLevel(aec_dump_mic_level_);
} }
@ -261,7 +261,7 @@ void AudioProcessingSimulator::ProcessStream(bool fixed_interface) {
// Store the mic level suggested by AGC. // Store the mic level suggested by AGC.
// Note that when the analog gain is simulated and an AEC dump is used as // Note that when the analog gain is simulated and an AEC dump is used as
// input, |analog_mic_level_| will not be used with set_stream_analog_level(). // input, `analog_mic_level_` will not be used with set_stream_analog_level().
analog_mic_level_ = ap_->recommended_stream_analog_level(); analog_mic_level_ = ap_->recommended_stream_analog_level();
if (settings_.simulate_mic_gain) { if (settings_.simulate_mic_gain) {
fake_recording_device_.SetMicLevel(analog_mic_level_); fake_recording_device_.SetMicLevel(analog_mic_level_);

View file

@ -19,11 +19,11 @@ namespace webrtc {
namespace test { namespace test {
// This function implements the audio processing simulation utility. Pass // This function implements the audio processing simulation utility. Pass
// |input_aecdump| to provide the content of an AEC dump file as a string; if // `input_aecdump` to provide the content of an AEC dump file as a string; if
// |input_aecdump| is not passed, a WAV or AEC input dump file must be specified // `input_aecdump` is not passed, a WAV or AEC input dump file must be specified
// via the |argv| argument. Pass |processed_capture_samples| to write in it the // via the `argv` argument. Pass `processed_capture_samples` to write in it the
// samples processed on the capture side; if |processed_capture_samples| is not // samples processed on the capture side; if `processed_capture_samples` is not
// passed, the output file can optionally be specified via the |argv| argument. // passed, the output file can optionally be specified via the `argv` argument.
// Any audio_processing object specified in the input is used for the // Any audio_processing object specified in the input is used for the
// simulation. Note that when the audio_processing object is specified all // simulation. Note that when the audio_processing object is specified all
// functionality that relies on using the internal builder is deactivated, // functionality that relies on using the internal builder is deactivated,
@ -34,11 +34,11 @@ int AudioprocFloatImpl(rtc::scoped_refptr<AudioProcessing> audio_processing,
char* argv[]); char* argv[]);
// This function implements the audio processing simulation utility. Pass // This function implements the audio processing simulation utility. Pass
// |input_aecdump| to provide the content of an AEC dump file as a string; if // `input_aecdump` to provide the content of an AEC dump file as a string; if
// |input_aecdump| is not passed, a WAV or AEC input dump file must be specified // `input_aecdump` is not passed, a WAV or AEC input dump file must be specified
// via the |argv| argument. Pass |processed_capture_samples| to write in it the // via the `argv` argument. Pass `processed_capture_samples` to write in it the
// samples processed on the capture side; if |processed_capture_samples| is not // samples processed on the capture side; if `processed_capture_samples` is not
// passed, the output file can optionally be specified via the |argv| argument. // passed, the output file can optionally be specified via the `argv` argument.
int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder, int AudioprocFloatImpl(std::unique_ptr<AudioProcessingBuilder> ap_builder,
int argc, int argc,
char* argv[], char* argv[],

View file

@ -125,8 +125,8 @@ std::unique_ptr<std::map<std::string, std::vector<int16_t>>> PreloadAudioTracks(
return audiotracks_map; return audiotracks_map;
} }
// Writes all the values in |source_samples| via |wav_writer|. If the number of // Writes all the values in `source_samples` via `wav_writer`. If the number of
// previously written samples in |wav_writer| is less than |interval_begin|, it // previously written samples in `wav_writer` is less than `interval_begin`, it
// adds zeros as left padding. The padding corresponds to intervals during which // adds zeros as left padding. The padding corresponds to intervals during which
// a speaker is not active. // a speaker is not active.
void PadLeftWriteChunk(rtc::ArrayView<const int16_t> source_samples, void PadLeftWriteChunk(rtc::ArrayView<const int16_t> source_samples,
@ -145,9 +145,9 @@ void PadLeftWriteChunk(rtc::ArrayView<const int16_t> source_samples,
wav_writer->WriteSamples(source_samples.data(), source_samples.size()); wav_writer->WriteSamples(source_samples.data(), source_samples.size());
} }
// Appends zeros via |wav_writer|. The number of zeros is always non-negative // Appends zeros via `wav_writer`. The number of zeros is always non-negative
// and equal to the difference between the previously written samples and // and equal to the difference between the previously written samples and
// |pad_samples|. // `pad_samples`.
void PadRightWrite(WavWriter* wav_writer, size_t pad_samples) { void PadRightWrite(WavWriter* wav_writer, size_t pad_samples) {
RTC_CHECK(wav_writer); RTC_CHECK(wav_writer);
RTC_CHECK_GE(pad_samples, wav_writer->num_samples()); RTC_CHECK_GE(pad_samples, wav_writer->num_samples());

View file

@ -52,14 +52,14 @@ class FakeRecordingDevice final {
void SetUndoMicLevel(const int level); void SetUndoMicLevel(const int level);
// Simulates the analog gain. // Simulates the analog gain.
// If |real_device_level| is a valid level, the unmodified mic signal is // If `real_device_level` is a valid level, the unmodified mic signal is
// virtually restored. To skip the latter step set |real_device_level| to // virtually restored. To skip the latter step set `real_device_level` to
// an empty value. // an empty value.
void SimulateAnalogGain(rtc::ArrayView<int16_t> buffer); void SimulateAnalogGain(rtc::ArrayView<int16_t> buffer);
// Simulates the analog gain. // Simulates the analog gain.
// If |real_device_level| is a valid level, the unmodified mic signal is // If `real_device_level` is a valid level, the unmodified mic signal is
// virtually restored. To skip the latter step set |real_device_level| to // virtually restored. To skip the latter step set `real_device_level` to
// an empty value. // an empty value.
void SimulateAnalogGain(ChannelBuffer<float>* buffer); void SimulateAnalogGain(ChannelBuffer<float>* buffer);

View file

@ -75,7 +75,7 @@ void CheckIfMonotoneSamplesModules(const ChannelBuffer<float>* prev,
} }
// Checks that the samples in each pair have the same sign unless the sample in // Checks that the samples in each pair have the same sign unless the sample in
// |dst| is zero (because of zero gain). // `dst` is zero (because of zero gain).
void CheckSameSign(const ChannelBuffer<float>* src, void CheckSameSign(const ChannelBuffer<float>* src,
const ChannelBuffer<float>* dst) { const ChannelBuffer<float>* dst) {
RTC_DCHECK_EQ(src->num_channels(), dst->num_channels()); RTC_DCHECK_EQ(src->num_channels(), dst->num_channels());

View file

@ -31,7 +31,7 @@ class PerformanceTimer {
double GetDurationStandardDeviation() const; double GetDurationStandardDeviation() const;
// These methods are the same as those above, but they ignore the first // These methods are the same as those above, but they ignore the first
// |number_of_warmup_samples| measurements. // `number_of_warmup_samples` measurements.
double GetDurationAverage(size_t number_of_warmup_samples) const; double GetDurationAverage(size_t number_of_warmup_samples) const;
double GetDurationStandardDeviation(size_t number_of_warmup_samples) const; double GetDurationStandardDeviation(size_t number_of_warmup_samples) const;

View file

@ -88,7 +88,7 @@ def FilterScoresByParams(data_frame, filter_params, score_name, config_dir):
data_cell_scores = data_with_config[data_with_config.eval_score_name == data_cell_scores = data_with_config[data_with_config.eval_score_name ==
score_name] score_name]
# Exactly one of |params_to_plot| must match: # Exactly one of `params_to_plot` must match:
(matching_param, ) = [ (matching_param, ) = [
x for x in filter_params if '-' + x in config_json x for x in filter_params if '-' + x in config_json
] ]

View file

@ -133,7 +133,7 @@ def _FindOptimalParameter(configs_and_scores, score_weighting):
{score1: value1, ...}}] into a numeric {score1: value1, ...}}] into a numeric
value value
Returns: Returns:
the config that has the largest values of |score_weighting| applied the config that has the largest values of `score_weighting` applied
to its scores. to its scores.
""" """

View file

@ -397,7 +397,7 @@ class TotalHarmonicDistorsionScore(EvaluationScore):
# TODO(alessiob): Fix or remove if not needed. # TODO(alessiob): Fix or remove if not needed.
# thd = np.sqrt(np.sum(b_terms[1:]**2)) / b_terms[0] # thd = np.sqrt(np.sum(b_terms[1:]**2)) / b_terms[0]
# TODO(alessiob): Check the range of |thd_plus_noise| and update the class # TODO(alessiob): Check the range of `thd_plus_noise` and update the class
# docstring above if accordingly. # docstring above if accordingly.
thd_plus_noise = distortion_and_noise / b_terms[0] thd_plus_noise = distortion_and_noise / b_terms[0]

View file

@ -363,7 +363,7 @@ class HtmlExport(object):
@classmethod @classmethod
def _SliceDataForScoreStatsTableCell(cls, scores, capture, render, def _SliceDataForScoreStatsTableCell(cls, scores, capture, render,
echo_simulator): echo_simulator):
"""Slices |scores| to extract the data for a tab.""" """Slices `scores` to extract the data for a tab."""
masks = [] masks = []
masks.append(scores.capture == capture) masks.append(scores.capture == capture)
@ -378,7 +378,7 @@ class HtmlExport(object):
@classmethod @classmethod
def _FindUniqueTuples(cls, data_frame, fields): def _FindUniqueTuples(cls, data_frame, fields):
"""Slices |data_frame| to a list of fields and finds unique tuples.""" """Slices `data_frame` to a list of fields and finds unique tuples."""
return data_frame[fields].drop_duplicates().values.tolist() return data_frame[fields].drop_duplicates().values.tolist()
@classmethod @classmethod

View file

@ -47,7 +47,7 @@ class ApmInputMixer(object):
Hard-clipping may occur in the mix; a warning is raised when this happens. Hard-clipping may occur in the mix; a warning is raised when this happens.
If |echo_filepath| is None, nothing is done and |capture_input_filepath| is If `echo_filepath` is None, nothing is done and `capture_input_filepath` is
returned. returned.
Args: Args:

View file

@ -174,7 +174,7 @@ class SignalProcessingUtils(object):
"""Detects hard clipping. """Detects hard clipping.
Hard clipping is simply detected by counting samples that touch either the Hard clipping is simply detected by counting samples that touch either the
lower or upper bound too many times in a row (according to |threshold|). lower or upper bound too many times in a row (according to `threshold`).
The presence of a single sequence of samples meeting such property is enough The presence of a single sequence of samples meeting such property is enough
to label the signal as hard clipped. to label the signal as hard clipped.
@ -295,16 +295,16 @@ class SignalProcessingUtils(object):
noise, noise,
target_snr=0.0, target_snr=0.0,
pad_noise=MixPadding.NO_PADDING): pad_noise=MixPadding.NO_PADDING):
"""Mixes |signal| and |noise| with a target SNR. """Mixes `signal` and `noise` with a target SNR.
Mix |signal| and |noise| with a desired SNR by scaling |noise|. Mix `signal` and `noise` with a desired SNR by scaling `noise`.
If the target SNR is +/- infinite, a copy of signal/noise is returned. If the target SNR is +/- infinite, a copy of signal/noise is returned.
If |signal| is shorter than |noise|, the length of the mix equals that of If `signal` is shorter than `noise`, the length of the mix equals that of
|signal|. Otherwise, the mix length depends on whether padding is applied. `signal`. Otherwise, the mix length depends on whether padding is applied.
When padding is not applied, that is |pad_noise| is set to NO_PADDING When padding is not applied, that is `pad_noise` is set to NO_PADDING
(default), the mix length equals that of |noise| - i.e., |signal| is (default), the mix length equals that of `noise` - i.e., `signal` is
truncated. Otherwise, |noise| is extended and the resulting mix has the same truncated. Otherwise, `noise` is extended and the resulting mix has the same
length of |signal|. length of `signal`.
Args: Args:
signal: AudioSegment instance (signal). signal: AudioSegment instance (signal).
@ -342,18 +342,18 @@ class SignalProcessingUtils(object):
signal_duration = len(signal) signal_duration = len(signal)
noise_duration = len(noise) noise_duration = len(noise)
if signal_duration <= noise_duration: if signal_duration <= noise_duration:
# Ignore |pad_noise|, |noise| is truncated if longer that |signal|, the # Ignore `pad_noise`, `noise` is truncated if longer that `signal`, the
# mix will have the same length of |signal|. # mix will have the same length of `signal`.
return signal.overlay(noise.apply_gain(gain_db)) return signal.overlay(noise.apply_gain(gain_db))
elif pad_noise == cls.MixPadding.NO_PADDING: elif pad_noise == cls.MixPadding.NO_PADDING:
# |signal| is longer than |noise|, but no padding is applied to |noise|. # `signal` is longer than `noise`, but no padding is applied to `noise`.
# Truncate |signal|. # Truncate `signal`.
return noise.overlay(signal, gain_during_overlay=gain_db) return noise.overlay(signal, gain_during_overlay=gain_db)
elif pad_noise == cls.MixPadding.ZERO_PADDING: elif pad_noise == cls.MixPadding.ZERO_PADDING:
# TODO(alessiob): Check that this works as expected. # TODO(alessiob): Check that this works as expected.
return signal.overlay(noise.apply_gain(gain_db)) return signal.overlay(noise.apply_gain(gain_db))
elif pad_noise == cls.MixPadding.LOOP: elif pad_noise == cls.MixPadding.LOOP:
# |signal| is longer than |noise|, extend |noise| by looping. # `signal` is longer than `noise`, extend `noise` by looping.
return signal.overlay(noise.apply_gain(gain_db), loop=True) return signal.overlay(noise.apply_gain(gain_db), loop=True)
else: else:
raise exceptions.SignalProcessingException('invalid padding type') raise exceptions.SignalProcessingException('invalid padding type')

View file

@ -264,7 +264,7 @@ class ApmModuleSimulator(object):
The file name is parsed to extract input signal creator and params. If a The file name is parsed to extract input signal creator and params. If a
creator is matched and the parameters are valid, a new signal is generated creator is matched and the parameters are valid, a new signal is generated
and written in |input_signal_filepath|. and written in `input_signal_filepath`.
Args: Args:
input_signal_filepath: Path to the input signal audio file to write. input_signal_filepath: Path to the input signal audio file to write.

View file

@ -116,7 +116,7 @@ class TestTestDataGenerators(unittest.TestCase):
key = noisy_signal_filepaths.keys()[0] key = noisy_signal_filepaths.keys()[0]
return noisy_signal_filepaths[key], reference_signal_filepaths[key] return noisy_signal_filepaths[key], reference_signal_filepaths[key]
# Test the |copy_with_identity| flag. # Test the `copy_with_identity` flag.
for copy_with_identity in [False, True]: for copy_with_identity in [False, True]:
# Instance the generator through the factory. # Instance the generator through the factory.
factory = test_data_generation_factory.TestDataGeneratorFactory( factory = test_data_generation_factory.TestDataGeneratorFactory(
@ -126,7 +126,7 @@ class TestTestDataGenerators(unittest.TestCase):
factory.SetOutputDirectoryPrefix('datagen-') factory.SetOutputDirectoryPrefix('datagen-')
generator = factory.GetInstance( generator = factory.GetInstance(
test_data_generation.IdentityTestDataGenerator) test_data_generation.IdentityTestDataGenerator)
# Check |copy_with_identity| is set correctly. # Check `copy_with_identity` is set correctly.
self.assertEqual(copy_with_identity, generator.copy_with_identity) self.assertEqual(copy_with_identity, generator.copy_with_identity)
# Generate test data and extract the paths to the noise and the reference # Generate test data and extract the paths to the noise and the reference
@ -137,7 +137,7 @@ class TestTestDataGenerators(unittest.TestCase):
noisy_signal_filepath, reference_signal_filepath = ( noisy_signal_filepath, reference_signal_filepath = (
GetNoiseReferenceFilePaths(generator)) GetNoiseReferenceFilePaths(generator))
# Check that a copy is made if and only if |copy_with_identity| is True. # Check that a copy is made if and only if `copy_with_identity` is True.
if copy_with_identity: if copy_with_identity:
self.assertNotEqual(noisy_signal_filepath, self.assertNotEqual(noisy_signal_filepath,
input_signal_filepath) input_signal_filepath)

View file

@ -63,7 +63,7 @@ int main(int argc, char* argv[]) {
std::unique_ptr<Vad> vad = CreateVad(Vad::Aggressiveness::kVadNormal); std::unique_ptr<Vad> vad = CreateVad(Vad::Aggressiveness::kVadNormal);
std::array<int16_t, kMaxFrameLen> samples; std::array<int16_t, kMaxFrameLen> samples;
char buff = 0; // Buffer to write one bit per frame. char buff = 0; // Buffer to write one bit per frame.
uint8_t next = 0; // Points to the next bit to write in |buff|. uint8_t next = 0; // Points to the next bit to write in `buff`.
while (true) { while (true) {
// Process frame. // Process frame.
const auto read_samples = const auto read_samples =

View file

@ -78,7 +78,7 @@ class ChannelBufferWavReader final {
explicit ChannelBufferWavReader(std::unique_ptr<WavReader> file); explicit ChannelBufferWavReader(std::unique_ptr<WavReader> file);
~ChannelBufferWavReader(); ~ChannelBufferWavReader();
// Reads data from the file according to the |buffer| format. Returns false if // Reads data from the file according to the `buffer` format. Returns false if
// a full buffer can't be read from the file. // a full buffer can't be read from the file.
bool Read(ChannelBuffer<float>* buffer); bool Read(ChannelBuffer<float>* buffer);
@ -115,7 +115,7 @@ class ChannelBufferVectorWriter final {
delete; delete;
~ChannelBufferVectorWriter(); ~ChannelBufferVectorWriter();
// Creates an interleaved copy of |buffer|, converts the samples to float S16 // Creates an interleaved copy of `buffer`, converts the samples to float S16
// and appends the result to output_. // and appends the result to output_.
void Write(const ChannelBuffer<float>& buffer); void Write(const ChannelBuffer<float>& buffer);

View file

@ -39,16 +39,16 @@
namespace webrtc { namespace webrtc {
namespace { namespace {
// Factors to take into account when choosing |kFilterSize|: // Factors to take into account when choosing `kFilterSize`:
// 1. Higher |kFilterSize|, means faster transition, which ensures less // 1. Higher `kFilterSize`, means faster transition, which ensures less
// aliasing. This is especially important when there is non-linear // aliasing. This is especially important when there is non-linear
// processing between the splitting and merging. // processing between the splitting and merging.
// 2. The delay that this filter bank introduces is // 2. The delay that this filter bank introduces is
// |kNumBands| * |kSparsity| * |kFilterSize| / 2, so it increases linearly // `kNumBands` * `kSparsity` * `kFilterSize` / 2, so it increases linearly
// with |kFilterSize|. // with `kFilterSize`.
// 3. The computation complexity also increases linearly with |kFilterSize|. // 3. The computation complexity also increases linearly with `kFilterSize`.
// The Matlab code to generate these |kFilterCoeffs| is: // The Matlab code to generate these `kFilterCoeffs` is:
// //
// N = kNumBands * kSparsity * kFilterSize - 1; // N = kNumBands * kSparsity * kFilterSize - 1;
// h = fir1(N, 1 / (2 * kNumBands), kaiser(N + 1, 3.5)); // h = fir1(N, 1 / (2 * kNumBands), kaiser(N + 1, 3.5));
@ -59,7 +59,7 @@ namespace {
// Because the total bandwidth of the lower and higher band is double the middle // Because the total bandwidth of the lower and higher band is double the middle
// one (because of the spectrum parity), the low-pass prototype is half the // one (because of the spectrum parity), the low-pass prototype is half the
// bandwidth of 1 / (2 * |kNumBands|) and is then shifted with cosine modulation // bandwidth of 1 / (2 * `kNumBands`) and is then shifted with cosine modulation
// to the right places. // to the right places.
// A Kaiser window is used because of its flexibility and the alpha is set to // A Kaiser window is used because of its flexibility and the alpha is set to
// 3.5, since that sets a stop band attenuation of 40dB ensuring a fast // 3.5, since that sets a stop band attenuation of 40dB ensuring a fast
@ -100,8 +100,8 @@ const float kDctModulation[ThreeBandFilterBank::kNumNonZeroFilters][kDctSize] =
{1.f, -2.f, 1.f}, {1.f, -2.f, 1.f},
{1.73205077f, 0.f, -1.73205077f}}; {1.73205077f, 0.f, -1.73205077f}};
// Filters the input signal |in| with the filter |filter| using a shift by // Filters the input signal `in` with the filter `filter` using a shift by
// |in_shift|, taking into account the previous state. // `in_shift`, taking into account the previous state.
void FilterCore( void FilterCore(
rtc::ArrayView<const float, kFilterSize> filter, rtc::ArrayView<const float, kFilterSize> filter,
rtc::ArrayView<const float, ThreeBandFilterBank::kSplitBandSize> in, rtc::ArrayView<const float, ThreeBandFilterBank::kSplitBandSize> in,
@ -164,10 +164,10 @@ ThreeBandFilterBank::ThreeBandFilterBank() {
ThreeBandFilterBank::~ThreeBandFilterBank() = default; ThreeBandFilterBank::~ThreeBandFilterBank() = default;
// The analysis can be separated in these steps: // The analysis can be separated in these steps:
// 1. Serial to parallel downsampling by a factor of |kNumBands|. // 1. Serial to parallel downsampling by a factor of `kNumBands`.
// 2. Filtering of |kSparsity| different delayed signals with polyphase // 2. Filtering of `kSparsity` different delayed signals with polyphase
// decomposition of the low-pass prototype filter and upsampled by a factor // decomposition of the low-pass prototype filter and upsampled by a factor
// of |kSparsity|. // of `kSparsity`.
// 3. Modulating with cosines and accumulating to get the desired band. // 3. Modulating with cosines and accumulating to get the desired band.
void ThreeBandFilterBank::Analysis( void ThreeBandFilterBank::Analysis(
rtc::ArrayView<const float, kFullBandSize> in, rtc::ArrayView<const float, kFullBandSize> in,
@ -222,9 +222,9 @@ void ThreeBandFilterBank::Analysis(
// The synthesis can be separated in these steps: // The synthesis can be separated in these steps:
// 1. Modulating with cosines. // 1. Modulating with cosines.
// 2. Filtering each one with a polyphase decomposition of the low-pass // 2. Filtering each one with a polyphase decomposition of the low-pass
// prototype filter upsampled by a factor of |kSparsity| and accumulating // prototype filter upsampled by a factor of `kSparsity` and accumulating
// |kSparsity| signals with different delays. // `kSparsity` signals with different delays.
// 3. Parallel to serial upsampling by a factor of |kNumBands|. // 3. Parallel to serial upsampling by a factor of `kNumBands`.
void ThreeBandFilterBank::Synthesis( void ThreeBandFilterBank::Synthesis(
rtc::ArrayView<const rtc::ArrayView<float>, ThreeBandFilterBank::kNumBands> rtc::ArrayView<const rtc::ArrayView<float>, ThreeBandFilterBank::kNumBands>
in, in,

View file

@ -55,13 +55,13 @@ class ThreeBandFilterBank final {
ThreeBandFilterBank(); ThreeBandFilterBank();
~ThreeBandFilterBank(); ~ThreeBandFilterBank();
// Splits |in| of size kFullBandSize into 3 downsampled frequency bands in // Splits `in` of size kFullBandSize into 3 downsampled frequency bands in
// |out|, each of size 160. // `out`, each of size 160.
void Analysis(rtc::ArrayView<const float, kFullBandSize> in, void Analysis(rtc::ArrayView<const float, kFullBandSize> in,
rtc::ArrayView<const rtc::ArrayView<float>, kNumBands> out); rtc::ArrayView<const rtc::ArrayView<float>, kNumBands> out);
// Merges the 3 downsampled frequency bands in |in|, each of size 160, into // Merges the 3 downsampled frequency bands in `in`, each of size 160, into
// |out|, which is of size kFullBandSize. // `out`, which is of size kFullBandSize.
void Synthesis(rtc::ArrayView<const rtc::ArrayView<float>, kNumBands> in, void Synthesis(rtc::ArrayView<const rtc::ArrayView<float>, kNumBands> in,
rtc::ArrayView<float, kFullBandSize> out); rtc::ArrayView<float, kFullBandSize> out);

View file

@ -26,7 +26,7 @@ using webrtc::TransientDetector;
// Creates a send times array, one for each step. // Creates a send times array, one for each step.
// Each block that contains a transient, has an infinite send time. // Each block that contains a transient, has an infinite send time.
// The resultant array is written to a DAT file // The resultant array is written to a DAT file
// Returns -1 on error or |lost_packets| otherwise. // Returns -1 on error or `lost_packets` otherwise.
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
if (argc != 5) { if (argc != 5) {
printf("\n%s - Application to generate a RTP timing file.\n\n", argv[0]); printf("\n%s - Application to generate a RTP timing file.\n\n", argv[0]);

View file

@ -18,7 +18,7 @@
namespace webrtc { namespace webrtc {
// Returns the proper length of the output buffer that you should use for the // Returns the proper length of the output buffer that you should use for the
// given |in_length| and decimation |odd_sequence|. // given `in_length` and decimation `odd_sequence`.
// Return -1 on error. // Return -1 on error.
inline size_t GetOutLengthToDyadicDecimate(size_t in_length, inline size_t GetOutLengthToDyadicDecimate(size_t in_length,
bool odd_sequence) { bool odd_sequence) {
@ -34,10 +34,10 @@ inline size_t GetOutLengthToDyadicDecimate(size_t in_length,
// Performs a dyadic decimation: removes every odd/even member of a sequence // Performs a dyadic decimation: removes every odd/even member of a sequence
// halving its overall length. // halving its overall length.
// Arguments: // Arguments:
// in: array of |in_length|. // in: array of `in_length`.
// odd_sequence: If false, the odd members will be removed (1, 3, 5, ...); // odd_sequence: If false, the odd members will be removed (1, 3, 5, ...);
// if true, the even members will be removed (0, 2, 4, ...). // if true, the even members will be removed (0, 2, 4, ...).
// out: array of |out_length|. |out_length| must be large enough to // out: array of `out_length`. `out_length` must be large enough to
// hold the decimated output. The necessary length can be provided by // hold the decimated output. The necessary length can be provided by
// GetOutLengthToDyadicDecimate(). // GetOutLengthToDyadicDecimate().
// Must be previously allocated. // Must be previously allocated.

View file

@ -42,7 +42,7 @@ TEST(DyadicDecimatorTest, DyadicDecimateErrorValues) {
static_cast<int16_t*>(NULL), kOutBufferLength); static_cast<int16_t*>(NULL), kOutBufferLength);
EXPECT_EQ(0u, out_samples); EXPECT_EQ(0u, out_samples);
// Less than required |out_length|. // Less than required `out_length`.
out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength, out_samples = DyadicDecimate(test_buffer_even_len, kEvenBufferLength,
false, // Even sequence. false, // Even sequence.
test_buffer_out, 2); test_buffer_out, 2);

View file

@ -50,63 +50,63 @@ int ConvertFloatToByteArray(float value, uint8_t out_bytes[4]);
// Returns 0 if correct, -1 on error. // Returns 0 if correct, -1 on error.
int ConvertDoubleToByteArray(double value, uint8_t out_bytes[8]); int ConvertDoubleToByteArray(double value, uint8_t out_bytes[8]);
// Reads |length| 16-bit integers from |file| to |buffer|. // Reads `length` 16-bit integers from `file` to `buffer`.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of 16-bit integers read or -1 on error. // Returns the number of 16-bit integers read or -1 on error.
size_t ReadInt16BufferFromFile(FileWrapper* file, size_t ReadInt16BufferFromFile(FileWrapper* file,
size_t length, size_t length,
int16_t* buffer); int16_t* buffer);
// Reads |length| 16-bit integers from |file| and stores those values // Reads `length` 16-bit integers from `file` and stores those values
// (converting them) in |buffer|. // (converting them) in `buffer`.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of 16-bit integers read or -1 on error. // Returns the number of 16-bit integers read or -1 on error.
size_t ReadInt16FromFileToFloatBuffer(FileWrapper* file, size_t ReadInt16FromFileToFloatBuffer(FileWrapper* file,
size_t length, size_t length,
float* buffer); float* buffer);
// Reads |length| 16-bit integers from |file| and stores those values // Reads `length` 16-bit integers from `file` and stores those values
// (converting them) in |buffer|. // (converting them) in `buffer`.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of 16-bit integers read or -1 on error. // Returns the number of 16-bit integers read or -1 on error.
size_t ReadInt16FromFileToDoubleBuffer(FileWrapper* file, size_t ReadInt16FromFileToDoubleBuffer(FileWrapper* file,
size_t length, size_t length,
double* buffer); double* buffer);
// Reads |length| floats in binary representation (4 bytes) from |file| to // Reads `length` floats in binary representation (4 bytes) from `file` to
// |buffer|. // `buffer`.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of floats read or -1 on error. // Returns the number of floats read or -1 on error.
size_t ReadFloatBufferFromFile(FileWrapper* file, size_t length, float* buffer); size_t ReadFloatBufferFromFile(FileWrapper* file, size_t length, float* buffer);
// Reads |length| doubles in binary representation (8 bytes) from |file| to // Reads `length` doubles in binary representation (8 bytes) from `file` to
// |buffer|. // `buffer`.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of doubles read or -1 on error. // Returns the number of doubles read or -1 on error.
size_t ReadDoubleBufferFromFile(FileWrapper* file, size_t ReadDoubleBufferFromFile(FileWrapper* file,
size_t length, size_t length,
double* buffer); double* buffer);
// Writes |length| 16-bit integers from |buffer| in binary representation (2 // Writes `length` 16-bit integers from `buffer` in binary representation (2
// bytes) to |file|. It flushes |file|, so after this call there are no // bytes) to `file`. It flushes `file`, so after this call there are no
// writings pending. // writings pending.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of doubles written or -1 on error. // Returns the number of doubles written or -1 on error.
size_t WriteInt16BufferToFile(FileWrapper* file, size_t WriteInt16BufferToFile(FileWrapper* file,
size_t length, size_t length,
const int16_t* buffer); const int16_t* buffer);
// Writes |length| floats from |buffer| in binary representation (4 bytes) to // Writes `length` floats from `buffer` in binary representation (4 bytes) to
// |file|. It flushes |file|, so after this call there are no writtings pending. // `file`. It flushes `file`, so after this call there are no writtings pending.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of doubles written or -1 on error. // Returns the number of doubles written or -1 on error.
size_t WriteFloatBufferToFile(FileWrapper* file, size_t WriteFloatBufferToFile(FileWrapper* file,
size_t length, size_t length,
const float* buffer); const float* buffer);
// Writes |length| doubles from |buffer| in binary representation (8 bytes) to // Writes `length` doubles from `buffer` in binary representation (8 bytes) to
// |file|. It flushes |file|, so after this call there are no writings pending. // `file`. It flushes `file`, so after this call there are no writings pending.
// |file| must be previously opened. // `file` must be previously opened.
// Returns the number of doubles written or -1 on error. // Returns the number of doubles written or -1 on error.
size_t WriteDoubleBufferToFile(FileWrapper* file, size_t WriteDoubleBufferToFile(FileWrapper* file,
size_t length, size_t length,

View file

@ -26,13 +26,13 @@ namespace webrtc {
// the last values of the moments. When needed. // the last values of the moments. When needed.
class MovingMoments { class MovingMoments {
public: public:
// Creates a Moving Moments object, that uses the last |length| values // Creates a Moving Moments object, that uses the last `length` values
// (including the new value introduced in every new calculation). // (including the new value introduced in every new calculation).
explicit MovingMoments(size_t length); explicit MovingMoments(size_t length);
~MovingMoments(); ~MovingMoments();
// Calculates the new values using |in|. Results will be in the out buffers. // Calculates the new values using `in`. Results will be in the out buffers.
// |first| and |second| must be allocated with at least |in_length|. // `first` and `second` must be allocated with at least `in_length`.
void CalculateMoments(const float* in, void CalculateMoments(const float* in,
size_t in_length, size_t in_length,
float* first, float* first,
@ -40,7 +40,7 @@ class MovingMoments {
private: private:
size_t length_; size_t length_;
// A queue holding the |length_| latest input values. // A queue holding the `length_` latest input values.
std::queue<float> queue_; std::queue<float> queue_;
// Sum of the values of the queue. // Sum of the values of the queue.
float sum_; float sum_;

View file

@ -43,8 +43,8 @@ TransientDetector::TransientDetector(int sample_rate_hz)
sample_rate_hz == ts::kSampleRate48kHz); sample_rate_hz == ts::kSampleRate48kHz);
int samples_per_transient = sample_rate_hz * kTransientLengthMs / 1000; int samples_per_transient = sample_rate_hz * kTransientLengthMs / 1000;
// Adjustment to avoid data loss while downsampling, making // Adjustment to avoid data loss while downsampling, making
// |samples_per_chunk_| and |samples_per_transient| always divisible by // `samples_per_chunk_` and `samples_per_transient` always divisible by
// |kLeaves|. // `kLeaves`.
samples_per_chunk_ -= samples_per_chunk_ % kLeaves; samples_per_chunk_ -= samples_per_chunk_ % kLeaves;
samples_per_transient -= samples_per_transient % kLeaves; samples_per_transient -= samples_per_transient % kLeaves;
@ -137,7 +137,7 @@ float TransientDetector::Detect(const float* data,
// In the current implementation we return the max of the current result and // In the current implementation we return the max of the current result and
// the previous results, so the high results have a width equals to // the previous results, so the high results have a width equals to
// |transient_length|. // `transient_length`.
return *std::max_element(previous_results_.begin(), previous_results_.end()); return *std::max_element(previous_results_.begin(), previous_results_.end());
} }

View file

@ -37,8 +37,8 @@ class TransientDetector {
~TransientDetector(); ~TransientDetector();
// Calculates the log-likelihood of the existence of a transient in |data|. // Calculates the log-likelihood of the existence of a transient in `data`.
// |data_length| has to be equal to |samples_per_chunk_|. // `data_length` has to be equal to `samples_per_chunk_`.
// Returns a value between 0 and 1, as a non linear representation of this // Returns a value between 0 and 1, as a non linear representation of this
// likelihood. // likelihood.
// Returns a negative value on error. // Returns a negative value on error.
@ -71,7 +71,7 @@ class TransientDetector {
float last_second_moment_[kLeaves]; float last_second_moment_[kLeaves];
// We keep track of the previous results from the previous chunks, so it can // We keep track of the previous results from the previous chunks, so it can
// be used to effectively give results according to the |transient_length|. // be used to effectively give results according to the `transient_length`.
std::deque<float> previous_results_; std::deque<float> previous_results_;
// Number of chunks that are going to return only zeros at the beginning of // Number of chunks that are going to return only zeros at the beginning of

View file

@ -27,22 +27,22 @@ class TransientSuppressor {
int detector_rate_hz, int detector_rate_hz,
int num_channels) = 0; int num_channels) = 0;
// Processes a |data| chunk, and returns it with keystrokes suppressed from // Processes a `data` chunk, and returns it with keystrokes suppressed from
// it. The float format is assumed to be int16 ranged. If there are more than // it. The float format is assumed to be int16 ranged. If there are more than
// one channel, the chunks are concatenated one after the other in |data|. // one channel, the chunks are concatenated one after the other in `data`.
// |data_length| must be equal to |data_length_|. // `data_length` must be equal to `data_length_`.
// |num_channels| must be equal to |num_channels_|. // `num_channels` must be equal to `num_channels_`.
// A sub-band, ideally the higher, can be used as |detection_data|. If it is // A sub-band, ideally the higher, can be used as `detection_data`. If it is
// NULL, |data| is used for the detection too. The |detection_data| is always // NULL, `data` is used for the detection too. The `detection_data` is always
// assumed mono. // assumed mono.
// If a reference signal (e.g. keyboard microphone) is available, it can be // If a reference signal (e.g. keyboard microphone) is available, it can be
// passed in as |reference_data|. It is assumed mono and must have the same // passed in as `reference_data`. It is assumed mono and must have the same
// length as |data|. NULL is accepted if unavailable. // length as `data`. NULL is accepted if unavailable.
// This suppressor performs better if voice information is available. // This suppressor performs better if voice information is available.
// |voice_probability| is the probability of voice being present in this chunk // `voice_probability` is the probability of voice being present in this chunk
// of audio. If voice information is not available, |voice_probability| must // of audio. If voice information is not available, `voice_probability` must
// always be set to 1. // always be set to 1.
// |key_pressed| determines if a key was pressed on this audio chunk. // `key_pressed` determines if a key was pressed on this audio chunk.
// Returns 0 on success and -1 otherwise. // Returns 0 on success and -1 otherwise.
virtual int Suppress(float* data, virtual int Suppress(float* data,
size_t data_length, size_t data_length,

View file

@ -194,7 +194,7 @@ int TransientSuppressorImpl::Suppress(float* data,
using_reference_ = detector_->using_reference(); using_reference_ = detector_->using_reference();
// |detector_smoothed_| follows the |detector_result| when this last one is // `detector_smoothed_` follows the `detector_result` when this last one is
// increasing, but has an exponential decaying tail to be able to suppress // increasing, but has an exponential decaying tail to be able to suppress
// the ringing of keyclicks. // the ringing of keyclicks.
float smooth_factor = using_reference_ ? 0.6 : 0.1; float smooth_factor = using_reference_ ? 0.6 : 0.1;
@ -223,7 +223,7 @@ int TransientSuppressorImpl::Suppress(float* data,
} }
// This should only be called when detection is enabled. UpdateBuffers() must // This should only be called when detection is enabled. UpdateBuffers() must
// have been called. At return, |out_buffer_| will be filled with the // have been called. At return, `out_buffer_` will be filled with the
// processed output. // processed output.
void TransientSuppressorImpl::Suppress(float* in_ptr, void TransientSuppressorImpl::Suppress(float* in_ptr,
float* spectral_mean, float* spectral_mean,
@ -325,7 +325,7 @@ void TransientSuppressorImpl::UpdateRestoration(float voice_probability) {
} }
// Shift buffers to make way for new data. Must be called after // Shift buffers to make way for new data. Must be called after
// |detection_enabled_| is updated by UpdateKeypress(). // `detection_enabled_` is updated by UpdateKeypress().
void TransientSuppressorImpl::UpdateBuffers(float* data) { void TransientSuppressorImpl::UpdateBuffers(float* data) {
// TODO(aluebs): Change to ring buffer. // TODO(aluebs): Change to ring buffer.
memmove(in_buffer_.get(), &in_buffer_[data_length_], memmove(in_buffer_.get(), &in_buffer_[data_length_],
@ -350,9 +350,9 @@ void TransientSuppressorImpl::UpdateBuffers(float* data) {
} }
// Restores the unvoiced signal if a click is present. // Restores the unvoiced signal if a click is present.
// Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds // Attenuates by a certain factor every peak in the `fft_buffer_` that exceeds
// the spectral mean. The attenuation depends on |detector_smoothed_|. // the spectral mean. The attenuation depends on `detector_smoothed_`.
// If a restoration takes place, the |magnitudes_| are updated to the new value. // If a restoration takes place, the `magnitudes_` are updated to the new value.
void TransientSuppressorImpl::HardRestoration(float* spectral_mean) { void TransientSuppressorImpl::HardRestoration(float* spectral_mean) {
const float detector_result = const float detector_result =
1.f - std::pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f); 1.f - std::pow(1.f - detector_smoothed_, using_reference_ ? 200.f : 50.f);
@ -376,10 +376,10 @@ void TransientSuppressorImpl::HardRestoration(float* spectral_mean) {
} }
// Restores the voiced signal if a click is present. // Restores the voiced signal if a click is present.
// Attenuates by a certain factor every peak in the |fft_buffer_| that exceeds // Attenuates by a certain factor every peak in the `fft_buffer_` that exceeds
// the spectral mean and that is lower than some function of the current block // the spectral mean and that is lower than some function of the current block
// frequency mean. The attenuation depends on |detector_smoothed_|. // frequency mean. The attenuation depends on `detector_smoothed_`.
// If a restoration takes place, the |magnitudes_| are updated to the new value. // If a restoration takes place, the `magnitudes_` are updated to the new value.
void TransientSuppressorImpl::SoftRestoration(float* spectral_mean) { void TransientSuppressorImpl::SoftRestoration(float* spectral_mean) {
// Get the spectral magnitude mean of the current block. // Get the spectral magnitude mean of the current block.
float block_frequency_mean = 0; float block_frequency_mean = 0;

View file

@ -34,22 +34,22 @@ class TransientSuppressorImpl : public TransientSuppressor {
int detector_rate_hz, int detector_rate_hz,
int num_channels) override; int num_channels) override;
// Processes a |data| chunk, and returns it with keystrokes suppressed from // Processes a `data` chunk, and returns it with keystrokes suppressed from
// it. The float format is assumed to be int16 ranged. If there are more than // it. The float format is assumed to be int16 ranged. If there are more than
// one channel, the chunks are concatenated one after the other in |data|. // one channel, the chunks are concatenated one after the other in `data`.
// |data_length| must be equal to |data_length_|. // `data_length` must be equal to `data_length_`.
// |num_channels| must be equal to |num_channels_|. // `num_channels` must be equal to `num_channels_`.
// A sub-band, ideally the higher, can be used as |detection_data|. If it is // A sub-band, ideally the higher, can be used as `detection_data`. If it is
// NULL, |data| is used for the detection too. The |detection_data| is always // NULL, `data` is used for the detection too. The `detection_data` is always
// assumed mono. // assumed mono.
// If a reference signal (e.g. keyboard microphone) is available, it can be // If a reference signal (e.g. keyboard microphone) is available, it can be
// passed in as |reference_data|. It is assumed mono and must have the same // passed in as `reference_data`. It is assumed mono and must have the same
// length as |data|. NULL is accepted if unavailable. // length as `data`. NULL is accepted if unavailable.
// This suppressor performs better if voice information is available. // This suppressor performs better if voice information is available.
// |voice_probability| is the probability of voice being present in this chunk // `voice_probability` is the probability of voice being present in this chunk
// of audio. If voice information is not available, |voice_probability| must // of audio. If voice information is not available, `voice_probability` must
// always be set to 1. // always be set to 1.
// |key_pressed| determines if a key was pressed on this audio chunk. // `key_pressed` determines if a key was pressed on this audio chunk.
// Returns 0 on success and -1 otherwise. // Returns 0 on success and -1 otherwise.
int Suppress(float* data, int Suppress(float* data,
size_t data_length, size_t data_length,

View file

@ -25,7 +25,7 @@ class WPDNode {
WPDNode(size_t length, const float* coefficients, size_t coefficients_length); WPDNode(size_t length, const float* coefficients, size_t coefficients_length);
~WPDNode(); ~WPDNode();
// Updates the node data. |parent_data| / 2 must be equals to |length_|. // Updates the node data. `parent_data` / 2 must be equals to `length_`.
// Returns 0 if correct, and -1 otherwise. // Returns 0 if correct, and -1 otherwise.
int Update(const float* parent_data, size_t parent_data_length); int Update(const float* parent_data, size_t parent_data_length);

View file

@ -65,7 +65,7 @@ class WPDTree {
// If level or index are out of bounds the function will return NULL. // If level or index are out of bounds the function will return NULL.
WPDNode* NodeAt(int level, int index); WPDNode* NodeAt(int level, int index);
// Updates all the nodes of the tree with the new data. |data_length| must be // Updates all the nodes of the tree with the new data. `data_length` must be
// teh same that was used for the creation of the tree. // teh same that was used for the creation of the tree.
// Returns 0 if correct, and -1 otherwise. // Returns 0 if correct, and -1 otherwise.
int Update(const float* data, size_t data_length); int Update(const float* data, size_t data_length);

View file

@ -22,7 +22,7 @@ class RTC_EXPORT TypingDetection {
// Run the detection algortihm. Shall be called every 10 ms. Returns true if // Run the detection algortihm. Shall be called every 10 ms. Returns true if
// typing is detected, or false if not, based on the update period as set with // typing is detected, or false if not, based on the update period as set with
// SetParameters(). See |report_detection_update_period_| description below. // SetParameters(). See `report_detection_update_period_` description below.
bool Process(bool key_pressed, bool vad_activity); bool Process(bool key_pressed, bool vad_activity);
// Gets the time in seconds since the last detection. // Gets the time in seconds since the last detection.
@ -43,14 +43,14 @@ class RTC_EXPORT TypingDetection {
int penalty_counter_; int penalty_counter_;
// Counter since last time the detection status reported by Process() was // Counter since last time the detection status reported by Process() was
// updated. See also |report_detection_update_period_|. // updated. See also `report_detection_update_period_`.
int counter_since_last_detection_update_; int counter_since_last_detection_update_;
// The detection status to report. Updated every // The detection status to report. Updated every
// |report_detection_update_period_| call to Process(). // `report_detection_update_period_` call to Process().
bool detection_to_report_; bool detection_to_report_;
// What |detection_to_report_| should be set to next time it is updated. // What `detection_to_report_` should be set to next time it is updated.
bool new_detection_to_report_; bool new_detection_to_report_;
// Settable threshold values. // Settable threshold values.
@ -61,10 +61,10 @@ class RTC_EXPORT TypingDetection {
// Penalty added for a typing + activity coincide. // Penalty added for a typing + activity coincide.
int cost_per_typing_; int cost_per_typing_;
// Threshold for |penalty_counter_|. // Threshold for `penalty_counter_`.
int reporting_threshold_; int reporting_threshold_;
// How much we reduce |penalty_counter_| every 10 ms. // How much we reduce `penalty_counter_` every 10 ms.
int penalty_decay_; int penalty_decay_;
// How old typing events we allow. // How old typing events we allow.

View file

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

View file

@ -81,7 +81,7 @@ void WebRtc_FreeBinaryDelayEstimatorFarend(BinaryDelayEstimatorFarend* self);
// //
// Return value: // Return value:
// - BinaryDelayEstimatorFarend* // - 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 // or if any of the input parameters are invalid NULL
// is returned. // is returned.
// //
@ -159,7 +159,7 @@ BinaryDelayEstimator* WebRtc_CreateBinaryDelayEstimator(
BinaryDelayEstimatorFarend* farend, BinaryDelayEstimatorFarend* farend,
int max_lookahead); 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. // updated at the same time if needed.
// //
// Input: // Input:
@ -237,7 +237,7 @@ int WebRtc_binary_last_delay(BinaryDelayEstimator* self);
// delay value. // delay value.
float WebRtc_binary_last_delay_quality(BinaryDelayEstimator* self); 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 // function is used internally in the Binary Delay Estimator as well as the
// Fixed point wrapper. // Fixed point wrapper.
// //

View file

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

View file

@ -80,7 +80,7 @@ DelayEstimatorTest::DelayEstimatorTest()
memset(far_u16_, 1, sizeof(far_u16_)); memset(far_u16_, 1, sizeof(far_u16_));
memset(near_u16_, 2, sizeof(near_u16_)); memset(near_u16_, 2, sizeof(near_u16_));
// Construct a sequence of binary spectra used to verify delay estimate. The // Construct a sequence of binary spectra used to verify delay estimate. The
// |kSequenceLength| has to be long enough for the delay estimation to leave // `kSequenceLength` has to be long enough for the delay estimation to leave
// the initialized state. // the initialized state.
binary_spectrum_[0] = 1; binary_spectrum_[0] = 1;
for (int i = 1; i < (kSequenceLength + kHistorySize); i++) { for (int i = 1; i < (kSequenceLength + kHistorySize); i++) {
@ -132,7 +132,7 @@ void DelayEstimatorTest::InitBinary() {
// Initialize Binary Delay Estimator // Initialize Binary Delay Estimator
WebRtc_InitBinaryDelayEstimator(binary_); WebRtc_InitBinaryDelayEstimator(binary_);
// Verify initialization. This does not guarantee a complete check, since // Verify initialization. This does not guarantee a complete check, since
// |last_delay| may be equal to -2 before initialization if done on the fly. // `last_delay` may be equal to -2 before initialization if done on the fly.
EXPECT_EQ(-2, binary_->last_delay); EXPECT_EQ(-2, binary_->last_delay);
} }
@ -144,7 +144,7 @@ void DelayEstimatorTest::VerifyDelay(BinaryDelayEstimator* binary_handle,
if (delay != -2) { if (delay != -2) {
// Verify correct delay estimate. In the non-causal case the true delay // Verify correct delay estimate. In the non-causal case the true delay
// is equivalent with the |offset|. // is equivalent with the `offset`.
EXPECT_EQ(offset, delay); EXPECT_EQ(offset, delay);
} }
} }
@ -160,7 +160,7 @@ void DelayEstimatorTest::RunBinarySpectra(BinaryDelayEstimator* binary1,
WebRtc_InitBinaryDelayEstimator(binary1); WebRtc_InitBinaryDelayEstimator(binary1);
WebRtc_InitBinaryDelayEstimator(binary2); WebRtc_InitBinaryDelayEstimator(binary2);
// Verify initialization. This does not guarantee a complete check, since // Verify initialization. This does not guarantee a complete check, since
// |last_delay| may be equal to -2 before initialization if done on the fly. // `last_delay` may be equal to -2 before initialization if done on the fly.
EXPECT_EQ(-2, binary1->last_delay); EXPECT_EQ(-2, binary1->last_delay);
EXPECT_EQ(-2, binary2->last_delay); EXPECT_EQ(-2, binary2->last_delay);
for (int i = kLookahead; i < (kSequenceLength + kLookahead); i++) { for (int i = kLookahead; i < (kSequenceLength + kLookahead); i++) {
@ -174,12 +174,12 @@ void DelayEstimatorTest::RunBinarySpectra(BinaryDelayEstimator* binary1,
VerifyDelay(binary2, VerifyDelay(binary2,
far_offset + kLookahead + lookahead_offset + near_offset, far_offset + kLookahead + lookahead_offset + near_offset,
delay_2); delay_2);
// Expect the two delay estimates to be offset by |lookahead_offset| + // Expect the two delay estimates to be offset by `lookahead_offset` +
// |near_offset| when we have left the initial state. // `near_offset` when we have left the initial state.
if ((delay_1 != -2) && (delay_2 != -2)) { if ((delay_1 != -2) && (delay_2 != -2)) {
EXPECT_EQ(delay_1, delay_2 - lookahead_offset - near_offset); EXPECT_EQ(delay_1, delay_2 - lookahead_offset - near_offset);
} }
// For the case of identical signals |delay_1| and |delay_2| should match // For the case of identical signals `delay_1` and `delay_2` should match
// all the time, unless one of them has robust validation turned on. In // all the time, unless one of them has robust validation turned on. In
// that case the robust validation leaves the initial state faster. // that case the robust validation leaves the initial state faster.
if ((near_offset == 0) && (lookahead_offset == 0)) { if ((near_offset == 0) && (lookahead_offset == 0)) {
@ -208,8 +208,8 @@ void DelayEstimatorTest::RunBinarySpectraTest(int near_offset,
BinaryDelayEstimator* binary2 = WebRtc_CreateBinaryDelayEstimator( BinaryDelayEstimator* binary2 = WebRtc_CreateBinaryDelayEstimator(
binary_farend_, kLookahead + lookahead_offset); binary_farend_, kLookahead + lookahead_offset);
// Verify the delay for both causal and non-causal systems. For causal systems // Verify the delay for both causal and non-causal systems. For causal systems
// the delay is equivalent with a positive |offset| of the far-end sequence. // the delay is equivalent with a positive `offset` of the far-end sequence.
// For non-causal systems the delay is equivalent with a negative |offset| of // For non-causal systems the delay is equivalent with a negative `offset` of
// the far-end sequence. // the far-end sequence.
binary_->robust_validation_enabled = ref_robust_validation; binary_->robust_validation_enabled = ref_robust_validation;
binary2->robust_validation_enabled = robust_validation; binary2->robust_validation_enabled = robust_validation;
@ -242,23 +242,23 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
EXPECT_TRUE(handle == NULL); EXPECT_TRUE(handle == NULL);
// WebRtc_InitDelayEstimatorFarend() and WebRtc_InitDelayEstimator() should // WebRtc_InitDelayEstimatorFarend() and WebRtc_InitDelayEstimator() should
// return -1 if we have a NULL pointer as |handle|. // return -1 if we have a NULL pointer as `handle`.
EXPECT_EQ(-1, WebRtc_InitDelayEstimatorFarend(NULL)); EXPECT_EQ(-1, WebRtc_InitDelayEstimatorFarend(NULL));
EXPECT_EQ(-1, WebRtc_InitDelayEstimator(NULL)); EXPECT_EQ(-1, WebRtc_InitDelayEstimator(NULL));
// WebRtc_AddFarSpectrumFloat() should return -1 if we have: // WebRtc_AddFarSpectrumFloat() should return -1 if we have:
// 1) NULL pointer as |handle|. // 1) NULL pointer as `handle`.
// 2) NULL pointer as far-end spectrum. // 2) NULL pointer as far-end spectrum.
// 3) Incorrect spectrum size. // 3) Incorrect spectrum size.
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(NULL, far_f_, spectrum_size_)); EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(NULL, far_f_, spectrum_size_));
// Use |farend_handle_| which is properly created at SetUp(). // Use `farend_handle_` which is properly created at SetUp().
EXPECT_EQ(-1, EXPECT_EQ(-1,
WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, spectrum_size_)); WebRtc_AddFarSpectrumFloat(farend_handle_, NULL, spectrum_size_));
EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_, EXPECT_EQ(-1, WebRtc_AddFarSpectrumFloat(farend_handle_, far_f_,
spectrum_size_ + 1)); spectrum_size_ + 1));
// WebRtc_AddFarSpectrumFix() should return -1 if we have: // WebRtc_AddFarSpectrumFix() should return -1 if we have:
// 1) NULL pointer as |handle|. // 1) NULL pointer as `handle`.
// 2) NULL pointer as far-end spectrum. // 2) NULL pointer as far-end spectrum.
// 3) Incorrect spectrum size. // 3) Incorrect spectrum size.
// 4) Too high precision in far-end spectrum (Q-domain > 15). // 4) Too high precision in far-end spectrum (Q-domain > 15).
@ -271,8 +271,8 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
spectrum_size_, 16)); spectrum_size_, 16));
// WebRtc_set_history_size() should return -1 if: // WebRtc_set_history_size() should return -1 if:
// 1) |handle| is a NULL. // 1) `handle` is a NULL.
// 2) |history_size| <= 1. // 2) `history_size` <= 1.
EXPECT_EQ(-1, WebRtc_set_history_size(NULL, 1)); EXPECT_EQ(-1, WebRtc_set_history_size(NULL, 1));
EXPECT_EQ(-1, WebRtc_set_history_size(handle_, 1)); EXPECT_EQ(-1, WebRtc_set_history_size(handle_, 1));
// WebRtc_history_size() should return -1 if: // WebRtc_history_size() should return -1 if:
@ -293,43 +293,43 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
EXPECT_EQ(-1, WebRtc_set_lookahead(handle_, -1)); EXPECT_EQ(-1, WebRtc_set_lookahead(handle_, -1));
// WebRtc_set_allowed_offset() should return -1 if we have: // WebRtc_set_allowed_offset() should return -1 if we have:
// 1) NULL pointer as |handle|. // 1) NULL pointer as `handle`.
// 2) |allowed_offset| < 0. // 2) `allowed_offset` < 0.
EXPECT_EQ(-1, WebRtc_set_allowed_offset(NULL, 0)); EXPECT_EQ(-1, WebRtc_set_allowed_offset(NULL, 0));
EXPECT_EQ(-1, WebRtc_set_allowed_offset(handle_, -1)); EXPECT_EQ(-1, WebRtc_set_allowed_offset(handle_, -1));
EXPECT_EQ(-1, WebRtc_get_allowed_offset(NULL)); EXPECT_EQ(-1, WebRtc_get_allowed_offset(NULL));
// WebRtc_enable_robust_validation() should return -1 if we have: // WebRtc_enable_robust_validation() should return -1 if we have:
// 1) NULL pointer as |handle|. // 1) NULL pointer as `handle`.
// 2) Incorrect |enable| value (not 0 or 1). // 2) Incorrect `enable` value (not 0 or 1).
EXPECT_EQ(-1, WebRtc_enable_robust_validation(NULL, kEnable[0])); EXPECT_EQ(-1, WebRtc_enable_robust_validation(NULL, kEnable[0]));
EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, -1)); EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, -1));
EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, 2)); EXPECT_EQ(-1, WebRtc_enable_robust_validation(handle_, 2));
// WebRtc_is_robust_validation_enabled() should return -1 if we have NULL // WebRtc_is_robust_validation_enabled() should return -1 if we have NULL
// pointer as |handle|. // pointer as `handle`.
EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(NULL)); EXPECT_EQ(-1, WebRtc_is_robust_validation_enabled(NULL));
// WebRtc_DelayEstimatorProcessFloat() should return -1 if we have: // WebRtc_DelayEstimatorProcessFloat() should return -1 if we have:
// 1) NULL pointer as |handle|. // 1) NULL pointer as `handle`.
// 2) NULL pointer as near-end spectrum. // 2) NULL pointer as near-end spectrum.
// 3) Incorrect spectrum size. // 3) Incorrect spectrum size.
// 4) Non matching history sizes if multiple delay estimators using the same // 4) Non matching history sizes if multiple delay estimators using the same
// far-end reference. // far-end reference.
EXPECT_EQ(-1, EXPECT_EQ(-1,
WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, spectrum_size_)); WebRtc_DelayEstimatorProcessFloat(NULL, near_f_, spectrum_size_));
// Use |handle_| which is properly created at SetUp(). // Use `handle_` which is properly created at SetUp().
EXPECT_EQ(-1, EXPECT_EQ(-1,
WebRtc_DelayEstimatorProcessFloat(handle_, NULL, spectrum_size_)); WebRtc_DelayEstimatorProcessFloat(handle_, NULL, spectrum_size_));
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_, EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(handle_, near_f_,
spectrum_size_ + 1)); spectrum_size_ + 1));
// |tmp_handle| is already in a non-matching state. // `tmp_handle` is already in a non-matching state.
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle, near_f_, EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFloat(tmp_handle, near_f_,
spectrum_size_)); spectrum_size_));
// WebRtc_DelayEstimatorProcessFix() should return -1 if we have: // WebRtc_DelayEstimatorProcessFix() should return -1 if we have:
// 1) NULL pointer as |handle|. // 1) NULL pointer as `handle`.
// 2) NULL pointer as near-end spectrum. // 2) NULL pointer as near-end spectrum.
// 3) Incorrect spectrum size. // 3) Incorrect spectrum size.
// 4) Too high precision in near-end spectrum (Q-domain > 15). // 4) Too high precision in near-end spectrum (Q-domain > 15).
@ -343,12 +343,12 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfWrapper) {
spectrum_size_ + 1, 0)); spectrum_size_ + 1, 0));
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_, EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(handle_, near_u16_,
spectrum_size_, 16)); spectrum_size_, 16));
// |tmp_handle| is already in a non-matching state. // `tmp_handle` is already in a non-matching state.
EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle, near_u16_, EXPECT_EQ(-1, WebRtc_DelayEstimatorProcessFix(tmp_handle, near_u16_,
spectrum_size_, 0)); spectrum_size_, 0));
WebRtc_FreeDelayEstimator(tmp_handle); WebRtc_FreeDelayEstimator(tmp_handle);
// WebRtc_last_delay() should return -1 if we have a NULL pointer as |handle|. // WebRtc_last_delay() should return -1 if we have a NULL pointer as `handle`.
EXPECT_EQ(-1, WebRtc_last_delay(NULL)); EXPECT_EQ(-1, WebRtc_last_delay(NULL));
// Free any local memory if needed. // Free any local memory if needed.
@ -422,7 +422,7 @@ TEST_F(DelayEstimatorTest, InitializedSpectrumAfterProcess) {
TEST_F(DelayEstimatorTest, CorrectLastDelay) { TEST_F(DelayEstimatorTest, CorrectLastDelay) {
// In this test we verify that we get the correct last delay upon valid call. // In this test we verify that we get the correct last delay upon valid call.
// We simply process the same data until we leave the initialized state // We simply process the same data until we leave the initialized state
// (|last_delay| = -2). Then we compare the Process() output with the // (`last_delay` = -2). Then we compare the Process() output with the
// last_delay() call. // last_delay() call.
// TODO(bjornv): Update quality values for robust validation. // TODO(bjornv): Update quality values for robust validation.
@ -488,8 +488,8 @@ TEST_F(DelayEstimatorTest, CorrectErrorReturnsOfBinaryEstimator) {
BinaryDelayEstimator* binary_handle = binary_; BinaryDelayEstimator* binary_handle = binary_;
// WebRtc_CreateBinaryDelayEstimator() should return -1 if we have a NULL // WebRtc_CreateBinaryDelayEstimator() should return -1 if we have a NULL
// pointer as |binary_farend| or invalid input values. Upon failure, the // pointer as `binary_farend` or invalid input values. Upon failure, the
// |binary_handle| should be NULL. // `binary_handle` should be NULL.
// Make sure we have a non-NULL value at start, so we can detect NULL after // Make sure we have a non-NULL value at start, so we can detect NULL after
// create failure. // create failure.
binary_handle = WebRtc_CreateBinaryDelayEstimator(NULL, kLookahead); binary_handle = WebRtc_CreateBinaryDelayEstimator(NULL, kLookahead);
@ -506,12 +506,12 @@ TEST_F(DelayEstimatorTest, MeanEstimatorFix) {
int32_t mean_value_before = mean_value; int32_t mean_value_before = mean_value;
int32_t new_mean_value = mean_value * 2; int32_t new_mean_value = mean_value * 2;
// Increasing |mean_value|. // Increasing `mean_value`.
WebRtc_MeanEstimatorFix(new_mean_value, 10, &mean_value); WebRtc_MeanEstimatorFix(new_mean_value, 10, &mean_value);
EXPECT_LT(mean_value_before, mean_value); EXPECT_LT(mean_value_before, mean_value);
EXPECT_GT(new_mean_value, mean_value); EXPECT_GT(new_mean_value, mean_value);
// Decreasing |mean_value|. // Decreasing `mean_value`.
new_mean_value = mean_value / 2; new_mean_value = mean_value / 2;
mean_value_before = mean_value; mean_value_before = mean_value;
WebRtc_MeanEstimatorFix(new_mean_value, 10, &mean_value); WebRtc_MeanEstimatorFix(new_mean_value, 10, &mean_value);
@ -569,7 +569,7 @@ TEST_F(DelayEstimatorTest, ExactDelayEstimateMultipleNearDifferentLookahead) {
TEST_F(DelayEstimatorTest, AllowedOffsetNoImpactWhenRobustValidationDisabled) { TEST_F(DelayEstimatorTest, AllowedOffsetNoImpactWhenRobustValidationDisabled) {
// The same setup as in ExactDelayEstimateMultipleNearSameSpectrum with the // The same setup as in ExactDelayEstimateMultipleNearSameSpectrum with the
// difference that |allowed_offset| is set for the reference binary delay // difference that `allowed_offset` is set for the reference binary delay
// estimator. // estimator.
binary_->allowed_offset = 10; binary_->allowed_offset = 10;

View file

@ -19,8 +19,8 @@
namespace webrtc { namespace webrtc {
// Only bit |kBandFirst| through bit |kBandLast| are processed and // Only bit `kBandFirst` through bit `kBandLast` are processed and
// |kBandFirst| - |kBandLast| must be < 32. // `kBandFirst` - `kBandLast` must be < 32.
enum { kBandFirst = 12 }; enum { kBandFirst = 12 };
enum { kBandLast = 43 }; enum { kBandLast = 43 };
@ -48,8 +48,8 @@ static void MeanEstimatorFloat(float new_value,
*mean_value += (new_value - *mean_value) * scale; *mean_value += (new_value - *mean_value) * scale;
} }
// Computes the binary spectrum by comparing the input |spectrum| with a // Computes the binary spectrum by comparing the input `spectrum` with a
// |threshold_spectrum|. Float and fixed point versions. // `threshold_spectrum`. Float and fixed point versions.
// //
// Inputs: // Inputs:
// - spectrum : Spectrum of which the binary spectrum should be // - 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); RTC_DCHECK_LT(q_domain, 16);
if (!(*threshold_initialized)) { 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. // value. This speeds up the convergence.
for (i = kBandFirst; i <= kBandLast; i++) { for (i = kBandFirst; i <= kBandLast; i++) {
if (spectrum[i] > 0) { 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); int32_t spectrum_q15 = ((int32_t)spectrum[i]) << (15 - q_domain);
threshold_spectrum[i].int32_ = (spectrum_q15 >> 1); threshold_spectrum[i].int32_ = (spectrum_q15 >> 1);
*threshold_initialized = 1; *threshold_initialized = 1;
@ -81,11 +81,11 @@ static uint32_t BinarySpectrumFix(const uint16_t* spectrum,
} }
} }
for (i = kBandFirst; i <= kBandLast; i++) { 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); 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_)); 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_) { if (spectrum_q15 > threshold_spectrum[i].int32_) {
out = SetBit(out, i - kBandFirst); out = SetBit(out, i - kBandFirst);
} }
@ -102,7 +102,7 @@ static uint32_t BinarySpectrumFloat(const float* spectrum,
const float kScale = 1 / 64.0; const float kScale = 1 / 64.0;
if (!(*threshold_initialized)) { 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. // value. This speeds up the convergence.
for (i = kBandFirst; i <= kBandLast; i++) { for (i = kBandFirst; i <= kBandLast; i++) {
if (spectrum[i] > 0.0f) { if (spectrum[i] > 0.0f) {
@ -113,9 +113,9 @@ static uint32_t BinarySpectrumFloat(const float* spectrum,
} }
for (i = kBandFirst; i <= kBandLast; i++) { for (i = kBandFirst; i <= kBandLast; i++) {
// Update the |threshold_spectrum|. // Update the `threshold_spectrum`.
MeanEstimatorFloat(spectrum[i], kScale, &(threshold_spectrum[i].float_)); 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_) { if (spectrum[i] > threshold_spectrum[i].float_) {
out = SetBit(out, i - kBandFirst); out = SetBit(out, i - kBandFirst);
} }
@ -219,7 +219,7 @@ int WebRtc_AddFarSpectrumFix(void* handle,
return -1; return -1;
} }
if (far_q > 15) { 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; return -1;
} }
@ -433,7 +433,7 @@ int WebRtc_DelayEstimatorProcessFix(void* handle,
return -1; return -1;
} }
if (near_q > 15) { 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; return -1;
} }

View file

@ -35,7 +35,7 @@ void WebRtc_FreeDelayEstimatorFarend(void* handle);
// determined together with WebRtc_set_lookahead(). // determined together with WebRtc_set_lookahead().
// //
// Return value: // 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 // if any of the input parameters are invalid NULL is
// returned. // returned.
void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size); void* WebRtc_CreateDelayEstimatorFarend(int spectrum_size, int history_size);
@ -85,13 +85,13 @@ void WebRtc_FreeDelayEstimator(void* handle);
// WebRtc_CreateDelayEstimatorFarend(). // WebRtc_CreateDelayEstimatorFarend().
// //
// Note that WebRtc_CreateDelayEstimator does not take // 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. // down properly after this instance.
// //
// - max_lookahead : Maximum amount of non-causal lookahead allowed. The // - max_lookahead : Maximum amount of non-causal lookahead allowed. The
// actual amount of lookahead used can be controlled by // actual amount of lookahead used can be controlled by
// WebRtc_set_lookahead(...). The default |lookahead| is // WebRtc_set_lookahead(...). The default `lookahead` is
// set to |max_lookahead| at create time. Use // set to `max_lookahead` at create time. Use
// WebRtc_set_lookahead(...) before start if a different // WebRtc_set_lookahead(...) before start if a different
// value is desired. // value is desired.
// //
@ -106,12 +106,12 @@ void WebRtc_FreeDelayEstimator(void* handle);
// estimated. // estimated.
// //
// Note that the effective range of delay estimates is // Note that the effective range of delay estimates is
// [-|lookahead|,... ,|history_size|-|lookahead|) // [-`lookahead`,... ,`history_size`-`lookahead`)
// where |history_size| is set through // where `history_size` is set through
// WebRtc_set_history_size(). // WebRtc_set_history_size().
// //
// Return value: // 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 // if any of the input parameters are invalid NULL is
// returned. // returned.
void* WebRtc_CreateDelayEstimator(void* farend_handle, int max_lookahead); 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. // - actual_shifts : The actual number of shifts performed.
int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift); int WebRtc_SoftResetDelayEstimator(void* handle, int delay_shift);
// Sets the effective |history_size| used. Valid values from 2. We simply need // 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 // at least two delays to compare to perform an estimate. If `history_size` is
// changed, buffers are reallocated filling in with zeros if necessary. // 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 // 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: // Inputs:
// - handle : Pointer to the delay estimation instance. // - handle : Pointer to the delay estimation instance.
// - history_size : Effective history size to be used. // - 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. // - handle : Pointer to the delay estimation instance.
int WebRtc_history_size(const void* handle); int WebRtc_history_size(const void* handle);
// Sets the amount of |lookahead| to use. Valid values are [0, max_lookahead] // Sets the amount of `lookahead` to use. Valid values are [0, max_lookahead]
// where |max_lookahead| was set at create time through // where `max_lookahead` was set at create time through
// WebRtc_CreateDelayEstimator(...). // WebRtc_CreateDelayEstimator(...).
// //
// Input: // Input:
@ -157,8 +157,8 @@ int WebRtc_history_size(const void* handle);
// - lookahead : The amount of lookahead to be used. // - lookahead : The amount of lookahead to be used.
// //
// Return value: // Return value:
// - new_lookahead : The actual amount of lookahead set, unless |handle| is // - new_lookahead : The actual amount of lookahead set, unless `handle` is
// a NULL pointer or |lookahead| is invalid, for which an // a NULL pointer or `lookahead` is invalid, for which an
// error is returned. // error is returned.
int WebRtc_set_lookahead(void* handle, int lookahead); 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. // - handle : Pointer to the delay estimation instance.
int WebRtc_lookahead(void* handle); 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 // 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 // the echo control filter length minus the expected echo duration, i.e., the
// delay offset the echo control can handle without quality regression. 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. // has to be non-negative.
// Inputs: // Inputs:
// - handle : Pointer to the delay estimation instance. // - handle : Pointer to the delay estimation instance.
@ -180,7 +180,7 @@ int WebRtc_lookahead(void* handle);
// the echo control filter can handle. // the echo control filter can handle.
int WebRtc_set_allowed_offset(void* handle, int allowed_offset); 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); int WebRtc_get_allowed_offset(const void* handle);
// Enables/Disables a robust validation functionality in the delay estimation. // 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 // TODO(https://crbug.com/webrtc/9577): Consider adding a factory and making
// the ctor private. // the ctor private.
// static std::unique_ptr<Pffft> Create(size_t fft_size, // 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::IsValidFftSize()). If not supported, the code will crash.
Pffft(size_t fft_size, FftType fft_type); Pffft(size_t fft_size, FftType fft_type);
Pffft(const Pffft&) = delete; Pffft(const Pffft&) = delete;
@ -73,9 +73,9 @@ class Pffft {
// Computes the backward fast Fourier transform. // Computes the backward fast Fourier transform.
void BackwardTransform(const FloatBuffer& in, FloatBuffer* out, bool ordered); void BackwardTransform(const FloatBuffer& in, FloatBuffer* out, bool ordered);
// Multiplies the frequency components of |fft_x| and |fft_y| and accumulates // Multiplies the frequency components of `fft_x` and `fft_y` and accumulates
// them into |out|. The arrays must have been obtained with // them into `out`. The arrays must have been obtained with
// ForwardTransform(..., /*ordered=*/false) - i.e., |fft_x| and |fft_y| must // ForwardTransform(..., /*ordered=*/false) - i.e., `fft_x` and `fft_y` must
// not be ordered. // not be ordered.
void FrequencyDomainConvolve(const FloatBuffer& fft_x, void FrequencyDomainConvolve(const FloatBuffer& fft_x,
const FloatBuffer& fft_y, const FloatBuffer& fft_y,

View file

@ -20,13 +20,13 @@ namespace webrtc {
// Where a 'mixture' is a Gaussian density. // Where a 'mixture' is a Gaussian density.
struct GmmParameters { struct GmmParameters {
// weight[n] = log(w[n]) - |dimension|/2 * log(2*pi) - 1/2 * log(det(cov[n])); // weight[n] = log(w[n]) - `dimension`/2 * log(2*pi) - 1/2 * log(det(cov[n]));
// where cov[n] is the covariance matrix of mixture n; // where cov[n] is the covariance matrix of mixture n;
const double* weight; const double* weight;
// pointer to the first element of a |num_mixtures|x|dimension| matrix // pointer to the first element of a `num_mixtures`x`dimension` matrix
// where kth row is the mean of the kth mixture. // where kth row is the mean of the kth mixture.
const double* mean; const double* mean;
// pointer to the first element of a |num_mixtures|x|dimension|x|dimension| // pointer to the first element of a `num_mixtures`x`dimension`x`dimension`
// 3D-matrix, where the kth 2D-matrix is the inverse of the covariance // 3D-matrix, where the kth 2D-matrix is the inverse of the covariance
// matrix of the kth mixture. // matrix of the kth mixture.
const double* covar_inverse; const double* covar_inverse;
@ -36,8 +36,8 @@ struct GmmParameters {
int num_mixtures; int num_mixtures;
}; };
// Evaluate the given GMM, according to |gmm_parameters|, at the given point // Evaluate the given GMM, according to `gmm_parameters`, at the given point
// |x|. If the dimensionality of the given GMM is larger that the maximum // `x`. If the dimensionality of the given GMM is larger that the maximum
// acceptable dimension by the following function -1 is returned. // acceptable dimension by the following function -1 is returned.
double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters); double EvaluateGmm(const double* x, const GmmParameters& gmm_parameters);

View file

@ -34,7 +34,7 @@ class PitchBasedVad {
// p_combined: an array which contains the combined activity probabilities // p_combined: an array which contains the combined activity probabilities
// computed prior to the call of this function. The method, // computed prior to the call of this function. The method,
// then, computes the voicing probabilities and combine them // then, computes the voicing probabilities and combine them
// with the given values. The result are returned in |p|. // with the given values. The result are returned in `p`.
int VoicingProbability(const AudioFeatures& features, double* p_combined); int VoicingProbability(const AudioFeatures& features, double* p_combined);
private: private:

View file

@ -14,7 +14,7 @@
namespace webrtc { namespace webrtc {
// TODO(turajs): Write a description of this function. Also be consistent with // TODO(turajs): Write a description of this function. Also be consistent with
// usage of |sampling_rate_hz| vs |kSamplingFreqHz|. // usage of `sampling_rate_hz` vs `kSamplingFreqHz`.
void GetSubframesPitchParameters(int sampling_rate_hz, void GetSubframesPitchParameters(int sampling_rate_hz,
double* gains, double* gains,
double* lags, double* lags,

View file

@ -26,12 +26,12 @@ class StandaloneVad {
// Outputs // Outputs
// p: a buffer where probabilities are written to. // p: a buffer where probabilities are written to.
// length_p: number of elements of |p|. // length_p: number of elements of `p`.
// //
// return value: // return value:
// -1: if no audio is stored or VAD returns error. // -1: if no audio is stored or VAD returns error.
// 0: in success. // 0: in success.
// In case of error the content of |activity| is unchanged. // In case of error the content of `activity` is unchanged.
// //
// Note that due to a high false-positive (VAD decision is active while the // Note that due to a high false-positive (VAD decision is active while the
// processed audio is just background noise) rate, stand-alone VAD is used as // processed audio is just background noise) rate, stand-alone VAD is used as

View file

@ -31,7 +31,7 @@ TEST(StandaloneVadTest, Api) {
for (size_t n = 0; n < kMaxNumFrames; n++) for (size_t n = 0; n < kMaxNumFrames; n++)
EXPECT_EQ(0, vad->AddAudio(data, kLength10Ms)); EXPECT_EQ(0, vad->AddAudio(data, kLength10Ms));
// Pretend |p| is shorter that it should be. // Pretend `p` is shorter that it should be.
EXPECT_EQ(-1, vad->GetActivity(p, kMaxNumFrames - 1)); EXPECT_EQ(-1, vad->GetActivity(p, kMaxNumFrames - 1));
EXPECT_EQ(0, vad->GetActivity(p, kMaxNumFrames)); EXPECT_EQ(0, vad->GetActivity(p, kMaxNumFrames));

View file

@ -132,7 +132,7 @@ void VadAudioProc::SubframeCorrelation(double* corr,
kNumSubframeSamples + kNumPastSignalSamples, kLpcOrder); kNumSubframeSamples + kNumPastSignalSamples, kLpcOrder);
} }
// Compute |kNum10msSubframes| sets of LPC coefficients, one per 10 ms input. // Compute `kNum10msSubframes` sets of LPC coefficients, one per 10 ms input.
// The analysis window is 15 ms long and it is centered on the first half of // The analysis window is 15 ms long and it is centered on the first half of
// each 10ms sub-frame. This is equivalent to computing LPC coefficients for the // each 10ms sub-frame. This is equivalent to computing LPC coefficients for the
// first half of each 10 ms subframe. // first half of each 10 ms subframe.
@ -169,7 +169,7 @@ static float QuadraticInterpolation(float prev_val,
return fractional_index; return fractional_index;
} }
// 1 / A(z), where A(z) is defined by |lpc| is a model of the spectral envelope // 1 / A(z), where A(z) is defined by `lpc` is a model of the spectral envelope
// of the input signal. The local maximum of the spectral envelope corresponds // of the input signal. The local maximum of the spectral envelope corresponds
// with the local minimum of A(z). It saves complexity, as we save one // with the local minimum of A(z). It saves complexity, as we save one
// inversion. Furthermore, we find the first local maximum of magnitude squared, // inversion. Furthermore, we find the first local maximum of magnitude squared,

View file

@ -38,8 +38,8 @@ class VadCircularBuffer {
// The mean value of the elements in the buffer. The return value is zero if // The mean value of the elements in the buffer. The return value is zero if
// buffer is empty, i.e. no value is inserted. // buffer is empty, i.e. no value is inserted.
double Mean(); double Mean();
// Remove transients. If the values exceed |val_threshold| for a period // Remove transients. If the values exceed `val_threshold` for a period
// shorter then or equal to |width_threshold|, then that period is considered // shorter then or equal to `width_threshold`, then that period is considered
// transient and set to zero. // transient and set to zero.
int RemoveTransient(int width_threshold, double val_threshold); int RemoveTransient(int width_threshold, double val_threshold);
@ -49,7 +49,7 @@ class VadCircularBuffer {
// insertion. |index = 1| is the one before the most recent insertion, and // insertion. |index = 1| is the one before the most recent insertion, and
// so on. // so on.
int Get(int index, double* value) const; int Get(int index, double* value) const;
// Set a given position to |value|. |index| is interpreted as above. // Set a given position to `value`. `index` is interpreted as above.
int Set(int index, double value); int Set(int index, double value);
// Return the number of valid elements in the buffer. // Return the number of valid elements in the buffer.
int BufferLevel(); int BufferLevel();

Some files were not shown because too many files have changed in this diff Show more