Remove the different block lengths in ns_core
Relanding the CL: https://webrtc-codereview.appspot.com/30539004/ It had to be reverted because some development code was uploaded by mistake. TBR=bjornv@webrtc.org BUG=webrtc:3811 Review URL: https://webrtc-codereview.appspot.com/28589005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7307 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
5088377d70
commit
384d05f362
@ -90,24 +90,18 @@ int WebRtcNs_InitCore(NSinst_t* inst, uint32_t fs) {
|
|||||||
if (fs == 8000) {
|
if (fs == 8000) {
|
||||||
// We only support 10ms frames
|
// We only support 10ms frames
|
||||||
inst->blockLen = 80;
|
inst->blockLen = 80;
|
||||||
inst->blockLen10ms = 80;
|
|
||||||
inst->anaLen = 128;
|
inst->anaLen = 128;
|
||||||
inst->window = kBlocks80w128;
|
inst->window = kBlocks80w128;
|
||||||
inst->outLen = 0;
|
|
||||||
} else if (fs == 16000) {
|
} else if (fs == 16000) {
|
||||||
// We only support 10ms frames
|
// We only support 10ms frames
|
||||||
inst->blockLen = 160;
|
inst->blockLen = 160;
|
||||||
inst->blockLen10ms = 160;
|
|
||||||
inst->anaLen = 256;
|
inst->anaLen = 256;
|
||||||
inst->window = kBlocks160w256;
|
inst->window = kBlocks160w256;
|
||||||
inst->outLen = 0;
|
|
||||||
} else if (fs == 32000) {
|
} else if (fs == 32000) {
|
||||||
// We only support 10ms frames
|
// We only support 10ms frames
|
||||||
inst->blockLen = 160;
|
inst->blockLen = 160;
|
||||||
inst->blockLen10ms = 160;
|
|
||||||
inst->anaLen = 256;
|
inst->anaLen = 256;
|
||||||
inst->window = kBlocks160w256;
|
inst->window = kBlocks160w256;
|
||||||
inst->outLen = 0;
|
|
||||||
}
|
}
|
||||||
inst->magnLen = inst->anaLen / 2 + 1; // Number of frequency bins
|
inst->magnLen = inst->anaLen / 2 + 1; // Number of frequency bins
|
||||||
|
|
||||||
@ -215,8 +209,6 @@ int WebRtcNs_InitCore(NSinst_t* inst, uint32_t fs) {
|
|||||||
// default mode
|
// default mode
|
||||||
WebRtcNs_set_policy_core(inst, 0);
|
WebRtcNs_set_policy_core(inst, 0);
|
||||||
|
|
||||||
memset(inst->outBuf, 0, sizeof(float) * 3 * BLOCKL_MAX);
|
|
||||||
|
|
||||||
inst->initFlag = 1;
|
inst->initFlag = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -789,14 +781,12 @@ int WebRtcNs_AnalyzeCore(NSinst_t* inst, float* speechFrame) {
|
|||||||
|
|
||||||
// update analysis buffer for L band
|
// update analysis buffer for L band
|
||||||
memcpy(inst->analyzeBuf,
|
memcpy(inst->analyzeBuf,
|
||||||
inst->analyzeBuf + inst->blockLen10ms,
|
inst->analyzeBuf + inst->blockLen,
|
||||||
sizeof(float) * (inst->anaLen - inst->blockLen10ms));
|
sizeof(float) * (inst->anaLen - inst->blockLen));
|
||||||
memcpy(inst->analyzeBuf + inst->anaLen - inst->blockLen10ms,
|
memcpy(inst->analyzeBuf + inst->anaLen - inst->blockLen,
|
||||||
speechFrame,
|
speechFrame,
|
||||||
sizeof(float) * inst->blockLen10ms);
|
sizeof(float) * inst->blockLen);
|
||||||
|
|
||||||
// check if processing needed
|
|
||||||
if (inst->outLen == 0) {
|
|
||||||
// windowing
|
// windowing
|
||||||
energy = 0.0;
|
energy = 0.0;
|
||||||
for (i = 0; i < inst->anaLen; i++) {
|
for (i = 0; i < inst->anaLen; i++) {
|
||||||
@ -868,8 +858,7 @@ int WebRtcNs_AnalyzeCore(NSinst_t* inst, float* speechFrame) {
|
|||||||
// compute simplified noise model during startup
|
// compute simplified noise model during startup
|
||||||
if (inst->blockInd < END_STARTUP_SHORT) {
|
if (inst->blockInd < END_STARTUP_SHORT) {
|
||||||
// Estimate White noise
|
// Estimate White noise
|
||||||
inst->whiteNoiseLevel +=
|
inst->whiteNoiseLevel += sumMagn / ((float)inst->magnLen) * inst->overdrive;
|
||||||
sumMagn / ((float)inst->magnLen) * inst->overdrive;
|
|
||||||
// Estimate Pink noise parameters
|
// Estimate Pink noise parameters
|
||||||
tmpFloat1 = sum_log_i_square * ((float)(inst->magnLen - kStartBand));
|
tmpFloat1 = sum_log_i_square * ((float)(inst->magnLen - kStartBand));
|
||||||
tmpFloat1 -= (sum_log_i * sum_log_i);
|
tmpFloat1 -= (sum_log_i * sum_log_i);
|
||||||
@ -1007,8 +996,7 @@ int WebRtcNs_AnalyzeCore(NSinst_t* inst, float* speechFrame) {
|
|||||||
}
|
}
|
||||||
// conservative noise update
|
// conservative noise update
|
||||||
if (probSpeech < PROB_RANGE) {
|
if (probSpeech < PROB_RANGE) {
|
||||||
inst->magnAvgPause[i] +=
|
inst->magnAvgPause[i] += GAMMA_PAUSE * (magn[i] - inst->magnAvgPause[i]);
|
||||||
GAMMA_PAUSE * (magn[i] - inst->magnAvgPause[i]);
|
|
||||||
}
|
}
|
||||||
// noise update
|
// noise update
|
||||||
if (gammaNoiseTmp == gammaNoiseOld) {
|
if (gammaNoiseTmp == gammaNoiseOld) {
|
||||||
@ -1032,7 +1020,6 @@ int WebRtcNs_AnalyzeCore(NSinst_t* inst, float* speechFrame) {
|
|||||||
for (i = 0; i < inst->magnLen; i++) {
|
for (i = 0; i < inst->magnLen; i++) {
|
||||||
inst->noisePrev[i] = noise[i];
|
inst->noisePrev[i] = noise[i];
|
||||||
}
|
}
|
||||||
} // end of if inst->outLen == 0
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -1081,24 +1068,22 @@ int WebRtcNs_ProcessCore(NSinst_t* inst,
|
|||||||
|
|
||||||
// update analysis buffer for L band
|
// update analysis buffer for L band
|
||||||
memcpy(inst->dataBuf,
|
memcpy(inst->dataBuf,
|
||||||
inst->dataBuf + inst->blockLen10ms,
|
inst->dataBuf + inst->blockLen,
|
||||||
sizeof(float) * (inst->anaLen - inst->blockLen10ms));
|
sizeof(float) * (inst->anaLen - inst->blockLen));
|
||||||
memcpy(inst->dataBuf + inst->anaLen - inst->blockLen10ms,
|
memcpy(inst->dataBuf + inst->anaLen - inst->blockLen,
|
||||||
speechFrame,
|
speechFrame,
|
||||||
sizeof(float) * inst->blockLen10ms);
|
sizeof(float) * inst->blockLen);
|
||||||
|
|
||||||
if (flagHB == 1) {
|
if (flagHB == 1) {
|
||||||
// update analysis buffer for H band
|
// update analysis buffer for H band
|
||||||
memcpy(inst->dataBufHB,
|
memcpy(inst->dataBufHB,
|
||||||
inst->dataBufHB + inst->blockLen10ms,
|
inst->dataBufHB + inst->blockLen,
|
||||||
sizeof(float) * (inst->anaLen - inst->blockLen10ms));
|
sizeof(float) * (inst->anaLen - inst->blockLen));
|
||||||
memcpy(inst->dataBufHB + inst->anaLen - inst->blockLen10ms,
|
memcpy(inst->dataBufHB + inst->anaLen - inst->blockLen,
|
||||||
speechFrameHB,
|
speechFrameHB,
|
||||||
sizeof(float) * inst->blockLen10ms);
|
sizeof(float) * inst->blockLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if processing needed
|
|
||||||
if (inst->outLen == 0) {
|
|
||||||
// windowing
|
// windowing
|
||||||
energy1 = 0.0;
|
energy1 = 0.0;
|
||||||
for (i = 0; i < inst->anaLen; i++) {
|
for (i = 0; i < inst->anaLen; i++) {
|
||||||
@ -1119,26 +1104,18 @@ int WebRtcNs_ProcessCore(NSinst_t* inst,
|
|||||||
0,
|
0,
|
||||||
sizeof(float) * inst->blockLen);
|
sizeof(float) * inst->blockLen);
|
||||||
|
|
||||||
// out buffer
|
for (i = 0; i < inst->blockLen; ++i)
|
||||||
inst->outLen = inst->blockLen - inst->blockLen10ms;
|
outFrame[i] =
|
||||||
if (inst->blockLen > inst->blockLen10ms) {
|
WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, fout[i], WEBRTC_SPL_WORD16_MIN);
|
||||||
for (i = 0; i < inst->outLen; i++) {
|
|
||||||
inst->outBuf[i] = fout[i + inst->blockLen10ms];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < inst->blockLen10ms; ++i)
|
|
||||||
outFrame[i] = WEBRTC_SPL_SAT(
|
|
||||||
WEBRTC_SPL_WORD16_MAX, fout[i], WEBRTC_SPL_WORD16_MIN);
|
|
||||||
|
|
||||||
// for time-domain gain of HB
|
// for time-domain gain of HB
|
||||||
if (flagHB == 1)
|
if (flagHB == 1)
|
||||||
for (i = 0; i < inst->blockLen10ms; ++i)
|
for (i = 0; i < inst->blockLen; ++i)
|
||||||
outFrameHB[i] = WEBRTC_SPL_SAT(
|
outFrameHB[i] = WEBRTC_SPL_SAT(
|
||||||
WEBRTC_SPL_WORD16_MAX, inst->dataBufHB[i], WEBRTC_SPL_WORD16_MIN);
|
WEBRTC_SPL_WORD16_MAX, inst->dataBufHB[i], WEBRTC_SPL_WORD16_MIN);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FFT
|
// FFT
|
||||||
WebRtc_rdft(inst->anaLen, 1, winData, inst->ip, inst->wfft);
|
WebRtc_rdft(inst->anaLen, 1, winData, inst->ip, inst->wfft);
|
||||||
|
|
||||||
@ -1281,28 +1258,7 @@ int WebRtcNs_ProcessCore(NSinst_t* inst,
|
|||||||
0,
|
0,
|
||||||
sizeof(float) * inst->blockLen);
|
sizeof(float) * inst->blockLen);
|
||||||
|
|
||||||
// out buffer
|
for (i = 0; i < inst->blockLen; ++i)
|
||||||
inst->outLen = inst->blockLen - inst->blockLen10ms;
|
|
||||||
if (inst->blockLen > inst->blockLen10ms) {
|
|
||||||
for (i = 0; i < inst->outLen; i++) {
|
|
||||||
inst->outBuf[i] = fout[i + inst->blockLen10ms];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // end of if out.len==0
|
|
||||||
else {
|
|
||||||
for (i = 0; i < inst->blockLen10ms; i++) {
|
|
||||||
fout[i] = inst->outBuf[i];
|
|
||||||
}
|
|
||||||
memcpy(inst->outBuf,
|
|
||||||
inst->outBuf + inst->blockLen10ms,
|
|
||||||
sizeof(float) * (inst->outLen - inst->blockLen10ms));
|
|
||||||
memset(inst->outBuf + inst->outLen - inst->blockLen10ms,
|
|
||||||
0,
|
|
||||||
sizeof(float) * inst->blockLen10ms);
|
|
||||||
inst->outLen -= inst->blockLen10ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < inst->blockLen10ms; ++i)
|
|
||||||
outFrame[i] =
|
outFrame[i] =
|
||||||
WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, fout[i], WEBRTC_SPL_WORD16_MIN);
|
WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, fout[i], WEBRTC_SPL_WORD16_MIN);
|
||||||
|
|
||||||
@ -1343,7 +1299,7 @@ int WebRtcNs_ProcessCore(NSinst_t* inst,
|
|||||||
gainTimeDomainHB = 1.0;
|
gainTimeDomainHB = 1.0;
|
||||||
}
|
}
|
||||||
// apply gain
|
// apply gain
|
||||||
for (i = 0; i < inst->blockLen10ms; i++) {
|
for (i = 0; i < inst->blockLen; i++) {
|
||||||
float o = gainTimeDomainHB * inst->dataBufHB[i];
|
float o = gainTimeDomainHB * inst->dataBufHB[i];
|
||||||
outFrameHB[i] =
|
outFrameHB[i] =
|
||||||
WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, o, WEBRTC_SPL_WORD16_MIN);
|
WEBRTC_SPL_SAT(WEBRTC_SPL_WORD16_MAX, o, WEBRTC_SPL_WORD16_MIN);
|
||||||
|
@ -52,9 +52,7 @@ typedef struct NSParaExtract_t_ {
|
|||||||
typedef struct NSinst_t_ {
|
typedef struct NSinst_t_ {
|
||||||
uint32_t fs;
|
uint32_t fs;
|
||||||
int blockLen;
|
int blockLen;
|
||||||
int blockLen10ms;
|
|
||||||
int windShift;
|
int windShift;
|
||||||
int outLen;
|
|
||||||
int anaLen;
|
int anaLen;
|
||||||
int magnLen;
|
int magnLen;
|
||||||
int aggrMode;
|
int aggrMode;
|
||||||
@ -62,7 +60,6 @@ typedef struct NSinst_t_ {
|
|||||||
float analyzeBuf[ANAL_BLOCKL_MAX];
|
float analyzeBuf[ANAL_BLOCKL_MAX];
|
||||||
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];
|
|
||||||
|
|
||||||
int initFlag;
|
int initFlag;
|
||||||
// parameters for quantile noise estimation
|
// parameters for quantile noise estimation
|
||||||
|
Loading…
x
Reference in New Issue
Block a user