From 0d065b7f235ad53e1cbd7d3903fd2296e0329284 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Sun, 28 Jan 2024 12:45:59 +0530 Subject: [PATCH] lpd functions converted to fixed [x] Contains float to fix and vice versa conversions for subfunctions of mode_switch_decoder_LPD [x] Contains float_to_fx and vice versa conversions for subfunctions of open_decoder_LPD [x] Contains cosmetic changes(comparsion, basop , type etc.) for dec_prm_tcx and stereo_tcx_dec_mode_switch_reconf [x] Added fixed table for igf_whitening_TH_flt --- lib_com/bits_alloc_fx.c | 4 +- lib_com/bitstream_fx.c | 8 +- lib_com/cldfb.c | 35 +- lib_com/float_to_fix_ops.c | 26 +- lib_com/igf_base_fx.c | 261 +++++++++++ lib_com/prot_fx2.h | 81 +++- lib_com/rom_com.c | 184 ++++++++ lib_com/rom_com.h | 3 + lib_com/stat_com.h | 1 + lib_dec/core_dec_init.c | 297 ++++++------ lib_dec/core_dec_init_fx.c | 795 +++++++++++++++++++++++++++++++ lib_dec/core_dec_reconf_fx.c | 171 +++++++ lib_dec/core_dec_switch_fx.c | 237 ++++++++++ lib_dec/dec_prm_fx.c | 10 +- lib_dec/igf_dec_fx.c | 124 ++++- lib_dec/ivas_tcx_core_dec.c | 801 ++++++++++++++++++++++++++++++++ lib_dec/stat_dec.h | 10 +- lib_dec/swb_tbe_dec_fx.c | 57 +++ lib_dec/waveadjust_fec_dec_fx.c | 62 +++ 19 files changed, 2976 insertions(+), 191 deletions(-) diff --git a/lib_com/bits_alloc_fx.c b/lib_com/bits_alloc_fx.c index d5c292aba..703b67144 100644 --- a/lib_com/bits_alloc_fx.c +++ b/lib_com/bits_alloc_fx.c @@ -55,7 +55,7 @@ void BITS_ALLOC_init_config_acelp( move16(); move16(); move16(); - rate_mode_index=(bit_rate > ACELP_9k60); + rate_mode_index = (Word8)GT_32( bit_rate, ACELP_9k60 ); pConfigAcelp->mode_index=rate_mode_index; @@ -66,7 +66,7 @@ void BITS_ALLOC_init_config_acelp( /*ACELP ICB config*/ test(); - IF( (rate_mode_index==0) || narrowBand != 0 ) + IF( EQ_16( rate_mode_index, 0 ) || NE_16( narrowBand, 0 ) ) { move16(); move16(); diff --git a/lib_com/bitstream_fx.c b/lib_com/bitstream_fx.c index d1f766ff2..8801e4ebd 100644 --- a/lib_com/bitstream_fx.c +++ b/lib_com/bitstream_fx.c @@ -389,13 +389,13 @@ UWord16 get_next_indice_fx( /* o : value of the indice */ { UWord16 value; Word16 i; - Word32 nbits_total; + Word16 nbits_total; assert(nb_bits <= 16); value = 0; move16(); - nbits_total = st_fx->total_brate / FRAMES_PER_SEC; + nbits_total = (Word16)(st_fx->total_brate / FRAMES_PER_SEC); /* detect corrupted bitstream */ IF(GT_16(add(st_fx->next_bit_pos, nb_bits), nbits_total)) { @@ -425,8 +425,8 @@ UWord16 get_next_indice_1_fx( /* o : value of the indice */ Decoder_State *st_fx /* i/o: decoder state structure */ ) { - Word32 nbits_total; - nbits_total = st_fx->total_brate / FRAMES_PER_SEC; + Word16 nbits_total; + nbits_total = (Word16)(st_fx->total_brate / FRAMES_PER_SEC); /* detect corrupted bitstream */ test(); test(); diff --git a/lib_com/cldfb.c b/lib_com/cldfb.c index fd09c1c46..083967c5b 100644 --- a/lib_com/cldfb.c +++ b/lib_com/cldfb.c @@ -1412,7 +1412,8 @@ ivas_error openCldfb_ivas( { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate memory for CLDFB" ); } - set32_fx( hs->cldfb_state_fx, 0, buf_len ); + hs->cldfb_state_length = buf_len;//Temporarily added to store the length of buffer + set32_fx(hs->cldfb_state_fx, 0, buf_len); #endif // IVAS_FLOAT_FIXED @@ -2080,22 +2081,24 @@ void cldfb_reset_memory_ivas( } #ifdef IVAS_FLOAT_FIXED void cldfb_reset_memory_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */, - Word16 *memory_length ) + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */ +) { - UWord16 offset = sub( hs->p_filter_length, hs->no_channels ); - - IF( hs->type == CLDFB_ANALYSIS ) - { - *memory_length = offset; - } - ELSE - { - *memory_length = hs->p_filter_length; - } - - /* save the memory */ - set32_fx( hs->cldfb_state_fx, 0, *memory_length ); + Word16 memory_length; + UWord16 offset = sub(hs->p_filter_length, hs->no_channels); + + IF (hs->type == CLDFB_ANALYSIS) + { + memory_length = offset; + } + ELSE + { + memory_length = hs->p_filter_length; + } + + hs->cldfb_state_length = memory_length; + /* save the memory */ + set32_fx(hs->cldfb_state_fx, 0, memory_length); return; } diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index c2a5ee0b1..c6864bc05 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -5,18 +5,22 @@ #include "prot.h" Word32 floatToFixed(const float f, Word16 Q) { + if (f == 1.0f && Q == Q15) + return MAX16B; + if (f == 1.0f && Q == Q31) + return MAXVAL_WORD32; if (Q < 0) - return (Word32)((float)(f) / (float)(1 << (-Q)) + (f >= 0 ? 0.5 : -0.5)); + return (Word32)((float)(f) / (float)(((unsigned)1) << (-Q)) + (f >= 0 ? 0.5 : -0.5)); else - return (Word32)(f * (float)(1 << Q) + (f >= 0 ? 0.5 : -0.5)); + return (Word32)(f * (float)(((unsigned)1) << Q) + (f >= 0 ? 0.5 : -0.5)); } float fixedToFloat(const Word32 i, Word16 Q) { if (Q < 0) - return (i * (float)(1 << (-Q))); + return (i * (float)(((unsigned)1) << (-Q))); else - return (float)(i) / (float)(1 << Q); + return (float)(i) / (float)(((unsigned)1) << Q); } void floatToFixed_arrL(const float *f, Word32 *i, Word16 Q, Word16 l) { @@ -46,13 +50,19 @@ void fixedToFloat_arr(const Word16 *i, float *f, Word16 Q, Word16 l) f[j] = fixedToFloat(i[j], Q); } } -Word16 Q_factor(Word16 x) +Word16 Q_factor(float x) { - return norm_s(x); + Word16 Q = 15; + if ( x >= 1 || x <= -1 ) + Q = norm_s((Word16)x); + return Q; } -Word16 Q_factor_L(Word32 x) +Word16 Q_factor_L(float x) { - return norm_l(x); + Word16 Q = 31; + if ( x >= 1 || x <= -1 ) + Q = norm_l((Word32)x); + return Q; } Word16 Q_factor_arr(float *x, Word16 l) { diff --git a/lib_com/igf_base_fx.c b/lib_com/igf_base_fx.c index 35564ffff..cfefe1121 100644 --- a/lib_com/igf_base_fx.c +++ b/lib_com/igf_base_fx.c @@ -848,6 +848,186 @@ static void IGF_gridSetUp(H_IGF_GRID hGrid, } } +#ifdef IVAS_FLOAT_FIXED +static void IGF_gridSetUp_ivas_fx( + H_IGF_GRID hGrid, /* o : IGF grid handle */ + Word16 bitRateIndex, /* i : IGF bitrate index */ + const Word32 sampleRate, /* i : sample rate */ + Word16 frameLength, /* i : frame length */ + const Word16 transFac, /* i : transFac */ + const Word16 igfMinFq /* i : IGF minimum frequency indicating lower start frequency for copy up */ +) +{ + Word16 t, k; + Word16 sfb; + Word16 swb_offset_len; + const Word16 *swb_offset; + Word16 bandwidth_fx; + const Word16 *igf_tile_offset; + Word16 tmp2, tmp1; + Word32 L_tmp1, L_tmp2; + + /* inits */ + swb_offset = NULL; + swb_offset_len = 0; + IF( EQ_16( transFac, 8192 ) && EQ_16( bitRateIndex, IGF_BITRATE_SWB_48000_CPE ) ) + { + bitRateIndex = IGF_BITRATE_SWB_48000_CPE_TCX10; + } + ELSE IF( EQ_16( transFac, 8192 ) && EQ_16( bitRateIndex, IGF_BITRATE_FB_48000_CPE ) ) + { + bitRateIndex = IGF_BITRATE_FB_48000_CPE_TCX10; + } + + IF( NE_16( bitRateIndex, IGF_BITRATE_UNKNOWN ) ) + { + swb_offset = &swb_offset_LB_new[bitRateIndex][1]; + swb_offset_len = swb_offset_LB_new[bitRateIndex][0]; + Copy( &igf_whitening_TH_ivas_fx[bitRateIndex][0][0], &hGrid->whiteningThreshold[0][0], IGF_MAX_TILES * 2 ); + } + ELSE + { + assert( 0 ); + } + + FOR( sfb = 0; sfb < swb_offset_len; sfb++ ) + { + hGrid->swb_offset[sfb] = IGF_ApplyTransFac( swb_offset[sfb], transFac ); + } + FOR( sfb = swb_offset_len; sfb < IGF_MAX_SFB; sfb++ ) + { + hGrid->swb_offset[sfb] = 0; + } + + hGrid->infoIsRefined = 0; + frameLength = IGF_ApplyTransFac( frameLength, transFac ); + tmp2 = norm_s( frameLength ); + bandwidth_fx = shl( frameLength, tmp2 ); + hGrid->swb_offset_len = extract_l( L_shr( sampleRate, 2 ) ); + tmp1 = sub( norm_s( hGrid->swb_offset_len ), 1 ); + hGrid->swb_offset_len = shl( hGrid->swb_offset_len, tmp1 ); + bandwidth_fx = div_s( hGrid->swb_offset_len, bandwidth_fx ); + tmp2 = sub( add( tmp2, 1 ), tmp1 ); + bandwidth_fx = shr( bandwidth_fx, sub( 15, tmp2 ) ); + hGrid->swb_offset_len = swb_offset_len; + hGrid->startSfb = 0; + hGrid->stopSfb = sub( hGrid->swb_offset_len, 1 ); + hGrid->startLine = hGrid->swb_offset[hGrid->startSfb]; + hGrid->stopLine = hGrid->swb_offset[hGrid->stopSfb]; + hGrid->startFrequency = imult1616( bandwidth_fx, hGrid->startLine ); + hGrid->stopFrequency = imult1616( bandwidth_fx, hGrid->stopLine ); + L_tmp1 = L_mult0( igfMinFq, frameLength ); + tmp1 = sub( norm_l( L_tmp1 ), 1 ); + L_tmp1 = L_shl( L_tmp1, tmp1 ); + tmp2 = norm_l( sampleRate ); + L_tmp2 = L_shl( sampleRate, tmp2 ); + tmp1 = add( WORD16_BITS - 1, sub( tmp1, add( tmp2, 1 ) ) ); /* takes into account sampleRate >> 1 */ + hGrid->minSrcSubband = div_s( extract_h( L_tmp1 ), extract_h( L_tmp2 ) ); + hGrid->minSrcSubband = shr( hGrid->minSrcSubband, tmp1 ); + hGrid->minSrcSubband = add( hGrid->minSrcSubband, s_and( hGrid->minSrcSubband, 1 ) ); + hGrid->minSrcFrequency = imult1616( bandwidth_fx, hGrid->minSrcSubband ); + hGrid->infoGranuleLen = frameLength; + hGrid->sfbWrap[0] = 0; + hGrid->tile[0] = hGrid->startLine; + + igf_tile_offset = &igf_tile_offset_table[bitRateIndex][1]; + hGrid->nTiles = igf_tile_offset_table[bitRateIndex][0]; + hGrid->tile[0] = hGrid->startLine; + hGrid->sfbWrap[0] = 0; + FOR( k = 0; k < hGrid->nTiles; k++ ) + { + hGrid->sfbWrap[k + 1] = igf_tile_offset[2 * k]; + hGrid->sbWrap[k] = add( hGrid->minSrcSubband, IGF_ApplyTransFac( igf_tile_offset[2 * k + 1], transFac ) ); + hGrid->tile[k + 1] = hGrid->swb_offset[igf_tile_offset[2 * k]]; + } + FOR( t = hGrid->nTiles + 1; t < IGF_MAX_TILES; t++ ) + { + hGrid->tile[t] = 0; + hGrid->sbWrap[t - 1] = 0; + hGrid->sfbWrap[t] = 0; + } + + /* adapt level envelope: */ + SWITCH( bitRateIndex ) + { + case IGF_BITRATE_RF_WB_13200: + case IGF_BITRATE_WB_9600: + case IGF_BITRATE_WB_13200_CPE: + case IGF_BITRATE_WB_16400_CPE: + hGrid->gFactor = 13107 /*0.80f Q14*/; + move16(); + hGrid->fFactor = 11469 /*0.70f Q14*/; + move16(); + hGrid->lFactor = 9830 /*0.60f Q14*/; + move16(); + BREAK; + case IGF_BITRATE_SWB_13200: + case IGF_BITRATE_SWB_16400_CPE: + case IGF_BITRATE_FB_16400: + case IGF_BITRATE_SWB_16400: + case IGF_BITRATE_FB_24400_CPE: + case IGF_BITRATE_SWB_24400_CPE: + hGrid->gFactor = 15237 /*0.93f Q14*/; + move16(); + hGrid->fFactor = 3277 /*0.20f Q14*/; + move16(); + hGrid->lFactor = 13926 /*0.85f Q14*/; + move16(); + BREAK; + case IGF_BITRATE_FB_24400: + case IGF_BITRATE_SWB_24400: + case IGF_BITRATE_FB_32000_CPE: + case IGF_BITRATE_SWB_32000_CPE: + case IGF_BITRATE_FB_32000: + case IGF_BITRATE_SWB_32000: + case IGF_BITRATE_SWB_48000_CPE: + case IGF_BITRATE_SWB_64000_CPE: + hGrid->gFactor = 15811 /*0.965f Q14*/; + move16(); + hGrid->fFactor = 3277 /*0.20f Q14*/; + move16(); + hGrid->lFactor = 13926 /*0.85f Q14*/; + move16(); + BREAK; + case IGF_BITRATE_FB_48000: + case IGF_BITRATE_SWB_48000: + case IGF_BITRATE_FB_64000: + case IGF_BITRATE_SWB_64000: + case IGF_BITRATE_SWB_80000_CPE: + case IGF_BITRATE_SWB_96000_CPE: + hGrid->gFactor = 16384 /*1.00f Q14*/; + move16(); + hGrid->fFactor = 3277 /*0.20f Q14*/; + move16(); + hGrid->lFactor = 16384 /*1.00f Q14*/; + move16(); + BREAK; + case IGF_BITRATE_SWB_9600: + case IGF_BITRATE_SWB_13200_CPE: + case IGF_BITRATE_RF_SWB_13200: + default: + hGrid->gFactor = 16384 /*1.00f Q14*/; + move16(); + hGrid->fFactor = 0; /*0.00f Q30*/ + ; + move16(); + hGrid->lFactor = 16384 /*1.00f Q14*/; + move16(); + } + + FOR ( t = add(hGrid->nTiles , 1); t < IGF_MAX_TILES; t++ ) + { + hGrid->tile[t] = 0; + move16(); + hGrid->sbWrap[t - 1] = 0; + move16(); + hGrid->sfbWrap[t] = 0; + move16(); + } + return; +} + +#endif // IVAS_FLOAT_FIXED /**********************************************************************/ /* calculates energy per sfb via power spectrum @@ -1045,6 +1225,87 @@ Word16 IGFCommonFuncsIGFConfiguration( return retValue; } +#ifdef IVAS_FLOAT_FIXED +Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +) +{ + H_IGF_GRID hGrid; + Word16 retValue; + Word32 sampleRate; + Word16 frameLength; + Word16 igfMinFq; + Word16 maxHopsize; + + retValue = 0; /* bitrate index is unknown -> error! */ + move16(); + + /* interface call for reading in settings */ + hIGFInfo->bitRateIndex = IGF_MapBitRateToIndex( total_brate, bwidth, element_mode, rf_mode ); + + IF( NE_16( hIGFInfo->bitRateIndex, IGF_BITRATE_UNKNOWN ) ) + { + retValue = 1; /* no error */ + move16(); + + /* mapping to local values */ + sampleRate = igfMode[hIGFInfo->bitRateIndex].sampleRate; + move32(); + frameLength = igfMode[hIGFInfo->bitRateIndex].frameLength; + move16(); + igfMinFq = igfMode[hIGFInfo->bitRateIndex].igfMinFq; + move16(); + maxHopsize = igfMode[hIGFInfo->bitRateIndex].maxHopsize; + move16(); + + /* basic information */ + hIGFInfo->sampleRate = sampleRate; + move32(); + hIGFInfo->frameLength = frameLength; + move16(); + hIGFInfo->maxHopsize = maxHopsize; + move16(); +#if 0 + //100820 temp fix +#endif + hIGFInfo->nfSeedBuf[0] = 0; + hIGFInfo->nfSeedBuf[1] = 0; + hIGFInfo->nfSeed = &hIGFInfo->nfSeedBuf[0]; + move16(); + + /* set up regular IGF grid for TCX 20 (transfac = 1.f) */ + hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; + IGF_gridSetUp_ivas_fx( hGrid, + hIGFInfo->bitRateIndex, + sampleRate, + frameLength, + 16384 /*1 Q14*/, + igfMinFq ); + /* set up IGF grid for CELP->TCX 20 transitions (transfac = 1.25) */ + hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; + IGF_gridSetUp_ivas_fx( hGrid, + hIGFInfo->bitRateIndex, + sampleRate, + frameLength, + 20480 /*1.25 Q14*/, + igfMinFq ); + /* set up IGF grid for TCX 10 (transfac = 0.5) */ + hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; + IGF_gridSetUp_ivas_fx( hGrid, + hIGFInfo->bitRateIndex, + sampleRate, + frameLength, + 8192 /*0.50f Q14*/, + igfMinFq ); + } + + return retValue; +} +#endif // IVAS_FLOAT_FIXED /**********************************************************************/ /* selects cumulative frequency tables and offsets for the IGF SCF arithmetic coder diff --git a/lib_com/prot_fx2.h b/lib_com/prot_fx2.h index e2de993c3..5e0859f7b 100644 --- a/lib_com/prot_fx2.h +++ b/lib_com/prot_fx2.h @@ -75,8 +75,8 @@ void floatToFixed_arrL(const float * f, Word32* i, Word16 Q, Word16 l); void floatToFixed_arr(const float * f, Word16* i, Word16 Q, Word16 l); void fixedToFloat_arrL(const Word32 *i, float * f, Word16 Q, Word16 l); void fixedToFloat_arr(const Word16 *i, float * f, Word16 Q, Word16 l); -Word16 Q_factor(Word16 x); -Word16 Q_factor_L(Word32 x); +Word16 Q_factor(float x); +Word16 Q_factor_L(float x); Word16 Q_factor_arr(float* x, Word16 l); Word16 Q_factor_arrL(float* x, Word16 l); //Handles the cases where Q is negative @@ -4909,6 +4909,15 @@ Word16 IGFCommonFuncsIGFConfiguration( H_IGF_INFO hIGFInfo, /* o : IGF info handle */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); +#ifdef IVAS_FLOAT_FIXED +Word16 IGFCommonFuncsIGFConfiguration_ivas_fx( + const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : element mode */ + H_IGF_INFO hIGFInfo, /* o : IGF info handle */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); +#endif // IVAS_FOAT_FIXED Word16 IGFCommonFuncsIGFGetCFTables( const Word32 total_brate, /* i : bitrate in bs e.g. 9600 for 9.6kbs */ const Word16 bwidth, /* i : audio bandwidth */ @@ -5045,6 +5054,11 @@ void GenTransition_WB_fx( Word32 output_Fs, Word16 *up_mem ); +#ifdef IVAS_FLOAT_FIXED +void TBEreset_dec_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +); +#endif // IVAS_FLOAT_FIXED void TBEreset_dec_fx( Decoder_State *st_fx, /* i/o: decoder state structure */ @@ -5160,6 +5174,9 @@ void td_cng_dec_init( //wavadjust_fec_dec_fx.c void set_state(Word16 *state, Word16 num, Word16 N); void concealment_init_x(Word16 N, void *_plcInfo); +void concealment_init_ivas_fx( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ); void concealment_update_x(Word16 bfi, Word16 curr_mode, Word16 harmonic, Word32 *invkoef, Word16 *invkoef_scale, void *_plcInfo); Word16 Sqrt_x_fast(Word32 value); @@ -6969,6 +6986,24 @@ void init_tcx_cfg_fx( const Word16 is_init /* i : indicate call from init_decoder() to avoid double TC initialization */ #endif ); +#ifdef IVAS_FLOAT_FIXED + void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const Word16 last_element_mode, /* i : last element mode */ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization */ + Word16* Q_syn_Overl_TDAC, + Word16* Q_fer_samples, + Word16* Q_syn_Overl, + Word16* Q_syn_Overl_TDACFB, + Word16* Q_syn_OverlFB, + Word16* Q_old_out, + Word16* Q_old_outLB, + Word16* Q_old_Aq_12_8); +#endif // IVAS_FLOAT_FIXED void reset_tcx_overl_buf_fx( TCX_DEC_HANDLE hTcxDec /* i/o: TCX decoder handle */ @@ -6977,8 +7012,7 @@ void init_tcx_cfg_fx( Decoder_State *st /* i/o: Decoder state */ ); void cldfb_reset_memory_fx( - HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */, - Word16 *memory_length ); + HANDLE_CLDFB_FILTER_BANK hs /* i/o: filter bank handle */); void tcxltp_dec_init_fx( TCX_LTP_DEC_HANDLE hTcxLtpDec, const Word16 ini_frame, @@ -7249,6 +7283,25 @@ void init_tcx_cfg_fx( void mode_switch_decoder_LPD(Decoder_State *st, Word16 bandwidth_in, Word32 bitrate, Word16 frame_size_index ); +#ifdef IVAS_FLOAT_FIXED + void mode_switch_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 last_total_brate, /* i : last frame total bitrate */ + const Word16 frame_size_index, /* i : index determining the frame size */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 last_element_mode, /* i : last element mode */ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 + ); +#endif // IVAS_FLOAT_FIXED //ari_hm_dec.c @@ -7545,6 +7598,17 @@ void IGFDecSetMode( const Word16 defaultStopLine, /* i : default stop subband index */ const Word16 rf_mode /* i : flag to signal the RF mode */ ); +#ifdef IVAS_FLOAT_FIXED +void IGFDecSetMode_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +); +#endif // IVAS_FLOAT_FIXED void IGFDecUpdateInfo(const IGF_DEC_INSTANCE_HANDLE hInstance, /**< in: | instance handle of IGF Decoder */ const Word16 igfGridIdx /**< in: | IGF grid index */ @@ -7684,6 +7748,15 @@ Word16 RCcontextMapping_decode2_no_mem_s17_LCS_fx( //core_dec_reconf_fx.c void reconfig_decoder_LPD(Decoder_State *st, Word16 bits_frame, Word16 bandwidth_mode, Word32 bitrate, Word16 L_frame_old); +#ifdef IVAS_FLOAT_FIXED +void reconfig_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bits_frame, /* i : bit budget */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 L_frame_old /* i : frame length */ +); +#endif // IVAS_FLOAT_FIXED //er_utils_fx.c void minimumStatistics(Word16* noiseLevelMemory, /* Q15, internal state */ diff --git a/lib_com/rom_com.c b/lib_com/rom_com.c index 68d4815ea..1fd50722d 100644 --- a/lib_com/rom_com.c +++ b/lib_com/rom_com.c @@ -35748,6 +35748,190 @@ const float igf_whitening_TH_flt[IGF_BITRATE_UNKNOWN][2][IGF_MAX_TILES] = /* strong */ {2.82f, 0.f, 0.f, 0.f} } }; +const Word16 igf_whitening_TH_ivas_fx[][2][IGF_MAX_TILES] = +{ + /* 0: for 9600 kbs WB */ + { + /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 1: for 13200 kbs WB RF */ + { + /* medium */ { 2949/*0.36f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 11551/*1.41f Q13*/, 11551/*1.41f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 2: for 9600 kbs SWB */ + { + /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 3: for 13200 kbs SWB */ + { + /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 4: for 13200 kbs SWB RF */ + { + /* medium */ { 6881/*0.84f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10650/*1.30f Q13*/, 10240/*1.25f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 5: for 16400 kbs SWB */ + { + /* medium */ { 6799/*0.83f Q13*/, 7291/*0.89f Q13*/, 7291/*0.89f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10732/*1.31f Q13*/, 9748/*1.19f Q13*/, 9748/*1.19f Q13*/, 0/*0.f Q13*/} + }, + /* 6: for 24400 kbs SWB*/ + { + /* medium */ { 6636/*0.81f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 11059/*1.35f Q13*/, 10076/*1.23f Q13*/, 10076/*1.23f Q13*/, 0/*0.f Q13*/} + }, + /* 7: for 32000 kbs SWB */ + { + /* medium */ { 7455/*0.91f Q13*/, 6963/*0.85f Q13*/, 6963/*0.85f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 10977/*1.34f Q13*/, 11059/*1.35f Q13*/, 11059/*1.35f Q13*/, 0/*0.f Q13*/} + }, + /* 8: for 48000 kbs SWB */ + { + /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 9: for 64000 kbs SWB */ + { + /* medium */ { 9421/*1.15f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 9748/*1.19f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 10: for 16400 kbs FB */ + { + /* medium */ { 5161/*0.63f Q13*/, 2212/*0.27f Q13*/, 2949/*0.36f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 12534/*1.53f Q13*/, 10813/*1.32f Q13*/, 5489/*0.67f Q13*/, 0/*0.f Q13*/} + }, + /* 11: for 24400 kbs FB */ + { + /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/}, + /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/} + }, + /* 12: for 32000 kbs FB */ + { + /* medium */ { 6390/*0.78f Q13*/, 2540/*0.31f Q13*/, 2785/*0.34f Q13*/, 2785/*0.34f Q13*/}, + /* strong */ { 12206/*1.49f Q13*/, 11305/*1.38f Q13*/, 5325/*0.65f Q13*/, 5325/*0.65f Q13*/} + }, + /* 13: for 48000 kbs FB */ + { + /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 14: for 64000 kbs FB */ + { + /* medium */ { 6554/*0.80f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 8192/*1.00f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 15: for 96000 kbs FB */ + { + /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 16: for 128000 kbs FB */ + { + /* medium */ { 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/}, + /* strong */ { 23101/*2.82f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/, 0/*0.f Q13*/} + }, + /* 17: for 13200 kbs WB (stereo) */ + { + /* medium */ {6554/*0.800000 Q13*/, 6144/*0.750000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {12288/*1.500000 Q13*/, 11878/*1.450000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 18: for 16400 kbs WB (stereo) */ + { + + /* medium */ {7373/*0.900000 Q13*/, 6963/*0.850000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {13107/*1.600000 Q13*/, 12288/*1.500000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 19: for 13200 kbs SWB (stereo) */ + { + /* medium */ {7291/*0.890000 Q13*/, 7291/*0.890000 Q13*/, 6554/*0.800000 Q13*/, 6554/*0.800000 Q13*/, }, + /* strong */ {10240/*1.250000 Q13*/, 10240/*1.250000 Q13*/, 9748/*1.190000 Q13*/, 9748/*1.190000 Q13*/, } + }, + /* 20: for 16400 kbs SWB (stereo) */ + { + /* medium */ {8602/*1.050000 Q13*/, 8602/*1.050000 Q13*/, 9011/*1.100000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8602/*1.050000 Q13*/, }, + /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13517/*1.650000 Q13*/, 13517/*1.650000 Q13*/, 13107/*1.600000 Q13*/, 12288/*1.500000 Q13*/, } + }, + /* 21: for 24400 kbs SWB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, }, + /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, } + }, + /* 22: for 32000 kbs SWB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, }, + /* strong */ {14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 13517/*1.650000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, } + }, + /* 23: for 48000 kbs SWB (stereo) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 24: for 48000 kbs SWB (stereo TCX10) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 25: for 64000 kbs SWB (stereo) */ + { + /* medium */ {8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/, 9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/ }, + /* strong */ {12288/*1.500000 Q13*/, 12288/*1.500000 Q13*/, 13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/ } + }, + /* 26: for 80000 kbs SWB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 27: for 96000 kbs SWB (stereo) */ + { + /* medium */ {9421/*1.150000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {9748/*1.190000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 28: for 24400 kbs FB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, + /* strong */ {13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 13926/*1.700000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } + }, + /* 29: for 32000 kbs FB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 9830/*1.200000 Q13*/, 9421/*1.150000 Q13*/, 9421/*1.150000 Q13*/, 9011/*1.100000 Q13*/, 8602/*1.050000 Q13*/, 8192/*1.000000 Q13*/, 7373/*0.900000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, + /* strong */ {14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 14746/*1.800000 Q13*/, 13517/*1.650000 Q13*/, 12698/*1.550000 Q13*/, 11878/*1.450000 Q13*/, 9830/*1.200000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } + }, + /* 30: for 48000 kbs FB (stereo) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6390/*0.780000 Q13*/, 2540/*0.310000 Q13*/, 2785/*0.340000 Q13*/, 2785/*0.340000 Q13*/ }, + /* strong */ {12206/*1.490000 Q13*/, 11305/*1.380000 Q13*/, 5325/*0.650000 Q13*/, 5325/*0.650000 Q13*/ } + }, + /* 31: for 48000 kbs FB (stereo TCX10) */ /* currently not used due to adaptive calculation of thresholds at 48 kbps */ + { + /* medium */ {6144/*0.750000 Q13*/, 5734/*0.700000 Q13*/, 4096/*0.500000 Q13*/, 4096/*0.500000 Q13*/ }, + /* strong */ {10240/*1.250000 Q13*/, 9011/*1.100000 Q13*/, 8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/ } + }, + /* 32: for 64000 kbs FB (stereo) */ + { + /* medium */ {8192/*1.000000 Q13*/, 8192/*1.000000 Q13*/, 9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 6144/*0.750000 Q13*/ }, + /* strong */ {12288/*1.500000 Q13*/, 12288/*1.500000 Q13*/, 13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 8192/*1.000000 Q13*/ } + }, + /* 33: for 80000 kbs FB (stereo) */ + { + /* medium */ {9830/*1.200000 Q13*/, 10240/*1.250000 Q13*/, 6144/*0.750000 Q13*/, 0/*0.000000 Q13*/ }, + /* strong */ {13107/*1.600000 Q13*/, 13107/*1.600000 Q13*/, 8192/*1.000000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 34: for 96000 kbs FB (stereo) */ + { + /* medium */ {7455/*0.910000 Q13*/, 6963/*0.850000 Q13*/ , 0/*0.000000 Q13*/ }, + /* strong */ {10977/*1.340000 Q13*/, 11059/*1.350000 Q13*/, 0/*0.000000 Q13*/ } + }, + /* 35: for 128000 kbs FB (stereo) */ + { + /* medium */ { 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/}, + /* strong */ {23101/*2.820000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/, 0/*0.000000 Q13*/} + } +}; const Word16 igf_whitening_TH[][2][IGF_MAX_TILES] = { /* 0: for 9600 kbs WB */ diff --git a/lib_com/rom_com.h b/lib_com/rom_com.h index 37765eb5b..2c9ab8eab 100644 --- a/lib_com/rom_com.h +++ b/lib_com/rom_com.h @@ -1898,6 +1898,9 @@ extern const int16_t swb_offset_LB_new[IGF_BITRATE_UNKNOWN][IGF_MAX_SFB]; extern const int16_t igf_tile_offset_table[IGF_BITRATE_UNKNOWN][2 * IGF_MAX_TILES + 1]; extern const float igf_whitening_TH_flt[IGF_BITRATE_UNKNOWN][2][IGF_MAX_TILES]; extern const Word16 igf_whitening_TH[][2][IGF_MAX_TILES]; +#ifdef IVAS_FLOAT_FIXED +extern const Word16 igf_whitening_TH_ivas_fx[IGF_BITRATE_UNKNOWN][2][IGF_MAX_TILES]; +#endif // IVAS_FLOAT_FIXED extern const int16_t cf_off_se01_tab[10]; extern const int16_t cf_off_se10_tab; extern const int16_t cf_off_se02_tab[10][IGF_CTX_COUNT]; diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 57259fcab..49e7f4a1e 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -743,6 +743,7 @@ typedef struct cldfb_filter_bank_struct #ifdef IVAS_FLOAT_FIXED Word32 *cldfb_state_fx; + Word16 cldfb_state_length; #endif /* other parameters */ diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index c92e2e43e..1d7f47e75 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -188,101 +188,101 @@ void open_decoder_LPD_flt( if (!is_init || st->element_mode != IVAS_CPE_MDCT) { #ifdef IVAS_FLOAT_FIXED - init_tcx_cfg_fx(st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag,fscaleFB); - st->hTcxCfg->preemph_fac_flt = st->preemph_fac_float; - st->hTcxCfg->sq_rounding_flt = fix16_to_float(st->hTcxCfg->sq_rounding, 15); - st->hTcxCfg->bandwidth_flt = fix16_to_float(st->hTcxCfg->bandwidth, 15); - st->hTcxCfg->na_scale_flt = fix16_to_float(st->hTcxCfg->na_scale, 15); - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++) - { - st->hTcxCfg->tcx_mdct_windowFB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_windowFB[i].v.im, 15); - st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_windowFB[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_trans_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_trans[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_trans[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_transFB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_transFB[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_transFB[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_half_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_half[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_half[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_halfFB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_minimum_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_minimum[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_minimum[i].v.re, 15); - } - FOR (i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++) - { - st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im, 15); - st->hTcxCfg->tcx_mdct_window_minimumFB_flt[st->hTcxCfg->tcx_mdct_window_min_lengthFB - i - 1] = fix16_to_float(st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re, 15); - } - Word16 n = st->L_frame; - Word16 n0 = shr(imult1616(n, 9), 5); - Word16 n1 = shr(imult1616(n, 23), 5); /* left slope length */ - Word16 n2 = shr(imult1616(n, 14), 5); /* right slope length */ - FOR (i = 0; i < n0; i++) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_1[i], 15); - } - FOR (i = n0; i < n / 2; i++) - { - st->hTcxCfg->tcx_aldo_window_1_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im, 15); - } - FOR (i = 0; i < n1 - n / 2; i++) - { - st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re, 15); - } - FOR (i = 0; i < n2 / 2; i++) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_2[i].v.im, 15); - } - FOR (i = n2 / 2; i < n2; i++) - { - st->hTcxCfg->tcx_aldo_window_2_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re, 15); - } - n = NS2SA_fx2(st->output_Fs, FRAME_SIZE_NS); - n0 = shr(imult1616(n, 9), 5); - n1 = shr(imult1616(n, 23), 5); /* left slope length */ - n2 = shr(imult1616(n, 14), 5); /* right slope length */ - FOR (i = 0; i < n0; i++) - { - st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_1_FB[i], 15); - } - FOR (i = n0; i < n / 2; i++) - { - st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_1_FB_trunc[i - n0].v.im, 15); - } - FOR (i = 0; i < n1 - n / 2; i++) - { - st->hTcxCfg->tcx_aldo_window_1_FB_flt[n / 2 + i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_1_FB_trunc[n1 - n / 2 - i - 1].v.re, 15); - } - FOR (i = 0; i < n2 / 2; i++) - { - st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im, 15); - } - FOR (i = n2 / 2; i < n2; i++) - { - st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fix16_to_float(st->hTcxCfg->tcx_aldo_window_2_FB[n2 - i - 1].v.re, 15); - } - st->hTcxCfg->tcx_aldo_window_1_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_flt + NS2SA(st->sr_core, N_ZERO_MDCT_NS); - st->hTcxCfg->tcx_aldo_window_1_FB_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_FB_flt + NS2SA(st->output_Fs, N_ZERO_MDCT_NS); + init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); + st->hTcxCfg->preemph_fac_flt = st->preemph_fac_float; + st->hTcxCfg->sq_rounding_flt = fix16_to_float( st->hTcxCfg->sq_rounding, 15 ); + st->hTcxCfg->bandwidth_flt = fix16_to_float( st->hTcxCfg->bandwidth, 15 ); + st->hTcxCfg->na_scale_flt = fix16_to_float( st->hTcxCfg->na_scale, 15 ); + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_windowFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_windowFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_windowFB[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_trans_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_trans[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_trans[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_transFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_transFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_transFB[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_half_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_half[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_half[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_halfFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_minimum_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimum[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimum[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_minimumFB_flt[st->hTcxCfg->tcx_mdct_window_min_lengthFB - i - 1] = fix16_to_float( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re, 15 ); + } + Word16 n = st->L_frame; + Word16 n0 = shr( imult1616( n, 9 ), 5 ); + Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ + Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ + FOR( i = 0; i < n0; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1[i], 15 ); + } + FOR( i = n0; i < n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im, 15 ); + } + FOR( i = 0; i < n1 - n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re, 15 ); + } + FOR( i = 0; i < n2 / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2[i].v.im, 15 ); + } + FOR( i = n2 / 2; i < n2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re, 15 ); + } + n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); + n0 = shr( imult1616( n, 9 ), 5 ); + n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ + n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ + FOR( i = 0; i < n0; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_FB[i], 15 ); + } + FOR( i = n0; i < n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_FB_trunc[i - n0].v.im, 15 ); + } + FOR( i = 0; i < n1 - n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_flt[n / 2 + i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_1_FB_trunc[n1 - n / 2 - i - 1].v.re, 15 ); + } + FOR( i = 0; i < n2 / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im, 15 ); + } + FOR( i = n2 / 2; i < n2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fix16_to_float( st->hTcxCfg->tcx_aldo_window_2_FB[n2 - i - 1].v.re, 15 ); + } + st->hTcxCfg->tcx_aldo_window_1_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_flt + NS2SA( st->sr_core, N_ZERO_MDCT_NS ); + st->hTcxCfg->tcx_aldo_window_1_FB_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_FB_flt + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ); #else init_tcx_cfg(st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac_float, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag); #endif @@ -319,11 +319,11 @@ void open_decoder_LPD_flt( if (st->hTcxDec != NULL) { #ifdef IVAS_FLOAT_FIXED - reset_tcx_overl_buf_fx(st->hTcxDec); - fixedToFloat_arr(hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl_float, 0, L_FRAME32k / 2); - fixedToFloat_arr(hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC_float, 0, L_FRAME32k / 2); - fixedToFloat_arr(hTcxDec->syn_Overl, hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2); - fixedToFloat_arr(hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDACFB_float, 0, L_FRAME_MAX / 2); + reset_tcx_overl_buf_fx( st->hTcxDec ); + fixedToFloat_arr( hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl_float, 0, L_FRAME32k / 2 ); + fixedToFloat_arr( hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC_float, 0, L_FRAME32k / 2 ); + fixedToFloat_arr( hTcxDec->syn_Overl, hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2 ); + fixedToFloat_arr( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDACFB_float, 0, L_FRAME_MAX / 2 ); #else reset_tcx_overl_buf(st->hTcxDec); #endif // IVAS_FLOAT_FIXED @@ -387,29 +387,29 @@ void open_decoder_LPD_flt( /* Switching from Mode 1 ACELP */ st->last_core_bfi = ACELP_CORE; #ifdef IVAS_FLOAT_FIXED - Word16 delay_comp = NS2SA_fx2(st->output_Fs, DELAY_CLDFB_NS); /*CLDFB delay*/ - Word16 Q_fer_samples = Q_factor_arr(st->hHQ_core->fer_samples + delay_comp, shr(st->hTcxDec->L_frameTCX, 1)) - 1; - IF(st->prev_bfi != 0 && st->hTcxCfg != NULL) - { - floatToFixed_arr(st->hHQ_core->fer_samples + delay_comp, st->hHQ_core->fer_samples_fx + delay_comp, Q_fer_samples, shr(st->hTcxDec->L_frameTCX, 1)); - floatToFixed_arr(st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, Q_fer_samples, L_FRAME_MAX / 2); - floatToFixed_arr(st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_fer_samples, L_FRAME32k / 2); - floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, Q_fer_samples - 1, L_FRAME48k); - floatToFixed_arr(st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, Q_fer_samples - 1, L_FRAME32k); - floatToFixed_arr(st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, Q_fer_samples - 1, L_FRAME_MAX / 2); - floatToFixed_arr(st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, Q_fer_samples - 1, L_FRAME32k / 2); - acelp_plc_mdct_transition_fx(st); - fixedToFloat_arr(st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, Q_fer_samples, L_FRAME_MAX / 2); - fixedToFloat_arr(st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, Q_fer_samples, L_FRAME32k / 2); - fixedToFloat_arr(st->hHQ_core->old_out_fx, st->hHQ_core->old_out, Q_fer_samples - 1, L_FRAME48k); - fixedToFloat_arr(st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, Q_fer_samples - 1, L_FRAME32k); - fixedToFloat_arr(st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, Q_fer_samples - 1, L_FRAME_MAX / 2); - fixedToFloat_arr(st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, Q_fer_samples - 1, L_FRAME32k / 2); - } + Word16 delay_comp = NS2SA_fx2( st->output_Fs, DELAY_CLDFB_NS ); /*CLDFB delay*/ + Word16 Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples + delay_comp, shr( st->hTcxDec->L_frameTCX, 1 ) ) - 1; + IF( st->prev_bfi != 0 && st->hTcxCfg != NULL ) + { + floatToFixed_arr( st->hHQ_core->fer_samples + delay_comp, st->hHQ_core->fer_samples_fx + delay_comp, Q_fer_samples, shr( st->hTcxDec->L_frameTCX, 1 ) ); + floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, Q_fer_samples, L_FRAME_MAX / 2 ); + floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_fer_samples, L_FRAME32k / 2 ); + floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, Q_fer_samples - 1, L_FRAME48k ); + floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, Q_fer_samples - 1, L_FRAME32k ); + floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, Q_fer_samples - 1, L_FRAME_MAX / 2 ); + floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, Q_fer_samples - 1, L_FRAME32k / 2 ); + acelp_plc_mdct_transition_fx( st ); + fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, Q_fer_samples, L_FRAME_MAX / 2 ); + fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, Q_fer_samples, L_FRAME32k / 2 ); + fixedToFloat_arr( st->hHQ_core->old_out_fx, st->hHQ_core->old_out, Q_fer_samples - 1, L_FRAME48k ); + fixedToFloat_arr( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, Q_fer_samples - 1, L_FRAME32k ); + fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, Q_fer_samples - 1, L_FRAME_MAX / 2 ); + fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, Q_fer_samples - 1, L_FRAME32k / 2 ); + } #else acelp_plc_mdct_transition(st); -#endif // IVAS_FLOAT_FIXED +#endif // IVAS_FLOAT_FIXED } if (st->last_codec_mode == MODE2 && @@ -436,15 +436,15 @@ void open_decoder_LPD_flt( if (st->hTcxDec != NULL) { #ifdef IVAS_FLOAT_FIXED - reset_tcx_overl_buf_fx(st->hTcxDec); - fixedToFloat_arr(hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl_float, 0, L_FRAME32k / 2); - fixedToFloat_arr(hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC_float, 0, L_FRAME32k / 2); - fixedToFloat_arr(hTcxDec->syn_Overl, hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2); - fixedToFloat_arr(hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDACFB_float, 0, L_FRAME_MAX / 2); + reset_tcx_overl_buf_fx( st->hTcxDec ); + fixedToFloat_arr( hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl_float, 0, L_FRAME32k / 2 ); + fixedToFloat_arr( hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC_float, 0, L_FRAME32k / 2 ); + fixedToFloat_arr( hTcxDec->syn_Overl, hTcxDec->syn_Overl_float, 0, L_FRAME32k / 2 ); + fixedToFloat_arr( hTcxDec->syn_Overl_TDACFB, hTcxDec->syn_Overl_TDACFB_float, 0, L_FRAME_MAX / 2 ); #else reset_tcx_overl_buf(st->hTcxDec); -#endif // IVAS_FLOAT_FIXED +#endif // IVAS_FLOAT_FIXED } if (st->hTcxCfg != NULL) @@ -469,26 +469,25 @@ void open_decoder_LPD_flt( /* reset CLDFB memories */ #ifdef IVAS_FLOAT_FIXED - Word16 memory_length=0; - cldfb_reset_memory_fx(st->cldfbAna,&memory_length); - fixedToFloat_arrL(st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, 0, memory_length); - cldfb_reset_memory_fx(st->cldfbBPF,&memory_length); - fixedToFloat_arrL(st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, 0, memory_length); - cldfb_reset_memory_fx(st->cldfbSyn,&memory_length); - fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, 0, memory_length); - #else + cldfb_reset_memory_fx( st->cldfbAna ); + fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, 0, st->cldfbAna->cldfb_state_length ); + cldfb_reset_memory_fx( st->cldfbBPF ); + fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, 0, st->cldfbBPF->cldfb_state_length ); + cldfb_reset_memory_fx( st->cldfbSyn ); + fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, 0, st->cldfbSyn->cldfb_state_length ); +#else cldfb_reset_memory_ivas(st->cldfbAna); cldfb_reset_memory_ivas(st->cldfbBPF); cldfb_reset_memory_ivas(st->cldfbSyn); #endif // IVAS_FLOAT_FIXED if (st->cldfbSynHB != NULL) { - #ifdef IVAS_FLOAT_FIXED - cldfb_reset_memory_fx(st->cldfbSynHB,&memory_length); - fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, 0, memory_length); - #else +#ifdef IVAS_FLOAT_FIXED + cldfb_reset_memory_fx( st->cldfbSynHB ); + fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, 0, st->cldfbSynHB->cldfb_state_length ); +#else cldfb_reset_memory_ivas(st->cldfbSynHB); - #endif +#endif } } else if ((st->L_frame != st->last_L_frame) && (st->L_frame <= L_FRAME16k) && (st->last_L_frame <= L_FRAME16k)) /* Rate switching between 12.8 and 16 kHz*/ @@ -739,16 +738,16 @@ void open_decoder_LPD_flt( if (hTcxLtpDec != NULL) { #ifdef IVAS_FLOAT_FIXED - tcxltp_dec_init_fx(hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core); - IF(st->ini_frame == 0 || (EQ_16(st->last_codec_mode, MODE1) && EQ_16(st->element_mode, EVS_MONO))) - { - IF(st->ini_frame == 0) - { - fixedToFloat_arr(hTcxLtpDec->tcxltp_mem_in,hTcxLtpDec->tcxltp_mem_in_float, 0, TCXLTP_MAX_DELAY); - fixedToFloat_arr(hTcxLtpDec->tcxltp_mem_out,hTcxLtpDec->tcxltp_mem_out_float, 0, L_FRAME48k); - hTcxLtpDec->tcxltp_gain_post_prev_float = fixedToFloat(hTcxLtpDec->tcxltp_gain_post_prev,0); - } - } + tcxltp_dec_init_fx( hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); + IF( st->ini_frame == 0 || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) + { + IF( st->ini_frame == 0 ) + { + fixedToFloat_arr( hTcxLtpDec->tcxltp_mem_in, hTcxLtpDec->tcxltp_mem_in_float, 0, TCXLTP_MAX_DELAY ); + fixedToFloat_arr( hTcxLtpDec->tcxltp_mem_out, hTcxLtpDec->tcxltp_mem_out_float, 0, L_FRAME48k ); + hTcxLtpDec->tcxltp_gain_post_prev_float = fixedToFloat( hTcxLtpDec->tcxltp_gain_post_prev, 0 ); + } + } #else tcxltp_dec_init(hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core); #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index 6eebcafd6..661473690 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1084,3 +1084,798 @@ void acelp_plc_mdct_transition_fx( return; } +#ifdef IVAS_FLOAT_FIXED +void open_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 last_total_brate, /* i : last total bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0) */ + const Word16 last_element_mode, /* i : last element mode */ + const Word16 is_init, /* i : indicate call from init_decoder() to avoid double TC initialization */ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 ) +{ + Word16 i; + Word16 mem_syn_r_size_new; + Word16 mem_syn_r_size_old; + Word16 fscaleFB; + Word16 encoderLookahead, encoderLookaheadFB; + BPF_DEC_HANDLE hBPF; + TD_BWE_DEC_HANDLE hBWE_TD; + TCX_LTP_DEC_HANDLE hTcxLtpDec; + HQ_DEC_HANDLE hHQ_core; + TCX_DEC_HANDLE hTcxDec; + + hBPF = st->hBPF; + hBWE_TD = st->hBWE_TD; + hHQ_core = st->hHQ_core; + hTcxLtpDec = st->hTcxLtpDec; + hTcxDec = st->hTcxDec; + + IF( NE_16( st->codec_mode, MODE1 ) ) /*already updated in MODE1*/ + { + st->fscale_old = st->fscale; + } + + st->sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); + st->fscale = sr2fscale_fx( st->sr_core ); + fscaleFB = sr2fscale_fx( st->output_Fs ); + + /* initializing variables for frame lengths etc. right in the beginning */ + st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); + IF( EQ_16( st->ini_frame, 0 ) ) + { + st->last_L_frame = st->L_frame_past = st->L_frame; + move16(); + move16(); + } + IF( st->hTcxDec != NULL ) + { + st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); + IF( EQ_16( st->ini_frame, 0 ) ) + { + st->L_frameTCX_past = st->hTcxDec->L_frameTCX; + } + } + + st->tcxonly = getTcxonly_fx( st->element_mode, total_brate, MCT_flag, st->is_ism_format ); + move16(); + + /* the TD TCX PLC in MODE1 still runs with 80ms subframes */ + IF( ( EQ_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( st->total_brate, 32000 ) ) || + ( GT_16( st->element_mode, EVS_MONO ) && EQ_16( st->L_frame, L_FRAME16k ) && LE_32( total_brate, MAX_ACELP_BRATE ) ) || + ( NE_16( st->tcxonly, 0 ) && ( EQ_32( st->sr_core, 32000 ) || EQ_32( st->sr_core, 16000 ) ) ) ) + { + st->nb_subfr = NB_SUBFR16k; + } + ELSE + { + st->nb_subfr = NB_SUBFR; + } + st->bits_frame = extract_l( L_shr( Mpy_32_16_1( L_shl( st->total_brate, 1 ), 20972 ), 6 ) ); /* 20972 = 0.01 * 64 * 32768 */ + // assert(FSCALE_DENOM == 512); + // assert(st->fscale == 2 * st->L_frame); /* this assumption is true if operated in 20ms frames with FSCALE_DENOM == 512, which is the current default */ + // assert(st->bits_frame == (int16_t)(((float)st->L_frame / (float)st->fscale) * (float)FSCALE_DENOM / 128.0f * (float)total_brate / 100.0f + 0.49f)); + st->TcxBandwidth = getTcxBandwidth( bwidth ); + st->narrowBand = 0; + IF( EQ_16( bwidth, NB ) ) + { + st->narrowBand = 1; + } + // To be replaced with basops + encoderLookahead = mult( L_LOOK_12k8<<6 , st->fscale ); + encoderLookaheadFB = mult(L_LOOK_12k8<<6 , fscaleFB ); + IF( EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->pit_res_max = initPitchLagParameters( INT_FS_12k8, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + IF( hTcxDec != NULL ) + { + i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( L_FRAME ) ); + hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) ); + hTcxDec->pit_min_TCX = extract_l( L_shr( L_mult( st->pit_min, i ), 7 ) ); + } + } + ELSE + { + st->pit_res_max = initPitchLagParameters( st->sr_core, &st->pit_min, &st->pit_fr1, &st->pit_fr1b, &st->pit_fr2, &st->pit_max ); + IF( hTcxDec != NULL ) + { + i = mult_r( hTcxDec->L_frameTCX, getInvFrameLen( st->L_frame ) ); + hTcxDec->pit_max_TCX = extract_l( L_shr( L_mult( st->pit_max, i ), 7 ) ); + hTcxDec->pit_min_TCX = extract_l( L_shr( L_mult( st->pit_min, i ), 7 ) ); + } + } + + IF( EQ_16( st->ini_frame, 0 ) ) + { + st->pit_res_max_past = st->pit_res_max; + } + + /*Preemphasis param*/ + IF( LT_16( st->fscale, ( 16000 * FSCALE_DENOM ) / INT_FS_12k8 ) ) /*To be replaced with basops*/ + { + st->preemph_fac = PREEMPH_FAC; /*WB*/ + move16(); + } + ELSE IF( LT_16( st->fscale, ( 24000 * FSCALE_DENOM ) / INT_FS_12k8 ) ) + { + st->preemph_fac = PREEMPH_FAC_16k; /*WB*/ + move16(); + } + ELSE + { + st->preemph_fac = PREEMPH_FAC_SWB; /*SWB*/ + } + + // gamma_float to be removed later + st->inv_gamma = GAMMA1_INV; + IF( EQ_32( st->sr_core, INT_FS_16k ) ) + { + st->gamma = GAMMA16k; + move16(); + st->inv_gamma = GAMMA16k_INV; + } + ELSE IF( GT_32( st->sr_core, INT_FS_16k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->gamma = GAMMA16k; + move16(); + st->inv_gamma = GAMMA16k_INV; + } + ELSE + { + st->gamma = GAMMA1; + move16(); + } + + /* LPC quantization */ + IF( LE_32( st->sr_core, INT_FS_16k ) && EQ_16( st->tcxonly, 0 ) ) + { + st->lpcQuantization = 1; + } + ELSE + { + st->lpcQuantization = 0; + } + + IF( EQ_16( st->tcxonly, 0 ) ) + { + st->numlpc = 1; + } + ELSE + { + st->numlpc = 2; + } + + /* Initialize TBE */ + st->prev_coder_type = GENERIC; + IF( st->hBWE_TD != NULL ) + { + set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); + hBWE_TD->prev_tilt_para_fx = 0; + set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); + } + + IF( st->hIGFDec != NULL ) + { + IF( !is_init || NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + init_tcx_cfg_fx( st->hTcxCfg, total_brate, st->sr_core, st->output_Fs, st->L_frame, st->bwidth, st->hTcxDec->L_frameTCX, st->fscale, encoderLookahead, encoderLookaheadFB, st->preemph_fac, st->tcxonly, st->rf_flag, st->igf, st->hIGFDec->infoIGFStopFreq, st->element_mode, st->ini_frame, MCT_flag, fscaleFB ); + } + ELSE + { + st->hTcxCfg->tcx_curr_overlap_mode = st->hTcxCfg->tcx_last_overlap_mode = ALDO_WINDOW; + st->hTcxCfg->last_aldo = 1; + } + } + IF( st->hTECDec != NULL ) + { + /*constraint for adaptive bpf, otherwise parameter estimation and post-processing not time aligned*/ + IF( EQ_16( st->tcxonly, 0 ) ) + { + // To be added later + // assert(0 == (st->hTcxCfg->lfacnext > 0 ? st->hTcxCfg->lfacnext : 0)); + } + + resetTecDec_Fx( st->hTECDec ); + } + + IF( NE_16( st->element_mode, IVAS_SCE ) ) + { + st->flag_cna = 0; + move16(); + } + IF( EQ_16( st->ini_frame, 0 ) ) + { + st->flag_cna = 0; + st->last_flag_cna = 0; + move16(); + } + + /* Static vectors to zero */ + IF( EQ_16( st->ini_frame, 0 ) ) + { + st->last_is_cng = 0; + move16(); + + st->rate_switching_reset = 0; + move16(); + + IF( st->hTcxDec != NULL ) + { + reset_tcx_overl_buf_fx( st->hTcxDec ); + set16_fx( hTcxDec->syn_OverlFB, 0, L_FRAME_MAX / 2 ); + set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + set16_fx( hTcxDec->synth_history_fx, 0, L_PROT48k + L_FRAME_MAX ); + } + set16_fx( st->syn, 0, M + 1 ); + set16_fx( st->mem_syn_r, 0, L_SYN_MEM ); + + mem_syn_r_size_old = 0; /* just to avoid MSVC warnings */ + mem_syn_r_size_new = 0; /* just to avoid MSVC warnings */ + + st->con_tcx = 0; + } + ELSE + { + /* Reset old_synth in case of core sampling rate switching and Mode 1/2 switching*/ + test(); + IF( st->hTcxDec != NULL && ( NE_16( st->L_frame, st->last_L_frame ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) ) + { + set16_fx( hTcxDec->old_synth, 0, OLD_SYNTH_INTERNAL_DEC ); + } + + /*Compute size of old and new memories*/ + /* 1.25/20.0 = 1.0/16.0 -> shift 4 to the right. */ + mem_syn_r_size_old = shr( st->last_L_frame, 4 ); + mem_syn_r_size_new = shr( st->L_frame, 4 ); + + /*Reset LPC mem*/ + test(); + test(); + IF( ( NE_16( st->L_frame, st->last_L_frame ) ) || ( EQ_16( st->last_core, AMR_WB_CORE ) ) || EQ_16( st->last_core, HQ_CORE ) ) + { + set16_fx( st->mem_MA_fx, 0, M ); + IF( EQ_32( st->sr_core, INT_FS_16k ) ) + { + Copy( GEWB2_Ave_fx, st->mem_AR_fx, M ); + } + ELSE + { + Copy( GEWB_Ave_fx, st->mem_AR_fx, M ); + } + } + + /*Mode 1/2 switching*/ + IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) + { + Copy( st->lsp_old_fx, st->lspold_uw, M ); + Copy( st->lsf_old_fx, st->lsfold_uw, M ); + set16_fx( st->syn, 0, M ); + } + IF( EQ_16( st->last_core, AMR_WB_CORE ) ) + { + st->last_core = ACELP_CORE; + move16(); + st->last_core_bfi = ACELP_CORE; + move16(); + } + + /*Codec switching from ACELP-A */ + test(); + test(); + test(); + test(); + IF( ( NE_16( st->element_mode, IVAS_CPE_DFT ) || ( EQ_16( st->element_mode, IVAS_CPE_DFT ) && st->prev_bfi ) ) && EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, ACELP_CORE ) ) + { + /* Switching from Mode 1 ACELP */ + st->last_core_bfi = ACELP_CORE; + move16(); + IF( NE_16( st->prev_bfi, 0 ) && st->hTcxCfg != NULL ) + { + acelp_plc_mdct_transition_fx( st ); + *Q_syn_Overl_TDAC = *Q_fer_samples - 1; + *Q_syn_Overl = *Q_fer_samples; + *Q_syn_Overl_TDACFB = *Q_fer_samples - 1; + *Q_syn_OverlFB = *Q_fer_samples; + *Q_old_out = *Q_fer_samples - 1; + *Q_old_outLB = *Q_fer_samples - 1; + } + } + + IF( EQ_16( st->last_codec_mode, MODE2 ) && NE_16( st->L_frame, st->last_L_frame ) && + ( ( EQ_16( st->m_frame_type, SID_FRAME ) && GT_16( st->last_core, ACELP_CORE ) ) || + ( GT_16( st->last_core, ACELP_CORE ) && GT_16( st->core, ACELP_CORE ) ) || st->prev_bfi ) ) + { + lerp( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_out_LB_fx, st->L_frame, st->last_L_frame ); + } + + /* Rate switching */ + IF( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->last_core, HQ_CORE ) ) + { + /* Switching from MDCT */ + + /*Reset of ACELP memories*/ + st->rate_switching_reset = 1; + // To be removed later + st->tilt_code_fx = TILT_CODE; + set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); + set16_fx( st->syn, 0, 1 + M ); + set16_fx( st->mem_syn2_fx, 0, M ); + + /*OLA -> zero */ + IF( st->hTcxDec != NULL ) + { + reset_tcx_overl_buf_fx( st->hTcxDec ); + } + + IF( st->hTcxCfg != NULL ) + { + hHQ_core->Q_old_wtda = -1; /*To be removed later when hHQ_core->Q_old_wtda vaue is updated*/ + Copy_Scale_sig( hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), hTcxDec->syn_OverlFB, st->hTcxCfg->tcx_mdct_window_lengthFB, negate( add( hHQ_core->Q_old_wtda, TCX_IMDCT_HEADROOM ) ) ); + *Q_syn_OverlFB = *Q_old_out; + st->hTcxCfg->last_aldo = 1; /*It was previously ALDO*/ + st->hTcxCfg->tcx_curr_overlap_mode = ALDO_WINDOW; + } + + /*OLA for Mode 2 TCX always reset in Mode switching cases*/ + IF( st->hHQ_core != NULL ) + { + set16_fx( hHQ_core->old_out_LB_fx, 0, st->L_frame ); + } + + st->last_core_bfi = TCX_20_CORE; + + IF( st->hPFstat != NULL ) + { + st->hPFstat->on = 0; + } + + /* reset CLDFB memories */ + cldfb_reset_memory_fx( st->cldfbAna ); + cldfb_reset_memory_fx( st->cldfbBPF ); + cldfb_reset_memory_fx( st->cldfbSyn ); + IF( st->cldfbSynHB != NULL ) + { + cldfb_reset_memory_fx( st->cldfbSynHB ); + } + } + ELSE IF( ( NE_16( st->L_frame, st->last_L_frame ) ) && ( LE_16( st->L_frame, L_FRAME16k ) ) && ( LE_16( st->last_L_frame, L_FRAME16k ) ) ) /* Rate switching between 12.8 and 16 kHz*/ + { + /*Interpolation of ACELP memories*/ + + /* convert quantized LSP vector */ + st->rate_switching_reset = lsp_convert_poly_fx( st->lsp_old_fx, st->L_frame, 0 ); + IF( EQ_16( st->tcxonly, 0 ) ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsf_old_fx, M, st->sr_core ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsf_old_fx, M ); + } + E_LPC_f_lsp_a_conversion( st->lsp_old_fx, st->old_Aq_12_8_fx, M ); + Copy( st->lsp_old_fx, st->lspold_uw, M ); + Copy( st->lsf_old_fx, st->lsfold_uw, M ); + *Q_old_Aq_12_8 = 14; + IF( !st->last_con_tcx ) + { + synth_mem_updt2( st->L_frame, st->last_L_frame, st->old_exc_fx, st->mem_syn_r, st->mem_syn2_fx, NULL, DEC ); + } + + /*mem of deemphasis stayed unchanged.*/ + } + ELSE IF( NE_16( st->L_frame, st->last_L_frame ) ) /* Rate switching involving TCX only modes */ + { + /*Partial reset of ACELP memories*/ + st->rate_switching_reset = 1; + + /*reset partly some memories*/ + st->tilt_code_fx = TILT_CODE; + IF( !st->last_con_tcx ) + { + set16_fx( st->old_exc_fx, 0, L_EXC_MEM_DEC ); + } + set16_fx( st->old_Aq_12_8_fx, 0, M + 1 ); + + /*Resamp others memories*/ + /*Size of LPC syn memory*/ + lerp( st->mem_syn_r + L_SYN_MEM - mem_syn_r_size_old, st->mem_syn_r + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + Copy( st->mem_syn_r + L_SYN_MEM - M, st->mem_syn2_fx, M ); + } + /* update of lsf_old only needed in BASOP */ + /* ELSE IF( !st->tcxonly && (st->L_frame == L_FRAME16k) && (st->last_total_brate > ACELP_32k) ) */ + /* { */ + /* lsp2lsf( st->lsp_old, st->lsf_old, M, st->sr_core ); */ + /* } */ + } + + IF( EQ_16( st->last_bwidth, NB ) && NE_16( st->bwidth, NB ) && NE_16( st->ini_frame, 0 ) ) + { + st->rate_switching_reset = 1; + move16(); + } + + IF( st->hTcxDec != NULL ) + { + st->hTcxDec->old_synth_len = shl( st->L_frame, 1 ); + st->hTcxDec->old_synth_lenFB = shl( hTcxDec->L_frameTCX, 1 ); + } + + /* bass pf reset */ + st->bpf_gain_param = 0; + IF( st->hBPF != NULL ) + { + set16_fx( hBPF->pst_old_syn_fx, 0, NBPSF_PIT_MAX ); + } + + /* Formant postfilter */ + IF( EQ_16( st->ini_frame, 0 ) ) + { + /* do nothing */ + } + ELSE IF( EQ_16( st->last_codec_mode, MODE2 ) ) + { + IF( !st->tcxonly ) + { + IF( st->hPFstat->on ) + { + lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + } + ELSE + { + set16_fx( st->hPFstat->mem_stp, 0, L_SYN_MEM ); + set16_fx( st->hPFstat->mem_pf_in, 0, L_SYN_MEM ); + st->hPFstat->reset = 1; + st->hPFstat->gain_prec = 16384; + move16(); + } + } + ELSE IF( st->hPFstat->on ) + { + lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + } + } + ELSE + { + /*codec mode switching*/ + + /*reset post-filter except for Narrowband*/ + IF( NE_32( st->output_Fs, L_FRAME8k * FRAMES_PER_SEC ) ) + { + IF( st->hPFstat != NULL ) + { + st->hPFstat->reset = 1; + IF( st->hPFstat->on != 0 ) + { + st->hPFstat->reset = 0; + //-------------Present in EVS + // Scale_sig(st->hPFstat->mem_pf_in, L_SUBFR, negate(st->Q_syn)); /* WB post_filter mem */ + // Scale_sig(st->hPFstat->mem_stp, L_SUBFR, negate(st->Q_syn)); /* WB post_filter mem */ + //-------------- + lerp( st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_stp + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + lerp( st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_old, st->hPFstat->mem_pf_in + L_SYN_MEM - mem_syn_r_size_new, mem_syn_r_size_new, mem_syn_r_size_old ); + } + } + } + ELSE + { + //----------------Present in EVS + // IF(st->hPFstat != NULL) + //{ + // Scale_sig(st->hPFstat->mem_pf_in, L_SUBFR, negate(st->Q_syn)); /* NB post_filter mem */ + // Scale_sig(st->hPFstat->mem_res2, DECMEM_RES2, negate(st->Q_syn)); /* NB post_filter mem */ + // Scale_sig(st->hPFstat->mem_stp, L_SUBFR, negate(st->Q_syn)); /* NB post_filter mem */ + //} + //------------------ + /*feed last value old_synth as it is used for pre-emphasis mem*/ + IF( st->hTcxDec != NULL ) + { + st->hTcxDec->old_synth[st->hTcxDec->old_synth_len - 1] = st->syn[M]; + } + IF( st->hBPF != NULL ) + { + st->hBPF->pst_old_syn_fx[NBPSF_PIT_MAX - 1] = st->syn[M]; + } + } + } + + /* lsf and lsp initialization */ + IF( EQ_16( st->ini_frame, 0 ) ) + { + Copy( st->lsp_old_fx, st->lspold_uw, M ); + Copy( st->lsf_old_fx, st->lsfold_uw, M ); + set16_fx( st->lsf_cng, 0, M ); + } + + st->seed_tcx_plc = RANDOM_INITSEED; + move16(); + st->past_gpit = 0; + move16(); + st->past_gcode = L_deposit_l( 0 ); + st->gc_threshold_fx = L_deposit_l( 0 ); + + E_LPC_lsf_lsp_conversion( st->lsf_cng, st->lspold_cng, M ); + E_LPC_f_lsp_a_conversion( st->lspold_cng, st->Aq_cng, M ); + st->plcBackgroundNoiseUpdated = 0; + Copy( st->lsf_old_fx, st->lsf_q_cng, M ); + Copy( st->lsf_old_fx, st->old_lsf_q_cng, M ); + Copy( st->lsp_old_fx, st->lsp_q_cng, M ); + Copy( st->lsp_old_fx, st->old_lsp_q_cng, M ); + set16_fx( st->mem_syn_unv_back, 0, M ); + st->last_gain_syn_deemph = 32768 / 2; /* 1.f Q14*/ + + IF( EQ_16( st->last_codec_mode, MODE1 ) || EQ_16( st->ini_frame, 0 ) ) + { + /* this assumes that MODE1 fades out in the frequency domain - + otherwise some data from MODE1 would be needed here */ + st->last_concealed_gain_syn_deemph = 32768 / 2; + move16(); + st->last_concealed_gain_syn_deemph_e = 1; + move16(); + IF( hTcxDec != NULL ) + { + hTcxDec->conceal_eof_gain = 32768 / 2; /*Q14*/ + } + } + /* Post processing */ + set16_fx( st->mem_Aq, 0, NB_SUBFR16k * ( M + 1 ) ); + + st->lp_ener_FER_fx = 15360; /*60.0f Q8*/ + IF( EQ_16( st->ini_frame, 0 ) ) + { + st->prev_bfi = 0; + st->last_core_bfi = -1; + IF( st->hTcxDec != NULL ) + { + hTcxDec->tcxConceal_recalc_exc = 0; + } + } + st->prev_old_bfi = 0; + + IF( st->hTcxDec != NULL ) + { + st->hTcxDec->noise_filling_index[0] = st->hTcxDec->noise_filling_index[1] = 0; + st->hTcxDec->tnsActive[0] = st->hTcxDec->tnsActive[1] = 0; + set16_fx( st->hTcxDec->ltpGainMemory_fx, 0, N_LTP_GAIN_MEMS ); + } + + Copy( st->lsf_old_fx, st->lsf_adaptive_mean_fx, M ); + Copy( st->lsf_old_fx, st->lsfoldbfi0_fx, M ); + Copy( st->lsf_old_fx, st->lsfoldbfi1_fx, M ); + + st->clas_dec = UNVOICED_CLAS; + + IF( !st->last_con_tcx ) + { + st->old_enr_LP = 0; /* LP filter E of last good voiced frame or local LP filter E in TD TCX PLC */ + } + + IF( st->prev_bfi ) + { + /* calculate energy at the end of the previous frame */ + IF( EQ_16( st->core, ACELP_CORE ) && EQ_16( st->last_core, HQ_CORE ) ) + { + st->output_frame_fx = st->hTcxDec->L_frameTCX; + floatToFixed_arr( st->previoussynth, st->previoussynth_fx, 0, 960 ); + frame_ener_fx( st->output_frame_fx, UNVOICED_CLAS, st->previoussynth_fx, -1, &st->enr_old_fx, 1, 0, 0, 0 ); + } + } + ELSE + { + st->last_good = UNVOICED_CLAS; /* last good received frame for concealment */ + st->enr_old_fx = L_deposit_l( 0 ); /* energy at the end of the previous frame */ + } + st->Mode2_lp_gainc = L_deposit_l( 0 ); + st->Mode2_lp_gainp = L_deposit_l( 0 ); + st->lp_gainc_fx = (Word16) L_deposit_l( 0 ); + st->lp_gainp_fx = (Word16) L_deposit_l( 0 ); + + IF( st->hTcxDec != NULL ) + { + st->hTcxDec->prev_widow_left_rect = 0; + + IF( is_init || MCT_flag || !( EQ_16( st->element_mode, IVAS_CPE_MDCT ) && EQ_16( st->element_mode, last_element_mode ) ) ) + { + st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = PLC_MIN_CNG_LEV; + st->hTcxDec->NoiseLevelIndex_bfi = PLC_MIN_STAT_BUFF_SIZE - 1; + st->hTcxDec->CurrLevelIndex_bfi = 0; + st->hTcxDec->LastFrameLevel_bfi_fx = PLC_MIN_CNG_LEV; + set16_fx( st->hTcxDec->NoiseLevelMemory_bfi_fx, PLC_MIN_CNG_LEV, PLC_MIN_STAT_BUFF_SIZE ); + st->hTcxDec->cummulative_damping_tcx = 32767 /*1.0f Q15*/; + } + } + st->cummulative_damping = 32767 /*1.0f Q15*/; + + FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) + { + st->old_pitch_buf_fx[i] = L_deposit_h( st->pit_min ); + } + + FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) + { + st->mem_pitch_gain[i] = 16384 /*1.f Q14*/; /*Q14*/ + } + st->old_fpitch = L_deposit_h( st->pit_min ); + st->rate_switching_init = 1; + + st->reset_mem_AR = 0; + + /* For phase dispersion */ + st->dm_fx.prev_gain_code = L_deposit_l( 0 ); + set16_fx( st->dm_fx.prev_gain_pit, 0, 6 ); + st->dm_fx.prev_state = 0; + move16(); + st->voice_fac = -1; + + /* TCX-LTP */ + IF( hTcxLtpDec != NULL ) + { + tcxltp_dec_init_fx( hTcxLtpDec, st->ini_frame, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); + } + + /* TCX */ + IF( hTcxDec != NULL ) + { + st->old_fpitchFB = L_deposit_h( hTcxDec->pit_min_TCX ); + + IF( EQ_16( st->ini_frame, 0 ) || ( EQ_16( st->last_codec_mode, MODE1 ) && EQ_16( st->element_mode, EVS_MONO ) ) ) + { + hTcxDec->tcxltp_last_gain_unmodified = 0; + } + + /* TCX */ + hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( total_brate, st->rf_flag, st->element_mode ); + + hTcxDec->envWeighted = 0; + } + + IF( st->hBPF != NULL ) + { + st->lp_error_ener = Mpy_32_16_1( L_shl( hBPF->pst_lp_ener_fx, 8 ), 0x2a86 ); /* convert from 7Q8 10*log10 -> 15Q16, log2 */ + hBPF->pst_mem_deemp_err_fx = 0; + } + ELSE + { + st->lp_error_ener = 0; + } + st->mem_error = L_deposit_l( 0 ); + IF( st->tcxonly ) + { + st->p_bpf_noise_buf = NULL; + st->p_bpf_noise_buf_float = NULL; /*To be removed later:Pointer initializations */ + st->p_bpf_noise_buf_32 = NULL; + } + ELSE + { + st->p_bpf_noise_buf = st->bpf_noise_buf; + st->p_bpf_noise_buf_float = st->bpf_noise_buf_float; /*To be removed later:Pointer initializations */ + st->p_bpf_noise_buf_32 = st->bpf_noise_buf_32; + } + IF( EQ_16( bwidth, SWB ) && ( EQ_32( st->total_brate, ACELP_16k40 ) || EQ_32( st->total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) + { + st->tec_tfa = 1; + } + ELSE + { + st->tec_tfa = 0; + } + + st->tec_flag = 0; + st->tfa_flag = 0; + + /* needed in decoder to read the bitstream */ + st->enableGplc = 0; + + st->flagGuidedAcelp = 0; + st->tonal_mdct_plc_active = 0; + st->T0_4th = L_SUBFR; + st->guidedT0 = st->T0_4th; + + IF( st->hPlcInfo != NULL && GE_32( total_brate, HQ_48k ) && EQ_16( st->element_mode, EVS_MONO ) ) + { + st->enablePlcWaveadjust = 1; + + IF( st->hTcxDec != NULL && ( EQ_16( st->ini_frame, 0 ) || LT_32( last_total_brate, HQ_48k ) || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) ) + { + concealment_init_ivas_fx( st->hTcxDec->L_frameTCX, st->hPlcInfo ); + //---------------- To be removed later : Only initializations + st->hPlcInfo->outx_new_n1 = 0.0f; + st->hPlcInfo->nsapp_gain = 0.0f; + st->hPlcInfo->nsapp_gain_n = 0.0f; + st->hPlcInfo->ener_mean = 59.4260f; + st->hPlcInfo->ener = 0.0f; + st->hPlcInfo->recovery_gain_float = 0.0f; + st->hPlcInfo->step_concealgain = 0.0f; + //-------------------To be removed later + } + } + ELSE + { + st->enablePlcWaveadjust = 0; + } + + /* PLC: [TCX: Tonal Concealment] */ + IF( st->hTonalMDCTConc != NULL && !( GT_16( st->element_mode, EVS_MONO ) && NE_16( st->ini_frame, 0 ) && EQ_16( st->hTonalMDCTConc->nSamples, st->hTcxDec->L_frameTCX ) ) ) + { + st->hTonalMDCTConc->nScaleFactors = 0; + st->hTonalMDCTConc->nSamples = 0; + st->hTonalMDCTConc->lastPcmOut = 0x0; + //----------To be removed later: pointer initializations + st->hTonalMDCTConc->lastPcmOut_float = 0x0; + //---------- + st->hTonalMDCTConc->lastPcmOut_float = 0x0; + st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; + st->hTonalMDCTConc->lastBlockData.nSamples = 0; + TonalMDCTConceal_Init_ivas_fx( st->hTonalMDCTConc, st->hTcxDec->L_frameTCX, st->L_frame, FDNS_NPTS, st->hTcxCfg ); + // To be removed later: Float pointer initiaizations----------------- + st->hTonalMDCTConc->lastBlockData.spectralData_float = st->hTonalMDCTConc->spectralDataBuffers_float[0]; + st->hTonalMDCTConc->secondLastBlockData.spectralData_float = st->hTonalMDCTConc->spectralDataBuffers_float[1]; + st->hTonalMDCTConc->secondLastPowerSpectrum_float = st->hTonalMDCTConc->secondLastBlockData.spectralData_float; + st->hTonalMDCTConc->lastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[0]; + st->hTonalMDCTConc->secondLastBlockData.scaleFactors_float = st->hTonalMDCTConc->scaleFactorsBuffers_float[1]; + st->hTonalMDCTConc->pTCI_float = (TonalComponentsInfo_float *) st->hTonalMDCTConc->timeDataBuffer_float; + st->hTonalMDCTConc->lastPitchLag_float = 0; + st->hTonalMDCTConc->scf_fadeout_flt = 1.0f; + st->hTonalMDCTConc->last_block_nrg_flt = 0.0f; + st->hTonalMDCTConc->curr_noise_nrg_flt = 0.0f; + st->hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; + st->hTonalMDCTConc->secondLastPcmOut_float = &st->hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - imult1616( 3, shr( s_min( L_FRAME_MAX, st->hTcxDec->L_frameTCX ), 1 ) )]; + st->hTonalMDCTConc->lastPcmOut_float = &st->hTonalMDCTConc->timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2 - s_min( L_FRAME_MAX, st->hTcxDec->L_frameTCX )]; + //---------------To be removed later + assert( sizeof( *st->hTonalMDCTConc->pTCI_float ) <= ( st->hTonalMDCTConc->lastPcmOut_float - st->hTonalMDCTConc->timeDataBuffer_float ) * sizeof( st->hTonalMDCTConc->timeDataBuffer_float[0] ) ); + } + + st->last_tns_active = 0; + st->second_last_tns_active = 0; + st->second_last_core = -1; + + IF( st->hTcxCfg != NULL && NE_16( st->element_mode, EVS_MONO ) ) + { + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( is_init ? total_brate : L_mult(st->bits_frame_nominal , (FRAMES_PER_SEC>>1)), st->igf, st->element_mode ); + } + IF( hTcxDec != NULL ) + { + hTcxDec->tcxltp_second_last_pitch = st->old_fpitch; + move16(); + hTcxDec->tcxltp_third_last_pitch = st->old_fpitch; + move16(); + } + + IF( ( EQ_32( total_brate, ACELP_9k60 ) || EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_32( st->element_mode, EVS_MONO ) ) + { + st->dec_glr = 1; + } + ELSE + { + st->dec_glr = 0; + } + + st->dec_glr_idx = 0; + + st->VAD = 0; + IF( hTcxDec != NULL ) + { + hTcxDec->enableTcxLpc = 1; + hTcxDec->old_gaintcx_bfi = 0; + hTcxDec->old_gaintcx_bfi_e = 0; + + hTcxDec->tcx_hm_LtpPitchLag = -1; + } + + IF( st->hTcxCfg != NULL ) + { + st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/; + } + + return; +} +#endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/core_dec_reconf_fx.c b/lib_dec/core_dec_reconf_fx.c index 6ecfa7ab1..a0eb87715 100644 --- a/lib_dec/core_dec_reconf_fx.c +++ b/lib_dec/core_dec_reconf_fx.c @@ -11,6 +11,177 @@ #include "rom_com.h" +#ifdef IVAS_FLOAT_FIXED +void reconfig_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bits_frame, /* i : bit budget */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 total_brate, /* i : total bitrate */ + const Word16 L_frame_old /* i : frame length */ +) +{ + UWord16 newLen, oldLen; + TCX_LTP_DEC_HANDLE hTcxLtpDec = st->hTcxLtpDec; + TCX_DEC_HANDLE hTcxDec = st->hTcxDec; + + Word32 lowrate_tcxlpc_max_br; + move16(); + st->bits_frame = bits_frame; + + IF( EQ_16( bwidth, NB ) ) + { + move16(); + st->narrowBand = 1; + } + ELSE IF( GT_16( bwidth, NB ) ) + { + move16(); + st->narrowBand = 0; + } + + BITS_ALLOC_init_config_acelp( st->total_brate, st->narrowBand, st->nb_subfr, &( st->acelp_cfg ) ); + + /*Configuration of partial copy*/ + st->acelp_cfg_rf.mode_index = 1; + st->acelp_cfg_rf.midLpc = 0; + st->acelp_cfg_rf.midLpc_enable = 0; + st->acelp_cfg_rf.pre_emphasis = 0; + st->acelp_cfg_rf.formant_enh = 1; + st->acelp_cfg_rf.formant_tilt = 1; + st->acelp_cfg_rf.voice_tilt = 1; + st->acelp_cfg_rf.formant_enh_num = FORMANT_SHARPENING_G1; + st->acelp_cfg_rf.formant_enh_den = FORMANT_SHARPENING_G2; + + IF( NE_16( st->element_mode, IVAS_SCE ) ) + { + st->flag_cna = getCnaPresent_fx( st->element_mode, st->element_brate, total_brate, bwidth ); + } + + /* TCX-LTP */ + IF( hTcxLtpDec != NULL ) + { + hTcxLtpDec->tcxltp = getTcxLtp( st->sr_core ); + } + move16(); + + /*Scale TCX for non-active frames to adjust loudness with ACELP*/ + IF( st->hTcxCfg != NULL ) + { + Word16 i; + st->hTcxCfg->na_scale = 32767 /*1.0f Q15*/; + test(); + IF( ( LT_16( bwidth, SWB ) ) && !( st->tcxonly ) ) + { + FOR( i = 0; i < SIZE_SCALE_TABLE_TCX; i++ ) + { + test(); + test(); + IF( ( EQ_16( bwidth, scaleTcxTable[i].bwmode ) ) && + ( GE_32( total_brate, scaleTcxTable[i].bitrateFrom ) ) && + ( LT_32( total_brate, scaleTcxTable[i].bitrateTo ) ) ) + { + IF( st->rf_flag ) + { + i--; + } + st->hTcxCfg->na_scale = scaleTcxTable[i].scale; + move16(); + BREAK; + } + } + } + } + IF( st->hTcxCfg != NULL ) + { + st->hTcxCfg->na_scale_flt = fixedToFloat( st->hTcxCfg->na_scale, 15 ); + } + /*if its not the first frame resample overlap buffer to new sampling rate */ + IF( NE_16(st->ini_frame , 0 )) + { + test(); + test(); + test(); + IF( st->hTcxCfg != NULL && + ( NE_16( st->fscale, st->fscale_old ) && + !( EQ_16( st->element_mode, EVS_MONO ) && + EQ_16( st->last_codec_mode, MODE1 ) && + EQ_16( st->last_core, ACELP_CORE ) && NE_16(st->prev_bfi , 0 ) ) )) + /* no resempling is needed here when recovering from mode 1 + ACELP PLC, since the buffers are already sampled with the + correct sampling rate in open_decoder_LPD() */ + { + newLen = st->hTcxCfg->tcx_mdct_window_length; + oldLen = st->hTcxCfg->tcx_mdct_window_length_old; + + move16(); + move16(); + test(); + test(); + IF( ( st->prev_bfi && EQ_16( st->last_core_bfi, ACELP_CORE ) ) || EQ_16( st->last_core, ACELP_CORE ) ) + { + newLen = shr( st->L_frame, 1 ); + oldLen = shr( L_frame_old, 1 ); + } + + IF( st->hTcxDec != NULL ) + { + lerp( hTcxDec->old_syn_Overl, hTcxDec->old_syn_Overl, newLen, oldLen ); + lerp( hTcxDec->syn_Overl, hTcxDec->syn_Overl, newLen, oldLen ); + + test(); + IF( st->prev_bfi && EQ_16( st->last_core_bfi, ACELP_CORE ) ) + { + lerp( hTcxDec->syn_Overl_TDAC, hTcxDec->syn_Overl_TDAC, newLen, oldLen ); + } + } + } + + IF( LE_16( st->L_frame, L_FRAME16k ) ) + { + IF( LE_16( st->last_L_frame, L_FRAME16k ) ) + { + IF( NE_16( st->L_frame, st->last_L_frame ) ) + { + IF( GT_16( st->L_frame, st->last_L_frame ) ) + { + oldLen = extract_l( L_shr( Mpy_32_16_1( L_mult0( st->last_L_frame, getInvFrameLen( st->L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); + newLen = L_SYN_MEM_CLAS_ESTIM; + } + ELSE + { + oldLen = L_SYN_MEM_CLAS_ESTIM; + newLen = extract_l( L_shr( Mpy_32_16_1( L_mult0( st->L_frame, getInvFrameLen( st->last_L_frame ) /*Q21*/ ) /*Q21*/, L_SYN_MEM_CLAS_ESTIM /*Q0*/ ) /*Q6*/, 6 ) /*Q0*/ ); + } + lerp( &st->mem_syn_clas_estim_fx[sub( L_SYN_MEM_CLAS_ESTIM, oldLen )], &st->mem_syn_clas_estim_fx[sub( L_SYN_MEM_CLAS_ESTIM, newLen )], newLen, oldLen ); + } + } + ELSE + { + set16_fx( st->mem_syn_clas_estim_fx, 0, L_SYN_MEM_CLAS_ESTIM ); + } + } + } + + test(); + test(); + lowrate_tcxlpc_max_br = LOWRATE_TCXLPC_MAX_BR; + move16(); + IF( GT_16( st->element_mode, IVAS_SCE ) ) + { + lowrate_tcxlpc_max_br = LOWRATE_TCXLPC_MAX_BR_CPE; + } + hTcxDec->enableTcxLpc = EQ_16( st->numlpc, 1 ) && EQ_16( st->lpcQuantization, 1 ) && ( LE_32( total_brate, lowrate_tcxlpc_max_br ) /*LOWRATE_TCXLPC_MAX_BR*/ || st->rf_flag ); + + IF( EQ_16(st->ini_frame , 0 )) + { + hTcxDec->envWeighted = 0; + move16(); + } + + return; +} +#endif + void reconfig_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ Word16 bits_frame, /* i : bit budget */ diff --git a/lib_dec/core_dec_switch_fx.c b/lib_dec/core_dec_switch_fx.c index e1e99540a..19d85c467 100644 --- a/lib_dec/core_dec_switch_fx.c +++ b/lib_dec/core_dec_switch_fx.c @@ -10,6 +10,9 @@ #include "prot_fx2.h" #include "rom_com.h" + //Temporarily added +#include "prot.h" + void mode_switch_decoder_LPD( Decoder_State *st, /* i/o: decoder state structure */ @@ -251,3 +254,237 @@ void mode_switch_decoder_LPD( } +#ifdef IVAS_FLOAT_FIXED +void mode_switch_decoder_LPD_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word32 total_brate, /* i : total bitrate */ + const Word32 last_total_brate, /* i : last frame total bitrate */ + const Word16 frame_size_index, /* i : index determining the frame size */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 last_element_mode, /* i : last element mode */ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 +) +{ + Word16 fscale, switchWB; + Word32 sr_core; + Word16 bSwitchFromAmrwbIO; + Word16 frame_size; + TCX_DEC_HANDLE hTcxDec; + TD_BWE_DEC_HANDLE hBWE_TD; + + hTcxDec = st->hTcxDec; + hBWE_TD = st->hBWE_TD; + switchWB = 0; + move16(); + bSwitchFromAmrwbIO = 0; + move16(); + IF( EQ_16( st->last_core, AMR_WB_CORE ) ) + { + bSwitchFromAmrwbIO = 1; + move16(); + } + sr_core = getCoreSamplerateMode2( st->element_mode, total_brate, bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); + fscale = sr2fscale_fx( sr_core ); + move16(); + + /* set number of coded lines */ + st->hTcxCfg->tcx_coded_lines = getNumTcxCodedLines( bwidth ); + test(); + test(); + + IF( ( GE_16( bwidth, WB ) ) && ( EQ_16( fscale, ( FSCALE_DENOM * 16000 ) / 12800 ) ) && ( EQ_16( fscale, st->fscale ) ) ) + { + test(); + test(); + test(); + IF( ( ( GT_32( total_brate, ACELP_32k ) ) && ( st->tcxonly == 0 ) ) || ( ( LE_32( total_brate, ACELP_32k ) ) && EQ_16( st->tcxonly, 1 ) ) ) + { + switchWB = 1; + move16(); + } + } + + test(); + IF( GT_16( st->last_L_frame, L_FRAME16k ) && LE_32( total_brate, ACELP_32k ) ) + { + switchWB = 1; /*force init when coming from MODE1*/ + move16(); + } + + st->igf = getIgfPresent_fx( st->element_mode, total_brate, bwidth, st->rf_flag ); + + IF( st->hIGFDec != NULL ) + { + st->hIGFDec->infoIGFStopFreq = -1; + } + + move16(); + test(); + test(); + IF( st->igf && ( st->idchan == 0 || EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) ) + { + /* switch IGF configuration */ + IGFDecSetMode_ivas_fx( st->hIGFDec, total_brate, bwidth, st->element_mode, -1, -1, st->rf_flag ); + } + test(); + test(); + test(); + test(); + + assert( (Word16) ( st->sr_core / FRAMES_PER_SEC ) == extract_l( Mult_32_16( st->sr_core, 0x0290 ) ) ); + IF( NE_16( fscale, st->fscale ) || switchWB || bSwitchFromAmrwbIO || EQ_16( st->last_codec_mode, MODE1 ) || st->force_lpd_reset ) + { + open_decoder_LPD_ivas_fx( st, total_brate, last_total_brate, bwidth, MCT_flag, last_element_mode, 0, Q_syn_Overl_TDAC, Q_fer_samples, Q_syn_Overl, Q_syn_Overl_TDACFB, Q_syn_OverlFB, Q_old_out, Q_old_outLB, Q_old_Aq_12_8 ); + } + ELSE + { + assert( fscale > ( FSCALE_DENOM / 2 ) ); + st->fscale_old = st->fscale; + move16(); + st->fscale = fscale; + move16(); + st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); + IF( st->hTcxDec != NULL ) + { + st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); + } + + IF( st->hTcxCfg != NULL ) + { + st->hTcxCfg->ctx_hm = getCtxHm( st->element_mode, total_brate, st->rf_flag ); + st->hTcxCfg->resq = getResq( total_brate ); + } + move16(); + + hTcxDec->tcx_lpc_shaped_ari = getTcxLpcShapedAri( total_brate, st->rf_flag, st->element_mode ); + + st->narrowBand = 0; + move16(); + IF( EQ_16( bwidth, NB ) ) + { + st->narrowBand = 1; + move16(); + } + ELSE + { + st->narrowBand = 0; + } + st->TcxBandwidth = getTcxBandwidth( bwidth ); + + IF( st->hTcxCfg != NULL ) + { + st->hTcxCfg->pCurrentTnsConfig = NULL; + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( total_brate, st->igf, st->element_mode ); + move16(); + } + + IF( st->hTcxCfg->fIsTNSAllowed && st->hIGFDec != NULL && st->hTcxCfg != NULL ) + { + InitTnsConfigs( bwidth, st->hTcxCfg->tcx_coded_lines, st->hTcxCfg->tnsConfig, st->hIGFDec->infoIGFStopFreq, total_brate, st->element_mode, MCT_flag ); + + SetAllowTnsOnWhite( st->hTcxCfg->tnsConfig, EQ_16(st->element_mode , IVAS_CPE_MDCT) ); + } + } + + frame_size = FrameSizeConfig[frame_size_index].frame_net_bits; + move16(); + reconfig_decoder_LPD_ivas_fx( st, frame_size, bwidth, total_brate, st->last_L_frame ); + + test(); + IF( hTcxDec->envWeighted && !hTcxDec->enableTcxLpc ) + { + Copy( st->lspold_uw, st->lsp_old_fx, M ); + Copy( st->lsfold_uw, st->lsf_old_fx, M ); + hTcxDec->envWeighted = 0; + move16(); + } + /* update PLC LSF memories */ + IF( EQ_16( st->tcxonly, 0 ) ) + { + lsp2lsf_fx( st->lsp_old_fx, st->lsfoldbfi1_fx, M, extract_l( st->sr_core ) ); + } + ELSE + { + E_LPC_lsp_lsf_conversion( st->lsp_old_fx, st->lsfoldbfi1_fx, M ); + } + Copy( st->lsfoldbfi1_fx, st->lsfoldbfi0_fx, M ); + Copy( st->lsfoldbfi1_fx, st->lsf_adaptive_mean_fx, M ); + + IF( st->igf && hBWE_TD != NULL ) + { + test(); + test(); + test(); + test(); + test(); + /* reset TBE */ + IF( ( EQ_16( st->bwidth, WB ) && NE_16( st->last_extl, WB_TBE ) ) || + ( EQ_16( st->bwidth, SWB ) && NE_16( st->last_extl, SWB_TBE ) ) || + ( EQ_16( st->bwidth, FB ) && NE_16( st->last_extl, FB_TBE ) ) ) + { + TBEreset_dec_ivas_fx( st ); + } + ELSE + { + set16_fx( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); + set16_fx( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); + set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); + hBWE_TD->gain_prec_swb_fx = 16384; + move16(); /*Q14 = 1 */ + } + } + test(); + test(); + IF( EQ_16( bwidth, SWB ) && ( EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) + { + IF( EQ_16( st->tec_tfa, 0 ) && st->hTECDec != NULL ) + { + set16_fx( st->hTECDec->loBuffer, 0, MAX_TEC_SMOOTHING_DEG ); + } + st->tec_tfa = 1; + move16(); + } + ELSE + { + st->tec_tfa = 0; + move16(); + } + + st->tec_flag = 0; + move16(); + st->tfa_flag = 0; + move16(); + + /* needed in decoder to read the bitstream */ + st->enableGplc = 0; + move16(); + test(); + test(); + IF( GE_16( bwidth, WB ) && EQ_32( total_brate, ACELP_24k40 ) && EQ_16( st->element_mode, EVS_MONO ) ) + { + st->enableGplc = 1; + move16(); + } + move16(); + st->dec_glr = 0; + test(); + test(); + test(); + IF( ( EQ_32( total_brate, ACELP_9k60 ) || EQ_32( total_brate, ACELP_16k40 ) || EQ_32( total_brate, ACELP_24k40 ) ) && EQ_16( st->element_mode, EVS_MONO ) ) + { + st->dec_glr = 1; + move16(); + } + move16(); + st->dec_glr_idx = 0; +} +#endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/dec_prm_fx.c b/lib_dec/dec_prm_fx.c index 44b8b606b..fe1f73521 100644 --- a/lib_dec/dec_prm_fx.c +++ b/lib_dec/dec_prm_fx.c @@ -31,7 +31,7 @@ void getLPCparam( IF( EQ_16( st->use_partial_copy, 0 ) ) { /* Number of sets of LPC parameters (does not include mid-lpc) */ - IF( ( st->tcxonly, 0 ) || LT_16( st->core, TCX_10_CORE ) ) + IF( EQ_16( st->tcxonly, 0 ) || LT_16( st->core, TCX_10_CORE ) ) { st->numlpc = 1; } @@ -313,7 +313,7 @@ void getTCXparam( last_core = TCX_20_CORE; } - SetTnsConfig( st->hTcxCfg, EQ_16( core, TCX_20_CORE ), EQ_16( st->last_core_from_bs, ACELP_CORE ) && ( k == 0 ) ); + SetTnsConfig( st->hTcxCfg, (Word16)EQ_16( core, TCX_20_CORE ), (Word16)EQ_16( st->last_core_from_bs, ACELP_CORE ) && ( k == 0 ) ); ix = 0; IF( no_param_tns ) @@ -347,7 +347,6 @@ void getTCXparam( IF( EQ_16( core, TCX_20_CORE ) ) { // Q-factor of TcxBandwidth is 15 : derived from getTcxBandwidth function - st->TcxBandwidth = (Word16)floatToFixed( st->TcxBandwidth_float, 15 ); hm_size = mult( st->TcxBandwidth, shl( lg, 1 ) ); IF( hTcxDec->tcx_lpc_shaped_ari && NE_16( st->last_core_from_bs, ACELP_CORE ) ) @@ -359,7 +358,6 @@ void getTCXparam( } ELSE { - st->TcxBandwidth = (Word16)floatToFixed( st->TcxBandwidth_float, 15 ); hm_size = mult( st->TcxBandwidth, shl( lgFB, 1 ) ); nbits_tcx = sub( shr( sub( add( sub( sub( st->bits_frame_core, bits_common ), nbits_igf ), 1 ), k ), 1 ), sub( sub( st0->next_bit_pos, start_bit_pos ), nbits_tcx ) ); } @@ -373,7 +371,7 @@ void getTCXparam( IF( useHarmonicModel ) { - ix = DecodeIndex_fx( st0, GE_16( hm_size, 256 ), prm + add( j, 1 ) ); + ix = DecodeIndex_fx( st0, (Word16)GE_16( hm_size, 256 ), prm + add( j, 1 ) ); flag_ctx_hm = 1; PeriodicityIndex = *( prm + add( j, 1 ) ); @@ -1537,7 +1535,7 @@ void dec_prm( IF (prm[j]) /* Read PeriodicityIndex */ { - Word16 NumIndexBits = DecodeIndex_fx(st,GE_16(hm_size , 256),prm+j+1); + Word16 NumIndexBits = DecodeIndex_fx(st,(Word16)GE_16(hm_size , 256),prm+j+1); flag_ctx_hm = 1; move16(); diff --git a/lib_dec/igf_dec_fx.c b/lib_dec/igf_dec_fx.c index 5839ae1b0..79e578f77 100644 --- a/lib_dec/igf_dec_fx.c +++ b/lib_dec/igf_dec_fx.c @@ -16,6 +16,8 @@ #include "cnst.h" #include "stat_dec.h" #include "basop_util.h" +//Temporarily added +#define MID 57/* (.89*1<<6)*/ /**********************************************************************/ /* get scalefactor of an Word32 array with condition @@ -1312,7 +1314,7 @@ static void IGF_RefineGrid(H_IGF_GRID hGrid #endif a[tmp] = add(hGrid->swb_offset[sfb], shr(delta, 6)); move16(); - if (s_and(a[tmp], 1) != 0) + IF(s_and(a[tmp], 1) != 0) { a[tmp] = sub(a[tmp], 1); move16(); @@ -1333,6 +1335,63 @@ static void IGF_RefineGrid(H_IGF_GRID hGrid } +#ifdef IVAS_FLOAT_FIXED +static void IGF_RefineGrid_ivas_fx( H_IGF_GRID hGrid /**< in/out: | IGF grid handle */ +) +{ + Word16 a[IGF_MAX_SFB + 1]; + Word16 sfb; + Word16 tmp; + Word16 delta; +#ifdef BASOP_NOGLOB_DECLARE_LOCAL + Flag Overflow = 0; +#endif + + set16_fx( a, 0, IGF_MAX_SFB + 1 ); + + + hGrid->infoIsRefined = 1; + move16(); + FOR( sfb = 0; sfb < hGrid->swb_offset_len; sfb++ ) + { + tmp = shl( sfb, 1 ); + a[tmp] = hGrid->swb_offset[sfb]; + move16(); + tmp = add( tmp, 1 ); + delta = sub( hGrid->swb_offset[sfb + 1], hGrid->swb_offset[sfb] ); +#ifdef BASOP_NOGLOB /* TBV for 16 kHz, 9.6kbps dtx condition, hGrid->swb_offset[sfb+1] points to an uninit value */ + delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl_o( delta, 5, &Overflow ) ); +#else + delta = mac_r( 0x00195000, 29491 /*0.45f Q16*/, shl( delta, 5 ) ); +#endif + a[tmp] = add( hGrid->swb_offset[sfb], shr( delta, 6 ) ); + move16(); + // Rounding off delta values >=t+0.5 to t+1 + IF( GE_16( sub( delta, shl( shr( delta, 6 ), 6 ) ), MID ) ) + { + a[tmp] = add( a[tmp], 1 ); + } + move16(); + IF( s_and( a[tmp], 1 ) != 0 ) + { + a[tmp] = sub( a[tmp], 1 ); + move16(); + } + } + hGrid->stopSfb = shl( hGrid->stopSfb, 1 ); + FOR( sfb = 0; sfb <= hGrid->stopSfb; sfb++ ) + { + hGrid->swb_offset[sfb] = a[sfb]; + move16(); + } + + FOR( sfb = 0; sfb <= hGrid->nTiles; sfb++ ) + { + hGrid->sfbWrap[sfb] = shl( hGrid->sfbWrap[sfb], 1 ); + move16(); + } +} +#endif // IVAS_FLOAT_FIXED /**********************************************************************/ /* reads whitening information from the bitstream **************************************************************************/ @@ -1652,6 +1711,69 @@ void IGFDecSetMode( } +#ifdef IVAS_FLOAT_FIXED +void IGFDecSetMode_ivas_fx( + const IGF_DEC_INSTANCE_HANDLE hIGFDec, /* i : instance handle of IGF Decoder */ + const Word32 total_brate, /* i : bitrate */ + const Word16 bwidth, /* i : audio bandwidth */ + const Word16 element_mode, /* i : IVAS element mode */ + const Word16 defaultStartLine, /* i : default start subband index */ + const Word16 defaultStopLine, /* i : default stop subband index */ + const Word16 rf_mode /* i : flag to signal the RF mode */ +) +{ + IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; + + hPrivateData = &hIGFDec->igfData; + hIGFDec->isIGFActive = 0; + move16(); + + IF( IGFCommonFuncsIGFConfiguration_ivas_fx( total_brate, bwidth, element_mode, &hPrivateData->igfInfo, rf_mode ) ) + { + IGFSCFDecoderOpen( &hPrivateData->hArithSCFdec, &hPrivateData->igfInfo, total_brate, bwidth, element_mode, rf_mode ); + + hIGFDec->infoIGFAllZero = 0; + move16(); + hIGFDec->isIGFActive = 1; + move16(); + hIGFDec->infoIGFStopLine = hPrivateData->igfInfo.grid[0].stopLine; + move16(); + hIGFDec->infoIGFStartLine = hPrivateData->igfInfo.grid[0].startLine; + move16(); + hIGFDec->infoIGFStopFreq = hPrivateData->igfInfo.grid[0].stopFrequency; + move16(); + hIGFDec->infoIGFStartFreq = hPrivateData->igfInfo.grid[0].startFrequency; + move16(); + + test(); + /* no refinement if maxHopsize is 1 */ + IF( NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_96000 ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_96000_CPE ) && + NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_128000 ) && NE_16( hPrivateData->igfInfo.bitRateIndex, IGF_BITRATE_FB_128000_CPE ) ) + { + IGF_RefineGrid_ivas_fx( &hPrivateData->igfInfo.grid[IGF_GRID_LB_NORM] ); + IGF_RefineGrid_ivas_fx( &hPrivateData->igfInfo.grid[IGF_GRID_LB_TRAN] ); + IGF_RefineGrid_ivas_fx( &hPrivateData->igfInfo.grid[IGF_GRID_LB_SHORT] ); + } + /* IGFDecOutInformation(hIGFDec); */ + } + ELSE + { + hIGFDec->infoIGFStopLine = defaultStopLine; + move16(); + hIGFDec->infoIGFStartLine = defaultStartLine; + move16(); + hIGFDec->infoIGFStopFreq = -1; + move16(); + hIGFDec->infoIGFStartFreq = -1; + move16(); + IVAS_ERROR( IVAS_ERR_INTERNAL, "IGFDecSetMode: initialization error!" ); + } + + hIGFDec->flag_sparse = &hIGFDec->flag_sparseBuf[0]; + hIGFDec->infoTCXNoise = &hIGFDec->infoTCXNoiseBuf[0]; + return; +} +#endif // IVAS_FLOAT_FIXED /**********************************************************************/ /* updates the start/stop frequency of IGF according to igfGridIdx **************************************************************************/ diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 660b70d68..a7a8cb208 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -52,6 +52,10 @@ static void dec_prm_tcx( Decoder_State *st, int16_t param[], int16_t param_lpc[] static void stereo_tcx_dec_mode_switch_reconf( Decoder_State *st, const int16_t MCT_flag, const int16_t last_element_mode ); +#ifdef IVAS_FLOAT_FIXED +static void dec_prm_tcx_ivas_fx(Decoder_State *st, Word16 param[], Word16 param_lpc[], Word16 *total_nbbits, const Word16 last_element_mode, Word16 *bitsRead); +static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( Decoder_State *st, const Word16 MCT_flag, const Word16 last_element_mode, Word16 *Q_syn_Overl_TDAC, Word16 *Q_fer_samples, Word16 *Q_syn_Overl, Word16 *Q_syn_Overl_TDACFB, Word16 *Q_syn_OverlFB, Word16 *Q_old_out, Word16 *Q_old_outLB, Word16 *Q_old_Aq_12_8 ); +#endif // IVAS_FLOAT_FIXED /*-------------------------------------------------------------* * stereo_tcx_init_dec() * @@ -263,7 +267,11 @@ void stereo_tcx_core_dec( { st->second_last_core = st->last_core; +#ifdef IVAS_FLOAT_FIXED + dec_prm_tcx_ivas_fx(st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead); +#else dec_prm_tcx( st, param, param_lpc, &total_nbbits, last_element_mode, &bitsRead ); +#endif // IVAS_FLOAT_FIXED } else { @@ -949,3 +957,796 @@ static void stereo_tcx_dec_mode_switch_reconf( return; } +#ifdef IVAS_FLOAT_FIXED +static void stereo_tcx_dec_mode_switch_reconf_ivas_fx( + Decoder_State *st, /* i/o: decoder state structure */ + const Word16 MCT_flag, /* i : hMCT handle allocated (1) or not (0)*/ + const Word16 last_element_mode, /* i : element mode of previous frame */ + Word16 *Q_syn_Overl_TDAC, + Word16 *Q_fer_samples, + Word16 *Q_syn_Overl, + Word16 *Q_syn_Overl_TDACFB, + Word16 *Q_syn_OverlFB, + Word16 *Q_old_out, + Word16 *Q_old_outLB, + Word16 *Q_old_Aq_12_8 +) +{ + Word16 frame_size_index; + + st->rate_switching_init = 1; + + /* Identify frame type - TCX Reconfiguration */ + FOR( frame_size_index = 0; frame_size_index < FRAME_SIZE_NB; frame_size_index++ ) + { + IF( LT_16( frame_size_index, sub( FRAME_SIZE_NB, 1 ) ) ) + { + IF( LE_16( FrameSizeConfig[frame_size_index].frame_bits, st->bits_frame_nominal ) && GT_16( FrameSizeConfig[add( frame_size_index, 1 )].frame_bits, st->bits_frame_nominal ) ) + { + BREAK; + } + } + ELSE + { + IF( LE_16( FrameSizeConfig[frame_size_index].frame_bits, st->bits_frame_nominal ) ) + { + BREAK; + } + } + } + + /* Reconfigure Core */ + mode_switch_decoder_LPD_ivas_fx( st, st->bwidth, st->bits_frame_nominal * FRAMES_PER_SEC, st->last_bits_frame_nominal * FRAMES_PER_SEC, frame_size_index, MCT_flag, last_element_mode,Q_syn_Overl_TDAC, Q_fer_samples, Q_syn_Overl, Q_syn_Overl_TDACFB, Q_syn_OverlFB, Q_old_out, Q_old_outLB, Q_old_Aq_12_8); + + return; +} +static void dec_prm_tcx_ivas_fx( + Decoder_State *st, /* i/o: decoder memory state */ + Word16 param[], /* o : decoded parameters */ + Word16 param_lpc[], /* o : LPC parameters */ + Word16 *total_nbbits, /* i/o: number of bits / decoded bits */ + const Word16 last_element_mode, /* i : last element mode */ + Word16 *bitsRead /* o : number of read bits */ +) +{ +#if 1/*--------------Float to fixed changes----------------*/ + H_IGF_GRID hGrid; + IGF_DEC_PRIVATE_DATA_HANDLE hPrivateData; + hPrivateData = &st->hIGFDec->igfData; + H_IGF_INFO hIGFInfo = &hPrivateData->igfInfo; + hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; + floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); + hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); + hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); + hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); + hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; + floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); + hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); + hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); + hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); + hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; + floatToFixed_arr( &hGrid->whiteningThreshold_flt[0][0], &hGrid->whiteningThreshold[0][0], 13, IGF_MAX_TILES * 2 ); + hGrid->gFactor = (Word16) floatToFixed( hGrid->gFactor_flt, 14 ); + hGrid->fFactor = (Word16) floatToFixed( hGrid->fFactor_flt, 14 ); + hGrid->lFactor = (Word16) floatToFixed( hGrid->lFactor_flt, 14 ); + Word16 i = 0, + Q_old_syn_Overl=0, Q_syn_Overl_TDAC=0, Q_syn_Overl=0, Q_syn_Overl_TDACFB=0, Q_syn_OverlFB=0, + Q_old_synth=0, Q_syn=0, Q_synth_history=0, Q_mem_syn_r=0, Q_old_exc=0, Q_fer_samples=0, Q_old_out=0, + Q_old_outLB=0, Q_mem_syn2=0, Q_cldfbAna_cldfb_state=0, Q_cldfbBPF_cldfb_state=0, Q_cldfbSyn_cldfb_state=0, Q_cldfbSynHB_cldfb_state=0, + Q_state_lpc_syn=0, Q_state_syn_shbexc=0, Q_mem_stp_swb=0, Q_mem_zero_swb=0, Q_old_Aq_12_8 = 12, Q_pst_old_syn=0, Q_mem_stp=0, Q_mem_pf_in=0, + Q_mem_res2=0, delay_comp=0, Q_loBuffer=0; + delay_comp = NS2SA_fx2( st->output_Fs, DELAY_CLDFB_NS ); /*CLDFB delay*/ + st->sr_core = getCoreSamplerateMode2( st->element_mode, st->bits_frame_nominal * FRAMES_PER_SEC, st->bwidth, st->flag_ACELP16k, st->rf_flag, st->is_ism_format ); + st->L_frame = extract_l( Mult_32_16( st->sr_core, 0x0290 ) ); + st->preemph_fac = (Word16) floatToFixed( st->preemph_fac_float, 15 ); + Q_syn = Q_factor_arr( st->syn_float, 17 ); + Q_old_exc = Q_factor_arr( st->old_exc, L_EXC_MEM_DEC ) - 1; + Q_mem_syn_r = Q_factor_arr( st->mem_syn_r_float, L_SYN_MEM ) - 1; + Q_mem_syn2 = Q_mem_syn_r; + floatToFixed_arr( st->old_exc, st->old_exc_fx, Q_old_exc, L_EXC_MEM_DEC ); + floatToFixed_arr( st->mem_syn_r_float, st->mem_syn_r, Q_mem_syn_r, L_SYN_MEM ); + floatToFixed_arr( st->syn_float, st->syn, Q_syn, M + 1 ); + floatToFixed_arr( st->lsp_old, st->lsp_old_fx, 15, M ); + floatToFixed_arr( st->lspold_uw_float, st->lspold_uw, 15, M ); + floatToFixed_arr( st->mem_syn2, st->mem_syn2_fx, Q_mem_syn2, M ); + FOR( i = 0; i < M; i++ ) + { + st->mem_MA_fx[i] = (Word16) floatToFixed( st->mem_MA[i] * 2.56, 0 ); + st->mem_AR_fx[i] = (Word16) floatToFixed( st->mem_AR[i] * 2.56, 0 ); + st->lsf_old_fx[i] = (Word16) floatToFixed( st->lsf_old[i] * 2.56, 0 ); + st->lsfold_uw[i] = (Word16) floatToFixed( st->lsfold_uw_float[i] * 2.56, 0 ); + } + IF( st->hTcxCfg ) + { + st->hTcxCfg->preemph_fac = (Word16) floatToFixed( st->hTcxCfg->preemph_fac_flt, 15 ); + st->hTcxCfg->sq_rounding = (Word16) floatToFixed( st->hTcxCfg->sq_rounding_flt, 15 ); + st->hTcxCfg->bandwidth = (Word16) floatToFixed( st->hTcxCfg->bandwidth_flt, 15 ); + st->hTcxCfg->na_scale = (Word16) floatToFixed( st->hTcxCfg->na_scale_flt, 15 ); + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_windowFB[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_windowFB_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_windowFB[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_trans[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_trans_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window_trans[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_transFB[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_transFB_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window_transFB[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_half[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_half_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window_half[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_halfFB_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_minimum[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_minimum_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window_minimum[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1], 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i], 15 ); + st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_mdct_window_minimumFB_flt[st->hTcxCfg->tcx_mdct_window_min_lengthFB - i - 1], 15 ); + } + Word16 n = st->L_frame; + Word16 n0 = shr( imult1616( n, 9 ), 5 ); + Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ + Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ + FOR( i = 0; i < n0; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1[i] = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[i], 15 ); + } + FOR( i = n0; i < n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[i], 15 ); + } + FOR( i = 0; i < n1 - n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i], 15 ); + } + FOR( i = 0; i < n2 / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_flt[i], 15 ); + } + FOR( i = n2 / 2; i < n2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_flt[i], 15 ); + } + n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); + n0 = shr( imult1616( n, 9 ), 5 ); + n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ + n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ + FOR( i = 0; i < n0; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB[i] = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_FB_flt[i], 15 ); + } + FOR( i = n0; i < n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_trunc[i - n0].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_FB_flt[i], 15 ); + } + FOR( i = 0; i < n1 - n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_trunc[n1 - n / 2 - i - 1].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_1_FB_flt[n / 2 + i], 15 ); + } + FOR( i = 0; i < n2 / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_FB_flt[i], 15 ); + } + FOR( i = n2 / 2; i < n2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_FB[n2 - i - 1].v.re = (Word16) floatToFixed( st->hTcxCfg->tcx_aldo_window_2_FB_flt[i], 15 ); + } + } + IF ( st->hTcxDec ) + { + Q_old_syn_Overl = Q_factor_arr( st->hTcxDec->old_syn_Overl_float, L_FRAME32k / 2 ) - 1; + Q_syn_Overl_TDAC = Q_factor_arr( st->hTcxDec->syn_Overl_TDAC_float, L_FRAME32k / 2 ) - 1; + Q_syn_Overl = Q_factor_arr( st->hTcxDec->syn_Overl_float, L_FRAME32k / 2 ) - 1; + Q_syn_Overl_TDACFB = Q_factor_arr( st->hTcxDec->syn_Overl_TDACFB_float, L_FRAME32k / 2 ); + Q_syn_OverlFB = Q_factor_arr( st->hTcxDec->syn_OverlFB_float, L_FRAME_MAX / 2 ); + Q_old_synth = Q_syn; + Q_synth_history = Q_factor_arr( st->hTcxDec->synth_history, L_PROT48k + L_FRAME_MAX ); + floatToFixed_arr( st->hTcxDec->old_syn_Overl_float, st->hTcxDec->old_syn_Overl, Q_old_syn_Overl, L_FRAME32k / 2 ); + floatToFixed_arr( st->hTcxDec->syn_Overl_TDAC_float, st->hTcxDec->syn_Overl_TDAC, Q_syn_Overl_TDAC, L_FRAME32k / 2 ); + floatToFixed_arr( st->hTcxDec->syn_Overl_float, st->hTcxDec->syn_Overl, Q_syn_Overl, L_FRAME32k / 2 ); + floatToFixed_arr( st->hTcxDec->syn_Overl_TDACFB_float, st->hTcxDec->syn_Overl_TDACFB, Q_syn_Overl_TDACFB, L_FRAME_MAX / 2 ); + floatToFixed_arr( st->hTcxDec->syn_OverlFB_float, st->hTcxDec->syn_OverlFB, Q_syn_OverlFB, L_FRAME_MAX / 2 ); + floatToFixed_arr( st->hTcxDec->old_synth_float, st->hTcxDec->old_synth, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); + floatToFixed_arr( st->hTcxDec->synth_history, st->hTcxDec->synth_history_fx, Q_synth_history, L_PROT48k + L_FRAME_MAX ); + st->hTcxDec->L_frameTCX = extract_l( Mult_32_16( st->output_Fs, 0x0290 ) ); + st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); + st->output_frame_fx = st->hTcxDec->L_frameTCX; + st->hTcxDec->CngLevelBackgroundTrace_bfi_fx = (Word16) floatToFixed( st->hTcxDec->CngLevelBackgroundTrace_bfi, 15 ); + st->hTcxDec->conceal_eof_gain = (Word16) floatToFixed( st->hTcxDec->conceal_eof_gain_float, 14 ); + st->hTcxDec->LastFrameLevel_bfi_fx = (Word16) floatToFixed( st->hTcxDec->LastFrameLevel_bfi, 15 ); + FOR( i = 0; i < PLC_MIN_STAT_BUFF_SIZE; i++ ) + { + st->hTcxDec->NoiseLevelMemory_bfi_fx[i] = floatToFixed( st->hTcxDec->NoiseLevelMemory_bfi[i], 15 ); + } + st->hTcxDec->cummulative_damping_tcx = floatToFixed( st->hTcxDec->cummulative_damping_tcx_float, 15 ); + } + IF ( st->hHQ_core ) + { + Q_fer_samples = Q_factor_arr( st->hHQ_core->fer_samples + delay_comp, shr( st->hTcxDec->L_frameTCX, 1 ) ) - 1; + Q_old_out = Q_factor_arr( st->hHQ_core->old_out, L_FRAME48k ); + Q_old_outLB = Q_factor_arrL( st->hHQ_core->old_outLB, L_FRAME32k ); + floatToFixed_arr( st->hHQ_core->fer_samples + delay_comp, st->hHQ_core->fer_samples_fx + delay_comp, Q_fer_samples, shr( st->hTcxDec->L_frameTCX, 1 ) ); + floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, Q_old_out, L_FRAME48k ); + floatToFixed_arrL( st->hHQ_core->old_outLB, st->hHQ_core->old_outLB_fx, Q_old_outLB, L_FRAME32k ); + } + IF ( st->cldfbAna ) + { + Q_cldfbAna_cldfb_state = Q_factor_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_length )-1; + floatToFixed_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, Q_cldfbAna_cldfb_state, st->cldfbAna->cldfb_state_length ); + } + IF ( st->cldfbBPF ) + { + Q_cldfbBPF_cldfb_state = Q_factor_arrL( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_length )-1; + floatToFixed_arrL( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_fx, Q_cldfbBPF_cldfb_state, st->cldfbBPF->cldfb_state_length ); + } + IF ( st->cldfbSyn ) + { + Q_cldfbSyn_cldfb_state = Q_factor_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_length )-1; + floatToFixed_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_fx, Q_cldfbSyn_cldfb_state, st->cldfbSyn->cldfb_state_length ); + } + IF ( st->cldfbSynHB ) + { + Q_cldfbSynHB_cldfb_state = Q_factor_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_length )-1; + floatToFixed_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_fx, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); + } + floatToFixed_arr( st->old_Aq_12_8, st->old_Aq_12_8_fx, Q_old_Aq_12_8, M + 1 ); + st->tilt_code_fx = (Word16) floatToFixed( st->tilt_code, 15 ); + IF ( st->hBPF ) + { + Q_pst_old_syn = Q_syn; + Q_pst_old_syn = Q_factor_arr( st->hBPF->pst_old_syn, NBPSF_PIT_MAX ); + floatToFixed_arr( st->hBPF->pst_old_syn, st->hBPF->pst_old_syn_fx, Q_pst_old_syn, NBPSF_PIT_MAX ); + } + IF ( st->hPFstat ) + { + Q_mem_stp = Q_factor_arr( st->hPFstat->mem_stp_flt, L_SUBFR ) - 1; + Q_mem_pf_in = Q_factor_arr( st->hPFstat->mem_pf_in_flt, L_SUBFR ) - 1; + Q_mem_res2 = Q_factor_arr( st->hPFstat->mem_res2_flt, DECMEM_RES2 ) - 1; + floatToFixed_arr( st->hPFstat->mem_stp_flt, st->hPFstat->mem_stp, Q_mem_stp, L_SUBFR ); + floatToFixed_arr( st->hPFstat->mem_pf_in_flt, st->hPFstat->mem_pf_in, Q_mem_pf_in, L_SUBFR ); + floatToFixed_arr( st->hPFstat->mem_res2_flt, st->hPFstat->mem_res2, Q_mem_res2, DECMEM_RES2 ); + st->hPFstat->gain_prec = floatToFixed( st->hPFstat->gain_prec_flt, 14 ); // 1.f + } + Word16 Q_lsf_cng = Q_factor( 6400 ); + floatToFixed_arr( st->lsf_cng_float, st->lsf_cng, Q_lsf_cng, M ); + st->last_concealed_gain_syn_deemph = (Word16) ( st->last_concealed_gain_syn_deemph_float, 14 ); + Word16 Q_old_enr_LP = Q_factor( st->old_enr_LP_float ); + st->old_enr_LP = (Word16) floatToFixed( st->old_enr_LP_float, Q_old_enr_LP ); + st->enr_old_fx = (Word16) floatToFixed( st->enr_old, 0 ); + floatToFixed_arr( st->previoussynth, st->previoussynth_fx, 0, 960 ); + Word16 Q_tcxltp_mem_in=0, Q_tcxltp_mem_out=0, Q_tcxltp_gain_post_prev=0; + IF ( st->hTcxLtpDec ) + { + Q_tcxltp_mem_in = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_in_float, TCXLTP_MAX_DELAY ); + Q_tcxltp_mem_out = Q_factor_arr( st->hTcxLtpDec->tcxltp_mem_out_float, L_FRAME48k ); + Q_tcxltp_gain_post_prev = Q_factor( st->hTcxLtpDec->tcxltp_gain_post_prev_float ); + st->hTcxLtpDec->tcxltp_gain_post_prev = (Word16) floatToFixed( st->hTcxLtpDec->tcxltp_gain_post_prev_float, Q_tcxltp_gain_post_prev ); + floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_in_float, st->hTcxLtpDec->tcxltp_mem_in, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + floatToFixed_arr( st->hTcxLtpDec->tcxltp_mem_out_float, st->hTcxLtpDec->tcxltp_mem_out, Q_tcxltp_mem_out, L_FRAME48k ); + } + + Word16 Q_mem_syn_clas_estim = Q_factor_arr( st->mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM ) - 1; + floatToFixed_arr( st->mem_syn_clas_estim, st->mem_syn_clas_estim_fx, Q_mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM ); + TD_BWE_DEC_HANDLE hBWE_TD = st->hBWE_TD; + Word16 Q_old_bwe_exc = 0, Q_bwe_non_lin_prev_scale = 0, Q_mem_genSHBexc_filt_down_wb2 = 0, Q_mem_genSHBexc_filt_down_wb3 = 0, Q_state_lsyn_filt_shb = 0, Q_state_lsyn_filt_dwn_shb = 0, Q_mem_resamp_HB = 0, Q_mem_genSHBexc_filt_down_shb = 0, Q_syn_overlap = 0, Q_mem_csfilt = 0, Q_tbe_demph = 0, Q_tbe_premph = 0, Q_gain_prec_swb = 0, Q_GainShape_Delay = 0, Q_int_3_over_2_tbemem_dec = 0, Q_mem_resamp_HB_32k = 0, Q_prev_fb_ener_adjust = 0, Q_fb_state_lpc_syn = 0, Q_fbbwe_hpf_mem = 0, Q_prev_fbbwe_ratio = 0, Q_fb_tbe_demph = 0, + Q_genSHBsynth_Hilbert_Mem=0, Q_genSHBsynth_state_lsyn_filt_shb_local=0; + IF ( hBWE_TD ) + { + Q_old_bwe_exc = Q_factor_arr( hBWE_TD->old_bwe_exc, PIT16k_MAX * 2 ); + floatToFixed_arr( hBWE_TD->old_bwe_exc, hBWE_TD->old_bwe_exc_fx, Q_old_bwe_exc, PIT16k_MAX * 2 ); + Q_bwe_non_lin_prev_scale = Q_factor_L( hBWE_TD->bwe_non_lin_prev_scale ); + hBWE_TD->bwe_non_lin_prev_scale_fx = floatToFixed( hBWE_TD->bwe_non_lin_prev_scale, Q_bwe_non_lin_prev_scale ); + Q_mem_genSHBexc_filt_down_wb2 = Q_factor_arr( hBWE_TD->mem_genSHBexc_filt_down_wb2, 7 ); + floatToFixed_arr( hBWE_TD->mem_genSHBexc_filt_down_wb2, hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, Q_mem_genSHBexc_filt_down_wb2, 7 ); + Q_state_lsyn_filt_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_shb, 6 ); + floatToFixed_arr( hBWE_TD->state_lsyn_filt_shb, hBWE_TD->state_lsyn_filt_shb_fx, Q_state_lsyn_filt_shb, 6 ); + Q_mem_genSHBexc_filt_down_wb3 = Q_factor_arr( hBWE_TD->mem_genSHBexc_filt_down_wb3, 7 ); + floatToFixed_arr( hBWE_TD->mem_genSHBexc_filt_down_wb3, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, Q_mem_genSHBexc_filt_down_wb3, 7 ); + Q_state_lsyn_filt_dwn_shb = Q_factor_arr( hBWE_TD->state_lsyn_filt_dwn_shb, 6 ); + floatToFixed_arr( hBWE_TD->state_lsyn_filt_dwn_shb, hBWE_TD->state_lsyn_filt_dwn_shb_fx, Q_state_lsyn_filt_dwn_shb, 6 ); + Q_mem_resamp_HB = Q_factor_arr( hBWE_TD->mem_resamp_HB, 13 ); + floatToFixed_arr( hBWE_TD->mem_resamp_HB, hBWE_TD->mem_resamp_HB_fx, Q_mem_resamp_HB, 13 ); + hBWE_TD->prev_pow_exc16kWhtnd_fx = (Word16) floatToFixed( hBWE_TD->prev_pow_exc16kWhtnd, 15 ); + hBWE_TD->prev_mix_factor_fx = (Word16) floatToFixed( hBWE_TD->prev_mix_factor, 15 ); + Q_mem_genSHBexc_filt_down_shb = Q_factor_arr( hBWE_TD->mem_genSHBexc_filt_down_shb, 7 ); + floatToFixed_arr( hBWE_TD->mem_genSHBexc_filt_down_shb, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, Q_mem_genSHBexc_filt_down_shb, 7 ); + Q_state_lpc_syn = Q_factor_arr( hBWE_TD->state_lpc_syn, 10 ); + floatToFixed_arr( hBWE_TD->state_lpc_syn, hBWE_TD->state_lpc_syn_fx, Q_state_lpc_syn, 10 ); + Q_state_syn_shbexc = Q_factor_arr( hBWE_TD->state_syn_shbexc, 20 ); + floatToFixed_arr( hBWE_TD->state_syn_shbexc, hBWE_TD->state_syn_shbexc_fx, Q_state_syn_shbexc, 20 ); + Q_syn_overlap = Q_factor_arr( hBWE_TD->syn_overlap, 20 ); + floatToFixed_arr( hBWE_TD->syn_overlap, hBWE_TD->syn_overlap_fx, Q_syn_overlap, 20 ); + Q_mem_csfilt = Q_factor_arrL( hBWE_TD->mem_csfilt, 2 ); + floatToFixed_arrL( hBWE_TD->mem_csfilt, hBWE_TD->mem_csfilt_fx, Q_mem_csfilt, 2 ); + Q_tbe_demph = Q_factor( (Word16) hBWE_TD->tbe_demph ); + Q_tbe_premph = Q_factor( (Word16) hBWE_TD->tbe_premph ); + Q_gain_prec_swb = Q_factor( (Word16) hBWE_TD->gain_prec_swb ); + Q_mem_stp_swb = Q_factor_arr( hBWE_TD->mem_stp_swb, 10 ); + Q_GainShape_Delay = Q_factor_arr( hBWE_TD->GainShape_Delay, 8 ); + Q_int_3_over_2_tbemem_dec = Q_factor_arr( hBWE_TD->int_3_over_2_tbemem_dec, 15 ); + Q_mem_resamp_HB_32k = Q_factor_arr( hBWE_TD->mem_resamp_HB_32k, 7 ); + Q_prev_fb_ener_adjust = Q_factor( (Word16) st->hBWE_FD->prev_fb_ener_adjust ); + Q_fb_state_lpc_syn = Q_factor_arr( hBWE_TD->fb_state_lpc_syn, 10 ); + Q_fbbwe_hpf_mem = Q_factor_arrL( &hBWE_TD->fbbwe_hpf_mem[0][0], 16 ); + Q_prev_fbbwe_ratio = Q_factor( (Word16) hBWE_TD->prev_fbbwe_ratio ); + st->prev_fb_ener_adjust_fx = (Word16) floatToFixed( st->hBWE_FD->prev_fb_ener_adjust, Q_prev_fb_ener_adjust ); + floatToFixed_arr( hBWE_TD->fb_state_lpc_syn, hBWE_TD->fb_state_lpc_syn_fx, Q_fb_state_lpc_syn, 10 ); + floatToFixed_arrL( &hBWE_TD->fbbwe_hpf_mem[0][0], &hBWE_TD->fbbwe_hpf_mem_fx[0][0], Q_fbbwe_hpf_mem, 16 ); + hBWE_TD->prev_fbbwe_ratio_fx = (Word16) floatToFixed( hBWE_TD->prev_fbbwe_ratio, Q_prev_fbbwe_ratio ); + Q_fb_tbe_demph = Q_factor( (Word16) hBWE_TD->fb_tbe_demph ); + hBWE_TD->fb_tbe_demph_fx = (Word16) floatToFixed( hBWE_TD->fb_tbe_demph, Q_fb_tbe_demph ); + hBWE_TD->tbe_demph_fx = (Word16) floatToFixed( hBWE_TD->tbe_demph, Q_tbe_demph ); + hBWE_TD->tbe_premph_fx = (Word16) floatToFixed( hBWE_TD->tbe_premph, Q_tbe_premph ); + hBWE_TD->gain_prec_swb_fx = (Word16) floatToFixed( hBWE_TD->gain_prec_swb, 14 ); + floatToFixed_arr( hBWE_TD->GainShape_Delay, st->GainShape_Delay, Q_GainShape_Delay, 8 ); + floatToFixed_arr( hBWE_TD->int_3_over_2_tbemem_dec, hBWE_TD->int_3_over_2_tbemem_dec_fx, Q_int_3_over_2_tbemem_dec, INTERP_3_2_MEM_LEN ); + floatToFixed_arr( hBWE_TD->mem_resamp_HB_32k, hBWE_TD->mem_resamp_HB_32k_fx, Q_mem_resamp_HB_32k, 7 ); + Q_genSHBsynth_Hilbert_Mem = Q_factor_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem, 21 ); + floatToFixed_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem, hBWE_TD->genSHBsynth_Hilbert_Mem_fx, Q_genSHBsynth_Hilbert_Mem, 21 ); + Q_genSHBsynth_state_lsyn_filt_shb_local = Q_factor_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 6 ); + floatToFixed_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, Q_genSHBsynth_state_lsyn_filt_shb_local, 6 ); + floatToFixed_arr( hBWE_TD->mem_stp_swb, hBWE_TD->mem_stp_swb_fx, Q_mem_stp_swb, 10 ); + Q_mem_zero_swb = Q_factor_arr( hBWE_TD->mem_zero_swb, LPC_SHB_ORDER ); + floatToFixed_arr( hBWE_TD->mem_zero_swb, hBWE_TD->mem_zero_swb_fx, Q_mem_zero_swb, LPC_SHB_ORDER ); + } + IF ( st->hTECDec ) + { + Q_loBuffer = Q_factor_arr( st->hTECDec->loBuffer_flt, MAX_TEC_SMOOTHING_DEG ); + floatToFixed_arr( st->hTECDec->loBuffer_flt, st->hTECDec->loBuffer, Q_loBuffer, MAX_TEC_SMOOTHING_DEG ); + } + st->TcxBandwidth = floatToFixed( st->TcxBandwidth_float, 15 ); +#endif // Float to fixed conversions end here + Word16 start_bit_pos, bits_common; + CONTEXT_HM_CONFIG hm_cfg; + Word16 indexBuffer[N_MAX + 1]; + + assert( EQ_16( st->mdct_sw, MODE1 ) ); + + /*--------------------------------------------------------------------------------* + * INIT + *--------------------------------------------------------------------------------*/ + + hm_cfg.indexBuffer = indexBuffer; + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + // The value of 1/ FRAMES_PER_SEC shifted left by 19 because taking Q as 15 led to precision loss + st->bits_frame_core = (Word16) L_sub(L_shr(Mpy_32_16_1( st->total_brate , 10486 ),4) , st->next_bit_pos ); + } + start_bit_pos = st->next_bit_pos; + + /* Init LTP data */ + st->hTcxDec->tcx_hm_LtpPitchLag = -1; + st->hTcxLtpDec->tcxltp_gain = 0; + + /*--------------------------------------------------------------------------------* + * header + *--------------------------------------------------------------------------------*/ + + /* Modes (ACE_GC, ACE_UC, TCX20, TCX10...) */ + getTCXMode_ivas( st, st, 0 /* <- MCT_flag */ ); + + /* last_core for error concealment */ + IF( !st->use_partial_copy && NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->last_core_from_bs = get_next_indice_fx( st, 1 ); /* Store decoder memory of last_core */ + IF( EQ_16( st->last_core, ACELP_CORE ) && NE_16( st->last_core_from_bs, ACELP_CORE ) ) + { + /* A mismatch between the memory and the last_core + from the bitstream indicates a frame was lost. If prev_bfi is + not set the frame loss occured during CNG and the prev_bfi needs to be set. */ + st->prev_bfi = 1; + } + + /* possible need for reconfiguration can only be decided correctly once last_core_from_bs has been decoded */ + IF( NE_16( st->last_core, st->last_core_from_bs ) && ( NE_16( st->last_core_from_bs, TCX_20_CORE ) && NE_16( st->last_core_from_bs, TCX_10_CORE ) && !( EQ_16( st->prev_bfi, 1 ) && EQ_16( st->last_core_from_bs, ACELP_CORE ) && EQ_16( st->last_con_tcx, 1 ) ) ) ) + { + stereo_tcx_dec_mode_switch_reconf_ivas_fx( st, 0, last_element_mode, &Q_syn_Overl_TDAC, &Q_fer_samples, &Q_syn_Overl, &Q_syn_Overl_TDACFB, &Q_syn_OverlFB, &Q_old_out, &Q_old_outLB, &Q_old_Aq_12_8 ); +#if 1 /*Fixed to float changes */ + hGrid = &hIGFInfo->grid[IGF_GRID_LB_NORM]; + fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); + hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); + hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); + hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); + hGrid = &hIGFInfo->grid[IGF_GRID_LB_TRAN]; + fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); + hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); + hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); + hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); + hGrid = &hIGFInfo->grid[IGF_GRID_LB_SHORT]; + fixedToFloat_arr( &hGrid->whiteningThreshold[0][0], &hGrid->whiteningThreshold_flt[0][0], 13, IGF_MAX_TILES * 2 ); + hGrid->gFactor_flt = fixedToFloat( hGrid->gFactor, 14 ); + hGrid->fFactor_flt = fixedToFloat( hGrid->fFactor, 14 ); + hGrid->lFactor_flt = fixedToFloat( hGrid->lFactor, 14 ); + IF ( st->hIGFDec ) + { + st->hIGFDec->virtualSpec_float = &st->hIGFDec->virtualSpecBuf[0]; + st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; + st->hIGFDec->igfData.igfInfo.nfSeed = &st->hIGFDec->igfData.igfInfo.nfSeedBuf[0]; + } + st->preemph_fac_float = fixedToFloat( st->preemph_fac, 15 ); + st->TcxBandwidth_float = fixedToFloat( st->TcxBandwidth, 15 ); + IF( EQ_32( st->sr_core, INT_FS_16k ) ) + { + st->gamma_float = GAMMA16k_FLT; + move16(); + } + ELSE IF( GT_32( st->sr_core, INT_FS_16k ) && EQ_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + st->gamma_float = GAMMA16k_FLT; + move16(); + } + ELSE + { + st->gamma_float = GAMMA1_FLT; + move16(); + } + IF( st->hBWE_TD != NULL ) + { + fixedToFloat_arr( st->hBWE_TD->prev_lsf_diff_fx, st->hBWE_TD->prev_lsf_diff, 15, LPC_SHB_ORDER - 2 ); + st->hBWE_TD->prev_tilt_para = 0.0f; + fixedToFloat_arr( st->hBWE_TD->cur_sub_Aq_fx, st->hBWE_TD->cur_sub_Aq, 15, M + 1 ); + fixedToFloat_arr( hBWE_TD->old_bwe_exc_fx, hBWE_TD->old_bwe_exc, Q_old_bwe_exc, PIT16k_MAX * 2 ); + hBWE_TD->bwe_non_lin_prev_scale = fixedToFloat( hBWE_TD->bwe_non_lin_prev_scale_fx, Q_bwe_non_lin_prev_scale ); + fixedToFloat_arr( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb2, Q_mem_genSHBexc_filt_down_wb2, 7 ); + fixedToFloat_arr( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3, Q_mem_genSHBexc_filt_down_wb3, 7 ); + fixedToFloat_arr( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_shb, Q_state_lsyn_filt_shb, 6 ); + fixedToFloat_arr( hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb, Q_state_lsyn_filt_dwn_shb, 6 ); + fixedToFloat_arr( hBWE_TD->mem_resamp_HB_fx, hBWE_TD->mem_resamp_HB, Q_mem_resamp_HB, 13 ); + fixedToFloat_arr( hBWE_TD->state_syn_shbexc_fx, hBWE_TD->state_syn_shbexc, Q_state_syn_shbexc, 20 ); + fixedToFloat_arrL( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_csfilt, Q_mem_csfilt, 2 ); + fixedToFloat_arr( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->mem_genSHBexc_filt_down_shb, Q_mem_genSHBexc_filt_down_shb, 7 ); + fixedToFloat_arr( hBWE_TD->syn_overlap_fx, hBWE_TD->syn_overlap, Q_syn_overlap, 20 ); + fixedToFloat_arr( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, Q_genSHBsynth_state_lsyn_filt_shb_local, HILBERT_MEM_SIZE ); + fixedToFloat_arrL( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_Hilbert_Mem, Q_genSHBsynth_Hilbert_Mem, HILBERT_MEM_SIZE ); + hBWE_TD->tbe_demph = fixedToFloat( hBWE_TD->tbe_demph_fx, Q_tbe_demph ); + hBWE_TD->tbe_premph = fixedToFloat( hBWE_TD->tbe_premph_fx, Q_tbe_premph ); + fixedToFloat_arr( st->GainShape_Delay, hBWE_TD->GainShape_Delay, Q_GainShape_Delay, 8 ); + fixedToFloat_arr( hBWE_TD->int_3_over_2_tbemem_dec_fx, hBWE_TD->int_3_over_2_tbemem_dec, Q_int_3_over_2_tbemem_dec, 15 ); + fixedToFloat_arr( hBWE_TD->mem_resamp_HB_32k_fx, hBWE_TD->mem_resamp_HB_32k, Q_mem_resamp_HB_32k, 7 ); + hBWE_TD->prev_pow_exc16kWhtnd = fixedToFloat( hBWE_TD->prev_pow_exc16kWhtnd_fx, 15 ); + hBWE_TD->prev_mix_factor = fixedToFloat( hBWE_TD->prev_mix_factor_fx, 15 ); + st->hBWE_FD->prev_fb_ener_adjust = fixedToFloat( st->prev_fb_ener_adjust_fx, Q_prev_fb_ener_adjust ); + hBWE_TD->fb_tbe_demph = fixedToFloat( hBWE_TD->fb_tbe_demph_fx, Q_fb_tbe_demph ); + fixedToFloat_arrL( &hBWE_TD->fbbwe_hpf_mem_fx[0][0], &hBWE_TD->fbbwe_hpf_mem[0][0], Q_fbbwe_hpf_mem, 16 ); + hBWE_TD->prev_fbbwe_ratio = fixedToFloat( hBWE_TD->prev_fbbwe_ratio_fx, Q_prev_fbbwe_ratio ); + fixedToFloat_arr( hBWE_TD->state_lpc_syn_fx, hBWE_TD->state_lpc_syn, Q_state_lpc_syn, LPC_SHB_ORDER ); + fixedToFloat_arr( hBWE_TD->state_syn_shbexc_fx, hBWE_TD->state_syn_shbexc, Q_state_syn_shbexc, L_SHB_LAHEAD ); + fixedToFloat_arr( hBWE_TD->mem_stp_swb_fx, hBWE_TD->mem_stp_swb, Q_mem_stp_swb, LPC_SHB_ORDER ); + fixedToFloat_arr( hBWE_TD->mem_zero_swb_fx, hBWE_TD->mem_zero_swb, Q_mem_zero_swb, LPC_SHB_ORDER ); + hBWE_TD->gain_prec_swb = fixedToFloat( hBWE_TD->gain_prec_swb_fx, 14 ); + } + + IF( st->hTECDec != NULL ) + { + FOR( i = 0; i < CLDFB_NO_COL_MAX; i++ ) + { + st->hTECDec->pGainTemp[i] = 0; + } + fixedToFloat_arr( st->hTECDec->loBuffer, st->hTECDec->loBuffer_flt, Q_loBuffer, MAX_TEC_SMOOTHING_DEG ); + } + IF( st->hTcxCfg ) + { + st->hTcxCfg->preemph_fac_flt = fixedToFloat( st->hTcxCfg->preemph_fac, 15 ); + st->hTcxCfg->sq_rounding_flt = fixedToFloat( st->hTcxCfg->sq_rounding, 15 ); + st->hTcxCfg->bandwidth_flt = fixedToFloat( st->hTcxCfg->bandwidth, 15 ); + st->hTcxCfg->na_scale_flt = fixedToFloat( st->hTcxCfg->na_scale, 15 ); + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_flt[st->hTcxCfg->tcx_mdct_window_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_windowFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_windowFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_windowFB_flt[st->hTcxCfg->tcx_mdct_window_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_windowFB[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_trans_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_trans[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_trans_flt[st->hTcxCfg->tcx_mdct_window_trans_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_trans[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_trans_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_transFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_transFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_transFB_flt[st->hTcxCfg->tcx_mdct_window_trans_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_transFB[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_half_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_half[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_half_flt[st->hTcxCfg->tcx_mdct_window_half_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_half[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_half_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_halfFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_halfFB_flt[st->hTcxCfg->tcx_mdct_window_half_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_halfFB[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_length / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_minimum_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimum[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_minimum_flt[st->hTcxCfg->tcx_mdct_window_min_length - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimum[i].v.re, 15 ); + } + FOR( i = 0; i < st->hTcxCfg->tcx_mdct_window_min_lengthFB / 2; i++ ) + { + st->hTcxCfg->tcx_mdct_window_minimumFB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.im, 15 ); + st->hTcxCfg->tcx_mdct_window_minimumFB_flt[st->hTcxCfg->tcx_mdct_window_min_lengthFB - i - 1] = fixedToFloat( st->hTcxCfg->tcx_mdct_window_minimumFB[i].v.re, 15 ); + } + Word16 n = st->L_frame; + Word16 n0 = shr( imult1616( n, 9 ), 5 ); + Word16 n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ + Word16 n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ + FOR( i = 0; i < n0; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1[i], 15 ); + } + FOR( i = n0; i < n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_trunc[i - n0].v.im, 15 ); + } + FOR( i = 0; i < n1 - n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_flt[n / 2 + i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_trunc[n1 - n / 2 - 1 - i].v.re, 15 ); + } + FOR( i = 0; i < n2 / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2[i].v.im, 15 ); + } + FOR( i = n2 / 2; i < n2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2[n2 - i - 1].v.re, 15 ); + } + n = NS2SA_fx2( st->output_Fs, FRAME_SIZE_NS ); + n0 = shr( imult1616( n, 9 ), 5 ); + n1 = shr( imult1616( n, 23 ), 5 ); /* left slope length */ + n2 = shr( imult1616( n, 14 ), 5 ); /* right slope length */ + FOR( i = 0; i < n0; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_FB[i], 15 ); + } + FOR( i = n0; i < n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_FB_trunc[i - n0].v.im, 15 ); + } + FOR( i = 0; i < n1 - n / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_1_FB_flt[n / 2 + i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_1_FB_trunc[n1 - n / 2 - i - 1].v.re, 15 ); + } + FOR( i = 0; i < n2 / 2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2_FB[i].v.im, 15 ); + } + FOR( i = n2 / 2; i < n2; i++ ) + { + st->hTcxCfg->tcx_aldo_window_2_FB_flt[i] = fixedToFloat( st->hTcxCfg->tcx_aldo_window_2_FB[n2 - i - 1].v.re, 15 ); + } + st->hTcxCfg->tcx_aldo_window_1_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_flt + NS2SA( st->sr_core, N_ZERO_MDCT_NS ); + st->hTcxCfg->tcx_aldo_window_1_FB_trunc_flt = st->hTcxCfg->tcx_aldo_window_1_FB_flt + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ); + } + IF ( st->hTcxDec ) + { + fixedToFloat_arr( st->hTcxDec->old_syn_Overl, st->hTcxDec->old_syn_Overl_float, Q_old_syn_Overl, L_FRAME32k / 2 ); + fixedToFloat_arr( st->hTcxDec->syn_Overl_TDAC, st->hTcxDec->syn_Overl_TDAC_float, Q_syn_Overl_TDAC, 320 ); + fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, Q_syn_Overl, 320 ); + fixedToFloat_arr( st->hTcxDec->syn_Overl_TDACFB, st->hTcxDec->syn_Overl_TDACFB_float, Q_syn_Overl_TDACFB, 480 ); + fixedToFloat_arr( st->hTcxDec->syn_OverlFB, st->hTcxDec->syn_OverlFB_float, Q_syn_OverlFB, 480 ); + fixedToFloat_arr( st->hTcxDec->old_synth, st->hTcxDec->old_synth_float, Q_old_synth, OLD_SYNTH_INTERNAL_DEC ); + fixedToFloat_arr( st->hTcxDec->synth_history_fx, st->hTcxDec->synth_history, Q_synth_history, L_PROT48k + L_FRAME_MAX ); + fixedToFloat_arr( st->hTcxDec->ltpGainMemory_fx, st->hTcxDec->ltpGainMemory, 0, N_LTP_GAIN_MEMS ); + st->hTcxDec->tcxltp_second_last_pitch_float = fixedToFloat( st->hTcxDec->tcxltp_second_last_pitch, 16 ); + st->hTcxDec->tcxltp_third_last_pitch_float = fixedToFloat( st->hTcxDec->tcxltp_third_last_pitch, 16 ); + st->hTcxDec->old_gaintcx_bfi_float = 0; + st->hTcxDec->conceal_eof_gain_float = fixedToFloat( st->hTcxDec->conceal_eof_gain, 14 ); + st->hTcxDec->CngLevelBackgroundTrace_bfi = fixedToFloat( st->hTcxDec->CngLevelBackgroundTrace_bfi_fx, 15 ); + st->hTcxDec->LastFrameLevel_bfi = fixedToFloat( st->hTcxDec->LastFrameLevel_bfi_fx, 15 ); + FOR( i = 0; i < PLC_MIN_STAT_BUFF_SIZE; i++ ) + { + st->hTcxDec->NoiseLevelMemory_bfi[i] = fixedToFloat( st->hTcxDec->NoiseLevelMemory_bfi_fx[i], 15 ); + } + st->hTcxDec->cummulative_damping_tcx_float = fixedToFloat( st->hTcxDec->cummulative_damping_tcx, 15 ); + } + fixedToFloat_arr( st->syn, st->syn_float, Q_syn, M + 1 ); + fixedToFloat_arr( st->old_exc_fx, st->old_exc, Q_old_exc, L_EXC_MEM_DEC ); + fixedToFloat_arr( st->mem_syn_r, st->mem_syn_r_float, Q_mem_syn_r, L_SYN_MEM ); + fixedToFloat_arr( st->lsp_old_fx, st->lsp_old, 15, M ); + fixedToFloat_arr( st->mem_syn2_fx, st->mem_syn2, Q_mem_syn2, M ); + fixedToFloat_arr( st->lspold_uw, st->lspold_uw_float, 15, M ); + FOR( i = 0; i < M; i++ ) + { + st->mem_AR[i] = fixedToFloat( L_mult( st->mem_AR_fx[i], 100 ), 9 ); + st->mem_MA[i] = fixedToFloat( L_mult( st->mem_MA_fx[i], 100 ), 9 ); + st->lsfold_uw_float[i] = fixedToFloat( L_mult( st->lsfold_uw[i], 100 ), 9 ); + st->lsf_old[i] = fixedToFloat( L_mult( st->lsf_old_fx[i], 100 ), 9 ); + } + IF ( st->hHQ_core ) + { + fixedToFloat_arr( st->hHQ_core->old_out_fx, st->hHQ_core->old_out, Q_old_out, L_FRAME48k ); + fixedToFloat_arr( st->hHQ_core->old_out_LB_fx, st->hHQ_core->old_outLB, Q_old_outLB, L_FRAME32k ); + } + IF ( st->cldfbAna ) + { + Q_cldfbAna_cldfb_state = Q_factor_arrL( st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_length )-1; + fixedToFloat_arrL( st->cldfbAna->cldfb_state_fx, st->cldfbAna->cldfb_state, Q_cldfbAna_cldfb_state, st->cldfbAna->cldfb_state_length ); + } + IF ( st->cldfbBPF ) + { + Q_cldfbBPF_cldfb_state = Q_factor_arrL( st->cldfbBPF->cldfb_state, st->cldfbBPF->cldfb_state_length )-1; + fixedToFloat_arrL( st->cldfbBPF->cldfb_state_fx, st->cldfbBPF->cldfb_state, Q_cldfbBPF_cldfb_state, st->cldfbBPF->cldfb_state_length ); + } + IF ( st->cldfbSyn ) + { + Q_cldfbSyn_cldfb_state = Q_factor_arrL( st->cldfbSyn->cldfb_state, st->cldfbSyn->cldfb_state_length )-1; + fixedToFloat_arrL( st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q_cldfbSyn_cldfb_state, st->cldfbSyn->cldfb_state_length ); + } + IF ( st->cldfbSynHB ) + { + Q_cldfbSynHB_cldfb_state = Q_factor_arrL( st->cldfbSynHB->cldfb_state, st->cldfbSynHB->cldfb_state_length )-1; + fixedToFloat_arrL( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q_cldfbSynHB_cldfb_state, st->cldfbSynHB->cldfb_state_length ); + } + fixedToFloat_arr( st->old_Aq_12_8_fx, st->old_Aq_12_8, Q_old_Aq_12_8, M + 1 ); + st->tilt_code = fixedToFloat( st->tilt_code_fx, 15 ); + IF ( st->hBPF ) + { + fixedToFloat_arr( st->hBPF->pst_old_syn_fx, st->hBPF->pst_old_syn, Q_pst_old_syn, NBPSF_PIT_MAX ); + st->hBPF->pst_mem_deemp_err = 0; + } + IF ( st->hPFstat ) + { + fixedToFloat_arr( st->hPFstat->mem_stp, st->hPFstat->mem_stp_flt, Q_mem_stp, L_SUBFR ); + fixedToFloat_arr( st->hPFstat->mem_pf_in, st->hPFstat->mem_pf_in_flt, Q_mem_pf_in, L_SUBFR ); + fixedToFloat_arr( st->hPFstat->mem_res2, st->hPFstat->mem_res2_flt, Q_mem_res2, DECMEM_RES2 ); + st->hPFstat->gain_prec_flt = fixedToFloat( st->hPFstat->gain_prec, 14 ); // 1.f + } + fixedToFloat_arr( st->lsf_cng, st->lsf_cng_float, Q_lsf_cng, M ); + st->past_gpit_float = fixedToFloat( st->past_gpit, 0 ); + st->past_gcode_float = fixedToFloat( st->past_gcode, 0 ); + st->gc_threshold = fixedToFloat( st->gc_threshold_fx, 0 ); + fixedToFloat_arr( st->lspold_cng, st->lspold_cng_float, 15, M ); + fixedToFloat_arr( st->Aq_cng, st->Aq_cng_float, 2, M ); + FOR( i = 0; i < M; i++ ) + { + st->lsf_q_cng_float[i] = fixedToFloat( L_mult( st->lsf_q_cng[i], 100 ), 9 ); + st->old_lsf_q_cng_float[i] = fixedToFloat( L_mult( st->old_lsf_q_cng[i], 100 ), 9 ); + } + fixedToFloat_arr( st->lsp_q_cng, st->lsp_q_cng_float, 15, M ); + fixedToFloat_arr( st->old_lsp_q_cng, st->old_lsp_q_cng_float, 15, M ); + fixedToFloat_arr( st->mem_syn_unv_back, st->mem_syn_unv_back_float, 0, M ); + fixedToFloat_arr( st->mem_Aq, st->mem_Aq_float, 0, NB_SUBFR16k * ( M + 1 ) ); + st->last_gain_syn_deemph_float = 1; + st->last_concealed_gain_syn_deemph_float = fixedToFloat( st->last_concealed_gain_syn_deemph, 14 ); + st->lp_ener_bfi = fixedToFloat( st->lp_ener_FER_fx, 8 ); + FOR( i = 0; i < M; i++ ) + { + st->lsf_adaptive_mean[i] = fixedToFloat( L_mult( st->lsf_adaptive_mean_fx[i], 100 ), 9 ); + st->lsfoldbfi0[i] = fixedToFloat( L_mult( st->lsfoldbfi0_fx[i], 100 ), 9 ); + st->lsfoldbfi1[i] = fixedToFloat( L_mult( st->lsfoldbfi1_fx[i], 100 ), 9 ); + } + st->old_enr_LP_float = fixedToFloat( st->old_enr_LP, Q_old_enr_LP ); + st->enr_old = fixedToFloat( st->enr_old_fx, 0 ); + st->lp_gainc = fixedToFloat( st->lp_gainc_fx, 0 ); + st->lp_gainp = fixedToFloat( st->lp_gainp_fx, 0 ); + st->cummulative_damping_float = 1; + FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) + { + st->old_pitch_buf[i] = fixedToFloat( st->old_pitch_buf_fx[i], 16 ); + } + FOR( i = 0; i < 2 * NB_SUBFR16k + 2; i++ ) + { + st->mem_pitch_gain_float[i] = 1; + } + st->old_fpitch_float = fixedToFloat( st->old_fpitch, 16 ); + FOR( i = 0; i < 8; i++ ) + { + st->dispMem[i] = 0; + } + st->voice_fac_float = st->voice_fac; /* purely unvoiced */ + IF( st->hTcxLtpDec != NULL ) + { + fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_in, st->hTcxLtpDec->tcxltp_mem_in_float, Q_tcxltp_mem_in, TCXLTP_MAX_DELAY ); + fixedToFloat_arr( st->hTcxLtpDec->tcxltp_mem_out, st->hTcxLtpDec->tcxltp_mem_out_float, Q_tcxltp_mem_out, L_FRAME48k ); + st->hTcxLtpDec->tcxltp_gain_post_prev_float = fixedToFloat( st->hTcxLtpDec->tcxltp_gain_post_prev, Q_tcxltp_gain_post_prev ); + } + IF ( st->hTonalMDCTConc ) + { + FOR( i = 0; i < FDNS_NPTS; i++ ) + { + st->hTonalMDCTConc->scaleFactorsBackground_flt[i] = fix16_to_float( st->hTonalMDCTConc->scaleFactorsBackground[i], 15 ); + } + } + IF ( st->hPlcInfo ) + { + FOR( i = 0; i < L_FRAME_MAX; i++ ) + { + st->hPlcInfo->data_reci2[i] = fixedToFloat( st->hPlcInfo->data_reci2_fx[i], 0 ); + } + } + st->old_fpitchFB_float = fixedToFloat( st->old_fpitchFB, 16 ); + ACELP_config *pConfigAcelp = &( st->acelp_cfg ); + IF( pConfigAcelp != NULL ) + { + pConfigAcelp->formant_enh_num_flt = fixedToFloat( pConfigAcelp->formant_enh_num, 15 ); + pConfigAcelp->formant_enh_den_flt = fixedToFloat( pConfigAcelp->formant_enh_den, 15 ); + st->acelp_cfg_rf.formant_enh_num_flt = fixedToFloat( st->acelp_cfg_rf.formant_enh_num, 15 ); + st->acelp_cfg_rf.formant_enh_den_flt = fixedToFloat( st->acelp_cfg_rf.formant_enh_den, 15 ); + fixedToFloat_arr( st->mem_syn_clas_estim_fx, st->mem_syn_clas_estim, Q_mem_syn_clas_estim, L_SYN_MEM_CLAS_ESTIM ); + } +#endif // Ends + } + + st->last_core = st->last_core_from_bs; + + /*for TCX 10 force last_core to be TCX since ACELP as previous core is forbidden*/ + IF( EQ_16( st->core, TCX_10_CORE ) ) + { + st->last_core = TCX_20_CORE; + } + } + + IF( !st->use_partial_copy ) + { + IF( NE_16( st->element_mode, IVAS_CPE_MDCT ) ) + { + getTCXWindowing_ivas( st->core, st->last_core, st->element_mode, st->hTcxCfg, st ); + } + st->flagGuidedAcelp = 0; + + IF( st->dec_glr ) + { + st->dec_glr_idx = -1; + } + } + + + /*--------------------------------------------------------------------------------* + * LPC parameters + *--------------------------------------------------------------------------------*/ + + getLPCparam( st, param_lpc, st, -1, 0 ); + + bits_common = sub( st->next_bit_pos, start_bit_pos ); + + + /*--------------------------------------------------------------------------------* + * TCX20/10 parameters + *--------------------------------------------------------------------------------*/ + + IF( EQ_16( st->use_partial_copy, 0 ) ) + { + getTCXparam( st, st, hm_cfg, param, bits_common, start_bit_pos, NULL, NULL, NULL, -1 ); + } + + IF( !st->use_partial_copy ) + { + IF( LT_16( sub( *total_nbbits, bitsRead[0] ), sub( st->next_bit_pos, start_bit_pos ) ) ) + { + st->BER_detect = 1; + st->next_bit_pos = add( start_bit_pos, sub( *total_nbbits, bitsRead[0] ) ); + } + + bitsRead[0] = sub( st->next_bit_pos, start_bit_pos ); + } + +#if 1 /*Fixed to float changes*/ + st->hTcxLtpDec->tcxltp_gain_float = fixedToFloat( st->hTcxLtpDec->tcxltp_gain, 15 ); + st->hTcxDec->tcxltp_last_gain_unmodified_float = fixedToFloat( st->hTcxDec->tcxltp_last_gain_unmodified, 15 ); +#endif // Ends here + return; +} +#endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index 8849e60bc..663b5f2ee 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -626,6 +626,9 @@ typedef struct tcx_dec_structure Word16 CngLevelBackgroundTrace_bfi_exp; /* state variables for the minimum statistics used for PLC */ float NoiseLevelMemory_bfi[PLC_MIN_STAT_BUFF_SIZE]; +#ifdef IVAS_FLOAT_FIXED + Word16 NoiseLevelMemory_bfi_fx[PLC_MIN_STAT_BUFF_SIZE]; +#endif // IVAS_FLOAT_FIXED int16_t NoiseLevelIndex_bfi; int16_t CurrLevelIndex_bfi; @@ -633,6 +636,9 @@ typedef struct tcx_dec_structure Word16 conCngLevelBackgroundTrace_e; float LastFrameLevel_bfi; +#ifdef IVAS_FLOAT_FIXED + Word16 LastFrameLevel_bfi_fx; +#endif // IVAS_FLOAT_FIXED Word16 conNoiseLevelMemory[PLC_MIN_STAT_BUFF_SIZE], conNoiseLevelMemory_e[PLC_MIN_STAT_BUFF_SIZE];/*Q15*/ Word16 conNoiseLevelIndex; /*Q0*/ @@ -1369,7 +1375,9 @@ typedef struct td_bwe_dec_structure Word16 state_32and48k_WB_upsample_fx[2 * ALLPASSSECTIONS_STEEP]; /* !!! this memory in FLP is called mem_resamp_HB */ float prev_pow_exc16kWhtnd; /* power of the LB excitation signal in the previous frame */ + Word16 prev_pow_exc16kWhtnd_fx; /* power of the LB excitation signal in the previous frame */ float prev_mix_factor; /* mixing factor in the previous frame */ + Word16 prev_mix_factor_fx; /* mixing factor in the previous frame */ int16_t syn_dm_phase; Word16 syn_dm_phase_fx; @@ -2576,7 +2584,7 @@ typedef struct Decoder_State Word16 last_element_mode; /* element mode */ Word16 coder_type_fx; /* low-rate mode flag */ - Word32 prev_synth_buffer32_fx[NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)]; + Word32 prev_synth_buffer32_fx[NS2SA(48000, IVAS_DEC_DELAY_NS - DELAY_CLDFB_NS)]; #ifdef DEBUGGING Word16 id_element; /* element ID */ diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 8a4b0a127..4daf093df 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -3736,6 +3736,63 @@ void TBEreset_dec_fx( return; } +#ifdef IVAS_FLOAT_FIXED +void TBEreset_dec_ivas_fx( + Decoder_State *st /* i/o: decoder state structure */ +) +{ + TD_BWE_DEC_HANDLE hBWE_TD; + + hBWE_TD = st->hBWE_TD; + + IF( NE_16( st->last_core, ACELP_CORE ) ) + { + set16_fx( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); + hBWE_TD->bwe_non_lin_prev_scale_fx = L_deposit_l( 0 ); + st->prev_Q_bwe_exc = 31; + move16(); + } + test(); + IF( EQ_16( st->bwidth, WB ) ) + { + wb_tbe_extras_reset_fx( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, hBWE_TD->mem_genSHBexc_filt_down_wb3_fx ); + wb_tbe_extras_reset_synth_fx( hBWE_TD->state_lsyn_filt_shb_fx, hBWE_TD->state_lsyn_filt_dwn_shb_fx, hBWE_TD->state_32and48k_WB_upsample_fx, hBWE_TD->mem_resamp_HB_fx ); + + set16_fx( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, 0, 7 ); + set16_fx( hBWE_TD->state_lpc_syn_fx, 0, 10 ); + set16_fx( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD / 4 ); + set16_fx( hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); + set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); + } + ELSE IF( EQ_16( st->bwidth, SWB ) || EQ_16( st->bwidth, FB ) ) + { + swb_tbe_reset_fx( hBWE_TD->mem_csfilt_fx, hBWE_TD->mem_genSHBexc_filt_down_shb_fx, hBWE_TD->state_lpc_syn_fx, hBWE_TD->syn_overlap_fx, hBWE_TD->state_syn_shbexc_fx, &( hBWE_TD->tbe_demph_fx ), &( hBWE_TD->tbe_premph_fx ), hBWE_TD->mem_stp_swb_fx, &( hBWE_TD->gain_prec_swb_fx ) ); + + set16_fx( st->GainShape_Delay, 0, NUM_SHB_SUBFR / 2 ); + set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN ); + set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); + hBWE_TD->prev_pow_exc16kWhtnd_fx = 32767; /*Q15 1.f*/ + hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f */ + swb_tbe_reset_synth_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx ); + + + IF( EQ_16( st->bwidth, FB ) ) + { + IF( st->hBWE_FD != NULL ) + { + st->prev_fb_ener_adjust_fx = 0; + } + set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); + hBWE_TD->fb_tbe_demph_fx = 0; + fb_tbe_reset_synth_fx( hBWE_TD->fbbwe_hpf_mem_fx, hBWE_TD->fbbwe_hpf_mem_fx_Q, &hBWE_TD->prev_fbbwe_ratio_fx ); + } + } + + return; +} + +#endif // IVAS_FLOAT_FIXED + /*-------------------------------------------------------------------* * td_bwe_dec_init() diff --git a/lib_dec/waveadjust_fec_dec_fx.c b/lib_dec/waveadjust_fec_dec_fx.c index ba1a91687..323cd536a 100644 --- a/lib_dec/waveadjust_fec_dec_fx.c +++ b/lib_dec/waveadjust_fec_dec_fx.c @@ -831,6 +831,68 @@ void concealment_init_x(Word16 N, void *_plcInfo) } return; } +#ifdef IVAS_FLOAT_FIXED +void concealment_init_ivas_fx( + const Word16 L_frameTCX, + T_PLCInfo_HANDLE hPlcInfo ) +{ + Word16 i; + hPlcInfo->L_frameTCX = L_frameTCX; + hPlcInfo->FrameSize = L_frameTCX; + move16(); + hPlcInfo->Pitch = 0; + hPlcInfo->Pitch_fx = 0; + move16(); + hPlcInfo->T_bfi = 0; + hPlcInfo->T_bfi_fx = 0; + move16(); + hPlcInfo->outx_new_n1_fx = 0; + move16(); + hPlcInfo->nsapp_gain_fx = 0; + move16(); + hPlcInfo->nsapp_gain_n_fx = 0; + move16(); + hPlcInfo->ener_mean_fx = L_deposit_l( 15213 ); + hPlcInfo->ener_fx = L_deposit_l( 0 ); + hPlcInfo->zp = L_frameTCX; + hPlcInfo->zp_fx = L_frameTCX; + move16(); + hPlcInfo->recovery_gain = 0; + move16(); + hPlcInfo->step_concealgain_fx = 0; + move16(); + hPlcInfo->concealment_method = TCX_NONTONAL; + move16(); + hPlcInfo->subframe = 0; + hPlcInfo->subframe_fx = 0; + move16(); + hPlcInfo->nbLostCmpt = (Word16)L_deposit_l( 0 ); + hPlcInfo->seed = RANDOM_INITSEED; + move16(); + + FOR( i = 0; i < TCX_TONALITY_INIT_CNT; i++ ) + { + hPlcInfo->TCX_Tonality[i] = 1; + move16(); + } + FOR( i = TCX_TONALITY_INIT_CNT; i < DEC_STATE_LEN; i++ ) + { + hPlcInfo->TCX_Tonality[i] = 0; + move16(); + } + FOR( i = 0; i < MAX_POST_LEN; i++ ) + { + hPlcInfo->Transient[i] = 1; + move16(); + } + + FOR( i = 0; i < L_FRAME_MAX; i++ ) + { + hPlcInfo->data_reci2_fx[i] = L_deposit_l( 0 ); + } + return; +} +#endif // IVAS_FLOAT_FIXED static Word16 own_random_fix( /* o : output random value */ Word16 *seed /* i/o: random seed */ -- GitLab