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:
parent
fa41d807a8
commit
af57de006a
@ -30,7 +30,7 @@ extern "C" {
|
||||
* Return value : 0 - Ok
|
||||
* -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
|
||||
* -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
|
||||
* -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
|
||||
* -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.
|
||||
@ -90,7 +90,7 @@ int WebRtcNs_Init(NsHandle *NS_inst, WebRtc_UWord32 fs);
|
||||
* Return value : 0 - Ok
|
||||
* -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
|
||||
* -1 - Error
|
||||
*/
|
||||
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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ extern "C" {
|
||||
* Return value : 0 - Ok
|
||||
* -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
|
||||
* -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
|
||||
* -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
|
||||
* -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.
|
||||
@ -90,7 +90,7 @@ int WebRtcNsx_Init(NsxHandle *nsxInst, WebRtc_UWord32 fs);
|
||||
* Return value : 0 - Ok
|
||||
* -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
|
||||
@ -110,11 +110,11 @@ int WebRtcNsx_set_policy(NsxHandle *nsxInst, int mode);
|
||||
* Return value : 0 - OK
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNsx_Process(NsxHandle *nsxInst,
|
||||
short *speechFrame,
|
||||
short *speechFrameHB,
|
||||
short *outFrame,
|
||||
short *outFrameHB);
|
||||
int WebRtcNsx_Process(NsxHandle* nsxInst,
|
||||
short* speechFrame,
|
||||
short* speechFrameHB,
|
||||
short* outFrame,
|
||||
short* outFrameHB);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -15,55 +15,51 @@
|
||||
#include "ns_core.h"
|
||||
#include "defines.h"
|
||||
|
||||
int WebRtcNs_get_version(char *versionStr, short length)
|
||||
{
|
||||
const char version[] = "NS 2.2.0";
|
||||
const short versionLen = (short)strlen(version) + 1; // +1 for null-termination
|
||||
int WebRtcNs_get_version(char* versionStr, short length) {
|
||||
const char version[] = "NS 2.2.0";
|
||||
const short versionLen = (short)strlen(version) + 1; // +1: null-termination
|
||||
|
||||
if (versionStr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (versionStr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (versionLen > length) {
|
||||
return -1;
|
||||
}
|
||||
if (versionLen > length) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int WebRtcNs_Free(NsHandle *NS_inst)
|
||||
{
|
||||
free(NS_inst);
|
||||
return 0;
|
||||
int WebRtcNs_Free(NsHandle* NS_inst) {
|
||||
free(NS_inst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int WebRtcNs_Init(NsHandle *NS_inst, WebRtc_UWord32 fs)
|
||||
{
|
||||
return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
|
||||
int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) {
|
||||
return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
|
||||
}
|
||||
|
||||
int WebRtcNs_set_policy(NsHandle *NS_inst, int mode)
|
||||
{
|
||||
return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
|
||||
int WebRtcNs_set_policy(NsHandle* NS_inst, int 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)
|
||||
{
|
||||
return WebRtcNs_ProcessCore((NSinst_t*) NS_inst, spframe, spframe_H, outframe, 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);
|
||||
}
|
||||
|
@ -15,60 +15,51 @@
|
||||
#include "nsx_core.h"
|
||||
#include "nsx_defines.h"
|
||||
|
||||
int WebRtcNsx_get_version(char *versionStr, short length)
|
||||
{
|
||||
const char version[] = "NS\t3.1.0";
|
||||
const short versionLen = (short)strlen(version) + 1; // +1 for null-termination
|
||||
int WebRtcNsx_get_version(char* versionStr, short length) {
|
||||
const char version[] = "NS\t3.1.0";
|
||||
const short versionLen = (short)strlen(version) + 1; // +1: null-termination
|
||||
|
||||
if (versionStr == NULL)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (versionStr == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (versionLen > length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
if (versionLen > length) {
|
||||
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;
|
||||
}
|
||||
|
||||
int WebRtcNsx_Create(NsxHandle **nsxInst)
|
||||
{
|
||||
*nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t));
|
||||
if (*nsxInst != NULL)
|
||||
{
|
||||
(*(NsxInst_t**)nsxInst)->initFlag = 0;
|
||||
return 0;
|
||||
} else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int WebRtcNsx_Free(NsxHandle *nsxInst)
|
||||
{
|
||||
free(nsxInst);
|
||||
return 0;
|
||||
int WebRtcNsx_Free(NsxHandle* nsxInst) {
|
||||
free(nsxInst);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebRtcNsx_Init(NsxHandle *nsxInst, WebRtc_UWord32 fs)
|
||||
{
|
||||
return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
|
||||
int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs) {
|
||||
return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
|
||||
}
|
||||
|
||||
int WebRtcNsx_set_policy(NsxHandle *nsxInst, int mode)
|
||||
{
|
||||
return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
|
||||
int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) {
|
||||
return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
|
||||
}
|
||||
|
||||
int WebRtcNsx_Process(NsxHandle *nsxInst, short *speechFrame, short *speechFrameHB,
|
||||
short *outFrame, short *outFrameHB)
|
||||
{
|
||||
return WebRtcNsx_ProcessCore((NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame,
|
||||
outFrameHB);
|
||||
int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame,
|
||||
short* speechFrameHB, short* outFrame,
|
||||
short* outFrameHB) {
|
||||
return WebRtcNsx_ProcessCore(
|
||||
(NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB);
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -15,95 +15,95 @@
|
||||
|
||||
typedef struct NSParaExtract_t_ {
|
||||
|
||||
//bin size of histogram
|
||||
float binSizeLrt;
|
||||
float binSizeSpecFlat;
|
||||
float binSizeSpecDiff;
|
||||
//range of histogram over which lrt threshold is computed
|
||||
float rangeAvgHistLrt;
|
||||
//scale parameters: multiply dominant peaks of the histograms by scale factor to obtain
|
||||
//thresholds for prior model
|
||||
float factor1ModelPars; //for lrt and spectral difference
|
||||
float factor2ModelPars; //for spectral_flatness: used when noise is flatter than speech
|
||||
//peak limit for spectral flatness (varies between 0 and 1)
|
||||
float thresPosSpecFlat;
|
||||
//limit on spacing of two highest peaks in histogram: spacing determined by bin size
|
||||
float limitPeakSpacingSpecFlat;
|
||||
float limitPeakSpacingSpecDiff;
|
||||
//limit on relevance of second peak:
|
||||
float limitPeakWeightsSpecFlat;
|
||||
float limitPeakWeightsSpecDiff;
|
||||
//limit on fluctuation of lrt feature
|
||||
float thresFluctLrt;
|
||||
//limit on the max and min values for the feature thresholds
|
||||
float maxLrt;
|
||||
float minLrt;
|
||||
float maxSpecFlat;
|
||||
float minSpecFlat;
|
||||
float maxSpecDiff;
|
||||
float minSpecDiff;
|
||||
//criteria of weight of histogram peak to accept/reject feature
|
||||
int thresWeightSpecFlat;
|
||||
int thresWeightSpecDiff;
|
||||
//bin size of histogram
|
||||
float binSizeLrt;
|
||||
float binSizeSpecFlat;
|
||||
float binSizeSpecDiff;
|
||||
//range of histogram over which lrt threshold is computed
|
||||
float rangeAvgHistLrt;
|
||||
//scale parameters: multiply dominant peaks of the histograms by scale factor to obtain
|
||||
//thresholds for prior model
|
||||
float factor1ModelPars; //for lrt and spectral difference
|
||||
float factor2ModelPars; //for spectral_flatness: used when noise is flatter than speech
|
||||
//peak limit for spectral flatness (varies between 0 and 1)
|
||||
float thresPosSpecFlat;
|
||||
//limit on spacing of two highest peaks in histogram: spacing determined by bin size
|
||||
float limitPeakSpacingSpecFlat;
|
||||
float limitPeakSpacingSpecDiff;
|
||||
//limit on relevance of second peak:
|
||||
float limitPeakWeightsSpecFlat;
|
||||
float limitPeakWeightsSpecDiff;
|
||||
//limit on fluctuation of lrt feature
|
||||
float thresFluctLrt;
|
||||
//limit on the max and min values for the feature thresholds
|
||||
float maxLrt;
|
||||
float minLrt;
|
||||
float maxSpecFlat;
|
||||
float minSpecFlat;
|
||||
float maxSpecDiff;
|
||||
float minSpecDiff;
|
||||
//criteria of weight of histogram peak to accept/reject feature
|
||||
int thresWeightSpecFlat;
|
||||
int thresWeightSpecDiff;
|
||||
|
||||
} NSParaExtract_t;
|
||||
|
||||
typedef struct NSinst_t_ {
|
||||
|
||||
WebRtc_UWord32 fs;
|
||||
int blockLen;
|
||||
int blockLen10ms;
|
||||
int windShift;
|
||||
int outLen;
|
||||
int anaLen;
|
||||
int magnLen;
|
||||
int aggrMode;
|
||||
const float* window;
|
||||
float dataBuf[ANAL_BLOCKL_MAX];
|
||||
float syntBuf[ANAL_BLOCKL_MAX];
|
||||
float outBuf[3 * BLOCKL_MAX];
|
||||
WebRtc_UWord32 fs;
|
||||
int blockLen;
|
||||
int blockLen10ms;
|
||||
int windShift;
|
||||
int outLen;
|
||||
int anaLen;
|
||||
int magnLen;
|
||||
int aggrMode;
|
||||
const float* window;
|
||||
float dataBuf[ANAL_BLOCKL_MAX];
|
||||
float syntBuf[ANAL_BLOCKL_MAX];
|
||||
float outBuf[3 * BLOCKL_MAX];
|
||||
|
||||
int initFlag;
|
||||
// parameters for quantile noise estimation
|
||||
float density[SIMULT * HALF_ANAL_BLOCKL];
|
||||
float lquantile[SIMULT * HALF_ANAL_BLOCKL];
|
||||
float quantile[HALF_ANAL_BLOCKL];
|
||||
int counter[SIMULT];
|
||||
int updates;
|
||||
// parameters for Wiener filter
|
||||
float smooth[HALF_ANAL_BLOCKL];
|
||||
float overdrive;
|
||||
float denoiseBound;
|
||||
int gainmap;
|
||||
// fft work arrays.
|
||||
int ip[IP_LENGTH];
|
||||
float wfft[W_LENGTH];
|
||||
int initFlag;
|
||||
// parameters for quantile noise estimation
|
||||
float density[SIMULT* HALF_ANAL_BLOCKL];
|
||||
float lquantile[SIMULT* HALF_ANAL_BLOCKL];
|
||||
float quantile[HALF_ANAL_BLOCKL];
|
||||
int counter[SIMULT];
|
||||
int updates;
|
||||
// parameters for Wiener filter
|
||||
float smooth[HALF_ANAL_BLOCKL];
|
||||
float overdrive;
|
||||
float denoiseBound;
|
||||
int gainmap;
|
||||
// fft work arrays.
|
||||
int ip[IP_LENGTH];
|
||||
float wfft[W_LENGTH];
|
||||
|
||||
// parameters for new method: some not needed, will reduce/cleanup later
|
||||
WebRtc_Word32 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 noisePrev[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame
|
||||
float magnPrev[HALF_ANAL_BLOCKL]; //magnitude spectrum of previous frame
|
||||
float logLrtTimeAvg[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing
|
||||
float priorSpeechProb; //prior speech/noise probability
|
||||
float featureData[7]; //data for features
|
||||
float magnAvgPause[HALF_ANAL_BLOCKL]; //conservative noise spectrum estimate
|
||||
float signalEnergy; //energy of magn
|
||||
float sumMagn; //sum of magn
|
||||
float whiteNoiseLevel; //initial noise estimate
|
||||
float initMagnEst[HALF_ANAL_BLOCKL]; //initial magnitude spectrum estimate
|
||||
float pinkNoiseNumerator; //pink noise parameter: numerator
|
||||
float pinkNoiseExp; //pink noise parameter: power of freq
|
||||
NSParaExtract_t featureExtractionParams; //parameters for feature extraction
|
||||
//histograms for parameter estimation
|
||||
int histLrt[HIST_PAR_EST];
|
||||
int histSpecFlat[HIST_PAR_EST];
|
||||
int histSpecDiff[HIST_PAR_EST];
|
||||
//quantities for high band estimate
|
||||
float speechProbHB[HALF_ANAL_BLOCKL]; //final speech/noise prob: prior + LRT
|
||||
float dataBufHB[ANAL_BLOCKL_MAX]; //buffering data for HB
|
||||
// parameters for new method: some not needed, will reduce/cleanup later
|
||||
WebRtc_Word32 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 noisePrev[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame
|
||||
float magnPrev[HALF_ANAL_BLOCKL]; //magnitude spectrum of previous frame
|
||||
float logLrtTimeAvg[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing
|
||||
float priorSpeechProb; //prior speech/noise probability
|
||||
float featureData[7]; //data for features
|
||||
float magnAvgPause[HALF_ANAL_BLOCKL]; //conservative noise spectrum estimate
|
||||
float signalEnergy; //energy of magn
|
||||
float sumMagn; //sum of magn
|
||||
float whiteNoiseLevel; //initial noise estimate
|
||||
float initMagnEst[HALF_ANAL_BLOCKL]; //initial magnitude spectrum estimate
|
||||
float pinkNoiseNumerator; //pink noise parameter: numerator
|
||||
float pinkNoiseExp; //pink noise parameter: power of freq
|
||||
NSParaExtract_t featureExtractionParams; //parameters for feature extraction
|
||||
//histograms for parameter estimation
|
||||
int histLrt[HIST_PAR_EST];
|
||||
int histSpecFlat[HIST_PAR_EST];
|
||||
int histSpecDiff[HIST_PAR_EST];
|
||||
//quantities for high band estimate
|
||||
float speechProbHB[HALF_ANAL_BLOCKL]; //final speech/noise prob: prior + LRT
|
||||
float dataBufHB[ANAL_BLOCKL_MAX]; //buffering data for HB
|
||||
|
||||
} NSinst_t;
|
||||
|
||||
@ -127,7 +127,7 @@ extern "C" {
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNs_InitCore(NSinst_t *inst, WebRtc_UWord32 fs);
|
||||
int WebRtcNs_InitCore(NSinst_t* inst, WebRtc_UWord32 fs);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcNs_set_policy_core(...)
|
||||
@ -144,7 +144,7 @@ int WebRtcNs_InitCore(NSinst_t *inst, WebRtc_UWord32 fs);
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNs_set_policy_core(NSinst_t *inst, int mode);
|
||||
int WebRtcNs_set_policy_core(NSinst_t* inst, int mode);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcNs_ProcessCore
|
||||
@ -166,11 +166,11 @@ int WebRtcNs_set_policy_core(NSinst_t *inst, int mode);
|
||||
*/
|
||||
|
||||
|
||||
int WebRtcNs_ProcessCore(NSinst_t *inst,
|
||||
short *inFrameLow,
|
||||
short *inFrameHigh,
|
||||
short *outFrameLow,
|
||||
short *outFrameHigh);
|
||||
int WebRtcNs_ProcessCore(NSinst_t* inst,
|
||||
short* inFrameLow,
|
||||
short* inFrameHigh,
|
||||
short* outFrameLow,
|
||||
short* outFrameHigh);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,85 +20,84 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
typedef struct NsxInst_t_
|
||||
{
|
||||
WebRtc_UWord32 fs;
|
||||
typedef struct NsxInst_t_ {
|
||||
WebRtc_UWord32 fs;
|
||||
|
||||
const WebRtc_Word16* window;
|
||||
WebRtc_Word16 analysisBuffer[ANAL_BLOCKL_MAX];
|
||||
WebRtc_Word16 synthesisBuffer[ANAL_BLOCKL_MAX];
|
||||
WebRtc_UWord16 noiseSupFilter[HALF_ANAL_BLOCKL];
|
||||
WebRtc_UWord16 overdrive; /* Q8 */
|
||||
WebRtc_UWord16 denoiseBound; /* Q14 */
|
||||
const WebRtc_Word16* factor2Table;
|
||||
WebRtc_Word16 noiseEstLogQuantile[SIMULT * HALF_ANAL_BLOCKL];
|
||||
WebRtc_Word16 noiseEstDensity[SIMULT * HALF_ANAL_BLOCKL];
|
||||
WebRtc_Word16 noiseEstCounter[SIMULT];
|
||||
WebRtc_Word16 noiseEstQuantile[HALF_ANAL_BLOCKL];
|
||||
const WebRtc_Word16* window;
|
||||
WebRtc_Word16 analysisBuffer[ANAL_BLOCKL_MAX];
|
||||
WebRtc_Word16 synthesisBuffer[ANAL_BLOCKL_MAX];
|
||||
WebRtc_UWord16 noiseSupFilter[HALF_ANAL_BLOCKL];
|
||||
WebRtc_UWord16 overdrive; /* Q8 */
|
||||
WebRtc_UWord16 denoiseBound; /* Q14 */
|
||||
const WebRtc_Word16* factor2Table;
|
||||
WebRtc_Word16 noiseEstLogQuantile[SIMULT* HALF_ANAL_BLOCKL];
|
||||
WebRtc_Word16 noiseEstDensity[SIMULT* HALF_ANAL_BLOCKL];
|
||||
WebRtc_Word16 noiseEstCounter[SIMULT];
|
||||
WebRtc_Word16 noiseEstQuantile[HALF_ANAL_BLOCKL];
|
||||
|
||||
WebRtc_Word16 anaLen;
|
||||
int anaLen2;
|
||||
int magnLen;
|
||||
int aggrMode;
|
||||
int stages;
|
||||
int initFlag;
|
||||
int gainMap;
|
||||
WebRtc_Word16 anaLen;
|
||||
int anaLen2;
|
||||
int magnLen;
|
||||
int aggrMode;
|
||||
int stages;
|
||||
int initFlag;
|
||||
int gainMap;
|
||||
|
||||
WebRtc_Word32 maxLrt;
|
||||
WebRtc_Word32 minLrt;
|
||||
WebRtc_Word32 logLrtTimeAvgW32[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing in Q8
|
||||
WebRtc_Word32 featureLogLrt;
|
||||
WebRtc_Word32 thresholdLogLrt;
|
||||
WebRtc_Word16 weightLogLrt;
|
||||
WebRtc_Word32 maxLrt;
|
||||
WebRtc_Word32 minLrt;
|
||||
WebRtc_Word32 logLrtTimeAvgW32[HALF_ANAL_BLOCKL]; //log lrt factor with time-smoothing in Q8
|
||||
WebRtc_Word32 featureLogLrt;
|
||||
WebRtc_Word32 thresholdLogLrt;
|
||||
WebRtc_Word16 weightLogLrt;
|
||||
|
||||
WebRtc_UWord32 featureSpecDiff;
|
||||
WebRtc_UWord32 thresholdSpecDiff;
|
||||
WebRtc_Word16 weightSpecDiff;
|
||||
WebRtc_UWord32 featureSpecDiff;
|
||||
WebRtc_UWord32 thresholdSpecDiff;
|
||||
WebRtc_Word16 weightSpecDiff;
|
||||
|
||||
WebRtc_UWord32 featureSpecFlat;
|
||||
WebRtc_UWord32 thresholdSpecFlat;
|
||||
WebRtc_Word16 weightSpecFlat;
|
||||
WebRtc_UWord32 featureSpecFlat;
|
||||
WebRtc_UWord32 thresholdSpecFlat;
|
||||
WebRtc_Word16 weightSpecFlat;
|
||||
|
||||
WebRtc_Word32 avgMagnPause[HALF_ANAL_BLOCKL]; //conservative estimate of noise spectrum
|
||||
WebRtc_UWord32 magnEnergy;
|
||||
WebRtc_UWord32 sumMagn;
|
||||
WebRtc_UWord32 curAvgMagnEnergy;
|
||||
WebRtc_UWord32 timeAvgMagnEnergy;
|
||||
WebRtc_UWord32 timeAvgMagnEnergyTmp;
|
||||
WebRtc_Word32 avgMagnPause[HALF_ANAL_BLOCKL]; //conservative estimate of noise spectrum
|
||||
WebRtc_UWord32 magnEnergy;
|
||||
WebRtc_UWord32 sumMagn;
|
||||
WebRtc_UWord32 curAvgMagnEnergy;
|
||||
WebRtc_UWord32 timeAvgMagnEnergy;
|
||||
WebRtc_UWord32 timeAvgMagnEnergyTmp;
|
||||
|
||||
WebRtc_UWord32 whiteNoiseLevel; //initial noise estimate
|
||||
WebRtc_UWord32 initMagnEst[HALF_ANAL_BLOCKL];//initial magnitude spectrum estimate
|
||||
WebRtc_Word32 pinkNoiseNumerator; //pink noise parameter: numerator
|
||||
WebRtc_Word32 pinkNoiseExp; //pink noise parameter: power of freq
|
||||
int minNorm; //smallest normalization factor
|
||||
int zeroInputSignal; //zero input signal flag
|
||||
WebRtc_UWord32 whiteNoiseLevel; //initial noise estimate
|
||||
WebRtc_UWord32 initMagnEst[HALF_ANAL_BLOCKL];//initial magnitude spectrum estimate
|
||||
WebRtc_Word32 pinkNoiseNumerator; //pink noise parameter: numerator
|
||||
WebRtc_Word32 pinkNoiseExp; //pink noise parameter: power of freq
|
||||
int minNorm; //smallest normalization factor
|
||||
int zeroInputSignal; //zero input signal flag
|
||||
|
||||
WebRtc_UWord32 prevNoiseU32[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame
|
||||
WebRtc_UWord16 prevMagnU16[HALF_ANAL_BLOCKL]; //magnitude spectrum from previous frame
|
||||
WebRtc_Word16 priorNonSpeechProb; //prior speech/noise probability // Q14
|
||||
WebRtc_UWord32 prevNoiseU32[HALF_ANAL_BLOCKL]; //noise spectrum from previous frame
|
||||
WebRtc_UWord16 prevMagnU16[HALF_ANAL_BLOCKL]; //magnitude spectrum from previous frame
|
||||
WebRtc_Word16 priorNonSpeechProb; //prior speech/noise probability // Q14
|
||||
|
||||
int blockIndex; //frame index counter
|
||||
int modelUpdate; //parameter for updating or estimating thresholds/weights for prior model
|
||||
int cntThresUpdate;
|
||||
int blockIndex; //frame index counter
|
||||
int modelUpdate; //parameter for updating or estimating thresholds/weights for prior model
|
||||
int cntThresUpdate;
|
||||
|
||||
//histograms for parameter estimation
|
||||
WebRtc_Word16 histLrt[HIST_PAR_EST];
|
||||
WebRtc_Word16 histSpecFlat[HIST_PAR_EST];
|
||||
WebRtc_Word16 histSpecDiff[HIST_PAR_EST];
|
||||
//histograms for parameter estimation
|
||||
WebRtc_Word16 histLrt[HIST_PAR_EST];
|
||||
WebRtc_Word16 histSpecFlat[HIST_PAR_EST];
|
||||
WebRtc_Word16 histSpecDiff[HIST_PAR_EST];
|
||||
|
||||
//quantities for high band estimate
|
||||
WebRtc_Word16 dataBufHBFX[ANAL_BLOCKL_MAX]; /* Q0 */
|
||||
//quantities for high band estimate
|
||||
WebRtc_Word16 dataBufHBFX[ANAL_BLOCKL_MAX]; /* Q0 */
|
||||
|
||||
int qNoise;
|
||||
int prevQNoise;
|
||||
int prevQMagn;
|
||||
int blockLen10ms;
|
||||
int qNoise;
|
||||
int prevQNoise;
|
||||
int prevQMagn;
|
||||
int blockLen10ms;
|
||||
|
||||
WebRtc_Word16 real[ANAL_BLOCKL_MAX];
|
||||
WebRtc_Word16 imag[ANAL_BLOCKL_MAX];
|
||||
WebRtc_Word32 energyIn;
|
||||
int scaleEnergyIn;
|
||||
int normData;
|
||||
WebRtc_Word16 real[ANAL_BLOCKL_MAX];
|
||||
WebRtc_Word16 imag[ANAL_BLOCKL_MAX];
|
||||
WebRtc_Word32 energyIn;
|
||||
int scaleEnergyIn;
|
||||
int normData;
|
||||
|
||||
} NsxInst_t;
|
||||
|
||||
@ -122,7 +121,7 @@ extern "C"
|
||||
* Return value : 0 - Ok
|
||||
* -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(...)
|
||||
@ -139,7 +138,7 @@ WebRtc_Word32 WebRtcNsx_InitCore(NsxInst_t *inst, WebRtc_UWord32 fs);
|
||||
* Return value : 0 - Ok
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNsx_set_policy_core(NsxInst_t *inst, int mode);
|
||||
int WebRtcNsx_set_policy_core(NsxInst_t* inst, int mode);
|
||||
|
||||
/****************************************************************************
|
||||
* WebRtcNsx_ProcessCore
|
||||
@ -159,16 +158,16 @@ int WebRtcNsx_set_policy_core(NsxInst_t *inst, int mode);
|
||||
* Return value : 0 - OK
|
||||
* -1 - Error
|
||||
*/
|
||||
int WebRtcNsx_ProcessCore(NsxInst_t *inst, short *inFrameLow, short *inFrameHigh,
|
||||
short *outFrameLow, short *outFrameHigh);
|
||||
int WebRtcNsx_ProcessCore(NsxInst_t* inst, short* inFrameLow, short* inFrameHigh,
|
||||
short* outFrameLow, short* outFrameHigh);
|
||||
|
||||
/****************************************************************************
|
||||
* 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,
|
||||
WebRtc_Word16 *qNoise);
|
||||
void WebRtcNsx_NoiseEstimation(NsxInst_t* inst, WebRtc_UWord16* magn, WebRtc_UWord32* noise,
|
||||
WebRtc_Word16* qNoise);
|
||||
|
||||
extern const WebRtc_Word16 WebRtcNsx_kLogTable[9];
|
||||
extern const WebRtc_Word16 WebRtcNsx_kLogTableFrac[256];
|
||||
|
@ -15,242 +15,226 @@
|
||||
#include <arm_neon.h>
|
||||
#include <assert.h>
|
||||
|
||||
void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWord32 *noise,
|
||||
WebRtc_Word16 *qNoise)
|
||||
{
|
||||
WebRtc_Word32 numerator;
|
||||
void WebRtcNsx_NoiseEstimation(NsxInst_t* inst, WebRtc_UWord16* magn, WebRtc_UWord32* noise,
|
||||
WebRtc_Word16* qNoise) {
|
||||
WebRtc_Word32 numerator;
|
||||
|
||||
WebRtc_Word16 lmagn[HALF_ANAL_BLOCKL], counter, countDiv, countProd, delta, zeros, frac;
|
||||
WebRtc_Word16 log2, tabind, logval, tmp16, tmp16no1, tmp16no2;
|
||||
WebRtc_Word16 log2Const = 22713;
|
||||
WebRtc_Word16 widthFactor = 21845;
|
||||
WebRtc_Word16 lmagn[HALF_ANAL_BLOCKL], counter, countDiv, countProd, delta, zeros, frac;
|
||||
WebRtc_Word16 log2, tabind, logval, tmp16, tmp16no1, tmp16no2;
|
||||
WebRtc_Word16 log2Const = 22713;
|
||||
WebRtc_Word16 widthFactor = 21845;
|
||||
|
||||
int i, s, offset;
|
||||
int i, s, offset;
|
||||
|
||||
numerator = FACTOR_Q16;
|
||||
numerator = FACTOR_Q16;
|
||||
|
||||
tabind = inst->stages - inst->normData;
|
||||
assert(tabind < 9);
|
||||
assert(tabind > -9);
|
||||
if (tabind < 0)
|
||||
{
|
||||
logval = -WebRtcNsx_kLogTable[-tabind];
|
||||
} else
|
||||
{
|
||||
logval = WebRtcNsx_kLogTable[tabind];
|
||||
tabind = inst->stages - inst->normData;
|
||||
assert(tabind < 9);
|
||||
assert(tabind > -9);
|
||||
if (tabind < 0) {
|
||||
logval = -WebRtcNsx_kLogTable[-tabind];
|
||||
} else {
|
||||
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))
|
||||
// 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;
|
||||
WebRtc_Word16 factor = FACTOR_Q7;
|
||||
if (inst->blockIndex < END_STARTUP_LONG)
|
||||
factor = FACTOR_Q7_STARTUP;
|
||||
|
||||
// Loop over simultaneous estimates
|
||||
for (s = 0; s < SIMULT; s++) {
|
||||
offset = s * inst->magnLen;
|
||||
|
||||
// Get counter values from state
|
||||
counter = inst->noiseEstCounter[s];
|
||||
assert(counter < 201);
|
||||
countDiv = WebRtcNsx_kCounterDiv[counter];
|
||||
countProd = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(counter, countDiv);
|
||||
|
||||
// quant_est(...)
|
||||
WebRtc_Word16 deltaBuff[8];
|
||||
int16x4_t tmp16x4_0;
|
||||
int16x4_t tmp16x4_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) {
|
||||
// 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);
|
||||
int16x8_t WIDTHQ8_16x8 = vdupq_n_s16(WIDTH_Q8);
|
||||
int16x8_t WIDTHFACTOR_16x8 = vdupq_n_s16(widthFactor);
|
||||
// Update log quantile estimate
|
||||
|
||||
WebRtc_Word16 factor = FACTOR_Q7;
|
||||
if (inst->blockIndex < END_STARTUP_LONG)
|
||||
factor = FACTOR_Q7_STARTUP;
|
||||
// tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(delta, countDiv, 14);
|
||||
tmp32x4 = vmull_s16(vld1_s16(&deltaBuff[0]), countDiv_16x4);
|
||||
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
|
||||
for (s = 0; s < SIMULT; s++)
|
||||
{
|
||||
offset = s * inst->magnLen;
|
||||
// prepare for the "if" branch
|
||||
// tmp16 += 2;
|
||||
// tmp16_1 = (Word16)(tmp16>>2);
|
||||
tmp16x8_1 = vrshrq_n_s16(tmp16x8_0, 2);
|
||||
|
||||
// Get counter values from state
|
||||
counter = inst->noiseEstCounter[s];
|
||||
assert(counter < 201);
|
||||
countDiv = WebRtcNsx_kCounterDiv[counter];
|
||||
countProd = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16(counter, countDiv);
|
||||
// inst->noiseEstLogQuantile[offset+i] + tmp16_1;
|
||||
tmp16x8_2 = vld1q_s16(&inst->noiseEstLogQuantile[offset + i]); // Keep
|
||||
tmp16x8_1 = vaddq_s16(tmp16x8_2, tmp16x8_1); // Keep for several lines
|
||||
|
||||
// quant_est(...)
|
||||
WebRtc_Word16 deltaBuff[8];
|
||||
int16x4_t tmp16x4_0;
|
||||
int16x4_t tmp16x4_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;
|
||||
// Prepare for the "else" branch
|
||||
// tmp16 += 1;
|
||||
// tmp16_1 = (Word16)(tmp16>>1);
|
||||
tmp16x8_0 = vrshrq_n_s16(tmp16x8_0, 1);
|
||||
|
||||
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);
|
||||
// tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1);
|
||||
tmp32x4 = vmull_s16(vget_low_s16(tmp16x8_0), Q3_16x4);
|
||||
tmp16x4_1 = vshrn_n_s32(tmp32x4, 1);
|
||||
|
||||
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]);
|
||||
}
|
||||
// tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1);
|
||||
tmp32x4 = vmull_s16(vget_high_s16(tmp16x8_0), Q3_16x4);
|
||||
tmp16x4_0 = vshrn_n_s32(tmp32x4, 1);
|
||||
|
||||
// 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);
|
||||
tmp32x4 = vmull_s16(vld1_s16(&deltaBuff[0]), countDiv_16x4);
|
||||
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.
|
||||
// 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);
|
||||
|
||||
// prepare for the "if" branch
|
||||
// tmp16 += 2;
|
||||
// tmp16_1 = (Word16)(tmp16>>2);
|
||||
tmp16x8_1 = vrshrq_n_s16(tmp16x8_0, 2);
|
||||
// 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);
|
||||
|
||||
// inst->noiseEstLogQuantile[offset+i] + tmp16_1;
|
||||
tmp16x8_2 = vld1q_s16(&inst->noiseEstLogQuantile[offset + i]); // Keep
|
||||
tmp16x8_1 = vaddq_s16(tmp16x8_2, tmp16x8_1); // Keep for several lines
|
||||
// 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);
|
||||
|
||||
// Prepare for the "else" branch
|
||||
// tmp16 += 1;
|
||||
// tmp16_1 = (Word16)(tmp16>>1);
|
||||
tmp16x8_0 = vrshrq_n_s16(tmp16x8_0, 1);
|
||||
// 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
|
||||
|
||||
// tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1);
|
||||
tmp32x4 = vmull_s16(vget_low_s16(tmp16x8_0), Q3_16x4);
|
||||
tmp16x4_1 = vshrn_n_s32(tmp32x4, 1);
|
||||
|
||||
// tmp16_2 = (Word16)WEBRTC_SPL_MUL_16_16_RSFT(tmp16_1,3,1);
|
||||
tmp32x4 = vmull_s16(vget_high_s16(tmp16x8_0), Q3_16x4);
|
||||
tmp16x4_0 = vshrn_n_s32(tmp32x4, 1);
|
||||
|
||||
// inst->noiseEstLogQuantile[offset + i] - tmp16_2;
|
||||
tmp16x8_0 = vcombine_s16(tmp16x4_1, tmp16x4_0); // keep
|
||||
tmp16x8_0 = vsubq_s16(tmp16x8_2, tmp16x8_0);
|
||||
|
||||
// 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);
|
||||
}
|
||||
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;
|
||||
}
|
||||
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
|
||||
if (inst->blockIndex < END_STARTUP_LONG)
|
||||
{
|
||||
// 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]++;
|
||||
|
||||
for (i = 0; i < inst->magnLen; i++)
|
||||
{
|
||||
noise[i] = (WebRtc_UWord32)(inst->noiseEstQuantile[i]); // Q(qNoise)
|
||||
}
|
||||
(*qNoise) = (WebRtc_Word16)inst->qNoise;
|
||||
} // end loop over simultaneous estimates
|
||||
|
||||
// Sequentially update the noise during startup
|
||||
if (inst->blockIndex < END_STARTUP_LONG) {
|
||||
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)
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user