From a86cedbc1e1701c99b5e034d0c0142cacf0630ac Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 16 Feb 2026 17:03:02 +0100 Subject: [PATCH 01/16] introduce FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - not testet yet, just making a backup of the day --- lib_com/cldfb_fx.c | 13 +++++++++++++ lib_com/options.h | 1 + lib_com/prot_fx.h | 6 +++++- lib_dec/lib_dec_fx.c | 5 +++++ lib_isar/lib_isar_pre_rend.c | 14 ++++++++++++++ lib_isar/lib_isar_pre_rend.h | 3 +++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index f0c0d8158..cb9759203 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1428,6 +1428,19 @@ ivas_error openCldfb_ivas_fx( return IVAS_ERR_OK; } +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT +ivas_error getLongCLDFBStates( HANDLE_CLDFB_FILTER_BANK h_cldfb , /* i/o: filter bank handle */ + Word16 len ) +{ + free( h_cldfb->cldfb_state_fx ); + IF( ( h_cldfb->cldfb_state_fx = (Word32 *) malloc( sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate long states memory for CLDFB" ); + } + return IVAS_ERR_OK; +} +#endif + /*-------------------------------------------------------------------* * resampleCldfb_ivas() diff --git a/lib_com/options.h b/lib_com/options.h index 6f0d8e55e..8c5b3aa56 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,6 +92,7 @@ #define HARM_FD_BWE /* VA: harmonize core-coder FD BWE function duplications */ #define FIX_2411_Harmonize_TNSANALYSIS_DETECTTNSFILT /* FhG: basop issue 2411: harmonize TNSAnalysis*_fx(), DetectTnsFilt*_fx()*/ #define HARMONIZE_READ_DECODE_TNS /* FhG basop 2389: Harm between two pairs of functions. */ +#define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /* #################### End BE switches ################################## */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 49e042e2d..1e1b79f7b 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8902,7 +8902,11 @@ ivas_error openCldfb_ivas_fx( CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ const Word16 enc_dec ); /* i : encoder/decoder flag */ -Word32 rand_gauss_fx( +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT +ivas_error getLongCLDFBStates( HANDLE_CLDFB_FILTER_BANK h_cldfb , Word16 len) ; +#endif + + Word32 rand_gauss_fx( Word32 *x, Word16 *seed, Word16 q ); diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index cbf282037..72e0f1af3 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6266,7 +6266,12 @@ static ivas_error ivas_dec_init_split_rend( move16(); } +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + /*call with a flag indicating long ana states*/ + error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag, 0 ); +#else error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag ); +#endif move16(); return error; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index f9858f413..0291ba77b 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -38,6 +38,10 @@ #include "isar_rom_post_rend.h" #include "lib_isar_pre_rend.h" #include "isar_prot.h" +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT +#include "lib_rend.h" +#endif + #ifdef DEBUGGING #include "debug.h" #endif @@ -58,6 +62,9 @@ ivas_error ISAR_PRE_REND_open( const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + , const int createLongStates +#endif ) { ivas_error error, ch, num_ch; @@ -123,6 +130,13 @@ ivas_error ISAR_PRE_REND_open( { return error; } +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + IF( createLongStates ) + { + Word16 buf_len = buf_len = sub( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]->p_filter_length, hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]->no_channels ); + getLongCLDFBStates( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] , buf_len * RENDERER_MAX_ISM_INPUTS ); + } +#endif } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index e085852d1..b4db2f578 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -49,6 +49,9 @@ ivas_error ISAR_PRE_REND_open( const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + , const int createLongStates +#endif ); void ISAR_PRE_REND_close( -- GitLab From 6c4226987168b33173db94b537fe8c5aa835b468 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 17 Feb 2026 14:17:19 +0100 Subject: [PATCH 02/16] fix e.g. mem alloc bug, create function for managing cldfg states, add multistates member to indicate multiple states per channel --- lib_com/cldfb_fx.c | 8 +++- lib_com/stat_com.h | 1 + lib_isar/lib_isar_pre_rend.c | 7 +++- lib_rend/lib_rend_fx.c | 79 +++++++++++++++++++++++++++++++++++- 4 files changed, 91 insertions(+), 4 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index cb9759203..dc45268d7 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1422,6 +1422,11 @@ ivas_error openCldfb_ivas_fx( move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); + #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + hs->cldfb_state_multiStates = 0; + move16(); + #endif + *h_cldfb = hs; move16(); @@ -1433,10 +1438,11 @@ ivas_error getLongCLDFBStates( HANDLE_CLDFB_FILTER_BANK h_cldfb , /* i/o: fil Word16 len ) { free( h_cldfb->cldfb_state_fx ); - IF( ( h_cldfb->cldfb_state_fx = (Word32 *) malloc( sizeof( Word32 ) ) ) == NULL ) + IF( ( h_cldfb->cldfb_state_fx = (Word32 *) malloc( len * sizeof( Word32 ) ) ) == NULL ) { return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate long states memory for CLDFB" ); } + set32_fx( h_cldfb->cldfb_state_fx, 0, len ); return IVAS_ERR_OK; } #endif diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index a85d6c7c0..2c9e4cf48 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -656,6 +656,7 @@ typedef struct ivas_cldfb_filter_bank_struct /* main filter state */ Word32 *cldfb_state_fx; // Q_cldfb_state Word16 cldfb_state_length; + Word16 cldfb_state_multiStates; /*multiple states per channel*/ Word16 cldfb_size; Word16 Q_cldfb_state; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 0291ba77b..a7e81abf0 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -133,8 +133,11 @@ ivas_error ISAR_PRE_REND_open( #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT IF( createLongStates ) { - Word16 buf_len = buf_len = sub( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]->p_filter_length, hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]->no_channels ); - getLongCLDFBStates( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] , buf_len * RENDERER_MAX_ISM_INPUTS ); + HANDLE_CLDFB_FILTER_BANK pCldfbAna = hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]; + pCldfbAna->cldfb_state_multiStates = 1; + /*Re-allocate CLDFB Analysis states*/ + Word16 buf_len = buf_len = sub( pCldfbAna->p_filter_length, pCldfbAna->no_channels ); + getLongCLDFBStates( pCldfbAna, buf_len * RENDERER_MAX_ISM_INPUTS ); } #endif } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 3a17884d4..fa8a7622d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4398,11 +4398,18 @@ static ivas_error isar_pre_rend_init( { isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); } - +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + /*call with additional flag to indicate long ana states*/ + IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } +#else IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) { return error; } +#endif } /* We may need to change the allocated buffer size if a new input is added. @@ -7202,6 +7209,52 @@ static void renderIsmToMasa( return; } +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT +/*Manage States pointer for next renderInputIsm call in case of multiple states per channel*/ +static void renderActiveInputsIsm_manageCldfbAnaStates( + int num_poses, + HANDLE_CLDFB_FILTER_BANK * pCurCldfbAna , + Word32* cldfb_states_orig, + int MODE) +{ + IF( pCurCldfbAna[0]->cldfb_state_multiStates > 0 ) + { + int pos_idx, ch; + FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) + { + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + Word32 **pCurStatePtr = &( pCurCldfbAna[pos_idx + ch]->cldfb_state_fx ); + int states_len = sub( pCurCldfbAna[pos_idx + ch]->p_filter_length, pCurCldfbAna[pos_idx + ch]->no_channels ); + + IF( EQ_32( MODE, 0 ) ) /*MODE 0 = Backup*/ + { + cldfb_states_orig[pos_idx + ch] = *pCurStatePtr; + } + + IF( EQ_32( MODE, 1 ) ) /*MODE 1 = update*/ + { + /*Update*/ + // if ( i > 0 ) + { + *pCurStatePtr += states_len; + } + } + + IF( EQ_32( MODE, 2 ) ) /*MODE 2 = restore*/ + { + /*restore if last iteration*/ + // if ( EQ_32( i, sub( RENDERER_MAX_ISM_INPUTS, 1 ) ) ) + { + *pCurStatePtr = cldfb_states_orig[pos_idx + ch]; + } + } + } + } + } +} +#endif + static ivas_error renderInputIsm( input_ism *ismInput, const AUDIO_CONFIG outConfig, @@ -7304,8 +7357,26 @@ static ivas_error renderActiveInputsIsm( ivas_error error; Word16 input_q = outAudio.q_factor; move16(); +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + Word32 cldfb_states_orig[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /*Array has size of maximum number of cldfbAna state handles*/ + int num_poses; + + num_poses = hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; + move32(); + set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); + /*Backup states*/ + renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna ), cldfb_states_orig, 0 ); + +#endif + FOR( ( i = 0, pCurrentInput = hIvasRend->inputsIsm ); i < RENDERER_MAX_ISM_INPUTS; ( ++i, ++pCurrentInput ) ) { +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + IF( i > 0 ) + { /*Update States*/ + renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( pCurrentInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna ), NULL, 1 ); + } +#endif IF( EQ_32( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { /* Skip inactive inputs */ @@ -7318,6 +7389,7 @@ static ivas_error renderActiveInputsIsm( { return error; } + FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) { outAudio.data_fx[j] = L_shl( outAudio.data_fx[j], sub( sub( input_q, 1 ), ( *outAudio.pq_fact ) ) ); /* Q(input_q - 1) */ @@ -7326,6 +7398,11 @@ static ivas_error renderActiveInputsIsm( *outAudio.pq_fact = sub( input_q, 1 ); move16(); } + +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + /*Restore states*/ + renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna ), cldfb_states_orig, 2 ); +#endif return IVAS_ERR_OK; } -- GitLab From 3bbd60f5549f4ef02f227d111db1b2333ffa2653 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Tue, 17 Feb 2026 16:05:58 +0100 Subject: [PATCH 03/16] fixed some warnings --- lib_com/cldfb_fx.c | 6 +++--- lib_com/prot_fx.h | 2 +- lib_dec/lib_dec_fx.c | 2 +- lib_isar/lib_isar_pre_rend.c | 6 +++--- lib_isar/lib_isar_pre_rend.h | 2 +- lib_rend/lib_rend_fx.c | 12 ++++++------ 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index dc45268d7..41c59834e 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1422,10 +1422,10 @@ ivas_error openCldfb_ivas_fx( move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); - #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT +#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT hs->cldfb_state_multiStates = 0; move16(); - #endif +#endif *h_cldfb = hs; move16(); @@ -1434,7 +1434,7 @@ ivas_error openCldfb_ivas_fx( } #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -ivas_error getLongCLDFBStates( HANDLE_CLDFB_FILTER_BANK h_cldfb , /* i/o: filter bank handle */ +ivas_error getCLDFBMultiStates( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ Word16 len ) { free( h_cldfb->cldfb_state_fx ); diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 1e1b79f7b..146ecd70f 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8903,7 +8903,7 @@ ivas_error openCldfb_ivas_fx( const Word16 enc_dec ); /* i : encoder/decoder flag */ #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -ivas_error getLongCLDFBStates( HANDLE_CLDFB_FILTER_BANK h_cldfb , Word16 len) ; +ivas_error getCLDFBMultiStates( HANDLE_CLDFB_FILTER_BANK h_cldfb, Word16 len ); #endif Word32 rand_gauss_fx( diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 72e0f1af3..c1973ebc9 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6267,7 +6267,7 @@ static ivas_error ivas_dec_init_split_rend( } #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - /*call with a flag indicating long ana states*/ + /*call with a flag indicating no long ana states*/ error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag, 0 ); #else error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag ); diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index a7e81abf0..d8902a288 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -63,7 +63,7 @@ ivas_error ISAR_PRE_REND_open( const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - , const int createLongStates + , const int createMultiStates #endif ) { @@ -131,13 +131,13 @@ ivas_error ISAR_PRE_REND_open( return error; } #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - IF( createLongStates ) + IF( createMultiStates ) { HANDLE_CLDFB_FILTER_BANK pCldfbAna = hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]; pCldfbAna->cldfb_state_multiStates = 1; /*Re-allocate CLDFB Analysis states*/ Word16 buf_len = buf_len = sub( pCldfbAna->p_filter_length, pCldfbAna->no_channels ); - getLongCLDFBStates( pCldfbAna, buf_len * RENDERER_MAX_ISM_INPUTS ); + getCLDFBMultiStates( pCldfbAna, buf_len * RENDERER_MAX_ISM_INPUTS ); } #endif } diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index b4db2f578..7a404b5a5 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -50,7 +50,7 @@ ivas_error ISAR_PRE_REND_open( const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - , const int createLongStates + , const int createMultiStates #endif ); diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index fa8a7622d..f5482bbe9 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4400,7 +4400,7 @@ static ivas_error isar_pre_rend_init( } #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /*call with additional flag to indicate long ana states*/ - IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 1 ) ) != IVAS_ERR_OK ) + IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 0 /*1*/ ) ) != IVAS_ERR_OK ) { return error; } @@ -7229,7 +7229,7 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( IF( EQ_32( MODE, 0 ) ) /*MODE 0 = Backup*/ { - cldfb_states_orig[pos_idx + ch] = *pCurStatePtr; + cldfb_states_orig[pos_idx + ch] = (Word32)(*pCurStatePtr); } IF( EQ_32( MODE, 1 ) ) /*MODE 1 = update*/ @@ -7246,7 +7246,7 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( /*restore if last iteration*/ // if ( EQ_32( i, sub( RENDERER_MAX_ISM_INPUTS, 1 ) ) ) { - *pCurStatePtr = cldfb_states_orig[pos_idx + ch]; + *pCurStatePtr = (Word32*)(cldfb_states_orig[pos_idx + ch]); } } } @@ -7365,7 +7365,7 @@ static ivas_error renderActiveInputsIsm( move32(); set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); /*Backup states*/ - renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna ), cldfb_states_orig, 0 ); + renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), cldfb_states_orig, 0 ); #endif @@ -7374,7 +7374,7 @@ static ivas_error renderActiveInputsIsm( #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT IF( i > 0 ) { /*Update States*/ - renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( pCurrentInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna ), NULL, 1 ); + renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( pCurrentInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), NULL, 1 ); } #endif IF( EQ_32( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) @@ -7401,7 +7401,7 @@ static ivas_error renderActiveInputsIsm( #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /*Restore states*/ - renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna ), cldfb_states_orig, 2 ); + renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), cldfb_states_orig, 2 ); #endif return IVAS_ERR_OK; } -- GitLab From ca21257ec2d11fb333b7bf698b9dd99d54d89ea3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 19 Feb 2026 14:42:28 +0100 Subject: [PATCH 04/16] move FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT macro to nonbe switches --- lib_com/options.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index 3e7666b26..d9841d63c 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -95,7 +95,7 @@ #define HARM_2336_DOTP /* VA: basop 2336; Harmonisation of some dot_product function + some BE optimisation */ #define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ #define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ -#define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT + /* #################### End BE switches ################################## */ @@ -103,6 +103,7 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define NONBE_MR2809 +#define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /* ##################### End NON-BE switches ########################### */ -- GitLab From bb3d4be6b98441a248864b770660d531f6ea16f9 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 19 Feb 2026 15:13:15 +0100 Subject: [PATCH 05/16] add address fix --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index d9841d63c..6f5fc53b5 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -104,6 +104,7 @@ #define NONBE_MR2809 #define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT +#define FIX_2436_CLDFBANAHANDLE_ADRESS /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index f5482bbe9..700ef82c3 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4400,7 +4400,7 @@ static ivas_error isar_pre_rend_init( } #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /*call with additional flag to indicate long ana states*/ - IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 0 /*1*/ ) ) != IVAS_ERR_OK ) + IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 1 ) ) != IVAS_ERR_OK ) { return error; } @@ -7129,7 +7129,11 @@ static ivas_error renderIsmToSplitBinaural( &tmpBinaural_CldfbRe[BINAURAL_CHANNELS * pos_idx + ch][slot_idx][0], &tmpBinaural_CldfbIm[BINAURAL_CHANNELS * pos_idx + ch][slot_idx][0], num_bands, +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS + ismInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[BINAURAL_CHANNELS * pos_idx + ch], +#else ismInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[pos_idx + ch], +#endif &q_cldfb ); } } @@ -7224,12 +7228,21 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( { FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ + Word32 **pCurStatePtr = &( pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->cldfb_state_fx ); + int states_len = sub( pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->p_filter_length, pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->no_channels ); +#else Word32 **pCurStatePtr = &( pCurCldfbAna[pos_idx + ch]->cldfb_state_fx ); int states_len = sub( pCurCldfbAna[pos_idx + ch]->p_filter_length, pCurCldfbAna[pos_idx + ch]->no_channels ); +#endif IF( EQ_32( MODE, 0 ) ) /*MODE 0 = Backup*/ { +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ + cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] = (Word32) ( *pCurStatePtr ); +#else cldfb_states_orig[pos_idx + ch] = (Word32)(*pCurStatePtr); +#endif } IF( EQ_32( MODE, 1 ) ) /*MODE 1 = update*/ @@ -7246,7 +7259,11 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( /*restore if last iteration*/ // if ( EQ_32( i, sub( RENDERER_MAX_ISM_INPUTS, 1 ) ) ) { +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ + *pCurStatePtr = (Word32 *) ( cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] ); +#else *pCurStatePtr = (Word32*)(cldfb_states_orig[pos_idx + ch]); +#endif } } } -- GitLab From 1598034cc33d4dcf8e0d519bda3d504f5ec641bc Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 19 Feb 2026 15:39:48 +0100 Subject: [PATCH 06/16] fix pointer type warning --- lib_rend/lib_rend_fx.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 700ef82c3..112893317 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7218,7 +7218,7 @@ static void renderIsmToMasa( static void renderActiveInputsIsm_manageCldfbAnaStates( int num_poses, HANDLE_CLDFB_FILTER_BANK * pCurCldfbAna , - Word32* cldfb_states_orig, + Word32 *cldfb_states_orig[], int MODE) { IF( pCurCldfbAna[0]->cldfb_state_multiStates > 0 ) @@ -7239,9 +7239,9 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( IF( EQ_32( MODE, 0 ) ) /*MODE 0 = Backup*/ { #ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ - cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] = (Word32) ( *pCurStatePtr ); + cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] = *pCurStatePtr; #else - cldfb_states_orig[pos_idx + ch] = (Word32)(*pCurStatePtr); + cldfb_states_orig[pos_idx + ch] = *pCurStatePtr; #endif } @@ -7260,9 +7260,9 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( // if ( EQ_32( i, sub( RENDERER_MAX_ISM_INPUTS, 1 ) ) ) { #ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ - *pCurStatePtr = (Word32 *) ( cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] ); + *pCurStatePtr = cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch]; #else - *pCurStatePtr = (Word32*)(cldfb_states_orig[pos_idx + ch]); + *pCurStatePtr = cldfb_states_orig[pos_idx + ch]; #endif } } @@ -7375,12 +7375,12 @@ static ivas_error renderActiveInputsIsm( Word16 input_q = outAudio.q_factor; move16(); #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - Word32 cldfb_states_orig[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /*Array has size of maximum number of cldfbAna state handles*/ + Word32 *cldfb_states_orig[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /*Array has size of maximum number of cldfbAna state handles*/ int num_poses; num_poses = hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; move32(); - set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); + //set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); /*Backup states*/ renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), cldfb_states_orig, 0 ); -- GitLab From c8a64af3bcacedb9cb6ee8b19f74861e9f8fb911 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 19 Feb 2026 16:44:52 +0100 Subject: [PATCH 07/16] activate accidentally deactivated codesections --- lib_rend/lib_rend_fx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 112893317..0220f793d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -7228,7 +7228,7 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( { FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) { -#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS Word32 **pCurStatePtr = &( pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->cldfb_state_fx ); int states_len = sub( pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->p_filter_length, pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->no_channels ); #else @@ -7238,7 +7238,7 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( IF( EQ_32( MODE, 0 ) ) /*MODE 0 = Backup*/ { -#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] = *pCurStatePtr; #else cldfb_states_orig[pos_idx + ch] = *pCurStatePtr; @@ -7259,7 +7259,7 @@ static void renderActiveInputsIsm_manageCldfbAnaStates( /*restore if last iteration*/ // if ( EQ_32( i, sub( RENDERER_MAX_ISM_INPUTS, 1 ) ) ) { -#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS_ +#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS *pCurStatePtr = cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch]; #else *pCurStatePtr = cldfb_states_orig[pos_idx + ch]; -- GitLab From fb293e774a1a7084eca24e3c90d01d7e36666727 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 19 Feb 2026 17:01:25 +0100 Subject: [PATCH 08/16] some comments --- lib_com/options.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 6f5fc53b5..bfdac5522 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -103,8 +103,8 @@ /* any switch which is non-be wrt. TS 26.251 V3.0 */ #define NONBE_MR2809 -#define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -#define FIX_2436_CLDFBANAHANDLE_ADRESS +#define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /*FhG: create and use more states per channel in cldfbhandle states to address multiple ISM inputs*/ +#define FIX_2436_CLDFBANAHANDLE_ADRESS /*FhG: cldfb handle pointer were handed over in faulty manner*/ /* ##################### End NON-BE switches ########################### */ -- GitLab From 9bb96b7ae2d80e657831fda07dabaae5da3d15f3 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 19 Feb 2026 17:20:41 +0100 Subject: [PATCH 09/16] clang patch --- lib_com/cldfb_fx.c | 2 +- lib_com/prot_fx.h | 2 +- lib_isar/lib_isar_pre_rend.c | 91 +++++++++++++------------ lib_rend/lib_rend_fx.c | 124 +++++++++++++++++------------------ 4 files changed, 108 insertions(+), 111 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 41c59834e..89462d6e3 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1435,7 +1435,7 @@ ivas_error openCldfb_ivas_fx( #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT ivas_error getCLDFBMultiStates( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - Word16 len ) + Word16 len ) { free( h_cldfb->cldfb_state_fx ); IF( ( h_cldfb->cldfb_state_fx = (Word32 *) malloc( len * sizeof( Word32 ) ) ) == NULL ) diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6af80f88e..6c4edf3aa 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8881,7 +8881,7 @@ ivas_error openCldfb_ivas_fx( ivas_error getCLDFBMultiStates( HANDLE_CLDFB_FILTER_BANK h_cldfb, Word16 len ); #endif - Word32 rand_gauss_fx( +Word32 rand_gauss_fx( Word32 *x, Word16 *seed, Word16 q ); diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index d8902a288..557653710 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -63,7 +63,8 @@ ivas_error ISAR_PRE_REND_open( const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - , const int createMultiStates + , + const int createMultiStates #endif ) { @@ -123,69 +124,67 @@ ivas_error ISAR_PRE_REND_open( num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; - FOR( ch = 0; ch < num_ch; ch++ ) - { + FOR( ch = 0; ch < num_ch; ch++ ){ IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), - CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) - { + CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ){ return error; - } + } #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - IF( createMultiStates ) - { - HANDLE_CLDFB_FILTER_BANK pCldfbAna = hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]; - pCldfbAna->cldfb_state_multiStates = 1; - /*Re-allocate CLDFB Analysis states*/ - Word16 buf_len = buf_len = sub( pCldfbAna->p_filter_length, pCldfbAna->no_channels ); - getCLDFBMultiStates( pCldfbAna, buf_len * RENDERER_MAX_ISM_INPUTS ); - } + IF( createMultiStates ) + { + HANDLE_CLDFB_FILTER_BANK pCldfbAna = hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]; + pCldfbAna->cldfb_state_multiStates = 1; + /*Re-allocate CLDFB Analysis states*/ + Word16 buf_len = buf_len = sub( pCldfbAna->p_filter_length, pCldfbAna->no_channels ); + getCLDFBMultiStates( pCldfbAna, buf_len * RENDERER_MAX_ISM_INPUTS ); + } #endif - } +} - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { - IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) - { - return error; - } - } +FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) +{ + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) + { + return error; } +} +} - IF( EQ_16( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) - { - if ( ( error = isar_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData +IF( EQ_16( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) +{ + if ( ( error = isar_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - OutSampleRate + , + OutSampleRate #endif - ) ) != IVAS_ERR_OK ) - { - return error; - } + ) ) != IVAS_ERR_OK ) + { + return error; } +} - IF( EQ_16( pcm_out_flag, 0 ) ) +IF( EQ_16( pcm_out_flag, 0 ) ) +{ + IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) { - IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) + IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, render_num_subframes ) ) != IVAS_ERR_OK ) { - IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, render_num_subframes ) ) != IVAS_ERR_OK ) - { - return error; - } + return error; } - ELSE - { - Word16 iNumBlocksPerFrame; - iNumBlocksPerFrame = ( CLDFB_NO_COL_MAX * pSplitRendConfig->codec_frame_size_ms ) / 20; + } + ELSE + { + Word16 iNumBlocksPerFrame; + iNumBlocksPerFrame = ( CLDFB_NO_COL_MAX * pSplitRendConfig->codec_frame_size_ms ) / 20; - IF( ( error = isar_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ), iNumBlocksPerFrame, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } + IF( ( error = isar_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ), iNumBlocksPerFrame, 1 ) ) != IVAS_ERR_OK ) + { + return error; } } +} - return IVAS_ERR_OK; +return IVAS_ERR_OK; } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 0220f793d..6e0fcf772 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4388,76 +4388,74 @@ static ivas_error isar_pre_rend_init( } /* these functions should only be called once during initial allocation */ - IF( pSplitRendEncBuffer->data_fx == NULL ) - { - IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) - { + IF( pSplitRendEncBuffer->data_fx == NULL ){ + IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ){ ISAR_PRE_REND_GetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis ); - } - ELSE IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) - { - isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); - } +} +ELSE IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) +{ + isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); +} #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - /*call with additional flag to indicate long ana states*/ - IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 1 ) ) != IVAS_ERR_OK ) - { - return error; - } +/*call with additional flag to indicate long ana states*/ +IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 1 ) ) != IVAS_ERR_OK ) +{ + return error; +} #else - IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) - { - return error; - } +IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) +{ + return error; +} #endif - } - - /* We may need to change the allocated buffer size if a new input is added. - * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ - test(); - IF( pSplitRendEncBuffer->data_fx != NULL && ( NE_16( cldfb_in_flag, pSplitRendEncBuffer->config.is_cldfb ) ) ) - { - realloc = true; - } +} - test(); - IF( pSplitRendEncBuffer->data_fx == NULL || NE_16( realloc, 0 ) ) - { - /* set buffer config */ - bufConfig.is_cldfb = cldfb_in_flag; - move16(); +/* We may need to change the allocated buffer size if a new input is added. + * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ +test(); +IF( pSplitRendEncBuffer->data_fx != NULL && ( NE_16( cldfb_in_flag, pSplitRendEncBuffer->config.is_cldfb ) ) ) +{ + realloc = true; +} - bufConfig.numSamplesPerChannel = L_FRAME_MAX; - move16(); - IF( NE_16( cldfb_in_flag, 0 ) ) - { - bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; - move16(); - } +test(); +IF( pSplitRendEncBuffer->data_fx == NULL || NE_16( realloc, 0 ) ) +{ + /* set buffer config */ + bufConfig.is_cldfb = cldfb_in_flag; + move16(); - bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); + bufConfig.numSamplesPerChannel = L_FRAME_MAX; + move16(); + IF( NE_16( cldfb_in_flag, 0 ) ) + { + bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; move16(); - pSplitRendEncBuffer->config = bufConfig; - move32(); + } - /* allocate memory */ - IF( NE_16( realloc, 0 ) ) - { - free( pSplitRendEncBuffer->data_fx ); - } + bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); + move16(); + pSplitRendEncBuffer->config = bufConfig; + move32(); - IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } + /* allocate memory */ + IF( NE_16( realloc, 0 ) ) + { + free( pSplitRendEncBuffer->data_fx ); + } - pSplitRendEncBuffer->q_factor = 0; - move16(); - pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; - move16(); + IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; } - return IVAS_ERR_OK; + pSplitRendEncBuffer->q_factor = 0; + move16(); + pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; + move16(); +} + +return IVAS_ERR_OK; } @@ -7215,11 +7213,11 @@ static void renderIsmToMasa( #ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /*Manage States pointer for next renderInputIsm call in case of multiple states per channel*/ -static void renderActiveInputsIsm_manageCldfbAnaStates( - int num_poses, - HANDLE_CLDFB_FILTER_BANK * pCurCldfbAna , +static void renderActiveInputsIsm_manageCldfbAnaStates( + int num_poses, + HANDLE_CLDFB_FILTER_BANK *pCurCldfbAna, Word32 *cldfb_states_orig[], - int MODE) + int MODE ) { IF( pCurCldfbAna[0]->cldfb_state_multiStates > 0 ) { @@ -7380,8 +7378,8 @@ static ivas_error renderActiveInputsIsm( num_poses = hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; move32(); - //set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); - /*Backup states*/ + // set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); + /*Backup states*/ renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), cldfb_states_orig, 0 ); #endif -- GitLab From ee8a9aef7294887fab048447f44f4eba7af6350b Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 2 Mar 2026 11:06:02 +0100 Subject: [PATCH 10/16] erase FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT code completely : not straightforward - use approach from float mr 2540 --- lib_com/cldfb_fx.c | 20 -------- lib_com/options.h | 1 - lib_com/prot_fx.h | 4 -- lib_dec/lib_dec_fx.c | 5 -- lib_isar/lib_isar_pre_rend.c | 17 ------- lib_isar/lib_isar_pre_rend.h | 3 -- lib_rend/lib_rend_fx.c | 88 ------------------------------------ 7 files changed, 138 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 89462d6e3..4c3a9f3d1 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1422,32 +1422,12 @@ ivas_error openCldfb_ivas_fx( move16(); set32_fx( hs->cldfb_state_fx, 0, buf_len ); -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - hs->cldfb_state_multiStates = 0; - move16(); -#endif - *h_cldfb = hs; move16(); return IVAS_ERR_OK; } -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -ivas_error getCLDFBMultiStates( HANDLE_CLDFB_FILTER_BANK h_cldfb, /* i/o: filter bank handle */ - Word16 len ) -{ - free( h_cldfb->cldfb_state_fx ); - IF( ( h_cldfb->cldfb_state_fx = (Word32 *) malloc( len * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Cannot allocate long states memory for CLDFB" ); - } - set32_fx( h_cldfb->cldfb_state_fx, 0, len ); - return IVAS_ERR_OK; -} -#endif - - /*-------------------------------------------------------------------* * resampleCldfb_ivas() * diff --git a/lib_com/options.h b/lib_com/options.h index e4e1c6844..26085eba8 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -106,7 +106,6 @@ #define NONBE_MR2809 #define FIX_2432_ISM_SPIKES_16KHZ /* VA: basop issue 2432: fix spikes in ISM decoding at 16kHz output sampling rate */ -#define FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT /*FhG: create and use more states per channel in cldfbhandle states to address multiple ISM inputs*/ #define FIX_2436_CLDFBANAHANDLE_ADRESS /*FhG: cldfb handle pointer were handed over in faulty manner*/ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 6c4edf3aa..a4a32366e 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -8877,10 +8877,6 @@ ivas_error openCldfb_ivas_fx( CLDFB_PROTOTYPE prototype, /* i : CLDFB version (1.25ms/5ms delay) */ const Word16 enc_dec ); /* i : encoder/decoder flag */ -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -ivas_error getCLDFBMultiStates( HANDLE_CLDFB_FILTER_BANK h_cldfb, Word16 len ); -#endif - Word32 rand_gauss_fx( Word32 *x, Word16 *seed, diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index a34ccfbfd..84cdc1b6a 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -6290,12 +6290,7 @@ static ivas_error ivas_dec_init_split_rend( move16(); } -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - /*call with a flag indicating no long ana states*/ - error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag, 0 ); -#else error = ISAR_PRE_REND_open( &st_ivas->hSplitBinRend->splitrend, &st_ivas->hRenderConfig->split_rend_config, st_ivas->hDecoderConfig->output_Fs, cldfb_in_flag, pcm_out_flag, st_ivas->hDecoderConfig->render_num_subframes, mixed_td_cldfb_flag ); -#endif move16(); return error; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 557653710..0e4a4df64 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -38,9 +38,6 @@ #include "isar_rom_post_rend.h" #include "lib_isar_pre_rend.h" #include "isar_prot.h" -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -#include "lib_rend.h" -#endif #ifdef DEBUGGING #include "debug.h" @@ -62,10 +59,6 @@ ivas_error ISAR_PRE_REND_open( const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - , - const int createMultiStates -#endif ) { ivas_error error, ch, num_ch; @@ -129,16 +122,6 @@ ivas_error ISAR_PRE_REND_open( CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ){ return error; } -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - IF( createMultiStates ) - { - HANDLE_CLDFB_FILTER_BANK pCldfbAna = hSplitRendWrapper->hCldfbHandles->cldfbAna[ch]; - pCldfbAna->cldfb_state_multiStates = 1; - /*Re-allocate CLDFB Analysis states*/ - Word16 buf_len = buf_len = sub( pCldfbAna->p_filter_length, pCldfbAna->no_channels ); - getCLDFBMultiStates( pCldfbAna, buf_len * RENDERER_MAX_ISM_INPUTS ); - } -#endif } FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) diff --git a/lib_isar/lib_isar_pre_rend.h b/lib_isar/lib_isar_pre_rend.h index 7a404b5a5..e085852d1 100644 --- a/lib_isar/lib_isar_pre_rend.h +++ b/lib_isar/lib_isar_pre_rend.h @@ -49,9 +49,6 @@ ivas_error ISAR_PRE_REND_open( const Word16 pcm_out_flag, /* i : Flag to indicate PCM output */ const IVAS_RENDER_NUM_SUBFR render_num_subframes, /* i : rendering number of subframes */ const Word16 mixed_td_cldfb_flag /* i : Flag to indicate combined TD and CLDFB input */ -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - , const int createMultiStates -#endif ); void ISAR_PRE_REND_close( diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 6e0fcf772..c311fbe6c 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4396,18 +4396,10 @@ ELSE IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_COR { isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); } -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -/*call with additional flag to indicate long ana states*/ -IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0, 1 ) ) != IVAS_ERR_OK ) -{ - return error; -} -#else IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) { return error; } -#endif } /* We may need to change the allocated buffer size if a new input is added. @@ -7211,65 +7203,6 @@ static void renderIsmToMasa( return; } -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT -/*Manage States pointer for next renderInputIsm call in case of multiple states per channel*/ -static void renderActiveInputsIsm_manageCldfbAnaStates( - int num_poses, - HANDLE_CLDFB_FILTER_BANK *pCurCldfbAna, - Word32 *cldfb_states_orig[], - int MODE ) -{ - IF( pCurCldfbAna[0]->cldfb_state_multiStates > 0 ) - { - int pos_idx, ch; - FOR( pos_idx = 0; pos_idx < num_poses; pos_idx++ ) - { - FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) - { -#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS - Word32 **pCurStatePtr = &( pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->cldfb_state_fx ); - int states_len = sub( pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->p_filter_length, pCurCldfbAna[BINAURAL_CHANNELS * pos_idx + ch]->no_channels ); -#else - Word32 **pCurStatePtr = &( pCurCldfbAna[pos_idx + ch]->cldfb_state_fx ); - int states_len = sub( pCurCldfbAna[pos_idx + ch]->p_filter_length, pCurCldfbAna[pos_idx + ch]->no_channels ); -#endif - - IF( EQ_32( MODE, 0 ) ) /*MODE 0 = Backup*/ - { -#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS - cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch] = *pCurStatePtr; -#else - cldfb_states_orig[pos_idx + ch] = *pCurStatePtr; -#endif - } - - IF( EQ_32( MODE, 1 ) ) /*MODE 1 = update*/ - { - /*Update*/ - // if ( i > 0 ) - { - *pCurStatePtr += states_len; - } - } - - IF( EQ_32( MODE, 2 ) ) /*MODE 2 = restore*/ - { - /*restore if last iteration*/ - // if ( EQ_32( i, sub( RENDERER_MAX_ISM_INPUTS, 1 ) ) ) - { -#ifdef FIX_2436_CLDFBANAHANDLE_ADRESS - *pCurStatePtr = cldfb_states_orig[BINAURAL_CHANNELS * pos_idx + ch]; -#else - *pCurStatePtr = cldfb_states_orig[pos_idx + ch]; -#endif - } - } - } - } - } -} -#endif - static ivas_error renderInputIsm( input_ism *ismInput, const AUDIO_CONFIG outConfig, @@ -7372,26 +7305,9 @@ static ivas_error renderActiveInputsIsm( ivas_error error; Word16 input_q = outAudio.q_factor; move16(); -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - Word32 *cldfb_states_orig[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS]; /*Array has size of maximum number of cldfbAna state handles*/ - int num_poses; - - num_poses = hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->multiBinPoseData.num_poses; - move32(); - // set32_fx( cldfb_states_orig, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS ); - /*Backup states*/ - renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), cldfb_states_orig, 0 ); - -#endif FOR( ( i = 0, pCurrentInput = hIvasRend->inputsIsm ); i < RENDERER_MAX_ISM_INPUTS; ( ++i, ++pCurrentInput ) ) { -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - IF( i > 0 ) - { /*Update States*/ - renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( pCurrentInput->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), NULL, 1 ); - } -#endif IF( EQ_32( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { /* Skip inactive inputs */ @@ -7414,10 +7330,6 @@ static ivas_error renderActiveInputsIsm( move16(); } -#ifdef FIX_2436_RENDERER_CLDFBSTATES_EACH_ISM_INPUT - /*Restore states*/ - renderActiveInputsIsm_manageCldfbAnaStates( num_poses, &( hIvasRend->inputsIsm->base.ctx.pSplitRendWrapper->hCldfbHandles->cldfbAna[0] ), cldfb_states_orig, 2 ); -#endif return IVAS_ERR_OK; } -- GitLab From 3a818c14f1603b0d5becea43b9b57793f6cca574 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 2 Mar 2026 10:16:21 +0000 Subject: [PATCH 11/16] Revert all changes but FIX_2436_CLDFBANAHANDLE_ADRESS --- lib_com/cldfb_fx.c | 1 + lib_com/options.h | 1 - lib_com/stat_com.h | 1 - lib_isar/lib_isar_pre_rend.c | 73 ++++++++++++------------ lib_rend/lib_rend_fx.c | 104 +++++++++++++++++------------------ 5 files changed, 90 insertions(+), 90 deletions(-) diff --git a/lib_com/cldfb_fx.c b/lib_com/cldfb_fx.c index 4c3a9f3d1..f0c0d8158 100644 --- a/lib_com/cldfb_fx.c +++ b/lib_com/cldfb_fx.c @@ -1428,6 +1428,7 @@ ivas_error openCldfb_ivas_fx( return IVAS_ERR_OK; } + /*-------------------------------------------------------------------* * resampleCldfb_ivas() * diff --git a/lib_com/options.h b/lib_com/options.h index 26085eba8..6e41c74bf 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -97,7 +97,6 @@ #define FIX_2431_AVOID_CALLOC /* VA: basp issue 2431: avoid use of calloc() */ #define FIX_2424_REMOVE_GAUSS_L2_ENC /* VA: basop issue 2424: Remove duplicated code in gauss_L2_ivas_fx() */ - /* #################### End BE switches ################################## */ /* #################### Start NON-BE switches ############################ */ diff --git a/lib_com/stat_com.h b/lib_com/stat_com.h index 2c9e4cf48..a85d6c7c0 100644 --- a/lib_com/stat_com.h +++ b/lib_com/stat_com.h @@ -656,7 +656,6 @@ typedef struct ivas_cldfb_filter_bank_struct /* main filter state */ Word32 *cldfb_state_fx; // Q_cldfb_state Word16 cldfb_state_length; - Word16 cldfb_state_multiStates; /*multiple states per channel*/ Word16 cldfb_size; Word16 Q_cldfb_state; diff --git a/lib_isar/lib_isar_pre_rend.c b/lib_isar/lib_isar_pre_rend.c index 0e4a4df64..f9858f413 100644 --- a/lib_isar/lib_isar_pre_rend.c +++ b/lib_isar/lib_isar_pre_rend.c @@ -38,7 +38,6 @@ #include "isar_rom_post_rend.h" #include "lib_isar_pre_rend.h" #include "isar_prot.h" - #ifdef DEBUGGING #include "debug.h" #endif @@ -117,57 +116,59 @@ ivas_error ISAR_PRE_REND_open( num_ch = hSplitRendWrapper->multiBinPoseData.num_poses * BINAURAL_CHANNELS; - FOR( ch = 0; ch < num_ch; ch++ ){ + FOR( ch = 0; ch < num_ch; ch++ ) + { IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbAna[ch] ), - CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ){ + CLDFB_ANALYSIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) + { return error; - } -} + } + } -FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) -{ - IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) - { - return error; + FOR( ch = 0; ch < BINAURAL_CHANNELS; ch++ ) + { + IF( ( error = openCldfb_ivas_fx( &( hSplitRendWrapper->hCldfbHandles->cldfbSyn[ch] ), CLDFB_SYNTHESIS, OutSampleRate, CLDFB_PROTOTYPE_5_00MS, DEC ) ) != IVAS_ERR_OK ) + { + return error; + } + } } -} -} -IF( EQ_16( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) -{ - if ( ( error = isar_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData + IF( EQ_16( pSplitRendConfig->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { + if ( ( error = isar_splitBinPreRendOpen( &hSplitRendWrapper->hBinHrSplitPreRend, &hSplitRendWrapper->multiBinPoseData #ifdef SPLIT_REND_WITH_HEAD_ROT_DEBUG - , - OutSampleRate + , + OutSampleRate #endif - ) ) != IVAS_ERR_OK ) - { - return error; - } -} - -IF( EQ_16( pcm_out_flag, 0 ) ) -{ - IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) - { - IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, render_num_subframes ) ) != IVAS_ERR_OK ) + ) ) != IVAS_ERR_OK ) { return error; } } - ELSE - { - Word16 iNumBlocksPerFrame; - iNumBlocksPerFrame = ( CLDFB_NO_COL_MAX * pSplitRendConfig->codec_frame_size_ms ) / 20; - IF( ( error = isar_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ), iNumBlocksPerFrame, 1 ) ) != IVAS_ERR_OK ) + IF( EQ_16( pcm_out_flag, 0 ) ) + { + IF( EQ_16( pSplitRendConfig->codec, ISAR_SPLIT_REND_CODEC_LC3PLUS ) ) { - return error; + IF( ( error = split_renderer_open_lc3plus( hSplitRendWrapper, pSplitRendConfig, OutSampleRate, render_num_subframes ) ) != IVAS_ERR_OK ) + { + return error; + } + } + ELSE + { + Word16 iNumBlocksPerFrame; + iNumBlocksPerFrame = ( CLDFB_NO_COL_MAX * pSplitRendConfig->codec_frame_size_ms ) / 20; + + IF( ( error = isar_splitBinLCLDEncOpen( &hSplitRendWrapper->hSplitBinLCLDEnc, OutSampleRate, BINAURAL_CHANNELS, isar_get_lcld_bitrate( pSplitRendConfig->splitRendBitRate, hSplitRendWrapper->multiBinPoseData.poseCorrectionMode ), iNumBlocksPerFrame, 1 ) ) != IVAS_ERR_OK ) + { + return error; + } } } -} -return IVAS_ERR_OK; + return IVAS_ERR_OK; } diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c311fbe6c..da4b0387a 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -4388,66 +4388,69 @@ static ivas_error isar_pre_rend_init( } /* these functions should only be called once during initial allocation */ - IF( pSplitRendEncBuffer->data_fx == NULL ){ - IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ){ + IF( pSplitRendEncBuffer->data_fx == NULL ) + { + IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_CLDFB ) ) + { ISAR_PRE_REND_GetMultiBinPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData, headRotData.sr_pose_pred_axis ); -} -ELSE IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) -{ - isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); -} -IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) -{ - return error; -} -} + } + ELSE IF( EQ_32( pSplit_rend_config->poseCorrectionMode, ISAR_SPLIT_REND_POSE_CORRECTION_MODE_NONE ) ) + { + isar_renderSplitUpdateNoCorrectionPoseData( pSplit_rend_config, &pSplitRendWrapper->multiBinPoseData ); + } -/* We may need to change the allocated buffer size if a new input is added. - * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ -test(); -IF( pSplitRendEncBuffer->data_fx != NULL && ( NE_16( cldfb_in_flag, pSplitRendEncBuffer->config.is_cldfb ) ) ) -{ - realloc = true; -} + IF( ( error = ISAR_PRE_REND_open( pSplitRendWrapper, pSplit_rend_config, outputSampleRate, cldfb_in_flag, outConfig == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM, num_subframes, 0 ) ) != IVAS_ERR_OK ) + { + return error; + } + } -test(); -IF( pSplitRendEncBuffer->data_fx == NULL || NE_16( realloc, 0 ) ) -{ - /* set buffer config */ - bufConfig.is_cldfb = cldfb_in_flag; - move16(); + /* We may need to change the allocated buffer size if a new input is added. + * If the cldfb_in_flag is different from what was previously allocated for the buffer, change the size */ + test(); + IF( pSplitRendEncBuffer->data_fx != NULL && ( NE_16( cldfb_in_flag, pSplitRendEncBuffer->config.is_cldfb ) ) ) + { + realloc = true; + } - bufConfig.numSamplesPerChannel = L_FRAME_MAX; - move16(); - IF( NE_16( cldfb_in_flag, 0 ) ) + test(); + IF( pSplitRendEncBuffer->data_fx == NULL || NE_16( realloc, 0 ) ) { - bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; + /* set buffer config */ + bufConfig.is_cldfb = cldfb_in_flag; move16(); - } - bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); - move16(); - pSplitRendEncBuffer->config = bufConfig; - move32(); + bufConfig.numSamplesPerChannel = L_FRAME_MAX; + move16(); + IF( NE_16( cldfb_in_flag, 0 ) ) + { + bufConfig.numSamplesPerChannel = MAX_CLDFB_BUFFER_LENGTH_PER_CHANNEL; + move16(); + } - /* allocate memory */ - IF( NE_16( realloc, 0 ) ) - { - free( pSplitRendEncBuffer->data_fx ); - } + bufConfig.numChannels = i_mult( BINAURAL_CHANNELS, pSplitRendWrapper->multiBinPoseData.num_poses ); + move16(); + pSplitRendEncBuffer->config = bufConfig; + move32(); - IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( Word32 ) ) ) == NULL ) - { - return IVAS_ERR_FAILED_ALLOC; - } + /* allocate memory */ + IF( NE_16( realloc, 0 ) ) + { + free( pSplitRendEncBuffer->data_fx ); + } - pSplitRendEncBuffer->q_factor = 0; - move16(); - pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; - move16(); -} + IF( ( pSplitRendEncBuffer->data_fx = malloc( bufConfig.numChannels * bufConfig.numSamplesPerChannel * sizeof( Word32 ) ) ) == NULL ) + { + return IVAS_ERR_FAILED_ALLOC; + } -return IVAS_ERR_OK; + pSplitRendEncBuffer->q_factor = 0; + move16(); + pSplitRendEncBuffer->pq_fact = &pSplitRendEncBuffer->q_factor; + move16(); + } + + return IVAS_ERR_OK; } @@ -7305,7 +7308,6 @@ static ivas_error renderActiveInputsIsm( ivas_error error; Word16 input_q = outAudio.q_factor; move16(); - FOR( ( i = 0, pCurrentInput = hIvasRend->inputsIsm ); i < RENDERER_MAX_ISM_INPUTS; ( ++i, ++pCurrentInput ) ) { IF( EQ_32( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) @@ -7320,7 +7322,6 @@ static ivas_error renderActiveInputsIsm( { return error; } - FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) { outAudio.data_fx[j] = L_shl( outAudio.data_fx[j], sub( sub( input_q, 1 ), ( *outAudio.pq_fact ) ) ); /* Q(input_q - 1) */ @@ -7329,7 +7330,6 @@ static ivas_error renderActiveInputsIsm( *outAudio.pq_fact = sub( input_q, 1 ); move16(); } - return IVAS_ERR_OK; } -- GitLab From 662244ceceae8c736ea01e5aa1152ace00558e30 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Mon, 2 Mar 2026 13:58:51 +0100 Subject: [PATCH 12/16] add code from float mr 2540 - To be ported --- lib_com/options.h | 1 + lib_rend/lib_rend_fx.c | 133 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 133 insertions(+), 1 deletion(-) diff --git a/lib_com/options.h b/lib_com/options.h index dfcffefc2..54d42922f 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,6 +115,7 @@ #define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ #define FIX_2436_CLDFBANAHANDLE_ADRESS /*FhG: cldfb handle pointer were handed over in faulty manner*/ +//#define FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR /*FhG: basop issue 2436 (related to basop 2283): fix garbage output for >1 object OMASA with extrend as ISAR prerenderer */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 745314ea5..460c1a6c9 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -564,6 +564,67 @@ static void accumulate2dArrayToBuffer_fx( return; } + + +#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR +/*-------------------------------------------------------------------* + * audio_buffer_td_to_cldfb() + * + * Performs CLDFB analysis on contents of td_buffer and mixes the result into cldfb_buffer. + * + * This function **does not** clear the destination buffer before writing. + * + * The number of valid CLDFB handles in cldfbAna must be a least equal to the number of channels + * in the audio buffers. + *-------------------------------------------------------------------*/ +static void audio_buffer_td_to_cldfb( + IVAS_REND_AudioBuffer td_buffer, + IVAS_REND_AudioBuffer cldfb_buffer, + int32_t fs, + HANDLE_CLDFB_FILTER_BANK *cldfbAna ) +{ + int16_t ch, slot_idx; + float *td_read_ptr; + float *cldfb_write_ptr; + int16_t num_bands, num_slots; + + assert( !td_buffer.config.is_cldfb ); + assert( cldfb_buffer.config.is_cldfb ); + + assert( td_buffer.config.numChannels == cldfb_buffer.config.numChannels ); + assert( td_buffer.config.numSamplesPerChannel * 2 == cldfb_buffer.config.numSamplesPerChannel ); + + td_read_ptr = td_buffer.data; + cldfb_write_ptr = cldfb_buffer.data; + num_bands = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * fs ) / 48000 ); + assert( td_buffer.config.numSamplesPerChannel % num_bands == 0 ); + num_slots = td_buffer.config.numSamplesPerChannel / num_bands; + + for ( ch = 0; ch < cldfb_buffer.config.numChannels; ++ch ) + { + for ( slot_idx = 0; slot_idx < num_slots; ++slot_idx ) + { + float re[CLDFB_NO_CHANNELS_MAX]; + float im[CLDFB_NO_CHANNELS_MAX]; + + cldfbAnalysis_ts( td_read_ptr, + re, + im, + num_bands, + cldfbAna[ch] ); + + td_read_ptr += num_bands; + + v_add( re, cldfb_write_ptr, cldfb_write_ptr, num_bands ); + cldfb_write_ptr += num_bands; + v_add( im, cldfb_write_ptr, cldfb_write_ptr, num_bands ); + cldfb_write_ptr += num_bands; + } + } +} +#endif + + /*-------------------------------------------------------------------* * limitRendererOutput() * @@ -7104,16 +7165,25 @@ static ivas_error renderIsmToSplitBinaural( const SPLIT_REND_WRAPPER *pSplitRendWrapper; IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_QUATERNION localHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; - Word16 i, ch, slot_idx, num_bands; + Word16 i; +#ifndef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR + Word16 ch, slot_idx, num_bands; Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; Word32 tmpBinaural_CldfbRe[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 tmpBinaural_CldfbIm[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; +#endif Word16 output_frame = ismInput->base.inputBuffer.config.numSamplesPerChannel; COMBINED_ORIENTATION_HANDLE pCombinedOrientationData; Word16 ism_md_subframe_update_ext, exp; push_wmops( "renderIsmToSplitBinaural" ); +#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR + assert( !outAudio.config.is_cldfb && + "ISM renderering only supports TD output. If CLDFB output was requested, " + "we convert to CLDFB higher up the stack after rendering all ISMs" ); +#endif + pSplitRendWrapper = ismInput->base.ctx.pSplitRendWrapper; pMultiBinPoseData = &pSplitRendWrapper->multiBinPoseData; @@ -7195,6 +7265,7 @@ static ivas_error renderIsmToSplitBinaural( } } +#ifndef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR IF( NE_16( outAudio.config.is_cldfb, 0 ) ) { /* Perform CLDFB analysis on rendered audio, since the output buffer is CLDFB domain */ @@ -7246,12 +7317,15 @@ static ivas_error renderIsmToSplitBinaural( } ELSE { +#endif /*FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR*/ /* Copy rendered audio to tmp storage buffer. Copying directly to output would * overwrite original audio, which is still needed for rendering next head pose. */ Copy32( tmpProcessing[0], tmpBinaural[i_mult( 2, pos_idx )], output_frame ); Copy32( tmpProcessing[1], tmpBinaural[add( i_mult( 2, pos_idx ), 1 )], output_frame ); +#ifndef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR } +#endif /* Overwrite processing buffer with original input audio again */ copyBufferTo2dArray_fx( ismInput->base.inputBuffer, tmpProcessing ); @@ -7263,6 +7337,7 @@ static ivas_error renderIsmToSplitBinaural( Copy_Quat_fx( &originalHeadRot[i], &pCombinedOrientationData->Quaternions[i] ); } +#ifndef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR if ( outAudio.config.is_cldfb ) { #ifdef FIX_2283_ACCU_CLDFB @@ -7273,8 +7348,11 @@ static ivas_error renderIsmToSplitBinaural( } else { +#endif /*FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR*/ accumulate2dArrayToBuffer_fx( tmpBinaural, &outAudio ); +#ifndef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR } +#endif pop_wmops(); /* Encoding to split rendering bitstream done at a higher level */ @@ -7427,6 +7505,44 @@ static ivas_error renderActiveInputsIsm( ivas_error error; Word16 input_q = outAudio.q_factor; move16(); + +#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR + int16_t num_active_inputs; + IVAS_REND_AudioBuffer work_buffer; + float tmp_td_binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k]; + + // Early return in case there are no active ISM inputs + num_active_inputs = 0; + for ( i = 0, pCurrentInput = hIvasRend->inputsIsm; i < RENDERER_MAX_ISM_INPUTS; ++i, ++pCurrentInput ) + { + if ( pCurrentInput->base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + { + ++num_active_inputs; + } + } + if ( num_active_inputs == 0 ) + { + return IVAS_ERR_OK; + } + + // By default (TD output), use outAudio as work_buffer. This means we render individual ISMs + // directly to outAudio, since the `data` member of both these structs is pointing to the same memory. + // Initializing this way also fixes MSVC's false-positive warning about work_buffer being used + // without initialization in code below, as well as some WMC tool instrumentation problems. + work_buffer = outAudio; + + // ISM rendering only supports TD output. If CLDFB output was requested, we first render + // to TD in a temporary buffer and then convert to CLDFB. We do this by swapping out the + // underlying memory of work_buffer and modifying its config to TD. + if ( outAudio.config.is_cldfb ) + { + work_buffer.config.numSamplesPerChannel /= 2; + work_buffer.config.is_cldfb = false; + work_buffer.data = tmp_td_binaural; + set_zero( tmp_td_binaural, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k ); + } +#endif + FOR( ( i = 0, pCurrentInput = hIvasRend->inputsIsm ); i < RENDERER_MAX_ISM_INPUTS; ( ++i, ++pCurrentInput ) ) { IF( EQ_32( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) @@ -7437,10 +7553,25 @@ static ivas_error renderActiveInputsIsm( *outAudio.pq_fact = input_q; move16(); +#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR + IF( NE_32( ( error = renderInputIsm( pCurrentInput, hIvasRend->outputConfig, work_buffer ) ), IVAS_ERR_OK ) ) +#else IF( NE_32( ( error = renderInputIsm( pCurrentInput, hIvasRend->outputConfig, outAudio ) ), IVAS_ERR_OK ) ) +#endif { return error; } + +#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR + if ( outAudio.config.is_cldfb ) + { + audio_buffer_td_to_cldfb( work_buffer, + outAudio, + hIvasRend->sampleRateOut, + hIvasRend->splitRendWrapper->hCldfbHandles->cldfbAna ); + } +#endif + FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) { outAudio.data_fx[j] = L_shl( outAudio.data_fx[j], sub( sub( input_q, 1 ), ( *outAudio.pq_fact ) ) ); /* Q(input_q - 1) */ -- GitLab From 65fe3ce502d8d84b9b52403bcc42bf0a3ad7bc98 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Wed, 4 Mar 2026 12:50:13 +0100 Subject: [PATCH 13/16] added ported versions of code, deleted float code, did a first stepthrough --- lib_com/options.h | 2 +- lib_rend/lib_rend_fx.c | 141 +++++++++++++++++++++++++++-------------- 2 files changed, 95 insertions(+), 48 deletions(-) diff --git a/lib_com/options.h b/lib_com/options.h index 54d42922f..7428fe696 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -115,7 +115,7 @@ #define FIX_FLOAT_1533_BLEND_SUBFR2 /* FhG: float issue 1533: correct blending in blend_subfr2() */ #define FIX_2436_CLDFBANAHANDLE_ADRESS /*FhG: cldfb handle pointer were handed over in faulty manner*/ -//#define FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR /*FhG: basop issue 2436 (related to basop 2283): fix garbage output for >1 object OMASA with extrend as ISAR prerenderer */ +#define FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR /*FhG: basop issue 2436 (related to basop 2283): fix garbage output for >1 object OMASA with extrend as ISAR prerenderer */ /* ##################### End NON-BE switches ########################### */ diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 460c1a6c9..584ac0d5f 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -568,7 +568,7 @@ static void accumulate2dArrayToBuffer_fx( #ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR /*-------------------------------------------------------------------* - * audio_buffer_td_to_cldfb() + * audio_buffer_td_to_cldfb_fx() * * Performs CLDFB analysis on contents of td_buffer and mixes the result into cldfb_buffer. * @@ -577,48 +577,83 @@ static void accumulate2dArrayToBuffer_fx( * The number of valid CLDFB handles in cldfbAna must be a least equal to the number of channels * in the audio buffers. *-------------------------------------------------------------------*/ -static void audio_buffer_td_to_cldfb( +static void audio_buffer_td_to_cldfb_fx( IVAS_REND_AudioBuffer td_buffer, IVAS_REND_AudioBuffer cldfb_buffer, - int32_t fs, + Word32 fs, HANDLE_CLDFB_FILTER_BANK *cldfbAna ) { - int16_t ch, slot_idx; - float *td_read_ptr; - float *cldfb_write_ptr; - int16_t num_bands, num_slots; + Word16 ch, slot_idx; + Word32 *td_read_ptr; + Word32 *cldfb_write_ptr; + Word16 num_bands, num_slots; + const Word32 inv48000_Q15r = 0x57619F10 /*1/48000 in Q15, rounded*/; assert( !td_buffer.config.is_cldfb ); assert( cldfb_buffer.config.is_cldfb ); - assert( td_buffer.config.numChannels == cldfb_buffer.config.numChannels ); - assert( td_buffer.config.numSamplesPerChannel * 2 == cldfb_buffer.config.numSamplesPerChannel ); + assert( EQ_16(td_buffer.config.numChannels, cldfb_buffer.config.numChannels) ); + assert( EQ_16(shl(td_buffer.config.numSamplesPerChannel, 1), cldfb_buffer.config.numSamplesPerChannel) ); - td_read_ptr = td_buffer.data; - cldfb_write_ptr = cldfb_buffer.data; - num_bands = (int16_t) ( ( CLDFB_NO_CHANNELS_MAX * fs ) / 48000 ); + td_read_ptr = td_buffer.data_fx; + cldfb_write_ptr = cldfb_buffer.data_fx; + num_bands = shl( extract_h( Mpy_32_32( imult3216( fs, CLDFB_NO_CHANNELS_MAX ), inv48000_Q15r ) ), 1 ) /*CLDFB*fs/48000 in Q0*/; assert( td_buffer.config.numSamplesPerChannel % num_bands == 0 ); - num_slots = td_buffer.config.numSamplesPerChannel / num_bands; + num_slots = idiv1616( td_buffer.config.numSamplesPerChannel, num_bands ); - for ( ch = 0; ch < cldfb_buffer.config.numChannels; ++ch ) + FOR ( ch = 0; ch < cldfb_buffer.config.numChannels; ++ch ) { - for ( slot_idx = 0; slot_idx < num_slots; ++slot_idx ) + FOR ( slot_idx = 0; slot_idx < num_slots; ++slot_idx ) { - float re[CLDFB_NO_CHANNELS_MAX]; - float im[CLDFB_NO_CHANNELS_MAX]; + Word32 re[CLDFB_NO_CHANNELS_MAX]; + Word32 im[CLDFB_NO_CHANNELS_MAX]; + Word16 q_cldfb = *( cldfb_buffer.pq_fact ); - cldfbAnalysis_ts( td_read_ptr, - re, - im, - num_bands, - cldfbAna[ch] ); + cldfbAnalysis_ts_fx( td_read_ptr, + re, + im, + num_bands, + cldfbAna[ch], + &q_cldfb ); td_read_ptr += num_bands; - v_add( re, cldfb_write_ptr, cldfb_write_ptr, num_bands ); - cldfb_write_ptr += num_bands; - v_add( im, cldfb_write_ptr, cldfb_write_ptr, num_bands ); - cldfb_write_ptr += num_bands; +#ifdef FIX_2283_Q_CLDFB + /* scale re and im according to exp-q_cldfb */ + { + Word16 exp = *( cldfb_buffer.pq_fact ); + Word16 noChannels = cldfbAna[ch]->no_channels; + +#ifdef FIX_2283_ACCU_CLDFB + Word16 scale = sub( exp, q_cldfb ); + FOR( Word16 j = 0; j < noChannels; j++ ) + { + re[j] = L_shl( re[j], scale ); /*Q(exp)*/ + im[j] = L_shl( im[j], scale ); /*Q(exp)*/ + } +#else + Word16 scale = sub( sub( exp, q_cldfb ), 1 ); + FOR( Word16 j = 0; j < noChannels; j++ ) + { + re[j] = L_shl( re[j], scale ); /*Q(exp)*/ + im[j] = L_shl( im[j], scale ); /*Q(exp)*/ + } +#endif + } +#endif + //v_add( re, cldfb_write_ptr, cldfb_write_ptr, num_bands ); + // cldfb_write_ptr += num_bands; + FOR( int smplIdx = 0; smplIdx < num_bands; smplIdx++ ) + { + *cldfb_write_ptr++ += re[smplIdx]; + } + + //v_add( im, cldfb_write_ptr, cldfb_write_ptr, num_bands ); + //cldfb_write_ptr += num_bands; + FOR( int smplIdx = 0; smplIdx < num_bands; smplIdx++ ) + { + *cldfb_write_ptr++ += im[smplIdx]; + } } } } @@ -7166,9 +7201,9 @@ static ivas_error renderIsmToSplitBinaural( IVAS_QUATERNION originalHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; IVAS_QUATERNION localHeadRot[MAX_PARAM_SPATIAL_SUBFRAMES]; Word16 i; + Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; #ifndef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR Word16 ch, slot_idx, num_bands; - Word32 tmpBinaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][L_FRAME48k]; Word32 tmpBinaural_CldfbRe[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; Word32 tmpBinaural_CldfbIm[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS][CLDFB_NO_COL_MAX][CLDFB_NO_CHANNELS_MAX]; #endif @@ -7507,20 +7542,24 @@ static ivas_error renderActiveInputsIsm( move16(); #ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR - int16_t num_active_inputs; + Word16 num_active_inputs; IVAS_REND_AudioBuffer work_buffer; - float tmp_td_binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k]; + Word32 tmp_td_binaural[MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k]; // Early return in case there are no active ISM inputs num_active_inputs = 0; - for ( i = 0, pCurrentInput = hIvasRend->inputsIsm; i < RENDERER_MAX_ISM_INPUTS; ++i, ++pCurrentInput ) + move16(); + pCurrentInput = hIvasRend->inputsIsm; + + FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { - if ( pCurrentInput->base.inConfig != IVAS_AUDIO_CONFIG_INVALID ) + if ( NE_32(pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID) ) { - ++num_active_inputs; + num_active_inputs = add( num_active_inputs, 1 ); } + ++pCurrentInput; } - if ( num_active_inputs == 0 ) + IF ( num_active_inputs == 0 ) { return IVAS_ERR_OK; } @@ -7530,16 +7569,24 @@ static ivas_error renderActiveInputsIsm( // Initializing this way also fixes MSVC's false-positive warning about work_buffer being used // without initialization in code below, as well as some WMC tool instrumentation problems. work_buffer = outAudio; + + /*This loop is instrumentation-only and has no effect on operational result*/ + for ( int i_instr = 0; i_instr < sizeof( outAudio ) / 4; i_instr++ ) + { + move32(); + } // ISM rendering only supports TD output. If CLDFB output was requested, we first render // to TD in a temporary buffer and then convert to CLDFB. We do this by swapping out the // underlying memory of work_buffer and modifying its config to TD. - if ( outAudio.config.is_cldfb ) + IF ( outAudio.config.is_cldfb ) { - work_buffer.config.numSamplesPerChannel /= 2; + work_buffer.config.numSamplesPerChannel = shr( work_buffer.config.numSamplesPerChannel, 1 ); work_buffer.config.is_cldfb = false; - work_buffer.data = tmp_td_binaural; - set_zero( tmp_td_binaural, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k ); + move16(); + + work_buffer.data_fx = tmp_td_binaural; + set32_fx( tmp_td_binaural, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k ); } #endif @@ -7562,16 +7609,6 @@ static ivas_error renderActiveInputsIsm( return error; } -#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR - if ( outAudio.config.is_cldfb ) - { - audio_buffer_td_to_cldfb( work_buffer, - outAudio, - hIvasRend->sampleRateOut, - hIvasRend->splitRendWrapper->hCldfbHandles->cldfbAna ); - } -#endif - FOR( Word16 j = 0; j < outAudio.config.numSamplesPerChannel * outAudio.config.numChannels; ++j ) { outAudio.data_fx[j] = L_shl( outAudio.data_fx[j], sub( sub( input_q, 1 ), ( *outAudio.pq_fact ) ) ); /* Q(input_q - 1) */ @@ -7581,6 +7618,16 @@ static ivas_error renderActiveInputsIsm( move16(); } +#ifdef FIX_BASOP_2436_REUSED_CLDFB_IN_OMASA_SR + IF( outAudio.config.is_cldfb ) + { + audio_buffer_td_to_cldfb_fx( work_buffer, + outAudio, + hIvasRend->sampleRateOut, + hIvasRend->splitRendWrapper->hCldfbHandles->cldfbAna ); + } +#endif + return IVAS_ERR_OK; } -- GitLab From da12e342ddd09abcba2aad6841187c9ac6ef430c Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 5 Mar 2026 11:21:24 +0100 Subject: [PATCH 14/16] correct instrumentation --- lib_rend/lib_rend_fx.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 584ac0d5f..44d42fa8d 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -641,18 +641,18 @@ static void audio_buffer_td_to_cldfb_fx( #endif } #endif - //v_add( re, cldfb_write_ptr, cldfb_write_ptr, num_bands ); - // cldfb_write_ptr += num_bands; FOR( int smplIdx = 0; smplIdx < num_bands; smplIdx++ ) { - *cldfb_write_ptr++ += re[smplIdx]; + *cldfb_write_ptr = L_add( *cldfb_write_ptr, re[smplIdx] ); + move32(); + cldfb_write_ptr++; } - //v_add( im, cldfb_write_ptr, cldfb_write_ptr, num_bands ); - //cldfb_write_ptr += num_bands; FOR( int smplIdx = 0; smplIdx < num_bands; smplIdx++ ) { - *cldfb_write_ptr++ += im[smplIdx]; + *cldfb_write_ptr = L_add( *cldfb_write_ptr, im[smplIdx] ); + move32(); + cldfb_write_ptr++; } } } @@ -7569,12 +7569,12 @@ static ivas_error renderActiveInputsIsm( // Initializing this way also fixes MSVC's false-positive warning about work_buffer being used // without initialization in code below, as well as some WMC tool instrumentation problems. work_buffer = outAudio; - - /*This loop is instrumentation-only and has no effect on operational result*/ - for ( int i_instr = 0; i_instr < sizeof( outAudio ) / 4; i_instr++ ) - { - move32(); - } + move16(); + move16(); + move16(); + move16(); + move32(); + move32(); // ISM rendering only supports TD output. If CLDFB output was requested, we first render // to TD in a temporary buffer and then convert to CLDFB. We do this by swapping out the @@ -7586,6 +7586,7 @@ static ivas_error renderActiveInputsIsm( move16(); work_buffer.data_fx = tmp_td_binaural; + move32(); set32_fx( tmp_td_binaural, 0, MAX_HEAD_ROT_POSES * BINAURAL_CHANNELS * L_FRAME48k ); } #endif -- GitLab From c8c60dc4b6f7ceffcf4442e97809606252d687b7 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 5 Mar 2026 11:46:49 +0100 Subject: [PATCH 15/16] clang format patch --- lib_rend/lib_rend_fx.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index c9ecb6692..7c1e4e6f2 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -557,8 +557,8 @@ static void audio_buffer_td_to_cldfb_fx( assert( !td_buffer.config.is_cldfb ); assert( cldfb_buffer.config.is_cldfb ); - assert( EQ_16(td_buffer.config.numChannels, cldfb_buffer.config.numChannels) ); - assert( EQ_16(shl(td_buffer.config.numSamplesPerChannel, 1), cldfb_buffer.config.numSamplesPerChannel) ); + assert( EQ_16( td_buffer.config.numChannels, cldfb_buffer.config.numChannels ) ); + assert( EQ_16( shl( td_buffer.config.numSamplesPerChannel, 1 ), cldfb_buffer.config.numSamplesPerChannel ) ); td_read_ptr = td_buffer.data_fx; cldfb_write_ptr = cldfb_buffer.data_fx; @@ -566,9 +566,9 @@ static void audio_buffer_td_to_cldfb_fx( assert( td_buffer.config.numSamplesPerChannel % num_bands == 0 ); num_slots = idiv1616( td_buffer.config.numSamplesPerChannel, num_bands ); - FOR ( ch = 0; ch < cldfb_buffer.config.numChannels; ++ch ) + FOR( ch = 0; ch < cldfb_buffer.config.numChannels; ++ch ) { - FOR ( slot_idx = 0; slot_idx < num_slots; ++slot_idx ) + FOR( slot_idx = 0; slot_idx < num_slots; ++slot_idx ) { Word32 re[CLDFB_NO_CHANNELS_MAX]; Word32 im[CLDFB_NO_CHANNELS_MAX]; @@ -612,7 +612,7 @@ static void audio_buffer_td_to_cldfb_fx( move32(); cldfb_write_ptr++; } - + FOR( int smplIdx = 0; smplIdx < num_bands; smplIdx++ ) { *cldfb_write_ptr = L_add( *cldfb_write_ptr, im[smplIdx] ); @@ -7503,13 +7503,13 @@ static ivas_error renderActiveInputsIsm( FOR( i = 0; i < RENDERER_MAX_ISM_INPUTS; ++i ) { - if ( NE_32(pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID) ) + if ( NE_32( pCurrentInput->base.inConfig, IVAS_AUDIO_CONFIG_INVALID ) ) { num_active_inputs = add( num_active_inputs, 1 ); } ++pCurrentInput; } - IF ( num_active_inputs == 0 ) + IF( num_active_inputs == 0 ) { return IVAS_ERR_OK; } @@ -7529,7 +7529,7 @@ static ivas_error renderActiveInputsIsm( // ISM rendering only supports TD output. If CLDFB output was requested, we first render // to TD in a temporary buffer and then convert to CLDFB. We do this by swapping out the // underlying memory of work_buffer and modifying its config to TD. - IF ( outAudio.config.is_cldfb ) + IF( outAudio.config.is_cldfb ) { work_buffer.config.numSamplesPerChannel = shr( work_buffer.config.numSamplesPerChannel, 1 ); work_buffer.config.is_cldfb = false; -- GitLab From f9978fb577366b23e1e5093644f6cb981f7d2bc9 Mon Sep 17 00:00:00 2001 From: Fabian Bauer Date: Thu, 5 Mar 2026 12:09:53 +0100 Subject: [PATCH 16/16] made fix from issue 2283 permanent because according MR was merged and macro is deleted --- lib_rend/lib_rend_fx.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/lib_rend/lib_rend_fx.c b/lib_rend/lib_rend_fx.c index 7c1e4e6f2..822f42882 100644 --- a/lib_rend/lib_rend_fx.c +++ b/lib_rend/lib_rend_fx.c @@ -583,29 +583,19 @@ static void audio_buffer_td_to_cldfb_fx( td_read_ptr += num_bands; -#ifdef FIX_2283_Q_CLDFB /* scale re and im according to exp-q_cldfb */ { Word16 exp = *( cldfb_buffer.pq_fact ); Word16 noChannels = cldfbAna[ch]->no_channels; -#ifdef FIX_2283_ACCU_CLDFB Word16 scale = sub( exp, q_cldfb ); FOR( Word16 j = 0; j < noChannels; j++ ) { re[j] = L_shl( re[j], scale ); /*Q(exp)*/ im[j] = L_shl( im[j], scale ); /*Q(exp)*/ } -#else - Word16 scale = sub( sub( exp, q_cldfb ), 1 ); - FOR( Word16 j = 0; j < noChannels; j++ ) - { - re[j] = L_shl( re[j], scale ); /*Q(exp)*/ - im[j] = L_shl( im[j], scale ); /*Q(exp)*/ - } -#endif } -#endif + FOR( int smplIdx = 0; smplIdx < num_bands; smplIdx++ ) { *cldfb_write_ptr = L_add( *cldfb_write_ptr, re[smplIdx] ); -- GitLab