SILK encoder control struct no longer part of the state
authorJean-Marc Valin <jean-marc.valin@octasic.com>
Tue, 20 Jul 2010 16:19:00 +0000 (12:19 -0400)
committerJean-Marc Valin <jean-marc.valin@octasic.com>
Tue, 20 Jul 2010 16:19:00 +0000 (12:19 -0400)
src/hybrid_encoder.c
src/hybrid_encoder.h

index 2acf3eb..fd9f599 100644 (file)
@@ -45,9 +45,12 @@ HybridEncoder *hybrid_encoder_create(int Fs)
 {
        HybridEncoder *st;
        int ret, encSizeBytes;
+    SKP_SILK_SDK_EncControlStruct encControl;
 
        st = calloc(sizeof(HybridEncoder), 1);
 
+    st->Fs = Fs;
+
     /* Create SILK encoder */
     ret = SKP_Silk_SDK_Get_Encoder_Size( &encSizeBytes );
     if( ret ) {
@@ -55,23 +58,16 @@ HybridEncoder *hybrid_encoder_create(int Fs)
     }
        st->silk_enc = malloc(encSizeBytes);
 
-    ret = SKP_Silk_SDK_InitEncoder( st->silk_enc, &st->encControl );
+    /*encControl.API_sampleRate        = st->Fs;
+    encControl.packetLossPercentage  = 0;
+    encControl.useInBandFEC          = 0;
+    encControl.useDTX                = 0;
+    encControl.complexity            = 2;*/
+    ret = SKP_Silk_SDK_InitEncoder( st->silk_enc, &encControl );
     if( ret ) {
         /* Handle error */
     }
 
-    st->Fs = Fs;
-
-    /* Set Encoder parameters */
-    st->encControl.API_sampleRate        = Fs;
-    st->encControl.maxInternalSampleRate = 16000;
-    st->encControl.packetSize            = Fs/50;
-    st->encControl.packetLossPercentage  = 0;
-    st->encControl.useInBandFEC          = 0;
-    st->encControl.useDTX                = 0;
-    st->encControl.complexity            = 2;
-    st->encControl.bitRate               = 18000;
-
     /* Create CELT encoder */
        /* We should not have to create a CELT mode for each encoder state */
        st->celt_mode = celt_mode_create(Fs, Fs/50, NULL);
@@ -93,27 +89,35 @@ int hybrid_encode(HybridEncoder *st, const short *pcm, int frame_size,
        SKP_int16 nBytes;
        ec_enc enc;
        ec_byte_buffer buf;
+       SKP_SILK_SDK_EncControlStruct encControl;
 
        ec_byte_writeinit_buffer(&buf, data, bytes_per_packet);
        ec_enc_init(&enc,&buf);
 
        if (st->mode != MODE_CELT_ONLY)
        {
-           st->encControl.bitRate = (bytes_per_packet*50*8+6000)/2;
+           /* Set Encoder parameters */
+           encControl.API_sampleRate        = st->Fs;
+           encControl.packetLossPercentage  = 0;
+           encControl.useInBandFEC          = 0;
+           encControl.useDTX                = 0;
+           encControl.complexity            = 2;
+
+           encControl.bitRate = (bytes_per_packet*50*8+6000)/2;
            if (st->Fs / frame_size == 100)
-               st->encControl.bitRate += 5000;
-           st->encControl.packetSize = frame_size;
+               encControl.bitRate += 5000;
+           encControl.packetSize = frame_size;
 
            if (st->bandwidth == BANDWIDTH_NARROWBAND)
-               st->encControl.maxInternalSampleRate = 8000;
+               encControl.maxInternalSampleRate = 8000;
            else if (st->bandwidth == BANDWIDTH_MEDIUMBAND)
-            st->encControl.maxInternalSampleRate = 12000;
+            encControl.maxInternalSampleRate = 12000;
            else
-               st->encControl.maxInternalSampleRate = 16000;
+               encControl.maxInternalSampleRate = 16000;
 
            /* Call SILK encoder for the low band */
            nBytes = bytes_per_packet;
-           ret = SKP_Silk_SDK_Encode( st->silk_enc, &st->encControl, pcm, frame_size, &enc, &nBytes );
+           ret = SKP_Silk_SDK_Encode( st->silk_enc, &encControl, pcm, frame_size, &enc, &nBytes );
            if( ret ) {
                fprintf (stderr, "SILK encode error\n");
                /* Handle error */
index 6e4c62a..adb5f1d 100644 (file)
@@ -43,7 +43,6 @@ struct HybridEncoder {
        CELTMode    *celt_mode;
        CELTEncoder *celt_enc;
        void        *silk_enc;
-       SKP_SILK_SDK_EncControlStruct encControl;
 
     int          mode;
        int          bandwidth;