diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index bb61171a803cbc042b4562241d0ce8fc7ccecf27..66e8f6dfa07ed4629c416bced48857875491f2f6 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -195,7 +195,11 @@ typedef enum #define MAX_JBM_L_FRAME48k 1920 #define MAX_JBM_L_FRAME_NS 40000000L #define MAX_SPAR_INTERNAL_CHANNELS IVAS_SPAR_MAX_CH +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +#define MAX_CLDFB_DIGEST_CHANNELS 3 /* == maximum of ParamISM TCs and ParamMC TCs */ +#else #define MAX_CLDFB_DIGEST_CHANNELS (FOA_CHANNELS + MAX_NUM_OBJECTS) +#endif typedef enum { diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index a88c13583e7be8b816e08d90d859e4bae0c68194..faaf2b55ad52a1676a68cfff25507d77db5a944a 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -641,6 +641,7 @@ void ivas_jbm_dec_get_adapted_subframes_fx( Word16 *nb_subframes /* i/o: number of subframes in the frame */ ); +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS void ivas_jbm_dec_copy_tc_no_tsm_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle Q0 */ Word32 *tc_fx[], /* i : transport channels Q11 */ @@ -654,7 +655,7 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( Word32 *transport_channels_f[], /* i : synthesized core-coder transport channels/DirAC output Q_tc*/ Word16 *Q_tc /* i/o : Q of input tc buffer */ ); - +#endif /*! r: number of bits read */ Word16 read_GR0( const UWord16 *bit_stream, /* i : bitstream to be read */ @@ -4234,14 +4235,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ Word16 *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - Word32 *data /* i/o: transport channels/output synthesis signal */ -); - -void ivas_jbm_dec_feed_tc_to_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ - Word16 *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ - Word32 *data /* i/o: transport channels/output synthesis signal */ + Word32 *data_fx /* i/o: transport channels/output synthesis signal */ ); void ivas_dec_prepare_renderer_fx( @@ -4336,11 +4330,10 @@ void ivas_ism_dec_digest_tc_fx( void ivas_param_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord16 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output */ - const Word16 q_tc_in + Word32 *p_data_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ + const Word16 q_data_in /* i : Q-factor of input signal for single channel */ ); - void ivas_param_ism_dec_dequant_md_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder handle */ ); @@ -4355,7 +4348,7 @@ void ivas_param_ism_dec_render_fx( const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ - Word32 *output_f_fx[] + Word32 *output_f_fx[] /* i/o: synthesized core-coder TCs / rendered signal*/ ); void ivas_param_ism_params_to_masa_param_mapping_fx( @@ -5145,7 +5138,7 @@ void ivas_param_mc_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots, /* i : number of CLFBS slots in the transport channels */ Word32 *p_data_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const Word16 transport_f_e + const Word16 q_data /* i : Q-factor of input signal for single channel */ ); void ivas_param_mc_dec_prepare_renderer( diff --git a/lib_com/options.h b/lib_com/options.h index fefc866d63b02944aeb49439535558a356c7f62a..5b005464915c745d281d27dade19a0976df49ac9 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,6 +115,7 @@ #define FIX_1388_MSAN_ivas_init_decoder /* VA: issue 1388: fix use-of-uninitialized value in ivas_init_decoder() */ #define FIX_1288_SPLIT_REND_XSAN /* Dlb: Fix asan, msan and usan issues in split rendering mode*/ #define LIB_DEC_REVISION /* VA: cleaning and simplification of lib_dec.c */ +#define UNIFIED_DECODING_PATHS_LEFTOVERS /* VA: issue 880: remove leftovers after NONBE_UNIFIED_DECODING_PATHS */ // object-editing feature porting #define TMP_FIX_SPLIT_REND // temporary fix to split-rendering (it follows the later state of the framework but it is needed now because of current test-conditions) diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index a41b2310f0b4184902fe10a4d7b74f9dcf1470c1..14e38ebdb85cd91d0a54277021c6a97b567119b9 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2076,7 +2076,7 @@ void ivas_dirac_dec_render_fx( move16(); SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word32 *output_f_local_fx[MAX_OUTPUT_CHANNELS]; - Word32 output_f_local_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 }; // VE2SB: TBV + Word32 output_f_local_buff_fx[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 }; hSpatParamRendCom = st_ivas->hSpatParamRendCom; diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index d2243feb2816ab4e972971aa54a0d3d5873da036..a094d8cf20c1488b02e0368813bd0347ae4488ff 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -44,6 +44,15 @@ #include "debug.h" +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +/*-----------------------------------------------------------------------* + * Local function declarations + *-----------------------------------------------------------------------*/ + +static void ivas_ism_param_dec_tc_gain_adjust_fx( Decoder_Struct *st_ivas, const Word16 nSamples, const Word16 nFadeLength, Word32 *p_data_fx[], Word16 *q_data ); + +#endif + /*-----------------------------------------------------------------------* * Local function definitions *-----------------------------------------------------------------------*/ @@ -72,6 +81,7 @@ static void ivas_param_ism_dec_dequant_DOA_fx( return; } + static void ivas_param_ism_dec_dequant_powrat_fx( PARAM_ISM_DEC_HANDLE hParamIsmDec /* i/o: decoder ParamISM handle */ ) @@ -167,6 +177,7 @@ static void ivas_ism_get_proto_matrix_fx( return; } + static void ivas_param_ism_collect_slot_fx( PARAM_ISM_DEC_HANDLE hParamIsmDec, /* i/o: decoder ParamISM handle */ Word32 *Cldfb_RealBuffer_in_fx, /*Q(31-exp_real)*/ @@ -183,7 +194,6 @@ static void ivas_param_ism_collect_slot_fx( Word16 exp_tmp; /* loop over parameter bands to collect transport channel energies */ - FOR( band_idx = 0; band_idx < hParamIsmDec->hParamIsm->nbands; band_idx++ ) { brange[0] = hParamIsmDec->hParamIsm->band_grouping[band_idx]; @@ -210,6 +220,7 @@ static void ivas_param_ism_collect_slot_fx( move16(); } } + return; } @@ -391,6 +402,7 @@ static void ivas_param_ism_compute_mixing_matrix_fx( return; } + static void ivas_param_ism_render_slot_fx( PARAM_ISM_DEC_HANDLE hParamIsmDec, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, @@ -435,6 +447,7 @@ static void ivas_param_ism_render_slot_fx( } } } + FOR( bin_idx = 0; bin_idx < hSpatParamRendCom->num_freq_bands; bin_idx++ ) { /* smooth the mixing matrix */ @@ -519,11 +532,11 @@ static ivas_error ivas_param_ism_rendering_init_fx( return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for proto matrix\n" ) ); } - IF( ( hParamIsmRendering->interpolator_fx = (Word16 *) malloc( subframe_nbslots * sizeof( Word16 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for interpolator\n" ) ); } + test(); test(); test(); @@ -539,6 +552,7 @@ static ivas_error ivas_param_ism_rendering_init_fx( return IVAS_ERR_OK; } + static void ivas_param_ism_update_mixing_matrix_fx( PARAM_ISM_DEC_HANDLE hParamIsmDec, Word32 mixing_matrix_fx[CLDFB_NO_CHANNELS_MAX][PARAM_ISM_MAX_CHAN * PARAM_ISM_MAX_DMX], /*Q(31-mixing_matrix_exp)*/ @@ -580,6 +594,7 @@ static void ivas_param_ism_update_mixing_matrix_fx( * * Open Param ISM handle *-------------------------------------------------------------------------*/ + ivas_error ivas_param_ism_dec_open_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -629,6 +644,7 @@ ivas_error ivas_param_ism_dec_open_fx( move32(); output_config = st_ivas->hDecoderConfig->output_config; move32(); + ivas_param_ism_config_fx( hParamIsmDec->hParamIsm, st_ivas->nchan_ism ); // assuming Q14 for gains; /*-----------------------------------------------------------------* @@ -833,6 +849,7 @@ ivas_error ivas_param_ism_dec_open_fx( return error; } + /*-------------------------------------------------------------------------* * ivas_param_ism_dec_close() * @@ -917,6 +934,7 @@ void ivas_param_ism_dec_close_fx( * * *-------------------------------------------------------------------------*/ + void ivas_ism_dec_digest_tc_fx( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -1081,17 +1099,24 @@ void ivas_ism_dec_digest_tc_fx( *-------------------------------------------------------------------------*/ void ivas_param_ism_dec_digest_tc_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ - Word32 *transport_channels[], /* i : synthesized core-coder transport channels/DirAC output q_tc_in */ - const Word16 q_tc_in ) + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ + Word32 *p_data_fx[], /* i/o: synthesized core-coder transport channels/DirAC output q_data_in */ + const Word16 q_data_in /* i : Q-factor of input signal for single channel */ +) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Word16 i, ch, slot_idx, output_frame; + Word16 num_freq_bands, cldfb_ch, n_ch_cldfb; + Word32 *cldfb_real_buffer, *cldfb_imag_buffer; + Word16 q_data = q_data_in; move16(); +#else move16(); move16(); move16(); - Word16 q_tc = q_tc_in; + Word16 q_tc = q_data_in; move16(); Word16 ch, nchan_transport, i; Word16 slot_idx; @@ -1100,8 +1125,38 @@ void ivas_param_ism_dec_digest_tc_fx( PARAM_ISM_DEC_HANDLE hParamIsmDec; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word16 fade_len; +#endif /* Initialization */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + num_freq_bands = st_ivas->hSpatParamRendCom->num_freq_bands; + move16(); + output_frame = imult1616( nCldfbSlots, st_ivas->hSpatParamRendCom->num_freq_bands ); + n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); + + cldfb_real_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx; + cldfb_imag_buffer = st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx; + + ivas_ism_param_dec_tc_gain_adjust_fx( st_ivas, output_frame, shr( output_frame, 1 ), p_data_fx, &q_data ); + + IF( !st_ivas->hDecoderConfig->Opt_tsm ) + { + Scale_sig32( p_data_fx[0], output_frame, sub( Q11, q_data ) ); /*keepeing p_data_fx at Q11*/ + Scale_sig32( p_data_fx[1], output_frame, sub( Q11, q_data ) ); /*keepeing p_data_fx at Q11*/ + } + ELSE + { + IF( NE_16( q_data, q_data_in ) ) + { + FOR( i = 0; i < MAX_PARAM_ISM_WAVE; i++ ) + { + scale_sig32( p_data_fx[i], output_frame, sub( q_data_in, q_data ) ); // q_data_in + } + q_data = q_data_in; + move16(); + } + } +#else hParamIsmDec = st_ivas->hParamIsmDec; assert( hParamIsmDec ); hSpatParamRendCom = st_ivas->hSpatParamRendCom; @@ -1112,9 +1167,6 @@ void ivas_param_ism_dec_digest_tc_fx( nchan_transport = st_ivas->nchan_transport; move16(); - push_wmops( "ivas_param_ism_dec" ); - - IF( st_ivas->hDecoderConfig->Opt_tsm ) { /*TODO : FhG to check*/ @@ -1130,7 +1182,29 @@ void ivas_param_ism_dec_digest_tc_fx( move16(); } } +#endif +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + /* CLDFB Analysis */ + FOR( ( ch = 0, cldfb_ch = 0 ); cldfb_ch < n_ch_cldfb; ( cldfb_ch++, ch++ ) ) + { + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + q_data = q_data_in; + move16(); + + cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][num_freq_bands * slot_idx] ), + &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &q_data ); + + st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = sub( 31, q_data ); + move16(); + st_ivas->hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = sub( 31, q_data ); + move16(); + } + } +#else FOR( ch = 0; ch < nchan_transport; ch++ ) { /* CLDFB Analysis */ @@ -1152,8 +1226,7 @@ void ivas_param_ism_dec_digest_tc_fx( } } } - - pop_wmops(); +#endif return; } @@ -1223,10 +1296,9 @@ void ivas_param_ism_dec_prepare_renderer_fx( ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate; /* Initialization */ - - hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = 25; + hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_exp = Q25; move16(); - hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = 25; + hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_exp = Q25; move16(); IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { @@ -1243,7 +1315,6 @@ void ivas_param_ism_dec_prepare_renderer_fx( nchan_out_woLFE = st_ivas->hIntSetup.nchan_out_woLFE; move16(); } - push_wmops( "ivas_param_ism_dec_digest_tc" ); /* general setup */ ivas_jbm_dec_get_adapted_linear_interpolator_fx( DEFAULT_JBM_CLDFB_TIMESLOTS, nCldfbSlots, hParamIsmDec->hParamIsmRendering->interpolator_fx ); @@ -1371,33 +1442,32 @@ void ivas_param_ism_dec_prepare_renderer_fx( ivas_param_ism_compute_mixing_matrix_fx( st_ivas->nchan_ism, hParamIsmDec, st_ivas->hISMDTX, direct_response_fx, nchan_transport, nchan_out_woLFE, cx_diag_fx, exp_cx_diag, hParamIsmDec->hParamIsmRendering->mixing_matrix_lin_fx, hParamIsmDec->hParamIsmRendering->exp_mixing_matrix_lin_fx ); - - pop_wmops(); - return; } + /*-------------------------------------------------------------------------* - * ivas_ism_param_dec_tc_gain_ajust() + * ivas_ism_param_dec_tc_gain_adjust() * * *-------------------------------------------------------------------------*/ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS +static void ivas_ism_param_dec_tc_gain_adjust_fx( +#else void ivas_ism_param_dec_tc_gain_ajust_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamples, /* i : number of samples to be compensate */ - const UWord16 nFadeLength, /* i : length of the crossfade in samples */ - Word32 *transport_channels_f[], /* i : synthesized core-coder transport channels/DirAC output Q_tc*/ - Word16 *Q_tc /* i/o : Q of input tc buffer */ +#endif + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const Word16 nSamples, /* i : number of samples to be compensate */ + const Word16 nFadeLength, /* i : length of the crossfade in samples */ + Word32 *p_data_fx[], /* i : synthesized core-coder transport channels/DirAC output q_data */ + Word16 *q_data /* i/o : Q of input data buffer */ ) - { Word16 i, tmp_e1, tmp_e2, tmp, tmp2, invFade; Word32 L_tmp1, L_tmp2; - Word16 gain_fx, last_gain_fx; Word32 ene_tc_fx, ene_sum_fx; - Word16 ene_tc_e, ene_sum_e; ene_tc_fx = 0; @@ -1409,7 +1479,6 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( ene_sum_e = 0; move16(); - last_gain_fx = st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_fx; move16(); @@ -1426,14 +1495,13 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( move16(); ch1_e = 0; move16(); - ch0 = transport_channels_f[0][i]; + ch0 = p_data_fx[0][i]; move16(); - ch1 = transport_channels_f[1][i]; + ch1 = p_data_fx[1][i]; move16(); ch0 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, 0, 0, &ch0_e ); ch1 = BASOP_Util_Add_Mant32Exp( ch1, ch1_e, 0, 0, &ch1_e ); - L_tmp1 = Mpy_32_32( ch0, ch0 ); /*L*L*/ tmp_e1 = add( ch0_e, ch0_e ); L_tmp2 = Mpy_32_32( ch1, ch1 ); /*R*R*/ @@ -1442,7 +1510,6 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( ene_tc_fx = BASOP_Util_Add_Mant32Exp( ene_tc_fx, ene_tc_e, L_tmp1, tmp_e1, &ene_tc_e ); ene_tc_fx = BASOP_Util_Add_Mant32Exp( ene_tc_fx, ene_tc_e, L_tmp2, tmp_e2, &ene_tc_e ); - L_tmp1 = BASOP_Util_Add_Mant32Exp( ch0, ch0_e, ch1, ch1_e, &tmp_e1 ); /*L + R*/ L_tmp1 = Mpy_32_32( L_tmp1, L_tmp1 ); // Q(31-(tmp_e1+tmp_e1 /*(L + R)*(L + R)*/ tmp_e1 = add( tmp_e1, tmp_e1 ); @@ -1492,6 +1559,7 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( { /* Smoothing */ gain_fx = add( mult_r( 24574, gain_fx ), mult_r( 8192, last_gain_fx ) ); // 24574 =.75f in Q15 , 8192=.25f in Q15 + /* 10ms ramp */ /* slope between two consecutive gains, 480 samples length */ invFade = div_s( 1, nFadeLength ); // Q15 @@ -1502,18 +1570,18 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( /* tmp2 = ( last_gain_fx + i * grad_fx )*/ tmp2 = add( mult_r( sub( 32767, tmp ), last_gain_fx ), mult_r( tmp, gain_fx ) ); // 32767= 1.0f in Q15, - transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], tmp2 ); // Q(Q_tc-tmp_e1) + p_data_fx[0][i] = Mpy_32_16_1( p_data_fx[0][i], tmp2 ); // Q(Q_tc-tmp_e1) move32(); - transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], tmp2 ); // Q(Q_tc-tmp_e1) + p_data_fx[1][i] = Mpy_32_16_1( p_data_fx[1][i], tmp2 ); // Q(Q_tc-tmp_e1) move32(); tmp = add( tmp, invFade ); } FOR( ; i < nSamples; i++ ) { - transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], gain_fx ); // Q(Q_tc-tmp_e1) + p_data_fx[0][i] = Mpy_32_16_1( p_data_fx[0][i], gain_fx ); // Q(Q_tc-tmp_e1) move32(); - transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], gain_fx ); // Q(Q_tc-tmp_e1) + p_data_fx[1][i] = Mpy_32_16_1( p_data_fx[1][i], gain_fx ); // Q(Q_tc-tmp_e1) move32(); } } @@ -1521,9 +1589,9 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( { FOR( i = 0; i < nSamples; i++ ) { - transport_channels_f[0][i] = Mpy_32_16_1( transport_channels_f[0][i], gain_fx ); // Q(Q_tc-tmp_e1) + p_data_fx[0][i] = Mpy_32_16_1( p_data_fx[0][i], gain_fx ); // Q(Q_tc-tmp_e1) move32(); - transport_channels_f[1][i] = Mpy_32_16_1( transport_channels_f[1][i], gain_fx ); // Q(Q_tc-tmp_e1) + p_data_fx[1][i] = Mpy_32_16_1( p_data_fx[1][i], gain_fx ); // Q(Q_tc-tmp_e1) move32(); } } @@ -1533,16 +1601,19 @@ void ivas_ism_param_dec_tc_gain_ajust_fx( st_ivas->hParamIsmDec->hParamIsm->last_dmx_gain_e = tmp_e1; move16(); - *Q_tc = sub( *Q_tc, tmp_e1 ); + *q_data = sub( *q_data, tmp_e1 ); move16(); + return; } + /*-------------------------------------------------------------------------* * ivas_ism_param_dec_render_sf() * * *-------------------------------------------------------------------------*/ + static void ivas_ism_param_dec_render_sf_fx( Decoder_Struct *st_ivas, IVAS_OUTPUT_SETUP hSetup, @@ -1552,7 +1623,7 @@ static void ivas_ism_param_dec_render_sf_fx( Word32 *output_f_fx[], /*Q_output*/ Word16 Q_output[] ) { - Word16 ch, slot_idx, i, index_slot; + Word16 ch, slot_idx, i, index_slot, cldfb_idx; /* CLDFB Output Buffers */ Word32 Cldfb_RealBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; // Q(31-real_exp) Word32 Cldfb_ImagBuffer_fx[PARAM_ISM_MAX_CHAN][JBM_CLDFB_SLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; // Q(31-imag_exp) @@ -1565,12 +1636,14 @@ static void ivas_ism_param_dec_render_sf_fx( Word16 idx_lfe; Word16 subframe_idx; Word16 samplesProcessed, no_col_cldfb, size_cldfb; + hParamIsmDec = st_ivas->hParamIsmDec; hSpatParamRendCom = st_ivas->hSpatParamRendCom; slot_idx_start = hSpatParamRendCom->slots_rendered; move16(); subframe_idx = hSpatParamRendCom->subframes_rendered; move16(); + /* Set some memories to zero */ FOR( ch = 0; ch < nchan_out_woLFE; ch++ ) { @@ -1581,17 +1654,15 @@ static void ivas_ism_param_dec_render_sf_fx( } } - Word16 real_exp[JBM_CLDFB_SLOTS_IN_SUBFRAME]; Word16 imag_exp[JBM_CLDFB_SLOTS_IN_SUBFRAME]; FOR( slot_idx = 0; slot_idx < hSpatParamRendCom->subframe_nbslots[subframe_idx]; slot_idx++ ) { index_slot = add( slot_idx_start, slot_idx ); - FOR( ch = 0; ch < nchan_transport; ch++ ) { - Word16 cldfb_idx = add( imult1616( imult1616( index_slot, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) ); + cldfb_idx = add( imult1616( imult1616( index_slot, hSpatParamRendCom->num_freq_bands ), nchan_transport ), imult1616( ch, hSpatParamRendCom->num_freq_bands ) ); Cldfb_RealBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_RealBuffer_tc_fx[cldfb_idx]; // Q11 Cldfb_ImagBuffer_in_fx[ch] = &hParamIsmDec->hParamIsmRendering->Cldfb_ImagBuffer_tc_fx[cldfb_idx]; // Q11 } @@ -1628,7 +1699,6 @@ static void ivas_ism_param_dec_render_sf_fx( } ELSE { - Word32 *RealBuffer_fx[16]; Word32 *ImagBuffer_fx[16]; @@ -1693,15 +1763,15 @@ static void ivas_ism_param_dec_render_sf_fx( * * *-------------------------------------------------------------------------*/ + void ivas_param_ism_dec_render_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ - const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ - UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_f_fx[] /*Q11*/ + Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ + const UWord16 nSamplesAsked, /* i : number of CLDFB slots requested */ + UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ + Word32 *output_f_fx[] /* i/o: synthesized core-coder TCs / rendered signal Q11*/ ) { - Word16 ch, slots_to_render, first_sf, last_sf, subframe_idx; UWord16 slot_size, n_samples_sf; PARAM_ISM_DEC_HANDLE hParamIsmDec; @@ -1800,6 +1870,7 @@ void ivas_param_ism_dec_render_fx( *nSamplesAvailableNext = imult1616( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), (Word16) slot_size ); move16(); + return; } @@ -1834,7 +1905,6 @@ void ivas_param_ism_params_to_masa_param_mapping_fx( nBins = hSpatParamRendCom->num_freq_bands; move16(); - IF( st_ivas->hISMDTX.dtx_flag ) { Word32 energy_ratio_fx; /* Q30 */ diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 8a36dda92f2d99a093bfbc2f9def81fcad27a973..13880a2047937c082375e190204330a368251bb7 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -51,8 +51,9 @@ * Local function prototypes *-----------------------------------------------------------------------*/ +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS static void ivas_jbm_dec_copy_tc( Decoder_Struct *st_ivas, const Word16 nSamplesForRendering, Word16 *nSamplesResidual, Word32 *data, Word32 *tc_digest_f[], Word16 data_q ); - +#endif static void ivas_jbm_dec_tc_buffer_playout_fx( Decoder_Struct *st_ivas, const UWord16 nSamplesAsked, UWord16 *nSamplesRendered, Word32 *output_fx[] ); static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas ); @@ -117,6 +118,7 @@ ivas_error ivas_jbm_dec_tc_fx( output_frame = extract_l( Mult_32_16( output_Fs, INV_FRAME_PER_SEC_Q15 ) ) /* output_Fs / FRAMES_PER_SEC */; + /* set pointers to transport channels audio */ FOR( n = 0; n < MAX_TRANSPORT_CHANNELS; n++ ) { p_output_fx[n] = st_ivas->p_output_fx[n]; @@ -283,12 +285,13 @@ ivas_error ivas_jbm_dec_tc_fx( { return error; } - +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS test(); IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && st_ivas->hDecoderConfig->Opt_tsm ) { ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { @@ -661,7 +664,7 @@ ivas_error ivas_jbm_dec_tc_fx( test(); /* external output */ - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) && EQ_32( st_ivas->hMasa->config.input_ivas_format, MASA_ISM_FORMAT ) ) { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { @@ -792,756 +795,885 @@ ivas_error ivas_jbm_dec_tc_fx( output_q = 8; move16(); } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ) - { + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ){ + IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_DISC ) ){ ivas_omasa_rearrange_channels_fx( p_output_fx, nchan_transport_ism, output_frame ); - } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) - { - /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ - ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame ); - } - ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) - { - /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */ - ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q ); - } + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) ) + { + /* Convert separate object to MASA, combine with the original MASA, and output combined MASA + empty objects. */ + ivas_omasa_combine_separate_ism_with_masa_fx( st_ivas, p_output_fx, &output_q, st_ivas->nchan_ism, output_frame ); + } + ELSE IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) + { + /* Extract objects from MASA, output MASA + all objects (i.e., extracted and separated objects) */ + ivas_omasa_render_objects_from_mix_fx( st_ivas, p_output_fx, st_ivas->nchan_ism, output_frame, &output_q ); + } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + } +#endif +} +IF( NE_16( output_q, Q11 ) ) +{ + FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) + { + Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11 + } +} +} +ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) +{ + Word16 nchan_ism, sba_ch_idx; - IF( st_ivas->hDecoderConfig->Opt_tsm ) - { - ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); - } - } - IF( NE_16( output_q, Q11 ) ) + set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); + nchan_ism = st_ivas->nchan_ism; + move16(); + IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + /* set ISM parameters and decode ISM metadata in OSBA format */ + IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { - FOR( n = 0; n < s_max( getNumChanSynthesis( st_ivas ), nchan_transport_ism + st_ivas->nchan_transport ); n++ ) - { - Scale_sig32( p_output_fx[n], output_frame, sub( Q11, output_q ) ); // Q11 - } + return error; } + sba_ch_idx = st_ivas->nchan_ism; + move16(); } - ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) + ELSE { - Word16 nchan_ism, sba_ch_idx; - - set16_fx( nb_bits_metadata, 0, MAX_SCE + 1 ); - nchan_ism = st_ivas->nchan_ism; + nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ ); + sba_ch_idx = 0; move16(); - IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + move16(); + } + + /* SBA metadata decoding */ + IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) + { + return error; + } + + test(); + IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) + { + st_ivas->hCPE[0]->element_brate = ivas_total_brate; + move32(); + } + + /* core-decoding of transport channels */ + Word16 q_output = 11; + move16(); + + IF( EQ_16( st_ivas->nSCE, 1 ) ) + { + set32_fx( p_output_fx[0], 0, L_FRAME48k ); + + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { - /* set ISM parameters and decode ISM metadata in OSBA format */ - IF( NE_32( ( error = ivas_osba_ism_metadata_dec_fx( st_ivas, ivas_total_brate, &nchan_ism, &nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) - { - return error; - } - sba_ch_idx = st_ivas->nchan_ism; - move16(); + return error; } - ELSE + } + ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + { + + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) { - nb_bits_metadata[1] = add( nb_bits_metadata[1], NO_BITS_MASA_ISM_NO_OBJ ); - sba_ch_idx = 0; - move16(); - move16(); + return error; } - /* SBA metadata decoding */ - IF( NE_32( ( error = ivas_spar_dec_fx( st_ivas, nb_bits_metadata ) ), IVAS_ERR_OK ) ) + IF( NE_16( q_output, Q11 ) ) + { + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 + } + } + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) { return error; } + } - test(); - IF( EQ_16( st_ivas->nchan_transport, CPE_CHANNELS ) && GE_16( st_ivas->nCPE, 1 ) ) + IF( st_ivas->sba_dirac_stereo_flag ) + { + FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) { - st_ivas->hCPE[0]->element_brate = ivas_total_brate; - move32(); + Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); // Q14 } - - /* core-decoding of transport channels */ - Word16 q_output = 11; + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 nchan_transport; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + nchan_out = nchan_transport; move16(); + 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 ); - IF( EQ_16( st_ivas->nSCE, 1 ) ) + IF( st_ivas->hSpar->hPCA != NULL ) { - set32_fx( p_output_fx[0], 0, L_FRAME48k ); - - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) - { - return error; - } + ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); } - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + 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 ) ); { - - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, add( nb_bits_metadata[0], nb_bits_metadata[1] ) ) ), IVAS_ERR_OK ) ) + Word16 q; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; + s = 0; + move16(); + FOR( i = 0; i < 2; i++ ) { - return error; + s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); } - - IF( NE_16( q_output, Q11 ) ) + FOR( i = 0; i < 2; i++ ) { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 + Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) } - } - ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) - { - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] + nb_bits_metadata[1] ) ), IVAS_ERR_OK ) ) + hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) { - return error; + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + move16(); + move16(); } - } - IF( st_ivas->sba_dirac_stereo_flag ) - { - FOR( i = 0; i < st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport; i++ ) - { - Scale_sig32( p_output_fx[i + sba_ch_idx], output_frame, Q14 - Q11 ); // Q14 - } - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 nchan_transport; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + q = hCPE->hStereoDft->q_dft; move16(); - nchan_out = nchan_transport; - move16(); - 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 ); - - IF( st_ivas->hSpar->hPCA != NULL ) + 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 ) { - ivas_pca_dec_fx( st_ivas->hSpar->hPCA, output_frame, st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->bfi, &p_output_fx[sba_ch_idx] ); + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft } - 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 ) ); + IF( hCPE->hCoreCoder[0] != NULL ) { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[sba_ch_idx + i], L_FRAME48k ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, s ); // Q(11+s) - } - hCPE->hStereoDft->q_dft = add( Q11, s ); + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + 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 ) ); // q_dft + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - move16(); - } + } - q = hCPE->hStereoDft->q_dft; + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; move16(); - 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 ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ) ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, sub( q, hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ) ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - 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 ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - - IF( hSCE != NULL ) - { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( 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 ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); - } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - 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 ) ); - } - - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 - - scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - 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 ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } - - FOR( 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 ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } } - } - - /* HP filtering */ - FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } - - nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); - - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) - { - num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); - SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; - Word16 nchan_transport; - // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; - nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; - move16(); - nchan_out = nchan_transport; - move16(); - Word16 Q_p_output; - Word16 min_norm = 31; - move16(); - - FOR( ch = 0; ch < nchan_transport; ++ch ) + FOR( 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 ) ); // q_dft + hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx + ivas_sba_dirac_stereo_dec_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame, 0 ); + FOR( i = 0; i < 2; i++ ) { - Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel - min_norm = s_min( norm, min_norm ); + Scale_sig32( p_output_fx[sba_ch_idx + i], L_FRAME48k, negate( s ) ); } - Q_p_output = s_max( 3, sub( min_norm, 1 ) ); + FOR( i = 0; i < CPE_CHANNELS; i++ ) + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( 11, hCPE->q_prev_synth_fx ) ); // Q11 - Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 - FOR( ch = 0; ch < nchan_transport; ch++ ) + scale_sig32( hCPE->input_mem_BPF_fx[0], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + FOR( i = 0; i < CPE_CHANNELS; ++i ) { - Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 } - Q_p_output = add( Q11, Q_p_output ); - hSpar->hMdDec->Q_mixer_mat = 31; - move16(); - 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, sub( Q_p_output, Q11 ) ); - FOR( Word16 c = 0; c < nchan_transport; c++ ) + IF( hCPE->hCoreCoder[0] != NULL ) { - Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); // Q11 + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda } - } - ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) - { - Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); - if ( EQ_16( size, 3 ) ) + IF( hCPE->hStereoDft != NULL ) { - size = add( size, 1 ); + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + move16(); } - FOR( i = sba_ch_idx; i < size; i++ ) + FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) { - Scale_sig32( p_output_fx[i], output_frame, ( Q14 - Q11 ) ); // Q14 + scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + hCPE->q_output_mem_fx[ii] = Q11; + move16(); } - - ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); } + } - test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) - { - /* loudness correction */ - ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ + /* HP filtering */ + FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } - FOR( i = 0; i < nchan_remapped; i++ ) - { - Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q - } - } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + nchan_remapped = ivas_sba_remapTCs_fx( &p_output_fx[sba_ch_idx], st_ivas, output_frame ); + + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + num_md_sub_frames = ivas_get_spar_dec_md_num_subframes( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->last_active_ivas_total_brate ); + SPAR_DEC_HANDLE hSpar = st_ivas->hSpar; + Word16 nchan_transport; + // num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; + nchan_transport = hSpar->hMdDec->spar_md_cfg.nchan_transport; + move16(); + nchan_out = nchan_transport; + move16(); + Word16 Q_p_output; + Word16 min_norm = 31; + move16(); + + FOR( ch = 0; ch < nchan_transport; ++ch ) { - ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); + Word16 norm = L_norm_arr( p_output_fx[sba_ch_idx + ch], output_frame ); // Normalize per channel + min_norm = s_min( norm, min_norm ); + } - Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11 + Q_p_output = s_max( 3, sub( min_norm, 1 ) ); - /* add W */ - FOR( n = 0; n < nchan_out; n++ ) - { - v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); - } + Q_p_output = s_min( Q_p_output, 19 ); // to restrict Q-factor of p_ouptut to Q30 + FOR( ch = 0; ch < nchan_transport; ch++ ) + { + Scale_sig32( p_output_fx[sba_ch_idx + ch], output_frame, Q_p_output ); // Q_p_output + Q11 } - } - ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) - { + Q_p_output = add( Q11, Q_p_output ); + hSpar->hMdDec->Q_mixer_mat = 31; + move16(); - // st = (st_ivas->nSCE > 0) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; - IF( st_ivas->nSCE > 0 ) + 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, sub( Q_p_output, Q11 ) ); + FOR( Word16 c = 0; c < nchan_transport; c++ ) { - st = st_ivas->hSCE[0]->hCoreCoder[0]; + Scale_sig32( p_output_fx[sba_ch_idx + c], output_frame, Q11 ); // Q11 } - ELSE + } + ELSE IF( NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->sba_dirac_stereo_flag == 0 ) + { + Word16 size = add( st_ivas->hSpar->hMdDec->spar_md_cfg.nchan_transport, sba_ch_idx ); + if ( EQ_16( size, 3 ) ) { - st = st_ivas->hCPE[0]->hCoreCoder[0]; + size = add( size, 1 ); } - IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) + FOR( i = sba_ch_idx; i < size; i++ ) { - /* LFE channel decoder */ - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); + Scale_sig32( p_output_fx[i], output_frame, ( Q14 - Q11 ) ); // Q14 + } - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - /* HP filtering */ - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + ivas_spar_dec_agc_pca_fx( st_ivas, &p_output_fx[sba_ch_idx], output_frame ); + } + + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) + { + /* loudness correction */ + ivas_dirac_dec_binaural_sba_gain_fx( &p_output_fx[sba_ch_idx], nchan_remapped, output_frame ); /*returns Q-1*/ + + FOR( i = 0; i < nchan_remapped; i++ ) + { + Scale_sig32( p_output_fx[i], output_frame, 1 ); // Q-1 -> Q + } + } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + ivas_ism_mono_dmx_fx( st_ivas, p_output_fx, output_frame ); + + Scale_sig32( p_output_fx[0], L_FRAME48k, Q11 - Q8 ); // Q11 + + /* add W */ + FOR( n = 0; n < nchan_out; n++ ) + { + v_add_32( p_output_fx[n], p_output_fx[n + s_max( nchan_out, nchan_ism )], p_output_fx[n], output_frame ); + } + } +} +ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) +{ + + // st = (st_ivas->nSCE > 0) ? st_ivas->hSCE[0]->hCoreCoder[0] : st_ivas->hCPE[0]->hCoreCoder[0]; + IF( st_ivas->nSCE > 0 ) + { + st = st_ivas->hSCE[0]->hCoreCoder[0]; + } + ELSE + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; + } + + IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) + { + /* LFE channel decoder */ + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); + + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, 0 ) ), IVAS_ERR_OK ) ) + { + return error; + } + /* HP filtering */ + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + IF( NE_16( n, LFE_CHANNEL ) ) { - IF( NE_16( n, LFE_CHANNEL ) ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } + } - test(); - test(); - test(); - IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + test(); + test(); + test(); + IF( NE_32( st_ivas->transport_config, st_ivas->intern_config ) && ( NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_FOA ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA2 ) || NE_32( st_ivas->intern_config, IVAS_AUDIO_CONFIG_HOA3 ) ) ) + { + IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) { - IF( GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ) ) ) - { - ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); - } + ivas_mc2sba_fx( st_ivas->hTransSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE_FX ); } + } - test(); - test(); - IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) + test(); + test(); + IF( ( EQ_32( st_ivas->renderer_type, RENDERER_MC ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && GE_16( add( st_ivas->hTransSetup.nchan_out_woLFE, st_ivas->hTransSetup.num_lfe ), add( st_ivas->hOutSetup.nchan_out_woLFE, st_ivas->hOutSetup.num_lfe ) ) ) + { + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) { - IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) ) + s = Q16 - Q11; + move16(); + s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - s = Q16 - Q11; - move16(); - s = sub( s, find_guarded_bits_fx( st_ivas->nchan_transport ) ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s) - } - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11 - } + Scale_sig32( p_output_fx[i], output_frame, s ); // Q(11+s) } - ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); ++i ) { - ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 ); + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); // Q11 } } + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) + { + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, output_frame, st_ivas->hOutSetup.ambisonics_order, 0 ); + } } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) - { - /* LFE channel decoder */ - ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); + } + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) + { + /* LFE channel decoder */ + ivas_lfe_dec_fx( st_ivas->hLFE, st, output_frame, st_ivas->bfi, p_output_fx[LFE_CHANNEL] ); - Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 + Scale_sig32( p_output_fx[LFE_CHANNEL], L_FRAME48k, Q11 - Q9 ); // Q11 - ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); + ivas_mc_paramupmix_dec_read_BS( st_ivas, st, st_ivas->hMCParamUpmix, &nb_bits_metadata[0] ); - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + /* HP filtering */ + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + IF( NE_16( n, LFE_CHANNEL ) ) { - return error; + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - /* HP filtering */ - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + } + + /* Rendering */ + test(); + test(); + IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + { + /* Compensate loudness for not doing full upmix */ + FOR( n = 4; n < 8; n++ ) { - IF( NE_16( n, LFE_CHANNEL ) ) - { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); - } + Scale_sig32( p_output_fx[n], output_frame, 1 ); } - /* Rendering */ test(); - test(); - IF( EQ_32( st_ivas->renderer_type, RENDERER_MC ) && ( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - /* Compensate loudness for not doing full upmix */ - FOR( n = 4; n < 8; n++ ) + s = Q16 - Q11; + move16(); + Word16 nchan_transport; + nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); + s = sub( s, find_guarded_bits_fx( nchan_transport ) ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { - Scale_sig32( p_output_fx[n], output_frame, 1 ); + Scale_sig32( p_output_fx[i], output_frame, s ); } - - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) + ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); + FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) { - s = Q16 - Q11; - move16(); - Word16 nchan_transport; - nchan_transport = audioCfg2channels( IVAS_AUDIO_CONFIG_5_1_2 ); - s = sub( s, find_guarded_bits_fx( nchan_transport ) ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, s ); - } - ivas_ls_setup_conversion_fx( st_ivas, nchan_transport, output_frame, p_output_fx, p_output_fx ); - FOR( i = 0; i < s_max( st_ivas->hDecoderConfig->nchan_out, nchan_transport ); ++i ) - { - Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); - } + Scale_sig32( p_output_fx[i], output_frame, negate( s ) ); } } } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) + } + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) + { + /* read Parametric MC parameters from the bitstream */ + ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); + + IF( EQ_16( st_ivas->nCPE, 1 ) ) { - /* read Parametric MC parameters from the bitstream */ - ivas_param_mc_dec_read_BS_fx( ivas_total_brate, st, st_ivas->hParamMC, &nb_bits_metadata[0] ); + Word16 q_output = 11; + move16(); - IF( EQ_16( st_ivas->nCPE, 1 ) ) + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { - Word16 q_output = 11; - move16(); - - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } + return error; } - ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + IF( NE_16( q_output, Q11 ) ) { - IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 } - - /* HP filtering */ - FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + } + ELSE IF( GT_16( st_ivas->nCPE, 1 ) ) + { + IF( NE_32( ( error = ivas_mct_dec_fx( st_ivas, p_output_fx, output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + return error; } + } - /* Rendering */ - test(); - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) - { - ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); - } + /* HP filtering */ + FOR( n = 0; n < st_ivas->nchan_transport; n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); } - ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + + /* Rendering */ + test(); + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_STEREO ) ) { - IF( st_ivas->hOutSetup.separateChannelEnabled ) - { - st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */ - } + ivas_ls_setup_conversion_fx( st_ivas, st_ivas->nchan_transport, output_frame, p_output_fx, p_output_fx ); + } + } + ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) + { + IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + st = st_ivas->hCPE[0]->hCoreCoder[0]; /* Metadata is always with CPE in the case of separated channel */ + } - /* read McMASA parameters from the bitstream */ + /* read McMASA parameters from the bitstream */ - IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + IF( NE_32( ( error = ivas_masa_decode_fx( st_ivas, st, &nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) + { + return error; + } + + IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + /* Decode the transport audio signals */ + Word16 q_output = 11; + move16(); + + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { return error; } - - IF( st_ivas->hOutSetup.separateChannelEnabled ) + IF( NE_16( q_output, Q11 ) ) { - /* Decode the transport audio signals */ - Word16 q_output = 11; - move16(); - - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 + } - /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ - n = LFE_CHANNEL - 1; - move16(); + /* Identify the index of the separated channel, always LFE_CHANNEL-1 here */ + n = LFE_CHANNEL - 1; + move16(); - /* Decode the separated channel to output[n] to be combined with the synthesized channels */ + /* Decode the separated channel to output[n] to be combined with the synthesized channels */ - set32_fx( p_output_fx[n], 0, L_FRAME48k ); + set32_fx( p_output_fx[n], 0, L_FRAME48k ); - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) - { - return error; - } - test(); - test(); - test(); - test(); - test(); - test(); - test(); - /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ - IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || - EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) - { - ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); - } - ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) - { - /* Delay the separated channel to sync with the DirAC rendering */ - delay_signal32_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); - } + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[n], output_frame, 0 ) ), IVAS_ERR_OK ) ) + { + return error; } - ELSE + test(); + test(); + test(); + test(); + test(); + test(); + test(); + /* Delay the separated channel to sync with CLDFB delay of the DirAC synthesis, and synthesize the LFE signal. */ + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1 ) || + EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe > 0 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { - Word16 q_output = 11; - move16(); - IF( EQ_16( st_ivas->nSCE, 1 ) ) - { - set32_fx( p_output_fx[0], 0, L_FRAME48k ); - - IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - } - ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) - { - - IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) - { - return error; - } - IF( NE_16( q_output, Q11 ) ) - { - Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 - Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 - } - } + ivas_lfe_synth_with_filters_fx( st_ivas->hMasa->hMasaLfeSynth, p_output_fx, output_frame, n, LFE_CHANNEL ); } - - IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) { - Word16 q; - hCPE = st_ivas->hCPE[0]; - hSCE = st_ivas->hSCE[0]; - s = 0; - move16(); - FOR( i = 0; i < 2; i++ ) - { - s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); - } - FOR( i = 0; i < 2; i++ ) - { - Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) - } - - hCPE->hStereoDft->q_dft = add( Q11, s ); - move16(); - IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) - { - hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; - hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; - - move16(); - move16(); - } - - q = hCPE->hStereoDft->q_dft; - move16(); - - 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 ) - { - scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - } - - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q - Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; - move16(); - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft - 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 ) ); // q_dft - hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; - move16(); - } + /* Delay the separated channel to sync with the DirAC rendering */ + delay_signal32_fx( p_output_fx[n], output_frame, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_fx, st_ivas->hMasa->hMasaLfeSynth->delayBuffer_syncDirAC_size ); + } + } + ELSE + { + Word16 q_output = 11; + move16(); + IF( EQ_16( st_ivas->nSCE, 1 ) ) + { + set32_fx( p_output_fx[0], 0, L_FRAME48k ); - IF( hSCE != NULL ) + IF( NE_32( ( error = ivas_sce_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { - Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft - hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; - move16(); - Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft - hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; - move16(); + return error; } - FOR( ii = 0; ii < CPE_CHANNELS; ii++ ) + } + ELSE IF( EQ_16( st_ivas->nCPE, 1 ) ) + { + + IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, 0, &p_output_fx[0], output_frame, nb_bits_metadata[0] ) ), IVAS_ERR_OK ) ) { - scale_sig32( hCPE->output_mem_fx[ii], NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, hCPE->q_output_mem_fx[ii] ) ); // q_dft - hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; - move16(); + return error; } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx - ivas_sba_dirac_stereo_dec_fx( st_ivas, p_output_fx, output_frame, 1 ); - FOR( i = 0; i < 2; i++ ) + IF( NE_16( q_output, Q11 ) ) { - Scale_sig32( p_output_fx[i], L_FRAME48k, negate( s ) ); + Scale_sig32( p_output_fx[0], output_frame, sub( Q11, q_output ) ); // Q11 + Scale_sig32( p_output_fx[1], output_frame, sub( Q11, q_output ) ); // Q11 } - FOR( i = 0; i < CPE_CHANNELS; i++ ) - Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 + } + } - 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 ) ); // Q11 - scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - } + IF( st_ivas->sba_dirac_stereo_flag != 0 ) /* use the flag to trigger the DFT upmix */ + { + Word16 q; + hCPE = st_ivas->hCPE[0]; + hSCE = st_ivas->hSCE[0]; + s = 0; + move16(); + FOR( i = 0; i < 2; i++ ) + { + s = s_min( s, L_norm_arr( p_output_fx[i], L_FRAME48k ) - 11 /* Guard bits */ ); + } + FOR( i = 0; i < 2; i++ ) + { + Scale_sig32( p_output_fx[i], L_FRAME48k, s ); // Q(11+s) + } - IF( hCPE->hCoreCoder[0] != NULL ) - { - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB - Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda - } - IF( hCPE->hStereoDft != NULL ) - { - scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 - scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 - hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; - move16(); - } - IF( st_ivas->hSpar != NULL ) - { - FOR( 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 ) ); // Q11 - hCPE->q_output_mem_fx[ii] = Q11; - move16(); - } - } + hCPE->hStereoDft->q_dft = add( Q11, s ); + move16(); + IF( EQ_16( hCPE->hStereoDft->first_frame, 1 ) ) + { + hCPE->hStereoDft->q_smoothed_nrg = Q6; // hCPE->hStereoDft->q_dft; + hCPE->hStereoDft->q_ap_delay_mem_fx = hCPE->hStereoDft->q_dft; + + move16(); + move16(); } - /* HP filtering */ - FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + q = hCPE->hStereoDft->q_dft; + move16(); + + 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 ) { - hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + scale_sig32( hCPE->input_mem_LB_fx[i], STEREO_DFT32MS_OVL_16k, sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + } + + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, L_FRAME32k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB ); // q + Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, L_FRAME48k, q - hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda ); // q + hCPE->hCoreCoder[0]->hHQ_core->Q_old_out_fx32 = q; + move16(); + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA( 16000, STEREO_DFT32MS_OVL_NS ), sub( hCPE->hStereoDft->q_dft, Q11 ) ); // q_dft + 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 ) ); // q_dft + hCPE->hStereoDft->q_ap_fade_mem_fx = hCPE->hStereoDft->q_dft; + move16(); + } + IF( st_ivas->hSpar != NULL ) + { + st_ivas->hSpar->hMdDec->Q_mixer_mat = 30; + move16(); + } + + IF( hSCE != NULL ) + { + Scale_sig32( &hSCE->save_hb_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_hb_synth_fx ); // q_dft + hSCE->q_save_hb_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + Scale_sig32( &hSCE->save_synth_fx[0], extract_l( Mpy_32_32( hCPE->hCoreCoder[0]->output_Fs, ONE_BY_FRAMES_PER_SEC_Q31 ) ), hCPE->hStereoDft->q_dft - hSCE->q_save_synth_fx ); // q_dft + hSCE->q_save_synth_fx = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( 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, hCPE->q_output_mem_fx[ii] ) ); // q_dft + hCPE->q_output_mem_fx[ii] = hCPE->hStereoDft->q_dft; + move16(); + } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( hCPE->q_prev_synth_fx, Q11 ) ); // q_prev_synth_fx + 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 ) ); } + FOR( i = 0; i < CPE_CHANNELS; i++ ) + Scale_sig32( hCPE->prev_synth_fx[i], NS2SA_FX2( output_Fs, IVAS_DEC_DELAY_NS - STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->q_prev_synth_fx ) ); // Q11 - IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) + 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 ) ); // Q11 + scale_sig32( hCPE->input_mem_fx[i], NS2SA_FX2( hCPE->hCoreCoder[0]->output_Fs, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + } + + IF( hCPE->hCoreCoder[0] != NULL ) + { + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_LB_fx, L_FRAME32k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda_LB, q ) ); // Q_old_wtda_LB + Copy_Scale_sig_32_16( hCPE->hCoreCoder[0]->hHQ_core->old_out_fx32, hCPE->hCoreCoder[0]->hHQ_core->old_out_fx, L_FRAME48k, sub( hCPE->hCoreCoder[0]->hHQ_core->Q_old_wtda, q ) ); // Q_old_wtda + } + IF( hCPE->hStereoDft != NULL ) + { + scale_sig32( hCPE->hStereoDft->buff_LBTCX_mem_fx, NS2SA_FX2( 16000, STEREO_DFT32MS_OVL_NS ), sub( Q11, hCPE->hStereoDft->q_dft ) ); // Q11 + scale_sig32( hCPE->hStereoDft->ap_delay_mem_fx, NS2SA_FX2( 16000, DELAY_BWE_TOTAL_NS ), sub( Q11, hCPE->hStereoDft->q_ap_fade_mem_fx ) ); // Q11 + hCPE->hStereoDft->q_ap_fade_mem_fx = Q11; + move16(); + } + IF( st_ivas->hSpar != NULL ) { - ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame ); + FOR( 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 ) ); // Q11 + hCPE->q_output_mem_fx[ii] = Q11; + move16(); + } } } + + /* HP filtering */ + FOR( n = 0; n < getNumChanSynthesis( st_ivas ); n++ ) + { + hp20_fx_32_opt( p_output_fx[n], output_frame, st_ivas->mem_hp20_out_fx[n], output_Fs ); + } + + IF( EQ_32( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) + { + ivas_mono_stereo_downmix_mcmasa_fx( st_ivas, p_output_fx, output_frame ); + } } +} - /*----------------------------------------------------------------* - * Write IVAS transport channels - *----------------------------------------------------------------*/ +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS +/*----------------------------------------------------------------* + * Write IVAS transport channels + *----------------------------------------------------------------*/ #ifdef LIB_DEC_REVISION - IF( st_ivas->hDecoderConfig->Opt_tsm == 0 ) +IF( st_ivas->hDecoderConfig->Opt_tsm == 0 ) #else - IF( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) ) +IF( EQ_16( st_ivas->hDecoderConfig->Opt_tsm, 1 ) ) +{ + ivas_syn_output_f_fx( p_output_fx, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data_fx ); +} +ELSE +#endif +{ + /* directly copy to tc buffers */ + /*note : the q of cldfb buffers (imag/real) are needed to be Q_p_output - 5 here 6 is taken for that*/ + ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_fx, output_frame ); +} +#endif +/*----------------------------------------------------------------* + * Common updates + *----------------------------------------------------------------*/ + +IF( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ +{ + st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; + move32(); + IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) { - ivas_syn_output_f_fx( p_output_fx, output_frame, st_ivas->hTcBuffer->nchan_transport_jbm, data_fx ); + st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate; + move32(); } ELSE -#endif { - /* directly copy to tc buffers */ - /*note : the q of cldfb buffers (imag/real) are needed to be Q_p_output - 5 here 6 is taken for that*/ - ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_fx, output_frame ); + st_ivas->last_active_ivas_total_brate = ivas_total_brate; + move32(); } +} - /*----------------------------------------------------------------* - * Common updates - *----------------------------------------------------------------*/ +test(); +test(); +if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ +{ + st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); + move16(); +} + +test(); +test(); +if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ +{ + st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); + move16(); +} + +st_ivas->last_ivas_format = st_ivas->ivas_format; +move32(); +pop_wmops(); + +return IVAS_ERR_OK; +} + + +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + +/*--------------------------------------------------------------------------* + * ivas_dec_feed_tc_to_renderer() + * + * Feed decoded transport channels to the IVAS renderer routine + * + digest TC channels in ParamISM and ParamMC + *--------------------------------------------------------------------------*/ + +void ivas_jbm_dec_feed_tc_to_renderer_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 nSamplesForRendering, /* i : number of TC samples available for rendering */ + Word16 *nSamplesResidual, /* o : number of samples not fitting into the renderer grid and buffer for the next call*/ + Word32 *data /* i : transport channels */ +) +{ + Word32 data_fx[MAX_CLDFB_DIGEST_CHANNELS][MAX_JBM_L_FRAME48k]; /* buffer for transport channels that will be directly converted with the CLDFB */ + Word32 *p_data_fx[MAX_CLDFB_DIGEST_CHANNELS]; + Word16 n, n_render_timeslots, n_ch_cldfb; + Word16 ch; + DECODER_TC_BUFFER_HANDLE hTcBuffer; + + hTcBuffer = st_ivas->hTcBuffer; + n_ch_cldfb = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + move16(); + + hTcBuffer->q_tc_fx = Q11; + move16(); - IF( !st_ivas->bfi ) /* do not update if first frame(s) are lost or NO_DATA */ + IF( st_ivas->hDecoderConfig->Opt_tsm ) { - st_ivas->hDecoderConfig->last_ivas_total_brate = ivas_total_brate; - move32(); - IF( LE_32( ivas_total_brate, IVAS_SID_5k2 ) ) + Word16 n_samples_still_available, m; + Word16 n_ch_full_copy; + Word16 n_ch_res_copy; + + FOR( n = 0; n < n_ch_cldfb; n++ ) { - st_ivas->last_active_ivas_total_brate = st_ivas->last_active_ivas_total_brate; - move32(); + p_data_fx[n] = &data_fx[n][0]; } - ELSE + + n_samples_still_available = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_rendered ); + hTcBuffer->n_samples_buffered = add( add( n_samples_still_available, nSamplesForRendering ), hTcBuffer->n_samples_discard ); + hTcBuffer->n_samples_available = i_mult( hTcBuffer->n_samples_granularity, idiv1616( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_granularity ) ); + *nSamplesResidual = sub( hTcBuffer->n_samples_buffered, hTcBuffer->n_samples_available ); + move16(); + move16(); + move16(); + n_ch_full_copy = s_min( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + n_ch_res_copy = sub( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + + FOR( ch = 0; ch < n_ch_full_copy; ch++ ) { - st_ivas->last_active_ivas_total_brate = ivas_total_brate; - move32(); + set32_fx( hTcBuffer->tc_fx[ch], 0, hTcBuffer->n_samples_discard ); + Copy32( hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_rendered, hTcBuffer->tc_fx[ch] + hTcBuffer->n_samples_discard, n_samples_still_available ); + FOR( m = 0; m < nSamplesForRendering; m++ ) + { + hTcBuffer->tc_fx[ch][n_samples_still_available + hTcBuffer->n_samples_discard + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; + move32(); + } } - } - test(); - test(); - if ( LT_16( st_ivas->ini_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) ) /* keep "st_ivas->ini_frame = 0" until first good received frame */ + IF( n_ch_res_copy > 0 ) + { + FOR( ; ch < hTcBuffer->nchan_transport_jbm; ch++ ) + { + Copy32( hTcBuffer->tc_fx[ch], p_data_fx[ch], n_samples_still_available ); + + FOR( m = 0; m < nSamplesForRendering; m++ ) + { + p_data_fx[ch][n_samples_still_available + m] = data[m * hTcBuffer->nchan_transport_jbm + ch]; + move32(); + } + Copy32( p_data_fx[ch] + hTcBuffer->n_samples_available, hTcBuffer->tc_fx[ch], *nSamplesResidual ); + } + } + + n_render_timeslots = idiv1616( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity ); + } + ELSE { - st_ivas->ini_frame = add( st_ivas->ini_frame, 1 ); + FOR( n = 0; n < n_ch_cldfb; n++ ) + { + p_data_fx[n] = &st_ivas->p_output_fx[n][0]; + move16(); + } + + FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) + { + hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ + move16(); + } + + hTcBuffer->n_samples_buffered = nSamplesForRendering; + hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered; + *nSamplesResidual = 0; + move16(); + move16(); + move16(); + + n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS; move16(); } + /* CLDFB analysis for ParamMC/ParamISM */ + test(); test(); test(); - if ( LT_16( st_ivas->ini_active_frame, MAX_FRAME_COUNTER ) && !( st_ivas->bfi && st_ivas->ini_frame == 0 ) && GT_32( ivas_total_brate, IVAS_SID_5k2 ) ) /* needed in MASA decoder in case the first active frame is BFI, and there were SID-frames decoded before */ + test(); + test(); + test(); + IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( EQ_32( st_ivas->renderer_type, RENDERER_PARAM_ISM ) || EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) ) { - st_ivas->ini_active_frame = add( st_ivas->ini_active_frame, 1 ); - move16(); + ivas_param_ism_dec_digest_tc_fx( st_ivas, n_render_timeslots, p_data_fx, Q11 ); + } + ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) && EQ_32( hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_RENDERER ) ) + { + ivas_param_mc_dec_digest_tc_fx( st_ivas, (uint8_t) n_render_timeslots, p_data_fx, Q11 ); } - st_ivas->last_ivas_format = st_ivas->ivas_format; - move32(); - pop_wmops(); + hTcBuffer->n_samples_rendered = 0; + move16(); + hTcBuffer->subframes_rendered = 0; + move16(); - return IVAS_ERR_OK; + return; } +#else /*--------------------------------------------------------------------------* * ivas_jbm_dec_feed_tc_to_renderer() @@ -1622,6 +1754,8 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( return; } +#endif + /*--------------------------------------------------------------------------* * ivas_dec_render() * @@ -1648,7 +1782,9 @@ ivas_error ivas_jbm_dec_render_fx( Word16 subframe_len, gd_bits, exp, nchan_in, i, j, ch; const Word16 output_q_factor = Q11; move16(); +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; +#endif Word16 nchan_out_syn_output; push_wmops( "ivas_dec_render" ); @@ -1656,7 +1792,9 @@ ivas_error ivas_jbm_dec_render_fx( * Initialization of local vars after struct has been set *----------------------------------------------------------------*/ +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS hSpatParamRendCom = st_ivas->hSpatParamRendCom; +#endif output_Fs = st_ivas->hDecoderConfig->output_Fs; move32(); nchan_out = st_ivas->hDecoderConfig->nchan_out; @@ -1672,28 +1810,36 @@ ivas_error ivas_jbm_dec_render_fx( { p_output_fx[n] = st_ivas->p_output_fx[n]; } + IF( !st_ivas->hDecoderConfig->Opt_tsm ) { +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) { p_tc_fx[n] = &p_output_fx[n][st_ivas->hTcBuffer->n_samples_rendered]; } - +#endif FOR( n = 0; n < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; n++ ) { st_ivas->hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; } } + +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS ELSE { +#endif FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) { p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered]; } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS } +#endif st_ivas->hTcBuffer->no_channels = st_ivas->hTcBuffer->nchan_buffer_full; move16(); + /*----------------------------------------------------------------* * Update combined orientation access index *----------------------------------------------------------------*/ @@ -1797,7 +1943,11 @@ ivas_error ivas_jbm_dec_render_fx( } } +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + ivas_ism2sba_sf_fx( p_tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); +#else ivas_ism2sba_sf_fx( st_ivas->hTcBuffer->tc_fx, p_output_fx, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order ); +#endif Word16 sba_num_chans = imult1616( add( st_ivas->hIntSetup.ambisonics_order, 1 ), add( st_ivas->hIntSetup.ambisonics_order, 1 ) ); FOR( j = 0; j < sba_num_chans; j++ ) @@ -1973,7 +2123,7 @@ ivas_error ivas_jbm_dec_render_fx( return error; } } - ELSE IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/ + ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) /*EXT output = individual objects + HOA3*/ { IF( NE_32( ( error = ivas_sba_dec_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output_fx[st_ivas->nchan_ism] ) ), IVAS_ERR_OK ) ) { @@ -1982,7 +2132,11 @@ ivas_error ivas_jbm_dec_render_fx( FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Copy32( p_tc_fx[n], p_output_fx[n], *nSamplesRendered ); +#else Copy32( st_ivas->hTcBuffer->tc_fx[n] + st_ivas->hTcBuffer->n_samples_rendered, p_output_fx[n], *nSamplesRendered ); +#endif } } ELSE @@ -1996,6 +2150,7 @@ ivas_error ivas_jbm_dec_render_fx( ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) { ivas_dirac_dec_binaural_render_fx( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output_fx ); + FOR( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ ) { scale_sig32( p_output_fx[n], *nSamplesRendered, 1 ); @@ -2008,7 +2163,7 @@ ivas_error ivas_jbm_dec_render_fx( return error; } - IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) { FOR( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- ) { @@ -2027,12 +2182,12 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { - +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS FOR( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ ) { p_tc_fx[n] = &st_ivas->hTcBuffer->tc_fx[n][st_ivas->hTcBuffer->n_samples_rendered]; } - +#endif IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) ) { Word16 crendInPlaceRotation = FALSE; @@ -2336,7 +2491,9 @@ ivas_error ivas_jbm_dec_render_fx( } ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS Word16 offset = imult1616( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->slot_size ); +#endif nchan_remapped = st_ivas->nchan_transport; move16(); @@ -2359,7 +2516,11 @@ ivas_error ivas_jbm_dec_render_fx( /* we still need to copy the separate channel if available */ IF( st_ivas->hOutSetup.separateChannelEnabled ) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL - 1] + offset, p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); @@ -2387,13 +2548,22 @@ ivas_error ivas_jbm_dec_render_fx( EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_7_1_4 ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_5_1_2 ) || ( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && GT_16( st_ivas->hOutSetup.num_lfe, 0 ) ) ) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Copy32( p_tc_fx[LFE_CHANNEL], p_output_fx[LFE_CHANNEL], *nSamplesRendered ); + Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL] + offset, p_output_fx[LFE_CHANNEL], *nSamplesRendered ); Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL - 1] + offset, p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } ELSE IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) && st_ivas->hOutSetup.num_lfe == 0 ) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Copy32( p_tc_fx[LFE_CHANNEL - 1], p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#else /* Delay the separated channel to sync with the DirAC rendering */ Copy32( st_ivas->hTcBuffer->tc_fx[LFE_CHANNEL - 1] + offset, p_output_fx[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered ); +#endif } } } @@ -3258,6 +3428,8 @@ Word16 ivas_jbm_dec_get_num_tc_channels_fx( return num_tc; } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS + /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_tc() * @@ -3323,6 +3495,8 @@ static void ivas_jbm_dec_copy_tc( return; } +#endif + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_render_granularity() * @@ -3743,11 +3917,13 @@ void ivas_jbm_dec_tc_buffer_close_fx( return; } + /*--------------------------------------------------------------------------* * ivas_jbm_dec_td_renderers_adapt_subframes() * * Close JBM transport channel buffer *--------------------------------------------------------------------------*/ + void ivas_jbm_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) @@ -3814,6 +3990,8 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( return; } + + /*--------------------------------------------------------------------------* * ivas_jbm_dec_get_tc_buffer_mode() * @@ -3825,6 +4003,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( ) { TC_BUFFER_MODE buffer_mode; + buffer_mode = TC_BUFFER_MODE_BUFFER; move16(); @@ -3922,6 +4101,7 @@ TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( return buffer_mode; } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS /*--------------------------------------------------------------------------* * ivas_jbm_dec_copy_tc_no_tsm() @@ -4013,6 +4193,8 @@ void ivas_jbm_dec_copy_tc_no_tsm_fx( return; } +#endif + /*--------------------------------------------------------------------------* * ivas_jbm_dec_metadata_open() * @@ -4023,10 +4205,12 @@ ivas_error ivas_jbm_dec_metadata_open( Decoder_Struct *st_ivas ) { JBM_METADATA_HANDLE hJbmMetadata; + IF( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) ); } + hJbmMetadata->sf_write_idx = 0; move16(); hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES; @@ -4100,6 +4284,7 @@ static void ivas_jbm_dec_copy_masa_meta_to_buffer( * * Map input MASA metadata subframes to slots in JBM processing *--------------------------------------------------------------------------*/ + static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const Word16 nCldfbTs /* i : number of CLDFB time slots */ @@ -4111,6 +4296,10 @@ static void ivas_jbm_masa_sf_to_slot_map( Word16 slot_idx; Word16 write_idx, sf_index; +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas ); + +#endif /* Set values */ hJbmMetadata = st_ivas->hJbmMetadata; num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES; diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index b56ffd56647fb8970b3e27c5fa6dddc2113f0158..4dd7e82f9968026da2b69058e598ec362b43fe92 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -73,38 +73,26 @@ typedef struct parameter_band_mapping_struct static void ivas_param_mc_dec_init_fx( PARAM_MC_DEC_HANDLE hParamMC, const Word16 nchan_in, const Word16 nchan_out ); static void ivas_param_mc_dec_copy_diffuse_proto( PARAM_MC_DEC_HANDLE hParamMC, Word32 Cldfb_buffer_real_fx[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 Cldfb_buffer_imag_fx[MAX_CICP_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 nY, const Word16 slot_idx ); + static Word16 ivas_param_mc_range_decoder_LC_fx( UWord16 *bit_buffer, Word16 *x, Word16 *BER_detect, const Word16 sz_seq, const Word16 sz_alphabet, const UWord16 *cft, const UWord16 *sft, const Word16 tot_shift, const Word16 nbbits ); - -static void ivas_param_mc_get_mixing_matrices_fx( - PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ - IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, - Word32 Cx_in_fixed[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], /* i : input covariance for all parameter bands */ - Word16 Cx_in_e, - const Word16 param_band_idx, - Word32 *mixing_matrix_fx[], - Word16 *mixing_matrix_e, - Word32 *mixing_matrix_res_fx[], - Word16 *mixing_matrix_res_e, - const Word16 nY_intern, /* i : number of channels in the transported format */ - const PARAM_MC_SYNTHESIS_CONF synth_config, /* i : Parametric MC synthesis config */ - const Word16 nX, /* i : number of transport channels */ - const Word16 nY_cov /* i : number of covariance synthesis output channels */ -); +static void ivas_param_mc_get_mixing_matrices_fx( PARAM_MC_DEC_HANDLE hParamMC, IVAS_OUTPUT_SETUP *hSynthesisOutputSetup, Word32 Cx_in_fixed[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS], Word16 Cx_in_e, const Word16 param_band_idx, Word32 *mixing_matrix_fx[], Word16 *mixing_matrix_e, Word32 *mixing_matrix_res_fx[], Word16 *mixing_matrix_res_e, const Word16 nY_intern, const PARAM_MC_SYNTHESIS_CONF synth_config, const Word16 nX, const Word16 nY_cov ); static Word16 ivas_param_mc_uniform_decoder_fx( Word16 *seq, const Word16 sz_seq, const Word16 *alphabet, const Word16 N, UWord16 bit_buffer[PARAM_MC_MAX_BITS] ); + static void ivas_param_mc_dec_compute_interpolator_fx( const UWord16 bAttackPresent, const UWord16 attackPos, const UWord16 interp_length, Word16 *interpolator ); static void param_mc_set_num_synth_bands( const Word32 output_Fs, PARAM_MC_DEC_HANDLE hParamMC ); static void ivas_param_mc_get_param_band_mapping( const Word16 n_target_bands, const Word16 *target_band_grouping, const Word16 n_source_bands, const Word16 *source_band_grouping, PARAM_MC_PARAMETER_BAND_MAPPING *parameter_band_mapping ); - 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 ); +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 ); static void param_mc_protoSignalComputation_fx( Word32 *RealBuffer_fx, Word32 *ImagBuffer_fx, Word32 *proto_frame_f_fx, const PARAM_MC_DIFF_PROTO_INFO *diff_proto_info, const Word16 num_freq_bands, const Word16 Cldfb_Real_Imag_exp, Word16 *proto_frame_f_fx_q /* Word16 ImagBuffer_fx_e, Word16 *common_e*/ ); @@ -263,7 +251,6 @@ ivas_error ivas_param_mc_dec_open_fx( ivas_param_mc_metadata_open_fx( mc_ls_setup, ivas_total_brate, hParamMC->hMetadataPMC ); /* 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" ) ); @@ -352,6 +339,7 @@ ivas_error ivas_param_mc_dec_open_fx( } } } + 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" ) ); @@ -528,6 +516,7 @@ ivas_error ivas_param_mc_dec_open_fx( set32_fx( hParamMC->Cldfb_RealBuffer_tc_fx, 0, cldfb_buf_size ); hParamMC->Cldfb_RealBuffer_tc_e = 25; // Q6 , Initialised with Q6 to match non jbm and jbm cases move16(); + IF( ( hParamMC->Cldfb_ImagBuffer_tc_fx = (Word32 *) malloc( cldfb_buf_size * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Parametric MC JBM\n" ) ); @@ -564,6 +553,7 @@ ivas_error ivas_param_mc_dec_open_fx( move16(); st_ivas->hParamMC = hParamMC; + return error; } @@ -629,6 +619,7 @@ static void ivas_param_mc_get_param_band_mapping( parameter_band_mapping->n_source_bands[target_band_idx] = source_band_in_target_band_cnt; move16(); } + return; } @@ -662,6 +653,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( hParamMC = st_ivas->hParamMC; error = IVAS_ERR_OK; move32(); + /* save important config information from the previous state */ nchan_transport_old = st_ivas->nchan_transport; move32(); @@ -721,6 +713,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( /*-----------------------------------------------------------------* * set input parameters *-----------------------------------------------------------------*/ + hParamMC->num_freq_bands = shr( add( (Word16) Mpy_32_32( output_Fs, INV_CLDFB_BANDWIDTH_Q31 << 1 ), 1 ), 1 ); // Q0 move16(); hParamMC->max_band_energy_compensation = hParamMC->num_freq_bands; @@ -837,7 +830,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( *-----------------------------------------------------------------*/ /* prototype signal computation */ - IF( EQ_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) { IF( NE_16( nchan_transport_old, nchan_transport ) ) @@ -864,8 +856,8 @@ ivas_error ivas_param_mc_dec_reconfig_fx( Copy32( st_ivas->hLsSetUpConversion->dmxMtx_fx[k], &hParamMC->ls_conv_dmx_matrix_fx[k * nchan_out_cov], nchan_out_cov ); } } - /* convert ParamMC parameter bands to SFB */ + /* convert ParamMC parameter bands to SFB */ st_ivas->hLsSetUpConversion->sfbCnt = hParamMC->num_param_bands_synth; move16(); FOR( k = 0; k <= hParamMC->num_param_bands_synth; k++ ) @@ -1075,6 +1067,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } } } + ivas_dirac_dec_output_synthesis_cov_close_fx( ¶ms_old, &cov_state_old ); } @@ -1093,7 +1086,6 @@ ivas_error ivas_param_mc_dec_reconfig_fx( set_zero_fx( hParamMC->proto_frame_f_fx, shl( imult1616( hParamMC->diff_proto_info->num_protos_diff, hParamMC->num_freq_bands ), 1 ) ); } - IF( NE_16( nchan_transport_old, nchan_transport ) ) { IF( NE_16( hParamMC->synthesis_conf, PARAM_MC_SYNTH_MONO_STEREO ) ) @@ -1144,6 +1136,7 @@ ivas_error ivas_param_mc_dec_reconfig_fx( } } } + return error; } @@ -1261,6 +1254,7 @@ void ivas_param_mc_dec_close_fx( free( hParamMC->diff_proto_info ); hParamMC->diff_proto_info = NULL; } + /* States */ /* free prototype signal buffers */ IF( hParamMC->proto_frame_f_fx != NULL ) @@ -1525,8 +1519,13 @@ void ivas_param_mc_dec_digest_tc_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder handle */ const UWord8 nCldfbSlots, /* i : number of CLDFB slots in transport channels */ Word32 *p_data_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ - const Word16 transport_f_e ) + const Word16 q_data /* i : Q-factor of input signal for single channel */ +) { +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + Word16 ch, num_freq_bands, slot_idx, cldfb_ch, n_ch_cldfb; + Word32 *cldfb_real_buffer, *cldfb_imag_buffer; +#else PARAM_MC_DEC_HANDLE hParamMC; Word16 ch, slot_idx; Word16 nchan_transport; @@ -1536,16 +1535,45 @@ void ivas_param_mc_dec_digest_tc_fx( hParamMC = st_ivas->hParamMC; assert( hParamMC ); - Word16 qout = 0; +#endif + Word16 q_out = 0; move16(); + /* Initialization */ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + num_freq_bands = st_ivas->hParamMC->num_freq_bands; + move16(); + n_ch_cldfb = sub( st_ivas->hTcBuffer->nchan_transport_jbm, st_ivas->hTcBuffer->nchan_buffer_full ); - push_wmops( "param_mc_dec_digest_tc" ); - + cldfb_real_buffer = st_ivas->hParamMC->Cldfb_RealBuffer_tc_fx; + cldfb_imag_buffer = st_ivas->hParamMC->Cldfb_ImagBuffer_tc_fx; +#else nchan_transport = st_ivas->nchan_transport; move16(); +#endif +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + /* CLDFB Analysis */ + FOR( ( ch = 0, cldfb_ch = 0 ); cldfb_ch < n_ch_cldfb; ( cldfb_ch++, ch++ ) ) + { + FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) + { + q_out = q_data; + move16(); + cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][num_freq_bands * slot_idx] ), + &cldfb_real_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + &cldfb_imag_buffer[slot_idx * num_freq_bands * n_ch_cldfb + cldfb_ch * num_freq_bands], + num_freq_bands, st_ivas->cldfbAnaDec[cldfb_ch], &q_out ); + } + + IF( st_ivas->hDecoderConfig->Opt_tsm ) + { + st_ivas->hParamMC->Cldfb_ImagBuffer_tc_e = q_out; + move16(); + } + } +#else /* slot loop for gathering the input data */ FOR( slot_idx = 0; slot_idx < nCldfbSlots; slot_idx++ ) { @@ -1557,20 +1585,19 @@ void ivas_param_mc_dec_digest_tc_fx( /* CLDFB Analysis*/ FOR( ch = 0; ch < nchan_transport; ch++ ) { - qout = transport_f_e; + q_out = q_data; move16(); - cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &qout ); + cldfbAnalysis_ts_fx_fixed_q( &( p_data_fx[ch][hParamMC->num_freq_bands * slot_idx] ), RealBuffer_fx, ImagBuffer_fx, hParamMC->num_freq_bands, st_ivas->cldfbAnaDec[ch], &q_out ); Copy32( RealBuffer_fx, &hParamMC->Cldfb_RealBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); Copy32( ImagBuffer_fx, &hParamMC->Cldfb_ImagBuffer_tc_fx[slot_idx * hParamMC->num_freq_bands * nchan_transport + ch * hParamMC->num_freq_bands], hParamMC->num_freq_bands ); } - hParamMC->Cldfb_ImagBuffer_tc_e = qout; + hParamMC->Cldfb_ImagBuffer_tc_e = q_out; move16(); } } - - pop_wmops(); +#endif return; } @@ -1593,21 +1620,18 @@ void ivas_param_mc_dec_prepare_renderer( Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; Word16 nchan_out_cov; PARAM_MC_DEC_HANDLE hParamMC; - + /*CLDFB*/ Word32 *pCx, *pCx_imag; Word32 cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_e) Word32 cx_imag_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_e) Word32 cx_next_band_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_next_band_e) Word32 cx_imag_next_band_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; // Q(31 - cx_imag_next_band_e) Word32 real_part_fx, imag_part_fx, L_tmp1, L_tmp2; - Word16 cx_buff_e[2][PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word16 cx_e; Word16 cx_imag_e, tmp_e; Word16 cx_imag_next_band_e, cx_next_band_e; - Word16 max_e; - /* format converter */ Word16 channel_active[MAX_OUTPUT_CHANNELS]; IVAS_OUTPUT_SETUP *hSynthesisOutputSetup; @@ -1898,7 +1922,6 @@ void ivas_param_mc_dec_render_fx( Word16 slot_idx, slot_idx_start, slot_idx_start_cldfb_synth, first_sf, last_sf, slots_to_render; Word16 nchan_transport, nchan_out_transport, nchan_out_cldfb; Word16 nchan_out_cov; - /*CLDFB*/ Word32 Cldfb_RealBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; @@ -1911,7 +1934,6 @@ void ivas_param_mc_dec_render_fx( } /*Decorrelator*/ Word32 onset_filter_fx[MAX_CICP_CHANNELS * CLDFB_NO_CHANNELS_MAX]; // Q31 - /* format converter */ Word16 channel_active[MAX_OUTPUT_CHANNELS]; UWord16 nband_synth; @@ -2033,6 +2055,7 @@ void ivas_param_mc_dec_render_fx( /*-----------------------------------------------------------------* * protoype signal computation *-----------------------------------------------------------------*/ + param_mc_protoSignalComputation_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], hParamMC->proto_frame_f_fx, hParamMC->diff_proto_info, @@ -2040,8 +2063,8 @@ void ivas_param_mc_dec_render_fx( /*-----------------------------------------------------------------* * frequency domain decorrelation *-----------------------------------------------------------------*/ - /* decorrelate prototype frame */ + /* decorrelate prototype frame */ ivas_dirac_dec_decorr_process_fx( hParamMC->num_freq_bands, hParamMC->num_outputs_diff, hParamMC->diff_proto_info->num_protos_diff, @@ -2076,6 +2099,7 @@ void ivas_param_mc_dec_render_fx( /*-----------------------------------------------------------------* * output synthesis *-----------------------------------------------------------------*/ + ivas_dirac_dec_output_synthesis_cov_param_mc_synthesise_slot_fx( &hParamMC->Cldfb_RealBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], &hParamMC->Cldfb_ImagBuffer_tc_fx[hParamMC->slots_rendered * nchan_transport * hParamMC->num_freq_bands], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, slot_idx, add( slot_idx, slot_idx_start ), @@ -2243,7 +2267,6 @@ void ivas_param_mc_dec_render_fx( ivas_lssetupconversion_process_param_mc_fx( st_ivas, hParamMC->subframe_nbslots[subframe_idx], Cldfb_RealBuffer_fx, Cldfb_ImagBuffer_fx, channel_active ); } - /* CLDFB synthesis */ FOR( ch = 0; ch < nchan_out_cldfb; ch++ ) { @@ -2282,13 +2305,13 @@ void ivas_param_mc_dec_render_fx( slot_idx_start = add( slot_idx_start, hParamMC->subframe_nbslots[subframe_idx] ); slot_idx_start_cldfb_synth = add( slot_idx_start_cldfb_synth, hParamMC->subframe_nbslots[subframe_idx] ); } + IF( EQ_16( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) { ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_f_fx, p_output_f_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } /* update */ - IF( EQ_16( hParamMC->slots_rendered, hParamMC->num_slots ) ) { hParamMC->hMetadataPMC->last_coded_bwidth = hParamMC->hMetadataPMC->coded_bwidth; @@ -2296,7 +2319,6 @@ void ivas_param_mc_dec_render_fx( param_mc_update_mixing_matrices_fx( hParamMC, hParamMC->h_output_synthesis_cov_state.mixing_matrix_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_exp, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_fx, hParamMC->h_output_synthesis_cov_state.mixing_matrix_res_exp, nchan_transport, nchan_out_cov ); } - hParamMC->subframes_rendered = last_sf; move16(); *nSamplesAvailableNext = imult1616( sub( hParamMC->num_slots, hParamMC->slots_rendered ), NS2SA_FX2( output_Fs, CLDFB_SLOT_NS ) ); @@ -2402,7 +2424,6 @@ static void param_mc_protoSignalComputation_fx( set32_fx( proto_frame_f_fx, 0, shl( imult1616( num_freq_bands, diff_proto_info->num_protos_diff ), 1 ) ); - FOR( proto_ch_idx = 0; proto_ch_idx < diff_proto_info->num_protos_diff; proto_ch_idx++ ) { Word16 num_source_ch = diff_proto_info->num_source_chan_diff[proto_ch_idx]; @@ -2423,7 +2444,6 @@ static void param_mc_protoSignalComputation_fx( FOR( band = 0; band < num_freq_bands; band++ ) { - Word32 tmp_x = L_shl( Mpy_32_32( fac_fx, ( *( p_real_buffer_fx++ ) ) ), 4 ); // Q(26 + 4 + 6 - 31) :: Q5 *( p_proto_frame_fx ) = L_add( *( p_proto_frame_fx ), tmp_x ); @@ -2462,6 +2482,7 @@ static void ivas_param_mc_dec_copy_diffuse_proto( Word16 k, l; Word16 num_freq_bands, num_freq_bands_diff; Word32 *p_proto_diff_fx; + num_freq_bands = hParamMC->num_freq_bands; move16(); num_freq_bands_diff = hParamMC->h_output_synthesis_params.max_band_decorr; @@ -2508,11 +2529,13 @@ static Word16 ivas_param_mc_bin2dec_fx( return out; } + /*------------------------------------------------------------------------- * ivas_param_mc_uniform_decoder() * * decode a uniformily coded sequence of float values *------------------------------------------------------------------------*/ + static Word16 ivas_param_mc_uniform_decoder_fx( Word16 *seq, /* o : decoded sequence of float values hParamCodingInfo -> Q-quant*/ const Word16 sz_seq, /* i : number of values to decode */ @@ -2547,6 +2570,7 @@ static Word16 ivas_param_mc_uniform_decoder_fx( * * decode a sequency of inidices coded with a range coder *------------------------------------------------------------------------*/ + static Word16 ivas_param_mc_range_decoder_LC_fx( UWord16 *bit_buffer, /* i : bit buffer to read from */ Word16 *x, /* o : decoded indices */ @@ -2603,6 +2627,7 @@ static Word16 ivas_param_mc_range_decoder_LC_fx( return cur_bit_pos; } + /*------------------------------------------------------------------------- * param_mc_compute_interpolator() * @@ -2715,12 +2740,9 @@ static void ivas_param_mc_get_mixing_matrices_fx( Word16 ch_idx1, ch_idx2, lfe_idx1, lfe_idx2; Word16 remove_lfe; Word16 lfe_indices[PARAM_MC_LOCAL_SZ_LFE_MAP]; - Word32 Cx_fx[PARAM_MC_MAX_TRANSPORT_CHANS * PARAM_MC_MAX_TRANSPORT_CHANS]; Word32 Cy_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - Word32 Cy_full_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; - Word32 Cr_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; // Q(31 - Cr_e) Word16 Cr_e; Word32 Cy_diag_fx[MAX_OUTPUT_CHANNELS]; // Q(31 - Cy_diag_buff_e) @@ -2740,19 +2762,14 @@ static void ivas_param_mc_get_mixing_matrices_fx( Word16 mixing_matrix_res_local_e; Word32 L_tmp; Word16 tmp_e, tmp; - Word16 proto_matrix_e = hParamMC->h_output_synthesis_params.proto_matrix_e; move16(); Word32 proto_matrix_noLFE_fx[PARAM_MC_MAX_TRANSPORT_CHANS * MAX_CICP_CHANNELS]; // Q(31 - proto_matrix_noLFE_e) - - Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; // Q(31 - mat_mult_buffer1_e) - - Word32 Cproto_diag_fx[MAX_CICP_CHANNELS]; // Q(31 - Cproto_diag_e) + Word32 mat_mult_buffer1_fx[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; // Q(31 - mat_mult_buffer1_e) + Word32 Cproto_diag_fx[MAX_CICP_CHANNELS]; // Q(31 - Cproto_diag_e) Word16 mat_mult_buffer1_e, proto_matrix_ptr_e, Cproto_diag_e; - Word32 *ptrMM_fx; Word32 *ptrMM_out_fx; - Word16 Cy_e, Cx_e; Word16 Cy_full_e; Word16 new_e = 0; @@ -2818,6 +2835,7 @@ static void ivas_param_mc_get_mixing_matrices_fx( num_lfe_bands = PARAM_MC_MAX_BAND_LFE; move16(); } + IF( hSynthesisOutputSetup->num_lfe > 0 && param_band_idx >= num_lfe_bands ) { remove_lfe = 1; @@ -2843,10 +2861,8 @@ static void ivas_param_mc_get_mixing_matrices_fx( Cx_old_state_fx = hParamMC->h_output_synthesis_cov_state.cx_old_fx[param_band_idx]; Cy_old_state_fx = hParamMC->h_output_synthesis_cov_state.cy_old_fx[param_band_idx]; - /* Getting mixing mtx */ /* estimate target cov from input cov and proto_matrix */ - Cx_state_e = Cx_in_e; move16(); matrix_product_fx( hParamMC->proto_matrix_int_fx, nY_intern, nX, 0, Cx_state_fx, nX, nX, 0, mat_mult_buffer1_fx ); @@ -2876,8 +2892,6 @@ static void ivas_param_mc_get_mixing_matrices_fx( nY_intern, nX, Cx_state_fx, Cx_state_e, Cproto_fx, Cproto_e, Cy_state_fx, &Cy_state_e ); - // dbgwrite2_txt(Cy_state_fx,nY_intern*nY_intern,"../cy_state_fx.txt"); - /* Smoothing: Sum over two buffers */ IF( hParamMC->hMetadataPMC->bAttackPresent ) { @@ -2892,8 +2906,6 @@ static void ivas_param_mc_get_mixing_matrices_fx( ELSE { /* smoothing gains are now identical to one, simply add up */ - // v_add( Cy_state, Cy_old_state, Cy_full, nY_cov * nY_cov ); - v_add_fx_me( Cx_state_fx, Cx_state_e, Cx_old_state_fx, hParamMC->h_output_synthesis_cov_state.cx_old_e[param_band_idx], Cx_fx, &Cx_e, imult1616( nX, nX ), 1 ); v_add_fx_me( Cy_state_fx, Cy_state_e, Cy_old_state_fx, hParamMC->h_output_synthesis_cov_state.cy_old_e[param_band_idx], Cy_full_fx, &Cy_full_e, imult1616( nY_cov, nY_cov ), 1 ); } @@ -2939,7 +2951,6 @@ static void ivas_param_mc_get_mixing_matrices_fx( /* remove LFE IF necessary */ IF( remove_lfe ) { - Cy_e = Cy_full_e; remove_lfe_from_cy_fx( nY_cov, lfe_indices, hSynthesisOutputSetup->num_lfe, Cy_full_fx, Cy_fx ); } @@ -2956,7 +2967,6 @@ static void ivas_param_mc_get_mixing_matrices_fx( matrix_product_diag_fx( mat_mult_buffer1_fx, mat_mult_buffer1_e, nY_band, nX, 0, proto_matrix_ptr_fx, proto_matrix_ptr_e, nY_band, nX, 1, Cproto_diag_fx, &Cproto_diag_e ); /* make sure we have no negative entries in Cproto_diag due to rounding errors */ - FOR( ch_idx1 = 0; ch_idx1 < nY_band; ch_idx1++ ) { if ( Cproto_diag_fx[ch_idx1] < 0 ) @@ -2966,13 +2976,13 @@ static void ivas_param_mc_get_mixing_matrices_fx( } } - /* Computing the mixing matrices */ /* bands with decorr */ IF( LT_16( brange[0], hParamMC->h_output_synthesis_params.max_band_decorr ) ) { computeMixingMatrices_fx( nX, nY_band, Cx_fx, Cx_e, Cy_fx, Cy_e, proto_matrix_ptr_fx, proto_matrix_ptr_e, 0, PARAM_MC_REG_SX_FX, 0, PARAM_MC_REG_GHAT_FX, 0, mixing_matrix_local_fx, &mixing_matrix_local_e, Cr_fx, &Cr_e ); + /* Compute mixing matrix FOR residual */ computeMixingMatricesResidual_fx( nY_band, Cproto_diag_fx, Cproto_diag_e, Cr_fx, Cr_e, PARAM_MC_REG_SX_FX, 0, PARAM_MC_REG_GHAT_FX, 0, mixing_matrix_res_local_fx, &mixing_matrix_res_local_e ); @@ -3147,13 +3157,6 @@ static void param_mc_update_mixing_matrices_fx( * generate the target covariance matrix *------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------- - * ivas_param_mc_dequantize_cov_fx() - * - * generate the target covariance matrix - *------------------------------------------------------------------------*/ - static void ivas_param_mc_dequantize_cov_fx( PARAM_MC_DEC_HANDLE hParamMC, /* i : Parametric MC handle */ Word16 *ild_q_fx, /* i : sequence of dequantized ILD values Q8 */ @@ -3227,7 +3230,6 @@ static void ivas_param_mc_dequantize_cov_fx( } /* estimate ICCs from estimated Cproto */ - FOR( k = 0; k < nY_int; k++ ) { // a_fx[k] = 1.f / ( sqrtf( Cproto_fx[k + nY_int * k] ) + EPSILON ); @@ -3362,7 +3364,6 @@ static void ivas_param_mc_dequantize_cov_fx( Word32 target_ch_ener_fx[MAX_CICP_CHANNELS]; // Q(31 - target_ch_ener_e) Word16 target_ch_ener_e[MAX_CICP_CHANNELS]; Word32 dmx_ch_ener_fx[MAX_CICP_CHANNELS]; - Word16 ls_conv_dmx_matrix_e[MAX_CICP_CHANNELS * MAX_CICP_CHANNELS]; set32_fx( target_ch_ener_fx, 0, MAX_CICP_CHANNELS ); @@ -3471,6 +3472,7 @@ static void ivas_param_mc_dequantize_cov_fx( return; } + /*-------------------------------------------------------------------------* * param_mc_set_num_synth_bands() * @@ -3529,7 +3531,6 @@ static void param_mc_set_num_synth_bands( * calculated the diffuse prototype information *-------------------------------------------------------------------------*/ - 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 */ @@ -3664,6 +3665,7 @@ static ivas_error param_mc_get_diff_proto_info_fx( proto_fac_ptr += nchan_out_cov; } } + return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_osba_dec_fx.c b/lib_dec/ivas_osba_dec_fx.c index 7929753397c3119c7dcb665e83d63321577bf080..67908e99647bce09865d9790b89ad4eee6e18508 100644 --- a/lib_dec/ivas_osba_dec_fx.c +++ b/lib_dec/ivas_osba_dec_fx.c @@ -134,7 +134,7 @@ ivas_error ivas_osba_dirac_td_binaural_jbm_fx( { Word16 n; ivas_error error; - Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; // VE2SB: TBV + Word32 output_separated_objects_fx[BINAURAL_CHANNELS][L_FRAME48k]; Word32 *p_sepobj_fx[BINAURAL_CHANNELS]; Word16 channel_offset; Word16 slot_idx_start; diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index af03f4b6ef9d61a6c78a50dfbc36b4f5cecea547..05417a821a2d35596f86234828a68a292a0de473 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -121,6 +121,7 @@ void ivas_sba2mc_cldfb_fx( return; } + /*-------------------------------------------------------------------------* * ivas_mc2sba() * @@ -129,12 +130,11 @@ void ivas_sba2mc_cldfb_fx( void ivas_mc2sba_fx( IVAS_OUTPUT_SETUP hIntSetup, /* i : Format of decoder output */ - Word32 *in_buffer_td_fx[], - /* i : MC signals (on input) and the HOA3 (on output) */ /*Q*/ - Word32 *buffer_td_fx[], /* i/o: MC signals (on input) and the HOA3 (on output) Q*/ - const Word16 output_frame, /* i : output frame length per channel Q0*/ - const Word16 sba_order, /* i : Ambisonic (SBA) order Q0*/ - const Word16 gain_lfe_fx /* i : gain for LFE, 0 = ignore LFE Q14*/ + Word32 *in_buffer_td_fx[], /* i : MC signals (on input) and the HOA3 (on output) Q*/ + Word32 *buffer_td_fx[], /* i/o: MC signals (on input) and the HOA3 (on output) Q*/ + const Word16 output_frame, /* i : output frame length per channel Q0*/ + const Word16 sba_order, /* i : Ambisonic (SBA) order Q0*/ + const Word16 gain_lfe_fx /* i : gain for LFE, 0 = ignore LFE Q14*/ ) { Word16 i, j, k; @@ -218,6 +218,7 @@ void ivas_mc2sba_fx( * MC signals transformed into SBA in CLDFB domain * used for binaural rendering with head rotation *-------------------------------------------------------------------------*/ + void ivas_param_mc_mc2sba_cldfb_fx( IVAS_OUTPUT_SETUP hTransSetup, /* i : transported MC Format */ Word32 *hoa_encoder_fx, /* i : HOA3 encoder for the transported MC format Q31*/ @@ -342,23 +343,25 @@ Word16 ivas_sba_remapTCs_fx( } } } + return ( nchan_remapped ); } + /*-------------------------------------------------------------------------* * ivas_ism2sba_sf() * * ISM transformed into SBA in TD domain. *-------------------------------------------------------------------------*/ + void ivas_ism2sba_sf_fx( - Word32 *buffer_in_fx[], - /* i : TC buffer */ /*Q_buffer_in*/ - Word32 *buffer_out_fx[], /* o : TD signal buffers Q_buffer_in + 29 - 31*/ - ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ - const Word16 num_objects, /* i : number of objects Q0*/ - const Word16 n_samples_to_render, /* i : output frame length per channel Q0*/ - const Word16 offset, /* i : offset for the interpolatr Q0*/ - const Word16 sba_order /* i : Ambisonic (SBA) order Q0*/ + Word32 *buffer_in_fx[], /* i : TC buffer Q_buffer_in*/ + Word32 *buffer_out_fx[], /* o : TD signal buffers Q_buffer_in + 29 - 31*/ + ISM_RENDERER_HANDLE hIsmRendererData, /* i/o: renderer data */ + const Word16 num_objects, /* i : number of objects Q0*/ + const Word16 n_samples_to_render, /* i : output frame length per channel Q0*/ + const Word16 offset, /* i : offset for the interpolatr Q0*/ + const Word16 sba_order /* i : Ambisonic (SBA) order Q0*/ ) { Word16 i, j, k; @@ -380,9 +383,13 @@ void ivas_ism2sba_sf_fx( FOR( j = 0; j < sba_num_chans; j++ ) { g2_fx = hIsmRendererData->interpolator_fx + offset; /*Pointer addition*/ /*Q15*/ - tc_fx = buffer_in_fx[i] + offset; /*Pointer addition*/ /*Q_buffer_in*/ - out_fx = buffer_tmp_fx[j]; /*Q_buffer_in + 29 - 31*/ - gain_fx = hIsmRendererData->gains_fx[i][j]; /*Q29*/ +#ifdef UNIFIED_DECODING_PATHS_LEFTOVERS + tc_fx = buffer_in_fx[i]; /*Q_buffer_in*/ +#else + tc_fx = buffer_in_fx[i] + offset; /*Pointer addition*/ /*Q_buffer_in*/ +#endif + out_fx = buffer_tmp_fx[j]; /*Q_buffer_in + 29 - 31*/ + gain_fx = hIsmRendererData->gains_fx[i][j]; /*Q29*/ move32(); prev_gain_fx = hIsmRendererData->prev_gains_fx[i][j]; /*Q29*/ move32(); @@ -397,13 +404,16 @@ void ivas_ism2sba_sf_fx( } } } + FOR( j = 0; j < sba_num_chans; j++ ) { Copy32( buffer_tmp_fx[j], buffer_out_fx[j], n_samples_to_render ); /*Q_buffer_in + 29 - 31*/ } + return; } + /*-------------------------------------------------------------------* * ivas_sba_linear_renderer() * @@ -477,6 +487,7 @@ ivas_error ivas_sba_linear_renderer_fx( * * Determine SBA mixing matrices *-------------------------------------------------------------------*/ + void ivas_sba_mix_matrix_determiner_fx( SPAR_DEC_HANDLE hSpar, /* i/o: SPAR decoder handle */ Word32 *output_fx[], /* i/o: transport/output audio channels Q_output*/ @@ -491,6 +502,7 @@ void ivas_sba_mix_matrix_determiner_fx( Word16 num_bands_out, nchan_transport, nchan_out; Word16 Q_p_output = add( 11, Q_output ); Word32 temp_fx; + /* Convert numeric range */ FOR( ch = 0; ch < nchan_remapped; ch++ ) { @@ -520,6 +532,7 @@ void ivas_sba_mix_matrix_determiner_fx( move16(); nchan_out = nchan_transport; /*Q0*/ move16(); + ivas_agc_dec_process_fx( hSpar->hAgcDec, ( output_fx ), ( output_fx ), nchan_transport, output_frame ); Q_p_output = sub( Q_p_output, 3 ); #ifdef DEBUGGING @@ -538,6 +551,8 @@ void ivas_sba_mix_matrix_determiner_fx( /* Mixing matrix determiner */ num_bands_out = hSpar->hFbMixer->pFb->filterbank_num_bands; /*Q0*/ move16(); + ivas_spar_dec_gen_umx_mat_fx( hSpar->hMdDec, nchan_transport, num_bands_out, bfi, num_md_sub_frames ); + return; } diff --git a/lib_dec/ivas_stat_dec.h b/lib_dec/ivas_stat_dec.h index 83e368364ee9b4a12e87eb643a39e90121ec37df..289b91b775581bc1cc10616ad2cffb519a31b3f1 100644 --- a/lib_dec/ivas_stat_dec.h +++ b/lib_dec/ivas_stat_dec.h @@ -1005,9 +1005,9 @@ typedef struct ivas_masa_ism_data_structure typedef struct decoder_tc_buffer_structure { - Word32 *tc_buffer_fx; /* the buffer itself */ /*stores memory length of tc buffer*/ - Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ // VE2SB: TBV - Word16 no_channels; /*Stores no of channels in tc_fx with values*/ + Word32 *tc_buffer_fx; /* the buffer itself */ /*stores memory length of tc buffer*/ + Word32 *tc_fx[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS]; /* pointers into the buffer to the beginning of each tc Q11 for ivas */ + Word16 no_channels; /*Stores no of channels in tc_fx with values*/ Word16 q_tc_fx; TC_BUFFER_MODE tc_buffer_mode; /* mode of the buffer (no buffering, render buffering, out buffering) */ Word16 nchan_transport_jbm; /* number of TCs after TC decoding */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 59c6e6b44971ffd02def15a732fcbfd42daa2a66..b32a49e17802b37f45c8083e57b3153cb175832e 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5576,10 +5576,12 @@ static ivas_error evs_dec_main_fx( Copy32( pcm_buf_local, p_output_fx[ch], nOutSamples ); } } +#ifndef UNIFIED_DECODING_PATHS_LEFTOVERS ELSE // ToDo: the 'else' branch can be removed once UNIFIED_DECODING_PATHS_LEFTOVERS is merged { ivas_jbm_dec_copy_tc_no_tsm_fx( st_ivas, p_output_fx, nOutSamples ); } +#endif #else IF( !st_ivas->hDecoderConfig->Opt_tsm ) {