Reformat the WebRTC code base

Running clang-format with chromium's style guide.

The goal is n-fold:
 * providing consistency and readability (that's what code guidelines are for)
 * preventing noise with presubmit checks and git cl format
 * building on the previous point: making it easier to automatically fix format issues
 * you name it

Please consider using git-hyper-blame to ignore this commit.

Bug: webrtc:9340
Change-Id: I694567c4cdf8cee2860958cfe82bfaf25848bb87
Reviewed-on: https://webrtc-review.googlesource.com/81185
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23660}
This commit is contained in:
Yves Gerey
2018-06-19 15:03:05 +02:00
parent b602123a5a
commit 665174fdbb
1569 changed files with 30495 additions and 30309 deletions

View File

@ -11,39 +11,45 @@
#ifndef MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
#define MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
#define BLOCKL_MAX 160 // max processing block length: 160
#define ANAL_BLOCKL_MAX 256 // max analysis block length: 256
#define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1
#define NUM_HIGH_BANDS_MAX 2 // max number of high bands: 2
#define BLOCKL_MAX 160 // max processing block length: 160
#define ANAL_BLOCKL_MAX 256 // max analysis block length: 256
#define HALF_ANAL_BLOCKL 129 // half max analysis block length + 1
#define NUM_HIGH_BANDS_MAX 2 // max number of high bands: 2
#define QUANTILE (float)0.25
#define QUANTILE (float)0.25
#define SIMULT 3
#define END_STARTUP_LONG 200
#define END_STARTUP_SHORT 50
#define FACTOR (float)40.0
#define WIDTH (float)0.01
#define SIMULT 3
#define END_STARTUP_LONG 200
#define END_STARTUP_SHORT 50
#define FACTOR (float)40.0
#define WIDTH (float)0.01
// Length of fft work arrays.
#define IP_LENGTH (ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2))
#define IP_LENGTH \
(ANAL_BLOCKL_MAX >> 1) // must be at least ceil(2 + sqrt(ANAL_BLOCKL_MAX/2))
#define W_LENGTH (ANAL_BLOCKL_MAX >> 1)
//PARAMETERS FOR NEW METHOD
#define DD_PR_SNR (float)0.98 // DD update of prior SNR
#define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90)
#define SPECT_FL_TAVG (float)0.30 // tavg parameter for spectral flatness measure
#define SPECT_DIFF_TAVG (float)0.30 // tavg parameter for spectral difference measure
#define PRIOR_UPDATE (float)0.10 // update parameter of prior model
#define NOISE_UPDATE (float)0.90 // update parameter for noise
#define SPEECH_UPDATE (float)0.99 // update parameter when likely speech
#define WIDTH_PR_MAP (float)4.0 // width parameter in sigmoid map for prior model
#define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature
#define SF_FEATURE_THR (float)0.5 // default threshold for Spectral Flatness feature
#define SD_FEATURE_THR (float)0.5 // default threshold for Spectral Difference feature
#define PROB_RANGE (float)0.20 // probability threshold for noise state in
// speech/noise likelihood
#define HIST_PAR_EST 1000 // histogram size for estimation of parameters
#define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate
// PARAMETERS FOR NEW METHOD
#define DD_PR_SNR (float)0.98 // DD update of prior SNR
#define LRT_TAVG (float)0.50 // tavg parameter for LRT (previously 0.90)
#define SPECT_FL_TAVG \
(float)0.30 // tavg parameter for spectral flatness measure
#define SPECT_DIFF_TAVG \
(float)0.30 // tavg parameter for spectral difference measure
#define PRIOR_UPDATE (float)0.10 // update parameter of prior model
#define NOISE_UPDATE (float)0.90 // update parameter for noise
#define SPEECH_UPDATE (float)0.99 // update parameter when likely speech
#define WIDTH_PR_MAP \
(float)4.0 // width parameter in sigmoid map for prior model
#define LRT_FEATURE_THR (float)0.5 // default threshold for LRT feature
#define SF_FEATURE_THR \
(float)0.5 // default threshold for Spectral Flatness feature
#define SD_FEATURE_THR \
(float)0.5 // default threshold for Spectral Difference feature
#define PROB_RANGE (float)0.20 // probability threshold for noise state in
// speech/noise likelihood
#define HIST_PAR_EST 1000 // histogram size for estimation of parameters
#define GAMMA_PAUSE (float)0.05 // update for conservative noise estimate
//
#define B_LIM (float)0.5 // threshold in final energy gain factor calculation
#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_
#define B_LIM (float)0.5 // threshold in final energy gain factor calculation
#endif // MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_DEFINES_H_

View File

@ -93,9 +93,9 @@ void WebRtcNs_Analyze(NsHandle* NS_inst, const float* spframe);
* - outframe : Pointer to output frame for each band
*/
void WebRtcNs_Process(NsHandle* NS_inst,
const float* const* spframe,
size_t num_bands,
float* const* outframe);
const float* const* spframe,
size_t num_bands,
float* const* outframe);
/* Returns the internally used prior speech probability of the current frame.
* There is a frequency bin based one as well, with which this should not be

View File

@ -78,26 +78,26 @@ typedef struct NoiseSuppressionC_ {
float wfft[W_LENGTH];
// Parameters for new method: some not needed, will reduce/cleanup later.
int32_t blockInd; // Frame index counter.
int32_t blockInd; // Frame index counter.
int modelUpdatePars[4]; // Parameters for updating or estimating.
// Thresholds/weights for prior model.
float priorModelPars[7]; // Parameters for prior model.
float noise[HALF_ANAL_BLOCKL]; // Noise spectrum from current frame.
float priorModelPars[7]; // Parameters for prior model.
float noise[HALF_ANAL_BLOCKL]; // Noise spectrum from current frame.
float noisePrev[HALF_ANAL_BLOCKL]; // Noise spectrum from previous frame.
// Magnitude spectrum of previous analyze frame.
float magnPrevAnalyze[HALF_ANAL_BLOCKL];
// Magnitude spectrum of previous process frame.
float magnPrevProcess[HALF_ANAL_BLOCKL];
float logLrtTimeAvg[HALF_ANAL_BLOCKL]; // Log LRT factor with time-smoothing.
float priorSpeechProb; // Prior speech/noise probability.
float priorSpeechProb; // Prior speech/noise probability.
float featureData[7];
// Conservative noise spectrum estimate.
float magnAvgPause[HALF_ANAL_BLOCKL];
float signalEnergy; // Energy of |magn|.
float sumMagn;
float whiteNoiseLevel; // Initial noise estimate.
float whiteNoiseLevel; // Initial noise estimate.
float initMagnEst[HALF_ANAL_BLOCKL]; // Initial magnitude spectrum estimate.
float pinkNoiseNumerator; // Pink noise parameter: numerator.
float pinkNoiseNumerator; // Pink noise parameter: numerator.
float pinkNoiseExp; // Pink noise parameter: power of frequencies.
float parametricNoise[HALF_ANAL_BLOCKL];
// Parameters for feature extraction.

View File

@ -20,98 +20,97 @@
#include "typedefs.h" // NOLINT(build/include)
typedef struct NoiseSuppressionFixedC_ {
uint32_t fs;
uint32_t fs;
const int16_t* window;
int16_t analysisBuffer[ANAL_BLOCKL_MAX];
int16_t synthesisBuffer[ANAL_BLOCKL_MAX];
uint16_t noiseSupFilter[HALF_ANAL_BLOCKL];
uint16_t overdrive; /* Q8 */
uint16_t denoiseBound; /* Q14 */
const int16_t* factor2Table;
int16_t noiseEstLogQuantile[SIMULT* HALF_ANAL_BLOCKL];
int16_t noiseEstDensity[SIMULT* HALF_ANAL_BLOCKL];
int16_t noiseEstCounter[SIMULT];
int16_t noiseEstQuantile[HALF_ANAL_BLOCKL];
const int16_t* window;
int16_t analysisBuffer[ANAL_BLOCKL_MAX];
int16_t synthesisBuffer[ANAL_BLOCKL_MAX];
uint16_t noiseSupFilter[HALF_ANAL_BLOCKL];
uint16_t overdrive; /* Q8 */
uint16_t denoiseBound; /* Q14 */
const int16_t* factor2Table;
int16_t noiseEstLogQuantile[SIMULT * HALF_ANAL_BLOCKL];
int16_t noiseEstDensity[SIMULT * HALF_ANAL_BLOCKL];
int16_t noiseEstCounter[SIMULT];
int16_t noiseEstQuantile[HALF_ANAL_BLOCKL];
size_t anaLen;
size_t anaLen2;
size_t magnLen;
int aggrMode;
int stages;
int initFlag;
int gainMap;
size_t anaLen;
size_t anaLen2;
size_t magnLen;
int aggrMode;
int stages;
int initFlag;
int gainMap;
int32_t maxLrt;
int32_t minLrt;
int32_t maxLrt;
int32_t minLrt;
// Log LRT factor with time-smoothing in Q8.
int32_t logLrtTimeAvgW32[HALF_ANAL_BLOCKL];
int32_t featureLogLrt;
int32_t thresholdLogLrt;
int16_t weightLogLrt;
int32_t logLrtTimeAvgW32[HALF_ANAL_BLOCKL];
int32_t featureLogLrt;
int32_t thresholdLogLrt;
int16_t weightLogLrt;
uint32_t featureSpecDiff;
uint32_t thresholdSpecDiff;
int16_t weightSpecDiff;
uint32_t featureSpecDiff;
uint32_t thresholdSpecDiff;
int16_t weightSpecDiff;
uint32_t featureSpecFlat;
uint32_t thresholdSpecFlat;
int16_t weightSpecFlat;
uint32_t featureSpecFlat;
uint32_t thresholdSpecFlat;
int16_t weightSpecFlat;
// Conservative estimate of noise spectrum.
int32_t avgMagnPause[HALF_ANAL_BLOCKL];
uint32_t magnEnergy;
uint32_t sumMagn;
uint32_t curAvgMagnEnergy;
uint32_t timeAvgMagnEnergy;
uint32_t timeAvgMagnEnergyTmp;
int32_t avgMagnPause[HALF_ANAL_BLOCKL];
uint32_t magnEnergy;
uint32_t sumMagn;
uint32_t curAvgMagnEnergy;
uint32_t timeAvgMagnEnergy;
uint32_t timeAvgMagnEnergyTmp;
uint32_t whiteNoiseLevel; // Initial noise estimate.
uint32_t whiteNoiseLevel; // Initial noise estimate.
// Initial magnitude spectrum estimate.
uint32_t initMagnEst[HALF_ANAL_BLOCKL];
uint32_t initMagnEst[HALF_ANAL_BLOCKL];
// Pink noise parameters:
int32_t pinkNoiseNumerator; // Numerator.
int32_t pinkNoiseExp; // Power of freq.
int minNorm; // Smallest normalization factor.
int zeroInputSignal; // Zero input signal flag.
int32_t pinkNoiseNumerator; // Numerator.
int32_t pinkNoiseExp; // Power of freq.
int minNorm; // Smallest normalization factor.
int zeroInputSignal; // Zero input signal flag.
// Noise spectrum from previous frame.
uint32_t prevNoiseU32[HALF_ANAL_BLOCKL];
uint32_t prevNoiseU32[HALF_ANAL_BLOCKL];
// Magnitude spectrum from previous frame.
uint16_t prevMagnU16[HALF_ANAL_BLOCKL];
uint16_t prevMagnU16[HALF_ANAL_BLOCKL];
// Prior speech/noise probability in Q14.
int16_t priorNonSpeechProb;
int16_t priorNonSpeechProb;
int blockIndex; // Frame index counter.
int blockIndex; // Frame index counter.
// Parameter for updating or estimating thresholds/weights for prior model.
int modelUpdate;
int cntThresUpdate;
int modelUpdate;
int cntThresUpdate;
// Histograms for parameter estimation.
int16_t histLrt[HIST_PAR_EST];
int16_t histSpecFlat[HIST_PAR_EST];
int16_t histSpecDiff[HIST_PAR_EST];
int16_t histLrt[HIST_PAR_EST];
int16_t histSpecFlat[HIST_PAR_EST];
int16_t histSpecDiff[HIST_PAR_EST];
// Quantities for high band estimate.
int16_t dataBufHBFX[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX];
int16_t dataBufHBFX[NUM_HIGH_BANDS_MAX][ANAL_BLOCKL_MAX];
int qNoise;
int prevQNoise;
int prevQMagn;
size_t blockLen10ms;
int qNoise;
int prevQNoise;
int prevQMagn;
size_t blockLen10ms;
int16_t real[ANAL_BLOCKL_MAX];
int16_t imag[ANAL_BLOCKL_MAX];
int32_t energyIn;
int scaleEnergyIn;
int normData;
int16_t real[ANAL_BLOCKL_MAX];
int16_t imag[ANAL_BLOCKL_MAX];
int32_t energyIn;
int scaleEnergyIn;
int normData;
struct RealFFT* real_fft;
} NoiseSuppressionFixedC;
#ifdef __cplusplus
extern "C"
{
extern "C" {
#endif
/****************************************************************************

View File

@ -11,54 +11,64 @@
#ifndef MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_
#define MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_
#define ANAL_BLOCKL_MAX 256 /* Max analysis block length */
#define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */
#define NUM_HIGH_BANDS_MAX 2 /* Max number of high bands */
#define SIMULT 3
#define END_STARTUP_LONG 200
#define END_STARTUP_SHORT 50
#define FACTOR_Q16 2621440 /* 40 in Q16 */
#define FACTOR_Q7 5120 /* 40 in Q7 */
#define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */
#define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */
#define ANAL_BLOCKL_MAX 256 /* Max analysis block length */
#define HALF_ANAL_BLOCKL 129 /* Half max analysis block length + 1 */
#define NUM_HIGH_BANDS_MAX 2 /* Max number of high bands */
#define SIMULT 3
#define END_STARTUP_LONG 200
#define END_STARTUP_SHORT 50
#define FACTOR_Q16 2621440 /* 40 in Q16 */
#define FACTOR_Q7 5120 /* 40 in Q7 */
#define FACTOR_Q7_STARTUP 1024 /* 8 in Q7 */
#define WIDTH_Q8 3 /* 0.01 in Q8 (or 25 ) */
/* PARAMETERS FOR NEW METHOD */
#define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */
#define DD_PR_SNR_Q11 2007 /* ~= Q11(0.98) DD update of prior SNR */
#define ONE_MINUS_DD_PR_SNR_Q11 41 /* DD update of prior SNR */
#define SPECT_FLAT_TAVG_Q14 4915 /* (0.30) tavg parameter for spectral flatness measure */
#define SPECT_DIFF_TAVG_Q8 77 /* (0.30) tavg parameter for spectral flatness measure */
#define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */
#define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */
#define SPECT_FLAT_TAVG_Q14 \
4915 /* (0.30) tavg parameter for spectral flatness measure */
#define SPECT_DIFF_TAVG_Q8 \
77 /* (0.30) tavg parameter for spectral flatness measure */
#define PRIOR_UPDATE_Q14 1638 /* Q14(0.1) Update parameter of prior model */
#define NOISE_UPDATE_Q8 26 /* 26 ~= Q8(0.1) Update parameter for noise */
/* Probability threshold for noise state in speech/noise likelihood. */
#define ONE_MINUS_PROB_RANGE_Q8 205 /* 205 ~= Q8(0.8) */
#define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */
#define HIST_PAR_EST 1000 /* Histogram size for estimation of parameters */
/* FEATURE EXTRACTION CONFIG */
/* Bin size of histogram */
#define BIN_SIZE_LRT 10
/* Scale parameters: multiply dominant peaks of the histograms by scale factor to obtain. */
#define BIN_SIZE_LRT 10
/* Scale parameters: multiply dominant peaks of the histograms by scale factor
* to obtain. */
/* Thresholds for prior model */
#define FACTOR_1_LRT_DIFF 6 /* For LRT and spectral difference (5 times bigger) */
/* For spectral_flatness: used when noise is flatter than speech (10 times bigger). */
#define FACTOR_2_FLAT_Q10 922
#define FACTOR_1_LRT_DIFF \
6 /* For LRT and spectral difference (5 times bigger) */
/* For spectral_flatness: used when noise is flatter than speech (10 times
* bigger). */
#define FACTOR_2_FLAT_Q10 922
/* Peak limit for spectral flatness (varies between 0 and 1) */
#define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */
/* Limit on spacing of two highest peaks in histogram: spacing determined by bin size. */
#define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */
#define THRES_PEAK_FLAT 24 /* * 2 * BIN_SIZE_FLAT_FX */
/* Limit on spacing of two highest peaks in histogram: spacing determined by bin
* size. */
#define LIM_PEAK_SPACE_FLAT_DIFF 4 /* * 2 * BIN_SIZE_DIFF_FX */
/* Limit on relevance of second peak */
#define LIM_PEAK_WEIGHT_FLAT_DIFF 2
#define THRES_FLUCT_LRT 10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */
#define LIM_PEAK_WEIGHT_FLAT_DIFF 2
#define THRES_FLUCT_LRT \
10240 /* = 20 * inst->modelUpdate; fluctuation limit of LRT feat. */
/* Limit on the max and min values for the feature thresholds */
#define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */
#define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */
#define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */
#define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */
#define MAX_FLAT_Q10 38912 /* * 2 * BIN_SIZE_FLAT_FX */
#define MIN_FLAT_Q10 4096 /* * 2 * BIN_SIZE_FLAT_FX */
#define MAX_DIFF 100 /* * 2 * BIN_SIZE_DIFF_FX */
#define MIN_DIFF 16 /* * 2 * BIN_SIZE_DIFF_FX */
/* Criteria of weight of histogram peak to accept/reject feature */
#define THRES_WEIGHT_FLAT_DIFF 154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */
#define THRES_WEIGHT_FLAT_DIFF \
154 /*(int)(0.3*(inst->modelUpdate)) for flatness and difference */
#define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */
#define ONE_MINUS_GAMMA_PAUSE_Q8 13 /* ~= Q8(0.05) Update for conservative noise estimate */
#define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 3 /* ~= Q8(0.01) Update for transition and noise region */
#define STAT_UPDATES 9 /* Update every 512 = 1 << 9 block */
#define ONE_MINUS_GAMMA_PAUSE_Q8 \
13 /* ~= Q8(0.05) Update for conservative noise estimate */
#define GAMMA_NOISE_TRANS_AND_SPEECH_Q8 \
3 /* ~= Q8(0.01) Update for transition and noise region */
#endif /* MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_NSX_DEFINES_H_ */

File diff suppressed because it is too large Load Diff