Index: celt/rate.c |
diff --git a/celt/rate.c b/celt/rate.c |
index e13d839d63b3ffb74a098b4dd4e6de28cac9e46c..f85c3ee63c8777c71caf409c3fb4f1828933ca9c 100644 |
--- a/celt/rate.c |
+++ b/celt/rate.c |
@@ -333,7 +333,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, |
/*Figure out how many left-over bits we would be adding to this band. |
This can include bits we've stolen back from higher, skipped bands.*/ |
left = total-psum; |
- percoeff = left/(m->eBands[codedBands]-m->eBands[start]); |
+ percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]); |
left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; |
rem = IMAX(left-(m->eBands[j]-m->eBands[start]),0); |
band_width = m->eBands[codedBands]-m->eBands[j]; |
@@ -414,7 +414,7 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, |
/* Allocate the remaining bits */ |
left = total-psum; |
- percoeff = left/(m->eBands[codedBands]-m->eBands[start]); |
+ percoeff = celt_udiv(left, m->eBands[codedBands]-m->eBands[start]); |
left -= (m->eBands[codedBands]-m->eBands[start])*percoeff; |
for (j=start;j<codedBands;j++) |
bits[j] += ((int)percoeff*(m->eBands[j+1]-m->eBands[j])); |
@@ -465,7 +465,8 @@ static OPUS_INLINE int interp_bits2pulses(const CELTMode *m, int start, int end, |
offset += NClogN>>3; |
/* Divide with rounding */ |
- ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1))) / (den<<BITRES)); |
+ ebits[j] = IMAX(0, (bits[j] + offset + (den<<(BITRES-1)))); |
+ ebits[j] = celt_udiv(ebits[j], den)>>BITRES; |
/* Make sure not to bust */ |
if (C*ebits[j] > (bits[j]>>BITRES)) |