From 6dff75d498df26da7683a7bdad4a44037399fdc5 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 15:41:14 +0200 Subject: [PATCH 1/5] fix --- lib_dec/ivas_jbm_dec_fx.c | 9 +++++++-- lib_dec/lib_dec_fx.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index 445470177..ec6c3a40b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -1678,7 +1678,7 @@ void ivas_jbm_dec_feed_tc_to_renderer_fx( #ifdef FIX_NCHAN_BUFFERS #ifdef JBM_MEMORY_OPT - ch = max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); + ch = s_max( hTcBuffer->nchan_transport_jbm, hTcBuffer->nchan_buffer_full ); #else ch = ivas_get_nchan_buffers_dec_fx( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ); #endif @@ -3962,7 +3962,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( ivas_jbm_dec_tc_audio_deallocate_fx( hTcBuffer ); - if ( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) + IF( ( error = ivas_jbm_dec_tc_audio_allocate_fx( hTcBuffer, st_ivas->hDecoderConfig->output_Fs, st_ivas->hDecoderConfig->Opt_tsm ) ) != IVAS_ERR_OK ) { return error; } @@ -4101,6 +4101,10 @@ void ivas_jbm_dec_tc_buffer_close_fx( IF( *phTcBuffer != NULL ) { +#ifdef JBM_MEMORY_OPT + ivas_jbm_dec_tc_audio_deallocate_fx( *phTcBuffer ); +#else + FOR( i = 0; i < MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { ( *phTcBuffer )->tc_fx[i] = NULL; @@ -4111,6 +4115,7 @@ void ivas_jbm_dec_tc_buffer_close_fx( free( ( *phTcBuffer )->tc_buffer_fx ); ( *phTcBuffer )->tc_buffer_fx = NULL; } +#endif free( *phTcBuffer ); *phTcBuffer = NULL; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 860bcdc94..26fe582b4 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3844,7 +3844,7 @@ ivas_error IVAS_DEC_ReadFormat( #ifdef JBM_MEMORY_OPT /*---------------------------------------------------------------------* - * IVAS_DEC_GetEditableParameters( ) + * apa_exec_evs_wrapper( ) * * *---------------------------------------------------------------------*/ @@ -3858,6 +3858,13 @@ static ivas_error apa_exec_evs_wrapper( Word16 tmp_apaExecBuffer[APA_BUF / APA_MAX_NUM_CHANNELS * 2]; /* in EVS, 2 output channels */ DECODER_TC_BUFFER_HANDLE hTcBuffer; + test(); + test(); + IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL || hIvasDec->st_ivas->hTcBuffer == NULL ) + { + return IVAS_ERR_UNEXPECTED_NULL_POINTER; + } + hTcBuffer = hIvasDec->st_ivas->hTcBuffer; FOR( ch = 0; ch < APA_BUF_PER_CHANNEL * nTransportChannels; ++ch ) @@ -3900,6 +3907,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( bool isInitialized_voip; #endif + test(); IF( hIvasDec == NULL || hIvasDec->st_ivas == NULL ) { return IVAS_ERR_UNEXPECTED_NULL_POINTER; @@ -3916,6 +3924,7 @@ ivas_error IVAS_DEC_GetSamplesDecoder( st_ivas = hIvasDec->st_ivas; #ifdef LIB_DEC_REVISION #ifdef JBM_MEMORY_OPT + test(); isInitialized_voip = hIvasDec->hTimeScaler != NULL; #else isInitialized_voip = hIvasDec->apaExecBuffer_fx != NULL; @@ -4027,7 +4036,6 @@ ivas_error IVAS_DEC_GetSamplesDecoder( #endif #endif - // tmp apaExecBuffer IF( EQ_16( (Word16) hIvasDec->mode, IVAS_DEC_MODE_EVS ) ) { #ifdef JBM_MEMORY_OPT -- GitLab From af60cbefbd472f4f05c7c5033ecd8238f28fde50 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 17:45:29 +0200 Subject: [PATCH 2/5] fix --- lib_dec/ivas_jbm_dec_fx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ec6c3a40b..de4de837b 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -4097,8 +4097,9 @@ void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ) { +#ifndef JBM_MEMORY_OPT Word16 i; - +#endif IF( *phTcBuffer != NULL ) { #ifdef JBM_MEMORY_OPT -- GitLab From 4765e6c6f2f5934c0cd9dc542c1bf95874f538bd Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 19:01:13 +0200 Subject: [PATCH 3/5] fix apa_exec_ivas_fx() --- lib_com/ivas_prot_fx.h | 216 ++++++++++++++++++------------------ lib_dec/ivas_init_dec_fx.c | 4 +- lib_dec/jbm_pcmdsp_apa_fx.c | 16 +++ 3 files changed, 127 insertions(+), 109 deletions(-) diff --git a/lib_com/ivas_prot_fx.h b/lib_com/ivas_prot_fx.h index 8ced4f1f2..19e2c6b97 100644 --- a/lib_com/ivas_prot_fx.h +++ b/lib_com/ivas_prot_fx.h @@ -204,19 +204,6 @@ Word32 calculate_cpe_brate_MASA_ISM_fx( const Word16 nchan_ism /* i : number of objects */ ); -Word16 ivas_jbm_dec_get_num_tc_channels_fx( - Decoder_Struct *st_ivas /* i : IVAS decoder handle */ -); - -ivas_error ivas_jbm_dec_tc_buffer_open_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ - const Word16 nchan_transport_jbm, /* i : number of real transport channels */ - const Word16 nchan_transport_internal, /* i : number of totally buffered channels */ - const Word16 nchan_full, /* i : number of channels to fully store */ - const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ -); - void ivas_dct_windowing_fx( const Word16 fade_len, /*Q0*/ const Word16 full_len, /*Q0*/ @@ -947,15 +934,6 @@ void update_last_metadata_fx( const Word16 updt_flag[] /* i : last metadata update flag */ ); -ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ - const Word16 nchan_transport_jbm, /* i : new number of real transport channels */ - const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ - const Word16 nchan_full, /* i : new number of channels to fully store */ - const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ -); - ivas_error ivas_dirac_allocate_parameters_fx( SPAT_PARAM_REND_COMMON_DATA_HANDLE hSpatParamRendCom, /* i/o: common data for spatial parametric rendering*/ const Word16 params_flag /* i : set of parameters flag */ @@ -999,21 +977,6 @@ Word16 IGF_MapBitRateToIndex( const Word16 rf_mode /* i : flag to signal the RF mode */ ); -#ifdef NONBE_1303_REND_GRANULARITY -Word16 ivas_jbm_dec_get_render_granularity_fx( - const RENDERER_TYPE renderer_type, /* i : renderer type */ - const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ - const int32_t output_Fs /* i : sampling rate */ -); -#else -Word16 ivas_jbm_dec_get_render_granularity( - const RENDERER_TYPE rendererType, /* i : renderer type */ - const IVAS_FORMAT ivas_format, /* i : ivas format */ - const MC_MODE mc_mode, /* i : MC mode */ - const Word32 output_Fs /* i : sampling rate */ -); -#endif - void stereo_dft_config_fx( STEREO_DFT_CONFIG_DATA_HANDLE hConfig, /* o : DFT stereo configuration */ const Word32 brate, /* i : IVAS/CPE/nominal total bitrate */ @@ -1095,12 +1058,6 @@ void ivas_ism_render_sf_fx( const Word16 n_samples_to_render /* i : output frame length per channel */ ); -void ivas_jbm_dec_get_adapted_linear_interpolator_fx( - const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ - const Word16 interp_length, /* i : length of the interpolator to be created */ - Word16 *interpolator_fx /* o : the interpolator */ -); - void ivas_omasa_separate_object_render_jbm_fx( Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ const UWord16 nSamplesRendered, /* i : number of samples rendered */ @@ -2576,14 +2533,6 @@ void ivas_omasa_dirac_rend_jbm_fx( Word32 *output_fx[] /* o : rendered time signal */ ); -ivas_error ivas_jbm_dec_render_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const UWord16 nSamplesAsked, /* i : number of samples wanted */ - UWord16 *nSamplesRendered, /* o : number of samples rendered */ - UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ - Word16 *data /* o : output synthesis signal */ -); - void ivas_sba_zero_vert_comp_fx( Word32 *sba_data[], /* i : SBA signals */ const Word16 sba_order, /* i : SBA order */ @@ -4228,63 +4177,6 @@ Word64 var_32_fx( Word16 q /* q : q-factor for the array */ ); -ivas_error ivas_jbm_dec_tc_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -#ifndef LIB_DEC_REVISION - , - Word32 *data_fx -#endif -); - -ivas_error ivas_jbm_dec_flush_renderer_fx( - Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ - const Word16 tc_granularity_new, /* i : new renderer granularity */ - const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ - const AUDIO_CONFIG intern_config_old, /* i : old internal config */ - const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ - const MC_MODE mc_mode_old, /* i : old MC mode */ - const ISM_MODE ism_mode_old, /* i : old ISM mode */ - UWord16 *nSamplesRendered, /* o : number of samples flushed */ - Word16 *data /* o : 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*/ - #ifndef JBM_MEMORY_OPT - , - Word32 *data_fx /* i/o: transport channels/output synthesis signal */ -#endif -); - -void ivas_dec_prepare_renderer_fx( - Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ -); - -void ivas_jbm_dec_get_adapted_subframes( - const Word16 nCldfbTs, /* i : number of time slots in the current frame */ - Word16 *subframe_nbslots, /* i/o: subframe grid */ - Word16 *nb_subframes /* i/o: number of subframes in the frame */ -); - -void ivas_jbm_dec_get_md_map( - const Word16 default_len, /* i : default frame length in metadata slots */ - const Word16 len, /* i : length of the modfied frames in metadata slots */ - const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the md buffer */ - const Word16 buf_len, /* i : length of the metadata buffer */ - Word16 *map /* o : metadata index map */ -); - -void ivas_jbm_dec_get_md_map_even_spacing( - const Word16 len, /* i : length of the modfied frames in metadata slots */ - const Word16 subframe_len, /* i : default length of a subframe */ - const Word16 offset, /* i : current read offset into the md buffer */ - const Word16 buf_len, /* i : length of the metadata buffer */ - Word16 *map /* o : metadata index map */ -); - void bitbudget_to_brate( const Word16 x[], /* i : bitbudgets */ Word32 y[], /* o : bitrates */ @@ -6273,14 +6165,122 @@ Word16 is_DTXrate( * JBM prototypes *----------------------------------------------------------------------------------*/ +ivas_error ivas_jbm_dec_tc_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +#ifndef LIB_DEC_REVISION + , + Word32 *data_fx +#endif +); + +ivas_error ivas_jbm_dec_render_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const UWord16 nSamplesAsked, /* i : number of samples wanted */ + UWord16 *nSamplesRendered, /* o : number of samples rendered */ + UWord16 *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */ + Word16 *data /* o : output synthesis signal */ +); + +ivas_error ivas_jbm_dec_flush_renderer_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const Word16 tc_granularity_new, /* i : new renderer granularity */ + const RENDERER_TYPE renderer_type_old, /* i : old renderer type */ + const AUDIO_CONFIG intern_config_old, /* i : old internal config */ + const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */ + const MC_MODE mc_mode_old, /* i : old MC mode */ + const ISM_MODE ism_mode_old, /* i : old ISM mode */ + UWord16 *nSamplesRendered, /* o : number of samples flushed */ + Word16 *data /* o : 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*/ +#ifndef JBM_MEMORY_OPT + , + Word32 *data_fx /* i/o: transport channels/output synthesis signal */ +#endif +); + +void ivas_dec_prepare_renderer_fx( + Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ +); + ivas_error ivas_jbm_dec_set_discard_samples_fx( Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */ ); +void ivas_jbm_dec_get_adapted_linear_interpolator_fx( + const Word16 default_interp_length, /* i : default length of the (full-frame) interpolator */ + const Word16 interp_length, /* i : length of the interpolator to be created */ + Word16 *interpolator_fx /* o : the interpolator */ +); + +void ivas_jbm_dec_get_adapted_subframes( + const Word16 nCldfbTs, /* i : number of time slots in the current frame */ + Word16 *subframe_nbslots, /* i/o: subframe grid */ + Word16 *nb_subframes /* i/o: number of subframes in the frame */ +); + +void ivas_jbm_dec_get_md_map( + const Word16 default_len, /* i : default frame length in metadata slots */ + const Word16 len, /* i : length of the modfied frames in metadata slots */ + const Word16 subframe_len, /* i : default length of a subframe */ + const Word16 offset, /* i : current read offset into the md buffer */ + const Word16 buf_len, /* i : length of the metadata buffer */ + Word16 *map /* o : metadata index map */ +); + +Word16 ivas_jbm_dec_get_num_tc_channels_fx( + Decoder_Struct *st_ivas /* i : IVAS decoder handle */ +); + +void ivas_jbm_dec_get_md_map_even_spacing( + const Word16 len, /* i : length of the modfied frames in metadata slots */ + const Word16 subframe_len, /* i : default length of a subframe */ + const Word16 offset, /* i : current read offset into the md buffer */ + const Word16 buf_len, /* i : length of the metadata buffer */ + Word16 *map /* o : metadata index map */ +); + TC_BUFFER_MODE ivas_jbm_dec_get_tc_buffer_mode_fx( Decoder_Struct *st_ivas /* i : IVAS decoder handle */ ); +#ifdef NONBE_1303_REND_GRANULARITY +Word16 ivas_jbm_dec_get_render_granularity_fx( + const RENDERER_TYPE renderer_type, /* i : renderer type */ + const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */ + const int32_t output_Fs /* i : sampling rate */ +); +#else +Word16 ivas_jbm_dec_get_render_granularity( + const RENDERER_TYPE rendererType, /* i : renderer type */ + const IVAS_FORMAT ivas_format, /* i : ivas format */ + const MC_MODE mc_mode, /* i : MC mode */ + const Word32 output_Fs /* i : sampling rate */ +); +#endif + +ivas_error ivas_jbm_dec_tc_buffer_open_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : buffer mode */ + const Word16 nchan_transport_jbm, /* i : number of real transport channels */ + const Word16 nchan_transport_internal, /* i : number of totally buffered channels */ + const Word16 nchan_full, /* i : number of channels to fully store */ + const Word16 n_samples_granularity /* i : granularity of the renderer/buffer */ +); + +ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( + Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */ + const TC_BUFFER_MODE tc_buffer_mode, /* i : new buffer mode */ + const Word16 nchan_transport_jbm, /* i : new number of real transport channels */ + const Word16 nchan_transport_internal, /* i : new number of totally buffered channels */ + const Word16 nchan_full, /* i : new number of channels to fully store */ + const Word16 n_samples_granularity /* i : new granularity of the renderer/buffer */ +); + void ivas_jbm_dec_tc_buffer_close_fx( DECODER_TC_BUFFER_HANDLE *phTcBuffer /* i/o: TC buffer handle */ ); diff --git a/lib_dec/ivas_init_dec_fx.c b/lib_dec/ivas_init_dec_fx.c index 00179537e..33ea403fe 100644 --- a/lib_dec/ivas_init_dec_fx.c +++ b/lib_dec/ivas_init_dec_fx.c @@ -3434,12 +3434,14 @@ void ivas_destroy_dec_fx( /* Limiter struct */ ivas_limiter_close_fx( &( st_ivas->hLimiter ) ); + /* Decoder configuration structure */ IF( st_ivas->hDecoderConfig != NULL ) { free( st_ivas->hDecoderConfig ); st_ivas->hDecoderConfig = NULL; } + /* JBM TC buffer structure */ ivas_jbm_dec_tc_buffer_close_fx( &st_ivas->hTcBuffer ); IF( st_ivas->hJbmMetadata != NULL ) @@ -3448,7 +3450,7 @@ void ivas_destroy_dec_fx( st_ivas->hJbmMetadata = NULL; } - /* output audio buffers */ + /* output audio buffers */ FOR( i = 0; i < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; i++ ) { IF( st_ivas->p_output_fx[i] != NULL ) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 49b1e1cc8..7abb087af 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -912,7 +912,11 @@ UWord8 apa_exec_ivas_fx( Word16 Q_a_out; Word16 Q_a_out_init_old; +#ifdef JBM_MEMORY_OPT + Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, l_in ) ), Q11 - Q16 - Q1 ); +#else Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 - Q1 ); +#endif Q_a_out_init_old = Q_a_out; /* store the possible scaling of a_in, to be re-used in the next frame */ move16(); statsResetThreshold = 1637; @@ -989,7 +993,11 @@ UWord8 apa_exec_ivas_fx( Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out IF( EQ_32( ps->scale, 100 ) ) { +#ifdef JBM_MEMORY_OPT + FOR( i = 0; i < L_mult0( ps->num_channels, ps->l_frm ); i++ ) +#else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) +#endif { a_out[i] = a_in[i]; // Q11 move32(); @@ -1001,7 +1009,11 @@ UWord8 apa_exec_ivas_fx( { Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); +#ifdef JBM_MEMORY_OPT + FOR( i = 0; i < L_mult0( ps->num_channels, ps->l_frm ); i++ ) +#else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) +#endif { a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out move16(); @@ -1051,7 +1063,11 @@ UWord8 apa_exec_ivas_fx( } } +#ifdef JBM_MEMORY_OPT + FOR( i = 0; i < L_mult0( ps->num_channels, ps->l_frm ); i++ ) +#else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) +#endif { a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 move32(); -- GitLab From e9646cab23ac184e625c29137bc804a811178674 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 19:58:44 +0200 Subject: [PATCH 4/5] fix JBM --- lib_dec/jbm_pcmdsp_apa_fx.c | 10 +++++----- lib_dec/lib_dec_fx.c | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 7abb087af..cfc4fa30a 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -691,7 +691,7 @@ UWord8 apa_exec_fx( { UWord16 i; #ifdef JBM_MEMORY_OPT - Word16 frm_in[APA_BUF / APA_MAX_NUM_CHANNELS * 2]; /* in EVS, 2 output channels */ /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ + Word16 frm_in[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ /* NOTE: this buffer could be smaller if alocated dynamically based on the actual sampling rate and number of channels */ #else Word16 frm_in[APA_BUF]; /* TODO(mcjbm): this buffer could be smaller - always allocates space for 16 channels */ #endif @@ -913,7 +913,7 @@ UWord8 apa_exec_ivas_fx( Word16 Q_a_out_init_old; #ifdef JBM_MEMORY_OPT - Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, l_in ) ), Q11 - Q16 - Q1 ); + Q_a_out = add( getScaleFactor32_copy( a_in, l_in ), Q11 - Q16 - Q1 ); #else Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 - Q1 ); #endif @@ -994,7 +994,7 @@ UWord8 apa_exec_ivas_fx( IF( EQ_32( ps->scale, 100 ) ) { #ifdef JBM_MEMORY_OPT - FOR( i = 0; i < L_mult0( ps->num_channels, ps->l_frm ); i++ ) + FOR( i = 0; i < ps->l_frm; i++ ) #else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) #endif @@ -1010,7 +1010,7 @@ UWord8 apa_exec_ivas_fx( Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); #ifdef JBM_MEMORY_OPT - FOR( i = 0; i < L_mult0( ps->num_channels, ps->l_frm ); i++ ) + FOR( i = 0; i < ps->l_frm; i++ ) #else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) #endif @@ -1064,7 +1064,7 @@ UWord8 apa_exec_ivas_fx( } #ifdef JBM_MEMORY_OPT - FOR( i = 0; i < L_mult0( ps->num_channels, ps->l_frm ); i++ ) + FOR( i = 0; i < 2 * ps->l_frm; i++ ) #else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) #endif diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 26fe582b4..9982eaff7 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3855,7 +3855,8 @@ static ivas_error apa_exec_evs_wrapper( UWord16 *nTimeScalerOutSamples ) { Word16 ch; - Word16 tmp_apaExecBuffer[APA_BUF / APA_MAX_NUM_CHANNELS * 2]; /* in EVS, 2 output channels */ + UWord16 apa_buff_len; + Word16 tmp_apaExecBuffer[CPE_CHANNELS * APA_BUF / APA_MAX_NUM_CHANNELS]; /* in EVS, 2 output channels */ DECODER_TC_BUFFER_HANDLE hTcBuffer; test(); @@ -3865,19 +3866,21 @@ static ivas_error apa_exec_evs_wrapper( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } + apa_buff_len = (UWord16) shl( mult0( hIvasDec->nSamplesFrame, nTransportChannels ), 1 ); + hTcBuffer = hIvasDec->st_ivas->hTcBuffer; - FOR( ch = 0; ch < APA_BUF_PER_CHANNEL * nTransportChannels; ++ch ) + FOR( ch = 0; ch < apa_buff_len; ++ch ) { tmp_apaExecBuffer[ch] = extract_l( L_shr( hTcBuffer->tc_buffer_fx[ch], Q11 ) ); // Q0 } - IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) imult3216( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, nTimeScalerOutSamples ) != 0 ) + IF( apa_exec_fx( hIvasDec->hTimeScaler, tmp_apaExecBuffer, (UWord16) mult0( hIvasDec->nSamplesFrame, nTransportChannels ), (UWord16) hIvasDec->tsm_max_scaling, tmp_apaExecBuffer, nTimeScalerOutSamples ) != 0 ) { return IVAS_ERR_UNKNOWN; } - FOR( ch = 0; ch < APA_BUF_PER_CHANNEL * nTransportChannels; ++ch ) + FOR( ch = 0; ch < apa_buff_len; ++ch ) { hTcBuffer->tc_buffer_fx[ch] = L_shl( tmp_apaExecBuffer[ch], Q11 ); // Q11 } @@ -5649,12 +5652,16 @@ static ivas_error evs_dec_main_fx( IF( st_ivas->hDecoderConfig->Opt_tsm ) { /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ +#ifdef JBM_MEMORY_OPT + Word32 pcm_buf_local[CPE_CHANNELS * L_FRAME48k]; +#else Word32 pcm_buf_local[L_FRAME48k]; +#endif FOR( ch = 0; ch < st_ivas->hDecoderConfig->nchan_out; ch++ ) { #ifdef JBM_MEMORY_OPT - ivas_buffer_deinterleaved_to_interleaved_fx( &p_output_fx[ch], nOutSamples, 1, pcm_buf_local ); + ivas_buffer_deinterleaved_to_interleaved_fx( &p_output_fx[ch], st_ivas->hDecoderConfig->nchan_out, nOutSamples, pcm_buf_local ); #else ivas_syn_output_f_fx( &p_output_fx[ch], nOutSamples, 1, pcm_buf_local ); #endif -- GitLab From 20e0bd7562d9f199834606acc5be8a39b8f6ad13 Mon Sep 17 00:00:00 2001 From: vaclav Date: Fri, 24 Oct 2025 15:58:36 +0200 Subject: [PATCH 5/5] comment --- lib_dec/lib_dec_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 56af40d1d..6d6eb6089 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -5669,7 +5669,7 @@ static ivas_error evs_dec_main_fx( #ifdef LIB_DEC_REVISION IF( st_ivas->hDecoderConfig->Opt_tsm ) { - /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ + /* BE workaround: in order to keep EVS bit-exact wrt. TS 26.443, convert 'float' output data to 'short' before the TSM */ // TODO: verify if it is still needed and if it works well for EVS stereo panning output #ifdef JBM_MEMORY_OPT Word32 pcm_buf_local[CPE_CHANNELS * L_FRAME48k]; #else -- GitLab