Refactor audio_processing/nsx: Removed usage of macro WEBRTC_SPL_MEMCPY_W16

The macro assumes int16_t pointers, but there is no check for it.

BUG=3348,3353
TESTED=locally on Linux and trybots
R=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/48959004

Cr-Commit-Position: refs/heads/master@{#8987}
This commit is contained in:
Bjorn Volcker 2015-04-13 15:45:17 +02:00
parent 61a4b04f40
commit 0f911d71a7
3 changed files with 28 additions and 38 deletions

View File

@ -513,9 +513,8 @@ static void SynthesisUpdateC(NoiseSuppressionFixedC* inst,
} }
// update synthesis buffer // update synthesis buffer
WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer, memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
inst->synthesisBuffer + inst->blockLen10ms, (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
inst->anaLen - inst->blockLen10ms);
WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
+ inst->anaLen - inst->blockLen10ms, inst->blockLen10ms); + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
} }
@ -527,11 +526,10 @@ static void AnalysisUpdateC(NoiseSuppressionFixedC* inst,
int i = 0; int i = 0;
// For lower band update analysis buffer. // For lower band update analysis buffer.
WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer, memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
inst->analysisBuffer + inst->blockLen10ms, (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
inst->anaLen - inst->blockLen10ms); memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms, new_speech,
WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer inst->blockLen10ms * sizeof(*inst->analysisBuffer));
+ inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
// Window data before FFT. // Window data before FFT.
for (i = 0; i < inst->anaLen; i++) { for (i = 0; i < inst->anaLen; i++) {
@ -1443,9 +1441,8 @@ void WebRtcNsx_DataSynthesis(NoiseSuppressionFixedC* inst, short* outFrame) {
outFrame[i] = inst->synthesisBuffer[i]; // Q0 outFrame[i] = inst->synthesisBuffer[i]; // Q0
} }
// update synthesis buffer // update synthesis buffer
WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer, memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
inst->synthesisBuffer + inst->blockLen10ms, (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
inst->anaLen - inst->blockLen10ms);
WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer + inst->anaLen - inst->blockLen10ms, WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer + inst->anaLen - inst->blockLen10ms,
inst->blockLen10ms); inst->blockLen10ms);
return; return;
@ -1578,13 +1575,11 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst,
// update analysis buffer for H band // update analysis buffer for H band
// append new data to buffer FX // append new data to buffer FX
for (i = 0; i < num_high_bands; ++i) { for (i = 0; i < num_high_bands; ++i) {
WEBRTC_SPL_MEMCPY_W16(inst->dataBufHBFX[i], int block_shift = inst->anaLen - inst->blockLen10ms;
inst->dataBufHBFX[i] + inst->blockLen10ms, memcpy(inst->dataBufHBFX[i], inst->dataBufHBFX[i] + inst->blockLen10ms,
inst->anaLen - inst->blockLen10ms); block_shift * sizeof(*inst->dataBufHBFX[i]));
WEBRTC_SPL_MEMCPY_W16( memcpy(inst->dataBufHBFX[i] + block_shift, speechFrameHB[i],
inst->dataBufHBFX[i] + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms * sizeof(*inst->dataBufHBFX[i]));
speechFrameHB[i],
inst->blockLen10ms);
for (j = 0; j < inst->blockLen10ms; j++) { for (j = 0; j < inst->blockLen10ms; j++) {
outFrameHB[i][j] = inst->dataBufHBFX[i][j]; // Q0 outFrameHB[i][j] = inst->dataBufHBFX[i][j]; // Q0
} }
@ -2043,13 +2038,10 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst,
// update analysis buffer for H band // update analysis buffer for H band
// append new data to buffer FX // append new data to buffer FX
for (i = 0; i < num_high_bands; ++i) { for (i = 0; i < num_high_bands; ++i) {
WEBRTC_SPL_MEMCPY_W16(inst->dataBufHBFX[i], memcpy(inst->dataBufHBFX[i], inst->dataBufHBFX[i] + inst->blockLen10ms,
inst->dataBufHBFX[i] + inst->blockLen10ms, (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->dataBufHBFX[i]));
inst->anaLen - inst->blockLen10ms); memcpy(inst->dataBufHBFX[i] + inst->anaLen - inst->blockLen10ms,
WEBRTC_SPL_MEMCPY_W16( speechFrameHB[i], inst->blockLen10ms * sizeof(*inst->dataBufHBFX[i]));
inst->dataBufHBFX[i] + inst->anaLen - inst->blockLen10ms,
speechFrameHB[i],
inst->blockLen10ms);
} }
// range for averaging low band quantities for H band gain // range for averaging low band quantities for H band gain

View File

@ -9,6 +9,7 @@
*/ */
#include <assert.h> #include <assert.h>
#include <string.h>
#include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h" #include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h" #include "webrtc/modules/audio_processing/ns/nsx_core.h"
@ -340,11 +341,10 @@ void WebRtcNsx_AnalysisUpdate_mips(NoiseSuppressionFixedC* inst,
#endif #endif
// For lower band update analysis buffer. // For lower band update analysis buffer.
WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer, memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
inst->analysisBuffer + inst->blockLen10ms, (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
inst->anaLen - inst->blockLen10ms); memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms, new_speech,
WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer inst->blockLen10ms * sizeof(*inst->analysisBuffer));
+ inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
// Window data before FFT. // Window data before FFT.
#if defined(MIPS_DSP_R1_LE) #if defined(MIPS_DSP_R1_LE)
@ -744,9 +744,8 @@ void WebRtcNsx_SynthesisUpdate_mips(NoiseSuppressionFixedC* inst,
); );
// update synthesis buffer // update synthesis buffer
WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer, memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
inst->synthesisBuffer + inst->blockLen10ms, (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
inst->anaLen - inst->blockLen10ms);
WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
+ inst->anaLen - inst->blockLen10ms, inst->blockLen10ms); + inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
} }

View File

@ -541,9 +541,8 @@ void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst,
assert(inst->anaLen % 16 == 0); assert(inst->anaLen % 16 == 0);
// For lower band update analysis buffer. // For lower band update analysis buffer.
// WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer, // memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
// inst->analysisBuffer + inst->blockLen10ms, // (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
// inst->anaLen - inst->blockLen10ms);
int16_t* p_start_src = inst->analysisBuffer + inst->blockLen10ms; int16_t* p_start_src = inst->analysisBuffer + inst->blockLen10ms;
int16_t* p_end_src = inst->analysisBuffer + inst->anaLen; int16_t* p_end_src = inst->analysisBuffer + inst->anaLen;
int16_t* p_start_dst = inst->analysisBuffer; int16_t* p_start_dst = inst->analysisBuffer;
@ -555,8 +554,8 @@ void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst,
p_start_dst += 8; p_start_dst += 8;
} }
// WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer // memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms,
// + inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms); // new_speech, inst->blockLen10ms * sizeof(*inst->analysisBuffer));
p_start_src = new_speech; p_start_src = new_speech;
p_end_src = new_speech + inst->blockLen10ms; p_end_src = new_speech + inst->blockLen10ms;
p_start_dst = inst->analysisBuffer + inst->anaLen - inst->blockLen10ms; p_start_dst = inst->analysisBuffer + inst->anaLen - inst->blockLen10ms;