From 78395818be0ba26cd23d17e735591f3b016f2f9d Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 20:51:32 +0200 Subject: [PATCH 1/3] FIX_APA_EXECS_SCALING --- lib_com/options.h | 2 ++ lib_dec/lib_dec_fx.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index dc7357918..45d5ec650 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -79,6 +79,8 @@ #define FIX_2092_ASSERT_IN_OMASA_RENDER /* FhG, Nokia: Fix LTV crash due to overflow in OMASA EXT output */ #define FIX_2084_FLOATING_POINT_LEFTOVERS /* FhG: convert floating-point leftovers in IVAS_ENC_FeedObjectMetadata() */ #define FIX_2141_ASSERT_IN_OMASA_BITRATE_SWITSCHING /* FhG: Replace L_shl with L_shl_sat to prevent overflow when calculating scale factors for very small numbers in the logarithmic domain */ +#define FIX_APA_EXECS_SCALING /* VA: fix scaling of JBM APA buffer */ + /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 7ee9289a6..5bc96bf27 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3973,6 +3973,10 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } +#ifdef FIX_APA_EXECS_SCALING + set_zero2_fx( hIvasDec->apaExecBuffer_fx, L_mult0( APA_BUF_PER_CHANNEL, (Word16) nTransportChannels ) ); +#endif + #ifdef LIB_DEC_REVISION ivas_syn_output_f_fx( st_ivas->p_output_fx, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer_fx ); -- GitLab From 5f1ec82f7b8ef196ae2e0674efb83b8dd7576f43 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 22:13:07 +0200 Subject: [PATCH 2/3] fix --- lib_dec/jbm_pcmdsp_apa_fx.c | 4 ++++ lib_dec/lib_dec_fx.c | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 7b64250b1..30991a255 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -904,7 +904,11 @@ UWord8 apa_exec_ivas_fx( Word16 Q_a_out; Word16 Q_a_out_init_old; +#ifdef FIX_APA_EXECS_SCALING + Q_a_out = add( getScaleFactor32_copy( a_in, l_in ), Q11 - Q16 - Q1 ); +#else Q_a_out = add( getScaleFactor32_copy( a_in, L_mult0( ps->num_channels, APA_BUF_PER_CHANNEL ) ), Q11 - Q16 - Q1 ); +#endif Q_a_out_init_old = Q_a_out; /* store the possible scaling of a_in, to be re-used in the next frame */ move16(); statsResetThreshold = 1637; diff --git a/lib_dec/lib_dec_fx.c b/lib_dec/lib_dec_fx.c index 5bc96bf27..7ee9289a6 100644 --- a/lib_dec/lib_dec_fx.c +++ b/lib_dec/lib_dec_fx.c @@ -3973,10 +3973,6 @@ ivas_error IVAS_DEC_GetSamplesDecoder( return IVAS_ERR_UNKNOWN; } -#ifdef FIX_APA_EXECS_SCALING - set_zero2_fx( hIvasDec->apaExecBuffer_fx, L_mult0( APA_BUF_PER_CHANNEL, (Word16) nTransportChannels ) ); -#endif - #ifdef LIB_DEC_REVISION ivas_syn_output_f_fx( st_ivas->p_output_fx, hIvasDec->nSamplesFrame, nTransportChannels, hIvasDec->apaExecBuffer_fx ); -- GitLab From bca77ac59554b2ba6b201ac1cb952847549b9271 Mon Sep 17 00:00:00 2001 From: vaclav Date: Thu, 23 Oct 2025 23:15:15 +0200 Subject: [PATCH 3/3] fix --- lib_dec/jbm_pcmdsp_apa_fx.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib_dec/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 30991a255..d68e7312f 100644 --- a/lib_dec/jbm_pcmdsp_apa_fx.c +++ b/lib_dec/jbm_pcmdsp_apa_fx.c @@ -985,7 +985,11 @@ UWord8 apa_exec_ivas_fx( Scale_sig( ps->buf_out_fx, ps->buf_out_capacity, sub( Q_a_out, ps->Q_buf_out ) ); // Q_buf_out -> Q_a_out IF( EQ_32( ps->scale, 100 ) ) { +#ifdef FIX_APA_EXECS_SCALING + FOR( i = 0; i < ps->l_frm; i++ ) +#else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) +#endif { a_out[i] = a_in[i]; // Q11 move32(); @@ -997,7 +1001,11 @@ UWord8 apa_exec_ivas_fx( { Word16 *frm_in_ptr = &( frm_in[ps->l_frm] ); +#ifdef FIX_APA_EXECS_SCALING + FOR( i = 0; i < ps->l_frm; i++ ) +#else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) +#endif { a_tmp[i] = extract_h( L_shl( a_in[i], add( Q_a_out, Q5 ) ) ); // Q_a_out move16(); @@ -1047,7 +1055,11 @@ UWord8 apa_exec_ivas_fx( } } +#ifdef FIX_APA_EXECS_SCALING + FOR( i = 0; i < l_frm_out; i++ ) +#else FOR( i = 0; i < ps->num_channels * APA_BUF_PER_CHANNEL; i++ ) +#endif { a_out[i] = L_shl( a_tmp[i], sub( Q11, Q_a_out ) ); // Q0 -> Q11 move32(); -- GitLab