michael@0: /*********************************************************************** michael@0: Copyright (c) 2006-2011, Skype Limited. All rights reserved. michael@0: Redistribution and use in source and binary forms, with or without michael@0: modification, are permitted provided that the following conditions michael@0: are met: michael@0: - Redistributions of source code must retain the above copyright notice, michael@0: this list of conditions and the following disclaimer. michael@0: - Redistributions in binary form must reproduce the above copyright michael@0: notice, this list of conditions and the following disclaimer in the michael@0: documentation and/or other materials provided with the distribution. michael@0: - Neither the name of Internet Society, IETF or IETF Trust, nor the michael@0: names of specific contributors, may be used to endorse or promote michael@0: products derived from this software without specific prior written michael@0: permission. michael@0: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" michael@0: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE michael@0: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE michael@0: ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE michael@0: LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR michael@0: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF michael@0: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS michael@0: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN michael@0: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) michael@0: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE michael@0: POSSIBILITY OF SUCH DAMAGE. michael@0: ***********************************************************************/ michael@0: michael@0: #ifdef HAVE_CONFIG_H michael@0: #include "config.h" michael@0: #endif michael@0: michael@0: #include "main_FIX.h" michael@0: #include "stack_alloc.h" michael@0: #include "tuning_parameters.h" michael@0: michael@0: /* Low Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode with lower bitrate */ michael@0: static OPUS_INLINE void silk_LBRR_encode_FIX( michael@0: silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ michael@0: silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ michael@0: const opus_int32 xfw_Q3[], /* I Input signal */ michael@0: opus_int condCoding /* I The type of conditional coding used so far for this frame */ michael@0: ); michael@0: michael@0: void silk_encode_do_VAD_FIX( michael@0: silk_encoder_state_FIX *psEnc /* I/O Pointer to Silk FIX encoder state */ michael@0: ) michael@0: { michael@0: /****************************/ michael@0: /* Voice Activity Detection */ michael@0: /****************************/ michael@0: silk_VAD_GetSA_Q8( &psEnc->sCmn, psEnc->sCmn.inputBuf + 1 ); michael@0: michael@0: /**************************************************/ michael@0: /* Convert speech activity into VAD and DTX flags */ michael@0: /**************************************************/ michael@0: if( psEnc->sCmn.speech_activity_Q8 < SILK_FIX_CONST( SPEECH_ACTIVITY_DTX_THRES, 8 ) ) { michael@0: psEnc->sCmn.indices.signalType = TYPE_NO_VOICE_ACTIVITY; michael@0: psEnc->sCmn.noSpeechCounter++; michael@0: if( psEnc->sCmn.noSpeechCounter < NB_SPEECH_FRAMES_BEFORE_DTX ) { michael@0: psEnc->sCmn.inDTX = 0; michael@0: } else if( psEnc->sCmn.noSpeechCounter > MAX_CONSECUTIVE_DTX + NB_SPEECH_FRAMES_BEFORE_DTX ) { michael@0: psEnc->sCmn.noSpeechCounter = NB_SPEECH_FRAMES_BEFORE_DTX; michael@0: psEnc->sCmn.inDTX = 0; michael@0: } michael@0: psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 0; michael@0: } else { michael@0: psEnc->sCmn.noSpeechCounter = 0; michael@0: psEnc->sCmn.inDTX = 0; michael@0: psEnc->sCmn.indices.signalType = TYPE_UNVOICED; michael@0: psEnc->sCmn.VAD_flags[ psEnc->sCmn.nFramesEncoded ] = 1; michael@0: } michael@0: } michael@0: michael@0: /****************/ michael@0: /* Encode frame */ michael@0: /****************/ michael@0: opus_int silk_encode_frame_FIX( michael@0: silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ michael@0: opus_int32 *pnBytesOut, /* O Pointer to number of payload bytes; */ michael@0: ec_enc *psRangeEnc, /* I/O compressor data structure */ michael@0: opus_int condCoding, /* I The type of conditional coding to use */ michael@0: opus_int maxBits, /* I If > 0: maximum number of output bits */ michael@0: opus_int useCBR /* I Flag to force constant-bitrate operation */ michael@0: ) michael@0: { michael@0: silk_encoder_control_FIX sEncCtrl; michael@0: opus_int i, iter, maxIter, found_upper, found_lower, ret = 0; michael@0: opus_int16 *x_frame; michael@0: ec_enc sRangeEnc_copy, sRangeEnc_copy2; michael@0: silk_nsq_state sNSQ_copy, sNSQ_copy2; michael@0: opus_int32 seed_copy, nBits, nBits_lower, nBits_upper, gainMult_lower, gainMult_upper; michael@0: opus_int32 gainsID, gainsID_lower, gainsID_upper; michael@0: opus_int16 gainMult_Q8; michael@0: opus_int16 ec_prevLagIndex_copy; michael@0: opus_int ec_prevSignalType_copy; michael@0: opus_int8 LastGainIndex_copy2; michael@0: SAVE_STACK; michael@0: michael@0: /* This is totally unnecessary but many compilers (including gcc) are too dumb to realise it */ michael@0: LastGainIndex_copy2 = nBits_lower = nBits_upper = gainMult_lower = gainMult_upper = 0; michael@0: michael@0: psEnc->sCmn.indices.Seed = psEnc->sCmn.frameCounter++ & 3; michael@0: michael@0: /**************************************************************/ michael@0: /* Set up Input Pointers, and insert frame in input buffer */ michael@0: /*************************************************************/ michael@0: /* start of frame to encode */ michael@0: x_frame = psEnc->x_buf + psEnc->sCmn.ltp_mem_length; michael@0: michael@0: /***************************************/ michael@0: /* Ensure smooth bandwidth transitions */ michael@0: /***************************************/ michael@0: silk_LP_variable_cutoff( &psEnc->sCmn.sLP, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length ); michael@0: michael@0: /*******************************************/ michael@0: /* Copy new frame to front of input buffer */ michael@0: /*******************************************/ michael@0: silk_memcpy( x_frame + LA_SHAPE_MS * psEnc->sCmn.fs_kHz, psEnc->sCmn.inputBuf + 1, psEnc->sCmn.frame_length * sizeof( opus_int16 ) ); michael@0: michael@0: if( !psEnc->sCmn.prefillFlag ) { michael@0: VARDECL( opus_int32, xfw_Q3 ); michael@0: VARDECL( opus_int16, res_pitch ); michael@0: VARDECL( opus_uint8, ec_buf_copy ); michael@0: opus_int16 *res_pitch_frame; michael@0: michael@0: ALLOC( res_pitch, michael@0: psEnc->sCmn.la_pitch + psEnc->sCmn.frame_length michael@0: + psEnc->sCmn.ltp_mem_length, opus_int16 ); michael@0: /* start of pitch LPC residual frame */ michael@0: res_pitch_frame = res_pitch + psEnc->sCmn.ltp_mem_length; michael@0: michael@0: /*****************************************/ michael@0: /* Find pitch lags, initial LPC analysis */ michael@0: /*****************************************/ michael@0: silk_find_pitch_lags_FIX( psEnc, &sEncCtrl, res_pitch, x_frame, psEnc->sCmn.arch ); michael@0: michael@0: /************************/ michael@0: /* Noise shape analysis */ michael@0: /************************/ michael@0: silk_noise_shape_analysis_FIX( psEnc, &sEncCtrl, res_pitch_frame, x_frame, psEnc->sCmn.arch ); michael@0: michael@0: /***************************************************/ michael@0: /* Find linear prediction coefficients (LPC + LTP) */ michael@0: /***************************************************/ michael@0: silk_find_pred_coefs_FIX( psEnc, &sEncCtrl, res_pitch, x_frame, condCoding ); michael@0: michael@0: /****************************************/ michael@0: /* Process gains */ michael@0: /****************************************/ michael@0: silk_process_gains_FIX( psEnc, &sEncCtrl, condCoding ); michael@0: michael@0: /*****************************************/ michael@0: /* Prefiltering for noise shaper */ michael@0: /*****************************************/ michael@0: ALLOC( xfw_Q3, psEnc->sCmn.frame_length, opus_int32 ); michael@0: silk_prefilter_FIX( psEnc, &sEncCtrl, xfw_Q3, x_frame ); michael@0: michael@0: /****************************************/ michael@0: /* Low Bitrate Redundant Encoding */ michael@0: /****************************************/ michael@0: silk_LBRR_encode_FIX( psEnc, &sEncCtrl, xfw_Q3, condCoding ); michael@0: michael@0: /* Loop over quantizer and entropy coding to control bitrate */ michael@0: maxIter = 6; michael@0: gainMult_Q8 = SILK_FIX_CONST( 1, 8 ); michael@0: found_lower = 0; michael@0: found_upper = 0; michael@0: gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr ); michael@0: gainsID_lower = -1; michael@0: gainsID_upper = -1; michael@0: /* Copy part of the input state */ michael@0: silk_memcpy( &sRangeEnc_copy, psRangeEnc, sizeof( ec_enc ) ); michael@0: silk_memcpy( &sNSQ_copy, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); michael@0: seed_copy = psEnc->sCmn.indices.Seed; michael@0: ec_prevLagIndex_copy = psEnc->sCmn.ec_prevLagIndex; michael@0: ec_prevSignalType_copy = psEnc->sCmn.ec_prevSignalType; michael@0: ALLOC( ec_buf_copy, 1275, opus_uint8 ); michael@0: for( iter = 0; ; iter++ ) { michael@0: if( gainsID == gainsID_lower ) { michael@0: nBits = nBits_lower; michael@0: } else if( gainsID == gainsID_upper ) { michael@0: nBits = nBits_upper; michael@0: } else { michael@0: /* Restore part of the input state */ michael@0: if( iter > 0 ) { michael@0: silk_memcpy( psRangeEnc, &sRangeEnc_copy, sizeof( ec_enc ) ); michael@0: silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy, sizeof( silk_nsq_state ) ); michael@0: psEnc->sCmn.indices.Seed = seed_copy; michael@0: psEnc->sCmn.ec_prevLagIndex = ec_prevLagIndex_copy; michael@0: psEnc->sCmn.ec_prevSignalType = ec_prevSignalType_copy; michael@0: } michael@0: michael@0: /*****************************************/ michael@0: /* Noise shaping quantization */ michael@0: /*****************************************/ michael@0: if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { michael@0: silk_NSQ_del_dec( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw_Q3, psEnc->sCmn.pulses, michael@0: sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, michael@0: sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); michael@0: } else { michael@0: silk_NSQ( &psEnc->sCmn, &psEnc->sCmn.sNSQ, &psEnc->sCmn.indices, xfw_Q3, psEnc->sCmn.pulses, michael@0: sEncCtrl.PredCoef_Q12[ 0 ], sEncCtrl.LTPCoef_Q14, sEncCtrl.AR2_Q13, sEncCtrl.HarmShapeGain_Q14, michael@0: sEncCtrl.Tilt_Q14, sEncCtrl.LF_shp_Q14, sEncCtrl.Gains_Q16, sEncCtrl.pitchL, sEncCtrl.Lambda_Q10, sEncCtrl.LTP_scale_Q14 ); michael@0: } michael@0: michael@0: /****************************************/ michael@0: /* Encode Parameters */ michael@0: /****************************************/ michael@0: silk_encode_indices( &psEnc->sCmn, psRangeEnc, psEnc->sCmn.nFramesEncoded, 0, condCoding ); michael@0: michael@0: /****************************************/ michael@0: /* Encode Excitation Signal */ michael@0: /****************************************/ michael@0: silk_encode_pulses( psRangeEnc, psEnc->sCmn.indices.signalType, psEnc->sCmn.indices.quantOffsetType, michael@0: psEnc->sCmn.pulses, psEnc->sCmn.frame_length ); michael@0: michael@0: nBits = ec_tell( psRangeEnc ); michael@0: michael@0: if( useCBR == 0 && iter == 0 && nBits <= maxBits ) { michael@0: break; michael@0: } michael@0: } michael@0: michael@0: if( iter == maxIter ) { michael@0: if( found_lower && ( gainsID == gainsID_lower || nBits > maxBits ) ) { michael@0: /* Restore output state from earlier iteration that did meet the bitrate budget */ michael@0: silk_memcpy( psRangeEnc, &sRangeEnc_copy2, sizeof( ec_enc ) ); michael@0: silk_assert( sRangeEnc_copy2.offs <= 1275 ); michael@0: silk_memcpy( psRangeEnc->buf, ec_buf_copy, sRangeEnc_copy2.offs ); michael@0: silk_memcpy( &psEnc->sCmn.sNSQ, &sNSQ_copy2, sizeof( silk_nsq_state ) ); michael@0: psEnc->sShape.LastGainIndex = LastGainIndex_copy2; michael@0: } michael@0: break; michael@0: } michael@0: michael@0: if( nBits > maxBits ) { michael@0: if( found_lower == 0 && iter >= 2 ) { michael@0: /* Adjust the quantizer's rate/distortion tradeoff and discard previous "upper" results */ michael@0: sEncCtrl.Lambda_Q10 = silk_ADD_RSHIFT32( sEncCtrl.Lambda_Q10, sEncCtrl.Lambda_Q10, 1 ); michael@0: found_upper = 0; michael@0: gainsID_upper = -1; michael@0: } else { michael@0: found_upper = 1; michael@0: nBits_upper = nBits; michael@0: gainMult_upper = gainMult_Q8; michael@0: gainsID_upper = gainsID; michael@0: } michael@0: } else if( nBits < maxBits - 5 ) { michael@0: found_lower = 1; michael@0: nBits_lower = nBits; michael@0: gainMult_lower = gainMult_Q8; michael@0: if( gainsID != gainsID_lower ) { michael@0: gainsID_lower = gainsID; michael@0: /* Copy part of the output state */ michael@0: silk_memcpy( &sRangeEnc_copy2, psRangeEnc, sizeof( ec_enc ) ); michael@0: silk_assert( psRangeEnc->offs <= 1275 ); michael@0: silk_memcpy( ec_buf_copy, psRangeEnc->buf, psRangeEnc->offs ); michael@0: silk_memcpy( &sNSQ_copy2, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); michael@0: LastGainIndex_copy2 = psEnc->sShape.LastGainIndex; michael@0: } michael@0: } else { michael@0: /* Within 5 bits of budget: close enough */ michael@0: break; michael@0: } michael@0: michael@0: if( ( found_lower & found_upper ) == 0 ) { michael@0: /* Adjust gain according to high-rate rate/distortion curve */ michael@0: opus_int32 gain_factor_Q16; michael@0: gain_factor_Q16 = silk_log2lin( silk_LSHIFT( nBits - maxBits, 7 ) / psEnc->sCmn.frame_length + SILK_FIX_CONST( 16, 7 ) ); michael@0: gain_factor_Q16 = silk_min_32( gain_factor_Q16, SILK_FIX_CONST( 2, 16 ) ); michael@0: if( nBits > maxBits ) { michael@0: gain_factor_Q16 = silk_max_32( gain_factor_Q16, SILK_FIX_CONST( 1.3, 16 ) ); michael@0: } michael@0: gainMult_Q8 = silk_SMULWB( gain_factor_Q16, gainMult_Q8 ); michael@0: } else { michael@0: /* Adjust gain by interpolating */ michael@0: gainMult_Q8 = gainMult_lower + silk_DIV32_16( silk_MUL( gainMult_upper - gainMult_lower, maxBits - nBits_lower ), nBits_upper - nBits_lower ); michael@0: /* New gain multplier must be between 25% and 75% of old range (note that gainMult_upper < gainMult_lower) */ michael@0: if( gainMult_Q8 > silk_ADD_RSHIFT32( gainMult_lower, gainMult_upper - gainMult_lower, 2 ) ) { michael@0: gainMult_Q8 = silk_ADD_RSHIFT32( gainMult_lower, gainMult_upper - gainMult_lower, 2 ); michael@0: } else michael@0: if( gainMult_Q8 < silk_SUB_RSHIFT32( gainMult_upper, gainMult_upper - gainMult_lower, 2 ) ) { michael@0: gainMult_Q8 = silk_SUB_RSHIFT32( gainMult_upper, gainMult_upper - gainMult_lower, 2 ); michael@0: } michael@0: } michael@0: michael@0: for( i = 0; i < psEnc->sCmn.nb_subfr; i++ ) { michael@0: sEncCtrl.Gains_Q16[ i ] = silk_LSHIFT_SAT32( silk_SMULWB( sEncCtrl.GainsUnq_Q16[ i ], gainMult_Q8 ), 8 ); michael@0: } michael@0: michael@0: /* Quantize gains */ michael@0: psEnc->sShape.LastGainIndex = sEncCtrl.lastGainIndexPrev; michael@0: silk_gains_quant( psEnc->sCmn.indices.GainsIndices, sEncCtrl.Gains_Q16, michael@0: &psEnc->sShape.LastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); michael@0: michael@0: /* Unique identifier of gains vector */ michael@0: gainsID = silk_gains_ID( psEnc->sCmn.indices.GainsIndices, psEnc->sCmn.nb_subfr ); michael@0: } michael@0: } michael@0: michael@0: /* Update input buffer */ michael@0: silk_memmove( psEnc->x_buf, &psEnc->x_buf[ psEnc->sCmn.frame_length ], michael@0: ( psEnc->sCmn.ltp_mem_length + LA_SHAPE_MS * psEnc->sCmn.fs_kHz ) * sizeof( opus_int16 ) ); michael@0: michael@0: /* Exit without entropy coding */ michael@0: if( psEnc->sCmn.prefillFlag ) { michael@0: /* No payload */ michael@0: *pnBytesOut = 0; michael@0: RESTORE_STACK; michael@0: return ret; michael@0: } michael@0: michael@0: /* Parameters needed for next frame */ michael@0: psEnc->sCmn.prevLag = sEncCtrl.pitchL[ psEnc->sCmn.nb_subfr - 1 ]; michael@0: psEnc->sCmn.prevSignalType = psEnc->sCmn.indices.signalType; michael@0: michael@0: /****************************************/ michael@0: /* Finalize payload */ michael@0: /****************************************/ michael@0: psEnc->sCmn.first_frame_after_reset = 0; michael@0: /* Payload size */ michael@0: *pnBytesOut = silk_RSHIFT( ec_tell( psRangeEnc ) + 7, 3 ); michael@0: michael@0: RESTORE_STACK; michael@0: return ret; michael@0: } michael@0: michael@0: /* Low-Bitrate Redundancy (LBRR) encoding. Reuse all parameters but encode excitation at lower bitrate */ michael@0: static OPUS_INLINE void silk_LBRR_encode_FIX( michael@0: silk_encoder_state_FIX *psEnc, /* I/O Pointer to Silk FIX encoder state */ michael@0: silk_encoder_control_FIX *psEncCtrl, /* I/O Pointer to Silk FIX encoder control struct */ michael@0: const opus_int32 xfw_Q3[], /* I Input signal */ michael@0: opus_int condCoding /* I The type of conditional coding used so far for this frame */ michael@0: ) michael@0: { michael@0: opus_int32 TempGains_Q16[ MAX_NB_SUBFR ]; michael@0: SideInfoIndices *psIndices_LBRR = &psEnc->sCmn.indices_LBRR[ psEnc->sCmn.nFramesEncoded ]; michael@0: silk_nsq_state sNSQ_LBRR; michael@0: michael@0: /*******************************************/ michael@0: /* Control use of inband LBRR */ michael@0: /*******************************************/ michael@0: if( psEnc->sCmn.LBRR_enabled && psEnc->sCmn.speech_activity_Q8 > SILK_FIX_CONST( LBRR_SPEECH_ACTIVITY_THRES, 8 ) ) { michael@0: psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded ] = 1; michael@0: michael@0: /* Copy noise shaping quantizer state and quantization indices from regular encoding */ michael@0: silk_memcpy( &sNSQ_LBRR, &psEnc->sCmn.sNSQ, sizeof( silk_nsq_state ) ); michael@0: silk_memcpy( psIndices_LBRR, &psEnc->sCmn.indices, sizeof( SideInfoIndices ) ); michael@0: michael@0: /* Save original gains */ michael@0: silk_memcpy( TempGains_Q16, psEncCtrl->Gains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) ); michael@0: michael@0: if( psEnc->sCmn.nFramesEncoded == 0 || psEnc->sCmn.LBRR_flags[ psEnc->sCmn.nFramesEncoded - 1 ] == 0 ) { michael@0: /* First frame in packet or previous frame not LBRR coded */ michael@0: psEnc->sCmn.LBRRprevLastGainIndex = psEnc->sShape.LastGainIndex; michael@0: michael@0: /* Increase Gains to get target LBRR rate */ michael@0: psIndices_LBRR->GainsIndices[ 0 ] = psIndices_LBRR->GainsIndices[ 0 ] + psEnc->sCmn.LBRR_GainIncreases; michael@0: psIndices_LBRR->GainsIndices[ 0 ] = silk_min_int( psIndices_LBRR->GainsIndices[ 0 ], N_LEVELS_QGAIN - 1 ); michael@0: } michael@0: michael@0: /* Decode to get gains in sync with decoder */ michael@0: /* Overwrite unquantized gains with quantized gains */ michael@0: silk_gains_dequant( psEncCtrl->Gains_Q16, psIndices_LBRR->GainsIndices, michael@0: &psEnc->sCmn.LBRRprevLastGainIndex, condCoding == CODE_CONDITIONALLY, psEnc->sCmn.nb_subfr ); michael@0: michael@0: /*****************************************/ michael@0: /* Noise shaping quantization */ michael@0: /*****************************************/ michael@0: if( psEnc->sCmn.nStatesDelayedDecision > 1 || psEnc->sCmn.warping_Q16 > 0 ) { michael@0: silk_NSQ_del_dec( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, michael@0: psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, michael@0: psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, michael@0: psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 ); michael@0: } else { michael@0: silk_NSQ( &psEnc->sCmn, &sNSQ_LBRR, psIndices_LBRR, xfw_Q3, michael@0: psEnc->sCmn.pulses_LBRR[ psEnc->sCmn.nFramesEncoded ], psEncCtrl->PredCoef_Q12[ 0 ], psEncCtrl->LTPCoef_Q14, michael@0: psEncCtrl->AR2_Q13, psEncCtrl->HarmShapeGain_Q14, psEncCtrl->Tilt_Q14, psEncCtrl->LF_shp_Q14, michael@0: psEncCtrl->Gains_Q16, psEncCtrl->pitchL, psEncCtrl->Lambda_Q10, psEncCtrl->LTP_scale_Q14 ); michael@0: } michael@0: michael@0: /* Restore original gains */ michael@0: silk_memcpy( psEncCtrl->Gains_Q16, TempGains_Q16, psEnc->sCmn.nb_subfr * sizeof( opus_int32 ) ); michael@0: } michael@0: }