diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index faaf2b55ad52a1676a68cfff25507d77db5a944a..b24d34ce8542ee11adff3a2cb86db0b0dc5b10e8 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -1184,20 +1184,20 @@ void v_multc_acc_32_32( void ivas_mono_stereo_downmix_mcmasa_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono or stereo output */ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/mono or stereo output */ Word16 output_frame /* i : output frame length per channel */ ); void ivas_apply_non_diegetic_panning_fx( Word32 *input_f_fx, /* i : non-diegetic object */ - Word32 *output_f_fx[], /* i/o: core-coder transport mono channel/stereo output */ + Word32 *output_fx[], /* i/o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain */ const Word16 output_frame /* i : output frame length per channel */ ); void ivas_ism_mono_dmx_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono output */ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/mono output */ const Word16 output_frame /* i : output frame length */ ); @@ -2364,7 +2364,7 @@ void ivas_dirac_dec_render_fx( 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[] /* o : rendered time signal */ + Word32 *output_fx[] /* o : rendered time signal */ ); void ivas_dirac_dec_read_BS_fx( @@ -2557,7 +2557,7 @@ void ivas_omasa_dirac_rend_jbm_fx( UWord16 *nSamplesRendered, /* o : number of samples rendered */ UWord16 *nSamplesAvailable, /* o : number of samples still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_f[] /* o : rendered time signal */ + Word32 *output_fx[] /* o : rendered time signal */ ); ivas_error ivas_jbm_dec_render_fx( @@ -4065,7 +4065,7 @@ ivas_error ivas_init_encoder_fx( ); ivas_error ivas_output_buff_dec_fx( - Word32 *p_output_f[], /* i/o: output audio buffers */ + Word32 *p_output_fx[], /* i/o: output audio buffers */ const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ const Word16 nchan_out_buff /* i : number of output channels */ ); @@ -4348,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[] /* i/o: synthesized core-coder TCs / rendered signal*/ + Word32 *output_fx[] /* i/o: synthesized core-coder TCs / rendered signal*/ ); void ivas_param_ism_params_to_masa_param_mapping_fx( @@ -5151,7 +5151,7 @@ void ivas_param_mc_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[], /* o : rendered time signal */ + Word32 *output_fx[], /* o : rendered time signal */ Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] ); @@ -5349,7 +5349,7 @@ void ivas_spar_dec_close_fx( ); ivas_error ivas_sba_linear_renderer_fx( - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output */ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output */ const Word16 output_frame, /* i : output frame length per channel */ const Word16 nchan_in, /* i : number of input ambisonics channels */ const Word16 nchan_ism, /* i : number of objects */ diff --git a/lib_com/options.h b/lib_com/options.h index c9c900f6db999f87b2d9d28e487b692106bd25c7..ef9d0e6dc747276b1eadca15efd45c03abd78977 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -110,6 +110,8 @@ #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 */ +#define FIX_NCHAN_BUFFERS /* VA: issue 1322: Correct the number of float buffers (channels) at the decoder */ +#define FIX_RENDERER_STACK /* VA: issue 1322: reduction of renderers' buffers size */ // 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) @@ -120,7 +122,7 @@ #define FIX_1217_OBJECT_EDIT_FILE_INTERFACE /* Nokia: issue #1217: add decoder functionality to read object edit instructions from a file */ #define NONBE_1217_OBJ_EDIT_FOA /* VA/Nokia: isse 1217: fix crash in object editing to FOA output in ParamISM */ #define NONBE_FIX_1255_OBJ_EDIT_JBM /* VA: issue 1255: restore object editing in JBM */ - +#define FIX_1372_OSBA_OBJECT_EDITING /* VA: issue 1372: Fix OSBA object-editing in BINAURAL_ROOM_IR */ /* #################### End BASOP porting switches ############################ */ diff --git a/lib_dec/ivas_dirac_dec_fx.c b/lib_dec/ivas_dirac_dec_fx.c index 14e38ebdb85cd91d0a54277021c6a97b567119b9..2eecca0e56fb89ddf2fd90948f9e9d79028c9b48 100644 --- a/lib_dec/ivas_dirac_dec_fx.c +++ b/lib_dec/ivas_dirac_dec_fx.c @@ -2075,20 +2075,28 @@ void ivas_dirac_dec_render_fx( Word16 temp = 0; 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 }; + Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; +#ifdef FIX_RENDERER_STACK + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; + Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k / MAX_PARAM_SPATIAL_SUBFRAMES]; +#else + Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k] = { 0 }; +#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_intern = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); FOR( ch = 0; ch < nchan_intern; ch++ ) { - output_f_local_fx[ch] = output_f_local_buff_fx[ch]; - set_zero_fx( output_f_local_fx[ch], nSamplesAsked ); + output_fx_local[ch] = output_fx_local_buff[ch]; +#ifdef FIX_RENDERER_STACK + p_output_fx[ch] = output_fx[ch]; +#else + set_zero_fx( output_fx_local[ch], nSamplesAsked ); +#endif } slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); // cL - /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */ slots_to_render = s_min( sub( hSpatParamRendCom->num_slots, hSpatParamRendCom->slots_rendered ), idiv1616( nSamplesAsked, slot_size ) ); @@ -2108,29 +2116,42 @@ void ivas_dirac_dec_render_fx( FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - ivas_dirac_dec_render_sf_fx( st_ivas, output_f_local_fx, nchan_transport, NULL, NULL ); + ivas_dirac_dec_render_sf_fx( st_ivas, output_fx_local, nchan_transport, NULL, NULL ); n_samples_sf = i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slot_size ); FOR( ch = 0; ch < nchan_intern; ch++ ) { - output_f_local_fx[ch] += n_samples_sf; +#ifdef FIX_RENDERER_STACK + /* move to output */ + test(); + test(); + IF( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( EQ_16( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, ch ) || EQ_16( add( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, 1 ), ch ) ) ) ) + { + Copy32( output_fx_local_buff[ch], p_output_fx[ch], n_samples_sf ); + } + + p_output_fx[ch] += n_samples_sf; +#else + output_fx_local[ch] += n_samples_sf; +#endif } /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } +#ifndef FIX_RENDERER_STACK FOR( ch = 0; ch < nchan_intern; ch++ ) { test(); test(); IF( !( ( st_ivas->hDirACRend->hOutSetup.separateChannelEnabled ) && ( ( EQ_16( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, ch ) || EQ_16( add( st_ivas->hDirACRend->hOutSetup.separateChannelIndex, 1 ), ch ) ) ) ) ) { - Copy32( output_f_local_buff_fx[ch], output_fx[ch], *nSamplesRendered ); + Copy32( output_fx_local_buff[ch], output_fx[ch], *nSamplesRendered ); } } - +#endif /* clang-format off */ IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) ) { diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 6f5694453882da693513237632f82d9ac6d44243..00179537e0749a109a66aa1f3bb9899188094d57 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -562,7 +562,7 @@ ivas_error ivas_dec_setup( } /*-------------------------------------------------------------------* - * Read other signling (ISM/MC mode, number of channels, etc.) + * Read other signaling (ISM/MC mode, number of channels, etc.) *-------------------------------------------------------------------*/ IF( is_DTXrate( ivas_total_brate ) == 0 ) @@ -2953,7 +2953,12 @@ ivas_error ivas_init_decoder_fx( * Allocate output audio buffers *-----------------------------------------------------------------*/ +#ifdef FIX_NCHAN_BUFFERS + k = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); + FOR( n = 0; n < k; n++ ) +#else FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, ivas_total_brate ); n++ ) +#endif { /* note: these are intra-frame heap memories */ IF( ( st_ivas->p_output_fx[n] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) diff --git a/lib_dec/ivas_ism_param_dec_fx.c b/lib_dec/ivas_ism_param_dec_fx.c index a094d8cf20c1488b02e0368813bd0347ae4488ff..4821d5cdd0abd61bfd0516c6c31dc259da162f5d 100644 --- a/lib_dec/ivas_ism_param_dec_fx.c +++ b/lib_dec/ivas_ism_param_dec_fx.c @@ -1620,7 +1620,7 @@ static void ivas_ism_param_dec_render_sf_fx( const Word16 nchan_transport, const Word16 nchan_out, const Word16 nchan_out_woLFE, - Word32 *output_f_fx[], /*Q_output*/ + Word32 *output_fx[], /*Q_output*/ Word16 Q_output[] ) { Word16 ch, slot_idx, i, index_slot, cldfb_idx; @@ -1690,7 +1690,7 @@ static void ivas_ism_param_dec_render_sf_fx( test(); IF( ( hSetup.num_lfe > 0 ) && EQ_16( hSetup.index_lfe[idx_lfe], ch ) ) { - set32_fx( output_f_fx[ch], 0, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); + set32_fx( output_fx[ch], 0, i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); if ( LT_16( idx_lfe, sub( hSetup.num_lfe, 1 ) ) ) { @@ -1724,7 +1724,7 @@ static void ivas_ism_param_dec_render_sf_fx( Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( sub( Q_real, 1 ), Q11 ) ); // Q_real-1 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = sub( Q_real, 1 ); move16(); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_f_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, output_fx[ch], i_mult( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); Scale_sig32( st_ivas->cldfbSynDec[ch]->cldfb_state_fx, st_ivas->cldfbSynDec[ch]->p_filter_length, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 st_ivas->cldfbSynDec[ch]->Q_cldfb_state = Q11; move16(); @@ -1741,7 +1741,7 @@ static void ivas_ism_param_dec_render_sf_fx( } size_cldfb = imult1616( st_ivas->cldfbSynDec[ch]->no_channels, no_col_cldfb ); - Scale_sig32( output_f_fx[ch], size_cldfb, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 + Scale_sig32( output_fx[ch], size_cldfb, sub( Q11, sub( Q_real, 1 ) ) ); // Q11 Q_output[ch] = 11; move16(); @@ -1769,7 +1769,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 *nSamplesAvailableNext, /* o : number of CLDFB slots still to render */ - Word32 *output_f_fx[] /* i/o: synthesized core-coder TCs / rendered signal Q11*/ + Word32 *output_fx[] /* i/o: synthesized core-coder TCs / rendered signal Q11*/ ) { Word16 ch, slots_to_render, first_sf, last_sf, subframe_idx; @@ -1778,7 +1778,7 @@ void ivas_param_ism_dec_render_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; IVAS_OUTPUT_SETUP hSetup; Word16 nchan_transport, nchan_out, nchan_out_woLFE; - Word32 *output_f_local_fx[MAX_OUTPUT_CHANNELS]; + Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; Word16 Q_output[MAX_OUTPUT_CHANNELS]; set16_fx( Q_output, 0, MAX_OUTPUT_CHANNELS ); @@ -1827,17 +1827,17 @@ void ivas_param_ism_dec_render_fx( FOR( ch = 0; ch < nchan_out; ch++ ) { - output_f_local_fx[ch] = &output_f_fx[ch][0]; + output_fx_local[ch] = &output_fx[ch][0]; } FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - ivas_ism_param_dec_render_sf_fx( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_f_local_fx, Q_output ); + ivas_ism_param_dec_render_sf_fx( st_ivas, hSetup, nchan_transport, nchan_out, nchan_out_woLFE, output_fx_local, Q_output ); n_samples_sf = i_mult( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->slot_size ); FOR( ch = 0; ch < nchan_out; ch++ ) { - output_f_local_fx[ch] += n_samples_sf; + output_fx_local[ch] += n_samples_sf; } } diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 0f639e14a7fbd1efdf4a797d6dc51bfb8cf95ed3..9ce180ec573c88b5c9f29b6d10784ae22b6ffb64 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1632,7 +1632,12 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( move16(); } +#ifdef FIX_NCHAN_BUFFERS + ch = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); + FOR( n = 0; n < ch; n++ ) +#else FOR( n = 0; n < ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); n++ ) +#endif { hTcBuffer->tc_fx[n] = st_ivas->p_output_fx[n]; /* note: buffers needed in the TD decorellator */ move16(); diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index cd449860a9f357d20143ae9105bcd40fe935f5fa..fe3f7fee990cefd5e99365060e791cecdb153f8d 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1695,6 +1695,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( Decoder_State **sts; UWord32 ivas_total_brate, last_ivas_total_brate; Word16 numCldfbAnalyses_old, numCldfbSyntheses_old; +#ifdef FIX_NCHAN_BUFFERS + Word16 nchan_out_buff_old, nchan_out_buff; +#endif ivas_error error; Word32 ism_total_brate; Word16 pos_idx; @@ -1703,6 +1706,9 @@ ivas_error ivas_masa_dec_reconfigure_fx( move32(); last_ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate; move32(); +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); +#endif test(); test(); @@ -1972,8 +1978,20 @@ ivas_error ivas_masa_dec_reconfigure_fx( } ELSE { +#ifdef FIX_NCHAN_BUFFERS + tc_nchan_to_allocate = BINAURAL_CHANNELS; + move16(); + test(); + if ( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + tc_nchan_to_allocate = 2 * BINAURAL_CHANNELS; + move16(); + } +#else tc_nchan_to_allocate = shl( BINAURAL_CHANNELS, 1 ); +#endif } + test(); test(); test(); @@ -2041,6 +2059,22 @@ ivas_error ivas_masa_dec_reconfigure_fx( } } +#ifdef FIX_NCHAN_BUFFERS + /*-----------------------------------------------------------------* + * output audio buffers + *-----------------------------------------------------------------*/ + + test(); + IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) && EQ_32( st_ivas->last_ivas_format, MASA_FORMAT ) ) /* note: switching with OMASA is addressed in ivas_omasa_dec_config() */ + { + nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 ); + IF( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ) != IVAS_ERR_OK ) + { + return error; + } + } + +#endif return IVAS_ERR_OK; } diff --git a/lib_dec/ivas_mc_param_dec_fx.c b/lib_dec/ivas_mc_param_dec_fx.c index 4dd7e82f9968026da2b69058e598ec362b43fe92..d95ffe9984499fd8f4a4655de7644f379a88da17 100644 --- a/lib_dec/ivas_mc_param_dec_fx.c +++ b/lib_dec/ivas_mc_param_dec_fx.c @@ -1913,7 +1913,7 @@ void ivas_param_mc_dec_render_fx( 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[], /* o : rendered time signal Q11*/ + Word32 *output_fx[], /* o : rendered time signal Q11*/ Word16 channel_active_fx[MAX_OUTPUT_CHANNELS] ) { PARAM_MC_DEC_HANDLE hParamMC; @@ -1927,10 +1927,10 @@ void ivas_param_mc_dec_render_fx( Word32 Cldfb_ImagBuffer_fx[MAX_INTERN_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_RealBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; Word32 Cldfb_ImagBuffer_Binaural_fx[MAX_HEAD_ROT_POSES][BINAURAL_CHANNELS][PARAM_MC_MAX_NSLOTS_IN_SUBFRAME][CLDFB_NO_CHANNELS_MAX]; - Word32 *p_output_f_fx[MAX_OUTPUT_CHANNELS]; + Word32 *p_output_fx[MAX_OUTPUT_CHANNELS]; FOR( i = 0; i < MAX_OUTPUT_CHANNELS; i++ ) { - p_output_f_fx[i] = output_f_fx[i]; // Q11 + p_output_fx[i] = output_fx[i]; // Q11 } /*Decorrelator*/ Word32 onset_filter_fx[MAX_CICP_CHANNELS * CLDFB_NO_CHANNELS_MAX]; // Q31 @@ -2291,15 +2291,15 @@ void ivas_param_mc_dec_render_fx( } Word16 len = add( imult1616( slot_idx_start_cldfb_synth, hParamMC->num_freq_bands ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); - scale_sig32( output_f_fx[ch], len, 5 - 11 ); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), + scale_sig32( output_fx[ch], len, 5 - 11 ); + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ), 0, 0, st_ivas->cldfbSynDec[ch] ); - scale_sig32( output_f_fx[ch], len, 11 - 5 ); // Q11 + scale_sig32( output_fx[ch], len, 11 - 5 ); // Q11 } ELSE { - set32_fx( &( output_f_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), 0, imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); + set32_fx( &( output_fx[ch][slot_idx_start_cldfb_synth * hParamMC->num_freq_bands] ), 0, imult1616( hParamMC->num_freq_bands, hParamMC->subframe_nbslots[subframe_idx] ) ); } } slot_idx_start = add( slot_idx_start, hParamMC->subframe_nbslots[subframe_idx] ); @@ -2308,7 +2308,7 @@ void ivas_param_mc_dec_render_fx( 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 ); + ivas_mc2sba_fx( st_ivas->hIntSetup, p_output_fx, p_output_fx, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0 ); } /* update */ diff --git a/lib_dec/ivas_mct_dec_fx.c b/lib_dec/ivas_mct_dec_fx.c index 63b776d8056a4ce94364fa7191c78a0fb1552596..aaffbee9ae66d0bffb33a2ccde5dec69dbf5ccd0 100644 --- a/lib_dec/ivas_mct_dec_fx.c +++ b/lib_dec/ivas_mct_dec_fx.c @@ -951,7 +951,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config ); /* transfer subframe info from DirAC or ParamMC to central tc buffer */ - if ( st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER ) + IF( NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) ) { test(); IF( EQ_16( last_mc_mode, MC_MODE_PARAMMC ) ) @@ -1246,6 +1246,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode ); move16(); } + IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) ) { UWord8 separateChannelEnabled; @@ -1287,6 +1288,7 @@ static ivas_error ivas_mc_dec_reconfig_fx( { return error; } + IF( EQ_16( last_mc_mode, MC_MODE_MCT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && GT_16( st_ivas->nchan_transport, CPE_CHANNELS ) ) { st = st_ivas->hCPE[1]->hCoreCoder[1]; @@ -1311,7 +1313,6 @@ static ivas_error ivas_mc_dec_reconfig_fx( return error; } - /*-----------------------------------------------------------------* * Reconfigure renderers *-----------------------------------------------------------------*/ @@ -1548,8 +1549,23 @@ static ivas_error ivas_mc_dec_reconfig_fx( test(); IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) ) { +#ifdef FIX_NCHAN_BUFFERS + tc_nchan_allocate_new = BINAURAL_CHANNELS; + move16(); + test(); + IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + tc_nchan_allocate_new = 2 * BINAURAL_CHANNELS; + move16(); + } + ELSE IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + tc_nchan_allocate_new = add( tc_nchan_allocate_new, 1 ); + } +#else tc_nchan_allocate_new = BINAURAL_CHANNELS * 2; move16(); +#endif tc_nchan_full_new = tc_nchan_allocate_new; move16(); } diff --git a/lib_dec/ivas_mono_dmx_renderer_fx.c b/lib_dec/ivas_mono_dmx_renderer_fx.c index f9b3de6ef5a43d7548ff05b7545cded874144b44..6c64eee816fc5cfbb4db6c676a09e080e004d4bc 100644 --- a/lib_dec/ivas_mono_dmx_renderer_fx.c +++ b/lib_dec/ivas_mono_dmx_renderer_fx.c @@ -106,9 +106,10 @@ void ivas_mono_dmx_renderer_close( * * Downmix process *------------------------------------------------------------------------*/ + void ivas_ism_mono_dmx_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono output Qin = 11/ Qout = 8*/ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/mono output Qin = 11/ Qout = 8*/ const Word16 output_frame /* i : output frame length */ ) { @@ -149,7 +150,7 @@ void ivas_ism_mono_dmx_fx( move16(); FOR( Word16 lp = 0; lp < numInputChannels; lp++ ) { - Word16 norm = L_norm_arr( output_f_fx[lp], output_frame ); + Word16 norm = L_norm_arr( output_fx[lp], output_frame ); Output_norm = s_min( Output_norm, norm ); } Q_shift = sub( Output_norm, find_guarded_bits_fx( numInputChannels ) ); @@ -157,11 +158,10 @@ void ivas_ism_mono_dmx_fx( /* Compute the Proto Signal */ FOR( i = 0; i < numInputChannels; i++ ) { - v_shr_32( output_f_fx[i], output_shr, output_frame, -Q_shift ); + v_shr_32( output_fx[i], output_shr, output_frame, -Q_shift ); v_add_32( output_shr, proto_signal_fx, proto_signal_fx, output_frame ); } - proto_norm = L_norm_arr( proto_signal_fx, output_frame ); proto_shift = sub( proto_norm, shr( ( add( find_guarded_bits_fx( output_frame ), 1 ) ), 1 ) ); @@ -176,7 +176,7 @@ void ivas_ism_mono_dmx_fx( protoEner_pre = L_add( protoEner_pre, Mpy_32_32( proto_sh, proto_sh ) ); FOR( j = 0; j < numInputChannels; j++ ) { - Word32 output_f_shift = L_shl( output_f_fx[j][i], input_shift ); + Word32 output_f_shift = L_shl( output_fx[j][i], input_shift ); inputEner_pre = L_add( inputEner_pre, Mpy_32_32( output_f_shift, output_f_shift ) ); } } @@ -257,8 +257,8 @@ void ivas_ism_mono_dmx_fx( } /* equalize the downmix */ - v_multc_fx_16( proto_signal_fx, eq_fx, output_f_fx[0], output_frame ); - v_shr_32( output_f_fx[0], output_f_fx[0], output_frame, Q_shift ); + v_multc_fx_16( proto_signal_fx, eq_fx, output_fx[0], output_frame ); + v_shr_32( output_fx[0], output_fx[0], output_frame, Q_shift ); return; } @@ -271,7 +271,7 @@ void ivas_ism_mono_dmx_fx( void ivas_mono_stereo_downmix_mcmasa_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - Word32 *output_f_fx[], /* i/o: synthesized core-coder transport channels/mono or stereo output Q11*/ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/mono or stereo output Q11*/ Word16 output_frame /* i : output frame length per channel */ ) { @@ -285,8 +285,8 @@ void ivas_mono_stereo_downmix_mcmasa_fx( test(); IF( EQ_16( st_ivas->hDecoderConfig->nchan_out, 2 ) && st_ivas->hOutSetup.separateChannelEnabled ) { - v_multc_acc_32_16( output_f_fx[st_ivas->hOutSetup.separateChannelIndex], INV_SQRT2_FX_Q15, output_f_fx[0], output_frame ); // Q11 - v_multc_acc_32_16( output_f_fx[st_ivas->hOutSetup.separateChannelIndex], INV_SQRT2_FX_Q15, output_f_fx[1], output_frame ); // Q11 + v_multc_acc_32_16( output_fx[st_ivas->hOutSetup.separateChannelIndex], INV_SQRT2_FX_Q15, output_fx[0], output_frame ); // Q11 + v_multc_acc_32_16( output_fx[st_ivas->hOutSetup.separateChannelIndex], INV_SQRT2_FX_Q15, output_fx[1], output_frame ); // Q11 } /* Mono downmix */ ELSE IF( EQ_16( st_ivas->hDecoderConfig->nchan_out, 1 ) ) @@ -294,16 +294,16 @@ void ivas_mono_stereo_downmix_mcmasa_fx( /* Downmix L and R to dmx_tmp */ FOR( i = 0; i < st_ivas->nchan_transport; i++ ) { - v_multc_acc_32_16( output_f_fx[i], INV_SQRT2_FX_Q15, dmx_tmp_fx, output_frame ); // Q11 + v_multc_acc_32_16( output_fx[i], INV_SQRT2_FX_Q15, dmx_tmp_fx, output_frame ); // Q11 } /* Add center channel */ IF( st_ivas->hOutSetup.separateChannelEnabled ) { - v_add_32( output_f_fx[st_ivas->hOutSetup.separateChannelIndex], dmx_tmp_fx, dmx_tmp_fx, output_frame ); + v_add_32( output_fx[st_ivas->hOutSetup.separateChannelIndex], dmx_tmp_fx, dmx_tmp_fx, output_frame ); } /* Move to output */ - Copy32( dmx_tmp_fx, output_f_fx[0], output_frame ); // Q11 + Copy32( dmx_tmp_fx, output_fx[0], output_frame ); // Q11 } return; @@ -318,7 +318,7 @@ void ivas_mono_stereo_downmix_mcmasa_fx( void ivas_apply_non_diegetic_panning_fx( Word32 *input_f_fx, /* i : non-diegetic object */ - Word32 *output_f_fx[], /* o: core-coder transport mono channel/stereo output */ + Word32 *output_fx[], /* o: core-coder transport mono channel/stereo output */ const Word16 non_diegetic_pan_gain_fx, /* i : non-diegetic panning gain Q15*/ const Word16 output_frame /* i : output frame length per channel Q11*/ ) @@ -328,8 +328,8 @@ void ivas_apply_non_diegetic_panning_fx( pan_left_fx = add( mult( non_diegetic_pan_gain_fx, 16384 ), 16384 ); // 0.5.Q15 = 16384 pan_right_fx = sub( 32767, pan_left_fx ); - v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_f_fx[1], output_frame ); - v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_f_fx[0], output_frame ); + v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_right_fx ), 16 ), output_fx[1], output_frame ); + v_multc_fx( input_f_fx, L_shl( L_deposit_l( pan_left_fx ), 16 ), output_fx[0], output_frame ); return; } diff --git a/lib_dec/ivas_omasa_dec_fx.c b/lib_dec/ivas_omasa_dec_fx.c index 6a44c76a322b6a896853aebce2ff5ef159368ed8..811935a6037f5ecc7c5b6c359084e4b308b80c04 100644 --- a/lib_dec/ivas_omasa_dec_fx.c +++ b/lib_dec/ivas_omasa_dec_fx.c @@ -1066,7 +1066,7 @@ void ivas_omasa_dirac_rend_jbm_fx( UWord16 *nSamplesRendered, /* o : number of samples rendered */ UWord16 *nSamplesAvailable, /* o : number of samples still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_f[] /* o : rendered time signal Q11*/ + Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { Word16 subframes_rendered; @@ -1079,11 +1079,10 @@ void ivas_omasa_dirac_rend_jbm_fx( { *nSamplesRendered = min( nSamplesAsked, st_ivas->hTcBuffer->n_samples_available ); - test(); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_MASA_ONE_OBJ ) || EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { - Copy32( &output_f[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); + Copy32( &output_fx[CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[0], *nSamplesRendered ); IF( EQ_32( st_ivas->ism_mode, ISM_MASA_MODE_PARAM_ONE_OBJ ) ) { /* Gain separated object, if edited */ @@ -1102,7 +1101,7 @@ void ivas_omasa_dirac_rend_jbm_fx( { FOR( n = 0; n < st_ivas->nchan_ism; n++ ) { - Copy32( &output_f[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); + Copy32( &output_fx[n + CPE_CHANNELS][st_ivas->hTcBuffer->n_samples_rendered], data_separated_objects[n], *nSamplesRendered ); /* Gain discrete objects, if edited */ IF( st_ivas->hMasaIsmData->ism_gain_is_edited[n] ) @@ -1117,8 +1116,8 @@ void ivas_omasa_dirac_rend_jbm_fx( { FOR( n = 0; n < 2; n++ ) { - v_multc_fx_16( output_f[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_f[n], *nSamplesRendered ); // Q = 8 - Scale_sig32( output_f[n], *nSamplesRendered, Q3 ); // Q = 11 + v_multc_fx_16( output_fx[n], st_ivas->hMasaIsmData->gain_masa_edited_fx, output_fx[n], *nSamplesRendered ); // Q = 8 + Scale_sig32( output_fx[n], *nSamplesRendered, Q3 ); // Q = 11 } } } @@ -1129,14 +1128,14 @@ void ivas_omasa_dirac_rend_jbm_fx( slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered; move16(); - ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_f ); + ivas_dirac_dec_render_fx( st_ivas, nchan_transport, nSamplesAsked, nSamplesRendered, nSamplesAvailable, output_fx ); FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) { scale_sig32( st_ivas->hIsmRendererData->prev_gains_fx[ind1], MAX_OUTPUT_CHANNELS, -1 ); // Q30 -> Q29 } - ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_f, subframes_rendered, slots_rendered ); + ivas_omasa_separate_object_render_jbm_fx( st_ivas, *nSamplesRendered, data_separated_objects, output_fx, subframes_rendered, slots_rendered ); FOR( Word16 ind1 = 0; ind1 < MAX_NUM_OBJECTS; ind1++ ) { diff --git a/lib_dec/ivas_sba_dec_fx.c b/lib_dec/ivas_sba_dec_fx.c index 6ffd97cdb85d47acb34958da01a13e9a6f8bc9ac..ea7e100a15db37363db57d012c49652c784fc0f9 100644 --- a/lib_dec/ivas_sba_dec_fx.c +++ b/lib_dec/ivas_sba_dec_fx.c @@ -876,22 +876,41 @@ ivas_error ivas_sba_dec_render_fx( Word32 *output_fx[] /* o : rendered time signal Q11*/ ) { - Word16 slots_to_render, first_sf, last_sf, subframe_idx; + Word16 slots_to_render, first_sf, last_sf, subframe_idx, n_samples_sf; UWord16 slot_size, ch; UWord16 nchan_internal, nchan_out; SPAR_DEC_HANDLE hSpar; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; - Word32 *output_f_local_fx[MAX_OUTPUT_CHANNELS]; + Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; ivas_error error; hSpar = st_ivas->hSpar; hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_internal = ivas_sba_get_nchan_metadata_fx( st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); nchan_out = add( st_ivas->hIntSetup.nchan_out_woLFE, st_ivas->hIntSetup.num_lfe ); /*Q0*/ +#ifdef FIX_NCHAN_BUFFERS + IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) ) + { + nchan_out = s_max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); + IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) ) + { + nchan_out = s_max( nchan_internal, sub( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ) ); + } +#ifdef FIX_1372_OSBA_OBJECT_EDITING + ELSE IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) + { + nchan_out = BINAURAL_CHANNELS; + move16(); + } +#endif + } + nchan_out = s_min( nchan_out, ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); + +#endif FOR( ch = 0; ch < nchan_out; ch++ ) { - output_f_local_fx[ch] = output_fx[ch]; /*Q11*/ + output_fx_local[ch] = output_fx[ch]; /*Q11*/ } slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); /*Q0*/ @@ -913,12 +932,13 @@ ivas_error ivas_sba_dec_render_fx( FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - Word16 n_samples_sf = imult1616( slot_size, hSpar->subframe_nbslots[subframe_idx] ); /*Q0*/ + n_samples_sf = imult1616( slot_size, hSpar->subframe_nbslots[subframe_idx] ); /*Q0*/ + + ivas_spar_dec_upmixer_sf_fx( st_ivas, output_fx_local, nchan_internal ); - ivas_spar_dec_upmixer_sf_fx( st_ivas, output_f_local_fx, nchan_internal ); FOR( ch = 0; ch < nchan_out; ch++ ) { - output_f_local_fx[ch] = output_f_local_fx[ch] + n_samples_sf; /*Q11*/ + output_fx_local[ch] = output_fx_local[ch] + n_samples_sf; /*Q11*/ } /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); diff --git a/lib_dec/ivas_sba_rendering_internal_fx.c b/lib_dec/ivas_sba_rendering_internal_fx.c index 05417a821a2d35596f86234828a68a292a0de473..bf64b92d83928ff6d148c270d846f37b3c4409c9 100644 --- a/lib_dec/ivas_sba_rendering_internal_fx.c +++ b/lib_dec/ivas_sba_rendering_internal_fx.c @@ -419,12 +419,9 @@ void ivas_ism2sba_sf_fx( * * Linear rendering for SBA format *-------------------------------------------------------------------*/ -/*TODO: To be tested*/ -/************************ -Float to fixed conversion required for:output_f -*************************/ + ivas_error ivas_sba_linear_renderer_fx( - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ const Word16 output_frame, /* i : output frame length per channel Q0*/ const Word16 nchan_in, /* i : number of input ambisonics channels Q0*/ const Word16 nchan_ism, /* i : number of objects Q0*/ @@ -461,17 +458,17 @@ ivas_error ivas_sba_linear_renderer_fx( case IVAS_AUDIO_CONFIG_HOA3: /* Ambisonics output, order: 3 */ FOR( i = nchan_hoa; i < output_setup.nchan_out_woLFE; i++ ) { - set_zero_fx( output_f[i], output_frame ); + set_zero_fx( output_fx[i], output_frame ); } BREAK; case IVAS_AUDIO_CONFIG_EXTERNAL: FOR( i = output_setup.nchan_out_woLFE - 1; i >= nchan_ism; i-- ) { - Copy32( output_f[i - nchan_ism], output_f[i], output_frame ); /*Q11*/ + Copy32( output_fx[i - nchan_ism], output_fx[i], output_frame ); /*Q11*/ } FOR( ; i >= 0; i-- ) { - set_zero_fx( output_f[i], output_frame ); + set_zero_fx( output_fx[i], output_frame ); } BREAK; default: diff --git a/lib_dec/ivas_spar_decoder_fx.c b/lib_dec/ivas_spar_decoder_fx.c index b0a802270e2d51a5cf61214b4903cf9c65d54516..12a916fbe490ea505582b7248fac025cec7742d9 100644 --- a/lib_dec/ivas_spar_decoder_fx.c +++ b/lib_dec/ivas_spar_decoder_fx.c @@ -1759,9 +1759,13 @@ void ivas_spar_dec_upmixer_sf_fx( p_tc_fx[i] = st_ivas->hTcBuffer->tc_fx[( i + nchan_ism )] + prod; /*Q11*/ } +#ifdef FIX_1372_OSBA_OBJECT_EDITING + IF( EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) +#else test(); test(); IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) && EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) && EQ_32( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) +#endif { FOR( i = 0; i < nchan_ism; i++ ) { diff --git a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c index 3f0c938cea795a5866ca2ec5f2b179cead2d9469..a38f024d0a3577f7474ec3bf88cf18d24eacf418 100644 --- a/lib_rend/ivas_dirac_dec_binaural_functions_fx.c +++ b/lib_rend/ivas_dirac_dec_binaural_functions_fx.c @@ -51,20 +51,9 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; * Local constants *------------------------------------------------------------------------*/ -#define CLDFB_HALF_BIN_FREQUENCY_OFFSET 0.5f -#define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN ( 2.0f ) -#define IVAS_TDET_DUCK_MULT_FAC_PARA_BIN_LOW_BR ( 3.0f ) -#define SBA_CARDI_TARGET_ENERGY_GAIN 0.5f - -#define STEREO_PREPROCESS_IIR_FACTOR ( 0.9f ) -#define STEREO_PREPROCESS_IIR_FACTOR_Q15 ( 29491 ) +#define STEREO_PREPROCESS_IIR_FACTOR_Q15 ( 29491 ) // 0.9f in Q15 /* powf(0.95f, 4.0f) for sub-frame smoothing instead of CLDFB slot */ -#define ADAPT_HTPROTO_IIR_FAC 0.81450625f - -#define ADAPT_HTPROTO_ILD_LIM_DB0 1.0f -#define ADAPT_HTPROTO_ILD_LIM_DB1 4.0f -#define ADAPT_HTPROTO_ROT_LIM_0 0.4f -#define ADAPT_HTPROTO_ROT_LIM_0_FX 429496736 // Q30 +#define ADAPT_HTPROTO_ROT_LIM_0_FX 429496736 // 0.4f in Q30 #define TWO_POINT_FIVE_IN_Q13 20480 // Q13 #define ADAPT_HTPROTO_IIR_FAC_FX 26689 // Q15 #define LOG_10_BASE_2_Q29 1783446528 // Q29 @@ -74,7 +63,6 @@ Word16 slot_fx[4] = { 32767, 16384, 10922, 8192 }; #define EPSILON_EXP ( -39 ) #define ONE_DIV_EPSILON_MANT 1953125000 /* 1e+12 = 0.9094947*(2^40) */ #define ONE_DIV_EPSILON_EXP ( 40 ) -#define ADAPT_HTPROTO_ROT_LIM_1 0.8f #define SMALL_EIGENVALUE 50 @@ -106,11 +94,11 @@ typedef struct parambin_rend_config_data * Local function prototypes *------------------------------------------------------------------------*/ -static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_f[] /*Q11*/, const Word16 nchan_transport, const Word16 subframe ); +static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, Word32 *output_fx[] /*Q11*/, const Word16 nchan_transport, const Word16 subframe ); -static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const Word16 num_freq_bands, const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME] /*q_inp*/[CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX], Word32 decIm[][CLDFB_NO_CHANNELS_MAX], Word16 *q_out ); +static void ivas_dirac_dec_decorrelate_slot_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const Word16 num_freq_bands, const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME] /*q_inp*/[CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX] /*q_inp*/, const Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX], Word32 decIm[][CLDFB_NO_CHANNELS_MAX], Word16 *q_out ); -static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, Word16 q ); +static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], const Word16 subframe, Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter, const Word16 q ); static void ivas_dirac_dec_binaural_formulate_target_covariance_matrices_fx( DIRAC_DEC_BIN_HANDLE hDiracDecBin, const SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, const PARAMBIN_REND_CONFIG_HANDLE hConfig, Word32 Rmat[3][3], const Word16 subframe, const Word16 isHeadtracked, const Word32 *subFrameTotalEne, Word16 *subFrameTotalEne_e, const Word32 *IIReneLimiter, const MASA_ISM_DATA_HANDLE hMasaIsmData ); @@ -157,11 +145,11 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( Word16 tmp_e; Word16 tmp2; ivas_error error; - Word16 num_poses, pos_idx; const IVAS_ROOM_ACOUSTICS_CONFIG_DATA *pRoomAcoustics; num_poses = 1; + move16(); IF( st_ivas->hSplitBinRend != NULL ) { num_poses = st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses; @@ -393,8 +381,22 @@ ivas_error ivas_dirac_dec_init_binaural_data_fx( Word16 nchan_to_allocate; Word16 n_samples_granularity; +#ifdef FIX_NCHAN_BUFFERS + nchan_to_allocate = BINAURAL_CHANNELS; + move16(); + IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + nchan_to_allocate = 2 * BINAURAL_CHANNELS; + move16(); + } + ELSE IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + nchan_to_allocate = add( nchan_to_allocate, 1 ); + } +#else nchan_to_allocate = 2 * BINAURAL_CHANNELS; move16(); +#endif if ( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { nchan_to_allocate = add( BINAURAL_CHANNELS, st_ivas->nchan_ism ); @@ -527,23 +529,29 @@ void ivas_dirac_dec_binaural_render_fx( UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_f[] /* o : rendered time signal, Q11 */ + Word32 *output_fx[] /* o : rendered time signal, Q11 */ ) { - Word16 slots_to_render, first_sf, last_sf, subframe_idx; + Word16 slots_to_render, first_sf, last_sf, subframe_idx, n_samples_sf; UWord16 slot_size, ch; UWord16 nchan_out; SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom; Word32 *output_fx_local[MAX_OUTPUT_CHANNELS]; +#ifndef FIX_RENDERER_STACK Word32 output_fx_local_buff[MAX_OUTPUT_CHANNELS][L_FRAME48k]; Word16 output_length; +#endif hSpatParamRendCom = st_ivas->hSpatParamRendCom; nchan_out = BINAURAL_CHANNELS; move16(); FOR( ch = 0; ch < nchan_out; ch++ ) { +#ifdef FIX_RENDERER_STACK + output_fx_local[ch] = output_fx[ch]; +#else output_fx_local[ch] = output_fx_local_buff[ch]; +#endif } slot_size = NS2SA_FX2( st_ivas->hDecoderConfig->output_Fs, CLDFB_SLOT_NS ); @@ -562,11 +570,14 @@ void ivas_dirac_dec_binaural_render_fx( last_sf = add( last_sf, 1 ); } +#ifndef FIX_RENDERER_STACK output_length = 0; move16(); +#endif FOR( subframe_idx = first_sf; subframe_idx < last_sf; subframe_idx++ ) { - Word16 n_samples_sf = imult1616( slot_size, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + n_samples_sf = imult1616( slot_size, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); + ivas_dirac_dec_binaural_internal_fx( st_ivas, st_ivas->hCombinedOrientationData, output_fx_local, nchan_transport, subframe_idx ); FOR( ch = 0; ch < nchan_out; ch++ ) @@ -574,17 +585,19 @@ void ivas_dirac_dec_binaural_render_fx( output_fx_local[ch] += n_samples_sf; } +#ifndef FIX_RENDERER_STACK output_length = add( output_length, n_samples_sf ); - +#endif /* update combined orientation access index */ ivas_combined_orientation_update_index( st_ivas->hCombinedOrientationData, n_samples_sf ); } +#ifndef FIX_RENDERER_STACK FOR( ch = 0; ch < nchan_out; ch++ ) { - Copy32( output_fx_local_buff[ch], output_f[ch], output_length ); + Copy32( output_fx_local_buff[ch], output_fx[ch], output_length ); } - +#endif IF( EQ_16( hSpatParamRendCom->slots_rendered, hSpatParamRendCom->num_slots ) ) { hSpatParamRendCom->dirac_read_idx = add( hSpatParamRendCom->dirac_read_idx, DEFAULT_JBM_SUBFRAMES_5MS ) % hSpatParamRendCom->dirac_md_buffer_length; @@ -597,11 +610,13 @@ void ivas_dirac_dec_binaural_render_fx( return; } + /*------------------------------------------------------------------------- * ivas_dirac_dec_binaural_sba_gain() * * loudness correction for parametric binaural renderer *------------------------------------------------------------------------*/ + void ivas_dirac_dec_binaural_sba_gain_fx( Word32 *output[], /* i/o: synthesized core-coder transport channels/DirAC output, inp Qx, out Qx-1 */ const Word16 nchan_remapped, /* i : num channels after remapping of TCs */ @@ -634,6 +649,7 @@ void ivas_dirac_dec_binaural_sba_gain_fx( /*------------------------------------------------------------------------- * Local functions *------------------------------------------------------------------------*/ + static void ivas_dirac_dec_binaural_internal_fx( Decoder_Struct *st_ivas, COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, @@ -641,7 +657,7 @@ static void ivas_dirac_dec_binaural_internal_fx( const Word16 nchan_transport, const Word16 subframe ) { - Word16 q_input = 11; + Word16 q_input = Q11; move16(); IF( st_ivas->hSCE[0] ) { @@ -784,6 +800,7 @@ static void ivas_dirac_dec_binaural_internal_fx( set32_fx( Cldfb_ImagBuffer_in_fx[i][j], 0, 60 ); } } + /* CLDFB Analysis of input */ FOR( slot = 0; slot < hSpatParamRendCom->subframe_nbslots[subframe]; slot++ ) { @@ -969,7 +986,6 @@ static void ivas_dirac_dec_binaural_internal_fx( ivas_omasa_preProcessStereoTransportsForEditedObjects_fx( st_ivas, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, &q_inp, nBins, subframe ); } - IF( hCombinedOrientationData ) { FOR( i = 0; i < 3; i++ ) @@ -1085,6 +1101,7 @@ static void ivas_dirac_dec_binaural_internal_fx( move32(); } + test(); IF( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { ivas_dirac_dec_binaural_process_output_fx( hDiracDecBin, hSpatParamRendCom, st_ivas->cldfbSynDec, output_fx, &q_out, Cldfb_RealBuffer_in_fx, Cldfb_ImagBuffer_in_fx, q_inp, max_band_decorr, numInChannels, config_data.processReverb, subframe, q_mat, @@ -1106,14 +1123,14 @@ static void ivas_dirac_dec_binaural_internal_fx( } hDiracDecBin->hDiffuseDist = NULL; - - if ( pMultiBinPoseData != NULL && pMultiBinPoseData->num_poses > 1 ) + test(); + IF( pMultiBinPoseData != NULL && GT_16( pMultiBinPoseData->num_poses, 1 ) ) { /* quaternion-based rotation from ivas_binRenderer_internal.c:ivas_binRenderer(), but using absolute rotation instead of delta rotations */ IVAS_QUATERNION Quaternions_rot, Quaternions_abs, *Quaternions_ref; Word32 Rmat_local[3][3]; - if ( hCombinedOrientationData ) + IF( hCombinedOrientationData ) { Quaternions_ref = &hCombinedOrientationData->Quaternions[0]; Copy_Quat_fx( Quaternions_ref, &Quaternions_abs ); @@ -1137,7 +1154,8 @@ static void ivas_dirac_dec_binaural_internal_fx( hDiracDecBin = st_ivas->hDiracDecBin[pos_idx]; assert( hDiracDecBin != NULL && "No DiracDecBin handle for this position" ); - if ( config_data.ivas_format == SBA_FORMAT || config_data.ivas_format == SBA_ISM_FORMAT ) + test(); + IF( EQ_32( config_data.ivas_format, SBA_FORMAT ) || EQ_32( config_data.ivas_format, SBA_ISM_FORMAT ) ) { hDiracDecBin->hDiffuseDist = &diffuseDistData; } @@ -1161,7 +1179,6 @@ static void ivas_dirac_dec_binaural_internal_fx( hCombinedOrientationData && hCombinedOrientationData->enableCombinedOrientation[subframe] > 0, nchanSeparateChannels, st_ivas->hMasaIsmData ); - q_mat = hDiracDecBin->q_processMtx; move16(); q_mat = s_min( q_mat, hDiracDecBin->q_processMtxPrev ); @@ -1242,7 +1259,7 @@ static void ivas_dirac_dec_decorrelate_slot_fx( const Word16 slot, Word32 inRe[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ Word32 inIm[][CLDFB_SLOTS_PER_SUBFRAME][CLDFB_NO_CHANNELS_MAX], /*q_inp*/ - Word16 q_inp, + const Word16 q_inp, Word32 decRe[][CLDFB_NO_CHANNELS_MAX], Word32 decIm[][CLDFB_NO_CHANNELS_MAX], Word16 *q_out ) @@ -1314,7 +1331,7 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( Word32 *subFrameTotalEne_fx, Word16 *subFrameTotalEne_e, Word32 *IIReneLimiter_fx, - Word16 q ) + const Word16 q ) { Word16 ch, slot, bin; Word16 nBins; @@ -1342,11 +1359,9 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( nBins = hSpatParamRendCom->num_freq_bands; /* Actually bins */ move16(); - set32_fx( hDiracDecBin->ChCrossRe_fx, 0, nBins ); set32_fx( hDiracDecBin->ChCrossIm_fx, 0, nBins ); - set16_fx( hDiracDecBin->ChCrossRe_e, 0, nBins ); set16_fx( hDiracDecBin->ChCrossIm_e, 0, nBins ); @@ -1481,7 +1496,6 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( } } - test(); /* Temporal IIR-type smoothing of covariance matrices. Also apply encoding quality based smoothing factor. */ IF( EQ_32( ivas_format, MASA_FORMAT ) && LT_32( ivas_total_brate, MASA_STEREO_MIN_BITRATE ) ) @@ -1495,7 +1509,6 @@ static void ivas_dirac_dec_binaural_formulate_input_covariance_matrices_fx( FOR( bin = 0; bin < nBins; bin++ ) { - /* Temporally smooth cov mtx estimates for resulting mixing matrix stability. The design principle is that * the energy history (IIR) must not be more than double of the current frame energy. This provides more * robust performance at energy offsets when compared to typical IIR averaging. */ @@ -2458,7 +2471,6 @@ static void ivas_dirac_dec_binaural_determine_processing_matrices_fx( q_gain = sub( 31, add( exp2, exp1 ) ); } - // 1073741824 = 4 in Q28 IF( LT_16( q_gain, Q28 ) ) { @@ -6795,7 +6807,7 @@ static void ivas_masa_ext_rend_parambin_internal_fx( void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ const Word16 num_subframes, /* i : number of subframes to render */ const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ @@ -6811,7 +6823,7 @@ void ivas_masa_ext_rend_parambin_render_fx( FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { - p_output[ch] = output_f[ch]; + p_output[ch] = output_fx[ch]; } hSpatParamRendCom->subframes_rendered = hSpatParamRendCom->dirac_read_idx; diff --git a/lib_rend/ivas_dirac_rend_fx.c b/lib_rend/ivas_dirac_rend_fx.c index 97b5ae51ea82e1cb63ac61cf491b04074424da0a..bde35181ee7c12d7d3da54a92c1be9e4cb051725 100644 --- a/lib_rend/ivas_dirac_rend_fx.c +++ b/lib_rend/ivas_dirac_rend_fx.c @@ -3569,7 +3569,7 @@ void rotateAziEle_DirAC_fx( /* A reduced rewrite of the corresponding decoder side function */ static void ivas_masa_ext_dirac_render_sf_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: IVAS decoder structure */ - Word32 *output_f_fx[] /* i/o: synthesized core-coder transport channels/DirAC output q11*/ + Word32 *output_fx[] /* i/o: synthesized core-coder transport channels/DirAC output q11*/ ) { Word16 i, ch, idx_in, idx_lfe; @@ -3783,7 +3783,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( move16(); hMasaExtRend->cldfbAnaRend[ch]->Q_cldfb_state = q_cldfb; move16(); - cldfbAnalysis_ts_fx_fixed_q( &( output_f_fx[ch][hSpatParamRendCom->num_freq_bands * index_slot] ), + cldfbAnalysis_ts_fx_fixed_q( &( output_fx[ch][hSpatParamRendCom->num_freq_bands * index_slot] ), Cldfb_RealBuffer_fx[ch][0], Cldfb_ImagBuffer_fx[ch][0], hSpatParamRendCom->num_freq_bands, @@ -4402,7 +4402,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( IF( hDirACRend->hOutSetup.num_lfe > 0 && ( EQ_16( hDirACRend->hOutSetup.index_lfe[idx_lfe], ch ) ) ) { /* No LFE for MASA rendering */ - set32_fx( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); + set32_fx( &( output_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), 0, imult1616( hSpatParamRendCom->subframe_nbslots[subframe_idx], hSpatParamRendCom->num_freq_bands ) ); IF( LT_16( idx_lfe, sub( hDirACRend->hOutSetup.num_lfe, 1 ) ) ) { @@ -4435,8 +4435,8 @@ static void ivas_masa_ext_dirac_render_sf_fx( ImagBuffer_fx[i] = Cldfb_ImagBuffer_fx[idx_in][i]; // q_cldfb } Word16 out_size = imult1616( hSpatParamRendCom->num_freq_bands, hSpatParamRendCom->subframe_nbslots[subframe_idx] ); - cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, 0, hMasaExtRend->cldfbSynRend[idx_in] ); - scale_sig32( &( output_f_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 + cldfbSynthesis_ivas_fx( RealBuffer_fx, ImagBuffer_fx, &( output_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, 0, 0, hMasaExtRend->cldfbSynRend[idx_in] ); + scale_sig32( &( output_fx[ch][index_slot * hSpatParamRendCom->num_freq_bands] ), out_size, sub( 11, q_out ) ); // q11 idx_in++; } } @@ -4453,7 +4453,7 @@ static void ivas_masa_ext_dirac_render_sf_fx( void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - Word32 *output_f[], /* i/o: input/output signals in time domain q11*/ + Word32 *output_fx[], /* i/o: input/output signals in time domain q11*/ const Word16 num_subframes /* i : number of subframes to render */ ) { @@ -4468,7 +4468,7 @@ void ivas_masa_ext_dirac_render_fx( FOR( n = 0; n < MAX_OUTPUT_CHANNELS; n++ ) { - output_f_local[n] = output_f[n]; // q11 + output_f_local[n] = output_fx[n]; // q11 } hSpatParamRendCom->subframes_rendered = hSpatParamRendCom->dirac_read_idx; diff --git a/lib_rend/ivas_output_init_fx.c b/lib_rend/ivas_output_init_fx.c index f67a9293a1adaa833fde29178b35a1dc97f12b15..0e2b264a83e9e1f4ded222a90137b981a9f83295 100644 --- a/lib_rend/ivas_output_init_fx.c +++ b/lib_rend/ivas_output_init_fx.c @@ -318,7 +318,11 @@ Word16 ivas_get_nchan_buffers_dec_fx( output_config = st_ivas->hDecoderConfig->output_config; move16(); +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = st_ivas->nchan_transport; +#else nchan_out_buff = MAX_OUTPUT_CHANNELS; +#endif move16(); IF( EQ_32( st_ivas->ivas_format, MONO_FORMAT ) ) @@ -332,6 +336,15 @@ Word16 ivas_get_nchan_buffers_dec_fx( } ELSE IF( EQ_32( st_ivas->ivas_format, ISM_FORMAT ) ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_ism ); + + test(); + IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + { + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + } +#else nchan_out_buff = st_ivas->nchan_ism; move16(); @@ -344,9 +357,16 @@ Word16 ivas_get_nchan_buffers_dec_fx( nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_FORMAT ) ) { +#ifdef FIX_NCHAN_BUFFERS + Word16 nchan_internal; + nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); + + nchan_out_buff = s_max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); +#else Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; @@ -362,9 +382,20 @@ Word16 ivas_get_nchan_buffers_dec_fx( nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } nchan_out_buff = s_max( nchan_out_buff, nchan_internal ); +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_FORMAT ) ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); + + test(); + IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + nchan_out_buff = 2 * BINAURAL_CHANNELS; + move16(); + } +#else nchan_out_buff = CPE_CHANNELS; move16(); @@ -393,9 +424,13 @@ Word16 ivas_get_nchan_buffers_dec_fx( { nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MASA_ISM_FORMAT ) ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = s_max( st_ivas->hDecoderConfig->nchan_out, add( st_ivas->nchan_transport, st_ivas->nchan_ism ) ); +#else nchan_out_buff = add( st_ivas->nchan_ism, CPE_CHANNELS ); test(); @@ -413,9 +448,32 @@ Word16 ivas_get_nchan_buffers_dec_fx( nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) ) { +#ifdef FIX_NCHAN_BUFFERS + Word16 nchan_internal; + + nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); + + if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC ) + { + nchan_internal = add( nchan_internal, st_ivas->nchan_ism ); + } + + if ( st_ivas->hMCT != NULL ) + { + nchan_internal = shl( shr( add( nchan_internal, 1 ), 1 ), 1 ); /* ensure odd number of channels in MCT */ + } + + nchan_out_buff = s_max( nchan_internal, st_ivas->hDecoderConfig->nchan_out ); + + if ( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) ) + { + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + } +#else Word16 nchan_internal; nchan_internal = ivas_sba_get_nchan_metadata_fx( sba_analysis_order, ivas_total_brate ); nchan_out_buff = add( st_ivas->nchan_ism, st_ivas->nchan_transport ); @@ -455,9 +513,28 @@ Word16 ivas_get_nchan_buffers_dec_fx( nchan_out_buff = s_max( nchan_out_buff, add( nchan_internal, st_ivas->nchan_ism ) ); } nchan_out_buff = s_min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS ); +#endif } ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) ) { +#ifdef FIX_NCHAN_BUFFERS + nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, st_ivas->nchan_transport ); + + IF( st_ivas->hOutSetup.separateChannelEnabled ) + { + nchan_out_buff = s_max( nchan_out_buff, add( st_ivas->nchan_transport, 1 ) ); + } + + IF( st_ivas->hDiracDecBin[0] != NULL && st_ivas->hDiracDecBin[0]->useTdDecorr ) + { + nchan_out_buff = 2 * BINAURAL_CHANNELS; + move16(); + } + ELSE + { + nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) ); + } +#else nchan_out_buff = st_ivas->hDecoderConfig->nchan_out; IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_LS_CUSTOM ) ) @@ -469,8 +546,10 @@ Word16 ivas_get_nchan_buffers_dec_fx( nchan_out_buff = s_max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) ); nchan_out_buff = s_max( nchan_out_buff, audioCfg2channels( output_config ) ); } +#endif } + test(); IF( EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS ); @@ -487,7 +566,7 @@ Word16 ivas_get_nchan_buffers_dec_fx( *-------------------------------------------------------------------*/ ivas_error ivas_output_buff_dec_fx( - Word32 *p_output_f[], /* i/o: output audio buffers */ + Word32 *p_output_fx[], /* i/o: output audio buffers */ const Word16 nchan_out_buff_old, /* i : previous frame number of output channels */ const Word16 nchan_out_buff /* i : number of output channels */ ) @@ -498,8 +577,16 @@ ivas_error ivas_output_buff_dec_fx( { FOR( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ ) { +#ifdef FIX_NCHAN_BUFFERS +#ifdef DEBUGGING + if ( p_output_fx[ch] != NULL ) + { + return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Memory for floating-point output audio buffer is already allocated!\n" ) ); + } +#endif +#endif /* note: these are intra-frame heap memories */ - IF( ( p_output_f[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */ + IF( ( p_output_fx[ch] = (Word32 *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( Word32 ) ) ) == NULL ) { return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for output audio buffer!\n" ) ); } @@ -509,8 +596,8 @@ ivas_error ivas_output_buff_dec_fx( { FOR( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ ) { - free( p_output_f[ch] ); - p_output_f[ch] = NULL; + free( p_output_fx[ch] ); + p_output_fx[ch] = NULL; } } diff --git a/lib_rend/ivas_prot_rend_fx.h b/lib_rend/ivas_prot_rend_fx.h index 4ac1041244e6969b1d3072e5b75eaf4a69bf8b0a..250fea7515e5222ce88904254b9b70510c34341d 100644 --- a/lib_rend/ivas_prot_rend_fx.h +++ b/lib_rend/ivas_prot_rend_fx.h @@ -208,13 +208,13 @@ void ivas_dirac_dec_binaural_render_fx( UWord16 *nSamplesRendered, /* o : number of CLDFB slots rendered */ UWord16 *nSamplesAvailable, /* o : number of CLDFB slots still to render */ const Word16 nchan_transport, /* i : number of transport channels */ - Word32 *output_f[] /* o : rendered time signal, Q11 */ + Word32 *output_fx[] /* o : rendered time signal, Q11 */ ); void ivas_masa_ext_rend_parambin_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA ext rend structure */ COMBINED_ORIENTATION_HANDLE hCombinedOrientationData, /* i : combined orientation handle */ - Word32 *output_f[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ + Word32 *output_fx[], /* i/o: synthesized core-coder transport channels/DirAC output Q11*/ const Word16 num_subframes, /* i : number of subframes to render */ const SPLIT_REND_WRAPPER *hSplitRendWrapper, /* i : split rendering orientation data */ Word32 Cldfb_Out_Real[][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX], /* o : rendered orientations for split rend. real part of cldfb */ @@ -570,7 +570,7 @@ void ivas_dirac_deallocate_parameters_fx( void ivas_masa_ext_dirac_render_fx( MASA_EXT_REND_HANDLE hMasaExtRend, /* i/o: MASA renderer structure */ - Word32 *output_f[], /* i/o: input/output signals in time domain q11 */ + Word32 *output_fx[], /* i/o: input/output signals in time domain q11 */ const Word16 num_subframes /* i : number of subframes to render */ );