From 9a8bac019c5e459d75a19b67ed59e2d37a5cbf08 Mon Sep 17 00:00:00 2001 From: Jean-Marc Valin Date: Mon, 5 May 2008 12:02:14 +1000 Subject: [PATCH] Using only a sign for the intra prediction instead of using up to 5 bits for an offset. --- libcelt/bands.c | 4 +- libcelt/rate.c | 11 ++-- libcelt/vq.c | 147 ++++++++++++++---------------------------------- libcelt/vq.h | 4 +- 4 files changed, 51 insertions(+), 115 deletions(-) diff --git a/libcelt/bands.c b/libcelt/bands.c index c9514001..7f10f23f 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -331,7 +331,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce if (q<0) intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], norm, P+C*eBands[i], eBands[i], eBands[m->nbEBands+1]); else - intra_prediction(m, X+C*eBands[i], W+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], enc); + intra_prediction(m, X+C*eBands[i], W+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], eBands[m->nbEBands+1], enc); } if (q > 0) @@ -389,7 +389,7 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, if (q<0) intra_fold(m, X+C*eBands[i], eBands[i+1]-eBands[i], norm, P+C*eBands[i], eBands[i], eBands[m->nbEBands+1]); else - intra_unquant(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], dec); + intra_unquant(m, X+C*eBands[i], eBands[i+1]-eBands[i], q, norm, P+C*eBands[i], eBands[i], eBands[m->nbEBands+1], dec); } if (q > 0) diff --git a/libcelt/rate.c b/libcelt/rate.c index 57c77094..efc2941f 100644 --- a/libcelt/rate.c +++ b/libcelt/rate.c @@ -47,6 +47,7 @@ #define BITOVERFLOW 10000 #ifndef STATIC_MODES +#if 0 static int log2_frac(ec_uint32 val, int frac) { int i; @@ -70,6 +71,7 @@ static int log2_frac(ec_uint32 val, int frac) } return L; } +#endif static int log2_frac64(ec_uint64 val, int frac) { @@ -135,14 +137,9 @@ void compute_alloc_cache(CELTMode *m) /* FIXME: Could there be a better test for the max number of pulses that fit in 64 bits? */ if (bits[i][j] > (60<= m->pitchEnd) - { - int max_pos = 2*eBands[i]-eBands[i+1]; - if (max_pos > 32) - max_pos = 32; - bits[i][j] += (1< MAX_INTRA) - max_pos = MAX_INTRA; - - /* Reverse the samples of x without reversing the channels */ - for (c=0;c10) + pred_gain = pg[10]; + else + pred_gain = pg[K]; + E = EPSILON; + if (N0 >= (Nmax>>1)) { - celt_norm_t * restrict Xrp = &Xr[C*N-C+c]; - const celt_norm_t * restrict xp = &x[c]; - j=0; do { - *Xrp = *xp; - Xrp -= C; - xp += C; - } while (++j MULT16_16(den, best_num)) + for (i=0;i10) - pred_gain = pg[10]; - else - pred_gain = pg[K]; - E = EPSILON; - for (c=0;c0) @@ -378,51 +323,45 @@ void intra_prediction(const CELTMode *m, celt_norm_t * restrict x, celt_mask_t * for (j=0;j MAX_INTRA) - max_pos = MAX_INTRA; - - sign = ec_dec_bits(dec, 1); - if (sign == 0) + + if (ec_dec_bits(dec, 1) == 0) s = 1; else s = -1; - if (max_pos == MAX_INTRA) - best = C*ec_dec_bits(dec, LOG_MAX_INTRA); - else - best = C*ec_dec_uint(dec, max_pos); - /*printf ("%d %d ", sign, best);*/ - if (K>10) pred_gain = pg[10]; else pred_gain = pg[K]; E = EPSILON; - for (c=0;c= (Nmax>>1)) { - for (j=0;j