annotate src/opus-1.3/silk/decode_indices.c @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents 4664ac0c1032
children
rev   line source
cannam@154 1 /***********************************************************************
cannam@154 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
cannam@154 3 Redistribution and use in source and binary forms, with or without
cannam@154 4 modification, are permitted provided that the following conditions
cannam@154 5 are met:
cannam@154 6 - Redistributions of source code must retain the above copyright notice,
cannam@154 7 this list of conditions and the following disclaimer.
cannam@154 8 - Redistributions in binary form must reproduce the above copyright
cannam@154 9 notice, this list of conditions and the following disclaimer in the
cannam@154 10 documentation and/or other materials provided with the distribution.
cannam@154 11 - Neither the name of Internet Society, IETF or IETF Trust, nor the
cannam@154 12 names of specific contributors, may be used to endorse or promote
cannam@154 13 products derived from this software without specific prior written
cannam@154 14 permission.
cannam@154 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
cannam@154 16 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
cannam@154 17 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
cannam@154 18 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
cannam@154 19 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
cannam@154 20 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
cannam@154 21 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
cannam@154 22 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
cannam@154 23 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
cannam@154 24 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
cannam@154 25 POSSIBILITY OF SUCH DAMAGE.
cannam@154 26 ***********************************************************************/
cannam@154 27
cannam@154 28 #ifdef HAVE_CONFIG_H
cannam@154 29 #include "config.h"
cannam@154 30 #endif
cannam@154 31
cannam@154 32 #include "main.h"
cannam@154 33
cannam@154 34 /* Decode side-information parameters from payload */
cannam@154 35 void silk_decode_indices(
cannam@154 36 silk_decoder_state *psDec, /* I/O State */
cannam@154 37 ec_dec *psRangeDec, /* I/O Compressor data structure */
cannam@154 38 opus_int FrameIndex, /* I Frame number */
cannam@154 39 opus_int decode_LBRR, /* I Flag indicating LBRR data is being decoded */
cannam@154 40 opus_int condCoding /* I The type of conditional coding to use */
cannam@154 41 )
cannam@154 42 {
cannam@154 43 opus_int i, k, Ix;
cannam@154 44 opus_int decode_absolute_lagIndex, delta_lagIndex;
cannam@154 45 opus_int16 ec_ix[ MAX_LPC_ORDER ];
cannam@154 46 opus_uint8 pred_Q8[ MAX_LPC_ORDER ];
cannam@154 47
cannam@154 48 /*******************************************/
cannam@154 49 /* Decode signal type and quantizer offset */
cannam@154 50 /*******************************************/
cannam@154 51 if( decode_LBRR || psDec->VAD_flags[ FrameIndex ] ) {
cannam@154 52 Ix = ec_dec_icdf( psRangeDec, silk_type_offset_VAD_iCDF, 8 ) + 2;
cannam@154 53 } else {
cannam@154 54 Ix = ec_dec_icdf( psRangeDec, silk_type_offset_no_VAD_iCDF, 8 );
cannam@154 55 }
cannam@154 56 psDec->indices.signalType = (opus_int8)silk_RSHIFT( Ix, 1 );
cannam@154 57 psDec->indices.quantOffsetType = (opus_int8)( Ix & 1 );
cannam@154 58
cannam@154 59 /****************/
cannam@154 60 /* Decode gains */
cannam@154 61 /****************/
cannam@154 62 /* First subframe */
cannam@154 63 if( condCoding == CODE_CONDITIONALLY ) {
cannam@154 64 /* Conditional coding */
cannam@154 65 psDec->indices.GainsIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
cannam@154 66 } else {
cannam@154 67 /* Independent coding, in two stages: MSB bits followed by 3 LSBs */
cannam@154 68 psDec->indices.GainsIndices[ 0 ] = (opus_int8)silk_LSHIFT( ec_dec_icdf( psRangeDec, silk_gain_iCDF[ psDec->indices.signalType ], 8 ), 3 );
cannam@154 69 psDec->indices.GainsIndices[ 0 ] += (opus_int8)ec_dec_icdf( psRangeDec, silk_uniform8_iCDF, 8 );
cannam@154 70 }
cannam@154 71
cannam@154 72 /* Remaining subframes */
cannam@154 73 for( i = 1; i < psDec->nb_subfr; i++ ) {
cannam@154 74 psDec->indices.GainsIndices[ i ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_delta_gain_iCDF, 8 );
cannam@154 75 }
cannam@154 76
cannam@154 77 /**********************/
cannam@154 78 /* Decode LSF Indices */
cannam@154 79 /**********************/
cannam@154 80 psDec->indices.NLSFIndices[ 0 ] = (opus_int8)ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->CB1_iCDF[ ( psDec->indices.signalType >> 1 ) * psDec->psNLSF_CB->nVectors ], 8 );
cannam@154 81 silk_NLSF_unpack( ec_ix, pred_Q8, psDec->psNLSF_CB, psDec->indices.NLSFIndices[ 0 ] );
cannam@154 82 celt_assert( psDec->psNLSF_CB->order == psDec->LPC_order );
cannam@154 83 for( i = 0; i < psDec->psNLSF_CB->order; i++ ) {
cannam@154 84 Ix = ec_dec_icdf( psRangeDec, &psDec->psNLSF_CB->ec_iCDF[ ec_ix[ i ] ], 8 );
cannam@154 85 if( Ix == 0 ) {
cannam@154 86 Ix -= ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 );
cannam@154 87 } else if( Ix == 2 * NLSF_QUANT_MAX_AMPLITUDE ) {
cannam@154 88 Ix += ec_dec_icdf( psRangeDec, silk_NLSF_EXT_iCDF, 8 );
cannam@154 89 }
cannam@154 90 psDec->indices.NLSFIndices[ i+1 ] = (opus_int8)( Ix - NLSF_QUANT_MAX_AMPLITUDE );
cannam@154 91 }
cannam@154 92
cannam@154 93 /* Decode LSF interpolation factor */
cannam@154 94 if( psDec->nb_subfr == MAX_NB_SUBFR ) {
cannam@154 95 psDec->indices.NLSFInterpCoef_Q2 = (opus_int8)ec_dec_icdf( psRangeDec, silk_NLSF_interpolation_factor_iCDF, 8 );
cannam@154 96 } else {
cannam@154 97 psDec->indices.NLSFInterpCoef_Q2 = 4;
cannam@154 98 }
cannam@154 99
cannam@154 100 if( psDec->indices.signalType == TYPE_VOICED )
cannam@154 101 {
cannam@154 102 /*********************/
cannam@154 103 /* Decode pitch lags */
cannam@154 104 /*********************/
cannam@154 105 /* Get lag index */
cannam@154 106 decode_absolute_lagIndex = 1;
cannam@154 107 if( condCoding == CODE_CONDITIONALLY && psDec->ec_prevSignalType == TYPE_VOICED ) {
cannam@154 108 /* Decode Delta index */
cannam@154 109 delta_lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_delta_iCDF, 8 );
cannam@154 110 if( delta_lagIndex > 0 ) {
cannam@154 111 delta_lagIndex = delta_lagIndex - 9;
cannam@154 112 psDec->indices.lagIndex = (opus_int16)( psDec->ec_prevLagIndex + delta_lagIndex );
cannam@154 113 decode_absolute_lagIndex = 0;
cannam@154 114 }
cannam@154 115 }
cannam@154 116 if( decode_absolute_lagIndex ) {
cannam@154 117 /* Absolute decoding */
cannam@154 118 psDec->indices.lagIndex = (opus_int16)ec_dec_icdf( psRangeDec, silk_pitch_lag_iCDF, 8 ) * silk_RSHIFT( psDec->fs_kHz, 1 );
cannam@154 119 psDec->indices.lagIndex += (opus_int16)ec_dec_icdf( psRangeDec, psDec->pitch_lag_low_bits_iCDF, 8 );
cannam@154 120 }
cannam@154 121 psDec->ec_prevLagIndex = psDec->indices.lagIndex;
cannam@154 122
cannam@154 123 /* Get countour index */
cannam@154 124 psDec->indices.contourIndex = (opus_int8)ec_dec_icdf( psRangeDec, psDec->pitch_contour_iCDF, 8 );
cannam@154 125
cannam@154 126 /********************/
cannam@154 127 /* Decode LTP gains */
cannam@154 128 /********************/
cannam@154 129 /* Decode PERIndex value */
cannam@154 130 psDec->indices.PERIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTP_per_index_iCDF, 8 );
cannam@154 131
cannam@154 132 for( k = 0; k < psDec->nb_subfr; k++ ) {
cannam@154 133 psDec->indices.LTPIndex[ k ] = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTP_gain_iCDF_ptrs[ psDec->indices.PERIndex ], 8 );
cannam@154 134 }
cannam@154 135
cannam@154 136 /**********************/
cannam@154 137 /* Decode LTP scaling */
cannam@154 138 /**********************/
cannam@154 139 if( condCoding == CODE_INDEPENDENTLY ) {
cannam@154 140 psDec->indices.LTP_scaleIndex = (opus_int8)ec_dec_icdf( psRangeDec, silk_LTPscale_iCDF, 8 );
cannam@154 141 } else {
cannam@154 142 psDec->indices.LTP_scaleIndex = 0;
cannam@154 143 }
cannam@154 144 }
cannam@154 145 psDec->ec_prevSignalType = psDec->indices.signalType;
cannam@154 146
cannam@154 147 /***************/
cannam@154 148 /* Decode seed */
cannam@154 149 /***************/
cannam@154 150 psDec->indices.Seed = (opus_int8)ec_dec_icdf( psRangeDec, silk_uniform4_iCDF, 8 );
cannam@154 151 }