From e81514ef04e58415f2f35217665e6a57fafcab12 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Nov 2025 16:25:30 +0100 Subject: [PATCH 1/8] replace hardcoded numbers by ONE_BY_SUBFR_PER_SEC_Q15 --- apps/renderer.c | 2 +- lib_com/cnst.h | 3 --- lib_com/ivas_cnst.h | 5 +++-- lib_dec/ivas_ism_renderer_fx.c | 2 +- lib_dec/ivas_jbm_dec_fx.c | 37 ++++++++++++++++++------------- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/lib_dec_fx.c | 8 +++---- lib_rend/ivas_crend_fx.c | 2 +- lib_rend/ivas_objectRenderer_fx.c | 11 +++++---- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/lib_rend_fx.c | 21 +++++++++++++----- 11 files changed, 53 insertions(+), 42 deletions(-) diff --git a/apps/renderer.c b/apps/renderer.c index 8256f1e46..7a0f297c0 100644 --- a/apps/renderer.c +++ b/apps/renderer.c @@ -1676,7 +1676,7 @@ int main( ObjectPositionBuffer mtdBuffer; outBuffer.pq_fact = &outBuffer.q_factor; - Word16 subframe_len = (Word16) ( args.sampleRate / ( 200 ) ); // sample rate /FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES + Word16 subframe_len = (Word16) ( args.sampleRate / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); Word16 gd_bits = find_guard_bits( subframe_len ); Word16 prev_q_fact = Q11; while ( 1 ) diff --git a/lib_com/cnst.h b/lib_com/cnst.h index 8aecbedaf..29f49e154 100644 --- a/lib_com/cnst.h +++ b/lib_com/cnst.h @@ -593,12 +593,9 @@ enum *----------------------------------------------------------------------------------*/ #define FRAMES_PER_SEC 50 -#define MAX_PARAM_SPATIAL_SUB_FRAMES_PER_SEC 200 //(FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES) -#define ONE_BY_SUBFRAME_LEN_MS_Q31 (429496730) #define ONE_BY_FRAMES_PER_SEC_Q31 ( 42949673 ) #define FRAMES_PER_SEC_BY_2 (FRAMES_PER_SEC >> 1) #define INV_FRAME_PER_SEC_Q15 656 -#define INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 164 #define FRAME_SIZE_NS 20000000L #define ACELP_LOOK_NS 8750000L diff --git a/lib_com/ivas_cnst.h b/lib_com/ivas_cnst.h index b8415b7fd..be6a5eab1 100644 --- a/lib_com/ivas_cnst.h +++ b/lib_com/ivas_cnst.h @@ -204,14 +204,15 @@ typedef enum #define EDIT_GAIN_MAX_Q12 16306 /* Maximum allowed object gain edit in Q12: 3.9810719f, +12 dB */ #endif - - typedef enum { TC_BUFFER_MODE_RENDERER, TC_BUFFER_MODE_BUFFER } TC_BUFFER_MODE; +#define ONE_BY_SUBFRAME_LEN_MS_Q31 429496730 +#define ONE_BY_SUBFR_PER_SEC_Q15 164 + /*----------------------------------------------------------------------------------* * IVAS Bitrates diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index 2e2a257a1..d426acc34 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -233,7 +233,7 @@ void ivas_ism_render_sf_fx( { Word16 n_samples_in_subframe; - n_samples_in_subframe = st_ivas->hTcBuffer->n_samples_granularity * st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]; + n_samples_in_subframe = imult1616(st_ivas->hTcBuffer->n_samples_granularity , st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]); test(); IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) ) { diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index f8664b60b..ce199719a 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2856,12 +2856,12 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx( { Word16 nMaxSlotsPerSubframe, nSlotsInFirstSubframe; Word16 temp, temp_e; + /* render first frame with front zero padding and discarding those samples */ - // nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; - temp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), &temp_e ); - temp = shr( temp, sub( 15, temp_e ) ); - nMaxSlotsPerSubframe = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); - nMaxSlotsPerSubframe = shr( nMaxSlotsPerSubframe, sub( 15, temp_e ) ); // Q0 + /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ + temp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); + nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */ nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); IF( nSlotsInFirstSubframe > 0 ) { @@ -3500,7 +3500,6 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( Word16 nMaxSlotsPerSubframe; ivas_error error; Word16 tmp, tmp_e; - Word32 tmp32; /*-----------------------------------------------------------------* * prepare library opening @@ -3538,9 +3537,10 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( hTcBuffer->nb_subframes = MAX_PARAM_SPATIAL_SUBFRAMES; move16(); - tmp32 = L_mult0( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES, hTcBuffer->n_samples_granularity ); // Q0 - tmp = BASOP_Util_Divide3232_Scale( st_ivas->hDecoderConfig->output_Fs, tmp32, &tmp_e ); - nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); // Q0 + /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ + tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ hTcBuffer->num_slots = mult0( nMaxSlotsPerSubframe, MAX_PARAM_SPATIAL_SUBFRAMES ); move16(); @@ -3606,8 +3606,13 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( IF( NE_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) ) { Word16 nMaxSlotsPerSubframeNew; + Word16 tmp, tmp_e; + + /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */ + tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ - nMaxSlotsPerSubframeNew = idiv1616( divide3216( st_ivas->hDecoderConfig->output_Fs, ( ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) >> 1 ) ), n_samples_granularity ); // Q0 /* if samples were flushed, take that into account here */ test(); IF( LT_16( n_samples_granularity, hTcBuffer->n_samples_granularity ) && hTcBuffer->n_samples_flushed > 0 ) @@ -3739,17 +3744,17 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */ ) { - Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, exp, tmp1, tmp2, s1, s2; + Word16 nMaxSlotsPerSubframe, nSlotsAvailable, tmp, tmp_e, tmp1, tmp2, s1, s2; UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = extract_l( Mpy_32_32_r( st_ivas->hDecoderConfig->output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); - tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &exp ); - nMaxSlotsPerSubframe = shr( tmp, sub( 15, exp ) ); // Q0 + tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); + nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ /* nSlotsAvailable = st_ivas->hTcBuffer->n_samples_available / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &exp ); - nSlotsAvailable = shr( tmp, sub( 15, exp ) ); // Q0 + tmp = BASOP_Util_Divide1616_Scale( st_ivas->hTcBuffer->n_samples_available, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); + nSlotsAvailable = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ st_ivas->hTcBuffer->num_slots = nSlotsAvailable; move16(); diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index b41036a5d..2c87eb208 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1422,7 +1422,7 @@ static ivas_error init_lfe_synth_data_fx( /* Ring buffer for the filterbank of the LFE synthesis. * The filterbank is using moving average lowpass filter with the crossover of 120 Hz. */ /* bufferSize = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES ); */ - bufferSize = extract_l( Mpy_32_32_r( output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); + bufferSize = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); IF( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 8ac73cb85..9382216cd 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -826,7 +826,7 @@ static Word16 get_render_frame_size_samples( ) { Word16 tmp; - tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); + tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { @@ -875,7 +875,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( #ifdef FIX_1119_SPLIT_RENDERING_VOIP *render_framesize = get_render_frame_size_samples( hIvasDec->st_ivas->hDecoderConfig ); #else - tmp = (Word16) Mpy_32_16_1( hIvasDec->st_ivas->hDecoderConfig->output_Fs, INV_FR_P_S_MX_PRM_SPL_SBFR_Q15 ); + tmp = (Word16) Mpy_32_16_1( hIvasDec->st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { @@ -1230,12 +1230,12 @@ static Word16 isar_get_frame_size( ( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) { - nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); + nSamplesPerChannel = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } ELSE { - nSamplesPerChannel = extract_l( ar_div( output_Fs, FRAMES_PER_SEC ) ); + nSamplesPerChannel = (Word16) Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ); } return nSamplesPerChannel; diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 9c3379527..0995ecb00 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1862,7 +1862,7 @@ static ivas_error ivas_rend_crendConvolver_fx( } /* subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; */ - subframe_length = extract_l( Mpy_32_32_r( output_Fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); + subframe_length = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); lfe_idx_in = -1; move16(); diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index dd99c0070..1c0368932 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -893,7 +893,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( { ISM_METADATA_FRAME hIsmMetaDataFrame; ISM_METADATA_HANDLE hIsmMetaData[1]; - Word16 lfe_idx, exp_tmp; + Word16 lfe_idx, tmp, exp_tmp; Word16 num_src; IVAS_FORMAT ivas_format; IVAS_REND_AudioConfigType inConfigType; @@ -968,11 +968,10 @@ ivas_error ivas_td_binaural_renderer_ext_fx( move16(); } - Word16 num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( output_frame, FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), output_Fs, &exp_tmp ); - IF( sub( 15, exp_tmp ) ) - { - num_subframes = shr( num_subframes, sub( 15, exp_tmp ) ); - } + tmp = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = BASOP_Util_Divide1616_Scale( tmp, output_frame, &exp_tmp ); + Word16 num_subframes = shr( tmp, sub( 15, exp_tmp ) ); // Q0 + FOR( Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) { Word16 idx = subframe_idx; diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index c05ed40c3..120502230 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1455,7 +1455,7 @@ ivas_error ivas_combined_orientation_open_fx( ( *hCombinedOrientationData )->subframe_idx = 0; move16(); /* ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); */ - ( *hCombinedOrientationData )->subframe_size = extract_l( Mpy_32_32_r( fs, 10737418 /* 1 / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) in Q31 */ ) ); + ( *hCombinedOrientationData )->subframe_size = (Word16) Mpy_32_16_1( fs, ONE_BY_SUBFR_PER_SEC_Q15 ); move16(); ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index b70cdcadb..51605a828 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6474,13 +6474,20 @@ static Word16 getNumSubframesInBuffer( const IVAS_REND_AudioBuffer *buffer, const Word32 sampleRate ) { - Word16 cldfb2tdShift; + Word16 cldfb2tdShift, temp, temp_e; - cldfb2tdShift = buffer->config.is_cldfb ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( buffer->config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } - Word16 scale, temp = extract_l( Mpy_32_32( sampleRate, 10737418 /* 1 / FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES in Q31 */ ) ); - temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &scale ); - temp = shr( temp, sub( 15, scale ) ); /* Q0 */ + // temp = ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); + temp = (Word16) Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); + temp = BASOP_Util_Divide1616_Scale( temp, buffer->config.numSamplesPerChannel, &temp_e ); + temp = shr( temp, sub( 15, temp_e ) ); // Q0 temp = shr( temp, cldfb2tdShift ); return temp; @@ -8963,7 +8970,9 @@ static ivas_error renderInputMasa( } copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); - num_subframes = BASOP_Util_Divide3232_Scale( L_mult0( masaInput->base.inputBuffer.config.numSamplesPerChannel, IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ), *masaInput->base.ctx.pOutSampleRate, &exp ); + /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ + num_subframes = (Word16) Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); + num_subframes = BASOP_Util_Divide1616_Scale( num_subframes, masaInput->base.inputBuffer.config.numSamplesPerChannel, &exp ); num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) -- GitLab From a8b89d19915186a3e9b5461a79a219b290a79f74 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Nov 2025 18:06:04 +0100 Subject: [PATCH 2/8] clang-format --- lib_dec/ivas_ism_renderer_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_dec/ivas_ism_renderer_fx.c b/lib_dec/ivas_ism_renderer_fx.c index d426acc34..32f54c45a 100644 --- a/lib_dec/ivas_ism_renderer_fx.c +++ b/lib_dec/ivas_ism_renderer_fx.c @@ -233,7 +233,7 @@ void ivas_ism_render_sf_fx( { Word16 n_samples_in_subframe; - n_samples_in_subframe = imult1616(st_ivas->hTcBuffer->n_samples_granularity , st_ivas->hTcBuffer->subframe_nbslots[subframe_idx]); + n_samples_in_subframe = imult1616( st_ivas->hTcBuffer->n_samples_granularity, st_ivas->hTcBuffer->subframe_nbslots[subframe_idx] ); test(); IF( st_ivas->hCombinedOrientationData && EQ_16( st_ivas->hCombinedOrientationData->enableCombinedOrientation[st_ivas->hCombinedOrientationData->subframe_idx], 1 ) ) { -- GitLab From 926beedab68ca725a11732667ca00f4541558162 Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Nov 2025 20:08:13 +0100 Subject: [PATCH 3/8] fix --- lib_dec/ivas_jbm_dec_fx.c | 2 +- lib_rend/ivas_objectRenderer_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ce199719a..ff6a0c8f0 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -3610,7 +3610,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */ tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); - tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); + tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e ); nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ /* if samples were flushed, take that into account here */ diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 1c0368932..fc4e73402 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -969,8 +969,8 @@ ivas_error ivas_td_binaural_renderer_ext_fx( } tmp = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); - tmp = BASOP_Util_Divide1616_Scale( tmp, output_frame, &exp_tmp ); - Word16 num_subframes = shr( tmp, sub( 15, exp_tmp ) ); // Q0 + tmp = BASOP_Util_Divide1616_Scale( output_frame, tmp, &exp_tmp ); + Word16 num_subframes = shr( tmp, sub( 15, exp_tmp ) ); /* Q0 */ FOR( Word16 subframe_idx = 0; subframe_idx < num_subframes; subframe_idx++ ) { -- GitLab From 86d488944f2219dea6e7642ba06818a001d1c0ce Mon Sep 17 00:00:00 2001 From: vaclav Date: Tue, 18 Nov 2025 21:03:21 +0100 Subject: [PATCH 4/8] fix --- lib_rend/ivas_rotation_fx.c | 3 +-- lib_rend/lib_rend_fx.c | 34 ++++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 120502230..196cf59e0 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1434,8 +1434,7 @@ ivas_error ivas_combined_orientation_open_fx( move32(); move16(); - ( *hCombinedOrientationData ) - ->Quaternion_prev_extOrientation = identity; + ( *hCombinedOrientationData )->Quaternion_prev_extOrientation = identity; ( *hCombinedOrientationData )->Quaternion_frozen_ext = identity; ( *hCombinedOrientationData )->Quaternion_frozen_head = identity; set_zero_fx( ( *hCombinedOrientationData )->chEneIIR_fx[0], MASA_FREQUENCY_BANDS ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 51605a828..4af56b5ab 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -5011,14 +5011,19 @@ ivas_error IVAS_REND_FeedInputAudio_fx( return IVAS_ERR_UNEXPECTED_NULL_POINTER; } - test(); - cldfb2tdShift = ( inputAudio.config.is_cldfb ) ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( inputAudio.config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } test(); test(); test(); test(); - IF( inputAudio.config.numSamplesPerChannel <= 0 || ( L_FRAME_MAX < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 0 ) || + IF( inputAudio.config.numSamplesPerChannel <= 0 || ( LT_16( L_FRAME_MAX, inputAudio.config.numSamplesPerChannel ) && inputAudio.config.is_cldfb == 0 ) || ( ( shl( L_FRAME_MAX, cldfb2tdShift ) ) < inputAudio.config.numSamplesPerChannel && inputAudio.config.is_cldfb == 1 ) ) { return IVAS_ERROR( IVAS_ERR_INVALID_BUFFER_SIZE, "Buffer size outside of supported range" ); @@ -5030,6 +5035,8 @@ ivas_error IVAS_REND_FeedInputAudio_fx( return IVAS_ERR_WRONG_NUM_CHANNELS; } + test(); + test(); test(); move32(); // move added for typecasting IF( EQ_32( getAudioConfigType( hIvasRend->outputConfig ), IVAS_REND_AUDIO_CONFIG_TYPE_BINAURAL ) && @@ -8563,7 +8570,14 @@ static ivas_error renderInputSba( move32(); inAudio = sbaInput->base.inputBuffer; - cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( outAudio.config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } + test(); IF( NE_32( L_shl( sbaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -8934,7 +8948,15 @@ static ivas_error renderInputMasa( inAudio = masaInput->base.inputBuffer; - cldfb2tdShift = outAudio.config.is_cldfb ? 1 : 0; + cldfb2tdShift = 0; + move16(); + if ( outAudio.config.is_cldfb ) + { + cldfb2tdShift = 1; + move16(); + } + test(); + test(); IF( ( NE_32( L_shl( masaInput->base.numNewSamplesPerChannel, cldfb2tdShift ), outAudio.config.numSamplesPerChannel ) ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) && NE_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) ) { @@ -8972,7 +8994,7 @@ static ivas_error renderInputMasa( /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ num_subframes = (Word16) Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); - num_subframes = BASOP_Util_Divide1616_Scale( num_subframes, masaInput->base.inputBuffer.config.numSamplesPerChannel, &exp ); + num_subframes = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, num_subframes, &exp ); num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) -- GitLab From c4dcc0b933465bb51a69237092fe6a71e61a220b Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Nov 2025 15:35:17 +0100 Subject: [PATCH 5/8] fix --- lib_rend/lib_rend_fx.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 4af56b5ab..f29a9d39b 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6493,7 +6493,7 @@ static Word16 getNumSubframesInBuffer( // temp = ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); temp = (Word16) Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); - temp = BASOP_Util_Divide1616_Scale( temp, buffer->config.numSamplesPerChannel, &temp_e ); + temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &temp_e ); temp = shr( temp, sub( 15, temp_e ) ); // Q0 temp = shr( temp, cldfb2tdShift ); @@ -8985,7 +8985,8 @@ static ivas_error renderInputMasa( ELSE { /* MASA external renderer -> other formats */ - Word16 num_subframes, exp; + Word16 num_subframes, temp, temp_e; + FOR( ch = 0; ch < MAX_OUTPUT_CHANNELS; ch++ ) { tmpBuffer_fx[ch] = tmpBuffer_buff_fx[ch]; @@ -8993,9 +8994,9 @@ static ivas_error renderInputMasa( copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ - num_subframes = (Word16) Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); - num_subframes = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, num_subframes, &exp ); - num_subframes = shr( num_subframes, sub( 15, exp ) ); /* Q0 */ + temp = (Word16) Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); + temp = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, temp, &temp_e ); + num_subframes = shr( num_subframes, sub( 15, temp_e ) ); /* Q0 */ IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { -- GitLab From 93f259dbc5cd4828b127a86e665956f78b6cf89f Mon Sep 17 00:00:00 2001 From: vaclav Date: Wed, 19 Nov 2025 15:57:26 +0100 Subject: [PATCH 6/8] fix --- lib_rend/lib_rend_fx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f29a9d39b..538523207 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -8996,7 +8996,7 @@ static ivas_error renderInputMasa( /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ temp = (Word16) Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); temp = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, temp, &temp_e ); - num_subframes = shr( num_subframes, sub( 15, temp_e ) ); /* Q0 */ + num_subframes = shr( temp, sub( 15, temp_e ) ); /* Q0 */ IF( EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) || EQ_32( outConfig, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) ) { -- GitLab From cc1543e1d30d92a66afb436016e4aaab5c0c3b0d Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 1 Dec 2025 14:09:07 +0100 Subject: [PATCH 7/8] use extract_l() instead of data casting --- lib_dec/ivas_jbm_dec_fx.c | 8 ++++---- lib_dec/ivas_masa_dec_fx.c | 2 +- lib_dec/ivas_stereo_dft_dec_fx.c | 2 +- lib_dec/lib_dec_fx.c | 9 +++++---- lib_rend/ivas_crend_fx.c | 2 +- lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/ivas_rotation_fx.c | 2 +- lib_rend/lib_rend_fx.c | 4 ++-- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib_dec/ivas_jbm_dec_fx.c b/lib_dec/ivas_jbm_dec_fx.c index ff6a0c8f0..fb4e2893c 100644 --- a/lib_dec/ivas_jbm_dec_fx.c +++ b/lib_dec/ivas_jbm_dec_fx.c @@ -2859,7 +2859,7 @@ ivas_error ivas_jbm_dec_set_discard_samples_fx( /* render first frame with front zero padding and discarding those samples */ /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ - temp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + temp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); temp = BASOP_Util_Divide1616_Scale( temp, st_ivas->hTcBuffer->n_samples_granularity, &temp_e ); nMaxSlotsPerSubframe = shr( temp, sub( 15, temp_e ) ); /* Q0 */ nSlotsInFirstSubframe = sub( nMaxSlotsPerSubframe, st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] ); @@ -3538,7 +3538,7 @@ ivas_error ivas_jbm_dec_tc_buffer_open_fx( move16(); /* nMaxSlotsPerSubframe = (Word16)(st_ivas->hDecoderConfig->output_Fs / (FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES)) / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); tmp = BASOP_Util_Divide1616_Scale( tmp, hTcBuffer->n_samples_granularity, &tmp_e ); nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ @@ -3609,7 +3609,7 @@ ivas_error ivas_jbm_dec_tc_buffer_reconfigure_fx( Word16 tmp, tmp_e; /* nMaxSlotsPerSubframeNew = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / n_samples_granularity; */ - tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); tmp = BASOP_Util_Divide1616_Scale( tmp, n_samples_granularity, &tmp_e ); nMaxSlotsPerSubframeNew = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ @@ -3748,7 +3748,7 @@ void ivas_jbm_dec_td_renderers_adapt_subframes( UWord16 nSlotsInLastSubframe, nSlotsInFirstSubframe; /* nMaxSlotsPerSubframe = (Word16) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity; */ - tmp = (Word16) Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = extract_l( Mpy_32_16_1( st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); tmp = BASOP_Util_Divide1616_Scale( tmp, st_ivas->hTcBuffer->n_samples_granularity, &tmp_e ); nMaxSlotsPerSubframe = shr( tmp, sub( 15, tmp_e ) ); /* Q0 */ diff --git a/lib_dec/ivas_masa_dec_fx.c b/lib_dec/ivas_masa_dec_fx.c index 2c87eb208..f596093fd 100644 --- a/lib_dec/ivas_masa_dec_fx.c +++ b/lib_dec/ivas_masa_dec_fx.c @@ -1422,7 +1422,7 @@ static ivas_error init_lfe_synth_data_fx( /* Ring buffer for the filterbank of the LFE synthesis. * The filterbank is using moving average lowpass filter with the crossover of 120 Hz. */ /* bufferSize = (int16_t) ( ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES ); */ - bufferSize = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + bufferSize = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); IF( ( hMasa->hMasaLfeSynth->lfeSynthRingBuffer_fx = (Word32 *) malloc( bufferSize * sizeof( Word32 ) ) ) == NULL ) { diff --git a/lib_dec/ivas_stereo_dft_dec_fx.c b/lib_dec/ivas_stereo_dft_dec_fx.c index b5e19dad5..ce26716f8 100644 --- a/lib_dec/ivas_stereo_dft_dec_fx.c +++ b/lib_dec/ivas_stereo_dft_dec_fx.c @@ -4396,7 +4396,7 @@ void stereo_dft_dec_read_BS_fx( test(); IF( EQ_32( ivas_total_brate, IVAS_SID_5k2 ) && NE_16( ivas_format, MASA_FORMAT ) ) { - *nb_bits = (Word16) Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 ); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; Q0*/ + *nb_bits = extract_l( Mult_32_16( L_sub( element_brate, SID_2k40 ), INV_FRAME_PER_SEC_Q15 )); /* => hCPE->hCoreCoder[0]->total_brate = SID_2k40; Q0*/ move16(); } { diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 9382216cd..18383ee6d 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -826,7 +826,8 @@ static Word16 get_render_frame_size_samples( ) { Word16 tmp; - tmp = (Word16) Mpy_32_16_1( hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + + tmp = extract_l( Mpy_32_16_1( hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); IF( EQ_16( hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { @@ -875,7 +876,7 @@ ivas_error IVAS_DEC_GetRenderFramesizeSamples( #ifdef FIX_1119_SPLIT_RENDERING_VOIP *render_framesize = get_render_frame_size_samples( hIvasDec->st_ivas->hDecoderConfig ); #else - tmp = (Word16) Mpy_32_16_1( hIvasDec->st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = extract_l( Mpy_32_16_1( hIvasDec->st_ivas->hDecoderConfig->output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); IF( EQ_16( hIvasDec->st_ivas->hDecoderConfig->render_framesize, IVAS_RENDER_FRAMESIZE_5MS ) ) { @@ -1230,12 +1231,12 @@ static Word16 isar_get_frame_size( ( EQ_32( st_ivas->hRenderConfig->split_rend_config.poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) || EQ_32( st_ivas->hRenderConfig->split_rend_config.dof, 0 ) ) ) { - nSamplesPerChannel = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + nSamplesPerChannel = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); nSamplesPerChannel = imult1616( nSamplesPerChannel, st_ivas->hDecoderConfig->render_framesize ); } ELSE { - nSamplesPerChannel = (Word16) Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 ); + nSamplesPerChannel = extract_l( Mpy_32_16_1( output_Fs, INV_FRAME_PER_SEC_Q15 )); } return nSamplesPerChannel; diff --git a/lib_rend/ivas_crend_fx.c b/lib_rend/ivas_crend_fx.c index 0995ecb00..bb1c5519a 100644 --- a/lib_rend/ivas_crend_fx.c +++ b/lib_rend/ivas_crend_fx.c @@ -1862,7 +1862,7 @@ static ivas_error ivas_rend_crendConvolver_fx( } /* subframe_length = (int16_t) ( output_Fs / FRAMES_PER_SEC ) / MAX_PARAM_SPATIAL_SUBFRAMES; */ - subframe_length = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + subframe_length = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); lfe_idx_in = -1; move16(); diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index fc4e73402..4e9d4e772 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -968,7 +968,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( move16(); } - tmp = (Word16) Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + tmp = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); tmp = BASOP_Util_Divide1616_Scale( output_frame, tmp, &exp_tmp ); Word16 num_subframes = shr( tmp, sub( 15, exp_tmp ) ); /* Q0 */ diff --git a/lib_rend/ivas_rotation_fx.c b/lib_rend/ivas_rotation_fx.c index 196cf59e0..e940fe52e 100644 --- a/lib_rend/ivas_rotation_fx.c +++ b/lib_rend/ivas_rotation_fx.c @@ -1454,7 +1454,7 @@ ivas_error ivas_combined_orientation_open_fx( ( *hCombinedOrientationData )->subframe_idx = 0; move16(); /* ( *hCombinedOrientationData )->subframe_size = (int16_t) ( fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ); */ - ( *hCombinedOrientationData )->subframe_size = (Word16) Mpy_32_16_1( fs, ONE_BY_SUBFR_PER_SEC_Q15 ); + ( *hCombinedOrientationData )->subframe_size = extract_l( Mpy_32_16_1( fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); move16(); ( *hCombinedOrientationData )->cur_subframe_samples_rendered = 0; move16(); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 538523207..03437e34e 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6492,7 +6492,7 @@ static Word16 getNumSubframesInBuffer( } // temp = ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); - temp = (Word16) Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); + temp = extract_l( Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 )); temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &temp_e ); temp = shr( temp, sub( 15, temp_e ) ); // Q0 temp = shr( temp, cldfb2tdShift ); @@ -8994,7 +8994,7 @@ static ivas_error renderInputMasa( copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ - temp = (Word16) Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ); + temp = extract_l( Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 )); temp = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, temp, &temp_e ); num_subframes = shr( temp, sub( 15, temp_e ) ); /* Q0 */ -- GitLab From 7ceb74360bc25c4fc470024b990c3eddb0135c4a Mon Sep 17 00:00:00 2001 From: vaclav Date: Mon, 1 Dec 2025 15:03:42 +0100 Subject: [PATCH 8/8] clang-format --- lib_rend/ivas_objectRenderer_fx.c | 2 +- lib_rend/lib_rend_fx.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/ivas_objectRenderer_fx.c b/lib_rend/ivas_objectRenderer_fx.c index 4e9d4e772..5c72bf87e 100644 --- a/lib_rend/ivas_objectRenderer_fx.c +++ b/lib_rend/ivas_objectRenderer_fx.c @@ -968,7 +968,7 @@ ivas_error ivas_td_binaural_renderer_ext_fx( move16(); } - tmp = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 )); + tmp = extract_l( Mpy_32_16_1( output_Fs, ONE_BY_SUBFR_PER_SEC_Q15 ) ); tmp = BASOP_Util_Divide1616_Scale( output_frame, tmp, &exp_tmp ); Word16 num_subframes = shr( tmp, sub( 15, exp_tmp ) ); /* Q0 */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 081c90019..65714ce98 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -6459,7 +6459,7 @@ static Word16 getNumSubframesInBuffer( } // temp = ( buffer->config.numSamplesPerChannel / ( sampleRate / FRAMES_PER_SEC / MAX_PARAM_SPATIAL_SUBFRAMES * cldfb2tdSampleFact ) ); - temp = extract_l( Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 )); + temp = extract_l( Mpy_32_16_1( sampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ) ); temp = BASOP_Util_Divide1616_Scale( buffer->config.numSamplesPerChannel, temp, &temp_e ); temp = shr( temp, sub( 15, temp_e ) ); // Q0 temp = shr( temp, cldfb2tdShift ); @@ -8951,7 +8951,7 @@ static ivas_error renderInputMasa( copyBufferTo2dArray_fx( masaInput->base.inputBuffer, tmpBuffer_buff_fx ); /* num_subframes = (int16_t) ( masaInput->base.inputBuffer.config.numSamplesPerChannel / ( *masaInput->base.ctx.pOutSampleRate / ( IVAS_NUM_FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) ); */ - temp = extract_l( Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 )); + temp = extract_l( Mpy_32_16_1( *masaInput->base.ctx.pOutSampleRate, ONE_BY_SUBFR_PER_SEC_Q15 ) ); temp = BASOP_Util_Divide1616_Scale( masaInput->base.inputBuffer.config.numSamplesPerChannel, temp, &temp_e ); num_subframes = shr( temp, sub( 15, temp_e ) ); /* Q0 */ -- GitLab