Some code style changes in audio_processing/ns/main/source/ by Astyle,

with a little manual modification.
Review URL: http://webrtc-codereview.appspot.com/201002

git-svn-id: http://webrtc.googlecode.com/svn/trunk@698 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
kma@webrtc.org 2011-10-05 23:36:01 +00:00
parent fa41d807a8
commit af57de006a
10 changed files with 4045 additions and 4439 deletions

View File

@ -30,7 +30,7 @@ extern "C" {
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error (probably length is not sufficient) * -1 - Error (probably length is not sufficient)
*/ */
int WebRtcNs_get_version(char *version, short length); int WebRtcNs_get_version(char* version, short length);
/* /*
@ -46,7 +46,7 @@ int WebRtcNs_get_version(char *version, short length);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_Create(NsHandle **NS_inst); int WebRtcNs_Create(NsHandle** NS_inst);
/* /*
@ -59,7 +59,7 @@ int WebRtcNs_Create(NsHandle **NS_inst);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_Free(NsHandle *NS_inst); int WebRtcNs_Free(NsHandle* NS_inst);
/* /*
@ -75,7 +75,7 @@ int WebRtcNs_Free(NsHandle *NS_inst);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_Init(NsHandle *NS_inst, WebRtc_UWord32 fs); int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs);
/* /*
* This changes the aggressiveness of the noise suppression method. * This changes the aggressiveness of the noise suppression method.
@ -90,7 +90,7 @@ int WebRtcNs_Init(NsHandle *NS_inst, WebRtc_UWord32 fs);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_set_policy(NsHandle *NS_inst, int mode); int WebRtcNs_set_policy(NsHandle* NS_inst, int mode);
/* /*
@ -111,11 +111,11 @@ int WebRtcNs_set_policy(NsHandle *NS_inst, int mode);
* Return value : 0 - OK * Return value : 0 - OK
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_Process(NsHandle *NS_inst, int WebRtcNs_Process(NsHandle* NS_inst,
short *spframe, short* spframe,
short *spframe_H, short* spframe_H,
short *outframe, short* outframe,
short *outframe_H); short* outframe_H);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -30,7 +30,7 @@ extern "C" {
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error (probably length is not sufficient) * -1 - Error (probably length is not sufficient)
*/ */
int WebRtcNsx_get_version(char *version, short length); int WebRtcNsx_get_version(char* version, short length);
/* /*
@ -46,7 +46,7 @@ int WebRtcNsx_get_version(char *version, short length);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_Create(NsxHandle **nsxInst); int WebRtcNsx_Create(NsxHandle** nsxInst);
/* /*
@ -59,7 +59,7 @@ int WebRtcNsx_Create(NsxHandle **nsxInst);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_Free(NsxHandle *nsxInst); int WebRtcNsx_Free(NsxHandle* nsxInst);
/* /*
@ -75,7 +75,7 @@ int WebRtcNsx_Free(NsxHandle *nsxInst);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_Init(NsxHandle *nsxInst, WebRtc_UWord32 fs); int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs);
/* /*
* This changes the aggressiveness of the noise suppression method. * This changes the aggressiveness of the noise suppression method.
@ -90,7 +90,7 @@ int WebRtcNsx_Init(NsxHandle *nsxInst, WebRtc_UWord32 fs);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_set_policy(NsxHandle *nsxInst, int mode); int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode);
/* /*
* This functions does noise suppression for the inserted speech frame. The * This functions does noise suppression for the inserted speech frame. The
@ -110,11 +110,11 @@ int WebRtcNsx_set_policy(NsxHandle *nsxInst, int mode);
* Return value : 0 - OK * Return value : 0 - OK
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_Process(NsxHandle *nsxInst, int WebRtcNsx_Process(NsxHandle* nsxInst,
short *speechFrame, short* speechFrame,
short *speechFrameHB, short* speechFrameHB,
short *outFrame, short* outFrame,
short *outFrameHB); short* outFrameHB);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -15,55 +15,51 @@
#include "ns_core.h" #include "ns_core.h"
#include "defines.h" #include "defines.h"
int WebRtcNs_get_version(char *versionStr, short length) int WebRtcNs_get_version(char* versionStr, short length) {
{ const char version[] = "NS 2.2.0";
const char version[] = "NS 2.2.0"; const short versionLen = (short)strlen(version) + 1; // +1: null-termination
const short versionLen = (short)strlen(version) + 1; // +1 for null-termination
if (versionStr == NULL) { if (versionStr == NULL) {
return -1; return -1;
} }
if (versionLen > length) { if (versionLen > length) {
return -1; return -1;
} }
strncpy(versionStr, version, versionLen); strncpy(versionStr, version, versionLen);
return 0;
}
int WebRtcNs_Create(NsHandle** NS_inst) {
*NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
if (*NS_inst != NULL) {
(*(NSinst_t**)NS_inst)->initFlag = 0;
return 0; return 0;
} } else {
return -1;
int WebRtcNs_Create(NsHandle **NS_inst) }
{
*NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
if (*NS_inst!=NULL) {
(*(NSinst_t**)NS_inst)->initFlag=0;
return 0;
} else {
return -1;
}
} }
int WebRtcNs_Free(NsHandle *NS_inst) int WebRtcNs_Free(NsHandle* NS_inst) {
{ free(NS_inst);
free(NS_inst); return 0;
return 0;
} }
int WebRtcNs_Init(NsHandle *NS_inst, WebRtc_UWord32 fs) int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) {
{ return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
} }
int WebRtcNs_set_policy(NsHandle *NS_inst, int mode) int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) {
{ return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
} }
int WebRtcNs_Process(NsHandle *NS_inst, short *spframe, short *spframe_H, short *outframe, short *outframe_H) int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H,
{ short* outframe, short* outframe_H) {
return WebRtcNs_ProcessCore((NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H); return WebRtcNs_ProcessCore(
(NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
} }

View File

@ -15,60 +15,51 @@
#include "nsx_core.h" #include "nsx_core.h"
#include "nsx_defines.h" #include "nsx_defines.h"
int WebRtcNsx_get_version(char *versionStr, short length) int WebRtcNsx_get_version(char* versionStr, short length) {
{ const char version[] = "NS\t3.1.0";
const char version[] = "NS\t3.1.0"; const short versionLen = (short)strlen(version) + 1; // +1: null-termination
const short versionLen = (short)strlen(version) + 1; // +1 for null-termination
if (versionStr == NULL) if (versionStr == NULL) {
{ return -1;
return -1; }
}
if (versionLen > length) if (versionLen > length) {
{ return -1;
return -1; }
}
strncpy(versionStr, version, versionLen); strncpy(versionStr, version, versionLen);
return 0;
}
int WebRtcNsx_Create(NsxHandle** nsxInst) {
*nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t));
if (*nsxInst != NULL) {
(*(NsxInst_t**)nsxInst)->initFlag = 0;
return 0; return 0;
} } else {
return -1;
int WebRtcNsx_Create(NsxHandle **nsxInst) }
{
*nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t));
if (*nsxInst != NULL)
{
(*(NsxInst_t**)nsxInst)->initFlag = 0;
return 0;
} else
{
return -1;
}
} }
int WebRtcNsx_Free(NsxHandle *nsxInst) int WebRtcNsx_Free(NsxHandle* nsxInst) {
{ free(nsxInst);
free(nsxInst); return 0;
return 0;
} }
int WebRtcNsx_Init(NsxHandle *nsxInst, WebRtc_UWord32 fs) int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs) {
{ return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
} }
int WebRtcNsx_set_policy(NsxHandle *nsxInst, int mode) int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) {
{ return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
} }
int WebRtcNsx_Process(NsxHandle *nsxInst, short *speechFrame, short *speechFrameHB, int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame,
short *outFrame, short *outFrameHB) short* speechFrameHB, short* outFrame,
{ short* outFrameHB) {
return WebRtcNsx_ProcessCore((NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, return WebRtcNsx_ProcessCore(
outFrameHB); (NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB);
} }

File diff suppressed because it is too large Load Diff

View File

@ -15,95 +15,95 @@
typedef struct NSParaExtract_t_ { typedef struct NSParaExtract_t_ {
//bin size of histogram //bin size of histogram
float binSizeLrt; float binSizeLrt;
float binSizeSpecFlat; float binSizeSpecFlat;
float binSizeSpecDiff; float binSizeSpecDiff;
//range of histogram over which lrt threshold is computed //range of histogram over which lrt threshold is computed
float rangeAvgHistLrt; float rangeAvgHistLrt;
//scale parameters: multiply dominant peaks of the histograms by scale factor to obtain //scale parameters: multiply dominant peaks of the histograms by scale factor to obtain
//thresholds for prior model //thresholds for prior model
float factor1ModelPars; //for lrt and spectral difference float factor1ModelPars; //for lrt and spectral difference
float factor2ModelPars; //for spectral_flatness: used when noise is flatter than speech float factor2ModelPars; //for spectral_flatness: used when noise is flatter than speech
//peak limit for spectral flatness (varies between 0 and 1) //peak limit for spectral flatness (varies between 0 and 1)
float thresPosSpecFlat; float thresPosSpecFlat;
//limit on spacing of two highest peaks in histogram: spacing determined by bin size //limit on spacing of two highest peaks in histogram: spacing determined by bin size
float limitPeakSpacingSpecFlat; float limitPeakSpacingSpecFlat;
float limitPeakSpacingSpecDiff; float limitPeakSpacingSpecDiff;
//limit on relevance of second peak: //limit on relevance of second peak:
float limitPeakWeightsSpecFlat; float limitPeakWeightsSpecFlat;
float limitPeakWeightsSpecDiff; float limitPeakWeightsSpecDiff;
//limit on fluctuation of lrt feature //limit on fluctuation of lrt feature
float thresFluctLrt; float thresFluctLrt;
//limit on the max and min values for the feature thresholds //limit on the max and min values for the feature thresholds
float maxLrt; float maxLrt;
float minLrt; float minLrt;
float maxSpecFlat; float maxSpecFlat;
float minSpecFlat; float minSpecFlat;
float maxSpecDiff; float maxSpecDiff;
float minSpecDiff; float minSpecDiff;
//criteria of weight of histogram peak to accept/reject feature //criteria of weight of histogram peak to accept/reject feature
int thresWeightSpecFlat; int thresWeightSpecFlat;
int thresWeightSpecDiff; int thresWeightSpecDiff;
} NSParaExtract_t; } NSParaExtract_t;
typedef struct NSinst_t_ { typedef struct NSinst_t_ {
WebRtc_UWord32 fs; WebRtc_UWord32 fs;
int blockLen; int blockLen;
int blockLen10ms; int blockLen10ms;
int windShift; int windShift;
int outLen; int outLen;
int anaLen; int anaLen;
int magnLen; int magnLen;
int aggrMode; int aggrMode;
const float* window; const float* window;
float dataBuf[ANAL_BLOCKL_MAX]; float dataBuf[ANAL_BLOCKL_MAX];
float syntBuf[ANAL_BLOCKL_MAX]; float syntBuf[ANAL_BLOCKL_MAX];
float outBuf[3 * BLOCKL_MAX]; float outBuf[3 * BLOCKL_MAX];
int initFlag; int initFlag;
// parameters for quantile noise estimation // parameters for quantile noise estimation
float density[SIMULT * HALF_ANAL_BLOCKL]; float density[SIMULT* HALF_ANAL_BLOCKL];
float lquantile[SIMULT * HALF_ANAL_BLOCKL]; float lquantile[SIMULT* HALF_ANAL_BLOCKL];
float quantile[HALF_ANAL_BLOCKL]; float quantile[HALF_ANAL_BLOCKL];
int counter[SIMULT]; int counter[SIMULT];
int updates; int updates;
// parameters for Wiener filter // parameters for Wiener filter
float smooth[HALF_ANAL_BLOCKL]; float smooth[HALF_ANAL_BLOCKL];
float overdrive; float overdrive;
float denoiseBound; float denoiseBound;
int gainmap; int gainmap;
// fft work arrays. // fft work arrays.
int ip[IP_LENGTH]; int ip[IP_LENGTH];
float wfft[W_LENGTH]; float wfft[W_LENGTH];
// parameters for new method: some not needed, will reduce/cleanup later // parameters for new method: some not needed, will reduce/cleanup later
WebRtc_Word32 blockInd; //frame index counter WebRtc_Word32 blockInd; //frame index counter
int modelUpdatePars[4]; //parameters for updating or estimating int modelUpdatePars[4]; //parameters for updating or estimating
// thresholds/weights for prior model // thresholds/weights for prior model
float priorModelPars[7]; //parameters for prior model float priorModelPars[7]; //parameters for prior model
float noisePrev[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame float noisePrev[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame
float magnPrev[HALF_ANAL_BLOCKL]; //magnitude spectrum of previous frame float magnPrev[HALF_ANAL_BLOCKL]; //magnitude spectrum of previous frame
float logLrtTimeAvg[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing 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]; //data for features float featureData[7]; //data for features
float magnAvgPause[HALF_ANAL_BLOCKL]; //conservative noise spectrum estimate float magnAvgPause[HALF_ANAL_BLOCKL]; //conservative noise spectrum estimate
float signalEnergy; //energy of magn float signalEnergy; //energy of magn
float sumMagn; //sum of magn float sumMagn; //sum of magn
float whiteNoiseLevel; //initial noise estimate float whiteNoiseLevel; //initial noise estimate
float initMagnEst[HALF_ANAL_BLOCKL]; //initial magnitude spectrum 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 freq float pinkNoiseExp; //pink noise parameter: power of freq
NSParaExtract_t featureExtractionParams; //parameters for feature extraction NSParaExtract_t featureExtractionParams; //parameters for feature extraction
//histograms for parameter estimation //histograms for parameter estimation
int histLrt[HIST_PAR_EST]; int histLrt[HIST_PAR_EST];
int histSpecFlat[HIST_PAR_EST]; int histSpecFlat[HIST_PAR_EST];
int histSpecDiff[HIST_PAR_EST]; int histSpecDiff[HIST_PAR_EST];
//quantities for high band estimate //quantities for high band estimate
float speechProbHB[HALF_ANAL_BLOCKL]; //final speech/noise prob: prior + LRT float speechProbHB[HALF_ANAL_BLOCKL]; //final speech/noise prob: prior + LRT
float dataBufHB[ANAL_BLOCKL_MAX]; //buffering data for HB float dataBufHB[ANAL_BLOCKL_MAX]; //buffering data for HB
} NSinst_t; } NSinst_t;
@ -127,7 +127,7 @@ extern "C" {
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_InitCore(NSinst_t *inst, WebRtc_UWord32 fs); int WebRtcNs_InitCore(NSinst_t* inst, WebRtc_UWord32 fs);
/**************************************************************************** /****************************************************************************
* WebRtcNs_set_policy_core(...) * WebRtcNs_set_policy_core(...)
@ -144,7 +144,7 @@ int WebRtcNs_InitCore(NSinst_t *inst, WebRtc_UWord32 fs);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNs_set_policy_core(NSinst_t *inst, int mode); int WebRtcNs_set_policy_core(NSinst_t* inst, int mode);
/**************************************************************************** /****************************************************************************
* WebRtcNs_ProcessCore * WebRtcNs_ProcessCore
@ -166,11 +166,11 @@ int WebRtcNs_set_policy_core(NSinst_t *inst, int mode);
*/ */
int WebRtcNs_ProcessCore(NSinst_t *inst, int WebRtcNs_ProcessCore(NSinst_t* inst,
short *inFrameLow, short* inFrameLow,
short *inFrameHigh, short* inFrameHigh,
short *outFrameLow, short* outFrameLow,
short *outFrameHigh); short* outFrameHigh);
#ifdef __cplusplus #ifdef __cplusplus

File diff suppressed because it is too large Load Diff

View File

@ -20,85 +20,84 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
typedef struct NsxInst_t_ typedef struct NsxInst_t_ {
{ WebRtc_UWord32 fs;
WebRtc_UWord32 fs;
const WebRtc_Word16* window; const WebRtc_Word16* window;
WebRtc_Word16 analysisBuffer[ANAL_BLOCKL_MAX]; WebRtc_Word16 analysisBuffer[ANAL_BLOCKL_MAX];
WebRtc_Word16 synthesisBuffer[ANAL_BLOCKL_MAX]; WebRtc_Word16 synthesisBuffer[ANAL_BLOCKL_MAX];
WebRtc_UWord16 noiseSupFilter[HALF_ANAL_BLOCKL]; WebRtc_UWord16 noiseSupFilter[HALF_ANAL_BLOCKL];
WebRtc_UWord16 overdrive; /* Q8 */ WebRtc_UWord16 overdrive; /* Q8 */
WebRtc_UWord16 denoiseBound; /* Q14 */ WebRtc_UWord16 denoiseBound; /* Q14 */
const WebRtc_Word16* factor2Table; const WebRtc_Word16* factor2Table;
WebRtc_Word16 noiseEstLogQuantile[SIMULT * HALF_ANAL_BLOCKL]; WebRtc_Word16 noiseEstLogQuantile[SIMULT* HALF_ANAL_BLOCKL];
WebRtc_Word16 noiseEstDensity[SIMULT * HALF_ANAL_BLOCKL]; WebRtc_Word16 noiseEstDensity[SIMULT* HALF_ANAL_BLOCKL];
WebRtc_Word16 noiseEstCounter[SIMULT]; WebRtc_Word16 noiseEstCounter[SIMULT];
WebRtc_Word16 noiseEstQuantile[HALF_ANAL_BLOCKL]; WebRtc_Word16 noiseEstQuantile[HALF_ANAL_BLOCKL];
WebRtc_Word16 anaLen; WebRtc_Word16 anaLen;
int anaLen2; int anaLen2;
int magnLen; int magnLen;
int aggrMode; int aggrMode;
int stages; int stages;
int initFlag; int initFlag;
int gainMap; int gainMap;
WebRtc_Word32 maxLrt; WebRtc_Word32 maxLrt;
WebRtc_Word32 minLrt; WebRtc_Word32 minLrt;
WebRtc_Word32 logLrtTimeAvgW32[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing in Q8 WebRtc_Word32 logLrtTimeAvgW32[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing in Q8
WebRtc_Word32 featureLogLrt; WebRtc_Word32 featureLogLrt;
WebRtc_Word32 thresholdLogLrt; WebRtc_Word32 thresholdLogLrt;
WebRtc_Word16 weightLogLrt; WebRtc_Word16 weightLogLrt;
WebRtc_UWord32 featureSpecDiff; WebRtc_UWord32 featureSpecDiff;
WebRtc_UWord32 thresholdSpecDiff; WebRtc_UWord32 thresholdSpecDiff;
WebRtc_Word16 weightSpecDiff; WebRtc_Word16 weightSpecDiff;
WebRtc_UWord32 featureSpecFlat; WebRtc_UWord32 featureSpecFlat;
WebRtc_UWord32 thresholdSpecFlat; WebRtc_UWord32 thresholdSpecFlat;
WebRtc_Word16 weightSpecFlat; WebRtc_Word16 weightSpecFlat;
WebRtc_Word32 avgMagnPause[HALF_ANAL_BLOCKL]; //conservative estimate of noise spectrum WebRtc_Word32 avgMagnPause[HALF_ANAL_BLOCKL]; //conservative estimate of noise spectrum
WebRtc_UWord32 magnEnergy; WebRtc_UWord32 magnEnergy;
WebRtc_UWord32 sumMagn; WebRtc_UWord32 sumMagn;
WebRtc_UWord32 curAvgMagnEnergy; WebRtc_UWord32 curAvgMagnEnergy;
WebRtc_UWord32 timeAvgMagnEnergy; WebRtc_UWord32 timeAvgMagnEnergy;
WebRtc_UWord32 timeAvgMagnEnergyTmp; WebRtc_UWord32 timeAvgMagnEnergyTmp;
WebRtc_UWord32 whiteNoiseLevel; //initial noise estimate WebRtc_UWord32 whiteNoiseLevel; //initial noise estimate
WebRtc_UWord32 initMagnEst[HALF_ANAL_BLOCKL];//initial magnitude spectrum estimate WebRtc_UWord32 initMagnEst[HALF_ANAL_BLOCKL];//initial magnitude spectrum estimate
WebRtc_Word32 pinkNoiseNumerator; //pink noise parameter: numerator WebRtc_Word32 pinkNoiseNumerator; //pink noise parameter: numerator
WebRtc_Word32 pinkNoiseExp; //pink noise parameter: power of freq WebRtc_Word32 pinkNoiseExp; //pink noise parameter: power of freq
int minNorm; //smallest normalization factor int minNorm; //smallest normalization factor
int zeroInputSignal; //zero input signal flag int zeroInputSignal; //zero input signal flag
WebRtc_UWord32 prevNoiseU32[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame WebRtc_UWord32 prevNoiseU32[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame
WebRtc_UWord16 prevMagnU16[HALF_ANAL_BLOCKL]; //magnitude spectrum from previous frame WebRtc_UWord16 prevMagnU16[HALF_ANAL_BLOCKL]; //magnitude spectrum from previous frame
WebRtc_Word16 priorNonSpeechProb; //prior speech/noise probability // Q14 WebRtc_Word16 priorNonSpeechProb; //prior speech/noise probability // Q14
int blockIndex; //frame index counter int blockIndex; //frame index counter
int modelUpdate; //parameter for updating or estimating thresholds/weights for prior model int modelUpdate; //parameter for updating or estimating thresholds/weights for prior model
int cntThresUpdate; int cntThresUpdate;
//histograms for parameter estimation //histograms for parameter estimation
WebRtc_Word16 histLrt[HIST_PAR_EST]; WebRtc_Word16 histLrt[HIST_PAR_EST];
WebRtc_Word16 histSpecFlat[HIST_PAR_EST]; WebRtc_Word16 histSpecFlat[HIST_PAR_EST];
WebRtc_Word16 histSpecDiff[HIST_PAR_EST]; WebRtc_Word16 histSpecDiff[HIST_PAR_EST];
//quantities for high band estimate //quantities for high band estimate
WebRtc_Word16 dataBufHBFX[ANAL_BLOCKL_MAX]; /* Q0 */ WebRtc_Word16 dataBufHBFX[ANAL_BLOCKL_MAX]; /* Q0 */
int qNoise; int qNoise;
int prevQNoise; int prevQNoise;
int prevQMagn; int prevQMagn;
int blockLen10ms; int blockLen10ms;
WebRtc_Word16 real[ANAL_BLOCKL_MAX]; WebRtc_Word16 real[ANAL_BLOCKL_MAX];
WebRtc_Word16 imag[ANAL_BLOCKL_MAX]; WebRtc_Word16 imag[ANAL_BLOCKL_MAX];
WebRtc_Word32 energyIn; WebRtc_Word32 energyIn;
int scaleEnergyIn; int scaleEnergyIn;
int normData; int normData;
} NsxInst_t; } NsxInst_t;
@ -122,7 +121,7 @@ extern "C"
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
WebRtc_Word32 WebRtcNsx_InitCore(NsxInst_t *inst, WebRtc_UWord32 fs); WebRtc_Word32 WebRtcNsx_InitCore(NsxInst_t* inst, WebRtc_UWord32 fs);
/**************************************************************************** /****************************************************************************
* WebRtcNsx_set_policy_core(...) * WebRtcNsx_set_policy_core(...)
@ -139,7 +138,7 @@ WebRtc_Word32 WebRtcNsx_InitCore(NsxInst_t *inst, WebRtc_UWord32 fs);
* Return value : 0 - Ok * Return value : 0 - Ok
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_set_policy_core(NsxInst_t *inst, int mode); int WebRtcNsx_set_policy_core(NsxInst_t* inst, int mode);
/**************************************************************************** /****************************************************************************
* WebRtcNsx_ProcessCore * WebRtcNsx_ProcessCore
@ -159,16 +158,16 @@ int WebRtcNsx_set_policy_core(NsxInst_t *inst, int mode);
* Return value : 0 - OK * Return value : 0 - OK
* -1 - Error * -1 - Error
*/ */
int WebRtcNsx_ProcessCore(NsxInst_t *inst, short *inFrameLow, short *inFrameHigh, int WebRtcNsx_ProcessCore(NsxInst_t* inst, short* inFrameLow, short* inFrameHigh,
short *outFrameLow, short *outFrameHigh); short* outFrameLow, short* outFrameHigh);
/**************************************************************************** /****************************************************************************
* Internal functions and variable declarations shared with optimized code. * Internal functions and variable declarations shared with optimized code.
*/ */
void WebRtcNsx_UpdateNoiseEstimate(NsxInst_t *inst, int offset); void WebRtcNsx_UpdateNoiseEstimate(NsxInst_t* inst, int offset);
void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWord32 *noise, void WebRtcNsx_NoiseEstimation(NsxInst_t* inst, WebRtc_UWord16* magn, WebRtc_UWord32* noise,
WebRtc_Word16 *qNoise); WebRtc_Word16* qNoise);
extern const WebRtc_Word16 WebRtcNsx_kLogTable[9]; extern const WebRtc_Word16 WebRtcNsx_kLogTable[9];
extern const WebRtc_Word16 WebRtcNsx_kLogTableFrac[256]; extern const WebRtc_Word16 WebRtcNsx_kLogTableFrac[256];

View File

@ -15,242 +15,226 @@
#include <arm_neon.h> #include <arm_neon.h>
#include <assert.h> #include <assert.h>
void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWord32 *noise, void WebRtcNsx_NoiseEstimation(NsxInst_t* inst, WebRtc_UWord16* magn, WebRtc_UWord32* noise,
WebRtc_Word16 *qNoise) WebRtc_Word16* qNoise) {
{ WebRtc_Word32 numerator;
WebRtc_Word32 numerator;
WebRtc_Word16 lmagn[HALF_ANAL_BLOCKL], counter, countDiv, countProd, delta, zeros, frac; WebRtc_Word16 lmagn[HALF_ANAL_BLOCKL], counter, countDiv, countProd, delta, zeros, frac;
WebRtc_Word16 log2, tabind, logval, tmp16, tmp16no1, tmp16no2; WebRtc_Word16 log2, tabind, logval, tmp16, tmp16no1, tmp16no2;
WebRtc_Word16 log2Const = 22713; WebRtc_Word16 log2Const = 22713;
WebRtc_Word16 widthFactor = 21845; WebRtc_Word16 widthFactor = 21845;
int i, s, offset; int i, s, offset;
numerator = FACTOR_Q16; numerator = FACTOR_Q16;
tabind = inst->stages - inst->normData; tabind = inst->stages - inst->normData;
assert(tabind < 9); assert(tabind < 9);
assert(tabind > -9); assert(tabind > -9);
if (tabind < 0) if (tabind < 0) {
{ logval = -WebRtcNsx_kLogTable[-tabind];
logval = -WebRtcNsx_kLogTable[-tabind]; } else {
} else logval = WebRtcNsx_kLogTable[tabind];
{ }
logval = WebRtcNsx_kLogTable[tabind];
int16x8_t logval_16x8 = vdupq_n_s16(logval);
// lmagn(i)=log(magn(i))=log(2)*log2(magn(i))
// magn is in Q(-stages), and the real lmagn values are:
// real_lmagn(i)=log(magn(i)*2^stages)=log(magn(i))+log(2^stages)
// lmagn in Q8
for (i = 0; i < inst->magnLen; i++) {
if (magn[i]) {
zeros = WebRtcSpl_NormU32((WebRtc_UWord32)magn[i]);
frac = (WebRtc_Word16)((((WebRtc_UWord32)magn[i] << zeros) & 0x7FFFFFFF) >> 23);
assert(frac < 256);
// log2(magn(i))
log2 = (WebRtc_Word16)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]);
// log2(magn(i))*log(2)
lmagn[i] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(log2, log2Const, 15);
// + log(2^stages)
lmagn[i] += logval;
} else {
lmagn[i] = logval;
} }
}
int16x8_t logval_16x8 = vdupq_n_s16(logval); int16x4_t Q3_16x4 = vdup_n_s16(3);
int16x8_t WIDTHQ8_16x8 = vdupq_n_s16(WIDTH_Q8);
int16x8_t WIDTHFACTOR_16x8 = vdupq_n_s16(widthFactor);
// lmagn(i)=log(magn(i))=log(2)*log2(magn(i)) WebRtc_Word16 factor = FACTOR_Q7;
// magn is in Q(-stages), and the real lmagn values are: if (inst->blockIndex < END_STARTUP_LONG)
// real_lmagn(i)=log(magn(i)*2^stages)=log(magn(i))+log(2^stages) factor = FACTOR_Q7_STARTUP;
// lmagn in Q8
for (i = 0; i < inst->magnLen; i++) // Loop over simultaneous estimates
{ for (s = 0; s < SIMULT; s++) {
if (magn[i]) offset = s * inst->magnLen;
{
zeros = WebRtcSpl_NormU32((WebRtc_UWord32)magn[i]); // Get counter values from state
frac = (WebRtc_Word16)((((WebRtc_UWord32)magn[i] << zeros) & 0x7FFFFFFF) >> 23); counter = inst->noiseEstCounter[s];
assert(frac < 256); assert(counter < 201);
// log2(magn(i)) countDiv = WebRtcNsx_kCounterDiv[counter];
log2 = (WebRtc_Word16)(((31 - zeros) << 8) + WebRtcNsx_kLogTableFrac[frac]); countProd = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(counter, countDiv);
// log2(magn(i))*log(2)
lmagn[i] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(log2, log2Const, 15); // quant_est(...)
// + log(2^stages) WebRtc_Word16 deltaBuff[8];
lmagn[i] += logval; int16x4_t tmp16x4_0;
} else int16x4_t tmp16x4_1;
{ int16x4_t countDiv_16x4 = vdup_n_s16(countDiv);
lmagn[i] = logval; int16x8_t countProd_16x8 = vdupq_n_s16(countProd);
int16x8_t tmp16x8_0 = vdupq_n_s16(countDiv);
int16x8_t prod16x8 = vqrdmulhq_s16(WIDTHFACTOR_16x8, tmp16x8_0);
int16x8_t tmp16x8_1;
int16x8_t tmp16x8_2;
int16x8_t tmp16x8_3;
int16x8_t tmp16x8_4;
int16x8_t tmp16x8_5;
int32x4_t tmp32x4;
for (i = 0; i < inst->magnLen - 7; i += 8) {
// Compute delta.
// Smaller step size during startup. This prevents from using
// unrealistic values causing overflow.
tmp16x8_0 = vdupq_n_s16(factor);
vst1q_s16(deltaBuff, tmp16x8_0);
int j;
for (j = 0; j < 8; j++) {
if (inst->noiseEstDensity[offset + i + j] > 512) {
deltaBuff[j] = WebRtcSpl_DivW32W16ResW16(
numerator, inst->noiseEstDensity[offset + i + j]);
} }
} }
int16x4_t Q3_16x4 = vdup_n_s16(3); // Update log quantile estimate
int16x8_t WIDTHQ8_16x8 = vdupq_n_s16(WIDTH_Q8);
int16x8_t WIDTHFACTOR_16x8 = vdupq_n_s16(widthFactor);
WebRtc_Word16 factor = FACTOR_Q7; // tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(delta, countDiv, 14);
if (inst->blockIndex < END_STARTUP_LONG) tmp32x4 = vmull_s16(vld1_s16(&deltaBuff[0]), countDiv_16x4);
factor = FACTOR_Q7_STARTUP; tmp16x4_1 = vshrn_n_s32(tmp32x4, 14);
tmp32x4 = vmull_s16(vld1_s16(&deltaBuff[4]), countDiv_16x4);
tmp16x4_0 = vshrn_n_s32(tmp32x4, 14);
tmp16x8_0 = vcombine_s16(tmp16x4_1, tmp16x4_0); // Keep for several lines.
// Loop over simultaneous estimates // prepare for the "if" branch
for (s = 0; s < SIMULT; s++) // tmp16 += 2;
{ // tmp16_1 = (Word16)(tmp16>>2);
offset = s * inst->magnLen; tmp16x8_1 = vrshrq_n_s16(tmp16x8_0, 2);
// Get counter values from state // inst->noiseEstLogQuantile[offset+i] + tmp16_1;
counter = inst->noiseEstCounter[s]; tmp16x8_2 = vld1q_s16(&inst->noiseEstLogQuantile[offset + i]); // Keep
assert(counter < 201); tmp16x8_1 = vaddq_s16(tmp16x8_2, tmp16x8_1); // Keep for several lines
countDiv = WebRtcNsx_kCounterDiv[counter];
countProd = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(counter, countDiv);
// quant_est(...) // Prepare for the "else" branch
WebRtc_Word16 deltaBuff[8]; // tmp16 += 1;
int16x4_t tmp16x4_0; // tmp16_1 = (Word16)(tmp16>>1);
int16x4_t tmp16x4_1; tmp16x8_0 = vrshrq_n_s16(tmp16x8_0, 1);
int16x4_t countDiv_16x4 = vdup_n_s16(countDiv);
int16x8_t countProd_16x8 = vdupq_n_s16(countProd);
int16x8_t tmp16x8_0 = vdupq_n_s16(countDiv);
int16x8_t prod16x8 = vqrdmulhq_s16(WIDTHFACTOR_16x8, tmp16x8_0);
int16x8_t tmp16x8_1;
int16x8_t tmp16x8_2;
int16x8_t tmp16x8_3;
int16x8_t tmp16x8_4;
int16x8_t tmp16x8_5;
int32x4_t tmp32x4;
for (i = 0; i < inst->magnLen - 7; i += 8) { // tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1);
// Compute delta. tmp32x4 = vmull_s16(vget_low_s16(tmp16x8_0), Q3_16x4);
// Smaller step size during startup. This prevents from using tmp16x4_1 = vshrn_n_s32(tmp32x4, 1);
// unrealistic values causing overflow.
tmp16x8_0 = vdupq_n_s16(factor);
vst1q_s16(deltaBuff, tmp16x8_0);
int j; // tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1);
for (j = 0; j < 8; j++) { tmp32x4 = vmull_s16(vget_high_s16(tmp16x8_0), Q3_16x4);
if (inst->noiseEstDensity[offset + i + j] > 512) tmp16x4_0 = vshrn_n_s32(tmp32x4, 1);
deltaBuff[j] = WebRtcSpl_DivW32W16ResW16(numerator,
inst->noiseEstDensity[offset + i + j]);
}
// Update log quantile estimate // inst->noiseEstLogQuantile[offset + i] - tmp16_2;
tmp16x8_0 = vcombine_s16(tmp16x4_1, tmp16x4_0); // keep
tmp16x8_0 = vsubq_s16(tmp16x8_2, tmp16x8_0);
// tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(delta, countDiv, 14); // logval is the smallest fixed point representation we can have. Values below
tmp32x4 = vmull_s16(vld1_s16(&deltaBuff[0]), countDiv_16x4); // that will correspond to values in the interval [0, 1], which can't possibly
tmp16x4_1 = vshrn_n_s32(tmp32x4, 14); // occur.
tmp32x4 = vmull_s16(vld1_s16(&deltaBuff[4]), countDiv_16x4); tmp16x8_0 = vmaxq_s16(tmp16x8_0, logval_16x8);
tmp16x4_0 = vshrn_n_s32(tmp32x4, 14);
tmp16x8_0 = vcombine_s16(tmp16x4_1, tmp16x4_0); // Keep for several lines.
// prepare for the "if" branch // Do the if-else branches:
// tmp16 += 2; tmp16x8_3 = vld1q_s16(&lmagn[i]); // keep for several lines
// tmp16_1 = (Word16)(tmp16>>2); tmp16x8_5 = vsubq_s16(tmp16x8_3, tmp16x8_2);
tmp16x8_1 = vrshrq_n_s16(tmp16x8_0, 2); __asm__("vcgt.s16 %q0, %q1, #0"::"w"(tmp16x8_4), "w"(tmp16x8_5));
__asm__("vbit %q0, %q1, %q2"::"w"(tmp16x8_2), "w"(tmp16x8_1), "w"(tmp16x8_4));
__asm__("vbif %q0, %q1, %q2"::"w"(tmp16x8_2), "w"(tmp16x8_0), "w"(tmp16x8_4));
vst1q_s16(&inst->noiseEstLogQuantile[offset + i], tmp16x8_2);
// inst->noiseEstLogQuantile[offset+i] + tmp16_1; // Update density estimate
tmp16x8_2 = vld1q_s16(&inst->noiseEstLogQuantile[offset + i]); // Keep // tmp16_1 + tmp16_2
tmp16x8_1 = vaddq_s16(tmp16x8_2, tmp16x8_1); // Keep for several lines tmp16x8_1 = vld1q_s16(&inst->noiseEstDensity[offset + i]);
tmp16x8_0 = vqrdmulhq_s16(tmp16x8_1, countProd_16x8);
tmp16x8_0 = vaddq_s16(tmp16x8_0, prod16x8);
// Prepare for the "else" branch // lmagn[i] - inst->noiseEstLogQuantile[offset + i]
// tmp16 += 1; tmp16x8_3 = vsubq_s16(tmp16x8_3, tmp16x8_2);
// tmp16_1 = (Word16)(tmp16>>1); tmp16x8_3 = vabsq_s16(tmp16x8_3);
tmp16x8_0 = vrshrq_n_s16(tmp16x8_0, 1); tmp16x8_4 = vcgtq_s16(WIDTHQ8_16x8, tmp16x8_3);
__asm__("vbit %q0, %q1, %q2"::"w"(tmp16x8_1), "w"(tmp16x8_0), "w"(tmp16x8_4));
vst1q_s16(&inst->noiseEstDensity[offset + i], tmp16x8_1);
} // End loop over magnitude spectrum
// tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1); for (; i < inst->magnLen; i++) {
tmp32x4 = vmull_s16(vget_low_s16(tmp16x8_0), Q3_16x4); // compute delta
tmp16x4_1 = vshrn_n_s32(tmp32x4, 1); if (inst->noiseEstDensity[offset + i] > 512) {
delta = WebRtcSpl_DivW32W16ResW16(numerator,
// tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1); inst->noiseEstDensity[offset + i]);
tmp32x4 = vmull_s16(vget_high_s16(tmp16x8_0), Q3_16x4); } else {
tmp16x4_0 = vshrn_n_s32(tmp32x4, 1); delta = FACTOR_Q7;
if (inst->blockIndex < END_STARTUP_LONG) {
// inst->noiseEstLogQuantile[offset + i] - tmp16_2; // Smaller step size during startup. This prevents from using
tmp16x8_0 = vcombine_s16(tmp16x4_1, tmp16x4_0); // keep // unrealistic values causing overflow.
tmp16x8_0 = vsubq_s16(tmp16x8_2, tmp16x8_0); delta = FACTOR_Q7_STARTUP;
// logval is the smallest fixed point representation we can have. Values below
// that will correspond to values in the interval [0, 1], which can't possibly
// occur.
tmp16x8_0 = vmaxq_s16(tmp16x8_0, logval_16x8);
// Do the if-else branches:
tmp16x8_3 = vld1q_s16(&lmagn[i]); // keep for several lines
tmp16x8_5 = vsubq_s16(tmp16x8_3, tmp16x8_2);
__asm__("vcgt.s16 %q0, %q1, #0"::"w"(tmp16x8_4), "w"(tmp16x8_5));
__asm__("vbit %q0, %q1, %q2"::"w"(tmp16x8_2), "w"(tmp16x8_1), "w"(tmp16x8_4));
__asm__("vbif %q0, %q1, %q2"::"w"(tmp16x8_2), "w"(tmp16x8_0), "w"(tmp16x8_4));
vst1q_s16(&inst->noiseEstLogQuantile[offset + i], tmp16x8_2);
// Update density estimate
// tmp16_1 + tmp16_2
tmp16x8_1 = vld1q_s16(&inst->noiseEstDensity[offset + i]);
tmp16x8_0 = vqrdmulhq_s16(tmp16x8_1, countProd_16x8);
tmp16x8_0 = vaddq_s16(tmp16x8_0, prod16x8);
// lmagn[i] - inst->noiseEstLogQuantile[offset + i]
tmp16x8_3 = vsubq_s16(tmp16x8_3, tmp16x8_2);
tmp16x8_3 = vabsq_s16(tmp16x8_3);
tmp16x8_4 = vcgtq_s16(WIDTHQ8_16x8, tmp16x8_3);
__asm__("vbit %q0, %q1, %q2"::"w"(tmp16x8_1), "w"(tmp16x8_0), "w"(tmp16x8_4));
vst1q_s16(&inst->noiseEstDensity[offset + i], tmp16x8_1);
} // End loop over magnitude spectrum
for (; i < inst->magnLen; i++)
{
// compute delta
if (inst->noiseEstDensity[offset + i] > 512)
{
delta = WebRtcSpl_DivW32W16ResW16(numerator,
inst->noiseEstDensity[offset + i]);
} else
{
delta = FACTOR_Q7;
if (inst->blockIndex < END_STARTUP_LONG) {
// Smaller step size during startup. This prevents from using
// unrealistic values causing overflow.
delta = FACTOR_Q7_STARTUP;
}
}
// update log quantile estimate
tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(delta, countDiv, 14);
if (lmagn[i] > inst->noiseEstLogQuantile[offset + i])
{
// +=QUANTILE*delta/(inst->counter[s]+1) QUANTILE=0.25, =1 in Q2
// CounterDiv=1/(inst->counter[s]+1) in Q15
tmp16 += 2;
tmp16no1 = WEBRTC_SPL_RSHIFT_W16(tmp16, 2);
inst->noiseEstLogQuantile[offset + i] += tmp16no1;
} else
{
tmp16 += 1;
tmp16no1 = WEBRTC_SPL_RSHIFT_W16(tmp16, 1);
// *(1-QUANTILE), in Q2 QUANTILE=0.25, 1-0.25=0.75=3 in Q2
tmp16no2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16no1, 3, 1);
inst->noiseEstLogQuantile[offset + i] -= tmp16no2;
if (inst->noiseEstLogQuantile[offset + i] < logval) {
// logval is the smallest fixed point representation we can have.
// Values below that will correspond to values in the interval
// [0, 1], which can't possibly occur.
inst->noiseEstLogQuantile[offset + i] = logval;
}
}
// update density estimate
if (WEBRTC_SPL_ABS_W16(lmagn[i] - inst->noiseEstLogQuantile[offset + i])
< WIDTH_Q8)
{
tmp16no1 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
inst->noiseEstDensity[offset + i], countProd, 15);
tmp16no2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(widthFactor,
countDiv, 15);
inst->noiseEstDensity[offset + i] = tmp16no1 + tmp16no2;
}
} // end loop over magnitude spectrum
if (counter >= END_STARTUP_LONG)
{
inst->noiseEstCounter[s] = 0;
if (inst->blockIndex >= END_STARTUP_LONG)
{
WebRtcNsx_UpdateNoiseEstimate(inst, offset);
}
} }
inst->noiseEstCounter[s]++; }
} // end loop over simultaneous estimates // update log quantile estimate
tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(delta, countDiv, 14);
if (lmagn[i] > inst->noiseEstLogQuantile[offset + i]) {
// +=QUANTILE*delta/(inst->counter[s]+1) QUANTILE=0.25, =1 in Q2
// CounterDiv=1/(inst->counter[s]+1) in Q15
tmp16 += 2;
tmp16no1 = WEBRTC_SPL_RSHIFT_W16(tmp16, 2);
inst->noiseEstLogQuantile[offset + i] += tmp16no1;
} else {
tmp16 += 1;
tmp16no1 = WEBRTC_SPL_RSHIFT_W16(tmp16, 1);
// *(1-QUANTILE), in Q2 QUANTILE=0.25, 1-0.25=0.75=3 in Q2
tmp16no2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16no1, 3, 1);
inst->noiseEstLogQuantile[offset + i] -= tmp16no2;
if (inst->noiseEstLogQuantile[offset + i] < logval) {
// logval is the smallest fixed point representation we can have.
// Values below that will correspond to values in the interval
// [0, 1], which can't possibly occur.
inst->noiseEstLogQuantile[offset + i] = logval;
}
}
// Sequentially update the noise during startup // update density estimate
if (inst->blockIndex < END_STARTUP_LONG) if (WEBRTC_SPL_ABS_W16(lmagn[i] - inst->noiseEstLogQuantile[offset + i])
{ < WIDTH_Q8) {
tmp16no1 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
inst->noiseEstDensity[offset + i], countProd, 15);
tmp16no2 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(
widthFactor, countDiv, 15);
inst->noiseEstDensity[offset + i] = tmp16no1 + tmp16no2;
}
} // end loop over magnitude spectrum
if (counter >= END_STARTUP_LONG) {
inst->noiseEstCounter[s] = 0;
if (inst->blockIndex >= END_STARTUP_LONG) {
WebRtcNsx_UpdateNoiseEstimate(inst, offset); WebRtcNsx_UpdateNoiseEstimate(inst, offset);
}
} }
inst->noiseEstCounter[s]++;
for (i = 0; i < inst->magnLen; i++) } // end loop over simultaneous estimates
{
noise[i] = (WebRtc_UWord32)(inst->noiseEstQuantile[i]); // Q(qNoise) // Sequentially update the noise during startup
} if (inst->blockIndex < END_STARTUP_LONG) {
(*qNoise) = (WebRtc_Word16)inst->qNoise; WebRtcNsx_UpdateNoiseEstimate(inst, offset);
}
for (i = 0; i < inst->magnLen; i++) {
noise[i] = (WebRtc_UWord32)(inst->noiseEstQuantile[i]); // Q(qNoise)
}
(*qNoise) = (WebRtc_Word16)inst->qNoise;
} }
#endif // defined(WEBRTC_ARCH_ARM_NEON) && defined(WEBRTC_ANDROID) #endif // defined(WEBRTC_ARCH_ARM_NEON) && defined(WEBRTC_ANDROID)

File diff suppressed because it is too large Load Diff