Updated to CELT's new API
authorJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Mon, 31 Jan 2011 04:44:51 +0000 (23:44 -0500)
committerJean-Marc Valin <jean-marc.valin@usherbrooke.ca>
Mon, 31 Jan 2011 04:44:51 +0000 (23:44 -0500)
celt
configure.ac
src/opus_decoder.c
src/opus_decoder.h
src/opus_encoder.c
src/opus_encoder.h

diff --git a/celt b/celt
index 620e716..8cf29f0 160000 (submodule)
--- a/celt
+++ b/celt
@@ -1 +1 @@
-Subproject commit 620e716b764eb643e0a376f64f55448ad9447eb2
+Subproject commit 8cf29f0991bea7460adbd90fd39d95328b9a3065
index 950609a..8dc2c1d 100644 (file)
@@ -3,7 +3,7 @@
 
 AC_PREREQ([2.59])
 AC_INIT(src/opus.h)
-AM_INIT_AUTOMAKE(opus,20101113)
+AM_INIT_AUTOMAKE(opus,20110122)
 
 # Checks for programs.
 AC_PROG_CC
index 3db3dcb..d15c976 100644 (file)
@@ -46,25 +46,20 @@ OpusDecoder *opus_decoder_create(int Fs)
 {
     char *raw_state;
        int ret, silkDecSizeBytes, celtDecSizeBytes;
-       CELTMode *celtMode;
        OpusDecoder *st;
 
-    /* We should not have to create a CELT mode for each encoder state */
-    celtMode = celt_mode_create(Fs, Fs/50, NULL);
-
        /* Initialize SILK encoder */
     ret = SKP_Silk_SDK_Get_Decoder_Size( &silkDecSizeBytes );
     if( ret ) {
         /* Handle error */
     }
-    celtDecSizeBytes = celt_decoder_get_size(celtMode, 1);
+    celtDecSizeBytes = celt_decoder_get_size(1);
     raw_state = calloc(sizeof(OpusDecoder)+silkDecSizeBytes+celtDecSizeBytes, 1);
     st = (OpusDecoder*)raw_state;
     st->silk_dec = (void*)(raw_state+sizeof(OpusDecoder));
     st->celt_dec = (CELTDecoder*)(raw_state+sizeof(OpusDecoder)+silkDecSizeBytes);
 
     st->Fs = Fs;
-    st->celt_mode = celtMode;
 
     /* Reset decoder */
     ret = SKP_Silk_SDK_InitDecoder( st->silk_dec );
@@ -73,7 +68,7 @@ OpusDecoder *opus_decoder_create(int Fs)
     }
 
        /* Initialize CELT decoder */
-       st->celt_dec = celt_decoder_init(st->celt_dec, st->celt_mode, 1, NULL);
+       st->celt_dec = celt_decoder_init(st->celt_dec, 48000, 1, NULL);
 
        return st;
 
@@ -166,10 +161,25 @@ int opus_decode(OpusDecoder *st, const unsigned char *data,
 
     if (st->mode != MODE_SILK_ONLY && st->bandwidth > BANDWIDTH_WIDEBAND)
     {
-        if (st->bandwidth == BANDWIDTH_SUPERWIDEBAND)
-            celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(20));
-        else
-            celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(21));
+       int endband;
+
+           switch(st->bandwidth)
+           {
+           case BANDWIDTH_NARROWBAND:
+               endband = 13;
+               break;
+           case BANDWIDTH_WIDEBAND:
+               endband = 17;
+               break;
+           case BANDWIDTH_SUPERWIDEBAND:
+               endband = 19;
+               break;
+           case BANDWIDTH_FULLBAND:
+               endband = 21;
+               break;
+           }
+           celt_decoder_ctl(st->celt_dec, CELT_SET_END_BAND(endband));
+
         /* Encode high band with CELT */
         celt_ret = celt_decode_with_ec(st->celt_dec, data, len, pcm_celt, frame_size, &dec);
         for (i=0;i<frame_size;i++)
@@ -221,7 +231,5 @@ void opus_decoder_ctl(OpusDecoder *st, int request, ...)
 
 void opus_decoder_destroy(OpusDecoder *st)
 {
-       celt_mode_destroy(st->celt_mode);
-
        free(st);
 }
index 9bb8106..c7a3be6 100644 (file)
@@ -36,7 +36,6 @@
 #include "opus.h"
 
 struct OpusDecoder {
-       CELTMode    *celt_mode;
        CELTDecoder *celt_dec;
        void        *silk_dec;
 
index f66b189..7de1b21 100644 (file)
 OpusEncoder *opus_encoder_create(int Fs)
 {
     char *raw_state;
-    CELTMode *celtMode;
        OpusEncoder *st;
        int ret, silkEncSizeBytes, celtEncSizeBytes;
     SKP_SILK_SDK_EncControlStruct encControl;
 
-    /* We should not have to create a CELT mode for each encoder state */
-    celtMode = celt_mode_create(Fs, Fs/50, NULL);
-
     /* Create SILK encoder */
     ret = SKP_Silk_SDK_Get_Encoder_Size( &silkEncSizeBytes );
     if( ret ) {
        /* Handle error */
     }
-    celtEncSizeBytes = celt_encoder_get_size(celtMode, 1);
+    celtEncSizeBytes = celt_encoder_get_size(1);
     raw_state = calloc(sizeof(OpusEncoder)+silkEncSizeBytes+celtEncSizeBytes, 1);
     st = (OpusEncoder*)raw_state;
     st->silk_enc = (void*)(raw_state+sizeof(OpusEncoder));
     st->celt_enc = (CELTEncoder*)(raw_state+sizeof(OpusEncoder)+silkEncSizeBytes);
 
     st->Fs = Fs;
-    st->celt_mode = celtMode;
 
     /*encControl.API_sampleRate        = st->Fs;
     encControl.packetLossPercentage  = 0;
@@ -78,7 +73,7 @@ OpusEncoder *opus_encoder_create(int Fs)
 
     /* Create CELT encoder */
        /* Initialize CELT encoder */
-       st->celt_enc = celt_encoder_init(st->celt_enc, st->celt_mode, 1, NULL);
+       st->celt_enc = celt_encoder_init(st->celt_enc, Fs, 1, NULL);
 
        st->mode = MODE_HYBRID;
        st->bandwidth = BANDWIDTH_FULLBAND;
@@ -119,19 +114,19 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
                if (st->Fs  == 100 * frame_size)
                    encControl.bitRate -= 5000;
            }
-            encControl.payloadSize_ms = 1000 * frame_size / st->Fs;
+           encControl.payloadSize_ms = 1000 * frame_size / st->Fs;
 
-            if (st->mode == MODE_HYBRID)
-               encControl.minInternalSampleRate = 16000;
-            else
-               encControl.minInternalSampleRate = 8000;
+           if (st->mode == MODE_HYBRID)
+               encControl.minInternalSampleRate = 16000;
+           else
+               encControl.minInternalSampleRate = 8000;
 
            if (st->bandwidth == BANDWIDTH_NARROWBAND)
                encControl.maxInternalSampleRate = 8000;
            else if (st->bandwidth == BANDWIDTH_MEDIUMBAND)
-               encControl.maxInternalSampleRate = 12000;
+               encControl.maxInternalSampleRate = 12000;
            else
-               encControl.maxInternalSampleRate = 16000;
+               encControl.maxInternalSampleRate = 16000;
 
            /* Call SILK encoder for the low band */
            nBytes = bytes_per_packet;
@@ -153,12 +148,25 @@ int opus_encode(OpusEncoder *st, const short *pcm, int frame_size,
 
        if (st->mode != MODE_SILK_ONLY && st->bandwidth > BANDWIDTH_WIDEBAND)
        {
+               int endband;
            short pcm_buf[960];
 
-        if (st->bandwidth == BANDWIDTH_SUPERWIDEBAND)
-            celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(20));
-        else
-            celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(21));
+           switch(st->bandwidth)
+           {
+           case BANDWIDTH_NARROWBAND:
+               endband = 13;
+               break;
+           case BANDWIDTH_WIDEBAND:
+               endband = 17;
+               break;
+           case BANDWIDTH_SUPERWIDEBAND:
+               endband = 19;
+               break;
+           case BANDWIDTH_FULLBAND:
+               endband = 21;
+               break;
+           }
+           celt_encoder_ctl(st->celt_enc, CELT_SET_END_BAND(endband));
 
            for (i=0;i<ENCODER_DELAY_COMPENSATION;i++)
                pcm_buf[i] = st->delay_buffer[i];
@@ -269,7 +277,6 @@ void opus_encoder_ctl(OpusEncoder *st, int request, ...)
 
 void opus_encoder_destroy(OpusEncoder *st)
 {
-       celt_mode_destroy(st->celt_mode);
        free(st);
 }
 
index 8c952ab..37d4370 100644 (file)
@@ -40,7 +40,6 @@
 #define ENCODER_DELAY_COMPENSATION 130
 
 struct OpusEncoder {
-       CELTMode    *celt_mode;
        CELTEncoder *celt_enc;
        void        *silk_enc;