diff --git a/lib_com/options.h b/lib_com/options.h index dc7357918a7940af6fab10b7bb3aa88a45de136e..45d5ec650fe60eed44e5404b7aa95770f6c50898 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/jbm_pcmdsp_apa_fx.c b/lib_dec/jbm_pcmdsp_apa_fx.c index 7b64250b182955ac529e723fe562ed616f256421..d68e7312f5a167e50d8cd6adb6fcad36ce562b56 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; @@ -981,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(); @@ -993,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(); @@ -1043,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();