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
@ -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,8 +32,7 @@ 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;
|
||||
@ -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);
|
||||
}
|
||||
|
@ -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
File diff suppressed because it is too large
Load Diff
@ -20,8 +20,7 @@
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
typedef struct NsxInst_t_
|
||||
{
|
||||
typedef struct NsxInst_t_ {
|
||||
WebRtc_UWord32 fs;
|
||||
|
||||
const WebRtc_Word16* window;
|
||||
|
@ -16,8 +16,7 @@
|
||||
#include <assert.h>
|
||||
|
||||
void WebRtcNsx_NoiseEstimation(NsxInst_t* inst, WebRtc_UWord16* magn, WebRtc_UWord32* noise,
|
||||
WebRtc_Word16 *qNoise)
|
||||
{
|
||||
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;
|
||||
|
@ -568,6 +568,7 @@ static const float kBlocks480w1024[1024] = {
|
||||
(float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
|
||||
(float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
|
||||
(float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000,
|
||||
(float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000};
|
||||
(float)0.00000000, (float)0.00000000, (float)0.00000000, (float)0.00000000
|
||||
};
|
||||
|
||||
#endif // WEBRTC_MODULES_AUDIO_PROCESSING_NS_MAIN_SOURCE_WINDOWS_PRIVATE_H_
|
||||
|
Loading…
x
Reference in New Issue
Block a user