Avoiding left shifts of negative values
diff --git a/celt/bands.c b/celt/bands.c
index f89a94e..64622ea 100644
--- 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)
diff --git a/celt/celt.c b/celt/celt.c
index ad48734..87d648f 100644
--- 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);*/
diff --git a/celt/rate.c b/celt/rate.c
index 987dffd..8afacda 100644
--- 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)