common_audio: Removed macro WEBRTC_SPL_LSHIFT_W16

The macro was a trivial << operation and where used has been replaced by <<. Affected components are
* ilbc
* isacfix

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

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@7404 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2014-10-09 08:47:02 +00:00
parent 127ca3f8e5
commit 3ea35fdb1b
8 changed files with 25 additions and 27 deletions

View File

@ -90,7 +90,6 @@
// Shifting with negative numbers not allowed
// We cannot do casting here due to signed/unsigned problem
#define WEBRTC_SPL_RSHIFT_W16(x, c) ((x) >> (c))
#define WEBRTC_SPL_LSHIFT_W16(x, c) ((x) << (c))
#define WEBRTC_SPL_RSHIFT_W32(x, c) ((x) >> (c))
#define WEBRTC_SPL_LSHIFT_W32(x, c) ((x) << (c))

View File

@ -67,7 +67,6 @@ TEST_F(SplTest, MacroTest) {
// Shifting with negative numbers not allowed
// We cannot do casting here due to signed/unsigned problem
EXPECT_EQ(8191, WEBRTC_SPL_RSHIFT_W16(a, 1));
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W16(a, 1));
EXPECT_EQ(8191, WEBRTC_SPL_RSHIFT_W32(a, 1));
EXPECT_EQ(32766, WEBRTC_SPL_LSHIFT_W32(a, 1));

View File

@ -71,7 +71,7 @@ void WebRtcIlbcfix_Lsp2Lsf(
tmp = (int16_t)WEBRTC_SPL_MUL_16_16_RSFT(WebRtcIlbcfix_kAcosDerivative[k],diff, 11);
/* freq in Q16 */
freq = (int16_t)WEBRTC_SPL_LSHIFT_W16(k,9)+tmp;
freq = (k << 9) + tmp;
/* lsf = freq*2*pi */
(*lsfPtr) = (int16_t)(((int32_t)freq*25736)>>15);

View File

@ -117,7 +117,7 @@ void WebRtcIlbcfix_Poly2Lsp(
sign = y;
y = WEBRTC_SPL_ABS_W16(y);
shifts = (int16_t)WebRtcSpl_NormW32(y)-16;
y = WEBRTC_SPL_LSHIFT_W16(y, shifts);
y <<= shifts;
y = (int16_t)WebRtcSpl_DivW32W16(536838144, y); /* 1/(yhigh-ylow) */
tmpW32 = WEBRTC_SPL_MUL_16_16_RSFT(x, y, (19-shifts));

View File

@ -93,16 +93,14 @@ static int16_t plc_filterma_Fast(
static __inline int32_t log2_Q8_T( uint32_t x ) {
int32_t zeros, lg2;
int32_t zeros;
int16_t frac;
zeros=WebRtcSpl_NormU32(x);
frac=(int16_t)WEBRTC_SPL_RSHIFT_W32(((uint32_t)WEBRTC_SPL_LSHIFT_W32(x, zeros)&0x7FFFFFFF), 23);
/* log2(magn(i)) */
lg2= (WEBRTC_SPL_LSHIFT_W16((31-zeros), 8)+frac);
return lg2;
return ((31 - zeros) << 8) + frac;
}
static __inline int16_t exp2_Q10_T(int16_t x) { // Both in and out in Q10
@ -114,7 +112,7 @@ static __inline int16_t exp2_Q10_T(int16_t x) { // Both in and out in Q10
if(tmp16_1>0)
return tmp16_2 >> tmp16_1;
else
return (int16_t) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1);
return tmp16_2 << -tmp16_1;
}

View File

@ -35,7 +35,7 @@ void WebRtcSpl_AToK_JSK(
int32_t tmp_inv_denum32;
int16_t tmp_inv_denum16;
k16[useOrder-1]= WEBRTC_SPL_LSHIFT_W16(a16[useOrder], 4); //Q11<<4 => Q15
k16[useOrder-1] = a16[useOrder] << 4; // Q11<<4 => Q15
for (m=useOrder-1; m>0; m--) {
tmp_inv_denum32 = ((int32_t) 1073741823) - WEBRTC_SPL_MUL_16_16(k16[m], k16[m]); // (1 - k^2) in Q30
@ -346,17 +346,14 @@ static const int16_t kPolyVecHi[6] = {
static __inline int32_t log2_Q8_LPC( uint32_t x ) {
int32_t zeros, lg2;
int32_t zeros;
int16_t frac;
zeros=WebRtcSpl_NormU32(x);
frac=(int16_t)WEBRTC_SPL_RSHIFT_W32(((uint32_t)WEBRTC_SPL_LSHIFT_W32(x, zeros)&0x7FFFFFFF), 23);
/* log2(x) */
lg2= (WEBRTC_SPL_LSHIFT_W16((31-zeros), 8)+frac);
return lg2;
return ((31 - zeros) << 8) + frac;
}
static const int16_t kMulPitchGain = -25; /* 200/256 in Q5 */
@ -424,13 +421,13 @@ void WebRtcIsacfix_GetVars(const int16_t *input, const int16_t *pitchGains_Q12,
tmp16_2 = (0x0400 | (tmp16 & 0x03FF));
tmp16_1 = ((uint16_t)(tmp16 ^ 0xFFFF) >> 10) - 3; /* Gives result in Q14 */
if (tmp16_1<0)
expPg=(int16_t) -WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1);
expPg = -(tmp16_2 << -tmp16_1);
else
expPg = -(tmp16_2 >> tmp16_1);
} else
expPg = (int16_t) -16384; /* 1 in Q14, since 2^0=1 */
expPg32 = (int32_t)WEBRTC_SPL_LSHIFT_W16((int32_t)expPg, 8); /* Q22 */
expPg32 = (int32_t)expPg << 8; /* Q22 */
divVal = WebRtcSpl_DivW32W16ResW16(expPg32, chngQ); /* Q22/Q12=Q10 */
tmp16=(int16_t)WEBRTC_SPL_MUL_16_16_RSFT_WITH_ROUND(kExp2,divVal,13);/* Q13*Q10>>13 => Q10*/
@ -438,7 +435,7 @@ void WebRtcIsacfix_GetVars(const int16_t *input, const int16_t *pitchGains_Q12,
tmp16_2 = (0x0400 | (tmp16 & 0x03FF));
tmp16_1 = ((uint16_t)(tmp16 ^ 0xFFFF) >> 10) - 3; /* Gives result in Q14 */
if (tmp16_1<0)
expPg=(int16_t) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1);
expPg = tmp16_2 << -tmp16_1;
else
expPg = tmp16_2 >> tmp16_1;
} else
@ -459,7 +456,7 @@ static __inline int16_t exp2_Q10_T(int16_t x) { // Both in and out in Q10
if(tmp16_1>0)
return tmp16_2 >> tmp16_1;
else
return (int16_t) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1);
return tmp16_2 << -tmp16_1;
}
@ -734,10 +731,13 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha, tmp);
} else if ((sh-shMem)<7){
tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufLoQQ[n], shMem); // Shift up CorrBufLoQQ as much as possible
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, (sh-shMem)), tmp); // Shift alpha the number of times required to get tmp in QdomLO
// Shift |alpha| the number of times required to get |tmp| in QdomLO.
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha << (sh - shMem), tmp);
} else {
tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufLoQQ[n], shMem); // Shift up CorrBufHiQQ as much as possible
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, 6), tmp); // Shift alpha as much as possible without overflow the number of times required to get tmp in QdomHI
// Shift |alpha| as much as possible without overflow the number of
// times required to get |tmp| in QdomLO.
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha << 6, tmp);
tmpCorr = WEBRTC_SPL_RSHIFT_W32(corrloQQ[n], sh-shMem-6);
tmp = tmp + tmpCorr;
maskdata->CorrBufLoQQ[n] = tmp;
@ -784,14 +784,17 @@ void WebRtcIsacfix_GetLpcCoef(int16_t *inLoQ0,
maskdata->CorrBufHiQdom[n] = QdomHI;
} else if ((sh-shMem)<7) {
tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufHiQQ[n], shMem); // Shift up CorrBufHiQQ as much as possible
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, (sh-shMem)), tmp); // Shift alpha the number of times required to get tmp in QdomHI
// Shift |alpha| the number of times required to get |tmp| in QdomHI.
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha << (sh - shMem), tmp);
tmpCorr = corrhiQQ[n];
tmp = tmp + tmpCorr;
maskdata->CorrBufHiQQ[n] = tmp;
maskdata->CorrBufHiQdom[n] = QdomHI;
} else {
tmp = WEBRTC_SPL_SHIFT_W32(maskdata->CorrBufHiQQ[n], shMem); // Shift up CorrBufHiQQ as much as possible
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(WEBRTC_SPL_LSHIFT_W16(alpha, 6), tmp); // Shift alpha as much as possible without overflow the number of times required to get tmp in QdomHI
// Shift |alpha| as much as possible without overflow the number of
// times required to get |tmp| in QdomHI.
tmp = WEBRTC_SPL_MUL_16_32_RSFT15(alpha << 6, tmp);
tmpCorr = WEBRTC_SPL_RSHIFT_W32(corrhiQQ[n], sh-shMem-6);
tmp = tmp + tmpCorr;
maskdata->CorrBufHiQQ[n] = tmp;

View File

@ -49,7 +49,7 @@ static __inline int16_t Exp2Q10(int16_t x) { // Both in and out in Q10
if(tmp16_1>0)
return tmp16_2 >> tmp16_1;
else
return (int16_t) WEBRTC_SPL_LSHIFT_W16(tmp16_2, -tmp16_1);
return tmp16_2 << -tmp16_1;
}

View File

@ -205,8 +205,7 @@ void WebRtcIsacfix_PitchFilterGains(const int16_t* indatQ0,
// Update parameters for each segment.
curLagQ7 += lagdeltaQ7;
indW16 = (int16_t)CalcLrIntQ(curLagQ7, 7);
tmpW16 = WEBRTC_SPL_LSHIFT_W16(indW16, 7);
tmpW16 -= curLagQ7;
tmpW16 = (indW16 << 7) - curLagQ7;
frcQQ = (tmpW16 >> 4) + 4;
if (frcQQ == PITCH_FRACS) {