audio_coding/codec/ilbc: Removed usage of macro WEBRTC_SPL_MUL_16_16

The macro is in C defined as
#define WEBRTC_SPL_MUL_16_16(a, b) ((int32_t) (((int16_t)(a)) * ((int16_t)(b))))
(For definition on ARMv7 and MIPS, see common_audio/signal_processing/include/spl_inl_armv7.h and common_audio/signal_processing/include/spl_inl_mips.h)

The replacement consists of
- avoiding casts to int16_t if inputs already are int16_t
- adding explicit cast to <type> if result is assigned to <type> (other than int or int32_t)

Some other minor code cleanup also exists.

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

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

Cr-Commit-Position: refs/heads/master@{#8358}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8358 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
bjornv@webrtc.org 2015-02-13 09:51:40 +00:00
parent 2bd299a172
commit ba97ea69f0
30 changed files with 122 additions and 126 deletions

View File

@ -37,6 +37,6 @@ void WebRtcIlbcfix_BwExpand(
/* out[i] = coef[i] * in[i] with rounding. /* out[i] = coef[i] * in[i] with rounding.
in[] and out[] are in Q12 and coef[] is in Q15 in[] and out[] are in Q12 and coef[] is in Q15
*/ */
out[i] = (int16_t)((WEBRTC_SPL_MUL_16_16(coef[i], in[i])+16384)>>15); out[i] = (int16_t)((coef[i] * in[i] + 16384) >> 15);
} }
} }

View File

@ -56,9 +56,9 @@ void WebRtcIlbcfix_CbConstruct(
gainPtr = &gain[0]; gainPtr = &gain[0];
for (j=0;j<veclen;j++) { for (j=0;j<veclen;j++) {
a32 = WEBRTC_SPL_MUL_16_16(*gainPtr++, cbvec0[j]); a32 = (*gainPtr++) * cbvec0[j];
a32 += WEBRTC_SPL_MUL_16_16(*gainPtr++, cbvec1[j]); a32 += (*gainPtr++) * cbvec1[j];
a32 += WEBRTC_SPL_MUL_16_16(*gainPtr, cbvec2[j]); a32 += (*gainPtr) * cbvec2[j];
gainPtr -= 2; gainPtr -= 2;
decvector[j] = (int16_t)((a32 + 8192) >> 14); decvector[j] = (int16_t)((a32 + 8192) >> 14);
} }

View File

@ -45,8 +45,7 @@ void WebRtcIlbcfix_CbMemEnergyCalc(
/* Calculate next energy by a +/- /* Calculate next energy by a +/-
operation on the edge samples */ operation on the edge samples */
tmp = WEBRTC_SPL_MUL_16_16(*ppi, *ppi); tmp = (*ppi) * (*ppi) - (*ppo) * (*ppo);
tmp -= WEBRTC_SPL_MUL_16_16(*ppo, *ppo);
energy += tmp >> scale; energy += tmp >> scale;
energy = WEBRTC_SPL_MAX(energy, 0); energy = WEBRTC_SPL_MAX(energy, 0);

View File

@ -113,7 +113,7 @@ void WebRtcIlbcfix_CbSearch(
if ((temp1>0)&&(temp2>0)) { if ((temp1>0)&&(temp2>0)) {
temp1 = WEBRTC_SPL_MAX(temp1, temp2); temp1 = WEBRTC_SPL_MAX(temp1, temp2);
scale = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(temp1, temp1)); scale = WebRtcSpl_GetSizeInBits((uint32_t)(temp1 * temp1));
} else { } else {
/* temp1 or temp2 is negative (maximum was -32768) */ /* temp1 or temp2 is negative (maximum was -32768) */
scale = 30; scale = 30;
@ -361,8 +361,7 @@ void WebRtcIlbcfix_CbSearch(
tmp = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(gains[1],gains[1], 14); tmp = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(gains[1],gains[1], 14);
targetEner = WEBRTC_SPL_MUL_16_16( targetEner = (int16_t)WEBRTC_SPL_SHIFT_W32(targetEner, -bits) * tmp;
WEBRTC_SPL_SHIFT_W32(targetEner, -bits), tmp);
tmpW32 = ((int32_t)(gains[1]-1))<<1; tmpW32 = ((int32_t)(gains[1]-1))<<1;
@ -381,7 +380,7 @@ void WebRtcIlbcfix_CbSearch(
gainTbl[i] < 2*gain[0] gainTbl[i] < 2*gain[0]
*/ */
t32 = WEBRTC_SPL_MUL_16_16(temp1, (*gainPtr)); t32 = temp1 * *gainPtr;
t32 = t32 - targetEner; t32 = t32 - targetEner;
if (t32 < 0) { if (t32 < 0) {
if ((*WebRtcIlbcfix_kGainSq5_ptr) < tmpW32) { if ((*WebRtcIlbcfix_kGainSq5_ptr) < tmpW32) {

View File

@ -70,7 +70,7 @@ void WebRtcIlbcfix_CbSearchCore(
cDotSqW16 = (int16_t)(((int32_t)(tmp16)*(tmp16))>>16); cDotSqW16 = (int16_t)(((int32_t)(tmp16)*(tmp16))>>16);
/* Calculate the criteria (cDot*cDot/energy) */ /* Calculate the criteria (cDot*cDot/energy) */
*critPtr=WEBRTC_SPL_MUL_16_16(cDotSqW16, (*inverseEnergyPtr)); *critPtr = cDotSqW16 * *inverseEnergyPtr;
/* Extract the maximum shift value under the constraint /* Extract the maximum shift value under the constraint
that the criteria is not zero */ that the criteria is not zero */

View File

@ -50,8 +50,7 @@ int16_t WebRtcIlbcfix_Chebyshev(
b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1); b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1);
/* Calculate 2*x*b1-b2+f[i] */ /* Calculate 2*x*b1-b2+f[i] */
tmp1W32 = WEBRTC_SPL_LSHIFT_W32( (WEBRTC_SPL_MUL_16_16(b1_high, x) + tmp1W32 = WEBRTC_SPL_LSHIFT_W32(b1_high * x + ((b1_low * x) >> 15), 2);
WEBRTC_SPL_MUL_16_16_RSFT(b1_low, x, 15)), 2);
tmp1W32 -= b2; tmp1W32 -= b2;
tmp1W32 += WEBRTC_SPL_LSHIFT_W32((int32_t)f[i], 14); tmp1W32 += WEBRTC_SPL_LSHIFT_W32((int32_t)f[i], 14);
@ -65,7 +64,7 @@ int16_t WebRtcIlbcfix_Chebyshev(
b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1); b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1);
/* tmp1W32 = x*b1 - b2 + f[i]/2 */ /* tmp1W32 = x*b1 - b2 + f[i]/2 */
tmp1W32 = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(b1_high, x), 1) + tmp1W32 = WEBRTC_SPL_LSHIFT_W32(b1_high * x, 1) +
WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16_RSFT(b1_low, x, 15), 1); WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16_RSFT(b1_low, x, 15), 1);
tmp1W32 -= b2; tmp1W32 -= b2;

View File

@ -107,12 +107,11 @@ void WebRtcIlbcfix_DoThePlc(
WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1), 15); WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1), 15);
shift2 = WebRtcSpl_GetSizeInBits(ener)-15; shift2 = WebRtcSpl_GetSizeInBits(ener)-15;
measure = WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_SHIFT_W32(ener, -shift2), measure = (int16_t)WEBRTC_SPL_SHIFT_W32(ener, -shift2) * crossSquare;
crossSquare);
shift3 = WebRtcSpl_GetSizeInBits(ener_comp)-15; shift3 = WebRtcSpl_GetSizeInBits(ener_comp)-15;
maxMeasure = WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_SHIFT_W32(ener_comp, -shift3), maxMeasure = (int16_t)WEBRTC_SPL_SHIFT_W32(ener_comp, -shift3) *
crossSquareMax); crossSquareMax;
/* Calculate shift value, so that the two measures can /* Calculate shift value, so that the two measures can
be put in the same Q domain */ be put in the same Q domain */
@ -164,7 +163,7 @@ void WebRtcIlbcfix_DoThePlc(
tmp1 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, (totscale>>1)); tmp1 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, (totscale>>1));
tmp2 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, totscale-(totscale>>1)); tmp2 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, totscale-(totscale>>1));
nom = WEBRTC_SPL_MUL_16_16(tmp1, tmp2); nom = tmp1 * tmp2;
max_perSquare = (int16_t)WebRtcSpl_DivW32W16(nom, denom); max_perSquare = (int16_t)WebRtcSpl_DivW32W16(nom, denom);
} else { } else {
@ -230,7 +229,7 @@ void WebRtcIlbcfix_DoThePlc(
for (i=0; i<iLBCdec_inst->blockl; i++) { for (i=0; i<iLBCdec_inst->blockl; i++) {
/* noise component - 52 < randlagFIX < 117 */ /* noise component - 52 < randlagFIX < 117 */
iLBCdec_inst->seed = (int16_t)(WEBRTC_SPL_MUL_16_16(iLBCdec_inst->seed, 31821)+(int32_t)13849); iLBCdec_inst->seed = (int16_t)(iLBCdec_inst->seed * 31821 + 13849);
randlag = 53 + (int16_t)(iLBCdec_inst->seed & 63); randlag = 53 + (int16_t)(iLBCdec_inst->seed & 63);
pick = i - randlag; pick = i - randlag;

View File

@ -154,7 +154,7 @@ void WebRtcIlbcfix_EncodeImpl(
index = (iLBCbits_inst->startIdx-1)*SUBL; index = (iLBCbits_inst->startIdx-1)*SUBL;
max=WebRtcSpl_MaxAbsValueW16(&residual[index], 2*SUBL); max=WebRtcSpl_MaxAbsValueW16(&residual[index], 2*SUBL);
scale=WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max,max)); scale = WebRtcSpl_GetSizeInBits((uint32_t)(max * max));
/* Scale to maximum 25 bits so that the MAC won't cause overflow */ /* Scale to maximum 25 bits so that the MAC won't cause overflow */
scale = scale - 25; scale = scale - 25;

View File

@ -39,26 +39,26 @@ void WebRtcIlbcfix_EnhUpsample(
/* i = 2 */ /* i = 2 */
pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
ps=seq1+2; ps=seq1+2;
(*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 = (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0; pu11+=ENH_UPS0;
/* i = 3 */ /* i = 3 */
pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
ps=seq1+3; ps=seq1+3;
(*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 = (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0; pu11+=ENH_UPS0;
/* i = 4 */ /* i = 4 */
pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1; pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
ps=seq1+4; ps=seq1+4;
(*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 = (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++); *pu11 += (*ps--) * *pp++;
pu1++; pu1++;
} }
@ -79,7 +79,7 @@ void WebRtcIlbcfix_EnhUpsample(
pp = polyp[j]+i; pp = polyp[j]+i;
ps = seq1+dim1-1; ps = seq1+dim1-1;
for(k=0;k<filterlength-i;k++) { for(k=0;k<filterlength-i;k++) {
*pu += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu += (*ps--) * *pp++;
} }
pu+=ENH_UPS0; pu+=ENH_UPS0;
} }
@ -92,17 +92,17 @@ void WebRtcIlbcfix_EnhUpsample(
/* i = 1 */ /* i = 1 */
pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+2; pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+2;
ps = w16tmp; ps = w16tmp;
(*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 = (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0; pu11+=ENH_UPS0;
/* i = 2 */ /* i = 2 */
pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3; pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3;
ps = w16tmp; ps = w16tmp;
(*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 = (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 += (*ps--) * *pp++;
(*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++); *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0; pu11+=ENH_UPS0;
pu1++; pu1++;

View File

@ -110,14 +110,14 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
for(iblock = 0; iblock<new_blocks; iblock++){ for(iblock = 0; iblock<new_blocks; iblock++){
/* references */ /* references */
i=60+WEBRTC_SPL_MUL_16_16(iblock,ENH_BLOCKL_HALF); i = 60 + iblock * ENH_BLOCKL_HALF;
target=downsampled+i; target=downsampled+i;
regressor=downsampled+i-10; regressor=downsampled+i-10;
/* scaling */ /* scaling */
max16=WebRtcSpl_MaxAbsValueW16(&regressor[-50], max16=WebRtcSpl_MaxAbsValueW16(&regressor[-50],
(int16_t)(ENH_BLOCKL_HALF+50-1)); (int16_t)(ENH_BLOCKL_HALF+50-1));
shifts = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max16, max16)) - 25; shifts = WebRtcSpl_GetSizeInBits((uint32_t)(max16 * max16)) - 25;
shifts = WEBRTC_SPL_MAX(0, shifts); shifts = WEBRTC_SPL_MAX(0, shifts);
/* compute cross correlation */ /* compute cross correlation */
@ -160,14 +160,14 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
for (i=1; i<3; i++) { for (i=1; i<3; i++) {
if (totsh[ind] > totsh[i]) { if (totsh[ind] > totsh[i]) {
sh = WEBRTC_SPL_MIN(31, totsh[ind]-totsh[i]); sh = WEBRTC_SPL_MIN(31, totsh[ind]-totsh[i]);
if ( WEBRTC_SPL_MUL_16_16(corr16[ind], en16[i]) < if (corr16[ind] * en16[i] <
WEBRTC_SPL_MUL_16_16_RSFT(corr16[i], en16[ind], sh)) { WEBRTC_SPL_MUL_16_16_RSFT(corr16[i], en16[ind], sh)) {
ind = i; ind = i;
} }
} else { } else {
sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]); sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]);
if (WEBRTC_SPL_MUL_16_16_RSFT(corr16[ind], en16[i], sh) < if (WEBRTC_SPL_MUL_16_16_RSFT(corr16[ind], en16[i], sh) <
WEBRTC_SPL_MUL_16_16(corr16[i], en16[ind])) { corr16[i] * en16[ind]) {
ind = i; ind = i;
} }
} }
@ -176,21 +176,20 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
lag = lagmax[ind] + 10; lag = lagmax[ind] + 10;
/* Store the estimated lag in the non-downsampled domain */ /* Store the estimated lag in the non-downsampled domain */
enh_period[ENH_NBLOCKS_TOT-new_blocks+iblock] = enh_period[ENH_NBLOCKS_TOT - new_blocks + iblock] = (int16_t)(lag * 8);
(int16_t)WEBRTC_SPL_MUL_16_16(lag, 8);
/* Store the estimated lag for backward PLC */ /* Store the estimated lag for backward PLC */
if (iLBCdec_inst->prev_enh_pl==1) { if (iLBCdec_inst->prev_enh_pl==1) {
if (!iblock) { if (!iblock) {
tlag = WEBRTC_SPL_MUL_16_16(lag, 2); tlag = lag * 2;
} }
} else { } else {
if (iblock==1) { if (iblock==1) {
tlag = WEBRTC_SPL_MUL_16_16(lag, 2); tlag = lag * 2;
} }
} }
lag = WEBRTC_SPL_MUL_16_16(lag, 2); lag *= 2;
} }
if ((iLBCdec_inst->prev_enh_pl==1)||(iLBCdec_inst->prev_enh_pl==2)) { if ((iLBCdec_inst->prev_enh_pl==1)||(iLBCdec_inst->prev_enh_pl==2)) {
@ -370,10 +369,10 @@ int WebRtcIlbcfix_EnhancerInterface( /* (o) Estimated lag in end of in[] */
/* Perform enhancement block by block */ /* Perform enhancement block by block */
for (iblock = 0; iblock<new_blocks; iblock++) { for (iblock = 0; iblock<new_blocks; iblock++) {
WebRtcIlbcfix_Enhancer(out+WEBRTC_SPL_MUL_16_16(iblock, ENH_BLOCKL), WebRtcIlbcfix_Enhancer(out + iblock * ENH_BLOCKL,
enh_buf, enh_buf,
ENH_BUFL, ENH_BUFL,
(int16_t)(WEBRTC_SPL_MUL_16_16(iblock, ENH_BLOCKL)+startPos), (int16_t)(iblock * ENH_BLOCKL + startPos),
enh_period, enh_period,
(int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT); (int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT);
} }

View File

@ -46,7 +46,7 @@ int16_t WebRtcIlbcfix_FrameClassify(
*/ */
max = WebRtcSpl_MaxAbsValueW16(residualFIX, iLBCenc_inst->blockl); max = WebRtcSpl_MaxAbsValueW16(residualFIX, iLBCenc_inst->blockl);
scale=WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(max,max)); scale = WebRtcSpl_GetSizeInBits((uint32_t)(max * max));
/* Scale to maximum 24 bits so that it won't overflow for 76 samples */ /* Scale to maximum 24 bits so that it won't overflow for 76 samples */
scale = scale-24; scale = scale-24;

View File

@ -41,5 +41,5 @@ int16_t WebRtcIlbcfix_GainDequant(
/* select the quantization table and return the decoded value */ /* select the quantization table and return the decoded value */
gain = WebRtcIlbcfix_kGain[stage]; gain = WebRtcIlbcfix_kGain[stage];
return((int16_t)((WEBRTC_SPL_MUL_16_16(scale, gain[index])+8192)>>14)); return (int16_t)((scale * gain[index] + 8192) >> 14);
} }

View File

@ -30,7 +30,7 @@ int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
int16_t *index /* (o) quantization index */ int16_t *index /* (o) quantization index */
) { ) {
int16_t scale, returnVal, cblen; int16_t scale, cblen;
int32_t gainW32, measure1, measure2; int32_t gainW32, measure1, measure2;
const int16_t *cbPtr, *cb; const int16_t *cbPtr, *cb;
int loc, noMoves, noChecks, i; int loc, noMoves, noChecks, i;
@ -62,7 +62,7 @@ int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
for (i=noChecks;i>0;i--) { for (i=noChecks;i>0;i--) {
noMoves>>=1; noMoves>>=1;
measure1=WEBRTC_SPL_MUL_16_16(scale, (*cbPtr)); measure1 = scale * *cbPtr;
/* Move up if gain is larger, otherwise move down in table */ /* Move up if gain is larger, otherwise move down in table */
measure1 = measure1 - gainW32; measure1 = measure1 - gainW32;
@ -78,16 +78,16 @@ int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
/* Check which value is the closest one: loc-1, loc or loc+1 */ /* Check which value is the closest one: loc-1, loc or loc+1 */
measure1=WEBRTC_SPL_MUL_16_16(scale, (*cbPtr)); measure1 = scale * *cbPtr;
if (gainW32>measure1) { if (gainW32>measure1) {
/* Check against value above loc */ /* Check against value above loc */
measure2=WEBRTC_SPL_MUL_16_16(scale, (*(cbPtr+1))); measure2 = scale * cbPtr[1];
if ((measure2-gainW32)<(gainW32-measure1)) { if ((measure2-gainW32)<(gainW32-measure1)) {
loc+=1; loc+=1;
} }
} else { } else {
/* Check against value below loc */ /* Check against value below loc */
measure2=WEBRTC_SPL_MUL_16_16(scale, (*(cbPtr-1))); measure2 = scale * cbPtr[-1];
if ((gainW32-measure2)<=(measure1-gainW32)) { if ((gainW32-measure2)<=(measure1-gainW32)) {
loc-=1; loc-=1;
} }
@ -98,9 +98,6 @@ int16_t WebRtcIlbcfix_GainQuant( /* (o) quantized gain value */
loc=WEBRTC_SPL_MIN(loc, (cblen-1)); loc=WEBRTC_SPL_MIN(loc, (cblen-1));
*index=loc; *index=loc;
/* Calculate the quantized gain value (in Q14) */ /* Calculate and return the quantized gain value (in Q14) */
returnVal=(int16_t)((WEBRTC_SPL_MUL_16_16(scale, cb[loc])+8192)>>14); return (int16_t)((scale * cb[loc] + 8192) >> 14);
/* return the quantized value */
return(returnVal);
} }

View File

@ -58,7 +58,7 @@ void WebRtcIlbcfix_GetCbVec(
/* Calculate lag */ /* Calculate lag */
k=(int16_t)WEBRTC_SPL_MUL_16_16(2, (index-(lMem-cbveclen+1)))+cbveclen; k = (int16_t)(2 * (index - (lMem - cbveclen + 1))) + cbveclen;
lag = k / 2; lag = k / 2;

View File

@ -67,7 +67,7 @@ void WebRtcIlbcfix_GetLspPoly(
high = (int16_t)(fPtr[-1] >> 16); high = (int16_t)(fPtr[-1] >> 16);
low = (int16_t)((fPtr[-1] - ((int32_t)high << 16)) >> 1); low = (int16_t)((fPtr[-1] - ((int32_t)high << 16)) >> 1);
tmpW32 = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(high, (*lspPtr)), 2) + tmpW32 = WEBRTC_SPL_LSHIFT_W32(high * *lspPtr, 2) +
WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16_RSFT(low, (*lspPtr), 15), 2); WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16_RSFT(low, (*lspPtr), 15), 2);
(*fPtr) += fPtr[-2]; (*fPtr) += fPtr[-2];

View File

@ -46,11 +46,12 @@ void WebRtcIlbcfix_GetSyncSeq(
/* present (find predicted lag from this position) */ /* present (find predicted lag from this position) */
WebRtcIlbcfix_NearestNeighbor(lagBlock+hl,plocs, WebRtcIlbcfix_NearestNeighbor(lagBlock + hl,
(int16_t)WEBRTC_SPL_MUL_16_16(2, (centerStartPos+centerEndPos)), plocs,
(int16_t)(2 * (centerStartPos + centerEndPos)),
periodl); periodl);
blockStartPos[hl]=(int16_t)WEBRTC_SPL_MUL_16_16(4, centerStartPos); blockStartPos[hl] = (int16_t)(4 * centerStartPos);
/* past (find predicted position and perform a refined /* past (find predicted position and perform a refined
search to find the best sequence) */ search to find the best sequence) */
@ -58,11 +59,14 @@ void WebRtcIlbcfix_GetSyncSeq(
for(q=hl-1;q>=0;q--) { for(q=hl-1;q>=0;q--) {
blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]]; blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]];
WebRtcIlbcfix_NearestNeighbor(lagBlock+q, plocs, WebRtcIlbcfix_NearestNeighbor(
(int16_t)(blockStartPos[q] + (int16_t)WEBRTC_SPL_MUL_16_16(4, ENH_BLOCKL_HALF)-period[lagBlock[q+1]]), lagBlock + q,
periodl); plocs,
(int16_t)(blockStartPos[q] + 4 * ENH_BLOCKL_HALF -
period[lagBlock[q + 1]]),
periodl);
if((blockStartPos[q]-(int16_t)WEBRTC_SPL_MUL_16_16(4, ENH_OVERHANG))>=0) { if (blockStartPos[q] - 4 * ENH_OVERHANG >= 0) {
/* Find the best possible sequence in the 4 times upsampled /* Find the best possible sequence in the 4 times upsampled
domain around blockStartPos+q */ domain around blockStartPos+q */
@ -82,17 +86,17 @@ void WebRtcIlbcfix_GetSyncSeq(
plocs2[i]=(plocs[i]-period[i]); plocs2[i]=(plocs[i]-period[i]);
} }
for(q=hl+1;q<=WEBRTC_SPL_MUL_16_16(2, hl);q++) { for (q = hl + 1; q <= (int16_t)(2 * hl); q++) {
WebRtcIlbcfix_NearestNeighbor(lagBlock+q,plocs2, WebRtcIlbcfix_NearestNeighbor(
(int16_t)(blockStartPos[q-1]+ lagBlock + q,
(int16_t)WEBRTC_SPL_MUL_16_16(4, ENH_BLOCKL_HALF)),periodl); plocs2,
(int16_t)(blockStartPos[q - 1] + 4 * ENH_BLOCKL_HALF),
periodl);
blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]]; blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]];
if( (blockStartPos[q]+(int16_t)WEBRTC_SPL_MUL_16_16(4, (ENH_BLOCKL+ENH_OVERHANG))) if (blockStartPos[q] + 4 * (ENH_BLOCKL + ENH_OVERHANG) < 4 * idatal) {
<
(int16_t)WEBRTC_SPL_MUL_16_16(4, idatal)) {
/* Find the best possible sequence in the 4 times upsampled /* Find the best possible sequence in the 4 times upsampled
domain around blockStartPos+q */ domain around blockStartPos+q */

View File

@ -43,16 +43,16 @@ void WebRtcIlbcfix_HpInput(
+ (-a[1])*y[i-1] + (-a[2])*y[i-2]; + (-a[1])*y[i-1] + (-a[2])*y[i-2];
*/ */
tmpW32 = WEBRTC_SPL_MUL_16_16(y[1], ba[3]); /* (-a[1])*y[i-1] (low part) */ tmpW32 = y[1] * ba[3]; /* (-a[1])*y[i-1] (low part) */
tmpW32 += WEBRTC_SPL_MUL_16_16(y[3], ba[4]); /* (-a[2])*y[i-2] (low part) */ tmpW32 += y[3] * ba[4]; /* (-a[2])*y[i-2] (low part) */
tmpW32 = (tmpW32>>15); tmpW32 = (tmpW32>>15);
tmpW32 += WEBRTC_SPL_MUL_16_16(y[0], ba[3]); /* (-a[1])*y[i-1] (high part) */ tmpW32 += y[0] * ba[3]; /* (-a[1])*y[i-1] (high part) */
tmpW32 += WEBRTC_SPL_MUL_16_16(y[2], ba[4]); /* (-a[2])*y[i-2] (high part) */ tmpW32 += y[2] * ba[4]; /* (-a[2])*y[i-2] (high part) */
tmpW32 = (tmpW32<<1); tmpW32 = (tmpW32<<1);
tmpW32 += WEBRTC_SPL_MUL_16_16(signal[i], ba[0]); /* b[0]*x[0] */ tmpW32 += signal[i] * ba[0]; /* b[0]*x[0] */
tmpW32 += WEBRTC_SPL_MUL_16_16(x[0], ba[1]); /* b[1]*x[i-1] */ tmpW32 += x[0] * ba[1]; /* b[1]*x[i-1] */
tmpW32 += WEBRTC_SPL_MUL_16_16(x[1], ba[2]); /* b[2]*x[i-2] */ tmpW32 += x[1] * ba[2]; /* b[2]*x[i-2] */
/* Update state (input part) */ /* Update state (input part) */
x[1] = x[0]; x[1] = x[0];

View File

@ -43,16 +43,16 @@ void WebRtcIlbcfix_HpOutput(
+ (-a[1])*y[i-1] + (-a[2])*y[i-2]; + (-a[1])*y[i-1] + (-a[2])*y[i-2];
*/ */
tmpW32 = WEBRTC_SPL_MUL_16_16(y[1], ba[3]); /* (-a[1])*y[i-1] (low part) */ tmpW32 = y[1] * ba[3]; /* (-a[1])*y[i-1] (low part) */
tmpW32 += WEBRTC_SPL_MUL_16_16(y[3], ba[4]); /* (-a[2])*y[i-2] (low part) */ tmpW32 += y[3] * ba[4]; /* (-a[2])*y[i-2] (low part) */
tmpW32 = (tmpW32>>15); tmpW32 = (tmpW32>>15);
tmpW32 += WEBRTC_SPL_MUL_16_16(y[0], ba[3]); /* (-a[1])*y[i-1] (high part) */ tmpW32 += y[0] * ba[3]; /* (-a[1])*y[i-1] (high part) */
tmpW32 += WEBRTC_SPL_MUL_16_16(y[2], ba[4]); /* (-a[2])*y[i-2] (high part) */ tmpW32 += y[2] * ba[4]; /* (-a[2])*y[i-2] (high part) */
tmpW32 = (tmpW32<<1); tmpW32 = (tmpW32<<1);
tmpW32 += WEBRTC_SPL_MUL_16_16(signal[i], ba[0]); /* b[0]*x[0] */ tmpW32 += signal[i] * ba[0]; /* b[0]*x[0] */
tmpW32 += WEBRTC_SPL_MUL_16_16(x[0], ba[1]); /* b[1]*x[i-1] */ tmpW32 += x[0] * ba[1]; /* b[1]*x[i-1] */
tmpW32 += WEBRTC_SPL_MUL_16_16(x[1], ba[2]); /* b[2]*x[i-2] */ tmpW32 += x[1] * ba[2]; /* b[2]*x[i-2] */
/* Update state (input part) */ /* Update state (input part) */
x[1] = x[0]; x[1] = x[0];

View File

@ -53,7 +53,7 @@ void WebRtcIlbcfix_Lsf2Lsp(
} }
/* Calculate linear approximation */ /* Calculate linear approximation */
tmpW32 = WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kCosDerivative[k], diff); tmpW32 = WebRtcIlbcfix_kCosDerivative[k] * diff;
lsp[i] = WebRtcIlbcfix_kCos[k] + (int16_t)(tmpW32 >> 12); lsp[i] = WebRtcIlbcfix_kCos[k] + (int16_t)(tmpW32 >> 12);
} }

View File

@ -37,7 +37,7 @@ void WebRtcIlbcfix_MyCorr(
max=WebRtcSpl_MaxAbsValueW16(seq1, dim1); max=WebRtcSpl_MaxAbsValueW16(seq1, dim1);
scale=WebRtcSpl_GetSizeInBits(max); scale=WebRtcSpl_GetSizeInBits(max);
scale = (int16_t)(WEBRTC_SPL_MUL_16_16(2,scale)-26); scale = (int16_t)(2 * scale - 26);
if (scale<0) { if (scale<0) {
scale=0; scale=0;
} }

View File

@ -38,7 +38,7 @@ void WebRtcIlbcfix_NearestNeighbor(
/* Calculate square distance */ /* Calculate square distance */
for(i=0;i<arlength;i++){ for(i=0;i<arlength;i++){
diff=array[i]-value; diff=array[i]-value;
crit[i]=WEBRTC_SPL_MUL_16_16(diff, diff); crit[i] = diff * diff;
} }
/* Find the minimum square distance */ /* Find the minimum square distance */

View File

@ -89,14 +89,14 @@ void WebRtcIlbcfix_Poly2Lsp(
xlow = WebRtcIlbcfix_kCosGrid[j]; xlow = WebRtcIlbcfix_kCosGrid[j];
ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]); ylow = WebRtcIlbcfix_Chebyshev(xlow, f[fi_select]);
if (WEBRTC_SPL_MUL_16_16(ylow, yhigh) <= 0) { if (ylow * yhigh <= 0) {
/* Run 4 times to reduce the interval */ /* Run 4 times to reduce the interval */
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
/* xmid =(xlow + xhigh)/2 */ /* xmid =(xlow + xhigh)/2 */
xmid = (xlow >> 1) + (xhigh >> 1); xmid = (xlow >> 1) + (xhigh >> 1);
ymid = WebRtcIlbcfix_Chebyshev(xmid, f[fi_select]); ymid = WebRtcIlbcfix_Chebyshev(xmid, f[fi_select]);
if (WEBRTC_SPL_MUL_16_16(ylow, ymid) <= 0) { if (ylow * ymid <= 0) {
yhigh = ymid; yhigh = ymid;
xhigh = xmid; xhigh = xmid;
} else { } else {

View File

@ -101,7 +101,7 @@ void WebRtcIlbcfix_Refiner(
/* make vector can be upsampled without ever running outside /* make vector can be upsampled without ever running outside
bounds */ bounds */
*updStartPos = (int16_t)WEBRTC_SPL_MUL_16_16(searchSegStartPos,4) + tloc + 4; *updStartPos = (int16_t)(searchSegStartPos * 4) + tloc + 4;
tloc2 = (tloc + 3) >> 2; tloc2 = (tloc + 3) >> 2;
@ -127,7 +127,7 @@ void WebRtcIlbcfix_Refiner(
} }
} }
/* Calculate which of the 4 fractions to use */ /* Calculate which of the 4 fractions to use */
fraction=(int16_t)WEBRTC_SPL_MUL_16_16(tloc2,ENH_UPS0)-tloc; fraction = (int16_t)(tloc2 * ENH_UPS0) - tloc;
/* compute the segment (this is actually a convolution) */ /* compute the segment (this is actually a convolution) */

View File

@ -36,11 +36,11 @@ void WebRtcIlbcfix_SimpleLsfDeQ(
cb_pos = 0; cb_pos = 0;
for (i = 0; i < LSF_NSPLIT; i++) { for (i = 0; i < LSF_NSPLIT; i++) {
for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) {
lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + j + index[i] *
WEBRTC_SPL_MUL_16_16(index[i], WebRtcIlbcfix_kLsfDimCb[i]) + j]; WebRtcIlbcfix_kLsfDimCb[i]];
} }
pos += WebRtcIlbcfix_kLsfDimCb[i]; pos += WebRtcIlbcfix_kLsfDimCb[i];
cb_pos += WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kLsfSizeCb[i], WebRtcIlbcfix_kLsfDimCb[i]); cb_pos += WebRtcIlbcfix_kLsfSizeCb[i] * WebRtcIlbcfix_kLsfDimCb[i];
} }
if (lpc_n>1) { if (lpc_n>1) {
@ -49,11 +49,11 @@ void WebRtcIlbcfix_SimpleLsfDeQ(
cb_pos = 0; cb_pos = 0;
for (i = 0; i < LSF_NSPLIT; i++) { for (i = 0; i < LSF_NSPLIT; i++) {
for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) { for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) {
lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[
WEBRTC_SPL_MUL_16_16(index[LSF_NSPLIT + i], WebRtcIlbcfix_kLsfDimCb[i]) + j]; cb_pos + index[LSF_NSPLIT + i] * WebRtcIlbcfix_kLsfDimCb[i] + j];
} }
pos += WebRtcIlbcfix_kLsfDimCb[i]; pos += WebRtcIlbcfix_kLsfDimCb[i];
cb_pos += WEBRTC_SPL_MUL_16_16(WebRtcIlbcfix_kLsfSizeCb[i], WebRtcIlbcfix_kLsfDimCb[i]); cb_pos += WebRtcIlbcfix_kLsfSizeCb[i] * WebRtcIlbcfix_kLsfDimCb[i];
} }
} }
return; return;

View File

@ -51,7 +51,7 @@ void WebRtcIlbcfix_Smooth(
maxtot=WEBRTC_SPL_MAX(max1, max2); maxtot=WEBRTC_SPL_MAX(max1, max2);
scale=WebRtcSpl_GetSizeInBits(maxtot); scale=WebRtcSpl_GetSizeInBits(maxtot);
scale = (int16_t)WEBRTC_SPL_MUL_16_16(2,scale)-26; scale = (int16_t)(2 * scale) - 26;
scale=WEBRTC_SPL_MAX(0, scale); scale=WEBRTC_SPL_MAX(0, scale);
w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale); w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale);
@ -122,17 +122,14 @@ void WebRtcIlbcfix_Smooth(
scale = scale1; scale = scale1;
} }
w11w00 = WEBRTC_SPL_MUL_16_16( w11w00 = (int16_t)WEBRTC_SPL_SHIFT_W32(w11, -scale) *
(int16_t)WEBRTC_SPL_SHIFT_W32(w11, -scale), (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale);
(int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale));
w10w10 = WEBRTC_SPL_MUL_16_16( w10w10 = (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale) *
(int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale), (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale);
(int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale));
w00w00 = WEBRTC_SPL_MUL_16_16( w00w00 = (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale) *
(int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale), (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale);
(int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale));
/* Calculate (w11*w00-w10*w10)/(w00*w00) in Q16 */ /* Calculate (w11*w00-w10*w10)/(w00*w00) in Q16 */
if (w00w00>65536) { if (w00w00>65536) {

View File

@ -37,7 +37,7 @@ int32_t WebRtcIlbcfix_Smooth_odata(
errs=0; errs=0;
for(i=0;i<80;i++) { for(i=0;i<80;i++) {
err = (psseq[i] - odata[i]) >> 3; err = (psseq[i] - odata[i]) >> 3;
errs+=WEBRTC_SPL_MUL_16_16(err, err); /* errs in Q-6 */ errs += err * err; /* errs in Q-6 */
} }
return errs; return errs;

View File

@ -60,7 +60,8 @@ void WebRtcIlbcfix_StateConstruct(
for(k=0; k<len; k++){ for(k=0; k<len; k++){
/*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 2097152 (= 0.5 << 22) /*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 2097152 (= 0.5 << 22)
maxVal is in Q8 and result is in Q(-1) */ maxVal is in Q8 and result is in Q(-1) */
(*tmp1) = (int16_t) ((WEBRTC_SPL_MUL_16_16(maxVal,WebRtcIlbcfix_kStateSq3[(*tmp2)])+(int32_t)2097152) >> 22); *tmp1 = (int16_t)((maxVal * WebRtcIlbcfix_kStateSq3[*tmp2] + 2097152) >>
22);
tmp1++; tmp1++;
tmp2--; tmp2--;
} }
@ -68,7 +69,8 @@ void WebRtcIlbcfix_StateConstruct(
for(k=0; k<len; k++){ for(k=0; k<len; k++){
/*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 262144 (= 0.5 << 19) /*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 262144 (= 0.5 << 19)
maxVal is in Q5 and result is in Q(-1) */ maxVal is in Q5 and result is in Q(-1) */
(*tmp1) = (int16_t) ((WEBRTC_SPL_MUL_16_16(maxVal,WebRtcIlbcfix_kStateSq3[(*tmp2)])+(int32_t)262144) >> 19); *tmp1 = (int16_t)((maxVal * WebRtcIlbcfix_kStateSq3[*tmp2] + 262144) >>
19);
tmp1++; tmp1++;
tmp2--; tmp2--;
} }
@ -76,7 +78,8 @@ void WebRtcIlbcfix_StateConstruct(
for(k=0; k<len; k++){ for(k=0; k<len; k++){
/*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 65536 (= 0.5 << 17) /*the shifting is due to the Q13 in sq4_fixQ13[i], also the adding of 65536 (= 0.5 << 17)
maxVal is in Q3 and result is in Q(-1) */ maxVal is in Q3 and result is in Q(-1) */
(*tmp1) = (int16_t) ((WEBRTC_SPL_MUL_16_16(maxVal,WebRtcIlbcfix_kStateSq3[(*tmp2)])+(int32_t)65536) >> 17); *tmp1 = (int16_t)((maxVal * WebRtcIlbcfix_kStateSq3[*tmp2] + 65536) >>
17);
tmp1++; tmp1++;
tmp2--; tmp2--;
} }

View File

@ -41,10 +41,10 @@ void WebRtcIlbcfix_Vq3(
/* Find the codebook with the lowest square distance */ /* Find the codebook with the lowest square distance */
for (j = 0; j < n_cb; j++) { for (j = 0; j < n_cb; j++) {
tmp = X[0] - CB[pos]; tmp = X[0] - CB[pos];
dist = WEBRTC_SPL_MUL_16_16(tmp, tmp); dist = tmp * tmp;
for (i = 1; i < 3; i++) { for (i = 1; i < 3; i++) {
tmp = X[i] - CB[pos + i]; tmp = X[i] - CB[pos + i];
dist += WEBRTC_SPL_MUL_16_16(tmp, tmp); dist += tmp * tmp;
} }
if (dist < mindist) { if (dist < mindist) {

View File

@ -41,10 +41,10 @@ void WebRtcIlbcfix_Vq4(
/* Find the codebook with the lowest square distance */ /* Find the codebook with the lowest square distance */
for (j = 0; j < n_cb; j++) { for (j = 0; j < n_cb; j++) {
tmp = X[0] - CB[pos]; tmp = X[0] - CB[pos];
dist = WEBRTC_SPL_MUL_16_16(tmp, tmp); dist = tmp * tmp;
for (i = 1; i < 4; i++) { for (i = 1; i < 4; i++) {
tmp = X[i] - CB[pos + i]; tmp = X[i] - CB[pos + i];
dist += WEBRTC_SPL_MUL_16_16(tmp, tmp); dist += tmp * tmp;
} }
if (dist < mindist) { if (dist < mindist) {

View File

@ -53,7 +53,7 @@ void WebRtcIlbcfix_Window32W32(
y_low = (int16_t)((y[i] - temp) >> 1); y_low = (int16_t)((y[i] - temp) >> 1);
/* Calculate z by a 32 bit multiplication using both low and high from x and y */ /* Calculate z by a 32 bit multiplication using both low and high from x and y */
temp = WEBRTC_SPL_LSHIFT_W32(WEBRTC_SPL_MUL_16_16(x_hi, y_hi), 1); temp = (x_hi * y_hi) << 1;
temp = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_hi, y_low, 14))); temp = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_hi, y_low, 14)));
z[i] = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_low, y_hi, 14))); z[i] = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_low, y_hi, 14)));