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}
diff --git a/webrtc/modules/audio_processing/ns/nsx_core.c b/webrtc/modules/audio_processing/ns/nsx_core.c
index 6faaeba..aa46d08 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core.c
@@ -513,9 +513,8 @@
}
// update synthesis buffer
- WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer,
- inst->synthesisBuffer + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
+ memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
+ (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
+ inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
}
@@ -527,11 +526,10 @@
int i = 0;
// For lower band update analysis buffer.
- WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer,
- inst->analysisBuffer + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
- WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer
- + inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
+ memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
+ (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
+ memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms, new_speech,
+ inst->blockLen10ms * sizeof(*inst->analysisBuffer));
// Window data before FFT.
for (i = 0; i < inst->anaLen; i++) {
@@ -1443,9 +1441,8 @@
outFrame[i] = inst->synthesisBuffer[i]; // Q0
}
// update synthesis buffer
- WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer,
- inst->synthesisBuffer + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
+ memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
+ (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer + inst->anaLen - inst->blockLen10ms,
inst->blockLen10ms);
return;
@@ -1578,13 +1575,11 @@
// update analysis buffer for H band
// append new data to buffer FX
for (i = 0; i < num_high_bands; ++i) {
- WEBRTC_SPL_MEMCPY_W16(inst->dataBufHBFX[i],
- inst->dataBufHBFX[i] + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
- WEBRTC_SPL_MEMCPY_W16(
- inst->dataBufHBFX[i] + inst->anaLen - inst->blockLen10ms,
- speechFrameHB[i],
- inst->blockLen10ms);
+ int block_shift = inst->anaLen - inst->blockLen10ms;
+ memcpy(inst->dataBufHBFX[i], inst->dataBufHBFX[i] + inst->blockLen10ms,
+ block_shift * sizeof(*inst->dataBufHBFX[i]));
+ memcpy(inst->dataBufHBFX[i] + block_shift, speechFrameHB[i],
+ inst->blockLen10ms * sizeof(*inst->dataBufHBFX[i]));
for (j = 0; j < inst->blockLen10ms; j++) {
outFrameHB[i][j] = inst->dataBufHBFX[i][j]; // Q0
}
@@ -2043,13 +2038,10 @@
// update analysis buffer for H band
// append new data to buffer FX
for (i = 0; i < num_high_bands; ++i) {
- WEBRTC_SPL_MEMCPY_W16(inst->dataBufHBFX[i],
- inst->dataBufHBFX[i] + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
- WEBRTC_SPL_MEMCPY_W16(
- inst->dataBufHBFX[i] + inst->anaLen - inst->blockLen10ms,
- speechFrameHB[i],
- inst->blockLen10ms);
+ memcpy(inst->dataBufHBFX[i], inst->dataBufHBFX[i] + inst->blockLen10ms,
+ (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->dataBufHBFX[i]));
+ memcpy(inst->dataBufHBFX[i] + inst->anaLen - inst->blockLen10ms,
+ speechFrameHB[i], inst->blockLen10ms * sizeof(*inst->dataBufHBFX[i]));
}
// range for averaging low band quantities for H band gain
diff --git a/webrtc/modules/audio_processing/ns/nsx_core_mips.c b/webrtc/modules/audio_processing/ns/nsx_core_mips.c
index 6c29a04..be65c25 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core_mips.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core_mips.c
@@ -9,6 +9,7 @@
*/
#include <assert.h>
+#include <string.h>
#include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h"
#include "webrtc/modules/audio_processing/ns/nsx_core.h"
@@ -340,11 +341,10 @@
#endif
// For lower band update analysis buffer.
- WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer,
- inst->analysisBuffer + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
- WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer
- + inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
+ memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
+ (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
+ memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms, new_speech,
+ inst->blockLen10ms * sizeof(*inst->analysisBuffer));
// Window data before FFT.
#if defined(MIPS_DSP_R1_LE)
@@ -744,9 +744,8 @@
);
// update synthesis buffer
- WEBRTC_SPL_MEMCPY_W16(inst->synthesisBuffer,
- inst->synthesisBuffer + inst->blockLen10ms,
- inst->anaLen - inst->blockLen10ms);
+ memcpy(inst->synthesisBuffer, inst->synthesisBuffer + inst->blockLen10ms,
+ (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->synthesisBuffer));
WebRtcSpl_ZerosArrayW16(inst->synthesisBuffer
+ inst->anaLen - inst->blockLen10ms, inst->blockLen10ms);
}
diff --git a/webrtc/modules/audio_processing/ns/nsx_core_neon.c b/webrtc/modules/audio_processing/ns/nsx_core_neon.c
index ed735e8..1c4c816 100644
--- a/webrtc/modules/audio_processing/ns/nsx_core_neon.c
+++ b/webrtc/modules/audio_processing/ns/nsx_core_neon.c
@@ -541,9 +541,8 @@
assert(inst->anaLen % 16 == 0);
// For lower band update analysis buffer.
- // WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer,
- // inst->analysisBuffer + inst->blockLen10ms,
- // inst->anaLen - inst->blockLen10ms);
+ // memcpy(inst->analysisBuffer, inst->analysisBuffer + inst->blockLen10ms,
+ // (inst->anaLen - inst->blockLen10ms) * sizeof(*inst->analysisBuffer));
int16_t* p_start_src = inst->analysisBuffer + inst->blockLen10ms;
int16_t* p_end_src = inst->analysisBuffer + inst->anaLen;
int16_t* p_start_dst = inst->analysisBuffer;
@@ -555,8 +554,8 @@
p_start_dst += 8;
}
- // WEBRTC_SPL_MEMCPY_W16(inst->analysisBuffer
- // + inst->anaLen - inst->blockLen10ms, new_speech, inst->blockLen10ms);
+ // memcpy(inst->analysisBuffer + inst->anaLen - inst->blockLen10ms,
+ // new_speech, inst->blockLen10ms * sizeof(*inst->analysisBuffer));
p_start_src = new_speech;
p_end_src = new_speech + inst->blockLen10ms;
p_start_dst = inst->analysisBuffer + inst->anaLen - inst->blockLen10ms;