ref: 784959e8e99efb462e23000ab25e6ede9bb3700e
parent: 05778451e700e60d0b7ee3b86fa0096b76e9ae1f
author: Jean-Marc Valin <[email protected]>
date: Fri Apr 18 15:35:34 EDT 2008
separated the two passes from interp_bits2pulses()
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -201,7 +201,6 @@
{
int lo, hi, out;
int j;
- int firstpass;
VARDECL(int, bits);
SAVE_STACK;
ALLOC(bits, len, int);
@@ -223,13 +222,23 @@
out = vec_bits2pulses(m, bits, pulses, len);
/* Do some refinement to use up all bits. In the first pass, we can only add pulses to
bands that are under their allocated budget. In the second pass, anything goes */
- firstpass = 1;
+ for (j=0;j<len;j++)
+ {
+ if (m->bits[j][pulses[j]] < bits[j] && pulses[j]<MAX_PULSES-1)
+ {
+ if (out+m->bits[j][pulses[j]+1]-m->bits[j][pulses[j]] <= total<<BITRES)
+ {
+ out = out+m->bits[j][pulses[j]+1]-m->bits[j][pulses[j]];
+ pulses[j] += 1;
+ }
+ }
+ }
while(1)
{
int incremented = 0;
for (j=0;j<len;j++)
{
- if ((!firstpass || m->bits[j][pulses[j]] < bits[j]) && pulses[j]<MAX_PULSES-1)
+ if (pulses[j]<MAX_PULSES-1)
{
if (out+m->bits[j][pulses[j]+1]-m->bits[j][pulses[j]] <= total<<BITRES)
{
@@ -240,12 +249,7 @@
}
}
if (!incremented)
- {
- if (firstpass)
- firstpass = 0;
- else
break;
- }
}
RESTORE_STACK;
return (out+BITROUND) >> BITRES;