diff --git a/webrtc/common_audio/signal_processing/include/signal_processing_library.h b/webrtc/common_audio/signal_processing/include/signal_processing_library.h index a658645d6..36ee34f9c 100644 --- a/webrtc/common_audio/signal_processing/include/signal_processing_library.h +++ b/webrtc/common_audio/signal_processing/include/signal_processing_library.h @@ -75,9 +75,6 @@ #define WEBRTC_SPL_MUL_16_32_RSFT16(a, b) \ (WEBRTC_SPL_MUL_16_16(a, b >> 16) \ + ((WEBRTC_SPL_MUL_16_16(a, (b & 0xffff) >> 1) + 0x4000) >> 15)) -#define WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, b32) \ - ((int32_t)(WEBRTC_SPL_MUL_16_32_RSFT16(a32a, b32) \ - + (WEBRTC_SPL_MUL_16_32_RSFT16(a32b, b32) >> 16))) #endif #endif diff --git a/webrtc/common_audio/signal_processing/include/spl_inl_armv7.h b/webrtc/common_audio/signal_processing/include/spl_inl_armv7.h index a437a5556..b52ebc53d 100644 --- a/webrtc/common_audio/signal_processing/include/spl_inl_armv7.h +++ b/webrtc/common_audio/signal_processing/include/spl_inl_armv7.h @@ -30,25 +30,6 @@ static __inline int32_t WEBRTC_SPL_MUL_16_32_RSFT16(int16_t a, int32_t b) { return tmp; } -/* This function produces result that is not bit exact with that by the generic - * C version in some cases, although the former is at least as accurate as the - * later. - */ -static __inline int32_t WEBRTC_SPL_MUL_32_32_RSFT32(int16_t a, - int16_t b, - int32_t c) { - int32_t tmp = 0; - __asm __volatile ( - "pkhbt %[tmp], %[b], %[a], lsl #16\n\t" - "smmulr %[tmp], %[tmp], %[c]\n\t" - :[tmp]"+&r"(tmp) - :[a]"r"(a), - [b]"r"(b), - [c]"r"(c) - ); - return tmp; -} - static __inline int32_t WEBRTC_SPL_MUL_32_32_RSFT32BI(int32_t a, int32_t b) { int32_t tmp = 0; __asm volatile ("smmulr %0, %1, %2":"=r"(tmp):"r"(a), "r"(b)); diff --git a/webrtc/common_audio/signal_processing/include/spl_inl_mips.h b/webrtc/common_audio/signal_processing/include/spl_inl_mips.h index e17377778..f29f701da 100644 --- a/webrtc/common_audio/signal_processing/include/spl_inl_mips.h +++ b/webrtc/common_audio/signal_processing/include/spl_inl_mips.h @@ -78,50 +78,6 @@ static __inline int32_t WEBRTC_SPL_MUL_32_32_RSFT32BI(int32_t a, return tmp; } -static __inline int32_t WEBRTC_SPL_MUL_32_32_RSFT32(int16_t a, - int16_t b, - int32_t c) { - int32_t tmp1 = 0, tmp2 = 0, tmp3 = 0, tmp4 = 0; - - __asm __volatile( - "sra %[tmp1], %[c], 16 \n\t" - "andi %[tmp2], %[c], 0xFFFF \n\t" -#if defined(MIPS32_R2_LE) - "seh %[a], %[a] \n\t" - "seh %[b], %[b] \n\t" -#else - "sll %[a], %[a], 16 \n\t" - "sra %[a], %[a], 16 \n\t" - "sll %[b], %[b], 16 \n\t" - "sra %[b], %[b], 16 \n\t" -#endif - "sra %[tmp2], %[tmp2], 1 \n\t" - "mul %[tmp3], %[a], %[tmp2] \n\t" - "mul %[tmp4], %[b], %[tmp2] \n\t" - "mul %[tmp2], %[a], %[tmp1] \n\t" - "mul %[tmp1], %[b], %[tmp1] \n\t" -#if defined(MIPS_DSP_R1_LE) - "shra_r.w %[tmp3], %[tmp3], 15 \n\t" - "shra_r.w %[tmp4], %[tmp4], 15 \n\t" -#else - "addiu %[tmp3], %[tmp3], 0x4000 \n\t" - "sra %[tmp3], %[tmp3], 15 \n\t" - "addiu %[tmp4], %[tmp4], 0x4000 \n\t" - "sra %[tmp4], %[tmp4], 15 \n\t" -#endif - "addu %[tmp3], %[tmp3], %[tmp2] \n\t" - "addu %[tmp4], %[tmp4], %[tmp1] \n\t" - "sra %[tmp4], %[tmp4], 16 \n\t" - "addu %[tmp1], %[tmp3], %[tmp4] \n\t" - : [tmp1] "=&r" (tmp1), [tmp2] "=&r" (tmp2), - [tmp3] "=&r" (tmp3), [tmp4] "=&r" (tmp4), - [a] "+r" (a), [b] "+r" (b) - : [c] "r" (c) - : "hi", "lo" - ); - return tmp1; -} - #if defined(MIPS_DSP_R1_LE) static __inline int16_t WebRtcSpl_SatW32ToW16(int32_t value32) { __asm __volatile( diff --git a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc index 284fb83c6..2a3470892 100644 --- a/webrtc/common_audio/signal_processing/signal_processing_unittest.cc +++ b/webrtc/common_audio/signal_processing/signal_processing_unittest.cc @@ -61,10 +61,6 @@ TEST_F(SplTest, MacroTest) { EXPECT_EQ(-3, WEBRTC_SPL_MUL_16_32_RSFT14(a, b)); EXPECT_EQ(-24, WEBRTC_SPL_MUL_16_32_RSFT11(a, b)); - int a32a = (WEBRTC_SPL_WORD32_MAX >> 16); - int a32b = (WEBRTC_SPL_WORD32_MAX & 0x0000ffff); - EXPECT_EQ(5, WEBRTC_SPL_MUL_32_32_RSFT32(a32a, a32b, A)); - EXPECT_EQ(-12288, WEBRTC_SPL_MUL_16_16_RSFT(a, b, 2)); EXPECT_EQ(-12287, WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(a, b, 2)); @@ -104,15 +100,10 @@ TEST_F(SplTest, MacroTest) { EXPECT_EQ(-1073741824, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, WEBRTC_SPL_WORD32_MAX)); - EXPECT_EQ(0x3fffffff, WEBRTC_SPL_MUL_32_32_RSFT32(WEBRTC_SPL_WORD16_MAX, - 0xffff, WEBRTC_SPL_WORD32_MAX)); #else EXPECT_EQ(-1073741823, WEBRTC_SPL_MUL_16_32_RSFT16(WEBRTC_SPL_WORD16_MIN, WEBRTC_SPL_WORD32_MAX)); - // TODO(bjornv): fix issue 3674 and re-enable or delete the following test. - // EXPECT_EQ(0x3fff7ffe, WEBRTC_SPL_MUL_32_32_RSFT32(WEBRTC_SPL_WORD16_MAX, - // 0xffff, WEBRTC_SPL_WORD32_MAX)); #endif } diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c index 1928a7cbf..c8dcb1664 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c @@ -129,12 +129,16 @@ void WebRtcIsacfix_HighpassFilterFixDec32C(int16_t *io, } #else /* Q35 * Q4 = Q39 ; shift 32 bit => Q7 */ - a1 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[5], coefficient[4], state0); - b1 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[7], coefficient[6], state1); + a1 = WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[5], state0) + + (WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[4], state0) >> 16); + b1 = WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[7], state1) + + (WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[6], state1) >> 16); /* Q30 * Q4 = Q34 ; shift 32 bit => Q2 */ - a2 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[1], coefficient[0], state0); - b2 = WEBRTC_SPL_MUL_32_32_RSFT32(coefficient[3], coefficient[2], state1); + a2 = WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[1], state0) + + (WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[0], state0) >> 16); + b2 = WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[3], state1) + + (WEBRTC_SPL_MUL_16_32_RSFT16(coefficient[2], state1) >> 16); #endif c = ((int32_t)in) + WEBRTC_SPL_RSHIFT_W32(a1+b1, 7); // Q0