From 0f911d71a75f9fbfc1006a1fdedfd6a7f6a6af62 Mon Sep 17 00:00:00 2001 From: Bjorn Volcker Date: Mon, 13 Apr 2015 15:45:17 +0200 Subject: [PATCH] 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} --- webrtc/modules/audio_processing/ns/nsx_core.c | 42 ++++++++----------- .../audio_processing/ns/nsx_core_mips.c | 15 ++++--- .../audio_processing/ns/nsx_core_neon.c | 9 ++-- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/webrtc/modules/audio_processing/ns/nsx_core.c b/webrtc/modules/audio_processing/ns/nsx_core.c index 6faaebac42..aa46d0867d 100644 --- a/webrtc/modules/audio_processing/ns/nsx_core.c +++ b/webrtc/modules/audio_processing/ns/nsx_core.c @@ -513,9 +513,8 @@ static void SynthesisUpdateC(NoiseSuppressionFixedC* inst, } // 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 @@ static void AnalysisUpdateC(NoiseSuppressionFixedC* inst, 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 @@ void WebRtcNsx_DataSynthesis(NoiseSuppressionFixedC* inst, short* outFrame) { 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 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst, // 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 @@ void WebRtcNsx_ProcessCore(NoiseSuppressionFixedC* inst, // 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 6c29a04c32..be65c25cca 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 +#include #include "webrtc/modules/audio_processing/ns/include/noise_suppression_x.h" #include "webrtc/modules/audio_processing/ns/nsx_core.h" @@ -340,11 +341,10 @@ void WebRtcNsx_AnalysisUpdate_mips(NoiseSuppressionFixedC* inst, #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 @@ void WebRtcNsx_SynthesisUpdate_mips(NoiseSuppressionFixedC* inst, ); // 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 ed735e8b8b..1c4c816e82 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 @@ void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst, 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 @@ void WebRtcNsx_AnalysisUpdateNeon(NoiseSuppressionFixedC* inst, 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;