shithub: opus

Download patch

ref: e5bab14e4f05d264de0fb732b77a0116bd7b8e4c
parent: 29ccab8aacdd3a0bb3d8c5b74fc54ece925384fd
author: Jean-Marc Valin <[email protected]>
date: Thu Dec 6 11:51:19 EST 2007

Doing init/reset of the entropy coder properly

--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -80,7 +80,6 @@
    st->nb_blocks  = B;
    
    ec_byte_writeinit(&st->buf);
-   ec_enc_init(&st->enc,&st->buf);
 
    mdct_init(&st->mdct_lookup, 2*N);
    st->fft = spx_fft_init(MAX_PERIOD);
@@ -173,6 +172,10 @@
    float gains[st->mode->nbPBands];
    int pitch_index;
    
+
+   ec_byte_reset(&st->buf);
+   ec_enc_init(&st->enc,&st->buf);
+
    for (i=0;i<N;i++)
       in[i] = st->in_mem[i];
    for (;i<(B+1)*N;i++)
@@ -267,7 +270,8 @@
          pcm[i*N+j] = (short)floor(.5+tmp);
       }
    }
-   printf ("%d\n", ec_byte_bytes(&st->buf));
+   ec_enc_done(&st->enc);
+   //printf ("%d\n", ec_byte_bytes(&st->buf));
    return 0;
 }