Fixes a bug in the init() functions where were weren't zeroing the entire state
authorJean-Marc Valin <jean-marc.valin@octasic.com>
Thu, 19 May 2011 21:25:48 +0000 (17:25 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Thu, 19 May 2011 21:25:48 +0000 (17:25 -0400)
src/opus_decoder.c
src/opus_encoder.c

index c47517c..c784233 100644 (file)
@@ -65,16 +65,15 @@ OpusDecoder *opus_decoder_init(OpusDecoder *st, int Fs, int channels)
 {
        void *silk_dec;
        CELTDecoder *celt_dec;
-       int ret, silkDecSizeBytes, celtDecSizeBytes;
+       int ret, silkDecSizeBytes;
 
-       memset(st, 0, sizeof(OpusDecoder));
+       memset(st, 0, opus_decoder_get_size(channels));
        /* Initialize SILK encoder */
     ret = silk_Get_Decoder_Size( &silkDecSizeBytes );
     if( ret ) {
         return NULL;
     }
     silkDecSizeBytes = align(silkDecSizeBytes);
-    celtDecSizeBytes = celt_decoder_get_size(channels);
     st->silk_dec_offset = align(sizeof(OpusDecoder));
     st->celt_dec_offset = st->silk_dec_offset+silkDecSizeBytes;
     silk_dec = (char*)st+st->silk_dec_offset;
index 4bc4950..f306606 100644 (file)
@@ -80,15 +80,14 @@ OpusEncoder *opus_encoder_init(OpusEncoder* st, int Fs, int channels)
        void *silk_enc;
        CELTEncoder *celt_enc;
     int err;
-       int ret, silkEncSizeBytes, celtEncSizeBytes;
+       int ret, silkEncSizeBytes;
 
-       memset(st, 0, sizeof(OpusEncoder));
+       memset(st, 0, opus_encoder_get_size(channels));
     /* Create SILK encoder */
     ret = silk_Get_Encoder_Size( &silkEncSizeBytes );
     if( ret )
        return NULL;
        silkEncSizeBytes = align(silkEncSizeBytes);
-    celtEncSizeBytes = celt_encoder_get_size(channels);
     st->silk_enc_offset = align(sizeof(OpusEncoder));
     st->celt_enc_offset = st->silk_enc_offset+silkEncSizeBytes;
     silk_enc = (char*)st+st->silk_enc_offset;