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
* -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
}

View File

@ -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
}

View File

@ -15,10 +15,9 @@
#include "ns_core.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 short versionLen = (short)strlen(version) + 1; // +1 for null-termination
const short versionLen = (short)strlen(version) + 1; // +1: null-termination
if (versionStr == NULL) {
return -1;
@ -33,11 +32,10 @@ int WebRtcNs_get_version(char *versionStr, short length)
return 0;
}
int WebRtcNs_Create(NsHandle **NS_inst)
{
int WebRtcNs_Create(NsHandle** NS_inst) {
*NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
if (*NS_inst!=NULL) {
(*(NSinst_t**)NS_inst)->initFlag=0;
if (*NS_inst != NULL) {
(*(NSinst_t**)NS_inst)->initFlag = 0;
return 0;
} else {
return -1;
@ -45,25 +43,23 @@ int WebRtcNs_Create(NsHandle **NS_inst)
}
int WebRtcNs_Free(NsHandle *NS_inst)
{
int WebRtcNs_Free(NsHandle* NS_inst) {
free(NS_inst);
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);
}
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);
}
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);
}

View File

@ -15,18 +15,15 @@
#include "nsx_core.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 short versionLen = (short)strlen(version) + 1; // +1 for null-termination
const short versionLen = (short)strlen(version) + 1; // +1: null-termination
if (versionStr == NULL)
{
if (versionStr == NULL) {
return -1;
}
if (versionLen > length)
{
if (versionLen > length) {
return -1;
}
@ -35,40 +32,34 @@ int WebRtcNsx_get_version(char *versionStr, short length)
return 0;
}
int WebRtcNsx_Create(NsxHandle **nsxInst)
{
int WebRtcNsx_Create(NsxHandle** nsxInst) {
*nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t));
if (*nsxInst != NULL)
{
if (*nsxInst != NULL) {
(*(NsxInst_t**)nsxInst)->initFlag = 0;
return 0;
} else
{
} else {
return -1;
}
}
int WebRtcNsx_Free(NsxHandle *nsxInst)
{
int WebRtcNsx_Free(NsxHandle* nsxInst) {
free(nsxInst);
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);
}
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);
}
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

View File

@ -65,8 +65,8 @@ typedef struct NSinst_t_ {
int initFlag;
// parameters for quantile noise estimation
float density[SIMULT * HALF_ANAL_BLOCKL];
float lquantile[SIMULT * HALF_ANAL_BLOCKL];
float density[SIMULT* HALF_ANAL_BLOCKL];
float lquantile[SIMULT* HALF_ANAL_BLOCKL];
float quantile[HALF_ANAL_BLOCKL];
int counter[SIMULT];
int updates;
@ -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

View File

@ -20,8 +20,7 @@
#include <stdio.h>
#endif
typedef struct NsxInst_t_
{
typedef struct NsxInst_t_ {
WebRtc_UWord32 fs;
const WebRtc_Word16* window;
@ -31,8 +30,8 @@ typedef struct NsxInst_t_
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 noiseEstLogQuantile[SIMULT* HALF_ANAL_BLOCKL];
WebRtc_Word16 noiseEstDensity[SIMULT* HALF_ANAL_BLOCKL];
WebRtc_Word16 noiseEstCounter[SIMULT];
WebRtc_Word16 noiseEstQuantile[HALF_ANAL_BLOCKL];
@ -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];

View File

@ -15,9 +15,8 @@
#include <arm_neon.h>
#include <assert.h>
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) {
WebRtc_Word32 numerator;
WebRtc_Word16 lmagn[HALF_ANAL_BLOCKL], counter, countDiv, countProd, delta, zeros, frac;
@ -32,11 +31,9 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
tabind = inst->stages - inst->normData;
assert(tabind < 9);
assert(tabind > -9);
if (tabind < 0)
{
if (tabind < 0) {
logval = -WebRtcNsx_kLogTable[-tabind];
} else
{
} else {
logval = WebRtcNsx_kLogTable[tabind];
}
@ -46,10 +43,8 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
// 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])
{
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);
@ -59,8 +54,7 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
lmagn[i] = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(log2, log2Const, 15);
// + log(2^stages)
lmagn[i] += logval;
} else
{
} else {
lmagn[i] = logval;
}
}
@ -74,8 +68,7 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
factor = FACTOR_Q7_STARTUP;
// Loop over simultaneous estimates
for (s = 0; s < SIMULT; s++)
{
for (s = 0; s < SIMULT; s++) {
offset = s * inst->magnLen;
// Get counter values from state
@ -108,9 +101,10 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
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]);
if (inst->noiseEstDensity[offset + i + j] > 512) {
deltaBuff[j] = WebRtcSpl_DivW32W16ResW16(
numerator, inst->noiseEstDensity[offset + i + j]);
}
}
// Update log quantile estimate
@ -175,15 +169,12 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
vst1q_s16(&inst->noiseEstDensity[offset + i], tmp16x8_1);
} // End loop over magnitude spectrum
for (; i < inst->magnLen; i++)
{
for (; i < inst->magnLen; i++) {
// compute delta
if (inst->noiseEstDensity[offset + i] > 512)
{
if (inst->noiseEstDensity[offset + i] > 512) {
delta = WebRtcSpl_DivW32W16ResW16(numerator,
inst->noiseEstDensity[offset + i]);
} else
{
} else {
delta = FACTOR_Q7;
if (inst->blockIndex < END_STARTUP_LONG) {
// Smaller step size during startup. This prevents from using
@ -194,15 +185,13 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
// update log quantile estimate
tmp16 = (WebRtc_Word16)WEBRTC_SPL_MUL_16_16_RSFT(delta, countDiv, 14);
if (lmagn[i] > inst->noiseEstLogQuantile[offset + i])
{
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
{
} 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
@ -218,21 +207,18 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
// update density estimate
if (WEBRTC_SPL_ABS_W16(lmagn[i] - inst->noiseEstLogQuantile[offset + i])
< WIDTH_Q8)
{
< 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);
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)
{
if (counter >= END_STARTUP_LONG) {
inst->noiseEstCounter[s] = 0;
if (inst->blockIndex >= END_STARTUP_LONG)
{
if (inst->blockIndex >= END_STARTUP_LONG) {
WebRtcNsx_UpdateNoiseEstimate(inst, offset);
}
}
@ -241,13 +227,11 @@ void WebRtcNsx_NoiseEstimation(NsxInst_t *inst, WebRtc_UWord16 *magn, WebRtc_UWo
} // end loop over simultaneous estimates
// Sequentially update the noise during startup
if (inst->blockIndex < END_STARTUP_LONG)
{
if (inst->blockIndex < END_STARTUP_LONG) {
WebRtcNsx_UpdateNoiseEstimate(inst, offset);
}
for (i = 0; i < inst->magnLen; i++)
{
for (i = 0; i < inst->magnLen; i++) {
noise[i] = (WebRtc_UWord32)(inst->noiseEstQuantile[i]); // Q(qNoise)
}
(*qNoise) = (WebRtc_Word16)inst->qNoise;

File diff suppressed because it is too large Load Diff