ref: 8f0f4b942166bf9385319fdbbde390e5a21e0f6a
parent: 5b50f4bf81d532de20bc07be795a7787348bcadd
author: Jean-Marc Valin <[email protected]>
date: Mon Feb 11 08:52:44 EST 2008
Limiting intra-frame prediction codebook to 32 entries (plus sign)
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -340,6 +340,8 @@
}
}
+ if (ec_enc_tell(&st->enc, 0) < nbCompressedBytes*8 - 8)
+ celt_warning_int ("too make unused bits", nbCompressedBytes*8-ec_enc_tell(&st->enc, 0));
//printf ("%d\n", ec_enc_tell(&st->enc, 0)-8*nbCompressedBytes);
/* Finishing the stream with a 0101... pattern so that the decoder can check is everything's right */
{
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -124,7 +124,12 @@
done = 1;
/* Add the intra-frame prediction bits */
if (eBands[i] >= m->pitchEnd)
- alloc->bits[i][j] += (1<<BITRES) + log2_frac64(2*eBands[i]-eBands[i+1],BITRES);
+ {
+ int max_pos = 2*eBands[i]-eBands[i+1];
+ if (max_pos > 32)
+ max_pos = 32;
+ alloc->bits[i][j] += (1<<BITRES) + log2_frac(max_pos,BITRES);
+ }
/* We could just update rev_bits here */
if (done)
break;
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -271,7 +271,11 @@
float s = 1;
int sign;
float E;
- for (i=0;i<N0*B-N;i+=B)
+ int max_pos = N0-N/B;
+ if (max_pos > 32)
+ max_pos = 32;
+
+ for (i=0;i<max_pos*B;i+=B)
{
int j;
float xy=0, yy=0;
@@ -298,7 +302,7 @@
sign = 0;
//printf ("%d %d ", sign, best);
ec_enc_uint(enc,sign,2);
- ec_enc_uint(enc,best/B,N0-N/B);
+ ec_enc_uint(enc,best/B,max_pos);
//printf ("%d %f\n", best, best_score);
float pred_gain;
@@ -335,6 +339,10 @@
float s;
int best;
float E;
+ int max_pos = N0-N/B;
+ if (max_pos > 32)
+ max_pos = 32;
+
sign = ec_dec_uint(dec, 2);
if (sign == 0)
s = 1;
@@ -341,7 +349,7 @@
else
s = -1;
- best = B*ec_dec_uint(dec, N0-N/B);
+ best = B*ec_dec_uint(dec, max_pos);
//printf ("%d %d ", sign, best);
float pred_gain;