From 479270d0f45aa0e7e7789959a3b87261ed4e6473 Mon Sep 17 00:00:00 2001 From: Sandesh Venkatesh Date: Fri, 3 May 2024 16:38:26 +0530 Subject: [PATCH] ivas_mc_dec_reconfig conversion, ivas_cpe and ivas_jbm cleanup [x] TonalMDCTConceal_INSTANCE structure cleanup [x] ivas_cpe and ivas_jbm cleanup [x] ivas_mc_dec_reconfig, ivas_lfe_plc converted to fixed point --- Workspace_msvc/lib_dec.vcxproj | 1 + lib_com/float_to_fix_ops.c | 24 +- lib_com/ivas_cnst.h | 8 +- lib_com/ivas_mdct_imdct_fx.c | 22 +- lib_com/ivas_prot.h | 13 +- lib_com/ivas_prot_fx.h | 8 +- lib_com/ivas_rom_com.c | 22 +- lib_com/ivas_rom_com.h | 6 +- lib_com/modif_fs_fx.c | 2 +- lib_dec/acelp_core_dec_ivas_fx.c | 27 +- lib_dec/cng_dec_fx.c | 3 - lib_dec/core_dec_init.c | 4 +- lib_dec/core_dec_init_fx.c | 6 +- lib_dec/core_switching_dec.c | 4 +- lib_dec/core_switching_dec_fx.c | 7 +- lib_dec/init_dec_fx.c | 6 - lib_dec/ivas_binRenderer_internal.c | 3 +- lib_dec/ivas_core_dec.c | 86 +- lib_dec/ivas_corecoder_dec_reconfig.c | 34 +- lib_dec/ivas_cpe_dec_fx.c | 70 +- lib_dec/ivas_dirac_output_synthesis_cov.c | 24 +- lib_dec/ivas_init_dec.c | 162 +- lib_dec/ivas_ism_dec.c | 49 +- lib_dec/ivas_jbm_dec.c | 1420 ++---------------- lib_dec/ivas_lfe_dec.c | 3 +- lib_dec/ivas_lfe_dec_fx.c | 21 +- lib_dec/ivas_lfe_plc.c | 3 +- lib_dec/ivas_lfe_plc_fx.c | 990 ++++++++++++ lib_dec/ivas_ls_custom_dec.c | 5 +- lib_dec/ivas_mc_param_dec.c | 786 +++++++++- lib_dec/ivas_mct_dec.c | 895 ++++++++++- lib_dec/ivas_mdct_core_dec.c | 10 +- lib_dec/ivas_mono_dmx_renderer.c | 9 +- lib_dec/ivas_omasa_dec.c | 5 +- lib_dec/ivas_osba_dec.c | 6 +- lib_dec/ivas_out_setup_conversion.c | 132 +- lib_dec/ivas_post_proc.c | 11 + lib_dec/ivas_sba_dec.c | 4 +- lib_dec/ivas_sba_rendering_internal.c | 93 +- lib_dec/ivas_sce_dec_fx.c | 94 +- lib_dec/ivas_spar_decoder.c | 94 +- lib_dec/ivas_spar_md_dec.c | 8 +- lib_dec/ivas_stat_dec.h | 64 +- lib_dec/ivas_stereo_cng_dec.c | 14 +- lib_dec/ivas_stereo_dft_dec.c | 577 +------ lib_dec/ivas_stereo_dft_dec_fx.c | 193 ++- lib_dec/ivas_stereo_switching_dec.c | 8 +- lib_dec/ivas_tcx_core_dec.c | 16 +- lib_dec/stat_dec.h | 35 +- lib_dec/swb_tbe_dec.c | 246 +-- lib_dec/swb_tbe_dec_fx.c | 67 +- lib_dec/tonalMDCTconcealment.c | 8 +- lib_dec/tonalMDCTconcealment_fx.c | 12 +- lib_rend/ivas_crend.c | 6 + lib_rend/ivas_dirac_ana.c | 23 +- lib_rend/ivas_dirac_dec_binaural_functions.c | 7 +- lib_rend/ivas_orient_trk.c | 20 +- lib_rend/ivas_prot_rend.h | 6 + lib_rend/ivas_reverb.c | 60 +- lib_rend/ivas_rom_rend.c | 4 +- lib_rend/ivas_rom_rend.h | 3 +- lib_rend/ivas_rotation.c | 58 +- lib_rend/ivas_stat_rend.h | 115 +- lib_rend/lib_rend.c | 77 +- 64 files changed, 3476 insertions(+), 3323 deletions(-) create mode 100644 lib_dec/ivas_lfe_plc_fx.c diff --git a/Workspace_msvc/lib_dec.vcxproj b/Workspace_msvc/lib_dec.vcxproj index f51c45ee2..d6e4a7c67 100644 --- a/Workspace_msvc/lib_dec.vcxproj +++ b/Workspace_msvc/lib_dec.vcxproj @@ -297,6 +297,7 @@ + diff --git a/lib_com/float_to_fix_ops.c b/lib_com/float_to_fix_ops.c index 3620d6fe7..736b2f38a 100644 --- a/lib_com/float_to_fix_ops.c +++ b/lib_com/float_to_fix_ops.c @@ -694,10 +694,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( } //st->hTcxDec->tcxltp_last_gain_unmodified = (Word16) floatToFixed( st->hTcxDec->tcxltp_last_gain_unmodified_float, 15 ); - if ( st->hTonalMDCTConc != NULL ) - { - floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, st->hTonalMDCTConc->nSamples ); - } + //if ( st->hTonalMDCTConc != NULL ) + //{ + // floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, st->hTonalMDCTConc->nSamples ); + //} st->Q_syn = 0; @@ -721,10 +721,10 @@ void stereo_tcx_dec_mode_switch_reconf_To_fixed_2( floatToFixed_arr( st->hHQ_core->old_out + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), st->hHQ_core->old_out_fx + NS2SA( st->output_Fs, N_ZERO_MDCT_NS ), 0, NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - if ( !st->tcxonly ) - { - floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); - } + //if ( !st->tcxonly ) + //{ + // floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); + //} st->mem_error = st->hBPF->pst_mem_deemp_err_fx; @@ -829,10 +829,10 @@ void fixed_to_float_stereo_tcx_core_dec( //fixedToFloat_arr( hTcxDec->old_synthFB_fx, hTcxDec->old_synthFB, 0, NS2SA_fx2( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) + hTcxDec->old_synth_lenFB ); - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } + //if ( !st->tcxonly ) + //{ + // fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); + //} st->hBPF->pst_mem_deemp_err_fx = (Word16)st->mem_error; /*=================================*/ diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index f3bbf79d2..2e36dc469 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -1046,15 +1046,15 @@ typedef enum /* Common SPAR metadata constants */ #define IVAS_ACTIVEW_DM_F_SCALE 0.5f -#define IVAS_ACTIVEW_DM_F_SCALE_FX IVAS_ACTIVEW_DM_F_SCALE * ONE_IN_Q31 +#define IVAS_ACTIVEW_DM_F_SCALE_FX (1073741824) /* 0.5f in Q31 */ #define IVAS_ACTIVEW_DM_F_SCALE_DTX 0.25f -#define IVAS_ACTIVEW_DM_F_SCALE_DTX_FX IVAS_ACTIVEW_DM_F_SCALE_DTX * ONE_IN_Q31 +#define IVAS_ACTIVEW_DM_F_SCALE_DTX_FX (536870912) /* 0.25f in Q31 */ #define IVAS_ACTIVEW_DM_F_SCALE_VLBR 0.25f -#define IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX IVAS_ACTIVEW_DM_F_SCALE_VLBR * ONE_IN_Q31 +#define IVAS_ACTIVEW_DM_F_SCALE_VLBR_FX (536870912) /* 0.25f in Q31 */ #define IVAS_SPAR_FOA_DFLT_FREQ_PER_CHAN 24000 #define IVAS_SPAR_DYN_ACTIVEW_THRESH (0.0039f) -#define IVAS_SPAR_DYN_ACTIVEW_THRESH_FX IVAS_SPAR_DYN_ACTIVEW_THRESH * ONE_IN_Q31 +#define IVAS_SPAR_DYN_ACTIVEW_THRESH_FX (8375186) /* 0.0039f in Q31 */ #define IVAS_SPAR_SIDE_CH_DYN_ACTIVEW_THRESH (32.0f) #define MAX_QUANT_STRATS 3 diff --git a/lib_com/ivas_mdct_imdct_fx.c b/lib_com/ivas_mdct_imdct_fx.c index d9c8a58ec..a9c7370fa 100644 --- a/lib_com/ivas_mdct_imdct_fx.c +++ b/lib_com/ivas_mdct_imdct_fx.c @@ -71,10 +71,12 @@ void ivas_tda_fx( Word16 i; Word16 len_by_2 = shr(length, 1); - FOR ( i = 0; i < len_by_2; i++ ) + FOR( i = 0; i < len_by_2; i++ ) { - pOut[i] = L_sub(pIn[len_by_2 + i], pIn[len_by_2 - i - 1]); - pOut[len_by_2 + i] = L_add(pIn[length * 2 - i - 1], pIn[length + i]); + pOut[i] = L_sub( pIn[add( len_by_2, i )], pIn[sub( sub( len_by_2, i ), 1 )] ); + move32(); + pOut[add( len_by_2, i )] = L_add( pIn[sub( sub( i_mult( length, 2 ), i ), 1 )], pIn[add( length, i )] ); + move32(); } return; @@ -105,23 +107,23 @@ void ivas_dct_windowing_fx( Copy32( pTemp_lfe, ( pOut_buf + fade_len + zero_pad_len ), dct_len ); - set32_fx(pOut_buf, 0, zero_pad_len); + set32_fx( pOut_buf, 0, zero_pad_len ); Copy32( ( pOut_buf + full_len - fade_len ), pBuffer_prev, fade_len ); - FOR ( i = 0; i < fade_len; i++ ) + FOR( i = 0; i < fade_len; i++ ) { - pOut_buf[zero_pad_len + i] = Mult_32_32(pOut_buf[zero_pad_len + i], pWindow_coeffs[i]); + pOut_buf[add( zero_pad_len, i )] = Mult_32_32( pOut_buf[add( zero_pad_len, i )], pWindow_coeffs[i] ); } - rem_len = full_len - ( zero_pad_len * 3 + fade_len ); + rem_len = sub( full_len, ( add( i_mult( zero_pad_len, 3 ), fade_len ) ) ); - FOR ( i = 0; i < rem_len; i++ ) + FOR( i = 0; i < rem_len; i++ ) { - pOut_buf[zero_pad_len * 3 + fade_len + i] = Mult_32_32(pOut_buf[zero_pad_len * 3 + fade_len + i], pWindow_coeffs[fade_len - i - 1]); + pOut_buf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )] = Mult_32_32( pOut_buf[add( add( i_mult( zero_pad_len, 3 ), fade_len ), i )], pWindow_coeffs[sub( sub( fade_len, i ), 1 )] ); } - set32_fx(&pOut_buf[full_len], 0, frame_len - full_len); + set32_fx( &pOut_buf[full_len], 0, sub( frame_len, full_len ) ); return; } diff --git a/lib_com/ivas_prot.h b/lib_com/ivas_prot.h index c3a997af0..52fd2480c 100644 --- a/lib_com/ivas_prot.h +++ b/lib_com/ivas_prot.h @@ -4127,8 +4127,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nchan_transport_old, /* i : number of TCs in previous frame */ Word16 numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ - const Word16 numCldfbSyntheses_old, /* i : number of CLDFB synthesis instances in previous frame */ - const Word16 Q_cldfbSynDec + const Word16 numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ ); #endif // IVAS_FLOAT_FIXED @@ -4630,6 +4629,11 @@ void ivas_param_mc_enc( float *data_f[], /* i/o: input/transport MC data */ const int16_t input_frame /* i : input frame length */ ); +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_param_mc_dec_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); +#endif // IVAS_FLOAT_FIXED ivas_error ivas_param_mc_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -4644,6 +4648,11 @@ ivas_error ivas_param_mc_dec_reconfig_fx( ivas_error ivas_param_mc_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ); +#ifdef IVAS_FLOAT_FIXED +void ivas_param_mc_dec_close_fx( + PARAM_MC_DEC_HANDLE *hParamMC_out /* i/o: Parametric MC decoder handle */ +); +#endif // IVAS_FLOAT_FIXED void ivas_param_mc_dec_close( PARAM_MC_DEC_HANDLE *hParamMC /* i/o: Parametric MC decoder handle */ diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index c5f92d81c..cdd3f2c3f 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -150,7 +150,6 @@ ivas_error ivas_omasa_ism_metadata_dec_fx( ivas_error ivas_omasa_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - Word16 Q_cldfbSynDec, /* i : Q factor for cldfb state */ Word16 *num_src, Word16 SrcInd[MAX_NUM_TDREND_CHANNELS], Word16 *data /* o : output synthesis signal */ @@ -819,6 +818,13 @@ void ivas_lfe_dec_fx( Word32 output_lfe_ch[] /* o : output LFE synthesis */ ); +void ivas_lfe_tdplc_fx( + LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ + const Word32 *prevsynth, /* i : previous frame synthesis */ + Word32 *ytda, /* o : output time-domain buffer */ + const Word16 output_frame /* i : output frame length */ +); + void ivas_lfe_dec_close_fx( LFE_DEC_HANDLE *hLFE /* i/o: LFE decoder handle */ ); diff --git a/lib_com/ivas_rom_com.c b/lib_com/ivas_rom_com.c index 9b5c18ccb..39fb8cd23 100644 --- a/lib_com/ivas_rom_com.c +++ b/lib_com/ivas_rom_com.c @@ -3950,6 +3950,26 @@ const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP] = { 1, 0 }; const float ivas_lfe_lpf_delay[2] = { 0.00175f, 0.0035f }; const Word16 ivas_lfe_lpf_delay_Q15[2] = { 57, 114 }; +#ifdef IVAS_FLOAT_FIXED +//Q31 +const UWord32 d_hamm_lfe_plc_fx[LFE_PLC_LENANA / 2] = { + 171798691, 172140039, 173163845, 174869403, 177255533, 180320587, 184062447, 188478526, + 193565772, 199320670, 205739242, 212817053, 220549212, 228930373, 237954746, 247616094, + 257907739, 268822570, 280353042, 292491188, 305228618, 318556530, 332465713, 346946555, + 361989047, 377582794, 393717019, 410380572, 427561937, 445249239, 463430255, 482092421, + 501222838, 520808286, 540835229, 561289828, 582157945, 603425159, 625076772, 647097821, + 669473086, 692187106, 715224182, 738568392, 762203605, 786113486, 810281510, 834690976, + 859325014, 884166600, 909198565, 934403610, 959764316, 985263157, 1010882509, 1036604668, + 1062411858, 1088286242, 1114209939, 1140165034, 1166133589, 1192097656, 1218039293, 1243940572, + 1269783591, 1295550491, 1321223465, 1346784770, 1372216740, 1397501800, 1422622476, 1447561406, + 1472301355, 1496825225, 1521116069, 1545157098, 1568931699, 1592423440, 1615616087, 1638493611, + 1661040202, 1683240277, 1705078494, 1726539762, 1747609248, 1768272390, 1788514910, 1808322817, + 1827682422, 1846580346, 1865003529, 1882939237, 1900375077, 1917298998, 1933699304, 1949564660, + 1964884103, 1979647046, 1993843284, 2007463009, 2020496806, 2032935668, 2044771000, 2055994621, + 2066598775, 2076576133, 2085919801, 2094623320, 2102680676, 2110086301, 2116835076, 2122922337, + 2128343877, 2133095950, 2137175272, 2140579023, 2143304850, 2145350871, 2146715671, 2147398307 +}; +#else const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = { 0.08000000000000002, 0.08015895227847719, 0.08063569926248770, 0.08142991147368656, 0.08254104003450596, 0.08396831704748331, 0.08571075612595230, 0.08776715307573196, @@ -3968,7 +3988,7 @@ const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2] = 0.96233504613317988, 0.96698111571154954, 0.97133209998031445, 0.97538499198789563, 0.97913699079334116, 0.98258550340204664, 0.98572814655776630, 0.98856274838967395, 0.99108734991333569, 0.99330020638455863, 0.99519978850517732, 0.99678478347994692, 0.99805409592381300, 0.99900684861892730, 0.99964238312089115, 0.99996026021380402 }; - +#endif /*------------------------------------------------------------------------------------------* * MDFT/iMDFT ROM tables diff --git a/lib_com/ivas_rom_com.h b/lib_com/ivas_rom_com.h index dff83ec21..360d5095a 100644 --- a/lib_com/ivas_rom_com.h +++ b/lib_com/ivas_rom_com.h @@ -451,9 +451,11 @@ extern const int16_t ivas_lfe_min_shift_tbl[IVAS_LFE_NUM_COEFFS_IN_SUBGRP]; extern const ivas_lfe_freq_models ivas_str_lfe_freq_models; extern const float ivas_lfe_lpf_delay[2]; extern const Word16 ivas_lfe_lpf_delay_Q15[2]; - +#ifdef IVAS_FLOAT_FIXED +extern const UWord32 d_hamm_lfe_plc_fx[LFE_PLC_LENANA / 2]; +#else extern const double d_hamm_lfe_plc[LFE_PLC_LENANA / 2]; - +#endif extern const float ivas_sin_twiddle_480[IVAS_480_PT_LEN >> 1]; extern const float ivas_cos_twiddle_480[IVAS_480_PT_LEN >> 1]; extern const float ivas_sin_twiddle_320[IVAS_320_PT_LEN >> 1]; diff --git a/lib_com/modif_fs_fx.c b/lib_com/modif_fs_fx.c index 8cd86a314..be45576b7 100644 --- a/lib_com/modif_fs_fx.c +++ b/lib_com/modif_fs_fx.c @@ -221,7 +221,7 @@ Word16 modify_Fs_fx( /* o : length of output Q0 */ } /* interpolation */ - datastep = shr(div_s(shl(fac_den,8), shl(fac_num,11)),12); + datastep = shr(div_s(shl(fac_den,7), shl(fac_num,10)),12); /* equivalent to 'datastep = fac_den % fac_num' */ temp_n = i_mult2(datastep,fac_num); /*Q0*/ fracstep = sub(fac_den,temp_n); diff --git a/lib_dec/acelp_core_dec_ivas_fx.c b/lib_dec/acelp_core_dec_ivas_fx.c index 13a5425e2..5c76a407c 100644 --- a/lib_dec/acelp_core_dec_ivas_fx.c +++ b/lib_dec/acelp_core_dec_ivas_fx.c @@ -1519,6 +1519,7 @@ ivas_error acelp_core_dec_ivas_fx( IF(st->p_bpf_noise_buf_32) { Copy32(bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame); + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); } for (i = 0; i < L_FRAME16k; i++) @@ -1618,7 +1619,7 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32( realBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_real); Scale_sig32( imagBuffer_fx[i], CLDFB_NO_CHANNELS_MAX, Q_imag); } - Scale_sig32( st->cldfbSynHB->cldfb_state_fx, (Q_real - 1) - Q10, st->cldfbSynHB->p_filter_length); // (Q_real-1) + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, ( Q_real - 1 ) - Q10 ); // (Q_real-1) Scale_sig32(save_hb_synth_fx, L_FRAME48k, Q_real - 1); FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -1638,7 +1639,7 @@ ivas_error acelp_core_dec_ivas_fx( cldfbSynthesis_ivas_fx(realBuffer_fx, imagBuffer_fx, save_hb_synth_fx, -1, st->cldfbSynHB); Scale_sig32(save_hb_synth_fx, L_FRAME48k, -(Q_real - 1)); //Q0 - Scale_sig32(st->cldfbSynHB->cldfb_state_fx, Q10 - (Q_real - 1), st->cldfbSynHB->p_filter_length); // Q10 + Scale_sig32( st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->p_filter_length, Q10 - ( Q_real - 1 ) ); // Q10 /* restore lowband */ FOR( j = 0; j < CLDFB_NO_CHANNELS_MAX; j++ ) @@ -1760,10 +1761,12 @@ ivas_error acelp_core_dec_ivas_fx( Scale_sig32(synth_fx, L_FRAME48k, -(Q_real - 1)); Scale_sig32(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->p_filter_length, Q10 - (Q_real - 1)); - if (st->p_bpf_noise_buf_float) + if (st->p_bpf_noise_buf_32) { Copy_Scale_sig_16_32(bpf_error_signal_16fx, bpf_error_signal_fx, st->L_frame, -1); //Q_syn-1 Copy32(bpf_error_signal_fx, st->p_bpf_noise_buf_32, st->L_frame); + + Scale_sig32( st->p_bpf_noise_buf_32, st->L_frame, sub( Q11, sub( st->Q_syn, 1 ) ) ); } set_l(synth_fx, 0, output_frame); @@ -1831,9 +1834,9 @@ ivas_error acelp_core_dec_ivas_fx( if (!st->ppp_mode_dec && (st->idchan == 0 || st->element_mode != IVAS_CPE_TD || (st->idchan == 1 && st->element_mode == IVAS_CPE_TD && st->tdm_LRTD_flag))) { - Copy_Scale_sig_16_32(st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, 2 * st->Q_exc); + Copy_Scale_sig_16_32( st->hBWE_TD->old_bwe_exc_extended_fx, bwe_exc_extended_fx, NL_BUFF_OFFSET, ( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) ); non_linearity_ivas_fx( bwe_exc_fx, bwe_exc_extended_fx + NL_BUFF_OFFSET, L_FRAME32k, &st->hBWE_TD->bwe_non_lin_prev_scale_fx, st->Q_exc, st->coder_type, voice_factors_fx, st->L_frame ); - Copy_Scale_sig_32_16(bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -(2 * st->Q_exc)); + Copy_Scale_sig_32_16( bwe_exc_extended_fx + L_FRAME32k, st->hBWE_TD->old_bwe_exc_extended_fx, NL_BUFF_OFFSET, -( 2 * st->Q_exc - ( st->prev_Q_bwe_exc - 16 ) ) ); } if ( st->core_brate == FRAME_NO_DATA || st->core_brate == SID_2k40 ) @@ -1909,11 +1912,6 @@ void acelp_decoder_state_float2fix(Decoder_State *st/*, STEREO_CNG_DEC_HANDLE hS st->hFdCngDec->hFdCngCom->cngNoiseLevelExp = Q31 - 4; floatToFixed_arrL(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, Q31 - st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, FFTCLDFBLEN); } - - /*TD_BWE_DEC_HANDLE*/ - if (st->hBWE_TD) { - floatToFixed_arr(st->hBWE_TD->old_bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended_fx, 0, NL_BUFF_OFFSET); - } } void acelp_decoder_state_fix2float(Decoder_State *st) { @@ -1929,10 +1927,6 @@ void acelp_decoder_state_fix2float(Decoder_State *st) { fixedToFloat_arrL(st->cldfbSynHB->cldfb_state_fx, st->cldfbSynHB->cldfb_state, Q10, st->cldfbSynHB->p_filter_length); fixedToFloat_arrL(st->cldfbSyn->cldfb_state_fx, st->cldfbSyn->cldfb_state, Q10, st->cldfbSyn->p_filter_length); - IF(st->p_bpf_noise_buf_32) { - fixedToFloat_arrL(st->p_bpf_noise_buf_32, st->p_bpf_noise_buf_float, st->Q_syn-1, st->L_frame); - } - //FdCng if ( st->hFdCngDec ) { @@ -1959,11 +1953,6 @@ void acelp_decoder_state_fix2float(Decoder_State *st) { } } } - - /*TD_BWE_DEC_HANDLE*/ - if (st->hBWE_TD) { - fixedToFloat_arr(st->hBWE_TD->old_bwe_exc_extended_fx, st->hBWE_TD->old_bwe_exc_extended, 0, NL_BUFF_OFFSET); - } } static void rescale_fdCngDec(HANDLE_FD_CNG_DEC hFdCngDec, Word16 Exp_diff) { diff --git a/lib_dec/cng_dec_fx.c b/lib_dec/cng_dec_fx.c index 3617fa5d0..abb6fd166 100644 --- a/lib_dec/cng_dec_fx.c +++ b/lib_dec/cng_dec_fx.c @@ -1324,9 +1324,6 @@ static void shb_CNG_decod_ivas_fx( } ResetSHBbuffer_Dec_fx( st ); -#if 1 // TODO: To be removed later - ResetSHBbuffer_Dec( st->hBWE_TD, st->extl ); -#endif return; } #endif diff --git a/lib_dec/core_dec_init.c b/lib_dec/core_dec_init.c index 662e4bc38..c5001197f 100644 --- a/lib_dec/core_dec_init.c +++ b/lib_dec/core_dec_init.c @@ -678,7 +678,6 @@ void open_decoder_LPD( { st->hBPF->pst_mem_deemp_err = 0.0f; } -#endif if (st->tcxonly) { st->p_bpf_noise_buf_float = NULL; @@ -689,6 +688,7 @@ void open_decoder_LPD( st->p_bpf_noise_buf_float = st->bpf_noise_buf_float; } +#endif if (bwidth == SWB && (total_brate == ACELP_16k40 || total_brate == ACELP_24k40) && st->element_mode == EVS_MONO) { @@ -729,7 +729,9 @@ void open_decoder_LPD( { st->hTonalMDCTConc->nScaleFactors = 0; st->hTonalMDCTConc->nSamples = 0; +#ifndef IVAS_FLOAT_FIXED st->hTonalMDCTConc->lastPcmOut_float = 0x0; +#endif st->hTonalMDCTConc->lastBlockData.tonalConcealmentActive = 0; st->hTonalMDCTConc->lastBlockData.nSamples = 0; diff --git a/lib_dec/core_dec_init_fx.c b/lib_dec/core_dec_init_fx.c index dd8502b67..d720137be 100644 --- a/lib_dec/core_dec_init_fx.c +++ b/lib_dec/core_dec_init_fx.c @@ -1771,13 +1771,11 @@ void open_decoder_LPD_ivas_fx( 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 ) ) @@ -1833,10 +1831,12 @@ void open_decoder_LPD_ivas_fx( st->hTonalMDCTConc->nScaleFactors = 0; st->hTonalMDCTConc->nSamples = 0; st->hTonalMDCTConc->lastPcmOut = 0x0; +#ifndef IVAS_FLOAT_FIXED //----------To be removed later: pointer initializations st->hTonalMDCTConc->lastPcmOut_float = 0x0; //---------- st->hTonalMDCTConc->lastPcmOut_float = 0x0; +#endif 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 ); @@ -1848,11 +1848,11 @@ void open_decoder_LPD_ivas_fx( st->hTonalMDCTConc->last_block_nrg_flt = 0.0f; st->hTonalMDCTConc->curr_noise_nrg_flt = 0.0f; st->hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; -#endif // #ifndef IVAS_FLOAT_FIXED 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 ) <= ( st->hTonalMDCTConc->lastPcmOut_float - st->hTonalMDCTConc->timeDataBuffer_float ) * sizeof( st->hTonalMDCTConc->timeDataBuffer_float[0] ) ); +#endif // #ifndef IVAS_FLOAT_FIXED } st->last_tns_active = 0; diff --git a/lib_dec/core_switching_dec.c b/lib_dec/core_switching_dec.c index e7238d971..ef01cc2bd 100644 --- a/lib_dec/core_switching_dec.c +++ b/lib_dec/core_switching_dec.c @@ -682,14 +682,14 @@ ivas_error core_switching_pre_dec_ivas_fx( { FOR( i = 0; i < shl(st->L_frame,1); i++ ) { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) floatToFixed( 0.6250f, 15 ) ); + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], (Word16) 20480 /* 0.6250f in Q15 */ ); } } ELSE { FOR( i = 0; i < shl(st->L_frame ,1); i++ ) { - st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) floatToFixed( 1.6f, 14 ) ); + st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i] = Mult_32_16( L_shl( st->hFdCngDec->hFdCngCom->olapBufferSynth_fx[i], 1 ), (Word16) 26214 /* 1.6f in Q14 */ ); } } } diff --git a/lib_dec/core_switching_dec_fx.c b/lib_dec/core_switching_dec_fx.c index 4b2713f41..d82aaea62 100644 --- a/lib_dec/core_switching_dec_fx.c +++ b/lib_dec/core_switching_dec_fx.c @@ -1492,9 +1492,9 @@ ivas_error core_switching_post_dec_fx( 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->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 ); + 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 ); } return error; @@ -2070,6 +2070,7 @@ ivas_error core_switching_post_dec_ivas_fx( 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->syn_overlap_fx_32, 0, L_SHB_LAHEAD ); set32_fx( hBWE_TD->mem_csfilt_fx, 0, 2 ); } } diff --git a/lib_dec/init_dec_fx.c b/lib_dec/init_dec_fx.c index e43ef4bed..c5cf8a7bc 100644 --- a/lib_dec/init_dec_fx.c +++ b/lib_dec/init_dec_fx.c @@ -1415,9 +1415,6 @@ ivas_error init_decoder_ivas_fx( return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TD BWE\n")); } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED // To be removed when fixed version is available. - td_bwe_dec_init(st_fx->hBWE_TD, st_fx->extl, st_fx->output_Fs); -#endif td_bwe_dec_init_ivas_fx(st_fx, st_fx->hBWE_TD, st_fx->output_Fs); } ELSE @@ -1823,9 +1820,6 @@ ivas_error init_decoder_ivas_fx( { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TonalMDCTConcealment\n")); } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - set_zero(st_fx->hTonalMDCTConc->timeDataBuffer_float, ( 3 * L_FRAME_MAX ) / 2); -#endif } ELSE { diff --git a/lib_dec/ivas_binRenderer_internal.c b/lib_dec/ivas_binRenderer_internal.c index cd17505e1..04c22da10 100644 --- a/lib_dec/ivas_binRenderer_internal.c +++ b/lib_dec/ivas_binRenderer_internal.c @@ -1979,9 +1979,10 @@ void ivas_binRenderer_close( IF( ( *hBinRenderer )->hReverb != NULL ) { - ivas_binaural_reverb_close( &( ( *hBinRenderer )->hReverb ) ); #ifdef IVAS_FLOAT_FIXED ivas_binaural_reverb_close_fx( &( ( *hBinRenderer )->hReverb ) ); +#else + ivas_binaural_reverb_close( &( ( *hBinRenderer )->hReverb ) ); #endif } diff --git a/lib_dec/ivas_core_dec.c b/lib_dec/ivas_core_dec.c index fd93643d2..25e7078cb 100644 --- a/lib_dec/ivas_core_dec.c +++ b/lib_dec/ivas_core_dec.c @@ -328,7 +328,6 @@ ivas_error ivas_core_dec( IF( sba_dirac_stereo_flag && hSCE && sts[0]->total_brate <= SID_2k40 && sts[0]->cng_type == FD_CNG ) { - floatToFixed_arrL( hSCE->save_hb_synth, hSCE->save_hb_synth_fx, Q11, output_frame ); save_hb_synth_32_fx = hSCE->save_hb_synth_fx; } ELSE @@ -507,7 +506,7 @@ ivas_error ivas_core_dec( if ( save_hb_synth_32_fx ) { Copy_Scale_sig_16_32( save_hb_synth_16_fx, save_hb_synth_32_fx, output_frame, Q11 ); - fixedToFloat_arrL( hSCE->save_hb_synth_fx, hSCE->save_hb_synth, negate( Q11 ), output_frame ); + hSCE->q_save_hb_synth_fx = Q11; } Copy_Scale_sig_16_32(old_syn_12k8_16k_fx_16, old_syn_12k8_16k_fx[n],L_FRAME16k,Q11 - (-1)); @@ -618,17 +617,8 @@ ivas_error ivas_core_dec( IF( st->hHQ_core ) floatToFixed_arr( st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, st->Q_syn, L_FRAME32k ); - if ( !st->tcxonly ) - { - floatToFixed_arr( st->p_bpf_noise_buf_float, st->p_bpf_noise_buf, 0, L_FRAME_16k ); - } - IF( st->hHQ_core ) floatToFixed_arr( st->hHQ_core->old_out, st->hHQ_core->old_out_fx, st->Q_syn, 960 ); - IF( st->hTonalMDCTConc ) - floatToFixed_arr( st->hTonalMDCTConc->lastPcmOut_float, st->hTonalMDCTConc->lastPcmOut, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) ); - IF( st->hTonalMDCTConc ) - floatToFixed_arr( st->hTonalMDCTConc->secondLastPcmOut_float, st->hTonalMDCTConc->secondLastPcmOut, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) / 2 ); if ( st->hTcxDec && st->hTcxDec->conLastFrameLevel_e < 0 ) { st->hTcxDec->conLastFrameLevel_e = 0; @@ -643,26 +633,26 @@ ivas_error ivas_core_dec( st->hTcxDec->conCurrLevelIndex = st->hTcxDec->CurrLevelIndex_bfi; } - IF( st_ivas->hLsSetUpConversion ) - f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion ) - f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion ) + //f2me_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion ) + //f2me_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], &st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->sfbCnt ); FOR( Word16 chOutIdx = 0; chOutIdx < st_ivas->hDecoderConfig->nchan_out; chOutIdx++ ) { FOR( Word16 chInIdx = 0; chInIdx < s_min( st_ivas->nchan_transport, 16 ); chInIdx++ ) { - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx] ) - st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx] ) + //st_ivas->hLsSetUpConversion->dmxMtx_fx[chInIdx][chOutIdx] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[chInIdx][chOutIdx], 30 ); /*Q30*/ } } #endif stereo_mdct_core_dec_fx( st_ivas, hCPE, output_32_fx, synth_16_fx ); #if 1 // Fix to float conversion - IF( st_ivas->hLsSetUpConversion ) - me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion ) - me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion ) + //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion ) + //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); FOR( ch = 0; ch < 2; ch++ ) { @@ -701,20 +691,10 @@ ivas_error ivas_core_dec( st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); } - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } - for ( int p = 0; p < 960; p++ ) { st->hHQ_core->old_out[p] = (float) st->hHQ_core->old_out_fx[p] / ( 1u << st->Q_syn ); } - - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, s_min( 960, st->hTonalMDCTConc->nSamples ) ); - IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, s_min( 480, st->hTonalMDCTConc->nSamples / 2 ) ); } Scale_sig(synth_16_fx[0],L_FRAME48k,e_sig - 15); @@ -802,10 +782,6 @@ ivas_error ivas_core_dec( #ifdef IVAS_FLOAT_FIXED /*cldfb struct*/ - IF(st->hBWE_TD != NULL) - { - floatToFixed_arr(st->hBWE_TD->old_bwe_exc_extended, st->hBWE_TD->old_bwe_exc_extended_fx, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET); - } /*------------------fix-to-fix-start---------------------*/ /*core_switching_post_dec*/ Q_synth = 0; @@ -841,7 +817,6 @@ ivas_error ivas_core_dec( /*size of synth is choosen as delay comp to start with*/ /*-------------------cldfb-start-------------------------*/ - floatToFixed_arrL(st->bpf_noise_buf_float, st->bpf_noise_buf_32, 11, L_FRAME_16k); if (st->cldfbAna != NULL) { floatToFixed_arrL(st->cldfbAna->cldfb_state, st->cldfbAna->cldfb_state_fx, 10, st->cldfbAna->cldfb_size); @@ -859,9 +834,6 @@ ivas_error ivas_core_dec( Word16 q_audio, old_syn_fx; old_syn_fx = Q11; q_audio = Q12; - if (hSCE != NULL) { - if(hSCE->save_synth != NULL)floatToFixed_arrL(hSCE->save_synth, hSCE->save_synth_fx, Q11, output_frame); - } #endif test(); test(); test(); test(); IF ( EQ_16(st->last_core, ACELP_CORE) && (EQ_16(st->core, TCX_20_CORE) || EQ_16(st->core, TCX_10_CORE) || EQ_16(st->core, HQ_CORE) ) && st->hBWE_TD != NULL ) @@ -904,7 +876,8 @@ ivas_error ivas_core_dec( test(); test(); test(); IF (sba_dirac_stereo_flag && NE_16(st->element_mode, IVAS_CPE_MDCT) && !(EQ_32(st->core_brate, SID_2k40) && EQ_16(st->cng_type, FD_CNG))) { - Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, Q11 - Q_synth); + //Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, Q11 - Q_synth); + Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, hSCE->q_save_synth_fx - Q_synth); } IF ( ( error = core_switching_post_dec_ivas_fx( st, synth_16_fx[n], output_32_fx[n], p_output_mem_16, ( st_ivas != NULL ) ? st_ivas->ivas_format : UNDEFINED_FORMAT, use_cldfb_for_dft, output_frame, 0 /*core_switching_flag*/, sba_dirac_stereo_flag, nchan_out, ( hCPE != NULL ) ? hCPE->last_element_mode : IVAS_SCE, &Q_synth ) ) != IVAS_ERR_OK ) @@ -916,7 +889,8 @@ ivas_error ivas_core_dec( test(); test(); test(); IF (sba_dirac_stereo_flag && hSCE && EQ_32(st->core_brate, SID_2k40) && EQ_16(st->cng_type, FD_CNG)) { - Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, Q11 - Q_synth); + //Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, Q11 - Q_synth); + Copy_Scale_sig_16_32(synth_16_fx[n], hSCE->save_synth_fx, output_frame, hSCE->q_save_synth_fx - Q_synth); } /* if we transition from inactive to active coding in MDCT-Stereo DTX and the output format is mono DMX, we need to sync the upsampled buffer between channels here */ @@ -935,9 +909,6 @@ ivas_error ivas_core_dec( Scale_sig32(output_32_fx[n], L_FRAME48k, Q11 - Q4); #ifdef IVAS_FLOAT_FIXED - if (hSCE != NULL) { - if (hSCE->save_synth != NULL)fixedToFloat_arrL(hSCE->save_synth_fx, hSCE->save_synth, Q11, output_frame); - } /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -977,7 +948,6 @@ ivas_error ivas_core_dec( st->hBWE_FD->prev_L_swb_norm = st->hBWE_FD->prev_L_swb_norm; st->hBWE_FD->prev_flag = st->hBWE_FD->prev_flag; } - #endif /*---------------------------------------------------------------------* * WB TBE decoding @@ -1002,11 +972,6 @@ ivas_error ivas_core_dec( Copy_Scale_sig_32_16(output_32_fx[n], output_16_fx[n], L_FRAME48k, negate(Q11)); Copy_Scale_sig_32_16(hb_synth_32_fx[n], hb_synth_16_fx[n], L_FRAME48k, negate(Q11)); - - IF( hBWE_TD != NULL ) - { - floatToFixed_arr( hBWE_TD->old_bwe_exc_extended, hBWE_TD->old_bwe_exc_extended_fx, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET ); - } #endif test(); test(); @@ -1145,13 +1110,6 @@ ivas_error ivas_core_dec( Copy_Scale_sig_16_32(st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, st->hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, 2 * ALLPASSSECTIONS_STEEP, -(st->prev_Q_bwe_syn2 - Q11)); } -#ifndef IVAS_FLOAT_CONV_TO_BE_REMOVED - - IF(hBWE_TD != NULL) - { - fixedToFloat_arr(hBWE_TD->old_bwe_exc_extended_fx, hBWE_TD->old_bwe_exc_extended, st->prev_Q_bwe_exc - 16, NL_BUFF_OFFSET); - } -#endif /*-------------------------------------------------------------------* * Inter-channel BWE decoding *-------------------------------------------------------------------*/ @@ -1372,13 +1330,6 @@ ivas_error ivas_core_dec( hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx[ind] = (Word32)(hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out[ind] * (1 << 11)); } } - if (hCPE->hCoreCoder[ch_ind]->p_bpf_noise_buf_float != NULL) - { - FOR(int ind = 0; ind < L_FRAME16k; ind++) - { - hCPE->hCoreCoder[ch_ind]->p_bpf_noise_buf_32[ind] = (Word32)(hCPE->hCoreCoder[ch_ind]->p_bpf_noise_buf_float[ind] * (1 << 11)); - } - } } } } @@ -1517,13 +1468,6 @@ ivas_error ivas_core_dec( hCPE->hCoreCoder[ch_ind]->hHQ_core->old_out[ind] = (float) hCPE->hCoreCoder[ch_ind]->hHQ_core->oldOut_fx[ind] / (float) ( 1 << 11 ); } } - if ( hCPE->hCoreCoder[ch_ind]->p_bpf_noise_buf_float != NULL ) - { - FOR( int ind = 0; ind < L_FRAME16k; ind++ ) - { - hCPE->hCoreCoder[ch_ind]->p_bpf_noise_buf_float[ind] = (float) hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[ind] / (float) ( 1 << 11 ); - } - } } } } diff --git a/lib_dec/ivas_corecoder_dec_reconfig.c b/lib_dec/ivas_corecoder_dec_reconfig.c index bae8ece3c..aa32ce707 100644 --- a/lib_dec/ivas_corecoder_dec_reconfig.c +++ b/lib_dec/ivas_corecoder_dec_reconfig.c @@ -122,13 +122,6 @@ ivas_error ivas_corecoder_dec_reconfig_fx( if ( st_ivas->hSCE[0] != NULL ) { -#if 1 /*TODO:To be removed later*/ - free( st_ivas->hSCE[0]->save_synth ); - st_ivas->hSCE[0]->save_synth = NULL; - - free( st_ivas->hSCE[0]->save_hb_synth ); - st_ivas->hSCE[0]->save_hb_synth = NULL; -#endif free( st_ivas->hSCE[0]->save_synth_fx ); st_ivas->hSCE[0]->save_synth_fx = NULL; @@ -400,33 +393,20 @@ ivas_error ivas_corecoder_dec_reconfig_fx( st_ivas->hCPE[0]->hCoreCoder[0] = st_ivas->hSCE[0]->hCoreCoder[0]; /* don't allocate unnecessary core coder, simply point to core coder of SCE element */ st_ivas->hCPE[0]->hCoreCoder[1] = NULL; - IF( st_ivas->hSCE[0]->save_synth == NULL ) + IF( st_ivas->hSCE[0]->save_synth_fx == NULL ) { -#if 1 /*TODO: To be removed later*/ - IF( ( st_ivas->hSCE[0]->save_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); - } - set_zero( st_ivas->hSCE[0]->save_synth, output_frame ); -#endif IF( ( st_ivas->hSCE[0]->save_synth_fx = (Word32 *) malloc( sizeof( *( st_ivas->hSCE[0]->save_synth_fx ) ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); } set32_fx( st_ivas->hSCE[0]->save_synth_fx, 0, output_frame ); st_ivas->hSCE[0]->q_save_synth_fx = 0; + //st_ivas->hSCE[0]->q_save_synth_fx = Q11; move16(); } - IF( st_ivas->hSCE[0]->save_hb_synth == NULL ) + IF( st_ivas->hSCE[0]->save_hb_synth_fx == NULL ) { -#if 1 /*TODO: To be removed later*/ - IF( ( st_ivas->hSCE[0]->save_hb_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); - } - set_zero( st_ivas->hSCE[0]->save_hb_synth, output_frame ); -#endif IF( ( st_ivas->hSCE[0]->save_hb_synth_fx = (Word32 *) malloc( sizeof( *( st_ivas->hSCE[0]->save_hb_synth_fx ) ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); @@ -953,8 +933,8 @@ ivas_error ivas_cldfb_dec_reconfig_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nchan_transport_old, /* i : number of TCs in previous frame */ Word16 numCldfbAnalyses_old, /* i : number of CLDFB analysis instances in previous frame */ - const Word16 numCldfbSyntheses_old, /* i : number of CLDFB synthesis instances in previous frame */ - const Word16 Q_cldfbSynDec ) + const Word16 numCldfbSyntheses_old /* i : number of CLDFB synthesis instances in previous frame */ +) { Word16 i, numCldfbAnalyses, numCldfbSyntheses; DECODER_CONFIG_HANDLE hDecoderConfig; @@ -974,7 +954,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( /* resample CLDFB analysis instances */ FOR( i = 0; i < min( numCldfbAnalyses, numCldfbAnalyses_old ); i++ ) { - IF( EQ_32( L_mult0( extract_l(L_mult0( st_ivas->cldfbAnaDec[i]->no_channels, st_ivas->cldfbAnaDec[i]->no_col )), FRAMES_PER_SEC ), hDecoderConfig->output_Fs ) ) + IF( NE_32( L_mult0( extract_l(L_mult0( st_ivas->cldfbAnaDec[i]->no_channels, st_ivas->cldfbAnaDec[i]->no_col )), FRAMES_PER_SEC ), hDecoderConfig->output_Fs ) ) { resampleCldfb_ivas_fx( st_ivas->cldfbAnaDec[i], hDecoderConfig->output_Fs ); } @@ -1027,7 +1007,7 @@ ivas_error ivas_cldfb_dec_reconfig_fx( FOR( i = 0; i < st_ivas->cldfbAnaDec[0]->cldfb_state_length; i++ ) st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbAnaDec[0]->cldfb_state_fx[i], 16 ); // Scaling down from 27 to 11 FOR( i = 0; i < st_ivas->cldfbSynDec[0]->cldfb_state_length; i++ ) - st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], 21- Q_cldfbSynDec); // Scaling down from 21 to Q_cldfbSynDec + st_ivas->cldfbSynDec[0]->cldfb_state_fx[i] = L_shr( st_ivas->cldfbSynDec[0]->cldfb_state_fx[i], 21 - 11); // Scaling down from 21 to 11 } return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_cpe_dec_fx.c b/lib_dec/ivas_cpe_dec_fx.c index 373b15f1a..bf2c88053 100644 --- a/lib_dec/ivas_cpe_dec_fx.c +++ b/lib_dec/ivas_cpe_dec_fx.c @@ -303,10 +303,7 @@ ivas_error ivas_cpe_dec_fx( IF( !st_ivas->bfi ) { /* Update DFT Stereo memories */ - stereo_dft_dec_update( hCPE->hStereoDft, output_frame, 0 ); -#ifdef IVAS_FLOAT_FIXED stereo_dft_dec_update_fx( hCPE->hStereoDft, output_frame, 0 ); -#endif IF( EQ_16( (Word16) st_ivas->ivas_format, MASA_FORMAT ) && LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) { @@ -367,18 +364,7 @@ ivas_error ivas_cpe_dec_fx( } } -#ifdef IVAS_FLOAT_FIXED -#if 1 - Word16 Q_coh = 13; - floatToFixed_arr( hCPE->hStereoCng->coh, hCPE->hStereoCng->coh_fx, Q_coh, 14 ); -#endif stereo_dft_dec_read_BS_fx( ivas_total_brate, hCPE->element_brate, &sts[0]->total_brate, sts[1], hCPE->hStereoDft, sts[0]->bwidth, output_frame, res_buf_fx, &nb_bits, hCPE->hStereoCng->coh_fx, st_ivas->ivas_format ); -#if 1 /*Fixed To Float changes*/ - fixedToFloat_arr( hCPE->hStereoCng->coh_fx, hCPE->hStereoCng->coh, Q_coh, 14 ); /*Q-13*/ -#endif -#else - stereo_dft_dec_read_BS( ivas_total_brate, hCPE->element_brate, &sts[0]->total_brate, sts[1], hCPE->hStereoDft, sts[0]->bwidth, output_frame, res_buf, &nb_bits, hCPE->hStereoCng->coh, st_ivas->ivas_format ); -#endif } /* subtract metadata bitbudget */ @@ -670,8 +656,6 @@ ivas_error ivas_cpe_dec_fx( Word16 q_dft; q_dft = hCPE->hStereoDft->q_dft; - floatToFixed_arr(&hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - floatToFixed_arr(&hCPE->hStereoCng->coh[0], &hCPE->hStereoCng->coh_fx[0], Q15, sizeof(hCPE->hStereoCng->coh_fx) / sizeof(hCPE->hStereoCng->coh_fx[0]) ); //TODO : To check this hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel = Q31 - hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevelExp; @@ -682,15 +666,12 @@ ivas_error ivas_cpe_dec_fx( &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->cngNoiseLevel_flt[0], hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->q_cngNoiseLevel, FFTCLDFBLEN ); - fixedToFloat_arr( &hCPE->hStereoCng->coh_fx[0], &hCPE->hStereoCng->coh[0], Q15, sizeof( hCPE->hStereoCng->coh_fx ) / sizeof( hCPE->hStereoCng->coh_fx[0] ) ); - fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } /* decoding */ IF( EQ_16( hCPE->nchan_out, 1 ) ) { #if 1 - float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { hCPE->hStereoDft->q_smoothed_nrg = hCPE->hStereoDft->q_dft; @@ -703,19 +684,15 @@ ivas_error ivas_cpe_dec_fx( scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; - - floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); #endif stereo_dft_unify_dmx_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng->prev_sid_nodata ); #if 1 scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); hCPE->hStereoDft->q_res_cod_mem_fx = Q16; - fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); #endif } ELSE { - float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; #if 1 { IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) @@ -730,17 +707,12 @@ ivas_error ivas_cpe_dec_fx( scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_res_cod_mem_fx ) ); hCPE->hStereoDft->q_res_cod_mem_fx = hCPE->hStereoDft->q_dft; - floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); } #endif stereo_dft_dec_fx( hCPE->hStereoDft, sts[0], DFT_fx, hCPE->input_mem_fx[1], hCPE->hStereoCng, 0, 0, 0, 0, 0, 0, MAX_PARAM_SPATIAL_SUBFRAMES ); #if 1 - { - fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - - scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); - hCPE->hStereoDft->q_res_cod_mem_fx = Q16; - } + scale_sig32( hCPE->hStereoDft->res_cod_mem_fx, STEREO_DFT_OVL_8k, sub( Q16, hCPE->hStereoDft->q_res_cod_mem_fx ) ); + hCPE->hStereoDft->q_res_cod_mem_fx = Q16; #endif } @@ -821,28 +793,7 @@ ivas_error ivas_cpe_dec_fx( IF( !st_ivas->sba_dirac_stereo_flag ) { - // Delete below - Word16 output_q = OUTPUT_Q; - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( Word32 k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth_fx[n][k] = (Word32) ( hCPE->prev_synth[n][k] * ( 1 << output_q ) ); - } - } - // till here - synchro_synthesis_fx( ivas_total_brate, hCPE, output, output_frame, 0 ); - - // delete the below - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( Word32 k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << output_q ); - } - } - // till here } test(); @@ -987,14 +938,6 @@ ivas_error create_cpe_dec( hCPE->nchan_out = 1; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - for ( n = 0; n < CPE_CHANNELS; n++ ) - { - //set_f( hCPE->prev_hb_synth[n], 0, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); - set_f( hCPE->prev_synth[n], 0, NS2SA( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ) ); - } -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED - FOR( n = 0; n < CPE_CHANNELS; n++ ) { set32_fx( hCPE->prev_hb_synth_fx[n], 0, NS2SA_fx2( output_Fs, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS ) ); @@ -1105,10 +1048,17 @@ ivas_error create_cpe_dec( IF( EQ_16( hCPE->element_mode, IVAS_CPE_DFT ) || ( st_ivas->sba_dirac_stereo_flag && EQ_16( hCPE->cpe_id, 0 ) ) ) { +#ifdef IVAS_FLOAT_FIXED + IF( ( error = stereo_dft_dec_create_fx( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) + { + return error; + } +#else IF( ( error = stereo_dft_dec_create( &( hCPE->hStereoDft ), hCPE->element_brate, output_Fs, st_ivas->sba_dirac_stereo_flag, st_ivas->nchan_transport ) ) != IVAS_ERR_OK ) { return error; } +#endif } /*-----------------------------------------------------------------* @@ -1229,7 +1179,7 @@ ivas_error create_cpe_dec( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Stereo CNG\n" ) ); } - stereo_cng_init_dec( hCPE->hStereoCng, &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->frameSize ); + stereo_cng_init_dec_fx( hCPE->hStereoCng, &hCPE->hCoreCoder[0]->hFdCngDec->hFdCngCom->frameSize ); } st_ivas->hCPE[cpe_id] = hCPE; diff --git a/lib_dec/ivas_dirac_output_synthesis_cov.c b/lib_dec/ivas_dirac_output_synthesis_cov.c index 2d3686cfa..c6d48cc4d 100644 --- a/lib_dec/ivas_dirac_output_synthesis_cov.c +++ b/lib_dec/ivas_dirac_output_synthesis_cov.c @@ -158,29 +158,29 @@ ivas_error ivas_dirac_dec_output_synthesis_cov_open_fx( set16_fx(h_dirac_output_synthesis_state->cx_old_e, 0, CLDFB_NO_CHANNELS_MAX); set16_fx(h_dirac_output_synthesis_state->cy_old_e, 0, CLDFB_NO_CHANNELS_MAX); - if ((h_dirac_output_synthesis_state->mixing_matrix_res_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) + if ((h_dirac_output_synthesis_state->mixing_matrix_res_exp = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, nchan_out * nchan_out); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, CLDFB_NO_CHANNELS_MAX); - if ((h_dirac_output_synthesis_state->mixing_matrix_res_old_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) + if ((h_dirac_output_synthesis_state->mixing_matrix_res_old_exp = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, nchan_out * nchan_out); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, CLDFB_NO_CHANNELS_MAX); - if ((h_dirac_output_synthesis_state->mixing_matrix_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) + if ((h_dirac_output_synthesis_state->mixing_matrix_exp = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_exp, 0, nchan_out * nchan_out); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_exp, 0, CLDFB_NO_CHANNELS_MAX); - if ((h_dirac_output_synthesis_state->mixing_matrix_old_exp = (Word16 *)malloc(nchan_out * nchan_out * sizeof(Word16))) == NULL) + if ((h_dirac_output_synthesis_state->mixing_matrix_old_exp = (Word16 *)malloc(CLDFB_NO_CHANNELS_MAX * sizeof(Word16))) == NULL) { return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DirAC synthesis matrix\n")); } - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_exp, 0, nchan_out * nchan_out); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_exp, 0, CLDFB_NO_CHANNELS_MAX); /*-----------------------------------------------------------------* * prepare processing parameters @@ -474,10 +474,10 @@ void ivas_dirac_dec_output_synthesis_cov_init_fx( } - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_exp, 0, nchan_out * nchan_in); - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_exp, 0, nchan_out * nchan_in); - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, nchan_out * nchan_out); - set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, nchan_out * nchan_out); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_old_exp, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_exp, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_old_exp, 0, CLDFB_NO_CHANNELS_MAX); + set16_fx(h_dirac_output_synthesis_state->mixing_matrix_res_exp, 0, CLDFB_NO_CHANNELS_MAX); #if 1/*TODO: To be removed :Floating point initializations*/ FOR ( idx = 0; idx < n_param_bands; idx++ ) { diff --git a/lib_dec/ivas_init_dec.c b/lib_dec/ivas_init_dec.c index 219d67aa7..4f8a83419 100644 --- a/lib_dec/ivas_init_dec.c +++ b/lib_dec/ivas_init_dec.c @@ -238,7 +238,7 @@ ivas_error ivas_dec_setup( DECODER_CONFIG_HANDLE hDecoderConfig=NULL; Word16 numch_out_dirac=0; SPAR_DEC_HANDLE hSpar = NULL; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in, numch_out, num_md_sub_frames; IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) @@ -271,31 +271,6 @@ ivas_error ivas_dec_setup( numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( int j = 0; j < numch_in; j++ ) - { - for ( int n = 0; n < num_md_sub_frames * IVAS_MAX_NUM_BANDS; n++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][n] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][n], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for (int n = 0; n < IVAS_MAX_SPAR_FB_MIXER_IN_CH; n++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][n][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][n][l], q2 ); - } - } - } - } -#endif for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -356,21 +331,6 @@ ivas_error ivas_dec_setup( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ((float)(st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i]) / (1LL << (Q11))); /*Rounding off*/ } } -#if 0 - FOR(int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++) - { - FOR(int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++) - { - FOR(int n = 0; n < IVAS_MAX_SPAR_FB_MIXER_IN_CH; n++) - { - FOR(int l = 0; l < IVAS_MAX_NUM_BANDS; l++) - { - hSpar->hMdDec->mixer_mat_prev[m][j][n][l] = ((float)hSpar->hMdDec->mixer_mat_prev_fx[m][j][n][l] / (1 << q2)); - } - } - } - } -#endif // fix2float (to be cleaned) IF((LT_32(hDecoderConfig->ivas_total_brate, IVAS_24k4)) && ((EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2)) || (EQ_16(hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3)))) { @@ -437,7 +397,7 @@ ivas_error ivas_dec_setup( } //////////////////////////////////////////////////////////////// - IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, Q_cldfbSynDec, &num_src, SrcInd, data ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ) != IVAS_ERR_OK ) { return error; } @@ -578,7 +538,7 @@ ivas_error ivas_dec_setup( } //////////////////////////////////////////////////////////////// - IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, Q_cldfbSynDec, &num_src, SrcInd, data ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_omasa_dec_config_fx( st_ivas, nSamplesRendered, &num_src, SrcInd, data ) ) != IVAS_ERR_OK ) { return error; } @@ -1206,7 +1166,7 @@ ivas_error ivas_init_decoder_front( { set_zero((st_ivas->hLsSetupCustom)->ls_azimuth, MAX_OUTPUT_CHANNELS ); set_zero((st_ivas->hLsSetupCustom)->ls_elevation, MAX_OUTPUT_CHANNELS ); - set_f( ( st_ivas->hLsSetupCustom )->separate_ch_gains, 0.0f, MAX_OUTPUT_CHANNELS ); + //set_f( ( st_ivas->hLsSetupCustom )->separate_ch_gains, 0.0f, MAX_OUTPUT_CHANNELS ); } ELSE #else @@ -1221,13 +1181,13 @@ ivas_error ivas_init_decoder_front( * Allocate and initialize Head-Tracking handle *--------------------------------------------------------------------*/ - IF ( st_ivas->hDecoderConfig->Opt_Headrotation ) +#ifdef IVAS_FLOAT_FIXED + IF( st_ivas->hDecoderConfig->Opt_Headrotation ) { - IF ( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_headTrack_open_fx( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) { return error; } -#ifdef IVAS_FLOAT_FIXED error = ivas_orient_trk_SetTrackingType_fx( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ); IF( ( error ) != IVAS_ERR_OK ) { @@ -1235,7 +1195,13 @@ ivas_error ivas_init_decoder_front( } } #else - IF ( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) + IF( st_ivas->hDecoderConfig->Opt_Headrotation ) + { + IF( ( error = ivas_headTrack_open( &( st_ivas->hHeadTrackData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + IF( ( error = ivas_orient_trk_SetTrackingType( st_ivas->hHeadTrackData->OrientationTracker, st_ivas->hDecoderConfig->orientation_tracking ) ) != IVAS_ERR_OK ) { return error; } @@ -2003,11 +1969,62 @@ ivas_error ivas_init_decoder_fx( return error; } } - +#ifdef IVAS_FLOAT_FIXED + IF( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1/*Fixed to float conversions*/ + PARAM_MC_DEC_HANDLE hParamMC; + hParamMC = st_ivas->hParamMC; + Word16 nchan_out_transport, nchan_out_cov; + MC_LS_SETUP mc_ls_setup; + Word16 nchan_transport; + mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); + st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + } + else + { + nchan_out_cov = nchan_out_transport; + } + if ( hParamMC ) + { + fixedToFloat_arr( hParamMC->icc_q_fx, hParamMC->icc_q, Q15, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); + fixedToFloat_arr( hParamMC->icld_q_fx, hParamMC->icld_q, Q8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); + fixedToFloat_arr( hParamMC->h_output_synthesis_params.interpolator_fx, hParamMC->h_output_synthesis_params.interpolator, 15, DEFAULT_JBM_CLDFB_TIMESLOTS ); + fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); + FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); + } + //if ( st_ivas->hLsSetUpConversion ) + //{ + // for ( k = 0; k < nchan_transport; k++ ) + // { + // for ( i = 0; i < nchan_out_cov; i++ ) + // { + // st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); + // } + // } + //} + fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, nchan_out_transport * nchan_transport ); + //if ( hParamMC->ls_conv_dmx_matrix ) + // fixedToFloat_arrL( hParamMC->ls_conv_dmx_matrix_fx, hParamMC->ls_conv_dmx_matrix, Q30, nchan_out_transport * nchan_out_cov ); + if ( hParamMC->hoa_encoder_fx ) + fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); + } +#endif // 1 +#else IF ( ( error = ivas_param_mc_dec_open( st_ivas ) ) != IVAS_ERR_OK ) { return error; } +#endif FOR ( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ ) { @@ -2063,7 +2080,26 @@ ivas_error ivas_init_decoder_fx( IF ( st_ivas->hVBAPdata == NULL ) { /* Distribute signal to all channels if VBAP is not properly initialized. */ - set_f( st_ivas->hLsSetupCustom->separate_ch_gains, inv_sqrt( st_ivas->hLsSetupCustom->num_spk ), st_ivas->hLsSetupCustom->num_spk ); + Word16 inv_sqr, sqr, exp = 15, exp_sqr; + IF(EQ_16(st_ivas->hLsSetupCustom->num_spk, 1)) + { + inv_sqr = 32767; + } + ELSE + { + sqr = Sqrt16(st_ivas->hLsSetupCustom->num_spk, &exp); + inv_sqr = BASOP_Util_Divide1616_Scale(32767, sqr, &exp_sqr); + exp_sqr = sub(exp_sqr, exp); + IF(LT_16(exp, 0)) + { + inv_sqr = shr(inv_sqr, exp); + } + ELSE + { + inv_sqr = shl(inv_sqr, exp); + } + } + set16_fx( st_ivas->hLsSetupCustom->separate_ch_gains_fx, inv_sqr, st_ivas->hLsSetupCustom->num_spk ); } ELSE { @@ -2133,11 +2169,6 @@ ivas_error ivas_init_decoder_fx( IF ( GT_16(n, 0 )) { - //IF ( ( st_ivas->mem_hp20_out = (float **) malloc( n * sizeof( float * ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - //} - IF( ( st_ivas->mem_hp20_out_fx = (Word32 **) malloc( n * sizeof(Word32 * ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); @@ -2145,26 +2176,17 @@ ivas_error ivas_init_decoder_fx( } ELSE { - //st_ivas->mem_hp20_out = NULL; - st_ivas->mem_hp20_out_fx = NULL; } FOR ( i = 0; i < n; i++ ) { - //IF ( ( st_ivas->mem_hp20_out[i] = (float *) malloc( L_HP20_MEM * sizeof( float ) ) ) == NULL ) - //{ - // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n" ) ); - //} - - //set_f( st_ivas->mem_hp20_out[i], 0.0f, L_HP20_MEM ); - - IF((st_ivas->mem_hp20_out_fx[i] = (Word32 *)malloc((L_HP20_MEM + 2) * sizeof(Word32))) == NULL) - { - return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n")); - } - - set32_fx(st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2); + IF((st_ivas->mem_hp20_out_fx[i] = (Word32 *)malloc((L_HP20_MEM + 2) * sizeof(Word32))) == NULL) + { + return (IVAS_ERROR(IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HP20 filter memory\n")); + } + + set32_fx(st_ivas->mem_hp20_out_fx[i], 0, L_HP20_MEM + 2); } /*-------------------------------------------------------------------* diff --git a/lib_dec/ivas_ism_dec.c b/lib_dec/ivas_ism_dec.c index 60f88277f..57fa0c8ce 100644 --- a/lib_dec/ivas_ism_dec.c +++ b/lib_dec/ivas_ism_dec.c @@ -294,8 +294,7 @@ static ivas_error ivas_ism_bitrate_switching_dec_fx( * CLDFB instances *-----------------------------------------------------------------*/ - Word16 Q_cldfbSynDec = Q21; - IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ,Q_cldfbSynDec) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) { return error; } @@ -501,7 +500,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in, numch_out, num_md_sub_frames; ; Word16 numch_out_dirac = hDecoderConfig->nchan_out; IF( hSpar ) @@ -509,32 +508,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - hSpar->hMdDec->Q_mixer_mat = q1; -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( int j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif + hSpar->hMdDec->Q_mixer_mat = Q30; for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -587,21 +561,6 @@ static ivas_error ivas_ism_bitrate_switching_dec( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } -#if 0 - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif // fix2float (to be cleaned) IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { @@ -860,7 +819,7 @@ static ivas_error ivas_ism_bitrate_switching_dec( floatToFixed_arrL( st_ivas->cldfbSynDec[0]->cldfb_state, st_ivas->cldfbSynDec[0]->cldfb_state_fx, Q_cldfbSynDec, sub( st_ivas->cldfbAnaDec[i]->p_filter_length, st_ivas->cldfbAnaDec[i]->no_channels ) ); } #endif - IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ,Q_cldfbSynDec) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_jbm_dec.c b/lib_dec/ivas_jbm_dec.c index a21e3c74a..e63c61572 100644 --- a/lib_dec/ivas_jbm_dec.c +++ b/lib_dec/ivas_jbm_dec.c @@ -427,7 +427,7 @@ ivas_error ivas_jbm_dec_tc( #if 1 // Float to fix Word16 ch, nCPE, cpe_id; - Word16 k, l; + Word16 l; nCPE = st_ivas->nCPE; move16(); @@ -500,21 +500,12 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); - IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); } - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } - /*-------------------cldfb-start-------------------------*/ if ( sts[n]->cldfbAna != NULL ) @@ -555,14 +546,6 @@ ivas_error ivas_jbm_dec_tc( /*------------------reset-code-end-----------------------*/ } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); - } - } } @@ -586,10 +569,10 @@ ivas_error ivas_jbm_dec_tc( } } - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) + //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) + //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); #endif // Fix to float #endif @@ -604,8 +587,6 @@ ivas_error ivas_jbm_dec_tc( IF( EQ_16( st_ivas->ivas_format, SBA_FORMAT ) ) { #ifdef IVAS_FLOAT_FIXED - - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); #if 1 /*Float to Fixed changes */ FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { @@ -616,87 +597,11 @@ ivas_error ivas_jbm_dec_tc( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; - Word16 b, i_ts, num_out_ch; + Word16 num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #endif ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx ), ( p_output_fx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); @@ -704,31 +609,14 @@ ivas_error ivas_jbm_dec_tc( { ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, p_output_fx ); } - ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, num_md_sub_frames ); - -#if 0 /*Fixed to float changes */ - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif + ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes(st_ivas->sba_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate)); #endif } #ifdef IVAS_FLOAT_FIXED { Word16 q; - float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; float max_val = 0.0; int i_max_val_op; hCPE = st_ivas->hCPE[0]; @@ -749,11 +637,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; } - - IF( hCPE->hStereoCng != NULL ) - { - floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - } q = hCPE->hStereoDft->q_dft; scale_sig32(hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub(hCPE->hStereoDft->q_dft, Q11)); FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -761,20 +644,11 @@ ivas_error ivas_jbm_dec_tc( scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } - if ( hSCE != NULL ) - { - floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - hSCE->q_save_hb_synth_fx = q; - floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - hSCE->q_save_synth_fx = q; - } IF( hCPE->hCoreCoder[0] != NULL ) { floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); - IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) - floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { @@ -782,13 +656,21 @@ ivas_error ivas_jbm_dec_tc( scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; } + + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + } st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - for ( int ii = 0; ii < CPE_CHANNELS; ii++ ) + FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; } - floatToFixed_arrL( &hCPE->prev_synth[0][0], &hCPE->prev_synth_fx[0][0], hCPE->q_prev_synth_fx, sizeof( hCPE->prev_synth ) / sizeof( hCPE->prev_synth[0][0] ) ); + Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), hCPE->q_prev_synth_fx - 11 ); ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, st_ivas->ivas_format == MC_FORMAT ); @@ -796,12 +678,7 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); } - - fixedToFloat_arrL( &hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof( hCPE->prev_synth ) / sizeof( hCPE->prev_synth[0][0] ) ); - IF( hCPE->hStereoCng != NULL ) - { - fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - } + Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx ) / sizeof( hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); scale_sig32(hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub(Q11, hCPE->hStereoDft->q_dft)); FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -809,17 +686,11 @@ ivas_error ivas_jbm_dec_tc( scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } - if ( hSCE != NULL ) - { - fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - } + IF( hCPE->hCoreCoder[0] != NULL ) { fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); - IF( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { @@ -867,105 +738,14 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[ch], output_frame, sub( Q_p_output, Q11 ) ); } - Word16 b, i_ts, num_out_ch; + Word16 num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #endif ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, p_output_fx, st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); #if 1 /*Fixed to float changes */ -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif FOR( Word16 c = 0; c < nchan_transport; c++ ) { Scale_sig32( p_output_fx[c], output_frame, 11 ); @@ -1258,7 +1038,7 @@ ivas_error ivas_jbm_dec_tc( #ifdef IVAS_FLOAT_FIXED #if 1 // Float to fix Word16 ch, nCPE, cpe_id; - Word16 k, l; + Word16 l; nCPE = st_ivas->nCPE; move16(); @@ -1331,33 +1111,12 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - //IF( st->hTcxDec ) - //st->hTcxDec->CngLevelBackgroundTrace_bfi = me2f_16( st->hTcxDec->conCngLevelBackgroundTrace, st->hTcxDec->conCngLevelBackgroundTrace_e ); - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); - IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); - - //fixedToFloat_arr( st->hTcxDec->old_synthFB_fx, st->hTcxDec->old_synthFB, st->Q_syn, st->hTcxDec->old_synth_lenFB + NS2SA( st->output_Fs, PH_ECU_LOOKAHEAD_NS ) ); - for ( int p = 0; p < st->L_frame / 2; p++ ) - { - //st->hTcxDec->old_syn_Overl_float[p] = (float) st->hTcxDec->old_syn_Overl[p] * 2 * ( 1u << st->Q_syn ); - //st->hTcxDec->syn_Overl_TDACFB_float[p] = (float) st->hTcxDec->syn_Overl_TDACFB[p] * 2 * (float) pow( 2, st->Q_syn ); - //st->hTcxDec->syn_Overl_TDAC_float[p] = (float) st->hTcxDec->syn_Overl_TDAC[p] * 2 * (float) pow( 2, st->Q_syn ); - } for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); } - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } - - //fixedToFloat_arr( st->hTcxDec->syn_Overl, st->hTcxDec->syn_Overl_float, st->Q_syn, L_FRAME32k / 2 ); - /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -1397,14 +1156,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); - } - } } @@ -1428,10 +1179,10 @@ ivas_error ivas_jbm_dec_tc( } } - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) + //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) + //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); #endif // Fix to float #endif @@ -1444,94 +1195,17 @@ ivas_error ivas_jbm_dec_tc( Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, sub( Q14, Q11 ) ); } #ifdef IVAS_FLOAT_FIXED - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, ivas_total_brate, st_ivas->last_active_ivas_total_brate ); #if 1 /*Float to Fixed changes */ SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; Word16 num_bands_out, nchan_transport; num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; nchan_out = nchan_transport; - Word16 b, i_ts, num_out_ch; + Word16 num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #endif ivas_agc_dec_process_fx( st_ivas->hSpar->hAgcDec, ( p_output_fx + sba_ch_idx ), ( p_output_fx + sba_ch_idx ), st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, output_frame ); @@ -1545,26 +1219,10 @@ ivas_error ivas_jbm_dec_tc( #else ivas_spar_dec_gen_umx_mat_fx( st_ivas->hSpar->hMdDec, st_ivas->nchan_transport, IVAS_MAX_NUM_BANDS, st_ivas->bfi, ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ) ); #endif -#if 0 /* Fixed to float changes*/ - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #endif #ifdef IVAS_FLOAT_FIXED { Word16 q; - float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; hCPE = st_ivas->hCPE[0]; hSCE = st_ivas->hSCE[0]; s = 0; @@ -1583,10 +1241,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; } - IF( hCPE->hStereoCng != NULL ) - { - floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - } q = hCPE->hStereoDft->q_dft; scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -1594,20 +1248,11 @@ ivas_error ivas_jbm_dec_tc( scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } - if ( hSCE != NULL ) - { - floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - hSCE->q_save_hb_synth_fx = q; - floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - hSCE->q_save_synth_fx = q; - } IF( hCPE->hCoreCoder[0] != NULL ) { floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); - IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) - floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { @@ -1616,51 +1261,39 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; } st_ivas->hSpar->hMdDec->Q_mixer_mat = Q30; -#if 0 - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) + + IF( hSCE != NULL ) { - for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) - { - floatToFixed_arrL( &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); - } + Scale_sig32( &hSCE->save_hb_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; } -#endif FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; } - floatToFixed_arrL( &hCPE->prev_synth[0][0], &hCPE->prev_synth_fx[0][0], hCPE->q_prev_synth_fx, sizeof( hCPE->prev_synth ) / sizeof( hCPE->prev_synth[0][0] ) ); - ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); - } - fixedToFloat_arrL( &hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof( hCPE->prev_synth ) / sizeof( hCPE->prev_synth[0][0] ) ); - IF( hCPE->hStereoCng != NULL ) + Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx) / sizeof(hCPE->prev_synth_fx[0][0]), hCPE->q_prev_synth_fx - 11); + ivas_sba_dirac_stereo_dec_fx(st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0); + FOR(i = 0; i < 2; i++) { - fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); + Scale_sig32(p_output_fx[sba_ch_idx + i], L_FRAME48k, negate(s)); } + + Scale_sig32(&hCPE->prev_synth_fx[0][0], sizeof(hCPE->prev_synth_fx) / sizeof(hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } - if ( hSCE != NULL ) - { - fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - } + IF( hCPE->hCoreCoder[0] != NULL ) { fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); - IF( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { @@ -1703,104 +1336,13 @@ ivas_error ivas_jbm_dec_tc( { Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, sub( Q_p_output, Q11 ) ); } - Word16 b, i_ts, num_out_ch; + Word16 num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #endif ivas_sba_mix_matrix_determiner_fx( st_ivas->hSpar, &p_output_fx[sba_ch_idx], st_ivas->bfi, nchan_remapped, output_frame, num_md_sub_frames ); -#if 0 /*Fixed to float changes */ - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #if 1 FOR( Word16 c = 0; c < nchan_transport; c++ ) { @@ -1867,7 +1409,7 @@ ivas_error ivas_jbm_dec_tc( #if 1 // Float to fix Word16 ch, nCPE, cpe_id; - Word16 q_output = 11, l, k; + Word16 l; nCPE = st_ivas->nCPE; move16(); @@ -1940,21 +1482,12 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); - IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); } - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } - /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -1995,13 +1528,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } } - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); - } - } } @@ -2025,10 +1551,10 @@ ivas_error ivas_jbm_dec_tc( } } - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) + //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) + //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); #endif // Fix to float #endif @@ -2087,8 +1613,7 @@ ivas_error ivas_jbm_dec_tc( #if 1 // Float to fix Word16 ch, nCPE, cpe_id; - Word16 q_output = 11; - Word16 k, l; + Word16 l; nCPE = st_ivas->nCPE; move16(); @@ -2160,19 +1685,11 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); - IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); } - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ if ( sts[n]->cldfbAna != NULL ) @@ -2211,13 +1728,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } } - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); - } - } } @@ -2241,10 +1751,10 @@ ivas_error ivas_jbm_dec_tc( } } - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) + //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) + //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); #endif // Fix to float #endif @@ -2312,8 +1822,7 @@ ivas_error ivas_jbm_dec_tc( #if 1 // Float to fix Word16 ch, nCPE, cpe_id; - Word16 q_output = 11; - Word16 k, l; + Word16 l; nCPE = st_ivas->nCPE; move16(); @@ -2386,19 +1895,11 @@ ivas_error ivas_jbm_dec_tc( { st = hCPE->hCoreCoder[n]; sts = hCPE->hCoreCoder; - IF( st->hTonalMDCTConc && st->hTonalMDCTConc->lastPcmOut_float ) - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); - IF( sts[0]->bfi == 0 && !st->hTonalMDCTConc->secondLastBlockData.tonalConcealmentActive ) - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); for ( int p = 0; p < 640; p++ ) { st->hHQ_core->old_outLB[p] = (float) st->hHQ_core->old_out_LB_fx[p] / ( 1u << st->Q_syn ); } - if ( !st->tcxonly ) - { - fixedToFloat_arr( st->p_bpf_noise_buf, st->p_bpf_noise_buf_float, 0, L_FRAME_16k ); - } /*-------------------cldfb-start-------------------------*/ /*note : cldfb_size here signifies the original size which was assigned to cldfb_state_fx buffer not its current size*/ @@ -2438,14 +1939,6 @@ ivas_error ivas_jbm_dec_tc( sts[n]->hBWE_FD->prev_flag = sts[n]->hBWE_FD->prev_flag; } } - - FOR( n = 0; n < CPE_CHANNELS; n++ ) - { - FOR( k = 0; k < NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ); k++ ) - { - hCPE->prev_synth[n][k] = (float) hCPE->prev_synth_fx[n][k] / ( 1 << q_output ); - } - } } @@ -2469,10 +1962,10 @@ ivas_error ivas_jbm_dec_tc( } } - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) - me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); - IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) - me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->targetEnergyPrev ) + //me2f_buf( st_ivas->hLsSetUpConversion->targetEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->te_prev_exp, st_ivas->hLsSetUpConversion->targetEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); + //IF( st_ivas->hLsSetUpConversion && st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx ) + //me2f_buf( st_ivas->hLsSetUpConversion->dmxEnergyPrev_fx[0], st_ivas->hLsSetUpConversion->dmx_prev_exp, st_ivas->hLsSetUpConversion->dmxEnergyPrev[0], st_ivas->hLsSetUpConversion->sfbCnt ); #endif // Fix to float #endif @@ -2651,7 +2144,6 @@ ivas_error ivas_jbm_dec_tc( { #ifdef IVAS_FLOAT_FIXED Word16 q; - float l_hb_nrg = 0.0, l_hb_nrg_subr = 0.0; float max_val = 0.0; int i_max_val_op; hCPE = st_ivas->hCPE[0]; @@ -2673,10 +2165,6 @@ ivas_error ivas_jbm_dec_tc( hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; } - IF( hCPE->hStereoCng != NULL ) - { - floatToFixed_arr( &hCPE->hStereoCng->cm[0], &hCPE->hStereoCng->cm_fx[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - } q = hCPE->hStereoDft->q_dft; scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) @@ -2684,80 +2172,55 @@ ivas_error ivas_jbm_dec_tc( scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); } - if ( hSCE != NULL ) - { - floatToFixed_arrL( &hSCE->save_hb_synth[0], &hSCE->save_hb_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - hSCE->q_save_hb_synth_fx = q; - floatToFixed_arrL( &hSCE->save_synth[0], &hSCE->save_synth_fx[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - hSCE->q_save_synth_fx = q; - } + IF( hCPE->hCoreCoder[0] != NULL ) { floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], q, L_FRAME32k ); hCPE->hCoreCoder[0]->hHQ_core->q_old_outLB_fx = q; floatToFixed_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], q, L_FRAME48k ); - IF( ( hCPE->hCoreCoder[0] != NULL ) && ( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) ) - floatToFixed_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - - //floatToFixed_arrL( &hCPE->hStereoDft->td_gain[0], &hCPE->hStereoDft->td_gain_fx[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); } IF( st_ivas->hSpar != NULL ) { - //floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; -#if 0 - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) - { - for (int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++) - { - floatToFixed_arrL(&st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); - } - } -#endif + } + + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + Scale_sig32( &hSCE->save_synth_fx[0], (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; } FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; } - floatToFixed_arrL( &hCPE->prev_synth[0][0], &hCPE->prev_synth_fx[0][0], hCPE->q_prev_synth_fx, sizeof( hCPE->prev_synth ) / sizeof( hCPE->prev_synth[0][0] ) ); - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - FOR( i = 0; i < 2; i++ ) + Scale_sig32( &hCPE->prev_synth_fx[0][0], sizeof( hCPE->prev_synth_fx) / sizeof(hCPE->prev_synth_fx[0][0]), hCPE->q_prev_synth_fx - 11); + ivas_sba_dirac_stereo_dec_fx(st_ivas, p_output_fx, output_frame, 1); + FOR(i = 0; i < 2; i++) { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); + Scale_sig32(p_output_fx[i], L_FRAME48k, negate(s)); } + Scale_sig32(&hCPE->prev_synth_fx[0][0], sizeof(hCPE->prev_synth_fx) / sizeof(hCPE->prev_synth_fx[0][0] ), 11 - hCPE->q_prev_synth_fx ); - fixedToFloat_arrL( &hCPE->prev_synth_fx[0][0], &hCPE->prev_synth[0][0], hCPE->q_prev_synth_fx, sizeof( hCPE->prev_synth ) / sizeof( hCPE->prev_synth[0][0] ) ); - IF( hCPE->hStereoCng != NULL ) - { - fixedToFloat_arr( &hCPE->hStereoCng->cm_fx[0], &hCPE->hStereoCng->cm[0], Q15, sizeof( hCPE->hStereoCng->cm_fx ) / sizeof( hCPE->hStereoCng->cm_fx[0] ) ); - } scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); FOR( i = 0; i < CPE_CHANNELS; ++i ) { scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); scale_sig32( hCPE->input_mem_fx[i], NS2SA( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); } - if ( hSCE != NULL ) - { - fixedToFloat_arrL( &hSCE->save_synth_fx[0], &hSCE->save_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - fixedToFloat_arrL( &hSCE->save_hb_synth_fx[0], &hSCE->save_hb_synth[0], q, (Word16) ( hCPE->hCoreCoder[0]->output_Fs / FRAMES_PER_SEC ) ); - } + IF( hCPE->hCoreCoder[0] != NULL ) { fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->old_outLB_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_outLB[0], q, L_FRAME32k ); fixedToFloat_arrL( &hCPE->hCoreCoder[0]->hHQ_core->oldOut_fx[0], &hCPE->hCoreCoder[0]->hHQ_core->old_out[0], q, L_FRAME48k ); - IF( hCPE->hCoreCoder[0]->p_bpf_noise_buf_32 != NULL ) - fixedToFloat_arrL( &hCPE->hCoreCoder[0]->p_bpf_noise_buf_32[0], &hCPE->hCoreCoder[0]->p_bpf_noise_buf_float[0], q, L_FRAME16k ); } IF( hCPE->hStereoDft != NULL ) { @@ -2769,28 +2232,7 @@ ivas_error ivas_jbm_dec_tc( } IF( st_ivas->hSpar != NULL ) { - //fixedToFloat_arrL(&st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx) / sizeof(st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0])); st_ivas->hSpar->hMdDec->Q_mixer_mat = 31; - for (int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++) - { - //fixedToFloat_arrL( &hCPE->hStereoDft->td_gain_fx[0], &hCPE->hStereoDft->td_gain[0], Q31, sizeof( hCPE->hStereoDft->td_gain_fx ) / sizeof( hCPE->hStereoDft->td_gain_fx[0] ) ); - } -#if 0 - IF( st_ivas->hSpar != NULL ) - { - fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0], &st_ivas->hSpar->hMdDec->mixer_mat_prev[0][0][0][0], Q31, sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx ) / sizeof( st_ivas->hSpar->hMdDec->mixer_mat_prev_fx[0][0][0][0] ) ); - for ( int ii = 0; ii < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; ii++ ) - { - for ( int jj = 0; jj < st_ivas->hSpar->hMdDec->mix_mat_dim_0_1; jj++ ) - { - fixedToFloat_arrL( &st_ivas->hSpar->hMdDec->mixer_mat_fx[ii][jj][0], - &st_ivas->hSpar->hMdDec->mixer_mat[ii][jj][0], - Q31, - st_ivas->hSpar->hMdDec->mix_mat_dim_2 ); - } - } - } -#endif FOR( int ii = 0; ii < CPE_CHANNELS; ii++ ) { scale_sig32( hCPE->output_mem_fx[ii], NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); @@ -3050,6 +2492,7 @@ ivas_error ivas_jbm_dec_tc( { set_f( p_output[n], 0.0f, output_frame ); } + } else if ( st_ivas->ivas_format == STEREO_FORMAT ) { @@ -3159,7 +2602,6 @@ ivas_error ivas_jbm_dec_tc( st_ivas->hCPE[0]->element_brate = ivas_total_brate; } - /* core-decoding of transport channels */ if ( st_ivas->nSCE == 1 ) { @@ -3778,7 +3220,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT ) { #if 1 - Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, j, b, i_ts, num_out_ch = 0; + Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, num_out_ch = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -3786,85 +3228,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -3937,22 +3302,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( #if 1 if (st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT) { -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - FOR(i_ts = 0; i_ts < num_md_sub_frames; i_ts++) - { - FOR(i = 0; i < num_out_ch; i++) - { - FOR(j = 0; j < num_in_ch; j++) - { - FOR(b = 0; b < num_bands_out; b++) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat(st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat); - } - } - } - } -#endif - IF(hSpar->hMdDec->td_decorr_flag && !(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM))) { Word16 ch_sba_idx = 0; @@ -4033,7 +3382,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( } #if 1 - Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, j, b, i_ts, num_out_ch = 0; + Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, num_out_ch = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -4041,85 +3390,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -4191,22 +3463,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { Word16 ch_sba_idx = 0; @@ -4263,93 +3519,16 @@ void ivas_jbm_dec_feed_tc_to_renderer( { ivas_jbm_dec_td_renderers_adapt_subframes( st_ivas ); #if 1 - Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, j, b, i_ts, num_out_ch = 0; + Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, num_out_ch = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; - hSpar->hMdDec->Q_mixer_mat = 31; - num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; + hSpar->hMdDec->Q_mixer_mat = 31; + num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -4421,22 +3600,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { Word16 ch_sba_idx = 0; @@ -4495,7 +3658,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( n_render_timeslots *= ( st_ivas->hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size ); } #if 1 - Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, j, b, i_ts, num_out_ch = 0; + Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, num_out_ch = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -4503,85 +3666,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -4653,22 +3739,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { Word16 ch_sba_idx = 0; @@ -4803,10 +3873,10 @@ void ivas_jbm_dec_feed_tc_to_renderer( } f2me_buf(st_ivas->hParamMC->h_output_synthesis_params.proto_matrix, st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_fx, &st_ivas->hParamMC->h_output_synthesis_params.proto_matrix_e, nchan_out_cov * nchan_transport); - IF (st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV) - { - f2me_buf(st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, &st_ivas->hParamMC->ls_conv_dmx_e, nchan_out_cov * nchan_out_transport); - } + //IF (st_ivas->hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV) + //{ + // f2me_buf(st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, &st_ivas->hParamMC->ls_conv_dmx_e, nchan_out_cov * nchan_out_transport); + //} floatToFixed_arr(st_ivas->hParamMC->icld_q, st_ivas->hParamMC->icld_q_fx, 8, st_ivas->hParamMC->hMetadataPMC->num_parameter_bands * st_ivas->hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe); @@ -4850,7 +3920,7 @@ void ivas_jbm_dec_feed_tc_to_renderer( { #if 1 - Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, j, b, i_ts, num_out_ch = 0; + Word16 num_in_ch = 0, num_bands_out = 0, nchan_transport = 0, num_md_sub_frames = 0, num_out_ch = 0; SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { @@ -4858,85 +3928,8 @@ void ivas_jbm_dec_feed_tc_to_renderer( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min( hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { @@ -5008,22 +4001,6 @@ void ivas_jbm_dec_feed_tc_to_renderer( #if 1 if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == SBA_ISM_FORMAT ) { -#if 0 - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - st_ivas->hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( st_ivas->hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], st_ivas->hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif - IF( hSpar->hMdDec->td_decorr_flag && !( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) ) { Word16 ch_sba_idx = 0; @@ -5361,7 +4338,7 @@ ivas_error ivas_jbm_dec_render( { FOR( j = 0; j < st_ivas->nchan_transport; j++ ) { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); + //st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); } } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); @@ -5694,45 +4671,16 @@ ivas_error ivas_jbm_dec_render( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; Word16 numch_out_dirac = hDecoderConfig->nchan_out; - Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } - Word16 q1 = 30, q2 = 30; hSpar->hMdDec->Q_mixer_mat = 30; -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -5775,21 +4723,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } -#if 0 - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif // fix2float (to be cleaned) IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { @@ -5854,45 +4787,16 @@ ivas_error ivas_jbm_dec_render( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; Word16 numch_out_dirac = hDecoderConfig->nchan_out; - Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } - Word16 q1 = 30, q2 = 30; hSpar->hMdDec->Q_mixer_mat = 30; -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -5949,21 +4853,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); } } -#if 0 - FOR( Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif // fix2float (to be cleaned) IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { @@ -6099,45 +4988,16 @@ ivas_error ivas_jbm_dec_render( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; Word16 numch_out_dirac = hDecoderConfig->nchan_out; - Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } - Word16 q1 = 30, q2 = 30; hSpar->hMdDec->Q_mixer_mat = 30; -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -6180,21 +5040,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); } } -#if 0 - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif // fix2float (to be cleaned) IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { @@ -6233,45 +5078,16 @@ ivas_error ivas_jbm_dec_render( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; Word16 numch_out_dirac = hDecoderConfig->nchan_out; - Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } - Word16 q1 = 30, q2 = 30; hSpar->hMdDec->Q_mixer_mat = 30; -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -6314,21 +5130,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } -#if 0 - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif // fix2float (to be cleaned) IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { @@ -6367,45 +5168,15 @@ ivas_error ivas_jbm_dec_render( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; Word16 numch_out_dirac = hDecoderConfig->nchan_out; - Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } - Word16 q1 = 30, q2 = 30; -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - hSpar->hMdDec->Q_mixer_mat = 30; - for ( int l = 0; l < numch_out; l++ ) - { - for ( j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -6448,21 +5219,6 @@ ivas_error ivas_jbm_dec_render( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); /*Rounding off*/ } } -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - FOR( Word16 m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { fixedToFloat_arr( hSpar->hMdDec->smooth_fac_fx, hSpar->hMdDec->smooth_fac, Q15, IVAS_MAX_NUM_BANDS ); @@ -6566,7 +5322,7 @@ ivas_error ivas_jbm_dec_render( { FOR( j = 0; j < st_ivas->nchan_transport; j++ ) { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); + //st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); } } ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc_fx, p_output_fx ); @@ -6698,7 +5454,7 @@ ivas_error ivas_jbm_dec_render( { FOR( j = 0; j < MC_PARAMUPMIX_MAX_INPUT_CHANS; j++ ) { - st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); + //st_ivas->hLsSetUpConversion->dmxMtx_fx[j][i] = float_to_fix( st_ivas->hLsSetUpConversion->dmxMtx[j][i], Q30 ); } } ivas_ls_setup_conversion_fx( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output_fx, p_output_fx ); diff --git a/lib_dec/ivas_lfe_dec.c b/lib_dec/ivas_lfe_dec.c index b6b88e0e4..a7c0fe222 100644 --- a/lib_dec/ivas_lfe_dec.c +++ b/lib_dec/ivas_lfe_dec.c @@ -47,7 +47,7 @@ /* Delay handling of LFE: overall_lfe_delay = max(11.5, BLOCK_OFFSET_MS); */ #define BLOCK_OFFSET_MS 12 - +#ifndef IVAS_FLOAT_FIXED /*-----------------------------------------------------------------------------------------* * Function ivas_lfe_dec_delay_adjust() * @@ -472,3 +472,4 @@ void ivas_lfe_dec_close( return; } #endif +#endif \ No newline at end of file diff --git a/lib_dec/ivas_lfe_dec_fx.c b/lib_dec/ivas_lfe_dec_fx.c index 4efe4a477..ecda2cb2e 100644 --- a/lib_dec/ivas_lfe_dec_fx.c +++ b/lib_dec/ivas_lfe_dec_fx.c @@ -352,27 +352,8 @@ void ivas_lfe_dec_fx( { /* note: in BFI branch, buffer 't_audio' is in time-domain ('wtda' signal) */ hLFE->bfi_count++; -#ifdef IVAS_FLOAT_FIXED_TBD - ivas_lfe_tdplc_fx( hLFE, hLFE->prevsynth_buf, t_audio, output_frame ); -#else - float t_audio_flt[L_FRAME48k]; - FOR( int k = 0; k < 240; k++ ) - { - - hLFE->prevsynth_buf[k] = (float) hLFE->prevsynth_buf_fx[k] / ONE_IN_Q9; - } - - ivas_lfe_tdplc( hLFE, hLFE->prevsynth_buf, t_audio_flt, output_frame ); - FOR( int k = 0; k < 960; k++ ) - { - if ( k < 240 ) - { - hLFE->prevsynth_buf_fx[k] = (Word32) ( hLFE->prevsynth_buf[k] * ONE_IN_Q9 ); - } - t_audio[k] = (Word32) ( t_audio_flt[k] * ONE_IN_Q9 ); - } -#endif // IVAS_FLOAT_FIXED_TBD + ivas_lfe_tdplc_fx( hLFE, hLFE->prevsynth_buf_fx, t_audio, output_frame ); ivas_itda_fx( t_audio, out, dct_len ); ivas_lfe_dec_windowing_fx( hLFE, out ); diff --git a/lib_dec/ivas_lfe_plc.c b/lib_dec/ivas_lfe_plc.c index 1844ca8ee..6fe8d5939 100644 --- a/lib_dec/ivas_lfe_plc.c +++ b/lib_dec/ivas_lfe_plc.c @@ -54,7 +54,7 @@ #define MAX_LEN_LP 960 #define EPS_STOP 1e-5 - +#ifndef IVAS_FLOAT_FIXED /*------------------------------------------------------------------------------------------* * Static function declarations * @@ -535,3 +535,4 @@ void ivas_lfe_tdplc( return; } +#endif \ No newline at end of file diff --git a/lib_dec/ivas_lfe_plc_fx.c b/lib_dec/ivas_lfe_plc_fx.c new file mode 100644 index 000000000..279749caa --- /dev/null +++ b/lib_dec/ivas_lfe_plc_fx.c @@ -0,0 +1,990 @@ +/****************************************************************************************************** + + (C) 2022-2024 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository. All Rights Reserved. + + This software is protected by copyright law and by international treaties. + The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB, + Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD., + Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange, + Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other + contributors to this repository retain full ownership rights in their respective contributions in + the software. This notice grants no license of any kind, including but not limited to patent + license, nor is any license granted by implication, estoppel or otherwise. + + Contributors are required to enter into the IVAS codec Public Collaboration agreement before making + contributions. + + This software is provided "AS IS", without any express or implied warranties. The software is in the + development stage. It is intended exclusively for experts who have experience with such software and + solely for the purpose of inspection. All implied warranties of non-infringement, merchantability + and fitness for a particular purpose are hereby disclaimed and excluded. + + Any dispute, controversy or claim arising under or in relation to providing this software shall be + submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in + accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and + the United Nations Convention on Contracts on the International Sales of Goods. + +*******************************************************************************************************/ + +#include +#include "options.h" +#include "prot.h" +#include "prot_fx1.h" +#include "prot_fx2.h" +#include "ivas_prot.h" +#include "ivas_rom_com.h" +#include +#include "wmc_auto.h" +#ifdef IVAS_FLOAT_FIXED +#include "ivas_prot_fx.h" +#endif + +/*------------------------------------------------------------------------------------------* + * Local constants + *------------------------------------------------------------------------------------------*/ + +#define LFE_PLC_DSF ( 48000 / LFE_PLC_FS ) +#define LFE_PLC_LPCORD ( 20 ) +#define LFE_PLC_MAXITER ( 10 ) +#define POW_THR ( 1.0e-8f ) +#define LFE_PLC_RECLEN_48K ( ( IVAS_LFE_NUM_COEFFS_IN_SUBGRP + 1 ) * L_FRAME48k / IVAS_LFE_NUM_COEFFS_IN_SUBGRP + LFE_PLC_FDEL ) +#define LFE_PLC_RECLEN ( ( LFE_PLC_RECLEN_48K / LFE_PLC_DSF ) ) +#define LFE_PLC_MUTE_THR ( 10 ) +#define LFE_PLC_BURST_ATT ( pow( pow( 10.0, -3.0 / 20.0 ), 1.0 / ( LFE_PLC_FS * 0.02 ) ) ) /* attenuate 3dB per frame starting with 10th consecutive loss */ + +#define MAX_LEN_LP 960 + +#define EPS_STOP 1e-5 +#ifdef IVAS_FLOAT_FIXED +#define POW_THR_Q50 ( 11258999 ) +#define EPS_STOP_Q31 ( 21475 ) +#define LFE_PLC_BURST_ATT_Q31 ( 2124429696 ) + +/*------------------------------------------------------------------------------------------* + * Static function declarations + * + * Note (DLB): the local double precision functions defined below are replica of corresponding + * float functions defined in tools.c, lpc_tools.c and syn_filt.c. + * Double precision arithmetic is required for proper functioning of the lfe_plc. + *------------------------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------* + * autocorr_fx() + * + * Compute autocorrelations of input signal + *---------------------------------------------------------------------*/ + +static void d_autocorr_fx( + const Word32 *x_fx, /* i : input signal */ + Word16 x_q_fx, + Word32 *r_fx, /* o : autocorrelations vector */ + Word16 *r_q_fx, + const Word16 m, /* i : order of LP filter */ + const Word16 len, /* i : window size */ + const UWord32 *wind_fx, /* i : window */ + const Word16 rev_flag, /* i : flag to reverse window */ + const Word16 sym_flag, /* i : symmetric window flag */ + const Word16 no_thr /* i : flag to avoid thresholding */ +) +{ + Word16 i, j; + Word32 t_fx[MAX_LEN_LP]; + Word64 s_fx; + Word32 temp; + Word16 tmp_q, exp1, exp2; + + /* Windowing of signal */ + IF( EQ_16( rev_flag, 1 ) ) + { + /* time reversed window */ + FOR( i = 0; i < len; i++ ) + { + t_fx[i] = Mpy_32_32( x_fx[i], wind_fx[sub( sub( len, i ), 1 )] ); // Q = x_q_fx + move32(); + } + } + ELSE IF( EQ_16( sym_flag, 1 ) ) + { + /* symmetric window of even length */ + FOR( i = 0; i < len / 2; i++ ) + { + t_fx[i] = Mpy_32_32( x_fx[i], wind_fx[i] ); // Q = x_q_fx + move32(); + } + + FOR( ; i < len; i++ ) + { + t_fx[i] = Mpy_32_32( x_fx[i], wind_fx[sub( sub( len, 1 ), i )] ); // Q = x_q_fx + move32(); + } + } + ELSE /* assymetric window */ + { + FOR( i = 0; i < len; i++ ) + { + t_fx[i] = Mpy_32_32( x_fx[i], wind_fx[i] ); // Q = x_q_fx + move32(); + } + } + + /* Compute r[1] to r[m] */ + FOR( i = 0; i <= m; i++ ) + { + exp1 = norm_l( t_fx[0] ); + exp2 = norm_l( t_fx[i] ); + s_fx = W_deposit32_l( Mpy_32_32( L_shl( t_fx[0], exp1 ), L_shl( t_fx[i], exp2 ) ) ); + r_q_fx[i] = sub( add( add( x_q_fx, exp1 ), add( x_q_fx, exp2 ) ), 31 ); + move16(); + FOR( j = 1; j < sub( len, i ); j++ ) + { + exp1 = norm_l( t_fx[j] ); + exp2 = norm_l( t_fx[add( i, j )] ); + temp = Mpy_32_32( L_shl( t_fx[j], exp1 ), L_shl( t_fx[add( i, j )], exp2 ) ); + tmp_q = sub( add( add( x_q_fx, exp1 ), add( x_q_fx, exp2 ) ), 31 ); + + IF( LT_16( tmp_q, r_q_fx[i] ) ) + { + s_fx = W_add( W_shr( s_fx, sub( r_q_fx[i], tmp_q ) ), W_deposit32_l( temp ) ); + r_q_fx[i] = tmp_q; + move16(); + } + ELSE + { + s_fx = W_add( s_fx, W_shr( temp, sub( tmp_q, r_q_fx[i] ) ) ); + } + } + exp1 = W_norm( s_fx ); + r_fx[i] = W_extract_h( W_shl( s_fx, exp1 ) ); + move32(); + r_q_fx[i] = sub( add( r_q_fx[i], exp1 ), 32 ); + move16(); + } + + // 2097152000 = 1000 in Q21 + IF( LT_16( r_q_fx[0], Q21 ) ) + { + IF( L_and( LT_32( r_fx[0], L_shr( 2097152000, sub( Q21, r_q_fx[0] ) ) ), EQ_16( no_thr, 0 ) ) ) + { + r_fx[0] = 2097152000; + move32(); + r_q_fx[0] = Q21; + move16(); + } + } + ELSE + { + IF( L_and( LT_32( L_shr( r_fx[0], sub( r_q_fx[0], Q21 ) ), 2097152000 ), EQ_16( no_thr, 0 ) ) ) + { + r_fx[0] = 2097152000; + move32(); + r_q_fx[0] = Q21; + move16(); + } + } + + return; +} + +/*---------------------------------------------------------------------* + * lev_dur_fx() + * + * Wiener-Levinson-Durbin algorithm to compute LP parameters from the autocorrelations + * of input signal + *---------------------------------------------------------------------*/ + +/*! r: energy of prediction error */ +static Word16 d_lev_dur_fx( + Word32 *a_fx, /* o : LP coefficients (a[0] = 1.0) */ + Word16 *a_q_fx, + Word32 *r_fx, /* i : vector of autocorrelations */ + Word16 *r_q_fx, + const Word16 m, /* i : order of LP filter */ + Word32 *epsP_fx, /* o : prediction error energy */ + Word16 *epsP_q_fx ) +{ + Word16 i, j, l; + Word16 flag = 0; + Word32 buf_fx[TCXLTP_LTP_ORDER]; + Word16 rc_q_fx[TCXLTP_LTP_ORDER]; + Word32 *rc_fx; /* reflection coefficients 0,...,m-1 */ + Word32 temp1, temp2, err_fx, at_fx, s, a_tmp; + Word16 temp_q1, temp_q2, s_q_fx, err_q_fx, exp1, exp2; + Word64 s_fx; + + rc_fx = &buf_fx[0]; + rc_fx[0] = BASOP_Util_Divide3232_Scale_cadence( -r_fx[1], r_fx[0], &temp_q2 ); + move32(); + rc_q_fx[0] = add( sub( r_q_fx[1], r_q_fx[0] ), sub( 31, temp_q2 ) ); + move16(); + + a_fx[0] = ONE_IN_Q30; + move32(); + a_q_fx[0] = 30; + move16(); + a_fx[1] = rc_fx[0]; + move32(); + a_q_fx[1] = rc_q_fx[0]; + move32(); + + temp1 = Mpy_32_32( r_fx[1], rc_fx[0] ); + temp_q1 = sub( add( r_q_fx[1], rc_q_fx[0] ), 31 ); + + IF( LT_16( temp_q1, r_q_fx[0] ) ) + { + err_fx = L_add( L_shr( r_fx[0], sub( r_q_fx[0], temp_q1 ) ), temp1 ); + err_q_fx = temp_q1; + move16(); + } + ELSE + { + err_fx = L_add( r_fx[0], L_shr( temp1, sub( temp_q1, r_q_fx[0] ) ) ); + err_q_fx = r_q_fx[0]; + move16(); + } + + IF( epsP_fx != NULL ) + { + epsP_fx[0] = r_fx[0]; + move32(); + epsP_q_fx[0] = r_q_fx[0]; + move16(); + epsP_fx[1] = err_fx; + move32(); + epsP_q_fx[1] = err_q_fx; + move16(); + } + + FOR( i = 2; i <= m; i++ ) + { + s_fx = 0; + move64(); + + FOR( j = 0; j < i; j++ ) + { + exp1 = norm_l( r_fx[i - j] ); + exp2 = norm_l( a_fx[j] ); + temp1 = Mpy_32_32( L_shl( r_fx[i - j], exp1 ), L_shl( a_fx[j], exp2 ) ); + temp_q1 = sub( add( add( r_q_fx[i - j], exp1 ), add( a_q_fx[j], exp2 ) ), 31 ); + + IF( EQ_16( j, 0 ) ) + { + s_fx = W_deposit32_l( temp1 ); + s_q_fx = temp_q1; + move16(); + } + ELSE + { + IF( LT_16( temp_q1, s_q_fx ) ) + { + s_fx = W_add( W_shr( s_fx, sub( s_q_fx, temp_q1 ) ), W_deposit32_l( temp1 ) ); + s_q_fx = temp_q1; + move16(); + } + ELSE + { + s_fx = W_add( s_fx, W_shr( W_deposit32_l( temp1 ), sub( temp_q1, s_q_fx ) ) ); + } + } + } + exp1 = W_norm( s_fx ); + s = W_extract_h( W_shl( s_fx, exp1 ) ); + s_q_fx = sub( add( s_q_fx, exp1 ), 32 ); + + rc_fx[i - 1] = L_shr( BASOP_Util_Divide3232_Scale_cadence( -s, err_fx, &temp_q2 ), 1 ); + move32(); + rc_q_fx[i - 1] = sub( add( sub( s_q_fx, err_q_fx ), sub( 31, temp_q2 ) ), 1 ); + move16(); + + IF( LT_16( rc_q_fx[i - 1], 31 ) ) + { + + IF( GT_32( abs( rc_fx[i - 1] ), L_shr( 2146302532, sub( 31, rc_q_fx[i - 1] ) ) ) ) // 2146302532 = 0.99945f in Q31 + { + flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ + move16(); + } + } + ELSE + { + IF( GT_32( abs( L_shr( rc_fx[i - 1], sub( rc_q_fx[i - 1], 31 ) ) ), 2146302532 ) ) // 2146302532 = 0.00045f in Q31 + { + flag = 1; /* Test for unstable filter. If unstable keep old A(z) */ + move16(); + } + } + + FOR( j = 1; j <= i / 2; j++ ) + { + l = sub( i, j ); + exp1 = sub( norm_l( rc_fx[sub( i, 1 )] ), 1 ); + exp2 = sub( norm_l( a_fx[l] ), 1 ); + rc_fx[sub( i, 1 )] = L_shl( rc_fx[sub( i, 1 )], exp1 ); + move32(); + rc_q_fx[sub( i, 1 )] = add( rc_q_fx[sub( i, 1 )], exp1 ); + move16(); + a_fx[l] = L_shl( a_fx[l], exp2 ); + move32(); + a_q_fx[l] = add( a_q_fx[l], exp2 ); + move16(); + + exp2 = sub( norm_l( a_fx[j] ), 1 ); + a_fx[j] = L_shl( a_fx[j], exp2 ); + move32(); + a_q_fx[j] = add( a_q_fx[j], exp2 ); + move16(); + + temp2 = Mpy_32_32( rc_fx[sub( i, 1 )], a_fx[l] ); + temp_q2 = sub( add( rc_q_fx[sub( i, 1 )], a_q_fx[l] ), 31 ); + + IF( LT_16( temp_q2, a_q_fx[j] ) ) + { + at_fx = L_add( L_shr( a_fx[j], sub( a_q_fx[j], temp_q2 ) ), temp2 ); + temp_q1 = temp_q2; + move16(); + } + ELSE + { + at_fx = L_add( a_fx[j], L_shr( temp2, sub( temp_q2, a_q_fx[j] ) ) ); + temp_q1 = a_q_fx[j]; + move16(); + } + + temp2 = Mpy_32_32( rc_fx[sub( i, 1 )], a_fx[j] ); + temp_q2 = sub( add( rc_q_fx[sub( i, 1 )], a_q_fx[j] ), 31 ); + + IF( LT_16( temp_q2, a_q_fx[l] ) ) + { + a_fx[l] = L_add( L_shr( a_fx[l], sub( a_q_fx[l], temp_q2 ) ), temp2 ); + move32(); + a_q_fx[l] = temp_q2; + move16(); + } + ELSE + { + a_fx[l] = L_add( a_fx[l], L_shr( temp2, sub( temp_q2, a_q_fx[l] ) ) ); + move16(); + } + a_fx[j] = at_fx; + move32(); + a_q_fx[j] = temp_q1; + move16(); + } + a_fx[i] = rc_fx[sub( i, 1 )]; + move32(); + a_q_fx[i] = rc_q_fx[sub( i, 1 )]; + move16(); + + exp1 = sub( norm_l( rc_fx[sub( i, 1 )] ), 1 ); + exp2 = norm_l( s ); + temp1 = Mpy_32_32( L_shl( rc_fx[sub( i, 1 )], exp1 ), L_shl( s, exp2 ) ); + temp_q1 = sub( add( add( rc_q_fx[sub( i, 1 )], exp1 ), add( s_q_fx, exp2 ) ), 31 ); + + IF( LT_16( temp_q1, err_q_fx ) ) + { + err_fx = L_add( L_shr( err_fx, sub( err_q_fx, temp_q1 ) ), temp1 ); + err_q_fx = temp_q1; + move16(); + } + ELSE + { + err_fx = L_add( err_fx, L_shr( temp1, sub( temp_q1, err_q_fx ) ) ); + } + + IF( LE_32( err_fx, 0 ) ) + { + err_fx = 21474836; // 0.01 in Q31 + move32(); + err_q_fx = Q31; + move16(); + } + IF( epsP_fx != NULL ) + { + epsP_fx[i] = err_fx; + move32(); + epsP_q_fx[i] = err_q_fx; + move16(); + } + } + + return ( flag ); +} + +/*-------------------------------------------------------------------* + * a2rc_fx() + * + * Convert from LPC to reflection coeff + *-------------------------------------------------------------------*/ + +static Word16 d_a2rc_fx( + const Word32 *a_fx, /* i : LPC coefficients */ + Word16 *a_q_fx, + Word32 *refl_fx, /* o : Reflection co-efficients */ + const Word16 lpcorder /* i : LPC order */ +) +{ + Word16 m, j, n; + Word32 ff_fx[LFE_PLC_LPCORD]; + Word32 km_fx, denom_fx, temp1, temp2, temp; + Word16 ff_q_fx[LFE_PLC_LPCORD], temp_q1, temp_q2, denom_q_fx, km_q_fx, temp_q; + Word16 exp1, exp2; + + FOR( m = 0; m < lpcorder; m++ ) + { + ff_fx[m] = -a_fx[m]; + move32(); + ff_q_fx[m] = a_q_fx[m]; + move32(); + } + + /* Initialization */ + FOR( m = sub( lpcorder, 1 ); m >= 0; m-- ) + { + km_fx = ff_fx[m]; + move32(); + km_q_fx = ff_q_fx[m]; + move16(); + IF( GE_64( W_shr( abs( km_fx ), sub( ff_q_fx[m], Q30 ) ), W_deposit32_l( ONE_IN_Q30 ) ) ) + { + FOR( j = 0; j < lpcorder; j++ ) + { + refl_fx[j] = 0; + move32(); + } + return 0; + } + + refl_fx[m] = -km_fx; + move32(); + + exp1 = norm_l( km_fx ); + temp1 = Mpy_32_32( L_shl( km_fx, exp1 ), L_shl( km_fx, exp1 ) ); + temp_q1 = sub( add( add( km_q_fx, exp1 ), add( km_q_fx, exp1 ) ), 31 ); + temp1 = L_sub( ONE_IN_Q30, L_shr( temp1, sub( temp_q1, 30 ) ) ); + denom_fx = L_deposit_l( BASOP_Util_Divide3232_Scale( ONE_IN_Q30, temp1, &temp_q1 ) ); + denom_q_fx = sub( 15, temp_q1 ); + + FOR( j = 0; j < m / 2; j++ ) + { + n = sub( sub( m, 1 ), j ); + + exp1 = norm_l( denom_fx ); + exp2 = sub( norm_l( ff_fx[j] ), 1 ); + temp1 = Mpy_32_32( L_shl( denom_fx, exp1 ), L_shl( ff_fx[j], exp2 ) ); + temp_q1 = sub( add( add( denom_q_fx, exp1 ), add( ff_q_fx[j], exp2 ) ), 31 ); + + exp2 = sub( norm_l( ff_fx[n] ), 1 ); + temp2 = Mpy_32_32( L_shl( denom_fx, exp1 ), L_shl( ff_fx[n], exp2 ) ); + temp_q2 = sub( add( add( denom_q_fx, exp1 ), add( ff_q_fx[n], exp2 ) ), 31 ); + + exp1 = norm_l( km_fx ); + exp2 = sub( norm_l( temp2 ), 1 ); + temp = Mpy_32_32( L_shl( km_fx, exp1 ), L_shl( temp2, exp2 ) ); + temp_q = sub( add( add( km_q_fx, exp1 ), add( temp_q2, exp2 ) ), 31 ); + + IF( LT_16( temp_q, temp_q1 ) ) + { + ff_fx[j] = L_add( L_shr( temp1, sub( temp_q1, temp_q ) ), temp ); + move32(); + ff_q_fx[j] = temp_q; + move16(); + } + ELSE + { + ff_fx[j] = L_add( temp1, L_shr( temp, sub( temp_q, temp_q1 ) ) ); + move32(); + ff_q_fx[j] = temp_q1; + move16(); + } + + exp1 = norm_l( km_fx ); + exp2 = sub( norm_l( temp1 ), 1 ); + temp = Mpy_32_32( L_shl( km_fx, exp1 ), L_shl( temp1, exp2 ) ); + temp_q = sub( add( add( km_q_fx, exp1 ), add( temp_q1, exp2 ) ), 31 ); + + IF( LT_16( temp_q, temp_q2 ) ) + { + ff_fx[n] = L_add( L_shr( temp2, sub( temp_q2, temp_q ) ), temp ); + move32(); + ff_q_fx[n] = temp_q; + move16(); + } + ELSE + { + ff_fx[n] = L_add( temp2, L_shr( temp, sub( temp_q, temp_q2 ) ) ); + move32(); + ff_q_fx[n] = temp_q2; + move16(); + } + } + + IF( m & 1 ) + { + exp1 = norm_l( denom_fx ); + exp2 = sub( norm_l( ff_fx[j] ), 1 ); + temp1 = Mpy_32_32( L_shl( denom_fx, exp1 ), L_shl( ff_fx[j], exp2 ) ); + temp_q1 = sub( add( add( denom_q_fx, exp1 ), add( ff_q_fx[j], exp2 ) ), 31 ); + + exp1 = norm_l( km_fx ); + exp2 = sub( norm_l( temp1 ), 1 ); + temp = Mpy_32_32( L_shl( km_fx, exp1 ), L_shl( temp1, exp2 ) ); + temp_q = sub( add( add( km_q_fx, exp1 ), add( temp_q1, exp2 ) ), 31 ); + + IF( LT_16( temp_q, temp_q1 ) ) + { + ff_fx[j] = L_add( L_shr( temp1, sub( temp_q1, temp_q ) ), temp ); + move32(); + ff_q_fx[j] = temp_q; + move16(); + } + ELSE + { + ff_fx[j] = L_add( temp1, L_shr( temp, sub( temp_q, temp_q1 ) ) ); + move32(); + ff_q_fx[j] = temp_q1; + move16(); + } + } + } + + return 1; +} + +static void d_syn_filt_fx( + const Word32 *a_fx, /* i : LP filter coefficients */ + Word16 *a_q_fx, + const Word16 m, /* i : order of LP filter */ + const Word32 *x_fx, /* i : input signal */ + Word32 *y_fx, /* o : output signal */ + Word16 *y_q_fx, + const Word16 l, /* i : size of filtering */ + const Word32 *mem_fx, /* i : initial filter states */ + Word16 mem_q_fx ) +{ + Word16 i, j; + Word32 buf_fx[LFE_PLC_LPCORD + LFE_PLC_RECLEN]; /* temporary synthesis buffer */ + Word32 s_fx, *yy_fx, temp; + Word16 yy_q_fx[LFE_PLC_LPCORD + LFE_PLC_RECLEN], exp1, exp2, s_q_fx, temp_q; + + yy_fx = &buf_fx[0]; + + /*------------------------------------------------------------------* + * copy initial filter states into synthesis buffer and do synthesis + *------------------------------------------------------------------*/ + FOR( i = 0; i < m; i++ ) + { + *yy_fx++ = mem_fx[i]; + move32(); + yy_q_fx[i] = mem_q_fx; + move16(); + } + + /*-----------------------------------------------------------------------* + * Do the filtering + *-----------------------------------------------------------------------*/ + + FOR( i = 0; i < l; i++ ) + { + s_fx = x_fx[i]; + move32(); + s_q_fx = Q31; + move16(); + FOR( j = 1; j <= m; j++ ) + { + exp1 = sub( norm_l( a_fx[j] ), 1 ); + exp2 = sub( norm_l( yy_fx[i - j] ), 1 ); + IF( GT_16( j, i ) ) + { + temp_q = mem_q_fx; + move16(); + } + ELSE + { + temp_q = yy_q_fx[sub( i, j )]; + move16(); + } + temp = Mpy_32_32( L_shl( a_fx[j], exp1 ), L_shl( yy_fx[sub( i, j )], exp2 ) ); + temp_q = sub( add( add( a_q_fx[j], exp1 ), add( temp_q, exp2 ) ), 31 ); + + IF( LT_16( s_q_fx, temp_q ) ) + { + s_fx = L_sub( s_fx, L_shr( temp, sub( temp_q, s_q_fx ) ) ); + } + ELSE + { + s_fx = L_sub( L_shr( s_fx, sub( s_q_fx, temp_q ) ), temp ); + s_q_fx = temp_q; + move16(); + } + } + yy_fx[i] = s_fx; + move32(); + yy_q_fx[i] = s_q_fx; + move16(); + y_fx[i] = L_shr( s_fx, sub( s_q_fx, Q5 ) ); + move32(); + } + *y_q_fx = Q5; + move16(); + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function check_stab_fx() + * + * LPC filter stability check applying given sharpening value delta + *-----------------------------------------------------------------------------------------*/ + +static Word16 check_stab_fx( + Word32 *a_fx, + Word16 *a_q_fx, + Word32 delta_fx, + Word16 delta_q_fx ) +{ + Word16 i; + Word16 stable; + + Word32 amod_fx[LFE_PLC_LPCORD], refl_fx[LFE_PLC_LPCORD]; + Word16 fac_q_fx, fac1_q_fx, amod_q_fx[LFE_PLC_LPCORD]; + Word16 exp1, exp2; + Word32 fac_fx, fac1_fx; + + exp1 = norm_l( delta_fx ); + delta_fx = L_shl( delta_fx, exp1 ); + delta_q_fx = add( delta_q_fx, exp1 ); + + IF( LT_16( delta_q_fx, 29 ) ) + { + fac_fx = L_add( L_shr( ONE_IN_Q29, sub( 29, delta_q_fx ) ), delta_fx ); + fac_q_fx = delta_q_fx; + move16(); + } + ELSE + { + fac_fx = L_add( ONE_IN_Q29, L_shr( delta_fx, sub( delta_q_fx, 29 ) ) ); + fac_q_fx = Q29; + move16(); + } + fac1_fx = fac_fx; + move32(); + fac1_q_fx = fac_q_fx; + move16(); + + FOR( i = 0; i < LFE_PLC_LPCORD; i++ ) + { + exp1 = norm_l( a_fx[i] ); + exp2 = norm_l( fac_fx ); + amod_fx[i] = Mpy_32_32( L_shl( a_fx[i], exp1 ), L_shl( fac_fx, exp2 ) ); + move32(); + amod_q_fx[i] = sub( add( add( a_q_fx[i], exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + move16(); + + exp1 = norm_l( fac_fx ); + exp2 = norm_l( fac1_fx ); + fac_fx = Mpy_32_32( L_shl( fac_fx, exp1 ), L_shl( fac1_fx, exp2 ) ); + fac_q_fx = sub( add( add( fac_q_fx, exp1 ), add( fac1_q_fx, exp2 ) ), 31 ); + } + stable = d_a2rc_fx( amod_fx, amod_q_fx, refl_fx, LFE_PLC_LPCORD ); + + return stable; +} + +/*-----------------------------------------------------------------------------------------* + * Function find_max_delta_fx() + * + * Find maximum LPC filter sharpening by iteration to get a filter that is almost instable + *-----------------------------------------------------------------------------------------*/ + +static Word32 find_max_delta_fx( + Word32 *a_fx, + Word16 *a_q_fx, + Word16 *delta_q_fx ) +{ + Word16 stable; + Word16 eps_q_fx, fac_q_fx, exp1, exp2; + Word32 delta_fx, fac_fx, eps_fx, temp; + + delta_fx = 0; + move32(); + eps_fx = 21474836; // 0.01 in Q31 + move32(); + fac_fx = 1073741824; // 2 in Q29 + move32(); + eps_q_fx = Q31; + move16(); + fac_q_fx = Q29; + move16(); + + stable = FALSE; + move16(); + + WHILE( check_stab_fx( a_fx, a_q_fx, eps_fx, eps_q_fx ) ) + { + exp1 = norm_l( eps_fx ); + exp2 = norm_l( fac_fx ); + eps_fx = Mpy_32_32( L_shl( eps_fx, exp1 ), L_shl( fac_fx, exp2 ) ); + eps_q_fx = sub( add( add( eps_q_fx, exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + stable = TRUE; + move16(); + } + fac_fx = 1073741824; // 0.5 in Q31 + move32(); + fac_q_fx = Q31; + move16(); + + IF( stable ) + { + exp1 = norm_l( eps_fx ); + exp2 = norm_l( fac_fx ); + eps_fx = Mpy_32_32( L_shl( eps_fx, exp1 ), L_shl( fac_fx, exp2 ) ); + eps_q_fx = sub( add( add( eps_q_fx, exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + } + + WHILE( !stable ) + { + exp1 = norm_l( eps_fx ); + exp2 = norm_l( fac_fx ); + eps_fx = Mpy_32_32( L_shl( eps_fx, exp1 ), L_shl( fac_fx, exp2 ) ); + eps_q_fx = sub( add( add( eps_q_fx, exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + + stable = check_stab_fx( a_fx, a_q_fx, eps_fx, eps_q_fx ); + } + + /* must be stable with current eps */ + *delta_q_fx = sub( norm_l( eps_fx ), 1 ); + delta_fx = L_shl( eps_fx, *delta_q_fx ); + *delta_q_fx = add( eps_q_fx, *delta_q_fx ); + + exp1 = norm_l( eps_fx ); + exp2 = norm_l( fac_fx ); + eps_fx = Mpy_32_32( L_shl( eps_fx, exp1 ), L_shl( fac_fx, exp2 ) ); + eps_q_fx = sub( add( add( eps_q_fx, exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + + WHILE( 1 ) + { + IF( LT_16( *delta_q_fx, eps_q_fx ) ) + { + delta_fx = L_add( delta_fx, L_shr( eps_fx, sub( eps_q_fx, *delta_q_fx ) ) ); + } + ELSE + { + delta_fx = L_add( L_shr( delta_fx, sub( *delta_q_fx, eps_q_fx ) ), eps_fx ); + *delta_q_fx = eps_q_fx; + move16(); + } + stable = check_stab_fx( a_fx, a_q_fx, delta_fx, *delta_q_fx ); + + IF( !stable ) + { + temp = abs( eps_fx ); + IF( GT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) + { + exp1 = norm_l( -temp ); + exp2 = norm_l( fac_fx ); + eps_fx = Mpy_32_32( L_shl( -temp, exp1 ), L_shl( fac_fx, exp2 ) ); + eps_q_fx = sub( add( add( eps_q_fx, exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + } + ELSE + { + eps_fx = -abs( eps_fx ); + } + } + ELSE + { + temp = abs( eps_fx ); + IF( LT_32( L_shr( temp, sub( eps_q_fx, 31 ) ), EPS_STOP_Q31 ) ) + { + BREAK; + } + + exp1 = norm_l( temp ); + exp1 = norm_l( fac_fx ); + eps_fx = Mpy_32_32( L_shl( temp, exp1 ), L_shl( fac_fx, exp2 ) ); + eps_q_fx = sub( add( add( eps_q_fx, exp1 ), add( fac_q_fx, exp2 ) ), 31 ); + } + } + + return delta_fx; +} + +/*-----------------------------------------------------------------------------------------* + * Function recover_samples_fx() + * + * recover lost samples by extrapolation of signal buffer + *-----------------------------------------------------------------------------------------*/ + +static void recover_samples_fx( + const Word16 bfi_count, + const Word32 *outbuf_fx, + Word16 outbuf_q_fx, + Word32 *rec_frame_fx, + Word16 *rec_frame_q_fx ) +{ + Word16 i; + Word32 d_outbuf_fx[LFE_PLC_BUFLEN], d_a_fx[LFE_PLC_LPCORD + 1], d_pee_fx[LFE_PLC_LPCORD + 1]; + Word16 d_r_q_fx[LFE_PLC_LPCORD + 1], d_a_q_fx[LFE_PLC_LPCORD + 1], d_pee_q_fx[LFE_PLC_LPCORD + 1]; + Word32 d_r_fx[LFE_PLC_LPCORD + 1], zeroes_fx[LFE_PLC_RECLEN]; + Word32 delta_fx, fac_fx, att_fx, temp; + Word16 delta_q_fx, fac_q_fx, att_q_fx, temp_q, exp1, exp2; + + Copy32( outbuf_fx, d_outbuf_fx, LFE_PLC_BUFLEN ); + + d_autocorr_fx( d_outbuf_fx, outbuf_q_fx, d_r_fx, d_r_q_fx, LFE_PLC_LPCORD, LFE_PLC_BUFLEN, d_hamm_lfe_plc_fx, 0, 1, 1 ); + + IF( LT_64( W_shr( d_r_fx[0], sub( d_r_q_fx[0], Q19 ) ), W_deposit32_l( Mpy_32_32( POW_THR_Q50, LFE_PLC_BUFLEN ) ) ) ) + { + set_zero_fx( rec_frame_fx, LFE_PLC_RECLEN ); + return; + } + + d_lev_dur_fx( d_a_fx, d_a_q_fx, d_r_fx, d_r_q_fx, LFE_PLC_LPCORD, d_pee_fx, d_pee_q_fx ); + + delta_fx = find_max_delta_fx( d_a_fx + 1, d_a_q_fx + 1, &delta_q_fx ); + + IF( LT_16( delta_q_fx, Q29 ) ) + { + fac_fx = L_add( L_shr( ONE_IN_Q29, sub( Q29, delta_q_fx ) ), delta_fx ); + fac_q_fx = delta_q_fx; + move16(); + } + ELSE + { + fac_fx = L_add( ONE_IN_Q29, L_shr( delta_fx, sub( delta_q_fx, Q29 ) ) ); + fac_q_fx = Q29; + move16(); + } + att_fx = ONE_IN_Q30; + move32(); + att_q_fx = Q30; + move16(); + + IF( GE_16( bfi_count, LFE_PLC_MUTE_THR ) ) + { + att_fx = LFE_PLC_BURST_ATT_Q31; + move32(); + fac_fx = Mpy_32_32( fac_fx, att_fx ); + fac_q_fx = sub( add( fac_q_fx, att_q_fx ), 31 ); + } + + FOR( i = 1; i <= LFE_PLC_LPCORD; i++ ) + { + d_a_fx[i] = Mpy_32_32( d_a_fx[i], fac_fx ); + move32(); + d_a_q_fx[i] = sub( add( d_a_q_fx[i], fac_q_fx ), 31 ); + move16(); + IF( LT_16( delta_q_fx, Q30 ) ) + { + temp = L_add( L_shr( ONE_IN_Q30, sub( Q30, delta_q_fx ) ), delta_fx ); + temp_q = delta_q_fx; + move16(); + } + ELSE + { + temp = L_add( ONE_IN_Q30, L_shr( delta_fx, sub( delta_q_fx, Q30 ) ) ); + temp_q = Q30; + move16(); + } + exp1 = norm_l( att_fx ); + exp2 = norm_l( temp ); + temp = Mpy_32_32( L_shl( att_fx, exp1 ), L_shl( temp, exp2 ) ); + temp_q = sub( add( add( att_q_fx, exp1 ), add( temp_q, exp2 ) ), 31 ); + + exp1 = norm_l( fac_fx ); + exp2 = norm_l( temp ); + fac_fx = Mpy_32_32( L_shl( fac_fx, exp1 ), L_shl( temp, exp2 ) ); + fac_q_fx = sub( add( add( fac_q_fx, exp1 ), add( temp_q, exp2 ) ), 31 ); + } + + set_zero_fx( zeroes_fx, LFE_PLC_RECLEN ); + + d_syn_filt_fx( d_a_fx, d_a_q_fx, LFE_PLC_LPCORD, zeroes_fx, rec_frame_fx, rec_frame_q_fx, LFE_PLC_RECLEN, outbuf_fx + LFE_PLC_BUFLEN - LFE_PLC_LPCORD, outbuf_q_fx ); + + return; +} + +/*-----------------------------------------------------------------------------------------* + * Function ivas_lfe_tdplc_fx() + * + * MDCT interface recover lost samples by extrapolation of signal buffer + *-----------------------------------------------------------------------------------------*/ + +void ivas_lfe_tdplc_fx( + LFE_DEC_HANDLE hLFE, /* i/o: LFE decoder handle */ + const Word32 *prevsynth, /* i : previous frame synthesis */ + Word32 *ytda, /* o : output time-domain buffer */ + const Word16 output_frame /* i : output frame length */ +) +{ + Word32 rec_frame_us_fx[LFE_PLC_RECLEN_48K], input_tda_fx[L_FRAME48k]; + Word32 rec_frame_fx[LFE_PLC_RECLEN], prevsynth_fx[LFE_PLC_BUFLEN]; + Word16 rec_frame_us_16_fx[LFE_PLC_RECLEN_48K], mem_fx[2 * LFE_PLC_FDEL / LFE_PLC_DSF], rec_frame_16_fx[LFE_PLC_RECLEN]; + Word16 prevsynth_16_fx[LFE_PLC_BUFLEN]; + const Word32 *pWindow_coeffs_fx; + Word32 output_Fs; + Word16 i, fade_len, full_len, dct_len, zero_pad_len, plc_fdel, rec_frame_len; + Word16 fdel_dsf_ratio, prevsynth_q_fx, rec_frame_q, temp, temp_q, idx, exp; + + output_Fs = L_mult0( output_frame, FRAMES_PER_SEC ); + fade_len = hLFE->pWindow_state->fade_len; + move16(); + full_len = hLFE->pWindow_state->full_len; + move16(); + dct_len = hLFE->pWindow_state->dct_len; + move16(); + zero_pad_len = hLFE->pWindow_state->zero_pad_len; + move16(); + pWindow_coeffs_fx = hLFE->pWindow_state->pWindow_coeffs_fx; + + temp = BASOP_Util_Divide3232_Scale( Mpy_32_32( L_shl( LFE_PLC_FDEL, 22 ), L_shl( output_Fs, 9 ) ), 48000, &temp_q ); + plc_fdel = shr( temp, sub( 15, temp_q ) ); + + temp = BASOP_Util_Divide3232_Scale( output_Fs, 48000, &temp_q ); + rec_frame_len = shl( mult( LFE_PLC_RECLEN_48K, temp ), temp_q ); + + Copy32( prevsynth, prevsynth_fx, LFE_PLC_BUFLEN ); + exp = L_norm_arr( prevsynth_fx, LFE_PLC_BUFLEN ); + scale_sig32( prevsynth_fx, LFE_PLC_BUFLEN, exp ); + prevsynth_q_fx = add( Q9, exp ); + move16(); + + recover_samples_fx( hLFE->bfi_count, prevsynth_fx, prevsynth_q_fx, rec_frame_fx, &rec_frame_q ); + + fdel_dsf_ratio = shl( div_l( LFE_PLC_FDEL, LFE_PLC_DSF ), 1 ); + set_s( mem_fx, 0, shl( fdel_dsf_ratio, 1 ) ); + + Copy_Scale_sig_32_16( prevsynth_fx, prevsynth_16_fx, LFE_PLC_BUFLEN, -16 ); // Q5 = Q21 - Q16 + Copy_Scale_sig_32_16( rec_frame_fx, rec_frame_16_fx, LFE_PLC_RECLEN, 0 ); // Q5 + + modify_Fs_fx( prevsynth_16_fx + LFE_PLC_BUFLEN - LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FDEL / LFE_PLC_DSF, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0 ); + modify_Fs_fx( rec_frame_16_fx, LFE_PLC_RECLEN, LFE_PLC_FS, rec_frame_us_16_fx, 48000, mem_fx, 0 ); + /*samples are generated with 48k sampling rate + and then converted to required sampling rate by simple decimation + as signal is already bandlimited*/ + + /*decimation to correct sampling rate*/ + IF( NE_32( output_Fs, 48000 ) ) + { + FOR( i = 0; i < rec_frame_len; i++ ) + { + idx = BASOP_Util_Divide3232_Scale( Mpy_32_32( L_shl( i, 16 ), L_shl( 44100, 15 ) ), output_Fs, &temp_q ); + idx = shr( idx, add( sub( 15, temp_q ), 1 ) ); + rec_frame_us_16_fx[i] = rec_frame_us_16_fx[idx]; + move16(); + } + } + + Copy_Scale_sig_16_32( rec_frame_us_16_fx, rec_frame_us_fx, LFE_PLC_RECLEN_48K, 5 ); // Q10 = rec_frame_q + 5 + + FOR( i = 0; i < 2; i++ ) + { + ivas_dct_windowing_fx( fade_len, full_len, dct_len, zero_pad_len, pWindow_coeffs_fx, output_frame, input_tda_fx, rec_frame_us_fx + plc_fdel, rec_frame_us_fx + add( add( plc_fdel, fade_len ), i_mult( i, dct_len ) ) ); + ivas_tda_fx( input_tda_fx, ytda + i * dct_len, dct_len ); + } + + return; +} +#endif \ No newline at end of file diff --git a/lib_dec/ivas_ls_custom_dec.c b/lib_dec/ivas_ls_custom_dec.c index f7c24d8f5..7c35700f2 100644 --- a/lib_dec/ivas_ls_custom_dec.c +++ b/lib_dec/ivas_ls_custom_dec.c @@ -45,7 +45,7 @@ * * Allocate Custom LS layout handle *-----------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_ls_custom_open( LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ ) @@ -70,8 +70,7 @@ ivas_error ivas_ls_custom_open( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_ls_custom_open_fx( LSSETUP_CUSTOM_HANDLE *hLsSetupCustom /* o : Custom loudspeaker setup handle */ ) diff --git a/lib_dec/ivas_mc_param_dec.c b/lib_dec/ivas_mc_param_dec.c index 43326c559..55373068d 100644 --- a/lib_dec/ivas_mc_param_dec.c +++ b/lib_dec/ivas_mc_param_dec.c @@ -79,6 +79,7 @@ typedef struct parameter_band_mapping_struct *-----------------------------------------------------------------------*/ static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, const int16_t nchan_in, const int16_t nchan_out ); +static void ivas_param_mc_dec_init_fx( PARAM_MC_DEC_HANDLE hParamMC, const Word16 nchan_in, const Word16 nchan_out ); static void param_mc_protoSignalComputation( float *RealBuffer, float *ImagBuffer, float *proto_frame_f, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const int16_t num_freq_bands ); #ifdef IVAS_FLOAT_FIXED @@ -108,9 +109,9 @@ static void ivas_param_mc_get_mixing_matrices_fx( const Word16 nX, /* i : number of transport channels */ const Word16 nY_cov /* i : number of covariance synthesis output channels */ ); - +#ifndef IVAS_FLOAT_FIXED static void ivas_param_mc_get_mono_stereo_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float Cx_in[PARAM_MC_MAX_PARAMETER_BANDS][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], float *mixing_matrix[], float *mixing_matrix_res[], const int16_t nY_intern, const int16_t nX, const int16_t nY_cov ); - +#endif static void param_mc_update_mixing_matrices( PARAM_MC_DEC_HANDLE hParamMC, float *mixing_matrix[], float *mixing_matrix_res[], const uint16_t nX, const uint16_t nY ); #ifdef IVAS_FLOAT_FIXED @@ -126,21 +127,466 @@ static ivas_error param_mc_get_diff_proto_info( const float *proto_mtx, const ui static void ivas_param_mc_get_param_band_mapping( const int16_t n_target_bands, const int16_t *target_band_grouping, const int16_t n_source_bands, const int16_t *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); -static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); +static void ivas_param_mc_bs_decode_parameter_values( uint16_t bit_buffer[], int16_t *bit_pos, const int16_t max_bits, int16_t *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const int16_t map_size_wo_lfe, const int16_t map_size, const int16_t num_lfe_bands, const int16_t band_step, const int16_t num_param_bands, float *value_buffer ); + +#ifdef IVAS_FLOAT_FIXED +static void ivas_param_mc_bs_decode_parameter_values_fx(UWord16 bit_buffer[], Word16 *bit_pos, const Word16 max_bits, Word16 *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const Word16 map_size_wo_lfe, const Word16 map_size, const Word16 num_lfe_bands, const Word16 band_step, const Word16 num_param_bands, Word16 *value_buffer); +static void ivas_param_mc_dequantize_cov_fx(PARAM_MC_DEC_HANDLE hParamMC, Word16 *ild_q_fx, Word16 *icc_q_fx, const Word16 param_band_index, const Word16 nY_cov, const PARAM_MC_SYNTHESIS_CONF synth_conf, const Word16 nY_int, const Word16 nX, Word32 *Cx_state_fx, Word16 Cx_state_e, Word32 *Cproto_fx, Word16 Cproto_e, Word32 *Cy_state_fx, Word16 *Cy_state_e); +static ivas_error param_mc_get_diff_proto_info_fx(const Word32 *proto_mtx, const UWord16 nchan_transport, const UWord16 nchan_out_cov, PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info, Word16 Q_proto_mtx); +static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); +#endif + +/*------------------------------------------------------------------------- + * ivas_param_mc_dec_open() + * + * Open Parametric MC decoder handle + *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_param_mc_dec_open_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +) +{ + Word16 k, nchan_transport; + PARAM_MC_DEC_HANDLE hParamMC; +#ifndef FIX_901_PARAMMC_DEAD_CODE + IVAS_OUTPUT_SETUP hTransportSetup; +#endif + Word16 nchan_out_transport; + Word16 nchan_out_cov; + Word32 proto_matrix_fx[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; + Word32 proto_mtx_norm_fx; + Word16 frequency_axis_fx[CLDFB_NO_CHANNELS_MAX]; + Word16 max_param_band_residual; + UWord16 config_index; + MC_LS_SETUP mc_ls_setup; + AUDIO_CONFIG output_config; + Word32 output_Fs, ivas_total_brate; + ivas_error error; + + error = IVAS_ERR_OK; + + /*-----------------------------------------------------------------* + * prepare library opening + *-----------------------------------------------------------------*/ + + if ( ( hParamMC = (PARAM_MC_DEC_HANDLE) malloc( sizeof( PARAM_MC_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + + if ( ( hParamMC->hMetadataPMC = (HANDLE_IVAS_PARAM_MC_METADATA) malloc( sizeof( IVAS_PARAM_MC_METADATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC metadata \n" ) ); + } + + output_Fs = st_ivas->hDecoderConfig->output_Fs; + output_config = st_ivas->hDecoderConfig->output_config; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; +#ifndef FIX_901_PARAMMC_DEAD_CODE + hTransportSetup = st_ivas->hTransSetup; +#endif + mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + hParamMC->hoa_encoder_fx = NULL; +#if 1/*TODO: To be removed later(floating pointer initialization)*/ + hParamMC->hoa_encoder = NULL; +#endif + + /* determine the synthesis config */ + if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM || st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD || st_ivas->transport_config == output_config ) + { + hParamMC->synthesis_conf = PARAM_MC_SYNTH_DIRECT; + } + else if ( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) + { + hParamMC->synthesis_conf = PARAM_MC_SYNTH_MONO_STEREO; + } + else if ( st_ivas->transport_config != output_config ) + { + if ( ( output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM && nchan_out_transport > audioCfg2channels( output_config ) ) || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && nchan_out_transport > st_ivas->hOutSetup.nchan_out_woLFE ) ) + { + hParamMC->synthesis_conf = PARAM_MC_SYNTH_LS_CONV_COV; + /* need to reset the intern config */ + st_ivas->intern_config = output_config; + ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM ) + { + st_ivas->hIntSetup.nchan_out_woLFE = st_ivas->hLsSetupCustom->num_spk; +#if 1/*TODO: To be removed later*/ + st_ivas->hIntSetup.ls_azimuth = st_ivas->hLsSetupCustom->ls_azimuth; + st_ivas->hIntSetup.ls_elevation = st_ivas->hLsSetupCustom->ls_elevation; +#endif + st_ivas->hIntSetup.ls_azimuth_fx = st_ivas->hLsSetupCustom->ls_azimuth_fx; + st_ivas->hIntSetup.ls_elevation_fx = st_ivas->hLsSetupCustom->ls_elevation_fx; + } + } + else + { + hParamMC->synthesis_conf = PARAM_MC_SYNTH_LS_CONV_CLDFB; + } + } + +#if 0/*TODO: To be removed later*/ + hParamMC->ls_conv_dmx_matrix = NULL; +#endif + hParamMC->ls_conv_dmx_matrix_fx = NULL; + + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + } + else + { + nchan_out_cov = nchan_out_transport; + } + + st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); + config_index = ivas_param_mc_get_configuration_index( mc_ls_setup, ivas_total_brate ); + nchan_transport = st_ivas->nchan_transport; + + switch ( nchan_transport ) + { + case 4: + case 3: + st_ivas->nCPE = 2; + st_ivas->nSCE = 0; + st_ivas->element_mode_init = IVAS_CPE_MDCT; + break; + case 2: + st_ivas->nCPE = 1; + st_ivas->nSCE = 0; + st_ivas->element_mode_init = IVAS_CPE_MDCT; + + break; + } + + /*-----------------------------------------------------------------* + * set input parameters + *-----------------------------------------------------------------*/ + + hParamMC->slot_size = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / CLDFB_NO_COL_MAX; + set_s( hParamMC->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS ); + set_s( hParamMC->subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, DEFAULT_JBM_SUBFRAMES_5MS ); + hParamMC->nb_subframes = DEFAULT_JBM_SUBFRAMES_5MS; + + hParamMC->num_freq_bands = (int16_t) ( output_Fs * INV_CLDFB_BANDWIDTH + 0.5f ); + hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; +#ifndef FIX_901_PARAMMC_DEAD_CODE + ivas_param_mc_metadata_open( mc_ls_setup, hTransportSetup.index_lfe[0], ivas_total_brate, hParamMC->hMetadataPMC ); +#else + ivas_param_mc_metadata_open( mc_ls_setup, ivas_total_brate, hParamMC->hMetadataPMC ); +#endif + + /* init arrays for quantized parameters */ + + if ( ( hParamMC->icc_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + if ( ( hParamMC->icld_q_fx = (Word16 *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( Word16 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + set16_fx( hParamMC->icld_q_fx, PARAM_MC_DEFAULT_MIN_ILD_FX, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); + set16_fx( hParamMC->icc_q_fx, 0, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); + +#if 1/*TODO: To be removed later(floating point initialization)*/ + if ( ( hParamMC->icc_q = (float *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + if ( ( hParamMC->icld_q = (float *) malloc( hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } +#endif + + param_mc_set_num_synth_bands( output_Fs, hParamMC ); + + /* Band Grouping */ + if ( hParamMC->hMetadataPMC->num_parameter_bands == 20 ) + { + mvs2s( param_mc_band_grouping_20, hParamMC->band_grouping, 20 + 1 ); + } + else if ( hParamMC->hMetadataPMC->num_parameter_bands == 14 ) + { + mvs2s( param_mc_band_grouping_14, hParamMC->band_grouping, 14 + 1 ); + } + else if ( hParamMC->hMetadataPMC->num_parameter_bands == 10 ) + { + mvs2s( param_mc_band_grouping_10, hParamMC->band_grouping, 10 + 1 ); + } + else + { + assert( 0 && "nbands must be 20, 14, or 10!" ); + } + + /* set max parameter band for abs cov */ + k = 0; + while ( hParamMC->band_grouping[k] <= PARAM_MC_MAX_BAND_ABS_COV_DEC ) + { + hParamMC->max_param_band_abs_cov = ( k++ ); + } + + /*-----------------------------------------------------------------* + * open sub-modules + *-----------------------------------------------------------------*/ + + /* prototype signal computation */ + + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_CLDFB || hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { +#if 0/*TODO: To be removed later (floating point malloc)*/ + if ( ( hParamMC->ls_conv_dmx_matrix = (float *) malloc( nchan_out_transport * nchan_out_cov * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } +#endif + IF( ( hParamMC->ls_conv_dmx_matrix_fx = (Word32 *) malloc( nchan_out_transport * nchan_out_cov * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + + for ( k = 0; k < nchan_out_transport; k++ ) + { + Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov], nchan_out_cov );/*Q30*/ + } + + /* convert ParamMC parameter bands to SFB */ + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + st_ivas->hLsSetUpConversion->sfbCnt = hParamMC->num_param_bands_synth; + for ( k = 0; k <= hParamMC->num_param_bands_synth; k++ ) + { + st_ivas->hLsSetUpConversion->sfbOffset[k] = PARAM_MC_BAND_TO_MDCT_BAND_RATIO * hParamMC->band_grouping[k]; + } + } + else + { + /* close the ls conversion handle immediately, it was only needed to get the DMX matrix in case of DMX in the covariance domain */ + ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + } + } + } + if ( ( hParamMC->proto_matrix_int_fx = (Word32 *) malloc( nchan_out_transport * nchan_transport * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, hParamMC->proto_matrix_int_fx, nchan_transport * nchan_out_transport );/*Q31*/ + + if ( ( hParamMC->proto_matrix_int = (float *) malloc( nchan_out_transport * nchan_transport * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, -4 ); /*Q.26*/ + matrix_product_fx( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_cov, nchan_out_transport, 0, ivas_param_mc_conf[config_index].dmx_fac_fx, nchan_out_transport, nchan_transport, 0, proto_matrix_fx );/*Q.26*/ + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, 4 ); /*Q.26*/ + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + proto_mtx_norm_fx = ONE_IN_Q26;/*Q26*/ + for ( k = 0; k < nchan_transport * nchan_out_cov; k++ ) + { + proto_mtx_norm_fx = L_max(L_abs(proto_mtx_norm_fx), L_abs( proto_matrix_fx[k] ) );/*Q.26*/ + } + proto_mtx_norm_fx = divide3232(ONE_IN_Q26 , proto_mtx_norm_fx);/*Q15*/ + + /* transfer flattened proto_matrix to 2D in hLsSetupConversion->dmxMtx */ + for ( k = 0; k < nchan_transport; k++ ) + { + for ( int16_t i = 0; i < nchan_out_cov; i++ ) + { + st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl(Mult_32_16(proto_matrix_fx[k * nchan_out_cov + i] , extract_l(proto_mtx_norm_fx)),4);/*Q.30*/ + } + } + } + } + else + { + Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, proto_matrix_fx, nchan_out_transport * nchan_transport );/*Q.31*/ + Scale_sig32( proto_matrix_fx, nchan_out_transport * nchan_transport, -5);/*Scaling down to 26*/ + } + + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + hParamMC->num_outputs_diff = 0; + hParamMC->diff_proto_info = NULL; + hParamMC->h_output_synthesis_params.use_onset_filters = 0; + hParamMC->max_band_decorr = 0; + hParamMC->h_freq_domain_decorr_ap_params = NULL; + hParamMC->h_freq_domain_decorr_ap_state = NULL; + } + else + { + hParamMC->num_outputs_diff = nchan_out_cov; + if ( ( hParamMC->diff_proto_info = (PARAM_MC_DIFF_PROTO_INFO *) malloc( sizeof( PARAM_MC_DIFF_PROTO_INFO ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + + if ( ( error = param_mc_get_diff_proto_info_fx( proto_matrix_fx, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info ,Q26) ) != IVAS_ERR_OK ) + { + return error; + } + + /* decorrelation */ + hParamMC->h_freq_domain_decorr_ap_params = NULL; + hParamMC->h_freq_domain_decorr_ap_state = NULL; + + ivas_dirac_dec_get_frequency_axis_fx( frequency_axis_fx, output_Fs, hParamMC->num_freq_bands ); + + IF( ( error = ivas_dirac_dec_decorr_open_fx( &( hParamMC->h_freq_domain_decorr_ap_params ), &( hParamMC->h_freq_domain_decorr_ap_state ), hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, + DIRAC_SYNTHESIS_COV_MC_LS, frequency_axis_fx, nchan_transport, output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + + hParamMC->h_output_synthesis_params.use_onset_filters = 0; + hParamMC->max_band_decorr = hParamMC->h_freq_domain_decorr_ap_params->max_band_decorr; + } + hParamMC->max_band_energy_compensation = hParamMC->band_grouping[hParamMC->hMetadataPMC->nbands_coded]; + max_param_band_residual = 0; + + for ( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- ) + { + if ( hParamMC->band_grouping[k] <= hParamMC->max_band_decorr ) + { + max_param_band_residual = k; + assert( hParamMC->band_grouping[k] == hParamMC->max_band_decorr ); + break; + } + } + + /* output synthesis */ + if ( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ) != IVAS_ERR_OK ) + { + return error; + } + + ivas_param_mc_dec_compute_interpolator_fx( 0, 0, DEFAULT_JBM_CLDFB_TIMESLOTS, hParamMC->h_output_synthesis_params.interpolator_fx ); + + /* Head or external rotation */ + if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) ) + { +#if 1/*TODO : To be removed later*/ + IF ( ( hParamMC->hoa_encoder = (float *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } +#endif + IF ( ( hParamMC->hoa_encoder_fx = (Word32 *) malloc( st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof(Word32) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + compute_hoa_encoder_mtx_fx( st_ivas->hTransSetup.ls_azimuth_fx, st_ivas->hTransSetup.ls_elevation_fx, hParamMC->hoa_encoder_fx, st_ivas->hTransSetup.nchan_out_woLFE, HEAD_ROTATION_HOA_ORDER ); + } + + /*-----------------------------------------------------------------* + * memory allocation + *-----------------------------------------------------------------*/ + + IF ( GT_16(hParamMC->max_band_decorr , 0) ) + { +#if 1/*TODO: To be removed later(floating point malloc)*/ + IF ( ( hParamMC->proto_frame_f = (float *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + IF ( ( hParamMC->proto_frame_dec_f = (float *) malloc( 2 * nchan_out_cov * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } +#endif + IF ( ( hParamMC->proto_frame_f_fx = (Word32 *) malloc( 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + IF ( ( hParamMC->proto_frame_dec_f_fx = (Word32 *) malloc( 2 * nchan_out_cov * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); + } + } + ELSE + { +#if 1/*TODO: To be removed later*/ + hParamMC->proto_frame_f = NULL; + hParamMC->proto_frame_dec_f = NULL; +#endif + hParamMC->proto_frame_f_fx = NULL; + hParamMC->proto_frame_dec_f_fx = NULL; + } + + ivas_param_mc_dec_init_fx( hParamMC, nchan_transport, nchan_out_cov ); + + IF ( hParamMC->synthesis_conf != PARAM_MC_SYNTH_MONO_STEREO ) + { + Word16 n_cldfb_slots; + + n_cldfb_slots = DEFAULT_JBM_CLDFB_TIMESLOTS; + IF ( st_ivas->hDecoderConfig->Opt_tsm ) + { + n_cldfb_slots = MAX_JBM_CLDFB_TIMESLOTS; + } + + IF( ( hParamMC->Cldfb_RealBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } + set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( Word32 ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } + set32_fx( hParamMC->Cldfb_ImagBuffer_tc_fx, 0, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + +#if 1/*TODO: To be removed later(floating point malloc)*/ + if ( ( hParamMC->Cldfb_RealBuffer_tc = (float *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } + set_zero( hParamMC->Cldfb_RealBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); + if ( ( hParamMC->Cldfb_ImagBuffer_tc = (float *) malloc( n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands * sizeof( float ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); + } + set_zero( hParamMC->Cldfb_ImagBuffer_tc, n_cldfb_slots * nchan_transport * hParamMC->num_freq_bands ); +#endif -#ifdef IVAS_FLOAT_FIXED -static void ivas_param_mc_bs_decode_parameter_values_fx(UWord16 bit_buffer[], Word16 *bit_pos, const Word16 max_bits, Word16 *BER_detect, HANDLE_IVAS_PARAM_MC_METADATA hMetadataPMC, HANDLE_PARAM_MC_PARAMETER_CODING_INFO hParamCodingInfo, const Word16 map_size_wo_lfe, const Word16 map_size, const Word16 num_lfe_bands, const Word16 band_step, const Word16 num_param_bands, Word16 *value_buffer); -static void ivas_param_mc_dequantize_cov_fx(PARAM_MC_DEC_HANDLE hParamMC, Word16 *ild_q_fx, Word16 *icc_q_fx, const Word16 param_band_index, const Word16 nY_cov, const PARAM_MC_SYNTHESIS_CONF synth_conf, const Word16 nY_int, const Word16 nX, Word32 *Cx_state_fx, Word16 Cx_state_e, Word32 *Cproto_fx, Word16 Cproto_e, Word32 *Cy_state_fx, Word16 *Cy_state_e); -static ivas_error param_mc_get_diff_proto_info_fx(const Word32 *proto_mtx, const UWord16 nchan_transport, const UWord16 nchan_out_cov, PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info); -static void param_mc_update_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, Word32 *mixing_matrix[], Word16 *mixing_matrix_fx, Word32 *mixing_matrix_res[], Word16 *mixing_matrix_res_exp, const UWord16 nX, const UWord16 nY ); + IF ( st_ivas->hTcBuffer == NULL ) + { + IF ( ( error = ivas_jbm_dec_tc_buffer_open_fx( st_ivas, TC_BUFFER_MODE_RENDERER, nchan_transport, nchan_transport, 0, NS2SA( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + ELSE + { + hParamMC->Cldfb_RealBuffer_tc_fx = NULL; + hParamMC->Cldfb_ImagBuffer_tc_fx = NULL; +#if 1/*TODO: To be removed later*/ + hParamMC->Cldfb_RealBuffer_tc = NULL; + hParamMC->Cldfb_ImagBuffer_tc = NULL; #endif + } -/*------------------------------------------------------------------------- - * ivas_param_mc_dec_open() - * - * Open Parametric MC decoder handle - *-------------------------------------------------------------------------*/ + hParamMC->subframes_rendered = 0; + hParamMC->slots_rendered = 0; + st_ivas->hParamMC = hParamMC; + return error; +} +#else ivas_error ivas_param_mc_dec_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -220,9 +666,9 @@ ivas_error ivas_param_mc_dec_open( hParamMC->synthesis_conf = PARAM_MC_SYNTH_LS_CONV_CLDFB; } } - +#ifndef IVAS_FLOAT_FIXED hParamMC->ls_conv_dmx_matrix = NULL; -#ifdef IVAS_FLOAT_FIXED +#else hParamMC->ls_conv_dmx_matrix_fx = NULL; #endif // IVAS_FLOAT_FIXED @@ -346,12 +792,13 @@ ivas_error ivas_param_mc_dec_open( /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) { +#ifndef IVAS_FLOAT_FIXED if ( ( hParamMC->ls_conv_dmx_matrix = (float *) malloc( nchan_out_transport * nchan_out_cov * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } -#ifdef IVAS_FLOAT_FIXED - IF ( ( hParamMC->ls_conv_dmx_matrix_fx = (Word32 *) malloc( nchan_out_transport * nchan_out_cov * sizeof( Word32 ) ) ) == NULL ) +#else + IF ( ( hParamMC->ls_conv_dmx_matrix_fx = (Word32 *) malloc( nchan_out_transport * nchan_out_cov * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } @@ -359,7 +806,14 @@ ivas_error ivas_param_mc_dec_open( for ( k = 0; k < nchan_out_transport; k++ ) { +#ifdef IVAS_FLOAT_FIXED +#if 1 //To be removed when hParamMC->ls_conv_dmx_matrix is removed + +#endif + Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov], nchan_out_cov ); +#else mvr2r( st_ivas->hLsSetUpConversion->dmxMtx[k], &hParamMC->ls_conv_dmx_matrix[k * nchan_out_cov], nchan_out_cov ); +#endif } /* convert ParamMC parameter bands to SFB */ @@ -492,12 +946,12 @@ ivas_error ivas_param_mc_dec_open( /* output synthesis */ #ifdef IVAS_FLOAT_FIXED - floatToFixed_arrL( proto_matrix, proto_matrix_fx, Q30, nchan_out_transport * nchan_transport); + floatToFixed_arrL( proto_matrix, proto_matrix_fx, Q26, MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS ); if ( ( error = ivas_dirac_dec_output_synthesis_cov_open_fx( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix_fx ) ) != IVAS_ERR_OK ) { return error; } - fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 30, nchan_transport * nchan_out_cov ); + fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, Q26, nchan_transport * nchan_out_cov ); #else if ( ( error = ivas_dirac_dec_output_synthesis_cov_open( &( hParamMC->h_output_synthesis_params ), &( hParamMC->h_output_synthesis_cov_state ), hParamMC->max_band_decorr, PARAM_MC_MAX_NSLOTS, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual, nchan_transport, nchan_out_cov, proto_matrix ) ) != IVAS_ERR_OK ) @@ -613,7 +1067,7 @@ ivas_error ivas_param_mc_dec_open( return error; } - +#endif /*------------------------------------------------------------------------- * ivas_param_mc_get_param_band_mapping() @@ -952,11 +1406,11 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } /* convert the ls conv dmx matrix into column order matrix format (nchan_out_cldfb x nchan_out) */ -#if 1/*To be removed later*/ +#if 0/*To be removed later*/ free( hParamMC->ls_conv_dmx_matrix ); #endif free( hParamMC->ls_conv_dmx_matrix_fx ); -#if 1 +#if 0 IF ( ( hParamMC->ls_conv_dmx_matrix = (float *) malloc( nchan_out_transport * nchan_out_cov * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); @@ -969,7 +1423,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( FOR ( k = 0; k < nchan_out_transport; k++ ) { Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov], nchan_out_cov ); - Scale_sig32( &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov],nchan_out_cov,1 ); } } /* convert ParamMC parameter bands to SFB */ @@ -1004,26 +1457,27 @@ ivas_error ivas_param_mc_dec_reconfig_fx( IF ( EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_LS_CONV_COV) || EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_MONO_STEREO) ) { + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, -4 ); matrix_product_fx( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_cov, nchan_out_transport, 0, ivas_param_mc_conf[config_index].dmx_fac_fx, nchan_out_transport, nchan_transport, 0, - proto_matrix_fx ); + proto_matrix_fx /*Q26*/); + Scale_sig32( hParamMC->ls_conv_dmx_matrix_fx, nchan_out_transport * nchan_out_cov, 4 ); IF ( EQ_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_MONO_STEREO) ) { - proto_mtx_norm_fx = MAX_32; + proto_mtx_norm_fx = ONE_IN_Q26; FOR ( k = 0; k < nchan_transport * nchan_out_cov; k++ ) { proto_mtx_norm_fx = L_max(L_abs( proto_mtx_norm_fx ), L_abs( proto_matrix_fx[k] ) ); } - proto_mtx_norm_fx = divide3232(1 , proto_mtx_norm_fx);/*Q15*/ + proto_mtx_norm_fx = divide3232(ONE_IN_Q26 , proto_mtx_norm_fx);/*Q15*/ /* transfer flattened proto_matrix to 2D in hLsSetupConversion->dmxMtx */ FOR ( k = 0; k < nchan_transport; k++ ) { FOR ( Word16 i = 0; i < nchan_out_cov; i++ ) { - st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shr(Mpy_32_16_1(proto_matrix_fx[k * nchan_out_cov + i] , (Word16)proto_mtx_norm_fx),1); - st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); + st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i] = L_shl(Mpy_32_16_1(proto_matrix_fx[k * nchan_out_cov + i] , (Word16)proto_mtx_norm_fx),4); } } } @@ -1031,6 +1485,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( ELSE { Copy32( ivas_param_mc_conf[config_index].dmx_fac_fx, proto_matrix_fx, nchan_out_transport * nchan_transport ); + Scale_sig32( proto_matrix_fx, nchan_out_transport * nchan_transport, -5 ); } IF ( NE_16(nchan_transport_old , nchan_transport) && NE_16(hParamMC->synthesis_conf , PARAM_MC_SYNTH_MONO_STEREO) ) @@ -1084,7 +1539,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC\n" ) ); } - IF ( ( param_mc_get_diff_proto_info_fx( proto_matrix_fx, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info ) ) != IVAS_ERR_OK ) + IF ( ( param_mc_get_diff_proto_info_fx( proto_matrix_fx, nchan_transport, nchan_out_cov, hParamMC->diff_proto_info ,Q26) ) != IVAS_ERR_OK ) { return error; } @@ -1293,7 +1748,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } return error; } -#endif // IVAS_FLOAT_FIXED +#else // IVAS_FLOAT_FIXED ivas_error ivas_param_mc_dec_reconfig( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -1810,7 +2265,7 @@ ivas_error ivas_param_mc_dec_reconfig( } return error; } - +#endif /*------------------------------------------------------------------------- * param_mc_get_num_cldfb_syntheses() @@ -1855,7 +2310,173 @@ int16_t param_mc_get_num_cldfb_syntheses( * * Close Parametric MC memories *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +void ivas_param_mc_dec_close_fx( + PARAM_MC_DEC_HANDLE *hParamMC_out /* i/o: Parametric MC decoder handle */ +) +{ + UWord16 i; + PARAM_MC_DEC_HANDLE hParamMC; + + IF( hParamMC_out == NULL || *hParamMC_out == NULL ) + { + return; + } + + hParamMC = *hParamMC_out; + + /* close sub-modules */ + ivas_dirac_dec_output_synthesis_cov_close_fx( &hParamMC->h_output_synthesis_params, &hParamMC->h_output_synthesis_cov_state ); + + IF( hParamMC->h_freq_domain_decorr_ap_params != NULL || hParamMC->h_freq_domain_decorr_ap_state != NULL ) + { + ivas_dirac_dec_decorr_close( &hParamMC->h_freq_domain_decorr_ap_params, &hParamMC->h_freq_domain_decorr_ap_state ); + } + + /* parameter decoding */ + IF( hParamMC->hMetadataPMC != NULL ) + { +#ifndef FIX_901_PARAMMC_DEAD_CODE + ivas_param_mc_metadata_close( hParamMC->hMetadataPMC ); +#endif + free( hParamMC->hMetadataPMC ); + hParamMC->hMetadataPMC = NULL; + } + IF( hParamMC->icc_q_fx != NULL ) + { + free( hParamMC->icc_q_fx ); + hParamMC->icc_q_fx = NULL; + } + + IF( hParamMC->icld_q_fx != NULL ) + { + free( hParamMC->icld_q_fx ); + hParamMC->icld_q_fx = NULL; + } + /* diffuse prototype info */ + IF( hParamMC->diff_proto_info ) + { + FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + free( hParamMC->diff_proto_info->source_chan_idx[i] ); + hParamMC->diff_proto_info->source_chan_idx[i] = NULL; + + free( hParamMC->diff_proto_info->proto_fac_fx[i] ); + hParamMC->diff_proto_info->proto_fac_fx[i] = NULL; + } + + free( hParamMC->diff_proto_info->source_chan_idx ); + hParamMC->diff_proto_info->source_chan_idx = NULL; + + free( hParamMC->diff_proto_info->proto_fac_fx ); + hParamMC->diff_proto_info->proto_fac_fx = NULL; + + free( hParamMC->diff_proto_info->proto_index_diff ); + hParamMC->diff_proto_info->proto_index_diff = NULL; + + free( hParamMC->diff_proto_info->num_source_chan_diff ); + hParamMC->diff_proto_info->num_source_chan_diff = NULL; + + free( hParamMC->diff_proto_info ); + hParamMC->diff_proto_info = NULL; + } + /* States */ + /* free prototype signal buffers */ + IF( hParamMC->proto_frame_f_fx != NULL ) + { + free( hParamMC->proto_frame_f_fx ); + hParamMC->proto_frame_f_fx = NULL; + } + + IF( hParamMC->proto_frame_dec_f_fx != NULL ) + { + free( hParamMC->proto_frame_dec_f_fx); + hParamMC->proto_frame_dec_f_fx = NULL; + } + IF( hParamMC->ls_conv_dmx_matrix_fx != NULL ) + { + free( hParamMC->ls_conv_dmx_matrix_fx ); + hParamMC->ls_conv_dmx_matrix_fx = NULL; + } + + IF( hParamMC->proto_matrix_int_fx != NULL ) + { + free( hParamMC->proto_matrix_int_fx ); + hParamMC->proto_matrix_int_fx = NULL; + } + + IF( hParamMC->hoa_encoder_fx != NULL ) + { + free( hParamMC->hoa_encoder_fx ); + hParamMC->hoa_encoder_fx = NULL; + } + IF( hParamMC->Cldfb_RealBuffer_tc_fx != NULL ) + { + free( hParamMC->Cldfb_RealBuffer_tc_fx ); + hParamMC->Cldfb_RealBuffer_tc_fx = NULL; + } + IF( hParamMC->Cldfb_ImagBuffer_tc_fx != NULL ) + { + free( hParamMC->Cldfb_ImagBuffer_tc_fx ); + hParamMC->Cldfb_ImagBuffer_tc_fx = NULL; + } +#if 1 /*TODO: To be removed later(Floating point memory dealloc)------------------------------- */ + + IF( hParamMC->icc_q != NULL ) + { + free( hParamMC->icc_q ); + hParamMC->icc_q = NULL; + } + + IF( hParamMC->icld_q != NULL ) + { + free( hParamMC->icld_q ); + hParamMC->icld_q = NULL; + } + IF( hParamMC->diff_proto_info ) + { + FOR( i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + free( hParamMC->diff_proto_info->proto_fac[i] ); + hParamMC->diff_proto_info->proto_fac[i] = NULL; + } + free( hParamMC->diff_proto_info->proto_fac ); + hParamMC->diff_proto_info->proto_fac = NULL; + } + IF( hParamMC->proto_frame_f != NULL ) + { + free( hParamMC->proto_frame_f ); + hParamMC->proto_frame_f = NULL; + } + IF( hParamMC->proto_frame_dec_f != NULL ) + { + free( hParamMC->proto_frame_dec_f ); + hParamMC->proto_frame_dec_f = NULL; + } + //IF( hParamMC->ls_conv_dmx_matrix != NULL ) + //{ + // free( hParamMC->ls_conv_dmx_matrix ); + // hParamMC->ls_conv_dmx_matrix = NULL; + //} + IF( hParamMC->Cldfb_RealBuffer_tc != NULL ) + { + free( hParamMC->Cldfb_RealBuffer_tc ); + hParamMC->Cldfb_RealBuffer_tc = NULL; + } + IF( hParamMC->Cldfb_ImagBuffer_tc != NULL ) + { + free( hParamMC->Cldfb_ImagBuffer_tc ); + hParamMC->Cldfb_ImagBuffer_tc = NULL; + } +#endif /***********************************ends here************************************************/ + + free( *hParamMC_out ); + *hParamMC_out = NULL; + + return; +} +#endif void ivas_param_mc_dec_close( PARAM_MC_DEC_HANDLE *hParamMC_out /* i/o: Parametric MC decoder handle */ ) @@ -1958,13 +2579,13 @@ void ivas_param_mc_dec_close( free( hParamMC->proto_frame_dec_f ); hParamMC->proto_frame_dec_f = NULL; } - +#ifndef IVAS_FLOAT_FIXED if ( hParamMC->ls_conv_dmx_matrix != NULL ) { free( hParamMC->ls_conv_dmx_matrix ); hParamMC->ls_conv_dmx_matrix = NULL; } -#ifdef IVAS_FLOAT_FIXED +#else if ( hParamMC->ls_conv_dmx_matrix_fx != NULL ) { free( hParamMC->ls_conv_dmx_matrix_fx ); @@ -2008,7 +2629,6 @@ void ivas_param_mc_dec_close( return; } - /*------------------------------------------------------------------------- * ivas_param_mc_dec_read_BS() * @@ -2469,7 +3089,7 @@ void ivas_param_mc_dec_digest_tc_fx( return; } -#endif +#else void ivas_param_mc_dec_digest_tc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ @@ -2703,7 +3323,7 @@ void ivas_param_mc_dec_digest_tc( return; } - +#endif /*------------------------------------------------------------------------- * ivas_param_mc_dec() @@ -2897,10 +3517,6 @@ void ivas_param_mc_dec_render( { #ifdef IVAS_FLOAT_FIXED #if 1 - IF( ( hParamMC->hoa_encoder_fx = (Word32 *) malloc(st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS * sizeof( Word32 ) ) ) == NULL ) - { - assert( 0 ); - } Word16 Q_hoa_encoder = 31; floatToFixed_arrL(hParamMC->hoa_encoder, hParamMC->hoa_encoder_fx, Q_hoa_encoder, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); @@ -2915,10 +3531,6 @@ void ivas_param_mc_dec_render( fixedToFloat_arrL( &Cldfb_ImagBuffer_fx[0][0][0], &Cldfb_ImagBuffer[0][0][0], Q_Cldfb_ImagBuffer, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); fixedToFloat_arrL( &Cldfb_RealBuffer_fx[0][0][0], &Cldfb_RealBuffer[0][0][0], Q_Cldfb_RealBuffer, 16 * MAX_PARAM_SPATIAL_SUBFRAMES * CLDFB_NO_CHANNELS_MAX ); - IF(hParamMC->hoa_encoder_fx) - { - free(hParamMC->hoa_encoder_fx); - } #endif // IVAS_FLOAT_FIXED #else ivas_param_mc_mc2sba_cldfb( st_ivas->hTransSetup, hParamMC->hoa_encoder, slot_idx, Cldfb_RealBuffer, Cldfb_ImagBuffer, nband_synth, GAIN_LFE ); @@ -3507,7 +4119,7 @@ void ivas_param_mc_dec_render( * * Parametric MC decoding process *------------------------------------------------------------------------*/ - +#if 0 //NO Calling location void ivas_param_mc_dec( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ float *output_f[] /* i/o: synthesized core-coder transport channels/DirAC output */ @@ -3541,14 +4153,72 @@ void ivas_param_mc_dec( pop_wmops(); return; } - +#endif /*------------------------------------------------------------------------- * param_mc_dec_init() * * Parametric MC decoding initialization *------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static void ivas_param_mc_dec_init_fx( + PARAM_MC_DEC_HANDLE hParamMC, /* i/o: decoder DirAC handle */ + const Word16 nchan_transport, /* i : number of input (transport) channels */ + const Word16 nchan_cov ) /* i : number of cov synthesis channels */ +{ + Word16 k; + UWord16 max_param_band_residual; + Word16 len; + + /*-----------------------------------------------------------------* + * init sub-modules + *-----------------------------------------------------------------*/ + + /* decorrelation */ + IF ( GT_16(hParamMC->max_band_decorr , 0) ) + { + len = hParamMC->diff_proto_info->num_protos_diff * hParamMC->h_freq_domain_decorr_ap_params->h_onset_detection_power_params.max_band_decorr; + + /* init onsetDetectionPower */ + set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1_fx, len ); + set_zero_fx( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2_fx, len ); +#if 1/*Floating point intialization: to be removed later*/ + set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_1, len ); + set_zero( hParamMC->h_freq_domain_decorr_ap_state->h_onset_detection_power_state.onset_detector_2, len ); +#endif + } + + max_param_band_residual = 0; + + /* output synthesis */ + FOR ( k = hParamMC->hMetadataPMC->num_parameter_bands; k >= 0; k-- ) + { + IF ( LE_16(hParamMC->band_grouping[k] , hParamMC->max_band_decorr) ) + { + max_param_band_residual = k; + break; + } + } + + ivas_dirac_dec_output_synthesis_cov_init_fx( &( hParamMC->h_output_synthesis_cov_state ), nchan_transport, nchan_cov, hParamMC->hMetadataPMC->num_parameter_bands, max_param_band_residual ); + + /*-----------------------------------------------------------------* + * init proto frames + *-----------------------------------------------------------------*/ + + IF ( GT_16(hParamMC->max_band_decorr , 0) ) + { +#if 1/*TODO: To be removed later*/ + set_zero( hParamMC->proto_frame_f, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); + set_zero( hParamMC->proto_frame_dec_f, 2 * nchan_cov * hParamMC->num_freq_bands ); +#endif + set_zero_fx( hParamMC->proto_frame_f_fx, 2 * hParamMC->diff_proto_info->num_protos_diff * hParamMC->num_freq_bands ); + set32_fx( hParamMC->proto_frame_dec_f_fx, 0, 2 * nchan_cov * hParamMC->num_freq_bands ); + } + return; +} +#endif // IVAS_FLOAT_FIXED static void ivas_param_mc_dec_init( PARAM_MC_DEC_HANDLE hParamMC, /* i/o: decoder DirAC handle */ const int16_t nchan_transport, /* i : number of input (transport) channels */ @@ -4167,10 +4837,10 @@ static void ivas_param_mc_get_mixing_matrices( set32_fx( Cy_state_fx, 0, matSize ); Cy_state_e = 0; - if ( synth_config == PARAM_MC_SYNTH_LS_CONV_COV ) - { - f2me_buf( hParamMC->ls_conv_dmx_matrix, hParamMC->ls_conv_dmx_matrix_fx, &hParamMC->ls_conv_dmx_e, nY_cov * nY_intern ); - } + //if ( synth_config == PARAM_MC_SYNTH_LS_CONV_COV ) + //{ + // f2me_buf( hParamMC->ls_conv_dmx_matrix, hParamMC->ls_conv_dmx_matrix_fx, &hParamMC->ls_conv_dmx_e, nY_cov * nY_intern ); + //} floatToFixed_arr( hParamMC->icld_q, icld_q_fx, 8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); for ( int lp = 0; lp < hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe; lp++ ) @@ -4806,7 +5476,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( return; } -#endif +#else @@ -4980,7 +5650,7 @@ static void ivas_param_mc_get_mono_stereo_mixing_matrices( return; } - +#endif /*------------------------------------------------------------------------- * param_mc_update_mixing_matrices() * @@ -5053,7 +5723,7 @@ static void param_mc_update_mixing_matrices_fx( * * generate the target covariance matrix *------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED static void ivas_param_mc_dequantize_cov( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ float *ild_q, /* i : sequence of dequantized ILD values */ @@ -5216,7 +5886,7 @@ static void ivas_param_mc_dequantize_cov( return; } -#ifdef IVAS_FLOAT_FIXED +#else /*------------------------------------------------------------------------- * ivas_param_mc_dequantize_cov_fx() @@ -5447,7 +6117,7 @@ static void ivas_param_mc_dequantize_cov_fx( set32_fx( target_ch_ener_fx, 0, MAX_CICP_CHANNELS ); set16_fx( target_ch_ener_e, 0, MAX_CICP_CHANNELS ); set32_fx( dmx_ch_ener_fx, 0, MAX_CICP_CHANNELS ); - set16_fx( ls_conv_dmx_matrix_e, hParamMC->ls_conv_dmx_e, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); + set16_fx( ls_conv_dmx_matrix_e, 1, MAX_OUTPUT_CHANNELS * MAX_OUTPUT_CHANNELS ); matrix_product_mant_exp( hParamMC->ls_conv_dmx_matrix_fx, ls_conv_dmx_matrix_e, nY_cov, nY_int, 0, Cy_state_int_fx, Cy_state_int_e, nY_int, nY_int, 0, @@ -5658,8 +6328,8 @@ static ivas_error param_mc_get_diff_proto_info_fx( const Word32 *proto_mtx, /* i : protoype matrix for the synthesis */ const UWord16 nchan_transport, /* i : number of transport channels */ const UWord16 nchan_out_cov, /* i : number if output channels of the covariance synthesis */ - PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info /* o : generated diffuse prototype info */ -) + PARAM_MC_DIFF_PROTO_INFO *p_diff_proto_info, /* o : generated diffuse prototype info */ + Word16 Q_proto_mtx ) { #if FLT_ENABLE float proto_fac[MAX_CICP_CHANNELS * PARAM_MC_MAX_TRANSPORT_CHANS]; @@ -5727,7 +6397,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( #if FLT_ENABLE if ( diff < 0.1f ) #else - if ( LT_64( diff_fx * 10, 2147483648 ) ) + if ( LT_64( diff_fx * 10, L_shl_sat(1, Q_proto_mtx)) ) #endif { found = 1; diff --git a/lib_dec/ivas_mct_dec.c b/lib_dec/ivas_mct_dec.c index 390fc1ae4..9f79b6a6f 100644 --- a/lib_dec/ivas_mct_dec.c +++ b/lib_dec/ivas_mct_dec.c @@ -1352,26 +1352,848 @@ ivas_error ivas_mc_dec_config( { if ( st_ivas->hDecoderConfig->last_ivas_total_brate != st_ivas->hDecoderConfig->ivas_total_brate || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode ) { +#ifdef IVAS_FLOAT_FIXED +#if 1 /*TODO: To be removed(Float to fixed conversion)*/ + DECODER_TC_BUFFER_HANDLE hTcBuffer; + hTcBuffer = st_ivas->hTcBuffer; + RENDERER_TYPE renderer_type_old; + renderer_type_old = st_ivas->renderer_type; + IF( st_ivas->hCombinedOrientationData ) + FOR( Word16 ind1 = 0; ind1 < 3; ind1++ ) + { + FOR( Word16 ind2 = 0; ind2 < 3; ind2++ ) + { + st_ivas->hCombinedOrientationData->Rmat_fx[0][ind1][ind2] = (Word32) ( st_ivas->hCombinedOrientationData->Rmat[0][ind1][ind2] * ( 1 << 15 ) ); + } + } + SPAR_DEC_HANDLE hSpar; + hSpar = st_ivas->hSpar; + Word16 nchan_transport_old = st_ivas->nchan_transport; + uint16_t nchan_internal; + Word32 ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + DECODER_CONFIG_HANDLE hDecoderConfig; + hDecoderConfig = st_ivas->hDecoderConfig; + + Word16 n_tc; + n_tc = st_ivas->hTcBuffer->nchan_transport_internal; + for ( int ch = 0; ch < n_tc; ch++ ) + { + floatToFixed_arrL( st_ivas->hTcBuffer->tc[ch], st_ivas->hTcBuffer->tc_fx[ch], Q11, L_FRAME48k ); + } + Word16 cx_e = 0, cy_e = 0, mmo_e = 0, mmro_e = 0; + PARAM_MC_DEC_HANDLE hParamMC; + hParamMC = st_ivas->hParamMC; + Word16 nchan_out_transport, nchan_out_cov; + MC_LS_SETUP mc_ls_setup; + Word16 nchan_transport; + if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); + nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + if ( st_ivas->hParamMC ) + { + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + } + else + { + nchan_out_cov = nchan_out_transport; + } + floatToFixed_arr( hParamMC->icc_q, hParamMC->icc_q_fx, Q15, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); + floatToFixed_arr( hParamMC->icld_q, hParamMC->icld_q_fx, Q8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); + Word32 max_cx_old_fx, max_cy_old_fx, max_mix_matrix_old_fx, max_mix_matrix_res_old_fx; + float max_cx_old = hParamMC->h_output_synthesis_cov_state.cx_old[0][0], max_cy_old = hParamMC->h_output_synthesis_cov_state.cy_old[0][0], max_mix_matrix_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[0][0], max_mix_matrix_res_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[0][0]; + for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) + { + if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) + { + for ( int j = 0; j < nchan_transport_old * nchan_transport_old; j++ ) + max_cx_old = max( max_cx_old, hParamMC->h_output_synthesis_cov_state.cx_old[i][j] ); + for ( int j = 0; j < nchan_out_cov * nchan_out_cov; j++ ) + max_cy_old = max( max_cy_old, hParamMC->h_output_synthesis_cov_state.cy_old[i][j] ); + for ( int j = 0; j < nchan_transport_old * nchan_out_cov; j++ ) + max_mix_matrix_old = max( max_mix_matrix_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i][j] ); + } + } + /*IF(st_ivas->hParamMC->ls_conv_dmx_matrix_fx ) + floatToFixed_arr32( st_ivas->hParamMC->ls_conv_dmx_matrix, st_ivas->hParamMC->ls_conv_dmx_matrix_fx, Q30, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) );*/ + for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) + { + for ( int j = 0; j < nchan_out_cov * nchan_out_cov; j++ ) + max_mix_matrix_res_old = max( max_mix_matrix_res_old, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i][j] ); + } + } + f2me( max_cx_old, &max_cx_old_fx, &cx_e ); + f2me( max_cy_old, &max_cy_old_fx, &cy_e ); + f2me( max_mix_matrix_old, &max_mix_matrix_old_fx, &mmo_e ); + f2me( max_mix_matrix_res_old, &max_mix_matrix_res_old_fx, &mmro_e ); + if ( mmo_e < 0 ) + mmo_e = 0; + if ( mmro_e < 0 ) + mmro_e = 0; + for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) + { + if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) + { + + floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.cx_old[i], hParamMC->h_output_synthesis_cov_state.cx_old_fx[i], 31 - cx_e, nchan_transport_old * nchan_transport_old ); + floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.cy_old[i], hParamMC->h_output_synthesis_cov_state.cy_old_fx[i], 31 - cy_e, nchan_out_cov * nchan_out_cov ); + floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); + } + } + for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) + { + floatToFixed_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[i], 31 - mmro_e, nchan_out_cov * nchan_out_cov ); + } + } + floatToFixed_arrL( hParamMC->proto_matrix_int, hParamMC->proto_matrix_int_fx, Q31, nchan_out_transport * nchan_transport ); + FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + if ( hParamMC->diff_proto_info ) + floatToFixed_arrL( hParamMC->diff_proto_info->proto_fac[i], hParamMC->diff_proto_info->proto_fac_fx[i], Q26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); + } + } + } + if ( st_ivas->hRenderConfig ) + FOR( Word16 i = 0; i < 4; i++ ) + { + st_ivas->hRenderConfig->directivity_fx[i * 3] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3], 6 ); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 1] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 1], 6 ); + st_ivas->hRenderConfig->directivity_fx[i * 3 + 2] = (Word16) floatToFixed( st_ivas->hRenderConfig->directivity[i * 3 + 2], 15 ); + } +#endif + if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1 + if ( st_ivas->mc_mode == MC_MODE_PARAMMC ) + { + hParamMC = st_ivas->hParamMC; + mc_ls_setup = ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ); + st_ivas->nchan_transport = ivas_param_mc_getNumTransportChannels( ivas_total_brate, mc_ls_setup ); + nchan_transport = st_ivas->nchan_transport; + nchan_out_transport = st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe; + if ( hParamMC->synthesis_conf == PARAM_MC_SYNTH_LS_CONV_COV || hParamMC->synthesis_conf == PARAM_MC_SYNTH_MONO_STEREO ) + { + nchan_out_cov = st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; + } + else + { + nchan_out_cov = nchan_out_transport; + } + if ( hParamMC ) + { + //if ( st_ivas->hLsSetUpConversion ) + //{ + // for ( Word16 k = 0; k < nchan_transport; k++ ) + // { + // for ( int16_t i = 0; i < nchan_out_cov; i++ ) + // { + // st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); + // } + // } + //} + fixedToFloat_arr( hParamMC->icc_q_fx, hParamMC->icc_q, Q15, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); + fixedToFloat_arr( hParamMC->icld_q_fx, hParamMC->icld_q, Q8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); + fixedToFloat_arrL( hParamMC->h_output_synthesis_params.proto_matrix_fx, hParamMC->h_output_synthesis_params.proto_matrix, 26, nchan_transport * nchan_out_cov ); + IF( hParamMC->diff_proto_info ) + FOR( Word16 i = 0; i < hParamMC->diff_proto_info->num_protos_diff; i++ ) + { + fixedToFloat_arrL( hParamMC->diff_proto_info->proto_fac_fx[i], hParamMC->diff_proto_info->proto_fac[i], 26, hParamMC->diff_proto_info->num_source_chan_diff[i] ); + } + fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, nchan_out_transport * nchan_transport ); + /*IF(st_ivas->hParamMC->ls_conv_dmx_matrix_fx ) + fixedToFloat_arrL( st_ivas->hParamMC->ls_conv_dmx_matrix_fx, st_ivas->hParamMC->ls_conv_dmx_matrix, Q30, st_ivas->hDecoderConfig->nchan_out * ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) );*/ + if ( last_mc_mode == MC_MODE_PARAMMC ) + { + for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) + { + if ( hParamMC->h_output_synthesis_cov_state.cx_old[i] ) + { + fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.cx_old_fx[i], hParamMC->h_output_synthesis_cov_state.cx_old[i], 31 - cx_e, nchan_transport_old * nchan_transport_old ); + fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.cy_old_fx[i], hParamMC->h_output_synthesis_cov_state.cy_old[i], 31 - cy_e, nchan_out_cov * nchan_out_cov ); + fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[i], 31 - mmo_e, nchan_transport_old * nchan_out_cov ); + } + } + for ( int i = 0; i < CLDFB_NO_CHANNELS_MAX; i++ ) + { + if ( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i] ) + { + fixedToFloat_arrL( hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old_fx[i], hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[i], 31 - mmro_e, nchan_out_cov * nchan_out_cov ); + } + } + } + if ( hParamMC->hoa_encoder_fx ) + fixedToFloat_arrL( hParamMC->hoa_encoder_fx, hParamMC->hoa_encoder, Q29, st_ivas->hTransSetup.nchan_out_woLFE * MAX_INTERN_CHANNELS ); + } + } +#endif +#else if ( ( error = ivas_mc_dec_reconfig( st_ivas, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif // IVAS_FLOAT_FIXED + } + } + + st_ivas->transport_config = signaled_config; + } + + return IVAS_ERR_OK; +} + + +/*------------------------------------------------------------------------- + * ivas_mc_dec_reconfig() + * + * reconfigure the MC format decoder + *-------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +static ivas_error ivas_mc_dec_reconfig( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */ + Word16 *data /* o : output synthesis signal */ +) +{ + Word16 nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old; + Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; + Word32 new_brate_SCE, new_brate_CPE, ivas_total_brate; + RENDERER_TYPE renderer_type_old; + Decoder_State *st; + ivas_error error; + MC_MODE mc_mode, last_mc_mode; + TC_BUFFER_MODE tc_buffer_mode_new; + Word16 tc_nchan_tc_new; + Word16 tc_nchan_allocate_new; + Word16 tc_granularity_new; + AUDIO_CONFIG intern_config_old; + IVAS_OUTPUT_SETUP hIntSetupOld; + Word16 nchan_out_buff_old, nchan_out_buff; + + error = IVAS_ERR_OK; + ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; + nchan_transport_old = st_ivas->nchan_transport; + nchan_out_buff_old = ivas_get_nchan_buffers_dec( st_ivas, -1, -1 ); + last_mc_mode = ivas_mc_mode_select( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */ + + /* temporally set the current mc_mode back to the previous one to make sure the following call to + ivas_init_dec_get_num_cldfb_instances() returns the correct counts */ + mc_mode = st_ivas->mc_mode; + st_ivas->mc_mode = last_mc_mode; + ivas_init_dec_get_num_cldfb_instances_ivas_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old ); + + st_ivas->mc_mode = mc_mode; + + nSCE_old = st_ivas->nSCE; + nCPE_old = st_ivas->nCPE; + sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag; + + /* special handling needed for the hp20 buffers for McMASA */ + IF ( EQ_16(last_mc_mode , MC_MODE_MCMASA) ) + { + nchan_hp20_old = getNumChanSynthesis( st_ivas ); + } + ELSE + { + nchan_hp20_old = nchan_transport_old; + } + st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas ); + + /* save old IntSetup, might be needed for JBM flushing...*/ + intern_config_old = st_ivas->intern_config; + hIntSetupOld = st_ivas->hIntSetup; + tc_granularity_new = 1; + + /* renderer might have changed, reselect */ + renderer_type_old = st_ivas->renderer_type; + ivas_renderer_select( st_ivas ); + + /* side effect of the renderer selection can be a changed internal config */ + ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); + + /* transfer subframe info from DirAC or ParamMC to central tc buffer */ + IF ( EQ_16(last_mc_mode , MC_MODE_PARAMMC) ) + { + st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes; + st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered; + st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots; + st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered; + Copy( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + ELSE IF ( EQ_16(last_mc_mode , MC_MODE_MCMASA) && st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes; + st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered; + st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots; + st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; + Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + + /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv + render what still fits in the new granularity */ + tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs ); + IF ( LT_16(tc_granularity_new , st_ivas->hTcBuffer->n_samples_granularity) ) + { + IF ( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ) != IVAS_ERR_OK ) + { + return error; + } + } + /* JBM: when granularity goes up set samples to discard at the beginning of the frame */ + ELSE IF ( GT_16(tc_granularity_new , st_ivas->hTcBuffer->n_samples_granularity) ) + { + IF ( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) ) + { + st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels( ivas_mc_map_output_config_to_mc_ls_setup( st_ivas->transport_config ) ); + st_ivas->nSCE = 0; + st_ivas->nCPE = st_ivas->nchan_transport / 2; + + IF ( NE_16(last_mc_mode , MC_MODE_MCT) ) + { + /*De-allocate handles for other MC modes*/ + IF ( st_ivas->hParamMC != NULL ) + { + ivas_param_mc_dec_close_fx( &st_ivas->hParamMC ); + + /* remove ls conversion if it was allocated by ParamMC */ + ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + } + + IF ( EQ_16(last_mc_mode , MC_MODE_PARAMUPMIX) ) + { + ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); + ivas_ls_setup_conversion_close_fx( &( st_ivas->hLsSetUpConversion ) ); + } + + /* De-allocate McMasa-related handles */ + ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); + + ivas_qmetadata_close( &st_ivas->hQMetaData ); + IF ( st_ivas->hDirAC != NULL ) + { + ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); + vbap_free_data_fx( &( st_ivas->hVBAPdata ) ); + } + + /* init LS conversion if the renderer type asks for it */ + IF ( EQ_16(st_ivas->renderer_type , RENDERER_MC) && st_ivas->hLsSetUpConversion == NULL ) + { + if ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) + { + st_ivas->nSCE = 0; + st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2; + st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS; + + IF ( NE_16(last_mc_mode , MC_MODE_PARAMUPMIX) ) + { + /*De-allocate handles for other MC modes*/ + IF ( st_ivas->hParamMC != NULL ) + { + ivas_param_mc_dec_close_fx( &st_ivas->hParamMC ); + + /* remove ls conversion if it was allocated by ParamMC */ + ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + } + + ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); + ivas_qmetadata_close( &st_ivas->hQMetaData ); + + /* init LS conversion if the renderer type asks for it */ + IF ( ( EQ_16(st_ivas->renderer_type , RENDERER_MC) ) && st_ivas->hLsSetUpConversion == NULL ) + { + IF ( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + IF ( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMMC) ) + { + IF ( NE_16(last_mc_mode , MC_MODE_PARAMMC) ) + { + /* remove old ls conversion for MCT if open, gets reopened correctly within ivas_param_mc_dec_open when needed */ + IF ( EQ_16(renderer_type_old , RENDERER_MC) && st_ivas->hLsSetUpConversion != NULL ) + { + ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + } + + IF ( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + } + ELSE + { + IF ( ( error = ivas_param_mc_dec_reconfig_fx( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + /* De-allocate McMasa-related handles */ + ivas_masa_dec_close_fx( &( st_ivas->hMasa ) ); + ivas_qmetadata_close( &st_ivas->hQMetaData ); + + IF ( st_ivas->hDirAC != NULL ) + { + ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); + vbap_free_data_fx( &( st_ivas->hVBAPdata ) ); + } + + IF ( EQ_16(last_mc_mode , MC_MODE_MCT) ) + { + IF ( st_ivas->hMCT != NULL && LE_16(st_ivas->nchan_transport , CPE_CHANNELS) ) + { + ivas_mct_dec_close( &st_ivas->hMCT ); + } + } + ELSE IF ( EQ_16(last_mc_mode , MC_MODE_PARAMUPMIX) ) + { + ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); + } + + /* LFE handle */ + ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + { + ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate ); + + IF ( NE_16(last_mc_mode , MC_MODE_MCMASA) ) + { + IF ( ( error = ivas_qmetadata_open( &( st_ivas->hQMetaData ) ) ) != IVAS_ERR_OK ) + { + return error; + } + } + + IF ( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + + /* LS conversion */ + IF ( st_ivas->hLsSetUpConversion != NULL ) + { + ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion ); + } + + ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) ); + + IF ( st_ivas->hParamMC != NULL ) + { + ivas_param_mc_dec_close_fx( &st_ivas->hParamMC ); + st_ivas->hParamMC = NULL; + } + + IF ( EQ_16(last_mc_mode , MC_MODE_MCT) ) + { + ivas_mct_dec_close( &st_ivas->hMCT ); + } + + /* LFE handle */ + ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) ); + } + + IF ( NE_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + { + IF ( EQ_16(st_ivas->nchan_transport , 1) ) + { + st_ivas->element_mode_init = IVAS_SCE; + } + ELSE + { + st_ivas->element_mode_init = IVAS_CPE_MDCT; + } + } + + /*-----------------------------------------------------------------* + * Reconfigure core coder + *-----------------------------------------------------------------*/ + + /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1 + and might have IGF static memory not allocated and the bit stream index list not set, + set correct mct_chan_mode and init missing static mem (IGF, HQ) and some config (TNS) do it here since it is _very_ MC specific */ + IF ( EQ_16(last_mc_mode , MC_MODE_MCT) && EQ_16(st_ivas->mc_mode , MC_MODE_PARAMMC) && GT_16(st_ivas->nchan_transport , CPE_CHANNELS) ) + { + st = st_ivas->hCPE[1]->hCoreCoder[1]; + + IF ( st_ivas->nchan_transport == 3 ) + { + st->mct_chan_mode = MCT_CHAN_MODE_IGNORE; + } + ELSE + { + st->mct_chan_mode = MCT_CHAN_MODE_REGULAR; + } + + IF ( st->hIGFDec == NULL ) + { + IF ( ( st->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) ); + } + + st->igf = 0; + init_igf_dec( st->hIGFDec ); +#if 1 /*TODO: To be removed later(floating point initialization)*/ +#if ( defined EVS_FLOAT ) || !( defined IVAS_FLOAT_FIXED ) + st->hIGFDec->virtualSpec_float = &st->hIGFDec->virtualSpecBuf[0]; + st->hIGFDec->igfData.pSpecFlat_float = &st->hIGFDec->igfData.pSpecFlatBuf[0]; + set_f( st->hIGFDec->igfData.pSpecFlatBuf, 0, IGF_START_MX ); +#endif + FOR( Word16 l = 0; l < IGF_START_MX; l++ ) + st->hIGFDec->infoTCXNoiseBuf[l] = (uint8_t) st->hIGFDec->infoTCXNoise_evs[l]; +#endif + } + + IF ( st->hHQ_core == NULL ) + { + IF ( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) ); + } + + /* HQ core initialization */ +#if 1/*TODO: To be removed later*/ + HQ_core_dec_init_flt( st->hHQ_core ); +#endif + HQ_core_dec_init_fx( st->hHQ_core ); + } + + /* check if we have a doubly used hTxcCfg, if so, allocate a distint one for the old MCT LFE channel */ + IF ( st->hTcxCfg == st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg ) + { + IF ( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) ); + } + } + + st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode ); + } + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + { + uint8_t separateChannelEnabled; + int16_t separateChannelIndex; + ivas_mcmasa_set_separate_channel_mode_fx( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate ); + ivas_mcmasa_split_brate_fx( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE ); + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) ) + { + new_brate_SCE = 0; + new_brate_CPE = ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS; + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) + { + new_brate_SCE = 0; + new_brate_CPE = ( ivas_total_brate / ( st_ivas->nchan_transport - 1 ) ) * CPE_CHANNELS; + } + ELSE + { + new_brate_SCE = 0; /* ivas_total_brate / st_ivas->nchan_transport;*/ + new_brate_CPE = ( ivas_total_brate / st_ivas->nchan_transport ) * CPE_CHANNELS; + } + + IF( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ) != IVAS_ERR_OK ) + { + return error; + } + IF ( EQ_16(last_mc_mode , MC_MODE_MCT) && EQ_16(st_ivas->mc_mode , MC_MODE_PARAMMC) && GT_16(st_ivas->nchan_transport , CPE_CHANNELS) ) + { + st = st_ivas->hCPE[1]->hCoreCoder[1]; + + /* TCX-LTP */ + IF ( st->hTcxLtpDec == NULL ) + { + IF ( ( st->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); + } + tcxltp_dec_init_fx( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core ); + } + } + + /*-----------------------------------------------------------------* + * re-configure HP20 memories + *-----------------------------------------------------------------*/ + IF ( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ) != IVAS_ERR_OK ) + { + return error; + } + /*-----------------------------------------------------------------* + * Allocate the LFE handle that is coded separately after the allocation of the core coders + *-----------------------------------------------------------------*/ + + IF ( ( EQ_16(st_ivas->mc_mode , MC_MODE_MCT) || EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) && st_ivas->hLFE == NULL ) + { + Word32 binauralization_delay_ns = st_ivas->binaural_latency_ns; + IF ( st_ivas->hBinRenderer != NULL ) + { + IF ( st_ivas->hBinRenderer->render_lfe ) + { + /* Account for filterbank delay */ + binauralization_delay_ns += IVAS_FB_DEC_DELAY_NS; + } + else + { + binauralization_delay_ns = 0; + } + } + + IF( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ) != IVAS_ERR_OK ) + { + return error; + } + + set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN ); + set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k ); + } + + /*-----------------------------------------------------------------* + * Reconfigure renderers + *-----------------------------------------------------------------*/ + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_MCMASA) ) + { + IF ( ( NE_16(st_ivas->renderer_type , RENDERER_DISABLE) ) && ( NE_16(st_ivas->renderer_type , RENDERER_MCMASA_MONO_STEREO) ) ) + { + IF ( st_ivas->hDirAC != NULL ) + { + /* reconfigure existing DirAC dec */ + IF ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + /* init a new DirAC dec */ + IF ( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ) != IVAS_ERR_OK ) { return error; } } } + ELSE IF ( EQ_16(st_ivas->renderer_type , RENDERER_DISABLE) && st_ivas->hDirAC != NULL ) + { + ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) ); + ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) ); + ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) ); + vbap_free_data_fx( &( st_ivas->hVBAPdata ) ); + } + } - st_ivas->transport_config = signaled_config; + IF ( NE_16(renderer_type_old , st_ivas->renderer_type) ) + { + AUDIO_CONFIG output_config; + + output_config = st_ivas->hDecoderConfig->output_config; + + /* binaural renderers*/ + IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR) || EQ_16(output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + { + /* remove unneeded binaural renderers */ + IF ( st_ivas->hBinRenderer != NULL && ( NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV) && NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) ) + { + ivas_binRenderer_close( &st_ivas->hBinRenderer ); + } + + IF ( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend != NULL ) && ( NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_MIXER_CONV) && NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_MIXER_CONV_ROOM) && ( NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_OBJECTS_TD) || NE_16(st_ivas->hIntSetup.output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) ) ) + { + + ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ) ); + } + + IF ( st_ivas->hBinRendererTd != NULL && ( NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_OBJECTS_TD) ) ) + { + ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd ); + st_ivas->hHrtfTD = NULL; + } + + IF ( st_ivas->hDiracDecBin != NULL ) + { + IF ( NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_PARAMETRIC) && NE_16(st_ivas->renderer_type , RENDERER_BINAURAL_PARAMETRIC_ROOM) && NE_16(st_ivas->renderer_type , RENDERER_STEREO_PARAMETRIC) ) + { + ivas_dirac_dec_close_binaural_data( &st_ivas->hDiracDecBin ); + } + } + + /* init necessary new renderers */ + IF ( st_ivas->hBinRenderer == NULL && ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV) || EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_FASTCONV_ROOM) ) ) + { + IF ( ( error = ivas_binRenderer_open( st_ivas ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE IF ( st_ivas->hBinRendererTd == NULL && EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_OBJECTS_TD) ) + { + IF( ( error = ivas_td_binaural_open_fx( st_ivas, &st_ivas->SrcInd[0], &st_ivas->num_src ) ) != IVAS_ERR_OK ) + { + return error; + } + IF ( EQ_16(st_ivas->hIntSetup.output_config , IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB) ) + { + IF ( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper ) ) != IVAS_ERR_OK ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" ); + } + + st_ivas->hCrendWrapper->hCrend = NULL; + st_ivas->hCrendWrapper->hHrtfCrend = NULL; + IF ( ( st_ivas->hCrendWrapper->hCrend = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" ); + } + } + } + ELSE IF ( st_ivas->hCrendWrapper == NULL && ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_MIXER_CONV) || EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_MIXER_CONV_ROOM) ) ) + { + IF ( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hDecoderConfig->output_Fs ) ) != IVAS_ERR_OK ) + { + return error; + } + st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns; + } + } + /* mono/stereo */ + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_MONO) || EQ_16(output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + /* nothing should happen here... */ + } + /* LS */ + ELSE IF ( EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_2) || EQ_16(output_config , IVAS_AUDIO_CONFIG_5_1_4) || EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1) || EQ_16(output_config , IVAS_AUDIO_CONFIG_7_1_4) || EQ_16(output_config , IVAS_AUDIO_CONFIG_LS_CUSTOM) ) + { + } } + /*-----------------------------------------------------------------* + * CLDFB instances + *-----------------------------------------------------------------*/ - return IVAS_ERR_OK; -} + IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ) != IVAS_ERR_OK ) + { + return error; + } + /*-----------------------------------------------------------------* + * JBM TC buffers + *-----------------------------------------------------------------*/ -/*------------------------------------------------------------------------- - * ivas_mc_dec_reconfig() - * - * reconfigure the MC format decoder - *-------------------------------------------------------------------------*/ + { + Word16 tc_nchan_full_new; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; + tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas ); + tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas ); + tc_nchan_allocate_new = tc_nchan_tc_new; + tc_nchan_full_new = tc_nchan_tc_new; + + IF ( EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type , RENDERER_BINAURAL_PARAMETRIC_ROOM) || EQ_16(st_ivas->renderer_type , RENDERER_STEREO_PARAMETRIC) ) + { + tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; + tc_nchan_full_new = tc_nchan_allocate_new; + } + + IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMMC) && NE_16(st_ivas->hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_MONO) && NE_16(st_ivas->hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_STEREO) ) + { + tc_nchan_full_new = 0; + } + ELSE IF ( EQ_16(st_ivas->mc_mode , MC_MODE_PARAMUPMIX) ) + { + tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS; + tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER; + IF ( EQ_16(st_ivas->hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_STEREO) || EQ_16(st_ivas->hDecoderConfig->output_config , IVAS_AUDIO_CONFIG_MONO) ) + { + tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER; + tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out; + tc_nchan_allocate_new = tc_nchan_tc_new; + } + tc_nchan_full_new = tc_nchan_allocate_new; + } + + /* reconfigure buffer */ + IF ( NE_16(hTcBuffer->tc_buffer_mode , tc_buffer_mode_new) || NE_16(hTcBuffer->nchan_transport_jbm , tc_nchan_tc_new) || + NE_16(hTcBuffer->nchan_buffer_full , tc_nchan_full_new) || NE_16(hTcBuffer->nchan_transport_internal , tc_nchan_allocate_new) || + NE_16(tc_granularity_new , hTcBuffer->n_samples_granularity) ) + { + IF ( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ) != IVAS_ERR_OK ) + { + return error; + } + } + /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */ + IF ( st_ivas->hSpatParamRendCom != NULL ) + { + st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + ELSE IF ( st_ivas->hParamMC != NULL ) + { + st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes; + st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered; + st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots; + st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered; + Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS ); + } + } + + + /*-----------------------------------------------------------------* + * floating-point output audio buffers + *-----------------------------------------------------------------*/ + + nchan_out_buff = ivas_get_nchan_buffers_dec_ivas_fx( st_ivas, -1, -1 ); + + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + { + return error; + } +#if 1/*TODO: To be removed later*/ + if ( ( error = ivas_output_buff_dec( st_ivas->p_output_f, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + { + return error; + } +#endif + return error; +} +#else static ivas_error ivas_mc_dec_reconfig( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -1499,7 +2321,7 @@ static ivas_error ivas_mc_dec_reconfig( nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in = 0, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in = 0, numch_out, num_md_sub_frames; ; Word16 numch_out_dirac = hDecoderConfig->nchan_out; IF( hSpar ) @@ -1508,31 +2330,7 @@ static ivas_error ivas_mc_dec_reconfig( numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); hSpar->hMdDec->Q_mixer_mat = 30; -#if 0 - for ( int l = 0; l < numch_out; l++ ) - { - for ( int j = 0; j < numch_in; j++ ) - { - for ( int k = 0; k < num_md_sub_frames * IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->mixer_mat_fx[l][j][k] = floatToFixed( hSpar->hMdDec->mixer_mat[l][j][k], q1 ); - } - } - } - for ( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - for ( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - for ( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - for ( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] = floatToFixed( hSpar->hMdDec->mixer_mat_prev[m][j][k][l], q2 ); - } - } - } - } -#endif + for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( Word16 i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) @@ -1585,21 +2383,7 @@ static ivas_error ivas_mc_dec_reconfig( st_ivas->cldfbAnaDec[in_ch]->cldfb_state[i] = ( (float) ( st_ivas->cldfbAnaDec[in_ch]->cldfb_state_fx[i] ) / ( 1LL << ( Q11 ) ) ); } } -#if 0 - FOR( int m = 0; m < MAX_PARAM_SPATIAL_SUBFRAMES + 1; m++ ) - { - FOR( int j = 0; j < IVAS_MAX_FB_MIXER_OUT_CH; j++ ) - { - FOR( int k = 0; k < IVAS_MAX_SPAR_FB_MIXER_IN_CH; k++ ) - { - FOR( int l = 0; l < IVAS_MAX_NUM_BANDS; l++ ) - { - hSpar->hMdDec->mixer_mat_prev[m][j][k][l] = ( (float) hSpar->hMdDec->mixer_mat_prev_fx[m][j][k][l] / ( 1 << q2 ) ); - } - } - } - } -#endif + // fix2float (to be cleaned) IF( ( LT_32( hDecoderConfig->ivas_total_brate, IVAS_24k4 ) ) && ( ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA2 ) ) || ( EQ_16( hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) ) { @@ -1804,15 +2588,15 @@ static ivas_error ivas_mc_dec_reconfig( { for ( Word16 k = 0; k < nchan_out_transport; k++ ) { - floatToFixed_arr32( st_ivas->hLsSetUpConversion->dmxMtx[k], st_ivas->hLsSetUpConversion->dmxMtx_fx[k], Q30, nchan_out_cov ); + //floatToFixed_arr32( st_ivas->hLsSetUpConversion->dmxMtx[k], st_ivas->hLsSetUpConversion->dmxMtx_fx[k], Q30, nchan_out_cov ); } } if ( st_ivas->hParamMC ) { floatToFixed_arr( hParamMC->icc_q, hParamMC->icc_q_fx, Q15, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->icc_mapping_conf->icc_map_size_lfe ); floatToFixed_arr( hParamMC->icld_q, hParamMC->icld_q_fx, Q8, hParamMC->hMetadataPMC->num_parameter_bands * hParamMC->hMetadataPMC->ild_mapping_conf->ild_map_size_lfe ); - if ( hParamMC->ls_conv_dmx_matrix ) - floatToFixed_arr32( hParamMC->ls_conv_dmx_matrix, hParamMC->ls_conv_dmx_matrix_fx, Q31, nchan_out_cov * nchan_out_transport ); + //if ( hParamMC->ls_conv_dmx_matrix ) + // floatToFixed_arr32( hParamMC->ls_conv_dmx_matrix, hParamMC->ls_conv_dmx_matrix_fx, Q31, nchan_out_cov * nchan_out_transport ); Word32 max_cx_old_fx, max_cy_old_fx, max_mix_matrix_old_fx, max_mix_matrix_res_old_fx; float max_cx_old = hParamMC->h_output_synthesis_cov_state.cx_old[0][0], max_cy_old = hParamMC->h_output_synthesis_cov_state.cy_old[0][0], max_mix_matrix_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_old[0][0], max_mix_matrix_res_old = hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_old[0][0]; for ( int i = 0; i < hParamMC->hMetadataPMC->num_parameter_bands; i++ ) @@ -1906,13 +2690,13 @@ static ivas_error ivas_mc_dec_reconfig( { for ( int16_t i = 0; i < nchan_out_cov; i++ ) { - st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); + //st_ivas->hLsSetUpConversion->dmxMtx[k][i] = fixedToFloat( st_ivas->hLsSetUpConversion->dmxMtx_fx[k][i], Q30 ); } } } fixedToFloat_arrL( hParamMC->proto_matrix_int_fx, hParamMC->proto_matrix_int, Q31, nchan_out_transport * nchan_transport ); - if ( hParamMC->ls_conv_dmx_matrix ) - fixedToFloat_arrL( hParamMC->ls_conv_dmx_matrix_fx, hParamMC->ls_conv_dmx_matrix, Q31, nchan_out_transport * nchan_out_cov ); + //if ( hParamMC->ls_conv_dmx_matrix ) + // fixedToFloat_arrL( hParamMC->ls_conv_dmx_matrix_fx, hParamMC->ls_conv_dmx_matrix, Q31, nchan_out_transport * nchan_out_cov ); } #endif #else @@ -2639,3 +3423,4 @@ static ivas_error ivas_mc_dec_reconfig( return error; } +#endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_mdct_core_dec.c b/lib_dec/ivas_mdct_core_dec.c index fa0aa44a1..9cc2cd5b0 100644 --- a/lib_dec/ivas_mdct_core_dec.c +++ b/lib_dec/ivas_mdct_core_dec.c @@ -1982,9 +1982,17 @@ void ivas_mdct_core_reconstruct_fx( /* Postfiltering */ Word16 x_fx_16[1200]; Copy_Scale_sig_32_16(x_fx[ch][0], x_fx_16, st->L_frame, sub(0, q_x)); + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, negate( Q11 ) ); + } post_decoder_ivas_fx( st, synth_buf_fx, pit_gain_fx[ch], pitch[ch], x_fx_16, st->p_bpf_noise_buf ); - + + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); + } IF ( signal_outFB_fx[ch] != NULL ) { Copy_Scale_sig( synthFB_fx, signal_outFB_fx[ch], st->hTcxDec->L_frameTCX, sub(sub(15, e_sig), q_syn) ); diff --git a/lib_dec/ivas_mono_dmx_renderer.c b/lib_dec/ivas_mono_dmx_renderer.c index 91e65b52c..75d42d5ec 100644 --- a/lib_dec/ivas_mono_dmx_renderer.c +++ b/lib_dec/ivas_mono_dmx_renderer.c @@ -72,8 +72,6 @@ ivas_error ivas_mono_dmx_renderer_open( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for downmixing\n" ) ); } - hDownmix->inputEnergy = 0; // float - hDownmix->protoEnergy = 0; // float hDownmix->inputEnergy_fx = 0; hDownmix->protoEnergy_fx = 0; hDownmix->Q_inputEner = 0; @@ -146,7 +144,7 @@ void ivas_mono_dmx_renderer_close( * * Downmix process *------------------------------------------------------------------------*/ - +#ifndef IVAS_FLOAT_FIXED void ivas_mono_downmix_render_passive( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output_f[], /* i/o: synthesized core-coder transport channels/mono output */ @@ -205,10 +203,7 @@ void ivas_mono_downmix_render_passive( return; } - -#ifdef IVAS_FLOAT_FIXED - - +#else void ivas_mono_downmix_render_passive_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono output */ diff --git a/lib_dec/ivas_omasa_dec.c b/lib_dec/ivas_omasa_dec.c index ba46a5eb7..8635457e6 100644 --- a/lib_dec/ivas_omasa_dec.c +++ b/lib_dec/ivas_omasa_dec.c @@ -277,7 +277,6 @@ void ivas_omasa_data_close( ivas_error ivas_omasa_dec_config_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ UWord16 *nSamplesRendered, /* o : number of samples flushed from the previous frame (JBM) */ - Word16 Q_cldfbSynDec, /* i : Q factor for cldfb state */ Word16 *num_src, Word16 SrcInd[MAX_NUM_TDREND_CHANNELS], Word16 *data /* o : output synthesis signal */ @@ -349,7 +348,7 @@ ivas_error ivas_omasa_dec_config_fx( DECODER_CONFIG_HANDLE hDecoderConfig = NULL; Word16 numch_out_dirac = 0; SPAR_DEC_HANDLE hSpar = NULL; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; + Word16 numch_in, numch_out, num_md_sub_frames; IF(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) || EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM) || EQ_16(st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC)) { IF(EQ_16(st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC) && NE_16(st_ivas->ism_mode, ISM_MASA_MODE_DISC)) @@ -667,7 +666,7 @@ ivas_error ivas_omasa_dec_config_fx( * CLDFB instances *-----------------------------------------------------------------*/ - IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, 2, numCldfbAnalyses_old, numCldfbSyntheses_old, Q_cldfbSynDec ) ) != IVAS_ERR_OK ) + IF ( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, 2, numCldfbAnalyses_old, numCldfbSyntheses_old) ) != IVAS_ERR_OK ) { return error; } diff --git a/lib_dec/ivas_osba_dec.c b/lib_dec/ivas_osba_dec.c index f8616e486..7a6d7e05e 100644 --- a/lib_dec/ivas_osba_dec.c +++ b/lib_dec/ivas_osba_dec.c @@ -343,20 +343,16 @@ ivas_error ivas_osba_render_sf_fx( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - Word16 numch_out = hSpar->hFbMixer->fb_cfg->num_out_chans; Word16 numch_in = hSpar->hFbMixer->fb_cfg->num_in_chans; DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; Word16 numch_out_dirac = hDecoderConfig->nchan_out; - Word16 num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_order, hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - for ( int i = 0; i < s_max( st_ivas->nchan_ism, 0 ) + nchan_internal; i++ ) { floatToFixed_arr32( st_ivas->hTcBuffer->tc[i], st_ivas->hTcBuffer->tc_fx[i], Q11, st_ivas->hTcBuffer->n_samples_available ); } - Word16 q1 = 30, q2 = 30; - hSpar->hMdDec->Q_mixer_mat = 30; + hSpar->hMdDec->Q_mixer_mat = Q30; for ( Word16 in_ch = 0; in_ch < numch_in; in_ch++ ) { for ( int i = 0; i < st_ivas->cldfbAnaDec[in_ch]->p_filter_length - st_ivas->cldfbAnaDec[in_ch]->no_channels; i++ ) diff --git a/lib_dec/ivas_out_setup_conversion.c b/lib_dec/ivas_out_setup_conversion.c index cee1062b1..e6c2a6f63 100644 --- a/lib_dec/ivas_out_setup_conversion.c +++ b/lib_dec/ivas_out_setup_conversion.c @@ -344,8 +344,7 @@ static void get_custom_ls_conversion_matrix_fx( return; } -#endif - +#else static void get_custom_ls_conversion_matrix( const EFAP_HANDLE hEFAPdata, /* i : EFAP handle */ const IVAS_OUTPUT_SETUP hTransSetup, /* i : Transport channel configuration handle */ @@ -417,7 +416,7 @@ static void get_custom_ls_conversion_matrix( return; } - +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error get_ls_conversion_matrix_fx( @@ -444,7 +443,7 @@ static ivas_error get_ls_conversion_matrix_fx( FOR( i = 0; i < LS_SETUP_CONVERSION_NUM_MAPPINGS; i++ ) { test(); - IF( ( EQ_32( input_config, ls_conversion_mapping[i].input_config ) ) && ( EQ_32( output_config, ls_conversion_mapping[i].output_config ) ) ) + IF( ( EQ_32( input_config, ls_conversion_mapping_fx[i].input_config ) ) && ( EQ_32( output_config, ls_conversion_mapping_fx[i].output_config ) ) ) { /* Special handling for MONO and STEREO downmix */ test(); @@ -513,7 +512,7 @@ static ivas_error get_ls_conversion_matrix_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "The conversion matrix between these formats is not defined!\n" ); } -#endif +#else static ivas_error get_ls_conversion_matrix( LSSETUP_CONVERSION_HANDLE hLsSetUpConversion, const AUDIO_CONFIG input_config, @@ -598,7 +597,7 @@ static ivas_error get_ls_conversion_matrix( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "The conversion matrix between these formats is not defined!\n" ); } - +#endif /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_open() * @@ -661,26 +660,28 @@ ivas_error ivas_ls_setup_conversion_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); } set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt ); + hLsSetUpConversion->te_prev_exp = 0; set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[chIdx], 0, hLsSetUpConversion->sfbCnt ); + hLsSetUpConversion->dmx_prev_exp = 0; /* TODO: remove the floating point dependency */ - IF( ( hLsSetUpConversion->targetEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - } - IF( ( hLsSetUpConversion->dmxEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - } - set_f( hLsSetUpConversion->targetEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); - set_f( hLsSetUpConversion->dmxEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); + //IF( ( hLsSetUpConversion->targetEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL ) + //{ + // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); + //} + //IF( ( hLsSetUpConversion->dmxEnergyPrev[chIdx] = (float *) malloc( ( hLsSetUpConversion->sfbCnt ) * sizeof( float ) ) ) == NULL ) + //{ + // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); + //} + //set_f( hLsSetUpConversion->targetEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); + //set_f( hLsSetUpConversion->dmxEnergyPrev[chIdx], 0.0f, hLsSetUpConversion->sfbCnt ); } FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) { hLsSetUpConversion->targetEnergyPrev_fx[chIdx] = NULL; hLsSetUpConversion->dmxEnergyPrev_fx[chIdx] = NULL; /* TODO: remove the floating point dependency */ - hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; - hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; + //hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; + //hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; } } ELSE @@ -714,28 +715,28 @@ ivas_error ivas_ls_setup_conversion_open_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); } /* TODO: remove the floating point dependency */ - IF( ( hLsSetUpConversion->targetEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - } - IF( ( hLsSetUpConversion->dmxEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); - } + //IF( ( hLsSetUpConversion->targetEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL ) + //{ + // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); + //} + //IF( ( hLsSetUpConversion->dmxEnergyPrev[0] = (float *) malloc( ( MAX_SFB + 2 ) * sizeof( float ) ) ) == NULL ) + //{ + // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for LS configuration Conversion Handle \n" ) ); + //} FOR( chIdx = 1; chIdx < MAX_CICP_CHANNELS; chIdx++ ) { hLsSetUpConversion->targetEnergyPrev_fx[chIdx] = NULL; hLsSetUpConversion->dmxEnergyPrev_fx[chIdx] = NULL; /* TODO: remove the floating point dependency */ - hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; - hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; + //hLsSetUpConversion->targetEnergyPrev[chIdx] = NULL; + //hLsSetUpConversion->dmxEnergyPrev[chIdx] = NULL; } set32_fx( hLsSetUpConversion->targetEnergyPrev_fx[0], 0, MAX_SFB + 2 ); set32_fx( hLsSetUpConversion->dmxEnergyPrev_fx[0], 0, MAX_SFB + 2 ); /* TODO: remove the floating point dependency */ - set_f( hLsSetUpConversion->targetEnergyPrev[0], 0.0f, MAX_SFB + 2 ); - set_f( hLsSetUpConversion->dmxEnergyPrev[0], 0.0f, MAX_SFB + 2 ); + //set_f( hLsSetUpConversion->targetEnergyPrev[0], 0.0f, MAX_SFB + 2 ); + //set_f( hLsSetUpConversion->dmxEnergyPrev[0], 0.0f, MAX_SFB + 2 ); } /* Initialize the DMX conversion matrix */ @@ -750,18 +751,18 @@ ivas_error ivas_ls_setup_conversion_open_fx( /* TODO: remove the floating point dependency */ /* Allocate memory depending on the number of output channels */ - IF( ( hLsSetUpConversion->dmxMtx[chIdx] = (float *) malloc( outChannels * sizeof( float ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR temp dmx matrix \n" ) ); - } - set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels ); + //IF( ( hLsSetUpConversion->dmxMtx[chIdx] = (float *) malloc( outChannels * sizeof( float ) ) ) == NULL ) + //{ + // return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory FOR temp dmx matrix \n" ) ); + //} + //set_zero( hLsSetUpConversion->dmxMtx[chIdx], outChannels ); } FOR( ; chIdx < MAX_CICP_CHANNELS; chIdx++ ) { hLsSetUpConversion->dmxMtx_fx[chIdx] = NULL; /* TODO: remove the floating point dependency */ - hLsSetUpConversion->dmxMtx[chIdx] = NULL; + //hLsSetUpConversion->dmxMtx[chIdx] = NULL; } IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) @@ -792,7 +793,7 @@ ivas_error ivas_ls_setup_conversion_open_fx( { FOR( Word16 j = 0; j < outChannels; ++j ) { - hLsSetUpConversion->dmxMtx[i][j] = fix_to_float( hLsSetUpConversion->dmxMtx_fx[i][j], Q30 ); + //hLsSetUpConversion->dmxMtx[i][j] = fix_to_float( hLsSetUpConversion->dmxMtx_fx[i][j], Q30 ); } } @@ -800,7 +801,7 @@ ivas_error ivas_ls_setup_conversion_open_fx( return IVAS_ERR_OK; } -#endif +#else ivas_error ivas_ls_setup_conversion_open( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ @@ -939,7 +940,7 @@ ivas_error ivas_ls_setup_conversion_open( return IVAS_ERR_OK; } - +#endif /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_close() @@ -980,23 +981,23 @@ void ivas_ls_setup_conversion_close_fx( } /* TODO: remove the floating point dependency */ - IF( ( *hLsSetUpConversion )->dmxMtx[idx] != NULL ) - { - free( ( *hLsSetUpConversion )->dmxMtx[idx] ); - ( *hLsSetUpConversion )->dmxMtx[idx] = NULL; - } + //IF( ( *hLsSetUpConversion )->dmxMtx[idx] != NULL ) + //{ + // free( ( *hLsSetUpConversion )->dmxMtx[idx] ); + // ( *hLsSetUpConversion )->dmxMtx[idx] = NULL; + //} - IF( ( *hLsSetUpConversion )->targetEnergyPrev[idx] != NULL ) - { - free( ( *hLsSetUpConversion )->targetEnergyPrev[idx] ); - ( *hLsSetUpConversion )->targetEnergyPrev[idx] = NULL; - } + //IF( ( *hLsSetUpConversion )->targetEnergyPrev[idx] != NULL ) + //{ + // free( ( *hLsSetUpConversion )->targetEnergyPrev[idx] ); + // ( *hLsSetUpConversion )->targetEnergyPrev[idx] = NULL; + //} - IF( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] != NULL ) - { - free( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] ); - ( *hLsSetUpConversion )->dmxEnergyPrev[idx] = NULL; - } + //IF( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] != NULL ) + //{ + // free( ( *hLsSetUpConversion )->dmxEnergyPrev[idx] ); + // ( *hLsSetUpConversion )->dmxEnergyPrev[idx] = NULL; + //} } free( *hLsSetUpConversion ); @@ -1004,7 +1005,7 @@ void ivas_ls_setup_conversion_close_fx( return; } -#endif +#else void ivas_ls_setup_conversion_close( LSSETUP_CONVERSION_HANDLE *hLsSetUpConversion /* i/o: LS converter handle */ @@ -1043,7 +1044,7 @@ void ivas_ls_setup_conversion_close( return; } - +#endif /*------------------------------------------------------------------------- * ivas_ls_setup_conversion() @@ -1112,7 +1113,7 @@ void ivas_ls_setup_conversion_fx( return; } -#endif +#else void ivas_ls_setup_conversion( Decoder_Struct *st_ivas, /* i : IVAS decoder structure */ @@ -1170,7 +1171,7 @@ void ivas_ls_setup_conversion( return; } - +#endif /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_process_mdct() @@ -1392,6 +1393,8 @@ void ivas_ls_setup_conversion_process_mdct_fx( move32(); hLsSetUpConversion->dmxEnergyPrev_fx[0][bandIdx] = dmxEnergy[bandIdx]; move32(); + hLsSetUpConversion->te_prev_exp = 31; + hLsSetUpConversion->dmx_prev_exp = 31; } FOR( i = 0; i < inChannels; ++i ) @@ -1478,7 +1481,7 @@ void ivas_ls_setup_conversion_process_mdct_fx( pop_wmops(); return; } -#endif +#else void ivas_ls_setup_conversion_process_mdct( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ float *output[] /* i/o: output synthesis signal */ @@ -1711,7 +1714,7 @@ void ivas_ls_setup_conversion_process_mdct( pop_wmops(); return; } - +#endif /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_process_mdct_param_mc() @@ -2057,7 +2060,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc_fx( } return; } -#endif // IVAS_FLOAT_FIXED +#else void ivas_ls_setup_conversion_process_mdct_param_mc( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ @@ -2426,7 +2429,7 @@ void ivas_ls_setup_conversion_process_mdct_param_mc( return; } - +#endif /*------------------------------------------------------------------------- * ivas_ls_setup_conversion_process_param_mc() @@ -2570,6 +2573,8 @@ void ivas_lssetupconversion_process_param_mc_fx( move32(); hLsSetUpConversion->dmxEnergyPrev_fx[chOutIdx][bandIdx] = dmxEnergy[chOutIdx][bandIdx]; move32(); + hLsSetUpConversion->te_prev_exp = 31; + hLsSetUpConversion->dmx_prev_exp = 31; } } } @@ -2605,7 +2610,7 @@ void ivas_lssetupconversion_process_param_mc_fx( pop_wmops(); return; } -#endif +#else void ivas_lssetupconversion_process_param_mc( Decoder_Struct *st_ivas, /* i/o: LS setup conversion renderer handle */ @@ -2729,3 +2734,4 @@ void ivas_lssetupconversion_process_param_mc( pop_wmops(); return; } +#endif \ No newline at end of file diff --git a/lib_dec/ivas_post_proc.c b/lib_dec/ivas_post_proc.c index dd20c4303..8a50efab3 100644 --- a/lib_dec/ivas_post_proc.c +++ b/lib_dec/ivas_post_proc.c @@ -36,6 +36,7 @@ #include "cnst.h" #include "rom_com.h" #include "prot.h" +#include "prot_fx1.h" #include "prot_fx2.h" #include "ivas_prot.h" #include "ivas_prot_fx.h" @@ -319,6 +320,11 @@ void stereo_dft_dec_core_switching_fx( st->last_core = st->last_core_bfi; } + IF( st->p_bpf_noise_buf_32 ) + { + Scale_sig32( st->p_bpf_noise_buf_32, L_FRAME16k, sub( *q, Q11 ) ); + } + IF( st->core == TCX_20_CORE || st->core == TCX_10_CORE || st->core == HQ_CORE || ( st->bfi == 1 && st->core == ACELP_CORE && st->con_tcx == 1 ) ) { IF( ( ( st->last_core != ACELP_CORE || ( st->prev_bfi == 1 && st->last_core == ACELP_CORE && st->last_con_tcx == 1 ) ) && st->last_core != AMR_WB_CORE ) || ( sba_dirac_stereo_dtx_flag && st->cng_type == FD_CNG ) ) /* TCX / HQ-CORE -> TCX / HQ-CORE */ @@ -692,6 +698,11 @@ void stereo_dft_dec_core_switching_fx( } } + IF( st->p_bpf_noise_buf_32 ) + { + Scale_sig32( st->p_bpf_noise_buf_32, L_FRAME16k, negate( sub( *q, Q11 ) ) ); + } + return; } #else diff --git a/lib_dec/ivas_sba_dec.c b/lib_dec/ivas_sba_dec.c index 848c602fc..dcf1bcdbf 100644 --- a/lib_dec/ivas_sba_dec.c +++ b/lib_dec/ivas_sba_dec.c @@ -1044,10 +1044,8 @@ ivas_error ivas_sba_dec_reconfigure_fx( hSpar = st_ivas->hSpar; uint16_t nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); - DECODER_CONFIG_HANDLE hDecoderConfig; hDecoderConfig = st_ivas->hDecoderConfig; - Word16 numch_in, numch_out, num_md_sub_frames, q1 = 30, q2 = 30; - ; + Word16 numch_in = 0, numch_out; Word16 numch_out_dirac = hDecoderConfig->nchan_out; IF( hSpar ) { diff --git a/lib_dec/ivas_sba_rendering_internal.c b/lib_dec/ivas_sba_rendering_internal.c index 97adb9a73..a779b98b1 100644 --- a/lib_dec/ivas_sba_rendering_internal.c +++ b/lib_dec/ivas_sba_rendering_internal.c @@ -986,104 +986,13 @@ void ivas_sba_mix_matrix_determiner( num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; #ifdef IVAS_FLOAT_FIXED #if 1 /*Float to fixed changes */ - Word16 j, b, i_ts, num_out_ch; + Word16 num_out_ch; num_out_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - Word16 Q_C_re_fx = 31, Q_P_re_fx = 31; hSpar->hMdDec->Q_mixer_mat = 31; Word16 num_in_ch; num_in_ch = hSpar->hMdDec->spar_md_cfg.num_umx_chs; -#if 0 - FOR ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, Q_factor_L( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR ( i = 0; i < num_out_ch; i++ ) - { - FOR ( j = 0; j < nchan_transport; j++ ) - { - FOR ( b = 0; b < num_bands_out; b++ ) - { - Q_C_re_fx = s_min( Q_C_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - FOR ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR ( i = 0; i < num_out_ch; i++ ) - { - FOR ( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR ( b = 0; b < num_bands_out; b++ ) - { - Q_P_re_fx = s_min( Q_P_re_fx, Q_factor_L( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] ) ); - } - } - } - } - hSpar->hMdDec->Q_mixer_mat = s_min(hSpar->hMdDec->Q_mixer_mat, s_min( Q_C_re_fx, Q_P_re_fx ) ); - FOR ( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR ( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < nchan_transport; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = nchan_transport; j < num_out_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #endif ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames); -#if 0 /*Fixed to float changes */ - FOR( i_ts = 0; i_ts < num_md_sub_frames; i_ts++ ) - { - FOR( i = 0; i < num_out_ch; i++ ) - { - FOR( j = 0; j < num_in_ch; j++ ) - { - FOR( b = 0; b < num_bands_out; b++ ) - { - hSpar->hMdDec->mixer_mat[i][j][b + i_ts * IVAS_MAX_NUM_BANDS] = fixedToFloat( hSpar->hMdDec->mixer_mat_fx[i][j][b + i_ts * IVAS_MAX_NUM_BANDS], hSpar->hMdDec->Q_mixer_mat ); - } - } - } - } -#endif #else ivas_spar_dec_gen_umx_mat( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); #endif // IVAS_FLOAT_FIXED diff --git a/lib_dec/ivas_sce_dec_fx.c b/lib_dec/ivas_sce_dec_fx.c index aea3b567c..8d3ff8518 100644 --- a/lib_dec/ivas_sce_dec_fx.c +++ b/lib_dec/ivas_sce_dec_fx.c @@ -45,9 +45,6 @@ #include "ivas_rom_com.h" #include "wmc_auto.h" -/* NOTE: Temporary macro for computation happening in floating point. This macro and code active under this is to be removed once the intermediate conversions to float are not required */ -#define IVAS_FLOAT_FIXED_TO_BE_REMOVED - /*--------------------------------------------------------------------------* * ivas_sce_dec() * @@ -240,33 +237,17 @@ ivas_error ivas_sce_dec_fx( * Decoder *----------------------------------------------------------------*/ #ifndef TO_BE_REMOVED_CONVERSION - //Word16 k; - - //{ - // sts = hCPE->hCoreCoder; - //} - - //core_coding_part will go in this loop, once the things are done - /* for (k = 0; k < n_channels; k++) - {*/ if (st->hTcxDec != NULL) { floatToFixed_arr(st->hHQ_core->old_out, st->hHQ_core->old_out_fx, 0, L_FRAME48k); floatToFixed_arr(st->hHQ_core->old_outLB, st->hHQ_core->old_out_LB_fx, 0, L_FRAME32k); floatToFixed_arrL(st->hHQ_core->old_outLB, st->hHQ_core->old_outLB_fx, 11, L_FRAME32k); - //sts[k]->hTcxDec->conceal_eof_gain32 = floatToFixed( sts[k]->hTcxDec->conceal_eof_gain_float, 15 ); } - /*}*/ IF(st->hFdCngDec != NULL && (st->element_mode == IVAS_CPE_MDCT && st->total_brate == SID_2k40)) { - //FOR(Word16 ch = 0; ch < CPE_CHANNELS; ++ch) - { f2me_buf(st->hFdCngDec->hFdCngCom->cngNoiseLevel_flt, st->hFdCngDec->hFdCngCom->cngNoiseLevel, &st->hFdCngDec->hFdCngCom->cngNoiseLevelExp, st->hFdCngDec->hFdCngCom->stopBand - st->hFdCngDec->hFdCngCom->startBand); - //floatToFixed_arr(st->hFdCngDec->hFdCngCom->A_cng_flt, st->hFdCngDec->hFdCngCom->A_cng, Q14, M + 1); - } } - #endif set32_fx(output[0], 0, L_FRAME48k); @@ -278,12 +259,8 @@ ivas_error ivas_sce_dec_fx( IF( st_ivas->sba_dirac_stereo_flag && ( GT_32( st->core_brate, SID_2k40 ) || EQ_16( st->cng_type, LP_CNG ) ) ) { /* skip addition of ACELP BWE for now, will be done after upmix */ -#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - mvr2r( outputHB_flt[0], hSCE->save_hb_synth, output_frame ); -#else Copy32( outputHB[0], hSCE->save_hb_synth_fx, output_frame ); - fixedToFloat_arrL(hSCE->save_hb_synth_fx, hSCE->save_hb_synth,Q11,output_frame); -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED + hSCE->q_save_hb_synth_fx = Q11; } ELSE IF( !st_ivas->sba_dirac_stereo_flag ) { @@ -360,9 +337,6 @@ ivas_error create_sce_dec( hSCE->sce_id = sce_id; hSCE->element_brate = element_brate; -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - //set_f( hSCE->prev_hb_synth, 0.0f, NS2SA( st_ivas->hDecoderConfig->output_Fs, L_sub( IVAS_DEC_DELAY_NS, DELAY_BWE_TOTAL_NS ) ) ); -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED set32_fx( hSCE->prev_hb_synth_fx, 0, NS2SA_fx2( st_ivas->hDecoderConfig->output_Fs, L_sub( IVAS_DEC_DELAY_NS, DELAY_BWE_TOTAL_NS ) ) ); /*-----------------------------------------------------------------* @@ -408,14 +382,6 @@ ivas_error create_sce_dec( } } -//#ifndef IVAS_FLOAT_FIXED -// IF( ( error = init_decoder_ivas_fx( st, 0, st_ivas->mc_mode ) ) != IVAS_ERR_OK ) -//#else -// IF( ( error = init_decoder_fx( st, EVS_MONO ) ) != IVAS_ERR_OK ) -//#endif -// { -// return error; -// } IF( EQ_16( (Word16) st_ivas->ivas_format, SBA_FORMAT ) && ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || ( EQ_16( (Word16) st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && EQ_16( st_ivas->nchan_transport, 1 ) ) ) ) { @@ -437,76 +403,34 @@ ivas_error create_sce_dec( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DTX/TD CNG\n" ) ); } -#ifdef IVAS_FLOAT_FIXED td_cng_dec_init_ivas_fx( st ); -#else - td_cng_dec_init( st ); -#endif // IVAS_FLOAT_FIXED } /*-----------------------------------------------------------------* * Synthesis buffers: allocate and initialize *-----------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED IF( st_ivas->sba_dirac_stereo_flag ) { - - IF( ( hSCE->save_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); - } - set_zero( hSCE->save_synth, output_frame ); - - IF( ( hSCE->save_hb_synth = (float *) malloc( sizeof( float ) * output_frame ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); - } - set_zero( hSCE->save_hb_synth, output_frame ); -#ifdef IVAS_FLOAT_FIXED IF( ( hSCE->save_synth_fx = (Word32 *) malloc( sizeof( *(hSCE->save_synth_fx) ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); } set_zero_fx( hSCE->save_synth_fx, output_frame ); + hSCE->q_save_synth_fx = 0; IF( ( hSCE->save_hb_synth_fx = (Word32 *) malloc( sizeof( *(hSCE->save_hb_synth_fx) ) * output_frame ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); } set_zero_fx( hSCE->save_hb_synth_fx, output_frame ); -#endif - } - ELSE - { - hSCE->save_synth = NULL; - hSCE->save_hb_synth = NULL; -#ifdef IVAS_FLOAT_FIXED - hSCE->save_synth_fx = NULL; - hSCE->save_hb_synth_fx = NULL; -#endif - } -#else - IF( st_ivas->sba_dirac_stereo_flag ) - { - IF( ( hSCE->save_synth_fx = (Word32 *) malloc( sizeof( Word32 ) * output_frame ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for stereo output\n" ) ); - } - set32_fx( hSCE->save_synth_fx, 0, output_frame ); - - IF( ( hSCE->save_hb_synth_fx = (Word32 *) malloc( sizeof( Word32 ) * output_frame ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate HB memory for stereo output\n" ) ); - } - set32_fx( hSCE->save_hb_synth_fx, 0, output_frame ); + hSCE->q_save_hb_synth_fx = 0; } ELSE { hSCE->save_synth_fx = NULL; hSCE->save_hb_synth_fx = NULL; } -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED hSCE->hCoreCoder[0] = st; st_ivas->hSCE[sce_id] = hSCE; @@ -537,18 +461,6 @@ void destroy_sce_dec( st = NULL; } -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED - IF( hSCE->save_synth != NULL ) - { - free( hSCE->save_synth ); - hSCE->save_synth = NULL; - } - IF( hSCE->save_hb_synth != NULL ) - { - free( hSCE->save_hb_synth ); - hSCE->save_hb_synth = NULL; - } -#endif // IVAS_FLOAT_FIXED_TO_BE_REMOVED IF( hSCE->save_synth_fx != NULL ) { free( hSCE->save_synth_fx ); diff --git a/lib_dec/ivas_spar_decoder.c b/lib_dec/ivas_spar_decoder.c index 5f23d5dc7..ef3222b47 100644 --- a/lib_dec/ivas_spar_decoder.c +++ b/lib_dec/ivas_spar_decoder.c @@ -591,9 +591,9 @@ ivas_error ivas_spar_dec_fx( { Word32 tmp = 0; tmp = (Word32) ( q_direction->band_data[j].elevation[k] * ( 1 << 22 ) ); - if (GT_32(L_abs(sub(tmp, q_direction->band_data[j].elevation_fx[k])), 1 << Q5)) + if ( GT_32( L_abs( L_sub( tmp, q_direction->band_data[j].elevation_fx[k] ) ), 1 << Q5 ) ) { - assert(0); + assert( 0 ); } q_direction->band_data[j].elevation_fx[k] = (Word32) ( q_direction->band_data[j].elevation[k] * ( 1 << 22 ) ); q_direction->band_data[j].azimuth_fx[k] = (Word32) ( q_direction->band_data[j].azimuth[k] * ( 1 << 22 ) ); @@ -1549,10 +1549,6 @@ static ivas_error ivas_spar_dec_MD_fx( * Initialization *---------------------------------------------------------------------*/ -#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - Word16 i, j, k; -#endif - sba_order = s_min( st_ivas->sba_analysis_order, IVAS_MAX_SBA_ORDER ); bfi = st_ivas->bfi; move16(); @@ -1591,7 +1587,6 @@ static ivas_error ivas_spar_dec_MD_fx( move16(); } -// From here TBD IF( ( error = ivas_spar_md_dec_init( hSpar->hMdDec, hDecoderConfig, num_channels, sba_order ) ) != IVAS_ERR_OK ) { return error; @@ -1605,27 +1600,6 @@ static ivas_error ivas_spar_dec_MD_fx( ivas_spar_md_dec_process_fx( st_ivas, st0, num_bands_out, sba_order ); -// Till here TBD -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - // float to fix - Word16 num_channels_tmp = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - FOR( i = 0; i < num_channels_tmp; i++ ) - { - FOR( j = 0; j < num_channels_tmp; j++ ) - { - FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][k], Q22 ); - } - } - } -#endif - /*---------------------------------------------------------------------* * read PCA bits *---------------------------------------------------------------------*/ @@ -1666,76 +1640,17 @@ static ivas_error ivas_spar_dec_MD_fx( { ivas_spar_update_md_hist_fx( hSpar->hMdDec ); } - -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - // fix to float - Word16 num_channels_tmp = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - FOR( i = 0; i < num_channels_tmp; i++ ) - { - FOR( j = 0; j < num_channels_tmp; j++ ) - { - FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k], Q22 ); - } - } - } -#endif } ELSE { -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - // float to fix - Word16 num_channels_tmp = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - FOR( i = 0; i < num_channels_tmp; i++ ) - { - FOR( j = 0; j < num_channels_tmp; j++ ) - { - FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.C_re[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k] = floatToFixed( hSpar->hMdDec->spar_coeffs.P_re[i][j][k], Q22 ); - } - } - } -#endif - IF( !bfi ) { ivas_spar_smooth_md_dtx_fx( hSpar->hMdDec, num_bands_out, num_md_sub_frames ); } set_s( hSpar->hMdDec->valid_bands, 0, IVAS_MAX_NUM_BANDS ); -#if 0 //ndef IVAS_FLOAT_FIXED_TO_BE_REMOVED - Word16 num_channels_tmp = hSpar->hMdDec->spar_md_cfg.num_umx_chs; - FOR( i = 0; i < num_channels_tmp; i++ ) - { - FOR( j = 0; j < num_channels_tmp; j++ ) - { - FOR( k = 0; k < IVAS_MAX_NUM_BANDS; k++ ) - { - hSpar->hMdDec->spar_coeffs_prev.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.C_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_prev.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_prev.P_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.C_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs_tar.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs_tar.P_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.C_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.C_re_fx[i][j][k], Q22 ); - hSpar->hMdDec->spar_coeffs.P_re[i][j][k] = fixedToFloat( hSpar->hMdDec->spar_coeffs.P_re_fx[i][j][k], Q22 ); - } - } - } -#endif } - pop_wmops(); return IVAS_ERR_OK; } @@ -2999,7 +2914,6 @@ void ivas_spar_dec_upmixer_sf_fx( float *cldfb_in_ts_re[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; float *cldfb_in_ts_im[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][CLDFB_NO_COL_MAX]; float Pcm_tmp[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS][L_FRAME48k]; - float mixer_mat[IVAS_SPAR_MAX_CH][IVAS_SPAR_MAX_CH][IVAS_MAX_NUM_BANDS]; float output[MAX_OUTPUT_CHANNELS][L_FRAME48k]; float *p_output[MAX_OUTPUT_CHANNELS]; /*---------------------------------------------------------------------------*/ @@ -3020,7 +2934,7 @@ void ivas_spar_dec_upmixer_sf_fx( DECODER_CONFIG_HANDLE hDecoderConfig; SPAR_DEC_HANDLE hSpar; Word16 num_md_sub_frames; - Word16 q1 = 30,q2=30; + Word16 q1 = 30; push_wmops( "ivas_spar_dec_upmixer_sf" ); hSpar = st_ivas->hSpar; hDecoderConfig = st_ivas->hDecoderConfig; @@ -3185,7 +3099,7 @@ void ivas_spar_dec_upmixer_sf_fx( } #endif #if 1 - FOR( Word16 out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) + FOR( out_ch = 0; out_ch < numch_out_dirac; out_ch++ ) { IF( st_ivas->cldfbSynDec[out_ch] ) { diff --git a/lib_dec/ivas_spar_md_dec.c b/lib_dec/ivas_spar_md_dec.c index b37c4720f..858b542ce 100644 --- a/lib_dec/ivas_spar_md_dec.c +++ b/lib_dec/ivas_spar_md_dec.c @@ -962,7 +962,7 @@ ivas_error ivas_spar_md_dec_init( { int16_t i, j; int16_t nchan_transport; - Word32 pFC[IVAS_MAX_NUM_BANDS], PR_minmax[2]; + Word32 pFC[IVAS_MAX_NUM_BANDS]; Word32 *pFC_fx=NULL, PR_minmax_fx[2]; ivas_error error; @@ -4885,13 +4885,12 @@ void ivas_spar_to_dirac_fx( int16_t azi[IVAS_MAX_NUM_BANDS]; int16_t ele[IVAS_MAX_NUM_BANDS]; //float dvx[IVAS_MAX_NUM_BANDS], dvy[IVAS_MAX_NUM_BANDS], dvz[IVAS_MAX_NUM_BANDS]; - Word32 dvx_q, dvy_q, dvz_q; Word32 dvx_fx[IVAS_MAX_NUM_BANDS], dvy_fx[IVAS_MAX_NUM_BANDS], dvz_fx[IVAS_MAX_NUM_BANDS]; //float radius; - Word32 radius_fx,radius_q; + Word32 radius_fx; //float en_ratio, res_pow; Word32 en_ratio_fx, res_pow_fx; - Word32 en_ratio_q, res_pow_q; + Word16 en_ratio_q, res_pow_q; int16_t num_slots_in_subfr; int16_t tmp_write_idx_param_band; int16_t tmp_write_idx_band; @@ -5019,7 +5018,6 @@ void ivas_spar_to_dirac_fx( ele[band] = max(-90, min(180, ele_res)); } - Word16 en_ratio_q = 0; if (st_ivas->nchan_transport == 1) { //float w_en_norm, f_scale; diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index adf8e5727..33b101cb6 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -99,7 +99,6 @@ typedef struct stereo_dft_dec_data_struct int16_t dft_trigo_step; #ifdef IVAS_FLOAT_FIXED - Word32 ONE_NFFT; /* Size of DFT */ const Word16 *dft_trigo_fx; /* Q15 */ const Word16 *dft_trigo_12k8_fx; /* Q15 */ const Word16 *dft_trigo_16k_fx; /* Q15 */ @@ -416,45 +415,46 @@ typedef struct stereo_dft_dmx_out_data_structure typedef struct stereo_dec_cng { +#ifndef IVAS_FLOAT_FIXED float coh[STEREO_DFT_BAND_MAX + 1]; /* coherence */ float cm[STEREO_DFT_BAND_MAX]; /* cm */ -#ifdef IVAS_FLOAT_FIXED - Word16 cm_fx[STEREO_DFT_BAND_MAX]; /* cm */ - Word16 coh_fx[STEREO_DFT_BAND_MAX + 1]; /* coherence */ +#else + Word16 cm_fx[STEREO_DFT_BAND_MAX]; /* cm */ /* Q15 */ + Word16 coh_fx[STEREO_DFT_BAND_MAX + 1]; /* coherence */ /* Q15 */ #endif - int16_t first_SID; /* first SID indicator */ - int16_t first_SID_after_TD; /* first SID after TD-stereo indicator */ - int16_t prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ - int16_t last_tdm_idx; /* last tdm index */ + int16_t first_SID; /* first SID indicator */ + int16_t first_SID_after_TD; /* first SID after TD-stereo indicator */ + int16_t prev_sid_nodata; /* previous frame SID/FRAME_NO_DATA indicator */ + int16_t last_tdm_idx; /* last tdm index */ #ifndef IVAS_FLOAT_FIXED - float c_LR_LT; /* left right cross correlation */ + float c_LR_LT; /* left right cross correlation */ #else - Word32 c_LR_LT_fx; /* left right cross correlation */ /* Q31 */ + Word32 c_LR_LT_fx; /* left right cross correlation */ /* Q31 */ #endif - int16_t active_frame_counter; /* counter for active frames */ - int16_t xfade_frame_counter; /* xfade counter */ - int16_t xfade_length; /* number of frames to perform xfade */ - int16_t nr_dft_frames; /* dft frame counter */ - int16_t nr_corr_frames; /* correlation frame counter */ - int16_t nr_sid_frames; /* SID frame counter */ - int16_t last_act_element_mode; /* Element mode of last active frame */ + int16_t active_frame_counter; /* counter for active frames */ + int16_t xfade_frame_counter; /* xfade counter */ + int16_t xfade_length; /* number of frames to perform xfade */ + int16_t nr_dft_frames; /* dft frame counter */ + int16_t nr_corr_frames; /* correlation frame counter */ + int16_t nr_sid_frames; /* SID frame counter */ + int16_t last_act_element_mode; /* Element mode of last active frame */ #ifndef IVAS_FLOAT_FIXED - float olapBufferSynth22[FFTLEN]; /* overlap buffer for secondary channel CNA */ + float olapBufferSynth22[FFTLEN]; /* overlap buffer for secondary channel CNA */ #endif - Word16 olapBufferSynth22_fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ - Word32 olapBufferSynth22_32fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ - int16_t flag_cna_fade; /* flag enabling CNA fade out */ + Word16 olapBufferSynth22_fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ + Word32 olapBufferSynth22_32fx[FFTLEN]; /* overlap buffer for secondary channel CNA */ + int16_t flag_cna_fade; /* flag enabling CNA fade out */ #ifndef IVAS_FLOAT_FIXED - float maskingNoiseS[L_FRAME16k]; /* masking noise (CNA) for secondary channel */ + float maskingNoiseS[L_FRAME16k]; /* masking noise (CNA) for secondary channel */ #endif - Word16 maskingNoiseS_fx[L_FRAME16k]; /* masking noise (CNA) for secondary channel */ - int16_t enableSecCNA; /* flag enabling secondary channel CNA */ + Word16 maskingNoiseS_fx[L_FRAME16k]; /* masking noise (CNA) for secondary channel */ + int16_t enableSecCNA; /* flag enabling secondary channel CNA */ #ifndef IVAS_FLOAT_FIXED - float c_PS_LT; /* long term cross-correlation between primary and secondary channel */ + float c_PS_LT; /* long term cross-correlation between primary and secondary channel */ #endif - Word16 c_PS_LT_fx; /* long term cross-correlation between primary and secondary channel */ // Assumed Q15 for initialization. Can be modified later if reqd. - const int16_t *frameSize; /* Frame size in samples */ - const int16_t *fftlen; /* FFT length used for the decomposition */ + Word16 c_PS_LT_fx; /* long term cross-correlation between primary and secondary channel */ // Assumed Q15 for initialization. Can be modified later if reqd. + const int16_t *frameSize; /* Frame size in samples */ + const int16_t *fftlen; /* FFT length used for the decomposition */ } STEREO_CNG_DEC, *STEREO_CNG_DEC_HANDLE; @@ -871,7 +871,9 @@ typedef struct ivas_param_mc_dec_data_structure Word16 *icld_q_fx; #endif int16_t max_param_band_abs_cov; +#ifndef IVAS_FLOAT_FIXED float *ls_conv_dmx_matrix; +#endif float *proto_matrix_int; #ifdef IVAS_FLOAT_FIXED Word32 *proto_frame_f_fx; @@ -1092,9 +1094,9 @@ typedef struct sce_dec_data_structure DEC_CORE_HANDLE hCoreCoder[1]; #ifndef IVAS_FLOAT_FIXED float prev_hb_synth[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; /* HB synthesis synchro buffer */ -#endif float *save_synth; float *save_hb_synth; +#endif #ifdef IVAS_FLOAT_FIXED Word32 prev_hb_synth_fx[NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; /* HB synthesis synchro buffer */ @@ -1142,8 +1144,8 @@ typedef struct cpe_dec_data_structure #ifndef IVAS_FLOAT_FIXED float prev_hb_synth[CPE_CHANNELS][NS2SA( 48000, IVAS_DEC_DELAY_NS - DELAY_BWE_TOTAL_NS )]; float *prev_synth_chs[CPE_CHANNELS]; -#endif float prev_synth[CPE_CHANNELS][NS2SA( 48000, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS )]; +#endif /* DFT stereo I/O channel buffer memories that need to be updated for TD->DFT stereo switching */ #ifndef IVAS_FLOAT_FIXED @@ -1590,6 +1592,8 @@ typedef struct Decoder_Struct Word32 **mem_hp20_out_fx; Word32 *p_output_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* floating-point output audio buffers */ Word16 p_out_len;/*Stores the total no of channels for which memory is allocated to p_output_fx*/ + Word16 num_src; + Word16 SrcInd[MAX_NUM_TDREND_CHANNELS]; #endif } Decoder_Struct; diff --git a/lib_dec/ivas_stereo_cng_dec.c b/lib_dec/ivas_stereo_cng_dec.c index 6036f72d0..b549879e0 100644 --- a/lib_dec/ivas_stereo_cng_dec.c +++ b/lib_dec/ivas_stereo_cng_dec.c @@ -2325,12 +2325,15 @@ void stereo_cna_update_params_fx( return; } #endif + + /*------------------------------------------------------------------- * stereo_cng_init_dec() * * Initialized stereo CNG *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void stereo_cng_init_dec( STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ const int16_t *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 */ @@ -2348,18 +2351,16 @@ void stereo_cng_init_dec( hStereoCng->nr_corr_frames = 0; hStereoCng->nr_sid_frames = 0; hStereoCng->flag_cna_fade = 0; -#ifndef IVAS_FLOAT_FIXED set_f( hStereoCng->olapBufferSynth22, 0.0f, FFTLEN ); set_zero( hStereoCng->maskingNoiseS, L_FRAME16k ); hStereoCng->c_PS_LT = 0.5f; -#endif hStereoCng->enableSecCNA = 0; hStereoCng->frameSize = frameSize; hStereoCng->last_act_element_mode = IVAS_CPE_DFT; return; } -#ifdef IVAS_FLOAT_FIXED +#else void stereo_cng_init_dec_fx( STEREO_CNG_DEC_HANDLE hStereoCng, /* i/o: stereo CNG decoder structure */ const Word16 *frameSize /* i : pointer to frameSize of channel 0 to be used for channel 1 */ @@ -2397,13 +2398,6 @@ void stereo_cng_init_dec_fx( hStereoCng->last_act_element_mode = IVAS_CPE_DFT; move16(); -#if 1 - //set_f( hStereoCng->olapBufferSynth22, 0.0f, FFTLEN ); - set_f( hStereoCng->coh, 0.5f, STEREO_DFT_BAND_MAX + 1 ); - set_zero( hStereoCng->cm, STEREO_DFT_BAND_MAX ); - //hStereoCng->c_PS_LT = 0.5f; -#endif - return; } #endif diff --git a/lib_dec/ivas_stereo_dft_dec.c b/lib_dec/ivas_stereo_dft_dec.c index 680b25b0d..711269dc5 100644 --- a/lib_dec/ivas_stereo_dft_dec.c +++ b/lib_dec/ivas_stereo_dft_dec.c @@ -251,62 +251,8 @@ void stereo_dft_dequantize_itd( * Create DFT stereo handle *------------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error stereo_dft_dec_create( -#ifdef IVAS_FLOAT_FIXED - STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const Word16 nchan_transport /* i : number of transport channels */ -) -{ - STEREO_DFT_DEC_DATA_HANDLE hStereoDft_loc; - Word16 tmpS; - - IF ( *hStereoDft != NULL ) - { - return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: DFT Stereo memory already allocated\n" ); - } - - IF ( ( hStereoDft_loc = (STEREO_DFT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_DFT_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT Stereo\n" ) ); - } - - IF ( ( hStereoDft_loc->hConfig = (STEREO_DFT_CONFIG_DATA_HANDLE) malloc( sizeof( STEREO_DFT_CONFIG_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT Stereo Config\n" ) ); - } - - IF ( ( hStereoDft_loc->hBpf = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF handle\n" ) ); - } - - IF ( ( hStereoDft_loc->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) - { - return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); - } - - hStereoDft_loc->hConfig->force_mono_transmission = 0; - move16(); - - IF ( sba_dirac_stereo_flag ) - { - ivas_sba_dirac_stereo_config( hStereoDft_loc->hConfig ); - } - ELSE - { - stereo_dft_config( hStereoDft_loc->hConfig, element_brate, &tmpS, &tmpS ); - } - - stereo_dft_dec_open( hStereoDft_loc, output_Fs, nchan_transport ); - - *hStereoDft = hStereoDft_loc; - - return IVAS_ERR_OK; -} -#else STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ const int32_t element_brate, /* i : element bitrate */ const int32_t output_Fs, /* i : output sampling rate */ @@ -368,102 +314,7 @@ ivas_error stereo_dft_dec_create( * Open DFT decoder stereo handle *-------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -void stereo_dft_dec_open( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 nchan_transport /* i : number of transport channels */ -) -{ - /*Sizes*/ - hStereoDft->N = (Word16) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); - - /*Init. DFT sizes*/ - hStereoDft->NFFT = (Word16) ( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); - - SWITCH (output_Fs) - { - case 48000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00222222 ); - BREAK; - case 32000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00333333 ); - BREAK; - case 16000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00666666 ); - BREAK; - case 8000: - hStereoDft->ONE_NFFT = (Word32) ( 0x00CCCCCC ); - BREAK; - default: - assert(0); - } - hStereoDft->dft_trigo_8k_fx = dft_trigo_32k_fx; - hStereoDft->dft_trigo_12k8_fx = dft_trigo_12k8_fx; - hStereoDft->dft_trigo_16k_fx = dft_trigo_32k_fx; - - hStereoDft->dft32ms_ovl = (Word16) ( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); - hStereoDft->win232ms_8k_fx = dft_win232ms_8k_fx; - hStereoDft->win232ms_12k8_fx = dft_win232ms_12k8_fx; - hStereoDft->win232ms_16k_fx = dft_win232ms_16k_fx; - - hStereoDft->dft32ms_ovl2 = (Word16) ( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); - hStereoDft->win32ms_8k_fx = dft_win232ms_8k_fx + 1; - hStereoDft->win32ms_12k8_fx = dft_win232ms_12k8_fx + 1; - hStereoDft->win32ms_16k_fx = dft_win232ms_16k_fx + 1; - - - IF ( EQ_32( output_Fs, 16000 ) ) - { - hStereoDft->dft_trigo_fx = dft_trigo_32k_fx; - hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP; - hStereoDft->win232ms_fx = dft_win232ms_16k_fx; - hStereoDft->win32ms_fx = dft_win232ms_16k_fx + 1; - } - ELSE IF ( EQ_32( output_Fs, 32000 ) ) - { - hStereoDft->dft_trigo_fx = dft_trigo_32k_fx; - hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP; - hStereoDft->win232ms_fx = dft_win232ms_32k_fx; - hStereoDft->win32ms_fx = dft_win232ms_32k_fx + 1; - } - ELSE - { - assert( EQ_32( output_Fs, 48000 ) ); - - hStereoDft->dft_trigo_fx = dft_trigo_48k_fx; - hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_48k_STEP; - hStereoDft->win232ms_fx = dft_win232ms_48k_fx; - hStereoDft->win32ms_fx = dft_win232ms_48k_fx + 1; - } - - hStereoDft->win_8k_fx = dft_win_8k_fx; - - /*Bands: find the number of bands, Nyquist freq. is not taken into account*/ - set_s( hStereoDft->band_res, hStereoDft->hConfig->band_res, STEREO_DFT_DEC_DFT_NB ); - - hStereoDft->nbands = stereo_dft_band_config_fx( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); - hStereoDft->hb_stefi_delay = NS2SA( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); - - IF ( GT_16( nchan_transport, 2 ) ) - { - hStereoDft->min_smooth_gains_fx = min_smooth_gains2_fx; - hStereoDft->max_smooth_gains_fx = max_smooth_gains2_fx; - } - ELSE - { - hStereoDft->min_smooth_gains_fx = min_smooth_gains1_fx; - hStereoDft->max_smooth_gains_fx = max_smooth_gains1_fx; - } - hStereoDft->q_hb_stefi_sig_fx = Q31; - hStereoDft->q_ap_fade_mem_fx = Q31; - - /* reset DFT stereo memories */ - stereo_dft_dec_reset( hStereoDft ); - - return; -} -#else +#ifndef IVAS_FLOAT_FIXED void stereo_dft_dec_open( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ const int32_t output_Fs, /* i : output sampling rate */ @@ -546,324 +397,7 @@ void stereo_dft_dec_open( * Reset DFT stereo memories *------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -void stereo_dft_dec_reset( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */ -) -{ - int16_t i; - int16_t j, b; - - /*Configuration*/ - set_s( hStereoDft->prm_res, hStereoDft->hConfig->prm_res, STEREO_DFT_DEC_DFT_NB ); - - /* SIDE_GAIN */ - set_s( hStereoDft->side_gain_index, 15, STEREO_DFT_BAND_MAX ); - set_s( hStereoDft->side_gain_index_previous, 15, STEREO_DFT_BAND_MAX ); - - /*residual prediction*/ - set_s( hStereoDft->res_pred_mode, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_DEC_DFT_NB ); - for ( i = 0; i < STEREO_DFT_PAST_MAX; i++ ) - { -#ifndef IVAS_FLOAT_FIXED - set_zero( hStereoDft->DFT_past_DMX[i], STEREO_DFT32MS_N_32k ); - set_zero( hStereoDft->past_res_pred_gain[i], STEREO_DFT_BAND_MAX ); -#else - set32_fx( hStereoDft->DFT_past_DMX_fx[i], 0, STEREO_DFT_BAND_MAX ); - set32_fx( hStereoDft->past_res_pred_gain_fx[i], 0, STEREO_DFT_BAND_MAX ); -#endif - } - -#ifdef IVAS_FLOAT_FIXED - FOR ( i = 0; i < STEREO_DFT_PAST_MAX; i++ ) - { - set_val_Word32( hStereoDft->DFT_past_DMX_fx[i], 0, STEREO_DFT32MS_N_32k ); - set_val_Word32( hStereoDft->past_res_pred_gain_fx[i], 0, STEREO_DFT_BAND_MAX ); - hStereoDft->q_DFT_past_DMX_fx[i] = 0; - } -#endif - - hStereoDft->past_DMX_pos = 0; - - set_s( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX ); - -#ifndef IVAS_FLOAT_FIXED - for ( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) - { - hStereoDft->res_gains_ind[0][i] = 15.f; - } - - set_zero( hStereoDft->res_gains_ind[1], STEREO_DFT_BAND_MAX ); -#else - FOR( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) - { - hStereoDft->res_gains_ind_fx[0][i] = 1006632960; /* 15.0f in Q26 */ - } - - set_val_Word32( hStereoDft->res_gains_ind_fx[1], 0, STEREO_DFT_BAND_MAX ); -#endif - - /*residual coding*/ - set_s( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB ); - hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->hConfig->band_res][hStereoDft->hConfig->res_cod_mode]; -#ifndef IVAS_FLOAT_FIXED - set_zero( hStereoDft->res_cod_mem, STEREO_DFT_OVL_8k ); -#else - set_l( hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); - hStereoDft->q_res_cod_mem_fx = Q16; -#endif - - hStereoDft->res_pred_band_min = max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max ); - -#ifndef IVAS_FLOAT_FIXED - hStereoDft->stab_fac_smooth_res = 0.f; -#else - hStereoDft->stab_fac_smooth_res_fx = 0; -#endif -#ifdef IVAS_FLOAT_FIXED - bass_psfilter_init_fx(hStereoDft->hBpf); -#endif - tcxltp_dec_init( hStereoDft->hTcxLtpDec, 0, MODE1, IVAS_CPE_DFT, PIT_MAX, 12800 ); - - hStereoDft->reverb_flag = 0; - -#ifndef IVAS_FLOAT_FIXED - hStereoDft->bpf_error_signal_last = 0.0f; - hStereoDft->bpf_error_ratio_mem = 1.0f; - hStereoDft->res_hb_nrg_mem = 0.0f; -#else - hStereoDft->res_hb_nrg_mem_fx = 0; - hStereoDft->bpf_error_signal_last_fx = 0; - hStereoDft->bpf_error_ratio_mem_fx = ONE_IN_Q13; -#endif // IVAS_FLOAT_FIXED - - /*reset parameters*/ -#ifndef IVAS_FLOAT_FIXED - set_zero( hStereoDft->side_gain, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); - set_zero( hStereoDft->gipd, STEREO_DFT_DEC_DFT_NB ); - set_zero( hStereoDft->itd, STEREO_DFT_DEC_DFT_NB ); - set_zero( hStereoDft->res_pred_gain, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); -#else - set32_fx( hStereoDft->side_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); - set32_fx( hStereoDft->gipd_fx, 0, STEREO_DFT_DEC_DFT_NB ); - set32_fx( hStereoDft->itd_fx, 0, STEREO_DFT_DEC_DFT_NB ); - set32_fx( hStereoDft->res_pred_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); -#endif - -#ifdef IVAS_FLOAT_FIXED - /*reset parameters*/ - set_val_Word32( hStereoDft->side_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); - set_val_Word32( hStereoDft->gipd_fx, 0, STEREO_DFT_DEC_DFT_NB ); - set_val_Word32( hStereoDft->itd_fx, 0, STEREO_DFT_DEC_DFT_NB ); - set_val_Word32( hStereoDft->res_pred_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); -#endif - - hStereoDft->wasTransient = 0; - hStereoDft->attackPresent = 0; - -#ifndef IVAS_FLOAT_FIXED - hStereoDft->lt_pred_gain = 0.0f; - hStereoDft->lt_pred_gain_variation = 0.0f; - hStereoDft->lt_var_mean_ratio = STEREO_DFT_RES_RATIO_LIMIT; - hStereoDft->stefi_short_gain = 1.0f; - hStereoDft->stefi_long_gain = 0.0f; -#else - hStereoDft->lt_pred_gain_fx = 0; - hStereoDft->lt_pred_gain_variation_fx = 0; - hStereoDft->lt_var_mean_ratio_fx = STEREO_DFT_RES_RATIO_LIMIT_FX; - hStereoDft->stefi_short_gain_fx = MAX_16; - hStereoDft->stefi_long_gain_fx = 0; - hStereoDft->q_lt_pred_gain = 0; -#endif - -#ifdef IVAS_FLOAT_FIXED - set_val_Word16( hStereoDft->g_state_fx, 0, STEREO_DFT_BAND_MAX ); - init_basic_allpass_fx( &hStereoDft->ap1, dft_ap_gains_fx[0], dft_ap_delays[0] ); - init_basic_allpass_fx( &hStereoDft->ap2, dft_ap_gains_fx[1], dft_ap_delays[1] ); - init_basic_allpass_fx( &hStereoDft->ap3, dft_ap_gains_fx[2], dft_ap_delays[2] ); -#else - set_zero( hStereoDft->g_state, STEREO_DFT_BAND_MAX ); - init_basic_allpass( &hStereoDft->ap1, dft_ap_gains[0], dft_ap_delays[0] ); - init_basic_allpass( &hStereoDft->ap2, dft_ap_gains[1], dft_ap_delays[1] ); - init_basic_allpass( &hStereoDft->ap3, dft_ap_gains[2], dft_ap_delays[2] ); -#endif - -#ifdef IVAS_FLOAT_FIXED - set32_fx( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - set32_fx( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); - hStereoDft->q_ap_delay_mem_fx = Q11; -#else - set_zero( hStereoDft->ap_delay_mem, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - set_zero( hStereoDft->ap_fade_mem, STEREO_DFT_ALLPASS_FADELEN_16k ); -#endif - hStereoDft->ap_wasTransient = 0; -#ifdef IVAS_FLOAT_FIXED - set32_fx( hStereoDft->smooth_dmx_nrg_fx, 0, STEREO_DFT_BAND_MAX ); - set32_fx( hStereoDft->smooth_res_nrg_fx, 0, STEREO_DFT_BAND_MAX ); -#else - set_zero(hStereoDft->smooth_dmx_nrg, STEREO_DFT_BAND_MAX); - set_zero(hStereoDft->smooth_res_nrg, STEREO_DFT_BAND_MAX); -#endif - - set_s( hStereoDft->core_hist, ACELP_CORE, STEREO_DFT_CORE_HIST_MAX ); - - //set_zero( hStereoDft->hb_stefi_sig, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); - //set_zero( hStereoDft->hb_nrg, STEREO_DFT_CORE_HIST_MAX ); - //set_zero( hStereoDft->td_gain, STEREO_DFT_CORE_HIST_MAX ); - -#ifdef IVAS_FLOAT_FIXED - set32_fx(hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA(48000, STEREO_DFT_TD_STEFI_DELAY_NS)); - set32_fx(hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX); -#endif - - /* PLC parameters */ -#ifdef IVAS_FLOAT_FIXED - set32_fx( hStereoDft->res_mem_fx, 0, STEREO_DFT_RES_BW_MAX ); -#else - set_zero( hStereoDft->res_mem, STEREO_DFT_RES_BW_MAX ); -#endif - hStereoDft->time_offs = 0; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->past_dmx_nrg_fx = 0; - hStereoDft->sg_mean_fx = 0; -#else - hStereoDft->past_dmx_nrg = 0; - hStereoDft->sg_mean = 0.0f; -#endif - hStereoDft->sg_mem_corrupt = 0; - hStereoDft->recovery_flg = 0; - #ifndef IVAS_FLOAT_FIXED - for ( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) - { - set_zero( hStereoDft->smooth_buf[i], SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - set_zero( hStereoDft->smooth_fac[0], SBA_DIRAC_STEREO_NUM_BANDS ); - set_zero( hStereoDft->smooth_fac[1], SBA_DIRAC_STEREO_NUM_BANDS ); -#else - FOR( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) - { - set32_fx( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - hStereoDft->q_smooth_buf_fx = Q7; - set16_fx( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); - set16_fx( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); -#endif - -#ifdef IVAS_FLOAT_FIXED - hStereoDft->itd_xfade_target_fx = 0; - hStereoDft->itd_xfade_step_fx = 0; -#else - hStereoDft->itd_xfade_target = 0.0f; - hStereoDft->itd_xfade_step = 0.0f; -#endif - hStereoDft->itd_xfade_counter = 0; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->itd_xfade_prev_fx = 0; -#else - hStereoDft->itd_xfade_prev = 0.0f; -#endif - hStereoDft->last_active_element_brate = 0; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->ipd_xfade_target_fx = 0; - hStereoDft->ipd_xfade_step_fx = 0; -#else - hStereoDft->ipd_xfade_target = 0.0f; - hStereoDft->ipd_xfade_step = 0.0f; -#endif - hStereoDft->ipd_xfade_counter = 0; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->ipd_xfade_prev_fx = 0; -#else - hStereoDft->ipd_xfade_prev = 0.0f; -#endif - -#ifdef IVAS_FLOAT_FIXED - FOR( b = 0; b < hStereoDft->nbands; b++ ) - { - FOR( i = 0; i < 2; i++ ) - { - FOR( j = 0; j < 4; j++ ) - { - hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; - } - } - } -#else - for ( b = 0; b < hStereoDft->nbands; b++ ) - { - for ( i = 0; i < 2; i++ ) - { - for ( j = 0; j < 4; j++ ) - { - hStereoDft->mixer_mat_smooth[i][j][b] = 0.0f; - } - } - } -#endif - hStereoDft->first_frame = 1; -#ifdef IVAS_FLOAT_FIXED - hStereoDft->g_L_prev_fx = 0; - hStereoDft->g_R_prev_fx = 0; -#else - hStereoDft->g_L_prev = 0.f; - hStereoDft->g_R_prev = 0.f; -#endif - -#ifdef IVAS_FLOAT_FIXED - set_val_Word32( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - set_val_Word32( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); - set_val_Word32( hStereoDft->smooth_dmx_nrg_fx, 0, STEREO_DFT_BAND_MAX ); - set_val_Word32( hStereoDft->smooth_res_nrg_fx, 0, STEREO_DFT_BAND_MAX ); - - set_s( hStereoDft->core_hist, ACELP_CORE, STEREO_DFT_CORE_HIST_MAX ); - - set_val_Word32( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); - set_val_Word32( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX ); - set_val_Word32( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX ); - set_val_Word32( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX ); - - /* PLC parameters */ - set_val_Word32( hStereoDft->res_mem_fx, 0, STEREO_DFT_RES_BW_MAX ); - hStereoDft->past_dmx_nrg_fx = 0; - hStereoDft->sg_mean_fx = 0; - hStereoDft->q_dft = 0; - hStereoDft->q_smoothed_nrg = 0; - - FOR ( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) - { - set_val_Word32( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); - } - hStereoDft->q_smooth_buf_fx = Q7; - set_val_Word16( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); - set_val_Word16( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); - - hStereoDft->itd_xfade_target_fx = 0; - hStereoDft->itd_xfade_step_fx = 0; - hStereoDft->itd_xfade_prev_fx = 0; - hStereoDft->ipd_xfade_target_fx = 0; - hStereoDft->ipd_xfade_step_fx = 0; - hStereoDft->ipd_xfade_prev_fx = 0; - - FOR ( b = 0; b < hStereoDft->nbands; b++ ) - { - FOR ( i = 0; i < 2; i++ ) - { - FOR ( j = 0; j < 4; j++ ) - { - hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; - } - } - } - hStereoDft->g_L_prev_fx = 0; - hStereoDft->g_R_prev_fx = 0; -#endif - - return; -} - -#else - void stereo_dft_dec_reset( STEREO_DFT_DEC_DATA_HANDLE hStereoDft /* i/o: decoder DFT stereo handle */ ) @@ -996,114 +530,7 @@ void stereo_dft_dec_reset( * * Update DFT memories for new frame *-------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED -void stereo_dft_dec_update( - STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const int16_t output_frame, /* i : output frame length */ - const int16_t sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ -) -{ - int16_t b, i, k_offset; - - /* Initialization */ - k_offset = STEREO_DFT_OFFSET; /*Add an offset*/ - - /* Update parameters */ -#ifndef IVAS_FLOAT_FIXED - for ( i = 0; i < k_offset * STEREO_DFT_BAND_MAX; i++ ) - { - hStereoDft->side_gain[i] = hStereoDft->side_gain[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i]; - hStereoDft->res_pred_gain[i] = hStereoDft->res_pred_gain[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i]; - } -#else - FOR( i = 0; i < k_offset * STEREO_DFT_BAND_MAX; i++ ) - { - hStereoDft->side_gain_fx[i] = hStereoDft->side_gain_fx[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i]; - hStereoDft->res_pred_gain_fx[i] = hStereoDft->res_pred_gain_fx[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i]; - } -#endif - -#ifndef IVAS_FLOAT_FIXED - for ( i = 0; i < k_offset; i++ ) - { - hStereoDft->gipd[i] = hStereoDft->gipd[STEREO_DFT_NBDIV + i]; - } -#else - FOR(i = 0; i < k_offset; i++) - { - hStereoDft->gipd_fx[i] = hStereoDft->gipd_fx[STEREO_DFT_NBDIV + i]; - } -#endif - - /* Update configuration memories */ - for ( i = 0; i < k_offset; i++ ) - { - hStereoDft->band_res[i] = hStereoDft->band_res[i + STEREO_DFT_NBDIV]; - hStereoDft->prm_res[i] = hStereoDft->prm_res[i + STEREO_DFT_NBDIV]; -#ifndef IVAS_FLOAT_FIXED - hStereoDft->itd[i] = hStereoDft->itd[STEREO_DFT_NBDIV + i]; -#else - hStereoDft->itd_fx[i] = hStereoDft->itd_fx[STEREO_DFT_NBDIV + i]; -#endif - hStereoDft->res_cod_mode[i] = hStereoDft->res_cod_mode[i + STEREO_DFT_NBDIV]; - hStereoDft->res_pred_mode[i] = hStereoDft->res_pred_mode[i + STEREO_DFT_NBDIV]; - } - - /* Load new configurations */ - set_s( hStereoDft->band_res + k_offset, hStereoDft->hConfig->band_res, STEREO_DFT_NBDIV ); - set_s( hStereoDft->prm_res + k_offset, hStereoDft->hConfig->prm_res, STEREO_DFT_NBDIV ); - set_s( hStereoDft->res_pred_mode + k_offset, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_NBDIV ); - set_s( hStereoDft->res_cod_mode + k_offset, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_NBDIV ); - - /*Update attack info*/ - if ( hStereoDft->attackPresent ) - { - hStereoDft->wasTransient = 1; - } - else if ( hStereoDft->wasTransient ) - { - hStereoDft->wasTransient = 0; - } - - for ( i = STEREO_DFT_CORE_HIST_MAX - 1; i > 0; i-- ) - { - hStereoDft->core_hist[i] = hStereoDft->core_hist[i - 1]; - } - - //mvr2r( hStereoDft->hb_stefi_sig + output_frame, hStereoDft->hb_stefi_sig, hStereoDft->hb_stefi_delay ); - //mvr2r( hStereoDft->hb_nrg, hStereoDft->hb_nrg + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); - //mvr2r( hStereoDft->td_gain, hStereoDft->td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); - #ifndef IVAS_FLOAT_FIXED - if ( sba_dirac_stereo_flag ) - { - /* buffer update, push back by 2 because of 2 subframes */ - for ( b = 0; b < hStereoDft->nbands; b++ ) - { - for ( i = SBA_DIRAC_NRG_SMOOTH_LONG; i > 1; i-- ) - { - hStereoDft->smooth_buf[b][i] = hStereoDft->smooth_buf[b][i - 2]; - } - } - } -#else - IF( sba_dirac_stereo_flag ) - { - /* buffer update, push back by 2 because of 2 subframes */ - FOR( b = 0; b < hStereoDft->nbands; b++ ) - { - FOR( i = SBA_DIRAC_NRG_SMOOTH_LONG; i > 1; i-- ) - { - hStereoDft->smooth_buf_fx[b][i] = hStereoDft->smooth_buf_fx[b][i - 2]; - } - } - } -#endif - - return; -} -#else - void stereo_dft_dec_update( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ const int16_t output_frame, /* i : output frame length */ diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index 14122fe14..7b3acb1ce 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -107,11 +107,12 @@ void stereo_dft_dec_reset_fx( /*residual prediction*/ set_s( hStereoDft->res_pred_mode, hStereoDft->hConfig->res_pred_mode, STEREO_DFT_DEC_DFT_NB ); - FOR ( i = 0; i < STEREO_DFT_PAST_MAX; i++ ) + FOR( i = 0; i < STEREO_DFT_PAST_MAX; i++ ) { - set_val_Word32( hStereoDft->DFT_past_DMX_fx[i], 0, STEREO_DFT32MS_N_32k ); - set_val_Word32( hStereoDft->past_res_pred_gain_fx[i], 0, STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->DFT_past_DMX_fx[i], 0, STEREO_DFT32MS_N_32k ); + set32_fx( hStereoDft->past_res_pred_gain_fx[i], 0, STEREO_DFT_BAND_MAX ); hStereoDft->q_DFT_past_DMX_fx[i] = 0; + move16(); } hStereoDft->past_DMX_pos = 0; @@ -119,28 +120,28 @@ void stereo_dft_dec_reset_fx( set_s( hStereoDft->res_pred_index_previous, 0, STEREO_DFT_BAND_MAX ); - FOR ( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) + FOR( i = 0; i < STEREO_DFT_BAND_MAX; i++ ) { - hStereoDft->res_gains_ind_fx[0][i] = (Word32)0x3C000000; + hStereoDft->res_gains_ind_fx[0][i] = 1006632960; /* 15.0f in Q26 */ move32(); } - set_val_Word32( hStereoDft->res_gains_ind_fx[1], 0, STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->res_gains_ind_fx[1], 0, STEREO_DFT_BAND_MAX ); /*residual coding*/ set_s( hStereoDft->res_cod_mode, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_DEC_DFT_NB ); hStereoDft->res_cod_band_max = dft_band_res_cod[hStereoDft->hConfig->band_res][hStereoDft->hConfig->res_cod_mode]; - set_val_Word32( hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); + set32_fx( hStereoDft->res_cod_mem_fx, 0, STEREO_DFT_OVL_8k ); hStereoDft->q_res_cod_mem_fx = Q16; + move16(); hStereoDft->res_pred_band_min = s_max( STEREO_DFT_RES_PRED_BAND_MIN, hStereoDft->res_cod_band_max ); move32(); hStereoDft->stab_fac_smooth_res_fx = 0; move16(); -#ifndef IVAS_FLOAT_FIXED - bass_psfilter_init( hStereoDft->hBpf ); -#endif + bass_psfilter_init_fx( hStereoDft->hBpf ); + tcxltp_dec_init( hStereoDft->hTcxLtpDec, 0, MODE1, IVAS_CPE_DFT, PIT_MAX, 12800 ); hStereoDft->reverb_flag = 0; @@ -154,10 +155,10 @@ void stereo_dft_dec_reset_fx( move16(); /*reset parameters*/ - set_val_Word32( hStereoDft->side_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); - set_val_Word32( hStereoDft->gipd_fx, 0, STEREO_DFT_DEC_DFT_NB ); - set_val_Word32( hStereoDft->itd_fx, 0, STEREO_DFT_DEC_DFT_NB ); - set_val_Word32( hStereoDft->res_pred_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->side_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->gipd_fx, 0, STEREO_DFT_DEC_DFT_NB ); + set32_fx( hStereoDft->itd_fx, 0, STEREO_DFT_DEC_DFT_NB ); + set32_fx( hStereoDft->res_pred_gain_fx, 0, STEREO_DFT_DEC_DFT_NB * STEREO_DFT_BAND_MAX ); hStereoDft->wasTransient = 0; move16(); @@ -165,36 +166,47 @@ void stereo_dft_dec_reset_fx( move16(); hStereoDft->lt_pred_gain_fx = 0; + move32(); hStereoDft->lt_pred_gain_variation_fx = 0; + move32(); hStereoDft->lt_var_mean_ratio_fx = STEREO_DFT_RES_RATIO_LIMIT_FX; + move32(); hStereoDft->stefi_short_gain_fx = MAX_16; + move16(); hStereoDft->stefi_long_gain_fx = 0; + move16(); hStereoDft->q_lt_pred_gain = 0; + move16(); - set_val_Word16( &hStereoDft->g_state_fx[0], 0, STEREO_DFT_BAND_MAX ); + set16_fx( &hStereoDft->g_state_fx[0], 0, STEREO_DFT_BAND_MAX ); init_basic_allpass_fx( &hStereoDft->ap1, dft_ap_gains_fx[0], dft_ap_delays[0] ); init_basic_allpass_fx( &hStereoDft->ap2, dft_ap_gains_fx[1], dft_ap_delays[1] ); init_basic_allpass_fx( &hStereoDft->ap3, dft_ap_gains_fx[2], dft_ap_delays[2] ); - set_val_Word32( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); - set_val_Word32( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); + set32_fx( hStereoDft->ap_delay_mem_fx, 0, NS2SA( 16000, DELAY_BWE_TOTAL_NS ) ); + set32_fx( hStereoDft->ap_fade_mem_fx, 0, STEREO_DFT_ALLPASS_FADELEN_16k ); hStereoDft->q_ap_delay_mem_fx = Q11; move16(); hStereoDft->ap_wasTransient = 0; move16(); - set_val_Word32( hStereoDft->smooth_dmx_nrg_fx, 0, STEREO_DFT_BAND_MAX ); - set_val_Word32( hStereoDft->smooth_res_nrg_fx, 0, STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->smooth_dmx_nrg_fx, 0, STEREO_DFT_BAND_MAX ); + set32_fx( hStereoDft->smooth_res_nrg_fx, 0, STEREO_DFT_BAND_MAX ); + hStereoDft->q_smoothed_nrg = 0; + move16(); set_s( hStereoDft->core_hist, ACELP_CORE, STEREO_DFT_CORE_HIST_MAX ); - set_val_Word32( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); - set_val_Word32( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX ); - set_val_Word32( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX ); - set_val_Word32( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX ); + set32_fx( hStereoDft->hb_stefi_sig_fx, 0, L_FRAME48k + NS2SA( 48000, STEREO_DFT_TD_STEFI_DELAY_NS ) ); + set32_fx( hStereoDft->hb_nrg_fx, 0, STEREO_DFT_CORE_HIST_MAX ); + set32_fx( hStereoDft->td_gain_fx, 0, STEREO_DFT_CORE_HIST_MAX ); + set32_fx( hStereoDft->q_td_gain, 0, STEREO_DFT_CORE_HIST_MAX ); + + hStereoDft->q_dft = 0; + move16(); /* PLC parameters */ - set_val_Word32( hStereoDft->res_mem_fx, 0, STEREO_DFT_RES_BW_MAX ); + set32_fx( hStereoDft->res_mem_fx, 0, STEREO_DFT_RES_BW_MAX ); hStereoDft->time_offs = 0; move16(); hStereoDft->past_dmx_nrg_fx = 0; @@ -206,37 +218,51 @@ void stereo_dft_dec_reset_fx( hStereoDft->recovery_flg = 0; move16(); - FOR ( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) + FOR( i = 0; i < SBA_DIRAC_STEREO_NUM_BANDS; i++ ) { - set_val_Word32( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); + set32_fx( hStereoDft->smooth_buf_fx[i], 0, SBA_DIRAC_NRG_SMOOTH_LONG + 1 ); } hStereoDft->q_smooth_buf_fx = Q7; - set_val_Word16( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); - set_val_Word16( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); + move16(); + set16_fx( hStereoDft->smooth_fac_fx[0], 0, SBA_DIRAC_STEREO_NUM_BANDS ); + set16_fx( hStereoDft->smooth_fac_fx[1], 0, SBA_DIRAC_STEREO_NUM_BANDS ); - hStereoDft->itd_xfade_target_fx = 0; move32(); - hStereoDft->itd_xfade_step_fx = 0; move32(); - hStereoDft->itd_xfade_counter = 0; move16(); - hStereoDft->itd_xfade_prev_fx = 0; move32(); - hStereoDft->last_active_element_brate = 0; move32(); - hStereoDft->ipd_xfade_target_fx = 0; move32(); - hStereoDft->ipd_xfade_step_fx = 0; move32(); - hStereoDft->ipd_xfade_counter = 0; move16(); - hStereoDft->ipd_xfade_prev_fx = 0; move32(); + hStereoDft->itd_xfade_target_fx = 0; + move32(); + hStereoDft->itd_xfade_step_fx = 0; + move32(); + hStereoDft->itd_xfade_counter = 0; + move16(); + hStereoDft->itd_xfade_prev_fx = 0; + move32(); + hStereoDft->last_active_element_brate = 0; + move32(); + hStereoDft->ipd_xfade_target_fx = 0; + move32(); + hStereoDft->ipd_xfade_step_fx = 0; + move32(); + hStereoDft->ipd_xfade_counter = 0; + move16(); + hStereoDft->ipd_xfade_prev_fx = 0; + move32(); - FOR ( b = 0; b < hStereoDft->nbands; b++ ) + FOR( b = 0; b < hStereoDft->nbands; b++ ) { - FOR ( i = 0; i < 2; i++ ) + FOR( i = 0; i < 2; i++ ) { - FOR ( j = 0; j < 4; j++ ) + FOR( j = 0; j < 4; j++ ) { - hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; move32(); + hStereoDft->mixer_mat_smooth_fx[i][j][b] = 0; + move32(); } } } - hStereoDft->first_frame = 1; move16(); - hStereoDft->g_L_prev_fx = 0; move32(); - hStereoDft->g_R_prev_fx = 0; move32(); + hStereoDft->first_frame = 1; + move16(); + hStereoDft->g_L_prev_fx = 0; + move32(); + hStereoDft->g_R_prev_fx = 0; + move32(); return; } @@ -249,41 +275,43 @@ void stereo_dft_dec_reset_fx( static void stereo_dft_dec_open_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 nchan_transport /* i : number of transport channels */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 nchan_transport /* i : number of transport channels */ ) { /*Sizes*/ - hStereoDft->N = (int16_t) ( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); + hStereoDft->N = extract_l( STEREO_DFT_HOP_MAX * output_Fs / 48000 ); /*Init. DFT sizes*/ - hStereoDft->NFFT = (int16_t) ( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); + hStereoDft->NFFT = extract_l( STEREO_DFT32MS_N_MAX * output_Fs / 48000 ); hStereoDft->dft_trigo_8k_fx = dft_trigo_32k_fx; hStereoDft->dft_trigo_12k8_fx = dft_trigo_12k8_fx; hStereoDft->dft_trigo_16k_fx = dft_trigo_32k_fx; - hStereoDft->dft32ms_ovl = (int16_t) ( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); + hStereoDft->dft32ms_ovl = extract_l( ( STEREO_DFT32MS_OVL_MAX * output_Fs ) / 48000 ); hStereoDft->win232ms_8k_fx = dft_win232ms_8k_fx; hStereoDft->win232ms_12k8_fx = dft_win232ms_12k8_fx; hStereoDft->win232ms_16k_fx = dft_win232ms_16k_fx; - hStereoDft->dft32ms_ovl2 = (int16_t) ( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); + hStereoDft->dft32ms_ovl2 = extract_l( ( STEREO_DFT32MS_OVL2_MAX * output_Fs ) / 48000 ); hStereoDft->win32ms_8k_fx = dft_win232ms_8k_fx + 1; hStereoDft->win32ms_12k8_fx = dft_win232ms_12k8_fx + 1; hStereoDft->win32ms_16k_fx = dft_win232ms_16k_fx + 1; - IF ( EQ_32(output_Fs , 16000) ) + IF( EQ_32( output_Fs, 16000 ) ) { hStereoDft->dft_trigo_fx = dft_trigo_32k_fx; hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_16k_STEP; + move16(); hStereoDft->win232ms_fx = dft_win232ms_16k_fx; hStereoDft->win32ms_fx = dft_win232ms_16k_fx + 1; } - ELSE IF ( EQ_32(output_Fs , 32000) ) + ELSE IF( EQ_32( output_Fs, 32000 ) ) { hStereoDft->dft_trigo_fx = dft_trigo_32k_fx; hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_32k_STEP; + move16(); hStereoDft->win232ms_fx = dft_win232ms_32k_fx; hStereoDft->win32ms_fx = dft_win232ms_32k_fx + 1; } @@ -292,6 +320,7 @@ static void stereo_dft_dec_open_fx( assert( output_Fs == 48000 ); hStereoDft->dft_trigo_fx = dft_trigo_48k_fx; hStereoDft->dft_trigo_step = STEREO_DFT_TRIGO_SRATE_48k_STEP; + move16(); hStereoDft->win232ms_fx = dft_win232ms_48k_fx; hStereoDft->win32ms_fx = dft_win232ms_48k_fx + 1; } @@ -304,7 +333,7 @@ static void stereo_dft_dec_open_fx( hStereoDft->nbands = stereo_dft_band_config( hStereoDft->band_limits, hStereoDft->band_res[0], hStereoDft->NFFT, DEC ); hStereoDft->hb_stefi_delay = NS2SA( output_Fs, STEREO_DFT_TD_STEFI_DELAY_NS ); - IF ( GT_16(nchan_transport , 2) ) + IF( GT_16( nchan_transport, 2 ) ) { hStereoDft->min_smooth_gains_fx = min_smooth_gains2_fx; hStereoDft->max_smooth_gains_fx = max_smooth_gains2_fx; @@ -315,7 +344,9 @@ static void stereo_dft_dec_open_fx( hStereoDft->max_smooth_gains_fx = max_smooth_gains1_fx; } hStereoDft->q_hb_stefi_sig_fx = Q31; + move16(); hStereoDft->q_ap_fade_mem_fx = Q31; + move16(); /* reset DFT stereo memories */ stereo_dft_dec_reset_fx( hStereoDft ); @@ -332,36 +363,36 @@ static void stereo_dft_dec_open_fx( ivas_error stereo_dft_dec_create_fx( STEREO_DFT_DEC_DATA_HANDLE *hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word32 element_brate, /* i : element bitrate */ - const Word32 output_Fs, /* i : output sampling rate */ - const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ - const Word16 nchan_transport /* i : number of transport channels */ + const Word32 element_brate, /* i : element bitrate */ + const Word32 output_Fs, /* i : output sampling rate */ + const Word16 sba_dirac_stereo_flag, /* i : signal stereo output for SBA DirAC */ + const Word16 nchan_transport /* i : number of transport channels */ ) { STEREO_DFT_DEC_DATA_HANDLE hStereoDft_loc; Word16 tmpS; - IF ( *hStereoDft != NULL ) + IF( *hStereoDft != NULL ) { return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: DFT Stereo memory already allocated\n" ); } - IF ( ( hStereoDft_loc = (STEREO_DFT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_DFT_DEC_DATA ) ) ) == NULL ) + IF( ( hStereoDft_loc = (STEREO_DFT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_DFT_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT Stereo\n" ) ); } - IF ( ( hStereoDft_loc->hConfig = (STEREO_DFT_CONFIG_DATA_HANDLE) malloc( sizeof( STEREO_DFT_CONFIG_DATA ) ) ) == NULL ) + IF( ( hStereoDft_loc->hConfig = (STEREO_DFT_CONFIG_DATA_HANDLE) malloc( sizeof( STEREO_DFT_CONFIG_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for DFT Stereo Config\n" ) ); } - IF ( ( hStereoDft_loc->hBpf = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) + IF( ( hStereoDft_loc->hBpf = (BPF_DEC_HANDLE) malloc( sizeof( BPF_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for BPF handle\n" ) ); } - IF ( ( hStereoDft_loc->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) + IF( ( hStereoDft_loc->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) ); } @@ -369,7 +400,7 @@ ivas_error stereo_dft_dec_create_fx( hStereoDft_loc->hConfig->force_mono_transmission = 0; move16(); - IF ( sba_dirac_stereo_flag ) + IF( sba_dirac_stereo_flag ) { ivas_sba_dirac_stereo_config( hStereoDft_loc->hConfig ); } @@ -380,10 +411,6 @@ ivas_error stereo_dft_dec_create_fx( stereo_dft_dec_open_fx( hStereoDft_loc, output_Fs, nchan_transport ); -#if 1 // TODO: To be removed later - stereo_dft_dec_open( hStereoDft_loc, output_Fs, nchan_transport ); -#endif - *hStereoDft = hStereoDft_loc; return IVAS_ERR_OK; @@ -504,8 +531,8 @@ static void stereo_dft_dequantize_res_gains_f_fx( void stereo_dft_dec_update_fx( STEREO_DFT_DEC_DATA_HANDLE hStereoDft, /* i/o: decoder DFT stereo handle */ - const Word16 output_frame, /* i : output frame length */ - const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ + const Word16 output_frame, /* i : output frame length */ + const Word16 sba_dirac_stereo_flag /* i : signal stereo output for SBA DirAC */ ) { Word16 b, i, k_offset; @@ -514,7 +541,7 @@ void stereo_dft_dec_update_fx( k_offset = STEREO_DFT_OFFSET; /*Add an offset*/ move16(); /* Update parameters */ - FOR ( i = 0; i < k_offset * STEREO_DFT_BAND_MAX; i++ ) + FOR( i = 0; i < k_offset * STEREO_DFT_BAND_MAX; i++ ) { hStereoDft->side_gain_fx[i] = hStereoDft->side_gain_fx[STEREO_DFT_NBDIV * STEREO_DFT_BAND_MAX + i]; move32(); @@ -522,14 +549,14 @@ void stereo_dft_dec_update_fx( move32(); } - FOR ( i = 0; i < k_offset; i++ ) + FOR( i = 0; i < k_offset; i++ ) { hStereoDft->gipd_fx[i] = hStereoDft->gipd_fx[STEREO_DFT_NBDIV + i]; move32(); } /* Update configuration memories */ - FOR ( i = 0; i < k_offset; i++ ) + FOR( i = 0; i < k_offset; i++ ) { hStereoDft->band_res[i] = hStereoDft->band_res[i + STEREO_DFT_NBDIV]; move16(); @@ -550,18 +577,18 @@ void stereo_dft_dec_update_fx( set_s( hStereoDft->res_cod_mode + k_offset, hStereoDft->hConfig->res_cod_mode, STEREO_DFT_NBDIV ); /*Update attack info*/ - IF ( hStereoDft->attackPresent ) + IF( hStereoDft->attackPresent ) { hStereoDft->wasTransient = 1; move16(); } - ELSE IF ( hStereoDft->wasTransient ) + ELSE IF( hStereoDft->wasTransient ) { hStereoDft->wasTransient = 0; move16(); } - FOR ( i = STEREO_DFT_CORE_HIST_MAX - 1; i > 0; i-- ) + FOR( i = STEREO_DFT_CORE_HIST_MAX - 1; i > 0; i-- ) { hStereoDft->core_hist[i] = hStereoDft->core_hist[i - 1]; move16(); @@ -570,14 +597,14 @@ void stereo_dft_dec_update_fx( Copy32( hStereoDft->hb_stefi_sig_fx + output_frame, hStereoDft->hb_stefi_sig_fx, hStereoDft->hb_stefi_delay ); Copy32( hStereoDft->hb_nrg_fx, hStereoDft->hb_nrg_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); Copy32( hStereoDft->td_gain_fx, hStereoDft->td_gain_fx + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); - Copy32( hStereoDft->q_td_gain, hStereoDft->q_td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1); + Copy32( hStereoDft->q_td_gain, hStereoDft->q_td_gain + 1, STEREO_DFT_CORE_HIST_MAX - 1 ); - IF ( sba_dirac_stereo_flag ) + IF( sba_dirac_stereo_flag ) { /* buffer update, push back by 2 because of 2 subframes */ - FOR ( b = 0; b < hStereoDft->nbands; b++ ) + FOR( b = 0; b < hStereoDft->nbands; b++ ) { - FOR ( i = SBA_DIRAC_NRG_SMOOTH_LONG; i > 1; i-- ) + FOR( i = SBA_DIRAC_NRG_SMOOTH_LONG; i > 1; i-- ) { hStereoDft->smooth_buf_fx[b][i] = hStereoDft->smooth_buf_fx[b][i - 2]; move32(); @@ -3098,10 +3125,10 @@ void stereo_dft_dec_sid_coh_fx( FOR( i = 0; i < b; i++ ) { - pred_fx = add( pred_fx, shl(mult( ( *pptr_fx++ ), cohBandq_fx[i] ), 2) ); /*q-13*/ + pred_fx = add( pred_fx, shl( mult( ( *pptr_fx++ ), cohBandq_fx[i] ), 2 ) ); /*q-13*/ } /* Weighted intra/inter-frame prediction */ - pred_fx = add( mult( alpha_fx, pred_fx ), mult( sub( 32767, alpha_fx ), coh_fx[b] ) ); /*q-13*/ + pred_fx = add( mult( alpha_fx, pred_fx ), mult( sub( 32767, alpha_fx ), shr( coh_fx[b], 2 ) ) ); /*q-13*/ /* Read residual index from bitstream */ IF( LT_16( *nb_bits, nr_of_sid_stereo_bits ) ) /* If the bit limit is reached, res_index = 0 is assumed for remaining indices */ @@ -3131,9 +3158,9 @@ void stereo_dft_dec_sid_coh_fx( cohBandq_fx[b] = 0; move16(); } - coh_fx[b] = cohBandq_fx[b]; /* Update memory for next frame */ - pred_fx = 0; + coh_fx[b] = shl_sat( cohBandq_fx[b], 2 ); /* Update memory for next frame */ move16(); + pred_fx = 0; move16(); } diff --git a/lib_dec/ivas_stereo_switching_dec.c b/lib_dec/ivas_stereo_switching_dec.c index b11233337..78f8b26dd 100644 --- a/lib_dec/ivas_stereo_switching_dec.c +++ b/lib_dec/ivas_stereo_switching_dec.c @@ -1540,10 +1540,6 @@ ivas_error stereo_memory_dec_fx( td_bwe_dec_init_ivas_fx( st, st->hBWE_TD, st->output_Fs ); -#if 1 // TODO: To be removed later - td_bwe_dec_init( st->hBWE_TD, -1, st->output_Fs ); -#endif - st->prev_Q_bwe_exc = 31; st->prev_Qx = 0; st->prev_ener_fx_Q = 31; @@ -1782,9 +1778,7 @@ ivas_error stereo_memory_dec_fx( } td_bwe_dec_init_ivas_fx( st, st->hBWE_TD, st->output_Fs ); -#if 1 // TODO: To be removed later - td_bwe_dec_init( st->hBWE_TD, -1, st->output_Fs ); -#endif + st->prev_Q_bwe_exc = 31; st->prev_Qx = 0; st->prev_ener_fx_Q = 31; diff --git a/lib_dec/ivas_tcx_core_dec.c b/lib_dec/ivas_tcx_core_dec.c index 83db7194b..21745b288 100644 --- a/lib_dec/ivas_tcx_core_dec.c +++ b/lib_dec/ivas_tcx_core_dec.c @@ -338,8 +338,6 @@ void stereo_tcx_core_dec_fx( IF( st->tcxonly ) { st->p_bpf_noise_buf_32 = NULL; - // To be removed - st->p_bpf_noise_buf_float = NULL; } ELSE { @@ -347,8 +345,6 @@ void stereo_tcx_core_dec_fx( st->p_bpf_noise_buf = st->bpf_noise_buf; set_s( pitch, L_SUBFR, st->nb_subfr ); set16_fx( pit_gain_fx, 0, st->nb_subfr ); - // To be removed - st->p_bpf_noise_buf_float = st->bpf_noise_buf_float; } /* Initialize pointers */ @@ -657,9 +653,6 @@ void stereo_tcx_core_dec_fx( IF( !bfi && st->hTonalMDCTConc != NULL ) { TonalMDCTConceal_SaveTimeSignal( st->hTonalMDCTConc, synthFB_fx, hTcxDec->L_frameTCX ); - // To be removed - fixedToFloat_arr( st->hTonalMDCTConc->secondLastPcmOut, st->hTonalMDCTConc->secondLastPcmOut_float, 0, st->hTonalMDCTConc->nSamples / 2 ); - fixedToFloat_arr( st->hTonalMDCTConc->lastPcmOut, st->hTonalMDCTConc->lastPcmOut_float, 0, st->hTonalMDCTConc->nSamples ); } decoder_tcx_post_fx( st, synth_fx, synthFB_fx, Aq_fx, bfi ); @@ -775,8 +768,17 @@ void stereo_tcx_core_dec_fx( st->last_is_cng = 0; /* Postfiltering */ + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_32_16( st->p_bpf_noise_buf_32, st->p_bpf_noise_buf, st->L_frame, negate( Q11 ) ); + } + post_decoder( st, synth_buf_fx, pit_gain_fx, pitch, signal_out_fx, st->p_bpf_noise_buf ); + IF( st->p_bpf_noise_buf_32 ) + { + Copy_Scale_sig_16_32_no_sat( st->p_bpf_noise_buf, st->p_bpf_noise_buf_32, st->L_frame, Q11 ); + } IF( signal_outFB_fx ) { Copy( synthFB_fx, signal_outFB_fx, hTcxDec->L_frameTCX ); diff --git a/lib_dec/stat_dec.h b/lib_dec/stat_dec.h index f9fb1e649..105e33499 100644 --- a/lib_dec/stat_dec.h +++ b/lib_dec/stat_dec.h @@ -395,25 +395,25 @@ typedef struct tonalmdctconceal blockData lastBlockData; blockData secondLastBlockData; - Float32 scaleFactorsBuffers_float[2][FDNS_NPTS]; /* Contains also global gain. If it can not be stored in 16 bits with global gain included, then store global gain separately. */ Word16 scaleFactorsBuffers[2][FDNS_NPTS]; /* Contains also global gain. */ Word16 scaleFactorsBuffers_exp[2][FDNS_NPTS]; - Float32 spectralDataBuffers_float[2][L_FRAME_MAX]; /* 16 bits is enough, because it is stored before applying scale factors. Take care that power spectrum is also stored here. */ Word16 spectralDataBuffers[2][L_FRAME_MAX]; /* 16 bits is enough, because it is stored before applying scale factors. Take care that power spectrum is also stored here. */ - Float32 timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2]; Word16 timeDataBuffer[(3 * L_FRAME_MAX) / 2]; /* 16 bits are enough for the TD signal */ - +#ifndef IVAS_FLOAT_FIXED + Float32 scaleFactorsBuffers_float[2][FDNS_NPTS]; /* Contains also global gain. If it can not be stored in 16 bits with global gain included, then store global gain separately. */ + Float32 spectralDataBuffers_float[2][L_FRAME_MAX]; /* 16 bits is enough, because it is stored before applying scale factors. Take care that power spectrum is also stored here. */ + Float32 timeDataBuffer_float[( 3 * L_FRAME_MAX ) / 2]; Float32 *lastPcmOut_float; + Float32 *secondLastPcmOut_float; +#endif Word16 * lastPcmOut; - Float32 *secondLastPcmOut_float; Word16 * secondLastPcmOut; - float *secondLastPowerSpectrum_float; Word16 * secondLastPowerSpectrum; Word16 secondLastPowerSpectrum_exp; @@ -421,6 +421,7 @@ typedef struct tonalmdctconceal //Word16 scaleFactorsBackground[FDNS_NPTS]; Word32 scaleFactorsBackground_fx[FDNS_NPTS]; #ifndef IVAS_FLOAT_FIXED + float *secondLastPowerSpectrum_float; float scaleFactorsBackground_flt[FDNS_NPTS]; float scf_fadeout_flt; #endif @@ -451,8 +452,9 @@ typedef struct tonalmdctconceal //Memory ovelap issue #endif TonalComponentsInfo *pTCI; +#ifndef IVAS_FLOAT_FIXED TonalComponentsInfo pTCI1; - +#endif } TonalMDCTConceal_INSTANCE, *TonalMDCTConcealPtr; @@ -1655,7 +1657,9 @@ typedef struct td_bwe_dec_structure #endif Word32 bwe_non_lin_prev_scale_fx; +#ifndef IVAS_FLOAT_FIXED float old_bwe_exc_extended[NL_BUFF_OFFSET]; +#endif Word16 old_bwe_exc_extended_fx[NL_BUFF_OFFSET]; @@ -1686,19 +1690,27 @@ typedef struct td_bwe_dec_structure Word16 genSHBsynth_state_lsyn_filt_shb_local_fx[2 * ALLPASSSECTIONS_STEEP]; Word32 genSHBsynth_state_lsyn_filt_shb_local_fx_32[2 * ALLPASSSECTIONS_STEEP]; +#ifndef IVAS_FLOAT_FIXED float state_lsyn_filt_shb[2 * ALLPASSSECTIONS_STEEP]; +#endif Word16 state_lsyn_filt_shb_fx[2 * ALLPASSSECTIONS_STEEP]; Word32 state_lsyn_filt_shb_fx_32[2 * ALLPASSSECTIONS_STEEP]; +#ifndef IVAS_FLOAT_FIXED float state_lsyn_filt_dwn_shb[2 * ALLPASSSECTIONS_STEEP]; +#endif Word16 state_lsyn_filt_dwn_shb_fx[2 * ALLPASSSECTIONS_STEEP]; Word32 state_lsyn_filt_dwn_shb_fx_32[2 * ALLPASSSECTIONS_STEEP]; +#ifndef IVAS_FLOAT_FIXED float mem_resamp_HB[INTERP_3_1_MEM_LEN]; +#endif Word16 mem_resamp_HB_fx[INTERP_3_1_MEM_LEN]; Word32 mem_resamp_HB_fx_32[INTERP_3_1_MEM_LEN]; +#ifndef IVAS_FLOAT_FIXED float mem_resamp_HB_32k[2 * ALLPASSSECTIONS_STEEP + 1]; +#endif Word16 mem_resamp_HB_32k_fx[2 * ALLPASSSECTIONS_STEEP + 1]; Word32 mem_resamp_HB_32k_fx_32[2 * ALLPASSSECTIONS_STEEP + 1]; @@ -1867,11 +1879,15 @@ typedef struct td_bwe_dec_structure #endif Word16 old_core_synth_fx[L_FRAME16k]; +#ifndef IVAS_FLOAT_FIXED float old_tbe_synth[L_SHB_TRANSITION_LENGTH]; +#endif Word16 old_tbe_synth_fx[L_SHB_TRANSITION_LENGTH]; Word32 old_tbe_synth_fx_32[L_SHB_TRANSITION_LENGTH]; +#ifndef IVAS_FLOAT_FIXED float int_3_over_2_tbemem_dec[INTERP_3_2_MEM_LEN]; +#endif Word16 int_3_over_2_tbemem_dec_fx[INTERP_3_2_MEM_LEN]; Word32 int_3_over_2_tbemem_dec_fx_32[INTERP_3_2_MEM_LEN]; @@ -2976,11 +2992,12 @@ typedef struct Decoder_State int16_t rate_switching_reset; - float bpf_noise_buf_float[L_FRAME16k]; Word16 bpf_noise_buf[L_FRAME_16k]; Word32 bpf_noise_buf_32[L_FRAME_16k]; - +#ifndef IVAS_FLOAT_FIXED + float bpf_noise_buf_float[L_FRAME16k]; float *p_bpf_noise_buf_float; +#endif Word16 *p_bpf_noise_buf; Word32 *p_bpf_noise_buf_32; diff --git a/lib_dec/swb_tbe_dec.c b/lib_dec/swb_tbe_dec.c index cbdffc62b..c9516a549 100644 --- a/lib_dec/swb_tbe_dec.c +++ b/lib_dec/swb_tbe_dec.c @@ -65,13 +65,13 @@ static void Dequant_mirror_point( const float lsf_q[], const int16_t m_idx, floa * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED void ResetSHBbuffer_Dec( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ const int16_t extl /* i : BWE extension layer */ ) { int16_t i; -#ifndef IVAS_FLOAT_FIXED float f; float inc; @@ -104,50 +104,11 @@ void ResetSHBbuffer_Dec( set_f(hBWE_TD->mem_genSHBexc_filt_down_shb, 0.0f, (2 * ALLPASSSECTIONS_STEEP + 1)); set_f(hBWE_TD->mem_genSHBexc_filt_down_wb2, 0.0f, (2 * ALLPASSSECTIONS_STEEP + 1)); set_f(hBWE_TD->mem_genSHBexc_filt_down_wb3, 0.0f, (2 * ALLPASSSECTIONS_STEEP + 1)); -#endif -#ifdef IVAS_FLOAT_FIXED - Word16 f_fx; - Word16 inc_fx; - IF( extl != WB_TBE ) - { - f_fx = 1489; - move16(); /* Q15 */ - inc_fx = 1489; - move16(); /* Q15 */ - } - ELSE - { - f_fx = 5461; - move16();/* Q15 */ - inc_fx = 5461; - move16(); /* Q15 */ - } - - /* states for the filters used in generating SHB excitation from WB excitation*/ - set_val_Word32( hBWE_TD->mem_csfilt_fx, 0, 2 ); - - /* states for the filters used in generating SHB signal from SHB excitation*/ - set_val_Word16( hBWE_TD->state_syn_shbexc_fx, 0, L_SHB_LAHEAD ); - set_val_Word16( hBWE_TD->state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - - IF ( extl == FB_TBE ) - { - set_val_Word16( 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 ); - } - - /* states for the filters used in generating SHB signal from SHB excitation in wideband*/ - set_val_Word16( hBWE_TD->mem_genSHBexc_filt_down_shb_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set_val_Word16( hBWE_TD->mem_genSHBexc_filt_down_wb2_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); - set_val_Word16( hBWE_TD->mem_genSHBexc_filt_down_wb3_fx, 0, ( 2 * ALLPASSSECTIONS_STEEP + 1 ) ); -#endif set_f( hBWE_TD->state_lsyn_filt_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); set_f( hBWE_TD->state_lsyn_filt_dwn_shb, 0, 2 * ALLPASSSECTIONS_STEEP ); set_f( hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); -#ifndef IVAS_FLOAT_FIXED /* States for the local synthesis filters */ set_f( hBWE_TD->syn_overlap, 0, L_SHB_LAHEAD ); @@ -184,57 +145,14 @@ void ResetSHBbuffer_Dec( hBWE_TD->prev_mix_factor = 1.0f; set_f(hBWE_TD->old_core_synth, 0, L_FRAME16k); -#endif -#ifdef IVAS_FLOAT_FIXED - IF( extl != WB_TBE ) - { - FOR( i = 0; i < LPC_SHB_ORDER; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; - move16(); /*Q15*/ - f_fx = add( f_fx, inc_fx ); - move16(); - } - } - ELSE - { - FOR( i = 0; i < LPC_SHB_ORDER_WB; i++ ) - { - hBWE_TD->lsp_prevfrm_fx[i] = f_fx; - move16();/*Q15*/ - f_fx = add( f_fx, inc_fx ); - move16(); - } - FOR( ; ilsp_prevfrm_fx[i] = 0; - move16(); - } - } - - hBWE_TD->GainFrame_prevfrm_fx = 0; - hBWE_TD->GainAttn_fx = 32767; - hBWE_TD->tbe_demph_fx = 0; - hBWE_TD->tbe_premph_fx = 0; - set_val_Word16( hBWE_TD->mem_stp_swb_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->gain_prec_swb_fx = 16384; - set_val_Word16( hBWE_TD->GainShape_Delay_fx, 0, NUM_SHB_SUBFR / 2 ); - hBWE_TD->prev_pow_exc16kWhtnd_fx32 = 1; /* Q0 1.f */ - hBWE_TD->prev_mix_factor_fx = 32767; /*Q15 1.f*/ - set16_fx( hBWE_TD->old_core_synth_fx, 0, L_FRAME16k ); -#endif set_f( hBWE_TD->old_tbe_synth, 0, L_SHB_TRANSITION_LENGTH ); -#ifndef IVAS_FLOAT_FIXED hBWE_TD->tilt_swb_fec = 0.0f; -#endif -#ifdef IVAS_FLOAT_FIXED - hBWE_TD->tilt_swb_fec_fx = 0; -#endif return; } -#ifndef IVAS_FLOAT_FIXED + + /*-------------------------------------------------------------------* * wb_tbe_dec() * @@ -4744,56 +4662,33 @@ void TBEreset_dec( * * Initialize TD BWE state structure at the decoder *-------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED +#ifndef IVAS_FLOAT_FIXED void td_bwe_dec_init( TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ const int16_t extl, /* i : BWE extension layer */ const int32_t output_Fs /* i : output sampling rate */ ) - { int16_t i; /* init. SHB buffers */; -#ifndef IVAS_FLOAT_FIXED set_f( hBWE_TD->old_bwe_exc, 0.0f, ( PIT16k_MAX * 2 ) ); -#endif -#ifdef IVAS_FLOAT_FIXED - set_val_Word16( hBWE_TD->old_bwe_exc_fx, 0, PIT16k_MAX * 2 ); -#endif hBWE_TD->bwe_seed[0] = 23; /* 1; */ hBWE_TD->bwe_seed[1] = 59; /* 10000; */ set_f( hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET ); -#ifndef IVAS_FLOAT_FIXED hBWE_TD->bwe_non_lin_prev_scale = 0; - set_f(hBWE_TD->genSHBsynth_Hilbert_Mem, 0.0f, HILBERT_MEM_SIZE); - set_f(hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 0.0f, 2 * ALLPASSSECTIONS_STEEP); -#endif -#ifdef IVAS_FLOAT_FIXED - hBWE_TD->bwe_non_lin_prev_scale_fx = 0; - - set32_fx( hBWE_TD->genSHBsynth_Hilbert_Mem_fx, 0, HILBERT_MEM_SIZE ); - set16_fx( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx, 0, 2 * ALLPASSSECTIONS_STEEP ); - set32_fx( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP ); -#endif + set_f( hBWE_TD->genSHBsynth_Hilbert_Mem, 0.0f, HILBERT_MEM_SIZE ); + set_f( hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 0.0f, 2 * ALLPASSSECTIONS_STEEP ); hBWE_TD->syn_dm_phase = 0; -#ifndef IVAS_FLOAT_FIXED hBWE_TD->prev_fbbwe_ratio = 1.0f; hBWE_TD->prev_wb_bwe_frame_pow = 0.001f; hBWE_TD->prev_swb_bwe_frame_pow = 0.001f; -#endif -#ifdef IVAS_FLOAT_FIXED - hBWE_TD->prev_fbbwe_ratio_fx = 32767/*1.0f Q15*/; - hBWE_TD->prev_wb_bwe_frame_pow_fx = 4194l/*0.001f Q22*/; - hBWE_TD->prev_swb_bwe_frame_pow_fx = 4194l/*0.001f Q22*/; -#endif /* reset SHB buffers */ ResetSHBbuffer_Dec( hBWE_TD, extl ); -#ifndef IVAS_FLOAT_FIXED if ( output_Fs == 48000 ) { set_f( hBWE_TD->fbbwe_hpf_mem[0], 0, 4 ); @@ -4801,41 +4696,17 @@ void td_bwe_dec_init( set_f( hBWE_TD->fbbwe_hpf_mem[2], 0, 4 ); set_f( hBWE_TD->fbbwe_hpf_mem[3], 0, 4 ); } -#endif -#ifdef IVAS_FLOAT_FIXED - IF(EQ_32(output_Fs, 48000)) - { - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[0], 0, 4); - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[1], 0, 4); - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[2], 0, 4); - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[3], 0, 4); - set16_fx(hBWE_TD->fbbwe_hpf_mem_fx_Q, 0, 4); - } -#endif set_f( hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN ); - set32_fx( hBWE_TD->mem_resamp_HB_fx_32, 0, INTERP_3_1_MEM_LEN ); set_f( hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); - set32_fx( hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); -#ifndef IVAS_FLOAT_FIXED hBWE_TD->tilt_mem = 0.0f; set_f( hBWE_TD->prev_lsf_diff, 0.5f, LPC_SHB_ORDER - 2 ); hBWE_TD->prev_tilt_para = 0.0f; set_f( hBWE_TD->cur_sub_Aq, 0.0f, M + 1 ); -#endif -#ifdef IVAS_FLOAT_FIXED - hBWE_TD->tilt_mem_fx = 0; - 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); -#endif - - set_f( hBWE_TD->int_3_over_2_tbemem_dec, 0.0f, INTERP_3_2_MEM_LEN ); /* TD BWE post-processing */ -#ifndef IVAS_FLOAT_FIXED hBWE_TD->ptr_mem_stp_swb = hBWE_TD->mem_stp_swb + LPC_SHB_ORDER - 1; set_f( hBWE_TD->mem_zero_swb, 0, LPC_SHB_ORDER ); @@ -4850,114 +4721,15 @@ void td_bwe_dec_init( hBWE_TD->prev_res_shb_gshape = 0.125f; hBWE_TD->prev_mixFactors = 0.5f; hBWE_TD->prev_GainShape = 0.0f; - - set_f(hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER); + set_f( hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph = 0.0f; - set_f(hBWE_TD->old_hb_synth, 0, L_FRAME48k); + + set_f( hBWE_TD->old_hb_synth, 0, L_FRAME48k ); hBWE_TD->GainFrame_prevfrm = 0.0f; hBWE_TD->prev_ener = 0.0f; -#endif -#ifdef IVAS_FLOAT_FIXED - hBWE_TD->ptr_mem_stp_swb_fx = hBWE_TD->mem_stp_swb_fx + LPC_SHB_ORDER - 1; - set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - - FOR(i = 0; i < LPC_SHB_ORDER; i++) - { - hBWE_TD->swb_lsp_prev_interp_fx[i] = swb_lsp_prev_interp_init[i]; - move16(); - } - - hBWE_TD->prev1_shb_ener_sf_fx = 32767; - hBWE_TD->prev2_shb_ener_sf_fx = 32767; - hBWE_TD->prev3_shb_ener_sf_fx = 32767; - hBWE_TD->prev_res_shb_gshape_fx = 8192; - hBWE_TD->prev_mixFactors_fx = 16384; - hBWE_TD->prev_GainShape_fx = 0; - - set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); - hBWE_TD->fb_tbe_demph_fx = 0; - set16_fx( hBWE_TD->old_hb_synth_fx, 0, L_FRAME48k ); - - hBWE_TD->GainFrame_prevfrm_fx = 0; - - hBWE_TD->prev_ener_fx = 0; -#endif return; } - -#else - -void td_bwe_dec_init( - TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const int16_t extl, /* i : BWE extension layer */ - const int32_t output_Fs /* i : output sampling rate */ -) -{ - int16_t i; - - /* init. SHB buffers */; - set_f(hBWE_TD->old_bwe_exc, 0.0f, (PIT16k_MAX * 2)); - hBWE_TD->bwe_seed[0] = 23; /* 1; */ - hBWE_TD->bwe_seed[1] = 59; /* 10000; */ - set_f(hBWE_TD->old_bwe_exc_extended, 0.0f, NL_BUFF_OFFSET); - hBWE_TD->bwe_non_lin_prev_scale = 0; - - set_f(hBWE_TD->genSHBsynth_Hilbert_Mem, 0.0f, HILBERT_MEM_SIZE); - set_f(hBWE_TD->genSHBsynth_state_lsyn_filt_shb_local, 0.0f, 2 * ALLPASSSECTIONS_STEEP); - - hBWE_TD->syn_dm_phase = 0; - hBWE_TD->prev_fbbwe_ratio = 1.0f; - hBWE_TD->prev_wb_bwe_frame_pow = 0.001f; - hBWE_TD->prev_swb_bwe_frame_pow = 0.001f; - - /* reset SHB buffers */ - ResetSHBbuffer_Dec(hBWE_TD, extl); - - if (output_Fs == 48000) - { - set_f(hBWE_TD->fbbwe_hpf_mem[0], 0, 4); - set_f(hBWE_TD->fbbwe_hpf_mem[1], 0, 4); - set_f(hBWE_TD->fbbwe_hpf_mem[2], 0, 4); - set_f(hBWE_TD->fbbwe_hpf_mem[3], 0, 4); - } - - set_f(hBWE_TD->mem_resamp_HB, 0, INTERP_3_1_MEM_LEN); - set_f(hBWE_TD->mem_resamp_HB_32k, 0, 2 * ALLPASSSECTIONS_STEEP + 1); - - hBWE_TD->tilt_mem = 0.0f; - set_f(hBWE_TD->prev_lsf_diff, 0.5f, LPC_SHB_ORDER - 2); - hBWE_TD->prev_tilt_para = 0.0f; - set_f(hBWE_TD->cur_sub_Aq, 0.0f, M + 1); - set_f(hBWE_TD->int_3_over_2_tbemem_dec, 0.0f, INTERP_3_2_MEM_LEN); - - /* TD BWE post-processing */ - hBWE_TD->ptr_mem_stp_swb = hBWE_TD->mem_stp_swb + LPC_SHB_ORDER - 1; - set_f(hBWE_TD->mem_zero_swb, 0, LPC_SHB_ORDER); - - for (i = 0; i < LPC_SHB_ORDER; i++) - { - hBWE_TD->swb_lsp_prev_interp[i] = (float)cos((float)i * EVS_PI / (float) 10.0f); - } - - hBWE_TD->prev1_shb_ener_sf = 1.0f; - hBWE_TD->prev2_shb_ener_sf = 1.0f; - hBWE_TD->prev3_shb_ener_sf = 1.0f; - hBWE_TD->prev_res_shb_gshape = 0.125f; - hBWE_TD->prev_mixFactors = 0.5f; - hBWE_TD->prev_GainShape = 0.0f; - set_f(hBWE_TD->fb_state_lpc_syn, 0, LPC_SHB_ORDER); - hBWE_TD->fb_tbe_demph = 0.0f; - - set_f(hBWE_TD->old_hb_synth, 0, L_FRAME48k); - - hBWE_TD->GainFrame_prevfrm = 0.0f; - - hBWE_TD->prev_ener = 0.0f; - - return; -} - #endif \ No newline at end of file diff --git a/lib_dec/swb_tbe_dec_fx.c b/lib_dec/swb_tbe_dec_fx.c index 2f9f66ac5..6f7ef267f 100644 --- a/lib_dec/swb_tbe_dec_fx.c +++ b/lib_dec/swb_tbe_dec_fx.c @@ -520,7 +520,8 @@ void ResetSHBbuffer_Dec_fx( Decoder_State* st_fx /* i/o: SHB encoder structure * set16_fx(hBWE_TD->state_32and48k_WB_upsample_fx, 0, 2 * ALLPASSSECTIONS_STEEP ); /* States for the local synthesis filters */ - set16_fx(hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); + set16_fx( hBWE_TD->syn_overlap_fx, 0, L_SHB_LAHEAD ); + set32_fx( hBWE_TD->syn_overlap_fx_32, 0, L_SHB_LAHEAD ); /* States for FEC */ @@ -4950,6 +4951,7 @@ void TBEreset_dec_ivas_fx( 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->syn_overlap_fx_32, 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 ) ) @@ -4993,66 +4995,71 @@ void TBEreset_dec_ivas_fx( #ifdef IVAS_FLOAT_FIXED void td_bwe_dec_init_ivas_fx( - Decoder_State* st_fx, /* i/o: SHB decoder structure */ + Decoder_State *st_fx, /* i/o: SHB decoder structure */ TD_BWE_DEC_HANDLE hBWE_TD, /* i/o: TD BWE data handle */ - const Word32 output_Fs /* i : output sampling rate */ + const Word32 output_Fs /* i : output sampling rate */ ) { - int16_t i; + Word16 i; /* init. SHB buffers */; - InitSWBdecBuffer_ivas_fx(st_fx); + InitSWBdecBuffer_ivas_fx( st_fx ); /* reset SHB buffers */ - ResetSHBbuffer_Dec_fx(st_fx); - IF(EQ_32(output_Fs, 48000)) + ResetSHBbuffer_Dec_fx( st_fx ); + IF( EQ_32( output_Fs, 48000 ) ) { - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[0], 0, 4); - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[1], 0, 4); - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[2], 0, 4); - set32_fx(hBWE_TD->fbbwe_hpf_mem_fx[3], 0, 4); - set16_fx(hBWE_TD->fbbwe_hpf_mem_fx_Q, 0, 4); + set32_fx( hBWE_TD->fbbwe_hpf_mem_fx[0], 0, 4 ); + set32_fx( hBWE_TD->fbbwe_hpf_mem_fx[1], 0, 4 ); + set32_fx( hBWE_TD->fbbwe_hpf_mem_fx[2], 0, 4 ); + set32_fx( hBWE_TD->fbbwe_hpf_mem_fx[3], 0, 4 ); + set16_fx( hBWE_TD->fbbwe_hpf_mem_fx_Q, 0, 4 ); } - set16_fx(hBWE_TD->mem_resamp_HB_fx, 0, INTERP_3_1_MEM_LEN); - set16_fx(hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1); - set16_fx(hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1); - set32_fx(hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1); + set16_fx( hBWE_TD->mem_resamp_HB_fx, 0, INTERP_3_1_MEM_LEN ); + set32_fx( hBWE_TD->mem_resamp_HB_fx_32, 0, INTERP_3_1_MEM_LEN ); + set16_fx( hBWE_TD->mem_resamp_HB_32k_fx, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); + set32_fx( hBWE_TD->mem_resamp_HB_32k_fx_32, 0, 2 * ALLPASSSECTIONS_STEEP + 1 ); hBWE_TD->tilt_mem_fx = 0; move16(); - set16_fx(hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2); + set16_fx( hBWE_TD->prev_lsf_diff_fx, 16384, LPC_SHB_ORDER - 2 ); hBWE_TD->prev_tilt_para_fx = 0; move16(); - set16_fx(hBWE_TD->cur_sub_Aq_fx, 0, M + 1); - set16_fx(hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN); - set32_fx(hBWE_TD->int_3_over_2_tbemem_dec_fx_32, 0, INTERP_3_2_MEM_LEN); + set16_fx( hBWE_TD->cur_sub_Aq_fx, 0, M + 1 ); + set16_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx, 0, INTERP_3_2_MEM_LEN ); + set32_fx( hBWE_TD->int_3_over_2_tbemem_dec_fx_32, 0, INTERP_3_2_MEM_LEN ); /* TD BWE post-processing */ hBWE_TD->ptr_mem_stp_swb_fx = hBWE_TD->mem_stp_swb_fx + LPC_SHB_ORDER - 1; - set16_fx(hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER); + set16_fx( hBWE_TD->mem_zero_swb_fx, 0, LPC_SHB_ORDER ); - FOR(i = 0; i < LPC_SHB_ORDER; i++) + FOR( i = 0; i < LPC_SHB_ORDER; i++ ) { hBWE_TD->swb_lsp_prev_interp_fx[i] = swb_lsp_prev_interp_init[i]; move16(); } - hBWE_TD->prev1_shb_ener_sf_fx = 32767; /* Q15*/ move16(); - hBWE_TD->prev2_shb_ener_sf_fx = 32767; /* Q15*/ move16(); - hBWE_TD->prev3_shb_ener_sf_fx = 32767; /* Q15*/ move16(); - hBWE_TD->prev_res_shb_gshape_fx = 8192; /* 0.125 in Q14*/ move16(); - hBWE_TD->prev_mixFactors_fx = 16384; /* 0.5 in Q15*/ move16(); + hBWE_TD->prev1_shb_ener_sf_fx = 32767; /* Q15*/ + move16(); + hBWE_TD->prev2_shb_ener_sf_fx = 32767; /* Q15*/ + move16(); + hBWE_TD->prev3_shb_ener_sf_fx = 32767; /* Q15*/ + move16(); + hBWE_TD->prev_res_shb_gshape_fx = 8192; /* 0.125 in Q14*/ + move16(); + hBWE_TD->prev_mixFactors_fx = 16384; /* 0.5 in Q15*/ + move16(); hBWE_TD->prev_GainShape_fx = 0; move16(); st_fx->prev_Q_bwe_exc_fb = 51; move16(); - set16_fx(hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER); + set16_fx( hBWE_TD->fb_state_lpc_syn_fx, 0, LPC_SHB_ORDER ); hBWE_TD->fb_tbe_demph_fx = 0; move16(); - set16_fx(hBWE_TD->old_hb_synth_fx, 0, L_FRAME48k); + set16_fx( hBWE_TD->old_hb_synth_fx, 0, L_FRAME48k ); - hBWE_TD->prev_ener_fx = L_deposit_l(0); + hBWE_TD->prev_ener_fx = L_deposit_l( 0 ); return; } diff --git a/lib_dec/tonalMDCTconcealment.c b/lib_dec/tonalMDCTconcealment.c index 98b367a4b..a3b0db6a0 100644 --- a/lib_dec/tonalMDCTconcealment.c +++ b/lib_dec/tonalMDCTconcealment.c @@ -84,9 +84,9 @@ ivas_error TonalMDCTConceal_Init_ivas( hTonalMDCTConc->lastBlockData.blockIsConcealed = 0; hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; - hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer_float; #ifndef IVAS_FLOAT_FIXED + hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer_float; hTonalMDCTConc->lastPitchLag_float = 0; #endif // #ifndef IVAS_FLOAT_FIXED @@ -112,7 +112,6 @@ ivas_error TonalMDCTConceal_Init_ivas( hTonalMDCTConc->last_block_nrg_flt = 0.0f; hTonalMDCTConc->curr_noise_nrg_flt = 0.0f; hTonalMDCTConc->faded_signal_nrg_flt = 0.0f; -#endif /* Offset the pointer to the end of buffer, so that pTCI is not destroyed when new time samples are stored in lastPcmOut */ /* just the second half of the second last pcm output is needed */ @@ -122,6 +121,7 @@ ivas_error TonalMDCTConceal_Init_ivas( /* If the second last frame was lost and concealed with tonal PLC, we reuse saved TonalComponentsInfo and don't update pcm buffers */ assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut_float - hTonalMDCTConc->timeDataBuffer_float) * sizeof( hTonalMDCTConc->timeDataBuffer_float[0] ) ); +#endif return IVAS_ERR_OK; } @@ -1032,7 +1032,7 @@ void TonalMDCTConceal_Apply_ivas( return; } #endif - +#ifndef IVAS_FLOAT_FIXED void TonalMDCTConceal_SaveTimeSignal_ivas( TonalMDCTConcealPtr hTonalMDCTConc, float *timeSignal, @@ -1052,7 +1052,7 @@ void TonalMDCTConceal_SaveTimeSignal_ivas( return; } - +#endif #ifdef IVAS_FLOAT_FIXED void TonalMdctConceal_create_concealment_noise_ivas_fx( diff --git a/lib_dec/tonalMDCTconcealment_fx.c b/lib_dec/tonalMDCTconcealment_fx.c index e79dcd83c..5f29ce870 100644 --- a/lib_dec/tonalMDCTconcealment_fx.c +++ b/lib_dec/tonalMDCTconcealment_fx.c @@ -178,9 +178,9 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( move16(); hTonalMDCTConc->secondLastBlockData.blockIsConcealed = 0; move16(); - //hTonalMDCTConc->pTCI = (TonalComponentsInfo_fix *) hTonalMDCTConc->timeDataBuffer; + hTonalMDCTConc->pTCI = (TonalComponentsInfo *) hTonalMDCTConc->timeDataBuffer; - hTonalMDCTConc->pTCI = &hTonalMDCTConc->pTCI1; + //hTonalMDCTConc->pTCI = &hTonalMDCTConc->pTCI1; move16(); hTonalMDCTConc->lastPitchLag = L_deposit_l( 0 ); @@ -229,13 +229,7 @@ ivas_error TonalMDCTConceal_Init_ivas_fx( hTonalMDCTConc->secondLastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, imult1616(3 , shr(s_min( L_FRAME_MAX, nSamples ),1 ) ) )]; hTonalMDCTConc->lastPcmOut = &hTonalMDCTConc->timeDataBuffer[sub( ( 3 * L_FRAME_MAX ) / 2, s_min( L_FRAME_MAX, nSamples ) )]; /* If the second last frame was lost, we reuse saved TonalComponentsInfo and don't update pcm buffers */ -#if 1 - // TO do enable when only fix code is present currently disabled due to float array in structure - //assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); - - /* TODO: remove float code*/ - assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut_float - hTonalMDCTConc->timeDataBuffer_float ) * sizeof( hTonalMDCTConc->timeDataBuffer_float[0] ) ); -#endif + assert( sizeof( *hTonalMDCTConc->pTCI ) <= ( hTonalMDCTConc->lastPcmOut - hTonalMDCTConc->timeDataBuffer ) * sizeof( hTonalMDCTConc->timeDataBuffer[0] ) ); return IVAS_ERR_OK; } diff --git a/lib_rend/ivas_crend.c b/lib_rend/ivas_crend.c index 4245124f7..6a5c50f8d 100644 --- a/lib_rend/ivas_crend.c +++ b/lib_rend/ivas_crend.c @@ -2967,6 +2967,12 @@ void ivas_rend_closeCrend( hCrend->lfe_delay_line = NULL; } + if ( hCrend->lfe_delay_line_fx != NULL ) + { + free( hCrend->lfe_delay_line_fx); + hCrend->lfe_delay_line_fx = NULL; + } + if ( hCrend->freq_buffer_re_diffuse != NULL ) { free( hCrend->freq_buffer_re_diffuse ); diff --git a/lib_rend/ivas_dirac_ana.c b/lib_rend/ivas_dirac_ana.c index 631fd5f55..c9f493c2c 100644 --- a/lib_rend/ivas_dirac_ana.c +++ b/lib_rend/ivas_dirac_ana.c @@ -114,7 +114,7 @@ ivas_error ivas_dirac_ana_open( return error; } } - +#ifndef IVAS_FLOAT_FIXED /* intensity 3-dim */ for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { @@ -132,7 +132,7 @@ ivas_error ivas_dirac_ana_open( set_zero( hDirAC->direction_vector_m[i][j], MASA_FREQUENCY_BANDS ); } } -#ifdef IVAS_FLOAT_FIXED +#else for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { if ( ( hDirAC->direction_vector_m_fx[i] = (Word32 **) malloc( MAX_PARAM_SPATIAL_SUBFRAMES * sizeof( Word32 * ) ) ) == NULL ) @@ -150,6 +150,7 @@ ivas_error ivas_dirac_ana_open( } } #endif +#ifndef IVAS_FLOAT_FIXED for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) @@ -161,7 +162,7 @@ ivas_error ivas_dirac_ana_open( set_zero( hDirAC->buffer_intensity_real[i][j], MASA_FREQUENCY_BANDS ); } } -#ifdef IVAS_FLOAT_FIXED +#else for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) @@ -175,7 +176,7 @@ ivas_error ivas_dirac_ana_open( } set_val_Word32( hDirAC->buffer_energy_fx, 0, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); #endif - set_zero( hDirAC->buffer_energy, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); + //set_zero( hDirAC->buffer_energy, DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS ); hDirAC->index_buffer_intensity = 0; @@ -220,34 +221,36 @@ void ivas_dirac_ana_close( for ( i = 0; i < DIRAC_NUM_DIMS; i++ ) { +#ifndef IVAS_FLOAT_FIXED for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { free( ( *hDirAC )->direction_vector_m[i][j] ); ( *hDirAC )->direction_vector_m[i][j] = NULL; } -#ifdef IVAS_FLOAT_FIXED + free( ( *hDirAC )->direction_vector_m[i] ); + ( *hDirAC )->direction_vector_m[i] = NULL; +#else for ( j = 0; j < MAX_PARAM_SPATIAL_SUBFRAMES; j++ ) { free( ( *hDirAC )->direction_vector_m_fx[i][j] ); ( *hDirAC )->direction_vector_m_fx[i][j] = NULL; } + free( ( *hDirAC )->direction_vector_m_fx[i] ); + ( *hDirAC )->direction_vector_m_fx[i] = NULL; #endif +#ifndef IVAS_FLOAT_FIXED for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { free( ( *hDirAC )->buffer_intensity_real[i][j] ); ( *hDirAC )->buffer_intensity_real[i][j] = NULL; } -#ifdef IVAS_FLOAT_FIXED +#else for ( j = 0; j < DIRAC_NO_COL_AVG_DIFF; j++ ) { free( ( *hDirAC )->buffer_intensity_real_fx[i][j] ); ( *hDirAC )->buffer_intensity_real_fx[i][j] = NULL; } - free( ( *hDirAC )->direction_vector_m_fx[i] ); - ( *hDirAC )->direction_vector_m_fx[i] = NULL; #endif - free( ( *hDirAC )->direction_vector_m[i] ); - ( *hDirAC )->direction_vector_m[i] = NULL; } free( ( *hDirAC )->hMasaOut ); diff --git a/lib_rend/ivas_dirac_dec_binaural_functions.c b/lib_rend/ivas_dirac_dec_binaural_functions.c index dda58984b..2e3ea1d4b 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions.c @@ -236,7 +236,11 @@ ivas_error ivas_dirac_dec_init_binaural_data( if ( hDiracDecBin->hReverb != NULL && ( ( hDiracDecBin->hReverb->numBins != nBins ) || ( hDiracDecBin->hReverb->blockSize != CLDFB_SLOTS_PER_SUBFRAME ) ) ) { +#ifdef IVAS_FLOAT_FIXED + ivas_binaural_reverb_close_fx( &( hDiracDecBin->hReverb ) ); +#else ivas_binaural_reverb_close( &( hDiracDecBin->hReverb ) ); +#endif } if ( hDiracDecBin->hReverb == NULL ) @@ -532,8 +536,9 @@ void ivas_dirac_dec_close_binaural_data( IF ((*hBinaural)->hReverb != NULL) { +#ifdef IVAS_FLOAT_FIXED ivas_binaural_reverb_close_fx(&((*hBinaural)->hReverb)); -#ifdef IVAS_FLOAT_FIXED_TO_BE_REMOVED +#else ivas_binaural_reverb_close(&((*hBinaural)->hReverb)); #endif } diff --git a/lib_rend/ivas_orient_trk.c b/lib_rend/ivas_orient_trk.c index 0f8aa9633..add5bd875 100644 --- a/lib_rend/ivas_orient_trk.c +++ b/lib_rend/ivas_orient_trk.c @@ -906,6 +906,7 @@ static void VectorRotationToQuaternion_fx( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_orient_trk_Init( ivas_orient_trk_state_t *pOTR ) /* i/o : orientation tracker handle */ { @@ -937,8 +938,7 @@ ivas_error ivas_orient_trk_Init( return IVAS_ERR_OK; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_orient_trk_Init_fx( ivas_orient_trk_state_t *pOTR ) /* i/o : orientation tracker handle */ { @@ -957,8 +957,11 @@ ivas_error ivas_orient_trk_Init_fx( /* configuration parameters */ pOTR->centerAdaptationRate_fx = C_ADP_RATE_Q31; + move32(); pOTR->offCenterAdaptationRate_fx = OFF_C_ADP_RATE_Q31; + move32(); pOTR->adaptationAngle_fx = PI_OVER_4_Q29; /* Excursion angle relative to center at which maximum adaptation rate shall be applied */ + move32(); /* initial adaptivity filter coefficient, will be auto-adapted */ // pOTR->alpha = sinf( PI2 * pOTR->offCenterAdaptationRate / OTR_UPDATE_RATE ); /* start adaptation at off-center rate = fastest rate */ @@ -1299,6 +1302,7 @@ ivas_error ivas_orient_trk_SetReferenceVector_fx( * *-------------------------------------------------------------------*/ +#ifndef IVAS_FLOAT_FIXED ivas_error ivas_orient_trk_Process( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION absRot, /* i : absolute head rotation */ @@ -1388,8 +1392,7 @@ ivas_error ivas_orient_trk_Process( return result; } - -#ifdef IVAS_FLOAT_FIXED +#else ivas_error ivas_orient_trk_Process_fx( ivas_orient_trk_state_t *pOTR, /* i/o: orientation tracker handle */ IVAS_QUATERNION absRot, /* i : absolute head rotation */ @@ -1442,7 +1445,7 @@ ivas_error ivas_orient_trk_Process_fx( Word16 scale_e; Word32 div; - div = L_deposit_h( BASOP_Util_Divide3232_Scale( PI2_C_ADP_RATE_Q31, updateRate_fx, &scale_e ) ); + div = L_deposit_h( BASOP_Util_Divide3232_Scale( pOTR->centerAdaptationRate_fx, updateRate_fx, &scale_e ) ); scale_e = scale_e - 8; // e+e1-e2// // here div value is less so we can use sandwitch rule of sine// @@ -1463,7 +1466,7 @@ ivas_error ivas_orient_trk_Process_fx( QuaternionProduct_fx( pOTR->trkRot, absRot, &pOTR->trkRot ); angle_fx = QuaternionAngle_fx( absRot, pOTR->trkRot ); // Q29 Word16 result_e = 0; - Word16 temp_result = BASOP_Util_Divide3232_Scale( angle_fx, PI_OVER_4_Q29, &result_e ); + Word16 temp_result = BASOP_Util_Divide3232_Scale( angle_fx, pOTR->adaptationAngle_fx, &result_e ); relativeOrientationRate_fx = L_deposit_h( temp_result ); Word32 one_fx; Word16 temp = result_e; @@ -1474,8 +1477,7 @@ ivas_error ivas_orient_trk_Process_fx( } /* Compute range of the adaptation rate between center = lower rate and off-center = higher rate */ - // rateRange_fx = L_sub(pOTR1_fx->offCenterAdaptationRate_fx, pOTR1_fx->centerAdaptationRate_fx); - rateRange_fx = L_sub( OFF_C_ADP_RATE_Q31, C_ADP_RATE_Q31 ); // repalce this with above line once calling functions are converted// + rateRange_fx = L_sub( pOTR->offCenterAdaptationRate_fx, pOTR->centerAdaptationRate_fx ); /* 'if' assumed to perform comparison to 0 */ IF( GT_32( 0, rateRange_fx ) ) { @@ -1495,7 +1497,7 @@ ivas_error ivas_orient_trk_Process_fx( temp_diff = 31 - q_cutoff_prod; cutoff_prod = L_shl( cutoff_prod, temp_diff ); /* Compute adaptivity cutoff frequency: interpolate between minimum (center) and maximum (off-center) values */ - cutoffFrequency_fx = L_add( C_ADP_RATE_Q31, cutoff_prod ); + cutoffFrequency_fx = L_add( pOTR->centerAdaptationRate_fx, cutoff_prod ); cutoff_prod = Mpy_32_32( cutoffFrequency_fx, PI2_C_Q28 ); q_cutoff_prod = 31 + 28 - 31; temp_result = BASOP_Util_Divide3232_Scale( cutoff_prod, updateRate_fx, &result_e ); diff --git a/lib_rend/ivas_prot_rend.h b/lib_rend/ivas_prot_rend.h index bb95f0b38..866bd05a5 100644 --- a/lib_rend/ivas_prot_rend.h +++ b/lib_rend/ivas_prot_rend.h @@ -2120,9 +2120,15 @@ ivas_error ivas_er_process( * Rotation Prototypes *-----------------------------------------------------------------------------------*/ +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_headTrack_open_fx( + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ +); +#else ivas_error ivas_headTrack_open( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ); +#endif void ivas_headTrack_close( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* i/o: head track handle */ diff --git a/lib_rend/ivas_reverb.c b/lib_rend/ivas_reverb.c index cbf9fe390..d95009101 100644 --- a/lib_rend/ivas_reverb.c +++ b/lib_rend/ivas_reverb.c @@ -223,19 +223,20 @@ static uint16_t binRend_rand( return (uint16_t) ( hReverb->binRend_RandNext / 65536 ) % 32768; } -#ifdef IVAS_FLOAT_FIXED + /*------------------------------------------------------------------------- * ivas_binaural_reverb_setPreDelay() * * *------------------------------------------------------------------------*/ -static void ivas_binaural_reverb_setPreDelay( +#ifdef IVAS_FLOAT_FIXED +static void ivas_binaural_reverb_setPreDelay_fx( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const Word16 delaySamples /* i : reverb pre-delay in CLDFB slots */ ) { - IF ( LT_16( delaySamples, 1 ) ) + IF( LT_16( delaySamples, 1 ) ) { hReverb->preDelayBufferLength = 1; move16(); @@ -243,7 +244,7 @@ static void ivas_binaural_reverb_setPreDelay( return; } - IF ( GT_16( delaySamples, REVERB_PREDELAY_MAX ) ) + IF( GT_16( delaySamples, REVERB_PREDELAY_MAX ) ) { hReverb->preDelayBufferLength = REVERB_PREDELAY_MAX; move16(); @@ -257,12 +258,6 @@ static void ivas_binaural_reverb_setPreDelay( return; } #else -/*------------------------------------------------------------------------- - * ivas_binaural_reverb_setPreDelay() - * - * - *------------------------------------------------------------------------*/ - static void ivas_binaural_reverb_setPreDelay( REVERB_STRUCT_HANDLE hReverb, /* i/o: binaural reverb handle */ const int16_t delaySamples /* i : reverb pre-delay in CLDFB slots */ @@ -288,6 +283,7 @@ static void ivas_binaural_reverb_setPreDelay( } #endif + /*------------------------------------------------------------------------- * ivas_binaural_reverb_setReverbTimes() * @@ -3778,11 +3774,12 @@ static ivas_error ivas_binaural_reverb_open( for ( k = 0; k < REVERB_PREDELAY_MAX + 1; k++ ) { +#ifndef IVAS_FLOAT_FIXED set_f( hReverb->preDelayBufferReal[k], 0.0f, hReverb->numBins ); set_f( hReverb->preDelayBufferImag[k], 0.0f, hReverb->numBins ); -#ifdef IVAS_FLOAT_FIXED - set_l( hReverb->preDelayBufferReal_fx[k], 0, hReverb->numBins ); - set_l( hReverb->preDelayBufferImag_fx[k], 0, hReverb->numBins ); +#else + set32_fx( hReverb->preDelayBufferReal_fx[k], 0, hReverb->numBins ); + set32_fx( hReverb->preDelayBufferImag_fx[k], 0, hReverb->numBins ); #endif } @@ -3792,6 +3789,7 @@ static ivas_error ivas_binaural_reverb_open( hReverb->loopBufLengthMax[bin] = (int16_t) ( 500 / ( 1 + bin ) + ( CLDFB_NO_CHANNELS_MAX - bin ) ); len = hReverb->loopBufLengthMax[bin] + hReverb->blockSize; +#ifndef IVAS_FLOAT_FIXED if ( ( hReverb->loopBufReal[bin] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); @@ -3803,7 +3801,7 @@ static ivas_error ivas_binaural_reverb_open( } set_f( hReverb->loopBufReal[bin], 0.0f, len ); set_f( hReverb->loopBufImag[bin], 0.0f, len ); -#ifdef IVAS_FLOAT_FIXED +#else if ( ( hReverb->loopBufReal_fx[bin] = (Word32 *) malloc( len * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); @@ -3813,8 +3811,8 @@ static ivas_error ivas_binaural_reverb_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); } - set_l( hReverb->loopBufReal_fx[bin], 0, len ); - set_l( hReverb->loopBufImag_fx[bin], 0, len ); + set32_fx( hReverb->loopBufReal_fx[bin], 0, len ); + set32_fx( hReverb->loopBufImag_fx[bin], 0, len ); #endif /* Determine loop buffer length. The following formula is manually tuned to generate sufficiently long @@ -3867,8 +3865,8 @@ static ivas_error ivas_binaural_reverb_open( { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Binaural Reverberator\n" ) ); } - set_l( hReverb->outputBufferReal_fx[bin][chIdx], 0, len ); - set_l( hReverb->outputBufferImag_fx[bin][chIdx], 0, len ); + set32_fx( hReverb->outputBufferReal_fx[bin][chIdx], 0, len ); + set32_fx( hReverb->outputBufferImag_fx[bin][chIdx], 0, len ); #else if ( ( hReverb->outputBufferReal[bin][chIdx] = (float *) malloc( len * sizeof( float ) ) ) == NULL ) { @@ -3895,20 +3893,17 @@ static ivas_error ivas_binaural_reverb_open( } ivas_binaural_reverb_setReverbTimes_fx( hReverb, sampling_rate, revTimes_fx, revEnes_fx ); - FOR( bin = 0; bin < hReverb->numBins; bin++) - { - hReverb->binauralCoherenceDirectGains[bin] = (float)hReverb->binauralCoherenceDirectGains_fx[bin] / ONE_IN_Q31; - hReverb->binauralCoherenceCrossmixGains[bin] = (float)hReverb->binauralCoherenceCrossmixGains_fx[bin] / ONE_IN_Q31; - hReverb->loopAttenuationFactor[bin] = (float)hReverb->loopAttenuationFactor_fx[bin] / ONE_IN_Q31; - hReverb->reverbEqGains[bin] = (float)hReverb->reverbEqGains_fx[bin] / ONE_IN_Q31; - } free(revTimes_fx); free(revEnes_fx); #else ivas_binaural_reverb_setReverbTimes( hReverb, sampling_rate, revTimes, revEnes ); #endif +#ifdef IVAS_FLOAT_FIXED + ivas_binaural_reverb_setPreDelay_fx( hReverb, preDelay ); +#else ivas_binaural_reverb_setPreDelay( hReverb, preDelay ); +#endif return IVAS_ERR_OK; } @@ -4023,6 +4018,7 @@ void ivas_binaural_reverb_close_fx( { Word16 bin, chIdx; + test(); IF( hReverb == NULL || *hReverb == NULL ) { return; @@ -4033,7 +4029,6 @@ void ivas_binaural_reverb_close_fx( FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] ); - free( ( *hReverb )->tapPointersReal_fx[bin][chIdx] ); free( ( *hReverb )->tapPointersImag_fx[bin][chIdx] ); free( ( *hReverb )->outputBufferReal_fx[bin][chIdx] ); @@ -4048,27 +4043,25 @@ void ivas_binaural_reverb_close_fx( return; } -#endif +#else void ivas_binaural_reverb_close( REVERB_STRUCT_HANDLE *hReverb /* i/o: binaural reverb handle */ ) { - Word16 bin, chIdx; + int16_t bin, chIdx; - IF( hReverb == NULL || *hReverb == NULL ) + if ( hReverb == NULL || *hReverb == NULL ) { return; } - FOR( bin = 0; bin < ( *hReverb )->numBins; bin++ ) + for ( bin = 0; bin < ( *hReverb )->numBins; bin++ ) { - FOR( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) + for ( chIdx = 0; chIdx < BINAURAL_CHANNELS; chIdx++ ) { free( ( *hReverb )->tapPhaseShiftType[bin][chIdx] ); -#ifndef IVAS_FLOAT_FIXED free( ( *hReverb )->tapPointersReal[bin][chIdx] ); free( ( *hReverb )->tapPointersImag[bin][chIdx] ); -#endif free( ( *hReverb )->outputBufferReal[bin][chIdx] ); free( ( *hReverb )->outputBufferImag[bin][chIdx] ); } @@ -4081,3 +4074,4 @@ void ivas_binaural_reverb_close( return; } +#endif diff --git a/lib_rend/ivas_rom_rend.c b/lib_rend/ivas_rom_rend.c index bff2bd7ce..eaba2d206 100644 --- a/lib_rend/ivas_rom_rend.c +++ b/lib_rend/ivas_rom_rend.c @@ -1513,7 +1513,7 @@ const float ls_conversion_cicpX_stereo[12][2] = {0.849999964f, 0.000000000f}, {0.000000000f, 0.849999964f} }; - +#ifndef IVAS_FLOAT_FIXED const LS_CONVERSION_MATRIX ls_conversion_cicp12_cicp6[] = { /* First row indicates the number of non-zero elements and the number of matrix columns */ @@ -1828,5 +1828,5 @@ const LS_CONVERSION_MAPPING ls_conversion_mapping[LS_SETUP_CONVERSION_NUM_MAPPIN {IVAS_AUDIO_CONFIG_5_1_4, IVAS_AUDIO_CONFIG_7_1_4, ls_conversion_cicp16_cicp19}, }; - +#endif /* clang-format on */ diff --git a/lib_rend/ivas_rom_rend.h b/lib_rend/ivas_rom_rend.h index 6c2831c63..7ffcb441e 100644 --- a/lib_rend/ivas_rom_rend.h +++ b/lib_rend/ivas_rom_rend.h @@ -186,8 +186,9 @@ extern const Word32 ls_conversion_cicpX_stereo_fx[12][2]; #endif /* Mapping table of input config : output config with corresponding matrix */ +#ifndef IVAS_FLOAT_FIXED extern const LS_CONVERSION_MAPPING ls_conversion_mapping[]; -#ifdef IVAS_FLOAT_FIXED +#else extern const LS_CONVERSION_MAPPING_FX ls_conversion_mapping_fx[]; #endif diff --git a/lib_rend/ivas_rotation.c b/lib_rend/ivas_rotation.c index 7d36ca793..ca299c1e1 100644 --- a/lib_rend/ivas_rotation.c +++ b/lib_rend/ivas_rotation.c @@ -108,41 +108,80 @@ static bool are_orientations_same( const IVAS_QUATERNION *orientation1, const IV * Allocate and initialize Head-Tracking handle *-----------------------------------------------------------------------*/ -ivas_error ivas_headTrack_open( +#ifdef IVAS_FLOAT_FIXED +ivas_error ivas_headTrack_open_fx( HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ ) { - int16_t i; + Word16 i; ivas_error error; /* Allocate Head-Tracking handle */ - if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) + IF( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for head-tracking memory\n" ) ); } /* Initialization */ - ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f; + ( *hHeadTrackData )->lrSwitchInterpVal_fx = 0; + move32(); ( *hHeadTrackData )->lrSwitchedCurrent = 0; + move32(); ( *hHeadTrackData )->lrSwitchedNext = 0; - if ( ( ( *hHeadTrackData )->OrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) + move32(); + IF( ( ( *hHeadTrackData )->OrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); } -#ifdef IVAS_FLOAT_FIXED - - if ( ( error = ivas_orient_trk_Init_fx( ( *hHeadTrackData )->OrientationTracker ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_orient_trk_Init_fx( ( *hHeadTrackData )->OrientationTracker ) ) != IVAS_ERR_OK ) { return error; } + /* Initialise Rmat_prev to I, Rmat will be computed later */ + FOR( i = 0; i < 3; i++ ) + { + set32_fx( ( *hHeadTrackData )->Rmat_prev_fx[i], 0, 3 ); + ( *hHeadTrackData )->Rmat_prev_fx[i][i] = ONE_IN_Q31; + move32(); + } + + + set32_fx( ( *hHeadTrackData )->chEneIIR_fx[0], 0, MASA_FREQUENCY_BANDS ); + set32_fx( ( *hHeadTrackData )->chEneIIR_fx[1], 0, MASA_FREQUENCY_BANDS ); + set32_fx( ( *hHeadTrackData )->procChEneIIR_fx[0], 0, MASA_FREQUENCY_BANDS ); + set32_fx( ( *hHeadTrackData )->procChEneIIR_fx[1], 0, MASA_FREQUENCY_BANDS ); + + return IVAS_ERR_OK; +} #else +ivas_error ivas_headTrack_open( + HEAD_TRACK_DATA_HANDLE *hHeadTrackData /* o : head track handle */ +) +{ + int16_t i; + ivas_error error; + + /* Allocate Head-Tracking handle */ + if ( ( *hHeadTrackData = (HEAD_TRACK_DATA_HANDLE) malloc( sizeof( HEAD_TRACK_DATA ) ) ) == NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for head-tracking memory\n" ) ); + } + + /* Initialization */ + ( *hHeadTrackData )->lrSwitchInterpVal = 0.0f; + ( *hHeadTrackData )->lrSwitchedCurrent = 0; + ( *hHeadTrackData )->lrSwitchedNext = 0; + if ( ( ( *hHeadTrackData )->OrientationTracker = (ivas_orient_trk_state_t *) malloc( sizeof( ivas_orient_trk_state_t ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); + } + if ( ( error = ivas_orient_trk_Init( ( *hHeadTrackData )->OrientationTracker ) ) != IVAS_ERR_OK ) { return error; } -#endif /* Initialise Rmat_prev to I, Rmat will be computed later */ for ( i = 0; i < 3; i++ ) @@ -159,6 +198,7 @@ ivas_error ivas_headTrack_open( return IVAS_ERR_OK; } +#endif /*-----------------------------------------------------------------------* diff --git a/lib_rend/ivas_stat_rend.h b/lib_rend/ivas_stat_rend.h index f8e577f69..d266aecfe 100644 --- a/lib_rend/ivas_stat_rend.h +++ b/lib_rend/ivas_stat_rend.h @@ -731,14 +731,13 @@ typedef struct vbap_data_structure /* Binaural reverberator structure */ typedef struct ivas_binaural_reverb_struct { +#ifndef IVAS_FLOAT_FIXED float *loopBufReal[CLDFB_NO_CHANNELS_MAX]; float *loopBufImag[CLDFB_NO_CHANNELS_MAX]; float preDelayBufferReal[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; float preDelayBufferImag[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; -#ifndef IVAS_FLOAT_FIXED float **tapPointersReal[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; float **tapPointersImag[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; -#endif float binauralCoherenceCrossmixGains[CLDFB_NO_CHANNELS_MAX]; float binauralCoherenceDirectGains[CLDFB_NO_CHANNELS_MAX]; @@ -747,8 +746,7 @@ typedef struct ivas_binaural_reverb_struct float *outputBufferReal[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; float *outputBufferImag[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; - -#ifdef IVAS_FLOAT_FIXED +#else Word32 *loopBufReal_fx[CLDFB_NO_CHANNELS_MAX]; Word32 *loopBufImag_fx[CLDFB_NO_CHANNELS_MAX]; Word32 preDelayBufferReal_fx[REVERB_PREDELAY_MAX + 1][CLDFB_NO_CHANNELS_MAX]; @@ -756,28 +754,28 @@ typedef struct ivas_binaural_reverb_struct Word32 **tapPointersReal_fx[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; Word32 **tapPointersImag_fx[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; - Word32 binauralCoherenceCrossmixGains_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 binauralCoherenceDirectGains_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 reverbEqGains_fx[CLDFB_NO_CHANNELS_MAX]; - Word32 loopAttenuationFactor_fx[CLDFB_NO_CHANNELS_MAX]; + Word32 binauralCoherenceCrossmixGains_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 binauralCoherenceDirectGains_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 reverbEqGains_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ + Word32 loopAttenuationFactor_fx[CLDFB_NO_CHANNELS_MAX]; /* Q31 */ Word32 *outputBufferReal_fx[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; Word32 *outputBufferImag_fx[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; #endif - int16_t numBins; + Word16 numBins; - int16_t useBinauralCoherence; - int16_t loopBufLength[CLDFB_NO_CHANNELS_MAX]; - int16_t loopBufLengthMax[CLDFB_NO_CHANNELS_MAX]; - int16_t preDelayBufferIndex; - int16_t preDelayBufferLength; + Word16 useBinauralCoherence; + Word16 loopBufLength[CLDFB_NO_CHANNELS_MAX]; + Word16 loopBufLengthMax[CLDFB_NO_CHANNELS_MAX]; + Word16 preDelayBufferIndex; + Word16 preDelayBufferLength; - int16_t taps[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; - int16_t *tapPhaseShiftType[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; + Word16 taps[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; + Word16 *tapPhaseShiftType[CLDFB_NO_CHANNELS_MAX][BINAURAL_CHANNELS]; - int16_t blockSize; - uint32_t binRend_RandNext; - int16_t highestBinauralCoherenceBin; + Word16 blockSize; + UWord32 binRend_RandNext; + Word16 highestBinauralCoherenceBin; #ifndef IVAS_FLOAT_FIXED float dmxmtx[BINAURAL_CHANNELS][MAX_OUTPUT_CHANNELS]; @@ -995,67 +993,71 @@ typedef struct EFAP typedef struct ivas_orient_trk_state_t { IVAS_HEAD_ORIENT_TRK_T orientation_tracking; +#ifndef IVAS_FLOAT_FIXED float centerAdaptationRate; float offCenterAdaptationRate; float adaptationAngle; +#endif float alpha; - IVAS_QUATERNION absAvgRot; /* average absolute orientation */ - IVAS_QUATERNION refRot; /* reference orientation */ - IVAS_QUATERNION trkRot; /* tracked rotation */ - #ifdef IVAS_FLOAT_FIXED - Word32 centerAdaptationRate_fx; - Word32 offCenterAdaptationRate_fx; - Word32 adaptationAngle_fx; + Word32 centerAdaptationRate_fx; /* Q31 */ + Word32 offCenterAdaptationRate_fx; /* Q31 */ + Word32 adaptationAngle_fx; /* Q29 */ +#endif Word32 alpha_fx; -#endif + IVAS_QUATERNION absAvgRot; /* average absolute orientation */ + IVAS_QUATERNION refRot; /* reference orientation */ + IVAS_QUATERNION trkRot; /* tracked rotation */ } ivas_orient_trk_state_t; /*----------------------------------------------------------------------------------* * Head rotation data structure *----------------------------------------------------------------------------------*/ -#ifdef IVAS_FLOAT_FIXED + typedef struct { Word8 headRotEnabled; IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_VECTOR3 Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; #ifdef IVAS_FLOAT_FIXED - Word32 crossfade_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; -#endif - float crossfade[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; - ivas_orient_trk_state_t *hOrientationTracker; - -} IVAS_REND_HeadRotData; + Word32 crossfade_fx[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; /* Q31 */ #else -typedef struct -{ - int8_t headRotEnabled; - IVAS_QUATERNION headPositions[MAX_PARAM_SPATIAL_SUBFRAMES]; - IVAS_VECTOR3 Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; float crossfade[L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#endif ivas_orient_trk_state_t *hOrientationTracker; } IVAS_REND_HeadRotData; -#endif + typedef struct ivas_binaural_head_track_struct { IVAS_QUATERNION Quaternions[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_VECTOR3 Pos[MAX_PARAM_SPATIAL_SUBFRAMES]; +#ifndef IVAS_FLOAT_FIXED float Rmat[3][3]; float Rmat_prev[3][3]; +#else + Word32 Rmat_fx[3][3]; + Word32 Rmat_prev_fx[3][3]; +#endif - uint8_t lrSwitchedNext; - uint8_t lrSwitchedCurrent; + UWord8 lrSwitchedNext; + UWord8 lrSwitchedCurrent; +#ifndef IVAS_FLOAT_FIXED float lrSwitchInterpVal; float chEneIIR[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ float procChEneIIR[2][MASA_FREQUENCY_BANDS]; +#else + Word32 lrSwitchInterpVal_fx; - int16_t shd_rot_max_order; + Word32 chEneIIR_fx[2][MASA_FREQUENCY_BANDS]; /* independent of the format. MASA bands are suitable for the task and readily available in ROM. */ + Word32 procChEneIIR_fx[2][MASA_FREQUENCY_BANDS]; +#endif + + Word16 shd_rot_max_order; ivas_orient_trk_state_t *OrientationTracker; } HEAD_TRACK_DATA, *HEAD_TRACK_DATA_HANDLE; @@ -2066,12 +2068,21 @@ typedef struct typedef struct ivas_LS_setupconversion_struct { +#ifndef IVAS_FLOAT_FIXED float *dmxMtx[MAX_OUTPUT_CHANNELS]; +#else Word32 *dmxMtx_fx[MAX_OUTPUT_CHANNELS]; // Q30 +#endif +#ifndef IVAS_FLOAT_FIXED float *targetEnergyPrev[MAX_OUTPUT_CHANNELS]; +#else Word32 *targetEnergyPrev_fx[MAX_OUTPUT_CHANNELS]; +#endif +#ifndef IVAS_FLOAT_FIXED float *dmxEnergyPrev[MAX_OUTPUT_CHANNELS]; +#else Word32 *dmxEnergyPrev_fx[MAX_OUTPUT_CHANNELS]; +#endif int16_t sfbOffset[MAX_SFB + 2]; int16_t sfbCnt; #ifdef IVAS_FLOAT_FIXED @@ -2094,7 +2105,7 @@ typedef struct ivas_LS_setupconversion_mapping_fx AUDIO_CONFIG output_config; const LS_CONVERSION_MATRIX_FX *conversion_matrix_fx; } LS_CONVERSION_MAPPING_FX; -#endif +#else typedef struct ivas_LS_setupconversion_matrix { @@ -2108,17 +2119,17 @@ typedef struct ivas_LS_setupconversion_mapping AUDIO_CONFIG output_config; const LS_CONVERSION_MATRIX *conversion_matrix; } LS_CONVERSION_MAPPING; - +#endif typedef struct ivas_mono_downmix_renderer_struct { +#ifndef IVAS_FLOAT_FIXED float inputEnergy; float protoEnergy; -#ifdef IVAS_FLOAT_FIXED +#else Word32 inputEnergy_fx; Word16 Q_inputEner; Word32 protoEnergy_fx; Word16 Q_protoEner; - #endif } MONO_DOWNMIX_RENDERER_STRUCT, *MONO_DOWNMIX_RENDERER_HANDLE; @@ -2139,7 +2150,6 @@ typedef struct ivas_LS_setup_custom Word16 num_lfe; /* number of LFE channels */ Word16 lfe_idx[MAX_OUTPUT_CHANNELS]; /* index for LFE channel insertion */ Word16 separate_ch_found; /* flag to indicate if a center channel was found */ - float separate_ch_gains[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */ Word16 separate_ch_gains_fx[MAX_OUTPUT_CHANNELS]; /* gains to pan McMASA separateChannel in case no center channel is present */ } LSSETUP_CUSTOM_STRUCT, *LSSETUP_CUSTOM_HANDLE; @@ -2288,17 +2298,26 @@ typedef struct ivas_dirac_ana_data_structure HANDLE_CLDFB_FILTER_BANK cldfbAnaEnc[DIRAC_MAX_ANA_CHANS]; /* DirAC parameter estimation */ +#ifndef IVAS_FLOAT_FIXED float **direction_vector_m[DIRAC_NUM_DIMS]; /* Average direction vector */ +#else Word32 **direction_vector_m_fx[DIRAC_NUM_DIMS]; /* Average direction vector */ +#endif int16_t band_grouping[MASA_FREQUENCY_BANDS + 1]; int16_t block_grouping[5]; /* diffuseness */ int16_t index_buffer_intensity; +#ifndef IVAS_FLOAT_FIXED float *buffer_intensity_real[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; +#else Word32 *buffer_intensity_real_fx[DIRAC_NUM_DIMS][DIRAC_NO_COL_AVG_DIFF]; +#endif +#ifndef IVAS_FLOAT_FIXED float buffer_energy[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS]; +#else Word32 buffer_energy_fx[DIRAC_NO_COL_AVG_DIFF * MASA_FREQUENCY_BANDS]; +#endif MASA_DECODER_EXT_OUT_META_HANDLE hMasaOut; SPHERICAL_GRID_DATA *sph_grid16; diff --git a/lib_rend/lib_rend.c b/lib_rend/lib_rend.c index 8ecc530fe..dbbdbd13f 100644 --- a/lib_rend/lib_rend.c +++ b/lib_rend/lib_rend.c @@ -464,6 +464,32 @@ static void freeMcLfeDelayBuffer( return; } +#ifdef IVAS_FLOAT_FIXED +static IVAS_QUATERNION quaternionInit_fx( + void ) +{ + IVAS_QUATERNION q; + q.w_fx = ONE_IN_Q29; + move32(); + q.x_fx = q.y_fx = q.z_fx = 0; + move32(); + move32(); + move32(); + + q.w_qfact = q.x_qfact = q.y_qfact = q.z_qfact = Q29; + move16(); + move16(); + move16(); + move16(); + +#ifndef IVAS_FLOAT_FIXED_TO_BE_REMOVED + q.w = 1.0f; + q.x = q.y = q.z = 0.0f; +#endif + + return q; +} +#else static IVAS_QUATERNION quaternionInit( void ) { @@ -472,6 +498,8 @@ static IVAS_QUATERNION quaternionInit( q.x = q.y = q.z = 0.0f; return q; } +#endif + #ifdef IVAS_FLOAT_FIXED static Word32 *getSmplPtr_fx( IVAS_REND_AudioBuffer buffer, @@ -1090,7 +1118,7 @@ static LSSETUP_CUSTOM_STRUCT defaultCustomLs( ls.num_lfe = 0; set_s( ls.lfe_idx, 0, MAX_OUTPUT_CHANNELS ); ls.separate_ch_found = 0; - set_f( ls.separate_ch_gains, 0, MAX_OUTPUT_CHANNELS ); + set_val_Word16( ls.separate_ch_gains_fx, 0, MAX_OUTPUT_CHANNELS ); return ls; } @@ -1742,12 +1770,11 @@ static ivas_error getEfapGains( } #ifdef IVAS_FLOAT_FIXED -static ivas_error initHeadRotation( +static ivas_error initHeadRotation_fx( IVAS_REND_HANDLE hIvasRend ) { Word16 i, crossfade_len; Word32 tmp_fx; - float tmp; ivas_error error; /* Head rotation is enabled by default */ @@ -1755,19 +1782,20 @@ static ivas_error initHeadRotation( /* Initialize 5ms crossfade */ crossfade_len = L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES; - tmp = 1.f / ( crossfade_len - 1 ); + move16(); tmp_fx = Q31_BY_SUB_FRAME_240; + move16(); - for ( i = 0; i < crossfade_len; i++ ) + FOR( i = 0; i < crossfade_len; i++ ) { - hIvasRend->headRotData.crossfade[i] = i * tmp; hIvasRend->headRotData.crossfade_fx[i] = UL_Mpy_32_32( i, tmp_fx ); + move32(); } /* Initialize with unit quaternions */ FOR( i = 0; i < hIvasRend->num_subframes; ++i ) { - hIvasRend->headRotData.headPositions[i] = quaternionInit(); + hIvasRend->headRotData.headPositions[i] = quaternionInit_fx(); } @@ -1776,17 +1804,10 @@ static ivas_error initHeadRotation( return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Orientation tracking" ); } -#ifdef IVAS_FLOAT_FIXED IF( ( error = ivas_orient_trk_Init_fx( hIvasRend->headRotData.hOrientationTracker ) ) != IVAS_ERR_OK ) { return error; } -#else - IF( ( error = ivas_orient_trk_Init( hIvasRend->headRotData.hOrientationTracker ) ) != IVAS_ERR_OK ) - { - return error; - } -#endif return IVAS_ERR_OK; } @@ -2240,7 +2261,7 @@ static void copyLsConversionMatrixToPanMatrix_fx( return; } -#endif +#else static void copyLsConversionMatrixToPanMatrix( const LS_CONVERSION_MATRIX *lsConvMatrix, @@ -2265,7 +2286,7 @@ static void copyLsConversionMatrixToPanMatrix( return; } - +#endif static void setZeroPanMatrix( pan_matrix panMatrix ) { @@ -2373,7 +2394,7 @@ static ivas_error initMcPanGainsWithConversionMapping_fx( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Missing multichannel conversion mapping" ); } -#endif +#else static ivas_error initMcPanGainsWithConversionMapping( input_mc *inputMc, @@ -2408,6 +2429,7 @@ static ivas_error initMcPanGainsWithConversionMapping( return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Missing multichannel conversion mapping" ); } +#endif #ifdef IVAS_FLOAT_FIXED static ivas_error initMcPanGainsWithEfap_fx( input_mc *inputMc, @@ -4620,7 +4642,7 @@ ivas_error IVAS_REND_Open( } /* Initialize headrotation data */ - if ( ( error = initHeadRotation( hIvasRend ) ) != IVAS_ERR_OK ) + IF( ( error = initHeadRotation_fx( hIvasRend ) ) != IVAS_ERR_OK ) { return error; } @@ -6742,6 +6764,8 @@ static void renderBufferChannel( return; } + +#ifndef IVAS_FLOAT_FIXED static ivas_error chooseCrossfade( const IVAS_REND_HeadRotData *headRotData, const float **pCrossfade ) @@ -6750,17 +6774,19 @@ static ivas_error chooseCrossfade( return IVAS_ERR_OK; } -#ifdef IVAS_FLOAT_FIXED +#else static ivas_error chooseCrossfade_fx( const IVAS_REND_HeadRotData *headRotData, const Word32 **pCrossfade ) { *pCrossfade = headRotData->crossfade_fx; + move32(); return IVAS_ERR_OK; } - #endif + + #ifdef IVAS_FLOAT_FIXED static ivas_error rotateFrameMc_fx( IVAS_REND_AudioBuffer inAudio, /* i : Input Audio buffer */ @@ -6917,8 +6943,7 @@ static ivas_error rotateFrameMc_fx( pop_wmops(); return IVAS_ERR_OK; } -#endif - +#else static ivas_error rotateFrameMc( IVAS_REND_AudioBuffer inAudio, /* i : Input Audio buffer */ AUDIO_CONFIG inConfig, /* i : Input Audio config */ @@ -7061,9 +7086,10 @@ static ivas_error rotateFrameMc( pop_wmops(); return IVAS_ERR_OK; } +#endif -#ifdef IVAS_FLOAT_FIXED +#ifdef IVAS_FLOAT_FIXED static ivas_error rotateFrameSba_fx( IVAS_REND_AudioBuffer inAudio, /* i : Input Audio buffer */ const AUDIO_CONFIG inConfig, /* i : Input Audio config */ @@ -7298,6 +7324,7 @@ static ivas_error rotateFrameSba( #endif + static ivas_error renderIsmToBinaural( const input_ism *ismInput, IVAS_REND_AudioBuffer outAudio ) @@ -11266,7 +11293,11 @@ static void freeMasaExtRenderer( if ( hMasaExtRend->hReverb != NULL ) { +#ifdef IVAS_FLOAT_FIXED + ivas_binaural_reverb_close_fx( &hMasaExtRend->hReverb ); +#else ivas_binaural_reverb_close( &hMasaExtRend->hReverb ); +#endif } if ( hMasaExtRend->hHrtfParambin != NULL ) -- GitLab