diff --git a/webrtc/common_audio/signal_processing/complex_fft.c b/webrtc/common_audio/signal_processing/complex_fft.c index 74b4258a8e..aaeda52ad9 100644 --- a/webrtc/common_audio/signal_processing/complex_fft.c +++ b/webrtc/common_audio/signal_processing/complex_fft.c @@ -126,11 +126,9 @@ int WebRtcSpl_ComplexFFT(int16_t frfi[], int stages, int mode) [wri]"r"(wri), [cfftrnd]"r"(CFFTRND)); #else - tr32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j]) - - WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j + 1]) + CFFTRND; + tr32 = wr * frfi[2 * j] - wi * frfi[2 * j + 1] + CFFTRND; - ti32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1]) - + WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j]) + CFFTRND; + ti32 = wr * frfi[2 * j + 1] + wi * frfi[2 * j] + CFFTRND; #endif tr32 >>= 15 - CFFTSFT; @@ -270,11 +268,9 @@ int WebRtcSpl_ComplexIFFT(int16_t frfi[], int stages, int mode) ); #else - tr32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j]) - - WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j + 1]) + CIFFTRND; + tr32 = wr * frfi[2 * j] - wi * frfi[2 * j + 1] + CIFFTRND; - ti32 = WEBRTC_SPL_MUL_16_16(wr, frfi[2 * j + 1]) - + WEBRTC_SPL_MUL_16_16(wi, frfi[2 * j]) + CIFFTRND; + ti32 = wr * frfi[2 * j + 1] + wi * frfi[2 * j] + CIFFTRND; #endif tr32 >>= 15 - CIFFTSFT; ti32 >>= 15 - CIFFTSFT; diff --git a/webrtc/common_audio/signal_processing/division_operations.c b/webrtc/common_audio/signal_processing/division_operations.c index 6aeb0fb2bf..eaa06a1ff9 100644 --- a/webrtc/common_audio/signal_processing/division_operations.c +++ b/webrtc/common_audio/signal_processing/division_operations.c @@ -106,8 +106,7 @@ int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low) // result in Q14 (Note: 3FFFFFFF = 0.5 in Q30) // tmpW32 = 1/den = approx * (2.0 - den * approx) (in Q30) - tmpW32 = (WEBRTC_SPL_MUL_16_16(den_hi, approx) << 1) - + ((WEBRTC_SPL_MUL_16_16(den_low, approx) >> 15) << 1); + tmpW32 = (den_hi * approx << 1) + ((den_low * approx >> 15) << 1); // tmpW32 = den * approx tmpW32 = (int32_t)0x7fffffffL - tmpW32; // result in Q30 (tmpW32 = 2.0-(den*approx)) @@ -117,8 +116,7 @@ int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low) tmp_low = (int16_t)((tmpW32 - ((int32_t)tmp_hi << 16)) >> 1); // tmpW32 = 1/den in Q29 - tmpW32 = ((WEBRTC_SPL_MUL_16_16(tmp_hi, approx) + (WEBRTC_SPL_MUL_16_16(tmp_low, approx) - >> 15)) << 1); + tmpW32 = (tmp_hi * approx + (tmp_low * approx >> 15)) << 1; // 1/den in hi and low format tmp_hi = (int16_t)(tmpW32 >> 16); @@ -130,8 +128,8 @@ int32_t WebRtcSpl_DivW32HiLow(int32_t num, int16_t den_hi, int16_t den_low) // num * (1/den) by 32 bit multiplication (result in Q28) - tmpW32 = (WEBRTC_SPL_MUL_16_16(num_hi, tmp_hi) + (WEBRTC_SPL_MUL_16_16(num_hi, tmp_low) - >> 15) + (WEBRTC_SPL_MUL_16_16(num_low, tmp_hi) >> 15)); + tmpW32 = num_hi * tmp_hi + (num_hi * tmp_low >> 15) + + (num_low * tmp_hi >> 15); // Put result in Q31 (convert from Q28) tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3); diff --git a/webrtc/common_audio/signal_processing/filter_ar.c b/webrtc/common_audio/signal_processing/filter_ar.c index 7386808c61..2a1805c7ad 100644 --- a/webrtc/common_audio/signal_processing/filter_ar.c +++ b/webrtc/common_audio/signal_processing/filter_ar.c @@ -51,13 +51,13 @@ int WebRtcSpl_FilterAR(const int16_t* a, stop = (i < a_length) ? i + 1 : a_length; for (j = 1; j < stop; j++) { - o -= WEBRTC_SPL_MUL_16_16(*a_ptr, *filtered_ptr--); - oLOW -= WEBRTC_SPL_MUL_16_16(*a_ptr++, *filtered_low_ptr--); + o -= *a_ptr * *filtered_ptr--; + oLOW -= *a_ptr++ * *filtered_low_ptr--; } for (j = i + 1; j < a_length; j++) { - o -= WEBRTC_SPL_MUL_16_16(*a_ptr, *state_ptr--); - oLOW -= WEBRTC_SPL_MUL_16_16(*a_ptr++, *state_low_ptr--); + o -= *a_ptr * *state_ptr--; + oLOW -= *a_ptr++ * *state_low_ptr--; } o += (oLOW >> 12); diff --git a/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c b/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c index 943b01c1d9..afec8393d3 100644 --- a/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c +++ b/webrtc/common_audio/signal_processing/filter_ma_fast_q12.c @@ -23,18 +23,14 @@ void WebRtcSpl_FilterMAFastQ12(const int16_t* in_ptr, int16_t B_length, int16_t length) { - int32_t o; int i, j; for (i = 0; i < length; i++) { - const int16_t* b_ptr = &B[0]; - const int16_t* x_ptr = &in_ptr[i]; - - o = (int32_t)0; + int32_t o = 0; for (j = 0; j < B_length; j++) { - o += WEBRTC_SPL_MUL_16_16(*b_ptr++, *x_ptr--); + o += B[j] * in_ptr[i - j]; } // If output is higher than 32768, saturate it. Same with negative side diff --git a/webrtc/common_audio/signal_processing/ilbc_specific_functions.c b/webrtc/common_audio/signal_processing/ilbc_specific_functions.c index de870b239b..dae25a445f 100644 --- a/webrtc/common_audio/signal_processing/ilbc_specific_functions.c +++ b/webrtc/common_audio/signal_processing/ilbc_specific_functions.c @@ -68,16 +68,11 @@ void WebRtcSpl_AddAffineVectorToVector(int16_t *out, int16_t *in, int16_t gain, int32_t add_constant, int16_t right_shifts, int vector_length) { - int16_t *inPtr; - int16_t *outPtr; int i; - inPtr = in; - outPtr = out; for (i = 0; i < vector_length; i++) { - (*outPtr++) += (int16_t)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) - + (int32_t)add_constant) >> right_shifts); + out[i] += (int16_t)((in[i] * gain + add_constant) >> right_shifts); } } @@ -85,15 +80,10 @@ void WebRtcSpl_AffineTransformVector(int16_t *out, int16_t *in, int16_t gain, int32_t add_constant, int16_t right_shifts, int vector_length) { - int16_t *inPtr; - int16_t *outPtr; int i; - inPtr = in; - outPtr = out; for (i = 0; i < vector_length; i++) { - (*outPtr++) = (int16_t)((WEBRTC_SPL_MUL_16_16((*inPtr++), gain) - + (int32_t)add_constant) >> right_shifts); + out[i] = (int16_t)((in[i] * gain + add_constant) >> right_shifts); } } diff --git a/webrtc/common_audio/signal_processing/levinson_durbin.c b/webrtc/common_audio/signal_processing/levinson_durbin.c index e07af5d3b6..eaf51430de 100644 --- a/webrtc/common_audio/signal_processing/levinson_durbin.c +++ b/webrtc/common_audio/signal_processing/levinson_durbin.c @@ -76,8 +76,7 @@ int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, // Alpha = R[0] * (1-K^2) - temp1W32 = (((WEBRTC_SPL_MUL_16_16(K_hi, K_low) >> 14) + WEBRTC_SPL_MUL_16_16(K_hi, K_hi)) - << 1); // temp1W32 = k^2 in Q31 + temp1W32 = ((K_hi * K_low >> 14) + K_hi * K_hi) << 1; // = k^2 in Q31 temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0 temp1W32 = (int32_t)0x7fffffffL - temp1W32; // temp1W32 = (1 - K[0]*K[0]) in Q31 @@ -87,9 +86,8 @@ int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, tmp_low = (int16_t)((temp1W32 - ((int32_t)tmp_hi << 16)) >> 1); // Calculate Alpha in Q31 - temp1W32 = ((WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_hi) - + (WEBRTC_SPL_MUL_16_16(R_hi[0], tmp_low) >> 15) - + (WEBRTC_SPL_MUL_16_16(R_low[0], tmp_hi) >> 15)) << 1); + temp1W32 = (R_hi[0] * tmp_hi + (R_hi[0] * tmp_low >> 15) + + (R_low[0] * tmp_hi >> 15)) << 1; // Normalize Alpha and put it in hi and low format @@ -113,10 +111,10 @@ int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, for (j = 1; j < i; j++) { - // temp1W32 is in Q31 - temp1W32 += ((WEBRTC_SPL_MUL_16_16(R_hi[j], A_hi[i-j]) << 1) - + (((WEBRTC_SPL_MUL_16_16(R_hi[j], A_low[i-j]) >> 15) - + (WEBRTC_SPL_MUL_16_16(R_low[j], A_hi[i-j]) >> 15)) << 1)); + // temp1W32 is in Q31 + temp1W32 += (R_hi[j] * A_hi[i - j] << 1) + + (((R_hi[j] * A_low[i - j] >> 15) + + (R_low[j] * A_hi[i - j] >> 15)) << 1); } temp1W32 = WEBRTC_SPL_LSHIFT_W32(temp1W32, 4); @@ -177,9 +175,8 @@ int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, + WEBRTC_SPL_LSHIFT_W32((int32_t)A_low[j],1); // temp1W32 += K*A[i-j] in Q27 - temp1W32 += ((WEBRTC_SPL_MUL_16_16(K_hi, A_hi[i-j]) - + (WEBRTC_SPL_MUL_16_16(K_hi, A_low[i-j]) >> 15) - + (WEBRTC_SPL_MUL_16_16(K_low, A_hi[i-j]) >> 15)) << 1); + temp1W32 += (K_hi * A_hi[i - j] + (K_hi * A_low[i - j] >> 15) + + (K_low * A_hi[i - j] >> 15)) << 1; // Put Anew in hi and low format A_upd_hi[j] = (int16_t)(temp1W32 >> 16); @@ -197,8 +194,7 @@ int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, // Alpha = Alpha * (1-K^2) - temp1W32 = (((WEBRTC_SPL_MUL_16_16(K_hi, K_low) >> 14) - + WEBRTC_SPL_MUL_16_16(K_hi, K_hi)) << 1); // K*K in Q31 + temp1W32 = ((K_hi * K_low >> 14) + K_hi * K_hi) << 1; // K*K in Q31 temp1W32 = WEBRTC_SPL_ABS_W32(temp1W32); // Guard against <0 temp1W32 = (int32_t)0x7fffffffL - temp1W32; // 1 - K*K in Q31 @@ -208,9 +204,8 @@ int16_t WebRtcSpl_LevinsonDurbin(const int32_t* R, int16_t* A, int16_t* K, tmp_low = (int16_t)((temp1W32 - ((int32_t)tmp_hi << 16)) >> 1); // Calculate Alpha = Alpha * (1-K^2) in Q31 - temp1W32 = ((WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_hi) - + (WEBRTC_SPL_MUL_16_16(Alpha_hi, tmp_low) >> 15) - + (WEBRTC_SPL_MUL_16_16(Alpha_low, tmp_hi) >> 15)) << 1); + temp1W32 = (Alpha_hi * tmp_hi + (Alpha_hi * tmp_low >> 15) + + (Alpha_low * tmp_hi >> 15)) << 1; // Normalize Alpha and store it on hi and low format diff --git a/webrtc/common_audio/signal_processing/lpc_to_refl_coef.c b/webrtc/common_audio/signal_processing/lpc_to_refl_coef.c index 5fb4d8596b..edcebd4e63 100644 --- a/webrtc/common_audio/signal_processing/lpc_to_refl_coef.c +++ b/webrtc/common_audio/signal_processing/lpc_to_refl_coef.c @@ -30,7 +30,7 @@ void WebRtcSpl_LpcToReflCoef(int16_t* a16, int use_order, int16_t* k16) for (m = use_order - 1; m > 0; m--) { // (1 - k^2) in Q30 - tmp_inv_denom32 = ((int32_t)1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); + tmp_inv_denom32 = 1073741823 - k16[m] * k16[m]; // (1 - k^2) in Q15 tmp_inv_denom16 = (int16_t)(tmp_inv_denom32 >> 15); @@ -39,8 +39,7 @@ void WebRtcSpl_LpcToReflCoef(int16_t* a16, int use_order, int16_t* k16) // tmp[k] = (a[k] - RC[m] * a[m-k+1]) / (1.0 - RC[m]*RC[m]); // [Q12<<16 - (Q15*Q12)<<1] = [Q28 - Q28] = Q28 - tmp32[k] = WEBRTC_SPL_LSHIFT_W32((int32_t)a16[k], 16) - - WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(k16[m], a16[m-k+1]), 1); + tmp32[k] = (a16[k] << 16) - (k16[m] * a16[m - k + 1] << 1); tmp32[k] = WebRtcSpl_DivW32W16(tmp32[k], tmp_inv_denom16); //Q28/Q15 = Q13 } diff --git a/webrtc/common_audio/signal_processing/spl_sqrt.c b/webrtc/common_audio/signal_processing/spl_sqrt.c index 1de6ccd713..24db4f822c 100644 --- a/webrtc/common_audio/signal_processing/spl_sqrt.c +++ b/webrtc/common_audio/signal_processing/spl_sqrt.c @@ -49,16 +49,16 @@ int32_t WebRtcSpl_SqrtLocal(int32_t in) A >>= 16; A = A * A * 2; // A = (x/2)^4 t16 = (int16_t)(A >> 16); - B = B + WEBRTC_SPL_MUL_16_16(-20480, t16) * 2; // B = B - 0.625*A + B += -20480 * t16 * 2; // B = B - 0.625*A // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 - A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = (x/2)^5 + A = x_half * t16 * 2; // A = (x/2)^5 t16 = (int16_t)(A >> 16); - B = B + WEBRTC_SPL_MUL_16_16(28672, t16) * 2; // B = B + 0.875*A + B += 28672 * t16 * 2; // B = B + 0.875*A // After this, B = 1 + x/2 - 0.5*(x/2)^2 - 0.625*(x/2)^4 + 0.875*(x/2)^5 t16 = (int16_t)(x2 >> 16); - A = WEBRTC_SPL_MUL_16_16(x_half, t16) * 2; // A = x/2^3 + A = x_half * t16 * 2; // A = x/2^3 B = B + (A >> 1); // B = B + 0.5*A // After this, B = 1 + x/2 - 0.5*(x/2)^2 + 0.5*(x/2)^3 - 0.625*(x/2)^4 + 0.875*(x/2)^5 @@ -166,7 +166,7 @@ int32_t WebRtcSpl_Sqrt(int32_t value) t16 = (int16_t)(A >> 16); // t16 = AH - A = WEBRTC_SPL_MUL_16_16(k_sqrt_2, t16) * 2; // A = 1/sqrt(2)*t16 + A = k_sqrt_2 * t16 * 2; // A = 1/sqrt(2)*t16 A = A + ((int32_t)32768); // Round off A = A & ((int32_t)0x7fff0000); // Round off diff --git a/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c b/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c index fc438c6373..f9570f313e 100644 --- a/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c +++ b/webrtc/common_audio/signal_processing/sqrt_of_one_minus_x_squared.c @@ -27,7 +27,7 @@ void WebRtcSpl_SqrtOfOneMinusXSquared(int16_t *xQ15, int vector_length, for (m = 0; m < vector_length; m++) { tmp = xQ15[m]; - sq = WEBRTC_SPL_MUL_16_16(tmp, tmp); // x^2 in Q30 + sq = tmp * tmp; // x^2 in Q30 sq = 1073741823 - sq; // 1-x^2, where 1 ~= 0.99999999906 is 1073741823 in Q30 sq = WebRtcSpl_Sqrt(sq); // sqrt(1-x^2) in Q15 yQ15[m] = (int16_t)sq; diff --git a/webrtc/common_audio/signal_processing/vector_scaling_operations.c b/webrtc/common_audio/signal_processing/vector_scaling_operations.c index 736f62c71f..9ae7480eb7 100644 --- a/webrtc/common_audio/signal_processing/vector_scaling_operations.c +++ b/webrtc/common_audio/signal_processing/vector_scaling_operations.c @@ -157,9 +157,8 @@ int WebRtcSpl_ScaleAndAddVectorsWithRoundC(const int16_t* in_vector1, for (i = 0; i < length; i++) { out_vector[i] = (int16_t)(( - WEBRTC_SPL_MUL_16_16(in_vector1[i], in_vector1_scale) - + WEBRTC_SPL_MUL_16_16(in_vector2[i], in_vector2_scale) - + round_value) >> right_shifts); + in_vector1[i] * in_vector1_scale + in_vector2[i] * in_vector2_scale + + round_value) >> right_shifts); } return 0;