/* Decodes signs of excitation */ void SKP_Silk_decode_signs(SKP_Silk_range_coder_state * sRC, /* I/O Range coder state */ int q[], /* I/O pulse signal */ const int length, /* I length of output */ const int sigtype, /* I Signal type */ const int QuantOffsetType, /* I Quantization offset type */ const int RateLevelIndex /* I Rate Level Index */ ) { int i; int data; const uint16_t *cdf; i = SKP_SMULBB(N_RATE_LEVELS - 1, SKP_LSHIFT(sigtype, 1) + QuantOffsetType) + RateLevelIndex; cdf = SKP_Silk_sign_CDF[i]; for (i = 0; i < length; i++) { if (q[i] > 0) { SKP_Silk_range_decoder(&data, sRC, cdf, 1); /* attach sign */ /* implementation with shift, subtraction, multiplication */ q[i] *= SKP_dec_map(data); } } }
/* Decodes signs of excitation */ void silk_decode_signs( ec_dec *psRangeDec, /* I/O Compressor data structure */ SKP_int pulses[], /* I/O pulse signal */ SKP_int length, /* I length of input */ const SKP_int signalType, /* I Signal type */ const SKP_int quantOffsetType, /* I Quantization offset type */ const SKP_int sum_pulses[ MAX_NB_SHELL_BLOCKS ] /* I Sum of absolute pulses per block */ ) { SKP_int i, j, p; SKP_uint8 icdf[ 2 ]; SKP_int *q_ptr; const SKP_uint8 *icdf_ptr; icdf[ 1 ] = 0; q_ptr = pulses; i = SKP_SMULBB( 6, SKP_ADD_LSHIFT( quantOffsetType, signalType, 1 ) ); icdf_ptr = &silk_sign_iCDF[ i ]; length = SKP_RSHIFT( length + SHELL_CODEC_FRAME_LENGTH/2, LOG2_SHELL_CODEC_FRAME_LENGTH ); for( i = 0; i < length; i++ ) { p = sum_pulses[ i ]; if( p > 0 ) { icdf[ 0 ] = icdf_ptr[ SKP_min( p - 1, 5 ) ]; for( j = 0; j < SHELL_CODEC_FRAME_LENGTH; j++ ) { if( q_ptr[ j ] > 0 ) { /* attach sign */ #if 0 /* conditional implementation */ if( ec_dec_icdf( psRangeDec, icdf, 8 ) == 0 ) { q_ptr[ j ] = -q_ptr[ j ]; } #else /* implementation with shift, subtraction, multiplication */ q_ptr[ j ] *= SKP_dec_map( ec_dec_icdf( psRangeDec, icdf, 8 ) ); #endif } } } q_ptr += SHELL_CODEC_FRAME_LENGTH; } }