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-Original-Commit-Position: refs/heads/master@{#8358}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: ba97ea69f0b8bb73a837869211627b705eac8f98
diff --git a/modules/audio_coding/codecs/ilbc/bw_expand.c b/modules/audio_coding/codecs/ilbc/bw_expand.c
index 4c29bb1..b02abab 100644
--- a/modules/audio_coding/codecs/ilbc/bw_expand.c
+++ b/modules/audio_coding/codecs/ilbc/bw_expand.c
@@ -37,6 +37,6 @@
/* out[i] = coef[i] * in[i] with rounding.
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);
}
}
diff --git a/modules/audio_coding/codecs/ilbc/cb_construct.c b/modules/audio_coding/codecs/ilbc/cb_construct.c
index 04a59e1..9d11b83 100644
--- a/modules/audio_coding/codecs/ilbc/cb_construct.c
+++ b/modules/audio_coding/codecs/ilbc/cb_construct.c
@@ -56,9 +56,9 @@
gainPtr = &gain[0];
for (j=0;j<veclen;j++) {
- a32 = WEBRTC_SPL_MUL_16_16(*gainPtr++, cbvec0[j]);
- a32 += WEBRTC_SPL_MUL_16_16(*gainPtr++, cbvec1[j]);
- a32 += WEBRTC_SPL_MUL_16_16(*gainPtr, cbvec2[j]);
+ a32 = (*gainPtr++) * cbvec0[j];
+ a32 += (*gainPtr++) * cbvec1[j];
+ a32 += (*gainPtr) * cbvec2[j];
gainPtr -= 2;
decvector[j] = (int16_t)((a32 + 8192) >> 14);
}
diff --git a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
index 4c7332a..87a510d 100644
--- a/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
+++ b/modules/audio_coding/codecs/ilbc/cb_mem_energy_calc.c
@@ -45,8 +45,7 @@
/* Calculate next energy by a +/-
operation on the edge samples */
- tmp = WEBRTC_SPL_MUL_16_16(*ppi, *ppi);
- tmp -= WEBRTC_SPL_MUL_16_16(*ppo, *ppo);
+ tmp = (*ppi) * (*ppi) - (*ppo) * (*ppo);
energy += tmp >> scale;
energy = WEBRTC_SPL_MAX(energy, 0);
diff --git a/modules/audio_coding/codecs/ilbc/cb_search.c b/modules/audio_coding/codecs/ilbc/cb_search.c
index 8a89c87..b4d2b37 100644
--- a/modules/audio_coding/codecs/ilbc/cb_search.c
+++ b/modules/audio_coding/codecs/ilbc/cb_search.c
@@ -113,7 +113,7 @@
if ((temp1>0)&&(temp2>0)) {
temp1 = WEBRTC_SPL_MAX(temp1, temp2);
- scale = WebRtcSpl_GetSizeInBits(WEBRTC_SPL_MUL_16_16(temp1, temp1));
+ scale = WebRtcSpl_GetSizeInBits((uint32_t)(temp1 * temp1));
} else {
/* temp1 or temp2 is negative (maximum was -32768) */
scale = 30;
@@ -361,8 +361,7 @@
tmp = (int16_t) WEBRTC_SPL_MUL_16_16_RSFT(gains[1],gains[1], 14);
- targetEner = WEBRTC_SPL_MUL_16_16(
- WEBRTC_SPL_SHIFT_W32(targetEner, -bits), tmp);
+ targetEner = (int16_t)WEBRTC_SPL_SHIFT_W32(targetEner, -bits) * tmp;
tmpW32 = ((int32_t)(gains[1]-1))<<1;
@@ -381,7 +380,7 @@
gainTbl[i] < 2*gain[0]
*/
- t32 = WEBRTC_SPL_MUL_16_16(temp1, (*gainPtr));
+ t32 = temp1 * *gainPtr;
t32 = t32 - targetEner;
if (t32 < 0) {
if ((*WebRtcIlbcfix_kGainSq5_ptr) < tmpW32) {
diff --git a/modules/audio_coding/codecs/ilbc/cb_search_core.c b/modules/audio_coding/codecs/ilbc/cb_search_core.c
index a511422..559d998 100644
--- a/modules/audio_coding/codecs/ilbc/cb_search_core.c
+++ b/modules/audio_coding/codecs/ilbc/cb_search_core.c
@@ -70,7 +70,7 @@
cDotSqW16 = (int16_t)(((int32_t)(tmp16)*(tmp16))>>16);
/* 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
that the criteria is not zero */
diff --git a/modules/audio_coding/codecs/ilbc/chebyshev.c b/modules/audio_coding/codecs/ilbc/chebyshev.c
index 6174c9d..50d91e4 100644
--- a/modules/audio_coding/codecs/ilbc/chebyshev.c
+++ b/modules/audio_coding/codecs/ilbc/chebyshev.c
@@ -50,8 +50,7 @@
b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1);
/* Calculate 2*x*b1-b2+f[i] */
- tmp1W32 = WEBRTC_SPL_LSHIFT_W32( (WEBRTC_SPL_MUL_16_16(b1_high, x) +
- WEBRTC_SPL_MUL_16_16_RSFT(b1_low, x, 15)), 2);
+ 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);
@@ -65,7 +64,7 @@
b1_low = (int16_t)((tmp1W32 - ((int32_t)b1_high << 16)) >> 1);
/* 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);
tmp1W32 -= b2;
diff --git a/modules/audio_coding/codecs/ilbc/do_plc.c b/modules/audio_coding/codecs/ilbc/do_plc.c
index 53a4e9a..2306be1 100644
--- a/modules/audio_coding/codecs/ilbc/do_plc.c
+++ b/modules/audio_coding/codecs/ilbc/do_plc.c
@@ -107,12 +107,11 @@
WEBRTC_SPL_SHIFT_W32(cross_comp, -shift1), 15);
shift2 = WebRtcSpl_GetSizeInBits(ener)-15;
- measure = WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_SHIFT_W32(ener, -shift2),
- crossSquare);
+ measure = (int16_t)WEBRTC_SPL_SHIFT_W32(ener, -shift2) * crossSquare;
shift3 = WebRtcSpl_GetSizeInBits(ener_comp)-15;
- maxMeasure = WEBRTC_SPL_MUL_16_16(WEBRTC_SPL_SHIFT_W32(ener_comp, -shift3),
- crossSquareMax);
+ maxMeasure = (int16_t)WEBRTC_SPL_SHIFT_W32(ener_comp, -shift3) *
+ crossSquareMax;
/* Calculate shift value, so that the two measures can
be put in the same Q domain */
@@ -164,7 +163,7 @@
tmp1 = (int16_t)WEBRTC_SPL_SHIFT_W32(cross, (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);
} else {
@@ -230,7 +229,7 @@
for (i=0; i<iLBCdec_inst->blockl; i++) {
/* 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);
pick = i - randlag;
diff --git a/modules/audio_coding/codecs/ilbc/encode.c b/modules/audio_coding/codecs/ilbc/encode.c
index 6f7c04e..1d46eff 100644
--- a/modules/audio_coding/codecs/ilbc/encode.c
+++ b/modules/audio_coding/codecs/ilbc/encode.c
@@ -154,7 +154,7 @@
index = (iLBCbits_inst->startIdx-1)*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 = scale - 25;
diff --git a/modules/audio_coding/codecs/ilbc/enh_upsample.c b/modules/audio_coding/codecs/ilbc/enh_upsample.c
index 91f3970..929c630 100644
--- a/modules/audio_coding/codecs/ilbc/enh_upsample.c
+++ b/modules/audio_coding/codecs/ilbc/enh_upsample.c
@@ -39,26 +39,26 @@
/* i = 2 */
pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
ps=seq1+2;
- (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
+ *pu11 = (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0;
/* i = 3 */
pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
ps=seq1+3;
- (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
+ *pu11 = (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0;
/* i = 4 */
pp=WebRtcIlbcfix_kEnhPolyPhaser[j]+1;
ps=seq1+4;
- (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--,*pp++);
+ *pu11 = (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
pu1++;
}
@@ -79,7 +79,7 @@
pp = polyp[j]+i;
ps = seq1+dim1-1;
for(k=0;k<filterlength-i;k++) {
- *pu += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
+ *pu += (*ps--) * *pp++;
}
pu+=ENH_UPS0;
}
@@ -92,17 +92,17 @@
/* i = 1 */
pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+2;
ps = w16tmp;
- (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
+ *pu11 = (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0;
/* i = 2 */
pp = WebRtcIlbcfix_kEnhPolyPhaser[j]+3;
ps = w16tmp;
- (*pu11) = WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
- (*pu11) += WEBRTC_SPL_MUL_16_16(*ps--, *pp++);
+ *pu11 = (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
+ *pu11 += (*ps--) * *pp++;
pu11+=ENH_UPS0;
pu1++;
diff --git a/modules/audio_coding/codecs/ilbc/enhancer_interface.c b/modules/audio_coding/codecs/ilbc/enhancer_interface.c
index 4f27988..5376930 100644
--- a/modules/audio_coding/codecs/ilbc/enhancer_interface.c
+++ b/modules/audio_coding/codecs/ilbc/enhancer_interface.c
@@ -110,14 +110,14 @@
for(iblock = 0; iblock<new_blocks; iblock++){
/* references */
- i=60+WEBRTC_SPL_MUL_16_16(iblock,ENH_BLOCKL_HALF);
+ i = 60 + iblock * ENH_BLOCKL_HALF;
target=downsampled+i;
regressor=downsampled+i-10;
/* scaling */
max16=WebRtcSpl_MaxAbsValueW16(®ressor[-50],
(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);
/* compute cross correlation */
@@ -160,14 +160,14 @@
for (i=1; i<3; i++) {
if (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)) {
ind = i;
}
} else {
sh = WEBRTC_SPL_MIN(31, totsh[i]-totsh[ind]);
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;
}
}
@@ -176,21 +176,20 @@
lag = lagmax[ind] + 10;
/* Store the estimated lag in the non-downsampled domain */
- enh_period[ENH_NBLOCKS_TOT-new_blocks+iblock] =
- (int16_t)WEBRTC_SPL_MUL_16_16(lag, 8);
+ enh_period[ENH_NBLOCKS_TOT - new_blocks + iblock] = (int16_t)(lag * 8);
/* Store the estimated lag for backward PLC */
if (iLBCdec_inst->prev_enh_pl==1) {
if (!iblock) {
- tlag = WEBRTC_SPL_MUL_16_16(lag, 2);
+ tlag = lag * 2;
}
} else {
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)) {
@@ -370,10 +369,10 @@
/* Perform enhancement block by block */
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_BUFL,
- (int16_t)(WEBRTC_SPL_MUL_16_16(iblock, ENH_BLOCKL)+startPos),
+ (int16_t)(iblock * ENH_BLOCKL + startPos),
enh_period,
(int16_t*)WebRtcIlbcfix_kEnhPlocs, ENH_NBLOCKS_TOT);
}
diff --git a/modules/audio_coding/codecs/ilbc/frame_classify.c b/modules/audio_coding/codecs/ilbc/frame_classify.c
index c93cdd4..d124b6b 100644
--- a/modules/audio_coding/codecs/ilbc/frame_classify.c
+++ b/modules/audio_coding/codecs/ilbc/frame_classify.c
@@ -46,7 +46,7 @@
*/
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 = scale-24;
diff --git a/modules/audio_coding/codecs/ilbc/gain_dequant.c b/modules/audio_coding/codecs/ilbc/gain_dequant.c
index 8570c8b..07e09bb 100644
--- a/modules/audio_coding/codecs/ilbc/gain_dequant.c
+++ b/modules/audio_coding/codecs/ilbc/gain_dequant.c
@@ -41,5 +41,5 @@
/* select the quantization table and return the decoded value */
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);
}
diff --git a/modules/audio_coding/codecs/ilbc/gain_quant.c b/modules/audio_coding/codecs/ilbc/gain_quant.c
index f7a8083..983c6db 100644
--- a/modules/audio_coding/codecs/ilbc/gain_quant.c
+++ b/modules/audio_coding/codecs/ilbc/gain_quant.c
@@ -30,7 +30,7 @@
int16_t *index /* (o) quantization index */
) {
- int16_t scale, returnVal, cblen;
+ int16_t scale, cblen;
int32_t gainW32, measure1, measure2;
const int16_t *cbPtr, *cb;
int loc, noMoves, noChecks, i;
@@ -62,7 +62,7 @@
for (i=noChecks;i>0;i--) {
noMoves>>=1;
- measure1=WEBRTC_SPL_MUL_16_16(scale, (*cbPtr));
+ measure1 = scale * *cbPtr;
/* Move up if gain is larger, otherwise move down in table */
measure1 = measure1 - gainW32;
@@ -78,16 +78,16 @@
/* 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) {
/* Check against value above loc */
- measure2=WEBRTC_SPL_MUL_16_16(scale, (*(cbPtr+1)));
+ measure2 = scale * cbPtr[1];
if ((measure2-gainW32)<(gainW32-measure1)) {
loc+=1;
}
} else {
/* Check against value below loc */
- measure2=WEBRTC_SPL_MUL_16_16(scale, (*(cbPtr-1)));
+ measure2 = scale * cbPtr[-1];
if ((gainW32-measure2)<=(measure1-gainW32)) {
loc-=1;
}
@@ -98,9 +98,6 @@
loc=WEBRTC_SPL_MIN(loc, (cblen-1));
*index=loc;
- /* Calculate the quantized gain value (in Q14) */
- returnVal=(int16_t)((WEBRTC_SPL_MUL_16_16(scale, cb[loc])+8192)>>14);
-
- /* return the quantized value */
- return(returnVal);
+ /* Calculate and return the quantized gain value (in Q14) */
+ return (int16_t)((scale * cb[loc] + 8192) >> 14);
}
diff --git a/modules/audio_coding/codecs/ilbc/get_cd_vec.c b/modules/audio_coding/codecs/ilbc/get_cd_vec.c
index fb9b03d..cf05ce3 100644
--- a/modules/audio_coding/codecs/ilbc/get_cd_vec.c
+++ b/modules/audio_coding/codecs/ilbc/get_cd_vec.c
@@ -58,7 +58,7 @@
/* 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;
diff --git a/modules/audio_coding/codecs/ilbc/get_lsp_poly.c b/modules/audio_coding/codecs/ilbc/get_lsp_poly.c
index 2b0fe2b..64079a3 100644
--- a/modules/audio_coding/codecs/ilbc/get_lsp_poly.c
+++ b/modules/audio_coding/codecs/ilbc/get_lsp_poly.c
@@ -67,7 +67,7 @@
high = (int16_t)(fPtr[-1] >> 16);
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);
(*fPtr) += fPtr[-2];
diff --git a/modules/audio_coding/codecs/ilbc/get_sync_seq.c b/modules/audio_coding/codecs/ilbc/get_sync_seq.c
index 695631a..480ed7c 100644
--- a/modules/audio_coding/codecs/ilbc/get_sync_seq.c
+++ b/modules/audio_coding/codecs/ilbc/get_sync_seq.c
@@ -46,11 +46,12 @@
/* present (find predicted lag from this position) */
- WebRtcIlbcfix_NearestNeighbor(lagBlock+hl,plocs,
- (int16_t)WEBRTC_SPL_MUL_16_16(2, (centerStartPos+centerEndPos)),
+ WebRtcIlbcfix_NearestNeighbor(lagBlock + hl,
+ plocs,
+ (int16_t)(2 * (centerStartPos + centerEndPos)),
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
search to find the best sequence) */
@@ -58,11 +59,14 @@
for(q=hl-1;q>=0;q--) {
blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]];
- WebRtcIlbcfix_NearestNeighbor(lagBlock+q, plocs,
- (int16_t)(blockStartPos[q] + (int16_t)WEBRTC_SPL_MUL_16_16(4, ENH_BLOCKL_HALF)-period[lagBlock[q+1]]),
- periodl);
+ WebRtcIlbcfix_NearestNeighbor(
+ lagBlock + q,
+ 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
domain around blockStartPos+q */
@@ -82,17 +86,17 @@
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,
- (int16_t)(blockStartPos[q-1]+
- (int16_t)WEBRTC_SPL_MUL_16_16(4, ENH_BLOCKL_HALF)),periodl);
+ WebRtcIlbcfix_NearestNeighbor(
+ lagBlock + q,
+ plocs2,
+ (int16_t)(blockStartPos[q - 1] + 4 * ENH_BLOCKL_HALF),
+ periodl);
blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]];
- if( (blockStartPos[q]+(int16_t)WEBRTC_SPL_MUL_16_16(4, (ENH_BLOCKL+ENH_OVERHANG)))
- <
- (int16_t)WEBRTC_SPL_MUL_16_16(4, idatal)) {
+ if (blockStartPos[q] + 4 * (ENH_BLOCKL + ENH_OVERHANG) < 4 * idatal) {
/* Find the best possible sequence in the 4 times upsampled
domain around blockStartPos+q */
diff --git a/modules/audio_coding/codecs/ilbc/hp_input.c b/modules/audio_coding/codecs/ilbc/hp_input.c
index 40c35eb..a36ea39 100644
--- a/modules/audio_coding/codecs/ilbc/hp_input.c
+++ b/modules/audio_coding/codecs/ilbc/hp_input.c
@@ -43,16 +43,16 @@
+ (-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 += WEBRTC_SPL_MUL_16_16(y[3], ba[4]); /* (-a[2])*y[i-2] (low part) */
+ tmpW32 = y[1] * ba[3]; /* (-a[1])*y[i-1] (low part) */
+ tmpW32 += y[3] * ba[4]; /* (-a[2])*y[i-2] (low part) */
tmpW32 = (tmpW32>>15);
- tmpW32 += WEBRTC_SPL_MUL_16_16(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[0] * ba[3]; /* (-a[1])*y[i-1] (high part) */
+ tmpW32 += y[2] * ba[4]; /* (-a[2])*y[i-2] (high part) */
tmpW32 = (tmpW32<<1);
- tmpW32 += WEBRTC_SPL_MUL_16_16(signal[i], ba[0]); /* b[0]*x[0] */
- tmpW32 += WEBRTC_SPL_MUL_16_16(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 += signal[i] * ba[0]; /* b[0]*x[0] */
+ tmpW32 += x[0] * ba[1]; /* b[1]*x[i-1] */
+ tmpW32 += x[1] * ba[2]; /* b[2]*x[i-2] */
/* Update state (input part) */
x[1] = x[0];
diff --git a/modules/audio_coding/codecs/ilbc/hp_output.c b/modules/audio_coding/codecs/ilbc/hp_output.c
index e1de829..970ae11 100644
--- a/modules/audio_coding/codecs/ilbc/hp_output.c
+++ b/modules/audio_coding/codecs/ilbc/hp_output.c
@@ -43,16 +43,16 @@
+ (-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 += WEBRTC_SPL_MUL_16_16(y[3], ba[4]); /* (-a[2])*y[i-2] (low part) */
+ tmpW32 = y[1] * ba[3]; /* (-a[1])*y[i-1] (low part) */
+ tmpW32 += y[3] * ba[4]; /* (-a[2])*y[i-2] (low part) */
tmpW32 = (tmpW32>>15);
- tmpW32 += WEBRTC_SPL_MUL_16_16(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[0] * ba[3]; /* (-a[1])*y[i-1] (high part) */
+ tmpW32 += y[2] * ba[4]; /* (-a[2])*y[i-2] (high part) */
tmpW32 = (tmpW32<<1);
- tmpW32 += WEBRTC_SPL_MUL_16_16(signal[i], ba[0]); /* b[0]*x[0] */
- tmpW32 += WEBRTC_SPL_MUL_16_16(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 += signal[i] * ba[0]; /* b[0]*x[0] */
+ tmpW32 += x[0] * ba[1]; /* b[1]*x[i-1] */
+ tmpW32 += x[1] * ba[2]; /* b[2]*x[i-2] */
/* Update state (input part) */
x[1] = x[0];
diff --git a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c
index 078a0fc..2503293 100644
--- a/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c
+++ b/modules/audio_coding/codecs/ilbc/lsf_to_lsp.c
@@ -53,7 +53,7 @@
}
/* 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);
}
diff --git a/modules/audio_coding/codecs/ilbc/my_corr.c b/modules/audio_coding/codecs/ilbc/my_corr.c
index c6cd834..048745a 100644
--- a/modules/audio_coding/codecs/ilbc/my_corr.c
+++ b/modules/audio_coding/codecs/ilbc/my_corr.c
@@ -37,7 +37,7 @@
max=WebRtcSpl_MaxAbsValueW16(seq1, dim1);
scale=WebRtcSpl_GetSizeInBits(max);
- scale = (int16_t)(WEBRTC_SPL_MUL_16_16(2,scale)-26);
+ scale = (int16_t)(2 * scale - 26);
if (scale<0) {
scale=0;
}
diff --git a/modules/audio_coding/codecs/ilbc/nearest_neighbor.c b/modules/audio_coding/codecs/ilbc/nearest_neighbor.c
index 8d1272f..6329908 100644
--- a/modules/audio_coding/codecs/ilbc/nearest_neighbor.c
+++ b/modules/audio_coding/codecs/ilbc/nearest_neighbor.c
@@ -38,7 +38,7 @@
/* Calculate square distance */
for(i=0;i<arlength;i++){
diff=array[i]-value;
- crit[i]=WEBRTC_SPL_MUL_16_16(diff, diff);
+ crit[i] = diff * diff;
}
/* Find the minimum square distance */
diff --git a/modules/audio_coding/codecs/ilbc/poly_to_lsp.c b/modules/audio_coding/codecs/ilbc/poly_to_lsp.c
index 74bb1b7..47d7fdc 100644
--- a/modules/audio_coding/codecs/ilbc/poly_to_lsp.c
+++ b/modules/audio_coding/codecs/ilbc/poly_to_lsp.c
@@ -89,14 +89,14 @@
xlow = WebRtcIlbcfix_kCosGrid[j];
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 */
for (i = 0; i < 4; i++) {
/* xmid =(xlow + xhigh)/2 */
xmid = (xlow >> 1) + (xhigh >> 1);
ymid = WebRtcIlbcfix_Chebyshev(xmid, f[fi_select]);
- if (WEBRTC_SPL_MUL_16_16(ylow, ymid) <= 0) {
+ if (ylow * ymid <= 0) {
yhigh = ymid;
xhigh = xmid;
} else {
diff --git a/modules/audio_coding/codecs/ilbc/refiner.c b/modules/audio_coding/codecs/ilbc/refiner.c
index e96ae26..ca99b3a 100644
--- a/modules/audio_coding/codecs/ilbc/refiner.c
+++ b/modules/audio_coding/codecs/ilbc/refiner.c
@@ -101,7 +101,7 @@
/* make vector can be upsampled without ever running outside
bounds */
- *updStartPos = (int16_t)WEBRTC_SPL_MUL_16_16(searchSegStartPos,4) + tloc + 4;
+ *updStartPos = (int16_t)(searchSegStartPos * 4) + tloc + 4;
tloc2 = (tloc + 3) >> 2;
@@ -127,7 +127,7 @@
}
}
/* 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) */
diff --git a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c b/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c
index ef54883..9fa0d61 100644
--- a/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c
+++ b/modules/audio_coding/codecs/ilbc/simple_lsf_dequant.c
@@ -36,11 +36,11 @@
cb_pos = 0;
for (i = 0; i < LSF_NSPLIT; i++) {
for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) {
- lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos +
- WEBRTC_SPL_MUL_16_16(index[i], WebRtcIlbcfix_kLsfDimCb[i]) + j];
+ lsfdeq[pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos + j + index[i] *
+ 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) {
@@ -49,11 +49,11 @@
cb_pos = 0;
for (i = 0; i < LSF_NSPLIT; i++) {
for (j = 0; j < WebRtcIlbcfix_kLsfDimCb[i]; j++) {
- lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[cb_pos +
- WEBRTC_SPL_MUL_16_16(index[LSF_NSPLIT + i], WebRtcIlbcfix_kLsfDimCb[i]) + j];
+ lsfdeq[LPC_FILTERORDER + pos + j] = WebRtcIlbcfix_kLsfCb[
+ cb_pos + index[LSF_NSPLIT + i] * WebRtcIlbcfix_kLsfDimCb[i] + j];
}
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;
diff --git a/modules/audio_coding/codecs/ilbc/smooth.c b/modules/audio_coding/codecs/ilbc/smooth.c
index 3d59c52..57bd4ae 100644
--- a/modules/audio_coding/codecs/ilbc/smooth.c
+++ b/modules/audio_coding/codecs/ilbc/smooth.c
@@ -51,7 +51,7 @@
maxtot=WEBRTC_SPL_MAX(max1, max2);
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);
w00=WebRtcSpl_DotProductWithScale(current,current,ENH_BLOCKL,scale);
@@ -122,17 +122,14 @@
scale = scale1;
}
- w11w00 = WEBRTC_SPL_MUL_16_16(
- (int16_t)WEBRTC_SPL_SHIFT_W32(w11, -scale),
- (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale));
+ w11w00 = (int16_t)WEBRTC_SPL_SHIFT_W32(w11, -scale) *
+ (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale);
- w10w10 = WEBRTC_SPL_MUL_16_16(
- (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale),
- (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale));
+ w10w10 = (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale) *
+ (int16_t)WEBRTC_SPL_SHIFT_W32(w10, -scale);
- w00w00 = WEBRTC_SPL_MUL_16_16(
- (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale),
- (int16_t)WEBRTC_SPL_SHIFT_W32(w00, -scale));
+ w00w00 = (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 */
if (w00w00>65536) {
diff --git a/modules/audio_coding/codecs/ilbc/smooth_out_data.c b/modules/audio_coding/codecs/ilbc/smooth_out_data.c
index 622af7b..9c41e04 100644
--- a/modules/audio_coding/codecs/ilbc/smooth_out_data.c
+++ b/modules/audio_coding/codecs/ilbc/smooth_out_data.c
@@ -37,7 +37,7 @@
errs=0;
for(i=0;i<80;i++) {
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;
diff --git a/modules/audio_coding/codecs/ilbc/state_construct.c b/modules/audio_coding/codecs/ilbc/state_construct.c
index 492ad59..80b3e1b 100644
--- a/modules/audio_coding/codecs/ilbc/state_construct.c
+++ b/modules/audio_coding/codecs/ilbc/state_construct.c
@@ -60,7 +60,8 @@
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)
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++;
tmp2--;
}
@@ -68,7 +69,8 @@
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)
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++;
tmp2--;
}
@@ -76,7 +78,8 @@
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)
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++;
tmp2--;
}
diff --git a/modules/audio_coding/codecs/ilbc/vq3.c b/modules/audio_coding/codecs/ilbc/vq3.c
index a6c6cdb..ee3b26e 100644
--- a/modules/audio_coding/codecs/ilbc/vq3.c
+++ b/modules/audio_coding/codecs/ilbc/vq3.c
@@ -41,10 +41,10 @@
/* Find the codebook with the lowest square distance */
for (j = 0; j < n_cb; j++) {
tmp = X[0] - CB[pos];
- dist = WEBRTC_SPL_MUL_16_16(tmp, tmp);
+ dist = tmp * tmp;
for (i = 1; i < 3; i++) {
tmp = X[i] - CB[pos + i];
- dist += WEBRTC_SPL_MUL_16_16(tmp, tmp);
+ dist += tmp * tmp;
}
if (dist < mindist) {
diff --git a/modules/audio_coding/codecs/ilbc/vq4.c b/modules/audio_coding/codecs/ilbc/vq4.c
index 7776dfb..bc20952 100644
--- a/modules/audio_coding/codecs/ilbc/vq4.c
+++ b/modules/audio_coding/codecs/ilbc/vq4.c
@@ -41,10 +41,10 @@
/* Find the codebook with the lowest square distance */
for (j = 0; j < n_cb; j++) {
tmp = X[0] - CB[pos];
- dist = WEBRTC_SPL_MUL_16_16(tmp, tmp);
+ dist = tmp * tmp;
for (i = 1; i < 4; i++) {
tmp = X[i] - CB[pos + i];
- dist += WEBRTC_SPL_MUL_16_16(tmp, tmp);
+ dist += tmp * tmp;
}
if (dist < mindist) {
diff --git a/modules/audio_coding/codecs/ilbc/window32_w32.c b/modules/audio_coding/codecs/ilbc/window32_w32.c
index ef5357e..7852419 100644
--- a/modules/audio_coding/codecs/ilbc/window32_w32.c
+++ b/modules/audio_coding/codecs/ilbc/window32_w32.c
@@ -53,7 +53,7 @@
y_low = (int16_t)((y[i] - temp) >> 1);
/* 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)));
z[i] = (temp + (WEBRTC_SPL_MUL_16_16_RSFT(x_low, y_hi, 14)));