ref: 803ec8c6b4d959b6b1df4b2e8f253415c7b4c325
parent: 40b954dcf3224a6352071834e7f92d07ef022816
author: Jean-Marc Valin <[email protected]>
date: Fri Sep 23 19:48:40 EDT 2011
Avoiding left shifts of negative values
--- a/celt/bands.c
+++ b/celt/bands.c
@@ -68,7 +68,7 @@
ls=EC_ILOG(isin);
icos<<=15-lc;
isin<<=15-ls;
- return ((ls-lc)<<11)
+ return (ls-lc)*(1<<11)
+FRAC_MUL16(isin, FRAC_MUL16(isin, -2597) + 7932)
-FRAC_MUL16(icos, FRAC_MUL16(icos, -2597) + 7932);
}
@@ -775,7 +775,7 @@
opus_int32 tell;
/* Decide on the resolution to give to the split parameter theta */
- pulse_cap = m->logN[i]+(LM<<BITRES);
+ pulse_cap = m->logN[i]+LM*(1<<BITRES);
offset = (pulse_cap>>1) - (stereo&&N==2 ? QTHETA_OFFSET_TWOPHASE : QTHETA_OFFSET);
qn = compute_qn(N, b, offset, pulse_cap, stereo);
if (stereo && i>=intensity)
--- a/celt/celt.c
+++ b/celt/celt.c
@@ -1430,7 +1430,7 @@
/*printf ("%d\n", st->vbr_reservoir);*/
/* Compute the offset we need to apply in order to reach the target */
- st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,(delta<<lm_diff)-st->vbr_offset-st->vbr_drift);
+ st->vbr_drift += (opus_int32)MULT16_32_Q15(alpha,(delta*(1<<lm_diff))-st->vbr_offset-st->vbr_drift);
st->vbr_offset = -st->vbr_drift;
/*printf ("%d\n", st->vbr_drift);*/
--- a/celt/rate.c
+++ b/celt/rate.c
@@ -571,7 +571,7 @@
thresh[j] = IMAX((C)<<BITRES, (3*(m->eBands[j+1]-m->eBands[j])<<LM<<BITRES)>>4);
/* Tilt of the allocation curve */
trim_offset[j] = C*(m->eBands[j+1]-m->eBands[j])*(alloc_trim-5-LM)*(end-j-1)
- <<(LM+BITRES)>>6;
+ *(1<<(LM+BITRES))>>6;
/* Giving less resolution to single-coefficient bands because they get
more benefit from having one coarse value per coefficient*/
if ((m->eBands[j+1]-m->eBands[j])<<LM==1)