ref: aa995ddde38b8982edc7fe7c2d372a95ed94017c
parent: 88c59a534bf163fc382eb27c038d16c23e3716ed
author: Jean-Marc Valin <[email protected]>
date: Thu Aug 5 13:39:13 EDT 2010
Making qn code 16-bit clean while simplifying it
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -413,7 +413,7 @@
int N2 = 2*N-1;
if (stereo && N==2)
N2--;
- qb = (b+N2*offset)/(N2);
+ qb = (b+N2*offset)/N2;
if (qb > (b>>1)-(1<<BITRES))
qb = (b>>1)-(1<<BITRES);
@@ -425,8 +425,8 @@
if (qb<(1<<BITRES>>1)) {
qn = 1;
} else {
- qn = ((1<<(qb>>BITRES))*exp2_table8[qb&0x7] + (1<<14))>>14;
- qn = qn>>1<<1;
+ qn = exp2_table8[qb&0x7]>>(14-(qb>>BITRES));
+ qn = (qn+1)>>1<<1;
if (qn>1024)
qn = 1024;
}