Refactor audio_coding/ilbc: removes usage of macro WEBRTC_SPL_LSHIFT_W32

The macro is defined as
#define WEBRTC_SPL_LSHIFT_W32(a, b) ((a) << (b))
It is a trivial operation that need no macro. In fact it may be confusing for to the user, since it can be interpreted as having an implicit cast to int32_t.

Also removes unnecessary casts to int32_t from int16_t.

BUG=3348,3353
TESTED=locally on linux and trybots
R=kwiberg@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/48519004

Cr-Commit-Position: refs/heads/master@{#8800}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8800 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2015-03-20 06:01:06 +00:00
parent bd8c865f43
commit 4ab23d0e8f
12 changed files with 23 additions and 35 deletions

View File

@ -53,7 +53,7 @@ void WebRtcIlbcfix_CbMemEnergy(
/* Normalize the energy and store the number of shifts */
energyShifts[0] = (int16_t)WebRtcSpl_NormW32(energy);
tmp32 = WEBRTC_SPL_LSHIFT_W32(energy, energyShifts[0]);
tmp32 = energy << energyShifts[0];
energyW16[0] = (int16_t)(tmp32 >> 16);
/* Compute the energy of the rest of the cb memory
@ -69,7 +69,7 @@ void WebRtcIlbcfix_CbMemEnergy(
/* Normalize the energy and store the number of shifts */
energyShifts[base_size] = (int16_t)WebRtcSpl_NormW32(energy);
tmp32 = WEBRTC_SPL_LSHIFT_W32(energy, energyShifts[base_size]);
tmp32 = energy << energyShifts[base_size];
energyW16[base_size] = (int16_t)(tmp32 >> 16);
ppi = filteredCB + lMem - 1 - lTarget;

View File

@ -58,7 +58,7 @@ void WebRtcIlbcfix_CbMemEnergyAugmentation(
/* Normalize the energy and store the number of shifts */
(*enShPtr) = (int16_t)WebRtcSpl_NormW32(energy);
tmp32 = WEBRTC_SPL_LSHIFT_W32(energy, (*enShPtr));
tmp32 = energy << *enShPtr;
*enPtr = (int16_t)(tmp32 >> 16);
enShPtr++;
enPtr++;

View File

@ -58,7 +58,7 @@ void WebRtcIlbcfix_CbMemEnergyCalc(
shft = (int16_t)WebRtcSpl_NormW32(energy);
*eSh_ptr++ = shft;
tmp = WEBRTC_SPL_LSHIFT_W32(energy, shft);
tmp = energy << shft;
*eW16_ptr++ = (int16_t)(tmp >> 16);
}
}

View File

@ -65,7 +65,7 @@ void WebRtcIlbcfix_CbSearchCore(
for (i=0;i<range;i++) {
/* Calculate cDot*cDot and put the result in a int16_t */
tmp32 = WEBRTC_SPL_LSHIFT_W32(*cDotPtr,sh);
tmp32 = *cDotPtr << sh;
tmp16 = (int16_t)(tmp32 >> 16);
cDotSqW16 = (int16_t)(((int32_t)(tmp16)*(tmp16))>>16);

View File

@ -39,8 +39,7 @@ int16_t WebRtcIlbcfix_Chebyshev(
b2 = (int32_t)0x1000000; /* b2 = 1.0 (Q23) */
/* Calculate b1 = 2*x + f[1] */
tmp1W32 = WEBRTC_SPL_LSHIFT_W32((int32_t)x, 10);
tmp1W32 += WEBRTC_SPL_LSHIFT_W32((int32_t)f[1], 14);
tmp1W32 = (x << 10) + (f[1] << 14);
for (i = 2; i < 5; i++) {
tmp2W32 = tmp1W32;
@ -50,10 +49,7 @@ int16_t WebRtcIlbcfix_Chebyshev(
b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1);
/* Calculate 2*x*b1-b2+f[i] */
tmp1W32 = WEBRTC_SPL_LSHIFT_W32(b1_high * x + ((b1_low * x) >> 15), 2);
tmp1W32 -= b2;
tmp1W32 += WEBRTC_SPL_LSHIFT_W32((int32_t)f[i], 14);
tmp1W32 = ((b1_high * x + ((b1_low * x) >> 15)) << 2) - b2 + (f[i] << 14);
/* Update b2 for next round */
b2 = tmp2W32;
@ -64,11 +60,8 @@ int16_t WebRtcIlbcfix_Chebyshev(
b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1);
/* tmp1W32 = x*b1 - b2 + f[i]/2 */
tmp1W32 = WEBRTC_SPL_LSHIFT_W32(b1_high * x, 1) +
WEBRTC_SPL_LSHIFT_W32((b1_low * x) >> 15, 1);
tmp1W32 -= b2;
tmp1W32 += WEBRTC_SPL_LSHIFT_W32((int32_t)f[i], 13);
tmp1W32 = ((b1_high * x) << 1) + (((b1_low * x) >> 15) << 1) -
b2 + (f[i] << 13);
/* Handle overflows and set to maximum or minimum int16_t instead */
if (tmp1W32>((int32_t)33553408)) {

View File

@ -151,7 +151,7 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
corr16[i] = (int16_t)WEBRTC_SPL_SHIFT_W32(corrmax[i], corrSh);
corr16[i] = (int16_t)((corr16[i] * corr16[i]) >> 16);
en16[i] = (int16_t)WEBRTC_SPL_SHIFT_W32(ener, enerSh);
totsh[i] = enerSh - WEBRTC_SPL_LSHIFT_W32(corrSh, 1);
totsh[i] = enerSh - (corrSh << 1);
}
/* Compare lagmax[0..3] for the (corr^2)/ener criteria */
@ -278,8 +278,7 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
(int16_t)tmp1);
/* Calculate the Sqrt of the energy in Q15 ((14+16)/2) */
SqrtEnChange = (int16_t)WebRtcSpl_SqrtFloor(
WEBRTC_SPL_LSHIFT_W32((int32_t)EnChange, 14));
SqrtEnChange = (int16_t)WebRtcSpl_SqrtFloor(EnChange << 14);
/* Multiply first part of vector with 2*SqrtEnChange */

View File

@ -48,7 +48,7 @@ int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
/* Multiply the gain with 2^14 to make the comparison
easier and with higher precision */
gainW32 = WEBRTC_SPL_LSHIFT_W32((int32_t)gain, 14);
gainW32 = gain << 14;
/* Do a binary search, starting in the middle of the CB
loc - defines the current position in the table

View File

@ -67,14 +67,13 @@ void WebRtcIlbcfix_GetLspPoly(
high = (int16_t)(fPtr[-1] >> 16);
low = (int16_t)((fPtr[-1] - ((int32_t)high << 16)) >> 1);
tmpW32 = WEBRTC_SPL_LSHIFT_W32(high * *lspPtr, 2) +
WEBRTC_SPL_LSHIFT_W32((low * *lspPtr) >> 15, 2);
tmpW32 = ((high * *lspPtr) << 2) + (((low * *lspPtr) >> 15) << 2);
(*fPtr) += fPtr[-2];
(*fPtr) -= tmpW32;
fPtr--;
}
(*fPtr) -= (int32_t)WEBRTC_SPL_LSHIFT_W32((int32_t)(*lspPtr), 10);
*fPtr -= *lspPtr << 10;
fPtr+=i;
lspPtr+=2;

View File

@ -77,11 +77,11 @@ void WebRtcIlbcfix_HpInput(
} else if (tmpW32<-268435456) {
tmpW32 = WEBRTC_SPL_WORD32_MIN;
} else {
tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3);
tmpW32 <<= 3;
}
y[0] = (int16_t)(tmpW32 >> 16);
y[1] = (int16_t)((tmpW32 - WEBRTC_SPL_LSHIFT_W32((int32_t)y[0], 16))>>1);
y[1] = (int16_t)((tmpW32 - (y[0] << 16)) >> 1);
}
return;

View File

@ -77,11 +77,11 @@ void WebRtcIlbcfix_HpOutput(
} else if (tmpW32<-268435456) {
tmpW32 = WEBRTC_SPL_WORD32_MIN;
} else {
tmpW32 = WEBRTC_SPL_LSHIFT_W32(tmpW32, 3);
tmpW32 <<= 3;
}
y[0] = (int16_t)(tmpW32 >> 16);
y[1] = (int16_t)((tmpW32 - WEBRTC_SPL_LSHIFT_W32((int32_t)y[0], 16))>>1);
y[1] = (int16_t)((tmpW32 - (y[0] << 16)) >> 1);
}

View File

@ -76,13 +76,12 @@ void WebRtcIlbcfix_Smooth(
scale1 = scale2 + 16;
}
w00prim = WEBRTC_SPL_LSHIFT_W32(w00, scale1);
w00prim = w00 << scale1;
w11prim = (int16_t) WEBRTC_SPL_SHIFT_W32(w11, scale2);
/* Perform C = sqrt(w11/w00) (C is in Q11 since (16+6)/2=11) */
if (w11prim>64) {
endiff = WEBRTC_SPL_LSHIFT_W32(
(int32_t)WebRtcSpl_DivW32W16(w00prim, w11prim), 6);
endiff = WebRtcSpl_DivW32W16(w00prim, w11prim) << 6;
C = (int16_t)WebRtcSpl_SqrtFloor(endiff); /* C is in Q11 */
} else {
C = 1;
@ -166,7 +165,7 @@ void WebRtcIlbcfix_Smooth(
/* B_W32 is in Q30 ( B = 1 - ENH_A0/2 - A * w10/w00 ) */
scale1 = 31-bitsw10;
scale2 = 21-scale1;
w10prim = WEBRTC_SPL_LSHIFT_W32(w10, scale1);
w10prim = w10 << scale1;
w00prim = WEBRTC_SPL_SHIFT_W32(w00, -scale2);
scale = bitsw00-scale2-15;

View File

@ -46,11 +46,9 @@ void WebRtcIlbcfix_Window32W32(
y_hi = (int16_t)(y[i] >> 16);
/* Extract lower bytes, defined as (w32 - hi<<16)>>1 */
temp = WEBRTC_SPL_LSHIFT_W32((int32_t)x_hi, 16);
x_low = (int16_t)((x[i] - temp) >> 1);
x_low = (int16_t)((x[i] - (x_hi << 16)) >> 1);
temp = WEBRTC_SPL_LSHIFT_W32((int32_t)y_hi, 16);
y_low = (int16_t)((y[i] - temp) >> 1);
y_low = (int16_t)((y[i] - (y_hi << 16)) >> 1);
/* Calculate z by a 32 bit multiplication using both low and high from x and y */
temp = ((x_hi * y_hi) << 1) + ((x_hi * y_low) >> 14);