shithub: opus

Download patch

ref: c7bcf389da1d5537cd66ae552f0dfe164834bd3d
parent: bdcaaf73c62844f7971b946ae19d641e58a8afad
author: Jean-Marc Valin <[email protected]>
date: Mon Jul 5 10:33:49 EDT 2010

Another coarse budget fix for _ec() calls

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -967,7 +967,8 @@
 #else
    max_decay = .125*nbAvailableBytes;
 #endif
-   coarse_needed = quant_coarse_energy(st->mode, st->start, bandLogE, st->oldBandE, nbAvailableBytes*4-8, intra_ener, st->mode->prob, error, enc, C, max_decay);
+   coarse_needed = quant_coarse_energy(st->mode, st->start, bandLogE, st->oldBandE, nbFilledBytes*8+nbAvailableBytes*4-8, intra_ener, st->mode->prob, error, enc, C, max_decay);
+   coarse_needed -= nbFilledBytes*8;
    coarse_needed = ((coarse_needed*3-1)>>3)+1;
    if (coarse_needed > nbAvailableBytes)
       coarse_needed = nbAvailableBytes;
@@ -1751,7 +1752,7 @@
 
    ALLOC(fine_quant, st->mode->nbEBands, int);
    /* Get band energies */
-   unquant_coarse_energy(st->mode, st->start, bandE, st->oldBandE, nbAvailableBytes*4-8, intra_ener, st->mode->prob, dec, C);
+   unquant_coarse_energy(st->mode, st->start, bandE, st->oldBandE, nbFilledBytes*8+nbAvailableBytes*4-8, intra_ener, st->mode->prob, dec, C);
 
    ALLOC(tf_res, st->mode->nbEBands, int);
    tf_decode(st->mode->nbEBands, C, isTransient, tf_res, nbAvailableBytes, LM, dec);