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 19379bf084..3a60c1db8e 100644 --- a/webrtc/common_audio/signal_processing/include/signal_processing_library.h +++ b/webrtc/common_audio/signal_processing/include/signal_processing_library.h @@ -57,12 +57,12 @@ #endif #endif -#define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 5) \ - + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10)) -#define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \ - ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 2) \ - + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13)) +#define WEBRTC_SPL_MUL_16_32_RSFT11(a, b) \ + (WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 5) + \ + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x0200) >> 10)) +#define WEBRTC_SPL_MUL_16_32_RSFT14(a, b) \ + (WEBRTC_SPL_MUL_16_16(a, (b) >> 16) * (1 << 2) + \ + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x1000) >> 13)) #define WEBRTC_SPL_MUL_16_32_RSFT15(a, b) \ ((WEBRTC_SPL_MUL_16_16(a, (b) >> 16) << 1) \ + (((WEBRTC_SPL_MUL_16_U16(a, (uint16_t)(b)) >> 1) + 0x2000) >> 14)) @@ -82,8 +82,7 @@ // Shifting with negative numbers allowed // Positive means left shift -#define WEBRTC_SPL_SHIFT_W32(x, c) \ - (((c) >= 0) ? ((x) << (c)) : ((x) >> (-(c)))) +#define WEBRTC_SPL_SHIFT_W32(x, c) ((c) >= 0 ? (x) * (1 << (c)) : (x) >> -(c)) // Shifting with negative numbers not allowed // We cannot do casting here due to signed/unsigned problem diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c index e3de437a58..cf2d507cb5 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/decode.c @@ -182,7 +182,7 @@ int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16, for (k = 0; k < FRAMESAMPLES/2; k++) { - Vector_Word32_1[k] = (Vector_Word16_2[k] * gainQ13) << 3; // Q25 + Vector_Word32_1[k] = (Vector_Word16_2[k] * gainQ13) * (1 << 3); // Q25 } @@ -192,7 +192,7 @@ int WebRtcIsacfix_DecodeImpl(int16_t* signal_out16, /* --- Store Highpass Residual --- */ for (k = 0; k < FRAMESAMPLES/2; k++) - Vector_Word32_1[k] = Vector_Word32_2[k] << 9; // Q16 -> Q25 + Vector_Word32_1[k] = Vector_Word32_2[k] * (1 << 9); // Q16 -> Q25 for( k = 0; k < PITCH_MAX_LAG + 10; k++ ) (ISACdec_obj->plcstr_obj).prevHP[k] = Vector_Word32_1[FRAMESAMPLES/2 - (PITCH_MAX_LAG + 10) + k]; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c index c9ddf93580..8e351277c3 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c @@ -255,7 +255,7 @@ static void CalcInvArSpec(const int16_t *ARCoefQ12, } for (k=0; k>16)<<3 = Q17, with 1/0.45 = 2.222222222222 ~= 18204 in Q13 - tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]) << 3; + tmp32 = + WEBRTC_SPL_MUL_16_32_RSFT16(18204, tmpcoeffs_sQ17[poss]) * (1 << 3); tmp32 = tmp32 + WebRtcIsacfix_kMeansShapeQ17[model][poss]; // Q17+Q17 = Q17 LPCCoefQ17[pos] = tmp32; } 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 b5d91d4219..2e92578cf7 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/filterbanks.c @@ -50,33 +50,37 @@ void WebRtcIsacfix_AllpassFilter2FixDec16C( // Process channel 1: in_out = data_ch1[n]; a = factor_ch1[0] * in_out; // Q15 * Q0 = Q15 - a <<= 1; // Q15 -> Q16 + a *= 1 << 1; // Q15 -> Q16 b = WebRtcSpl_AddSatW32(a, state0_ch1); a = -factor_ch1[0] * (int16_t)(b >> 16); // Q15 - state0_ch1 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16 + state0_ch1 = + WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16 in_out = (int16_t) (b >> 16); // Save as Q0 a = factor_ch1[1] * in_out; // Q15 * Q0 = Q15 - a <<= 1; // Q15 -> Q16 + a *= 1 << 1; // Q15 -> Q16 b = WebRtcSpl_AddSatW32(a, state1_ch1); // Q16 a = -factor_ch1[1] * (int16_t)(b >> 16); // Q15 - state1_ch1 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16 + state1_ch1 = + WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16 data_ch1[n] = (int16_t) (b >> 16); // Save as Q0 // Process channel 2: in_out = data_ch2[n]; a = factor_ch2[0] * in_out; // Q15 * Q0 = Q15 - a <<= 1; // Q15 -> Q16 + a *= 1 << 1; // Q15 -> Q16 b = WebRtcSpl_AddSatW32(a, state0_ch2); // Q16 a = -factor_ch2[0] * (int16_t)(b >> 16); // Q15 - state0_ch2 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16 + state0_ch2 = + WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16 in_out = (int16_t) (b >> 16); // Save as Q0 a = factor_ch2[1] * in_out; // Q15 * Q0 = Q15 - a <<= 1; // Q15 -> Q16 + a *= (1 << 1); // Q15 -> Q16 b = WebRtcSpl_AddSatW32(a, state1_ch2); // Q16 a = -factor_ch2[1] * (int16_t)(b >> 16); // Q15 - state1_ch2 = WebRtcSpl_AddSatW32(a << 1, (uint32_t)in_out << 16); // Q16 + state1_ch2 = + WebRtcSpl_AddSatW32(a * (1 << 1), (int32_t)in_out * (1 << 16)); // Q16 data_ch2[n] = (int16_t) (b >> 16); // Save as Q0 } @@ -144,11 +148,11 @@ void WebRtcIsacfix_HighpassFilterFixDec32C(int16_t *io, c = in + ((a1 + b1) >> 7); // Q0. io[k] = (int16_t)WebRtcSpl_SatW32ToW16(c); // Write output as Q0. - c = (in << 2) - a2 - b2; // In Q2. + c = in * (1 << 2) - a2 - b2; // In Q2. c = (int32_t)WEBRTC_SPL_SAT(536870911, c, -536870912); state1 = state0; - state0 = c << 2; // Write state as Q4 + state0 = c * (1 << 2); // Write state as Q4 } state[0] = state0; state[1] = state1; diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c index 22224a8071..2e9d0664ef 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/lattice.c @@ -274,7 +274,7 @@ void WebRtcIsacfix_NormLatticeFilterAr(size_t orderCoef, for (i=0;iQ26 + tmp32 = lat_inQ25[i + temp1] * (1 << 1); // Q25->Q26 tmp32 = WEBRTC_SPL_MUL_16_32_RSFT16(inv_gain16, tmp32); //lat_in[]*inv_gain in (Q(18-sh)*Q26)>>16 = Q(28-sh) tmp32 = WEBRTC_SPL_SHIFT_W32(tmp32, -(28-sh)); // lat_in[]*inv_gain in Q0 diff --git a/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c b/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c index 621f921013..362610a1c4 100644 --- a/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c +++ b/webrtc/modules/audio_coding/codecs/isac/fix/source/transform.c @@ -132,10 +132,10 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q tmp1rQ14 = -WebRtcIsacfix_kSinTab2[FRAMESAMPLES/4 - 1 - k]; tmp1iQ14 = WebRtcIsacfix_kSinTab2[k]; - tmpInRe = inreQ7[k] << 9; // Q7 -> Q16 - tmpInIm = inimQ7[k] << 9; // Q7 -> Q16 - tmpInRe2 = inreQ7[FRAMESAMPLES / 2 - 1 - k] << 9; // Q7 -> Q16 - tmpInIm2 = inimQ7[FRAMESAMPLES / 2 - 1 - k] << 9; // Q7 -> Q16 + tmpInRe = inreQ7[k] * (1 << 9); // Q7 -> Q16 + tmpInIm = inimQ7[k] * (1 << 9); // Q7 -> Q16 + tmpInRe2 = inreQ7[FRAMESAMPLES / 2 - 1 - k] * (1 << 9); // Q7 -> Q16 + tmpInIm2 = inimQ7[FRAMESAMPLES / 2 - 1 - k] * (1 << 9); // Q7 -> Q16 xrQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInRe) + WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInIm); xiQ16 = WEBRTC_SPL_MUL_16_32_RSFT14(tmp1rQ14, tmpInIm) - WEBRTC_SPL_MUL_16_32_RSFT14(tmp1iQ14, tmpInRe); @@ -184,8 +184,8 @@ void WebRtcIsacfix_Spec2TimeC(int16_t *inreQ7, int16_t *inimQ7, int32_t *outre1Q } } else { for (k=0; k<240; k++) { - outre1Q16[k] = inreQ7[k] << -sh; // Q(16+sh) -> Q16 - outre2Q16[k] = inimQ7[k] << -sh; // Q(16+sh) -> Q16 + outre1Q16[k] = inreQ7[k] * (1 << -sh); // Q(16+sh) -> Q16 + outre2Q16[k] = inimQ7[k] * (1 << -sh); // Q(16+sh) -> Q16 } }