shithub: opus

Download patch

ref: 8daa4d373948aadbd155f03b3dbc2ce658dfac12
parent: eb2c8f38e6ddaf238d07c090131c47c5f23eacfc
author: Koen Vos <[email protected]>
date: Sun Feb 21 09:27:11 EST 2016

take advantage of more efficient NLSF quantization by reducing number of survivors in search

JMV: edited to be a little more conservative

--- a/silk/NLSF_decode.c
+++ b/silk/NLSF_decode.c
@@ -60,11 +60,10 @@
 /***********************/
 /* NLSF vector decoder */
 /***********************/
-opus_int silk_NLSF_decode(                                      /* O    Number of bits (Q5), if signalType >= 0     */
+void silk_NLSF_decode(
           opus_int16            *pNLSF_Q15,                     /* O    Quantized NLSF vector [ LPC_ORDER ]         */
           opus_int8             *NLSFIndices,                   /* I    Codebook path vector [ LPC_ORDER + 1 ]      */
-    const silk_NLSF_CB_struct   *psNLSF_CB,                     /* I    Codebook object                             */
-    const opus_int              signalType                      /* I    SignalType, to determine number of bits     */
+    const silk_NLSF_CB_struct   *psNLSF_CB                      /* I    Codebook object                             */
 )
 {
     opus_int         i;
@@ -91,25 +90,4 @@
 
     /* NLSF stabilization */
     silk_NLSF_stabilize( pNLSF_Q15, psNLSF_CB->deltaMin_Q15, psNLSF_CB->order );
-
-    if( signalType >= 0 ) {
-        opus_int         prob_Q8, bits_Q5;
-        const opus_uint8 *iCDF_ptr;
-        bits_Q5 = 0;
-        iCDF_ptr = &psNLSF_CB->CB1_iCDF[ ( signalType >> 1 ) * psNLSF_CB->nVectors ];
-        if( NLSFIndices[ 0 ] == 0 ) {
-            prob_Q8 = 256 - iCDF_ptr[ NLSFIndices[ 0 ] ];
-        } else {
-            prob_Q8 = iCDF_ptr[ NLSFIndices[ 0 ] - 1 ] - iCDF_ptr[ NLSFIndices[ 0 ] ];
-        }
-        bits_Q5 = ( 8 << 5 ) - ( silk_lin2log( prob_Q8 ) >> 2 );
-        for( i = 0; i < psNLSF_CB->order; i++ ) {
-            const opus_uint8 *rates_Q5;
-            rates_Q5 = &psNLSF_CB->ec_Rates_Q5[ ec_ix[ i ] ];
-            bits_Q5 += rates_Q5[ NLSFIndices[ i + 1 ] + NLSF_QUANT_MAX_AMPLITUDE ];
-        }
-        return bits_Q5;
-    }
-
-    return 0;
 }
--- a/silk/NLSF_encode.c
+++ b/silk/NLSF_encode.c
@@ -37,7 +37,7 @@
 /***********************/
 opus_int32 silk_NLSF_encode(                                    /* O    Returns RD value in Q25                     */
           opus_int8             *NLSFIndices,                   /* I    Codebook path vector [ LPC_ORDER + 1 ]      */
-          opus_int16            *pNLSF_Q15,                     /* I/O  Quantized NLSF vector [ LPC_ORDER ]         */
+          opus_int16            *pNLSF_Q15,                     /* I/O  (Un)quantized NLSF vector [ LPC_ORDER ]     */
     const silk_NLSF_CB_struct   *psNLSF_CB,                     /* I    Codebook object                             */
     const opus_int16            *pW_Q2,                         /* I    NLSF weight vector [ LPC_ORDER ]            */
     const opus_int              NLSF_mu_Q20,                    /* I    Rate weight for the RD optimization         */
@@ -117,7 +117,7 @@
     silk_memcpy( &NLSFIndices[ 1 ], &tempIndices2[ bestIndex * MAX_LPC_ORDER ], psNLSF_CB->order * sizeof( opus_int8 ) );
 
     /* Decode */
-    silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB, -1 );
+    silk_NLSF_decode( pNLSF_Q15, NLSFIndices, psNLSF_CB );
 
     ret = RD_Q25[ 0 ];
     RESTORE_STACK;
--- a/silk/control_codec.c
+++ b/silk/control_codec.c
@@ -339,7 +339,7 @@
         psEncC->nStatesDelayedDecision          = 1;
         psEncC->useInterpolatedNLSFs            = 0;
         psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 4;
+        psEncC->NLSF_MSVQ_Survivors             = 3;
         psEncC->warping_Q16                     = 0;
     } else if( Complexity < 6 ) {
         psEncC->pitchEstimationComplexity       = SILK_PE_MID_COMPLEX;
@@ -350,7 +350,7 @@
         psEncC->nStatesDelayedDecision          = 2;
         psEncC->useInterpolatedNLSFs            = 1;
         psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 8;
+        psEncC->NLSF_MSVQ_Survivors             = 6;
         psEncC->warping_Q16                     = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 );
     } else if( Complexity < 8 ) {
         psEncC->pitchEstimationComplexity       = SILK_PE_MID_COMPLEX;
@@ -361,7 +361,7 @@
         psEncC->nStatesDelayedDecision          = 3;
         psEncC->useInterpolatedNLSFs            = 1;
         psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 16;
+        psEncC->NLSF_MSVQ_Survivors             = 8;
         psEncC->warping_Q16                     = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 );
     } else {
         psEncC->pitchEstimationComplexity       = SILK_PE_MAX_COMPLEX;
@@ -372,7 +372,7 @@
         psEncC->nStatesDelayedDecision          = MAX_DEL_DEC_STATES;
         psEncC->useInterpolatedNLSFs            = 1;
         psEncC->LTPQuantLowComplexity           = 0;
-        psEncC->NLSF_MSVQ_Survivors             = 32;
+        psEncC->NLSF_MSVQ_Survivors             = 16;
         psEncC->warping_Q16                     = psEncC->fs_kHz * SILK_FIX_CONST( WARPING_MULTIPLIER, 16 );
     }
 
--- a/silk/decode_parameters.c
+++ b/silk/decode_parameters.c
@@ -49,7 +49,7 @@
     /****************/
     /* Decode NLSFs */
     /****************/
-    silk_NLSF_decode( pNLSF_Q15, psDec->indices.NLSFIndices, psDec->psNLSF_CB, -1 );
+    silk_NLSF_decode( pNLSF_Q15, psDec->indices.NLSFIndices, psDec->psNLSF_CB );
 
     /* Convert NLSF parameters to AR prediction filter coefficients */
     silk_NLSF2A( psDecCtrl->PredCoef_Q12[ 1 ], pNLSF_Q15, psDec->LPC_order );
--- a/silk/define.h
+++ b/silk/define.h
@@ -205,7 +205,7 @@
 /******************/
 #define NLSF_W_Q                                2
 #define NLSF_VQ_MAX_VECTORS                     32
-#define NLSF_VQ_MAX_SURVIVORS                   32
+#define NLSF_VQ_MAX_SURVIVORS                   16
 #define NLSF_QUANT_MAX_AMPLITUDE                4
 #define NLSF_QUANT_MAX_AMPLITUDE_EXT            10
 #define NLSF_QUANT_LEVEL_ADJ                    0.1
--- a/silk/main.h
+++ b/silk/main.h
@@ -376,11 +376,10 @@
 /***********************/
 /* NLSF vector decoder */
 /***********************/
-opus_int silk_NLSF_decode(                                      /* O    Number of bits (Q5), if signalType >= 0     */
+void silk_NLSF_decode(
           opus_int16            *pNLSF_Q15,                     /* O    Quantized NLSF vector [ LPC_ORDER ]         */
           opus_int8             *NLSFIndices,                   /* I    Codebook path vector [ LPC_ORDER + 1 ]      */
-    const silk_NLSF_CB_struct   *psNLSF_CB,                     /* I    Codebook object                             */
-    const opus_int              signalType                      /* I    SignalType, to determine number of bits     */
+    const silk_NLSF_CB_struct   *psNLSF_CB                      /* I    Codebook object                             */
 );
 
 /****************************************************/