diff --git a/lib_com/options.h b/lib_com/options.h index e454fcc18f5e6eb12e885994212b8dd6611a19f2..c1a258bcf10ecf4e11eb0256e15bd3dd3b035e1a 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -92,7 +92,7 @@ #define FIX_2174_JBM_BASOP_ALIGNMENT /* VoiceAge, Nokia: Fixes to JBM BASOP implementation and alignment to float */ #define FIX_2176_ASSERT_DEC_MAP_PARAMS_DIRAC2STEREO /* FhG: Reduce hStereoDft->q_smooth_buf_fx by one to prevent overflow in the subframe_band_nrg[][] calculation */ - +#define FIX_2015_PREMPH_SAT_ALT /* VA: saturation can happen during preemphasis filtering due to a too aggressive scaling factor, allows preemphis to get 1 more bit headroom */ /* ################### End FIXES switches ########################### */ /* #################### Start BASOP porting switches ############################ */ diff --git a/lib_com/preemph_fx.c b/lib_com/preemph_fx.c index 0184a4aa3b31c265b23594424419c4997f614362..e8dfb4018b74af83d82724af75a021350913c13e 100644 --- a/lib_com/preemph_fx.c +++ b/lib_com/preemph_fx.c @@ -39,7 +39,7 @@ void preemph_copy_fx( return; } - +#ifndef FIX_2015_PREMPH_SAT_ALT void preemph_copy_32fx( const Word16 x[], /* i : input signal Qx */ Word32 y[], /* o : output signal Qx */ @@ -66,7 +66,34 @@ void preemph_copy_32fx( return; } +#else +void preemph_copy_32fx2( + const Word16 x[], /* i : input signal Qx */ + Word32 y[], /* o : output signal Qx-1*/ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +) +{ + Word16 i, temp; + + temp = x[lg - 1]; /* Qx */ + move16(); + FOR( i = lg - 1; i > 0; i-- ) + { + y[i] = L_msu0_sat( L_mult( x[i], 16384 ), x[i - 1], mu ); /* Qx+16 */ + move16(); + } + y[0] = L_msu0_sat( L_mult( x[0], 16384 ), *mem, mu ); /* Qx+16 */ + move16(); + + *mem = temp; /* Qx */ + move16(); + + return; +} +#endif /*-------------------------------------------------------------* * preemph_ivas_fx() * diff --git a/lib_com/prot_fx.h b/lib_com/prot_fx.h index 85984d53d3fad418a929f2f4be27ce08936c17ee..2f0e059ec47a8ab08e886c3e103f9031a6261beb 100644 --- a/lib_com/prot_fx.h +++ b/lib_com/prot_fx.h @@ -2753,9 +2753,12 @@ void lag_wind_32( ); // preemp_fx.c -#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) +#define PREEMPH_FX( signal, mu, L, mem ) preemph_copy_fx( ( signal ), ( signal ), ( mu ), ( L ), ( mem ) ) +#ifndef FIX_2015_PREMPH_SAT_ALT #define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) - +#else +#define PREEMPH_32FX( signal, signal_out, mu, L, mem ) preemph_copy_32fx2( ( signal ), ( signal_out ), ( mu ), ( L ), ( mem ) ) +#endif void preemph_copy_fx( const Word16 x[], /* i : i signal Qx */ Word16 y[], /* o : output signal Qx */ @@ -2764,6 +2767,7 @@ void preemph_copy_fx( Word16 *mem /* i/o: memory (x[-1]) Qx */ ); +#ifndef FIX_2015_PREMPH_SAT_ALT void preemph_copy_32fx( const Word16 x[], /* i : i signal Qx */ Word32 y[], /* o : output signal Qx */ @@ -2771,6 +2775,15 @@ void preemph_copy_32fx( const Word16 lg, /* i : vector size Q0 */ Word16 *mem /* i/o: memory (x[-1]) Qx */ ); +#else +void preemph_copy_32fx2( + const Word16 x[], /* i : i signal Qx */ + Word32 y[], /* o : output signal Qx */ + const Word16 mu, /* i : preemphasis coefficient Q15 */ + const Word16 lg, /* i : vector size Q0 */ + Word16 *mem /* i/o: memory (x[-1]) Qx */ +); +#endif void E_UTIL_f_preemph2( Word16 shift, /* Q0 */ diff --git a/lib_enc/ivas_core_pre_proc_front_fx.c b/lib_enc/ivas_core_pre_proc_front_fx.c index fff73a248cae6a23d5095adc19466514cf07fbb8..0a12c05eabe8cc6caa45aa399fb3d67036fcdde4 100644 --- a/lib_enc/ivas_core_pre_proc_front_fx.c +++ b/lib_enc/ivas_core_pre_proc_front_fx.c @@ -714,9 +714,11 @@ ivas_error pre_proc_front_ivas_fx( *Q_new = add( *Q_new, Q_inp_const ); move16(); - +#ifndef FIX_2015_PREMPH_SAT_ALT Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( *Q_new, st->q_inp ) ); /* Q_new */ - +#else + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, sub( add( *Q_new, 1 ), st->q_inp ) ); /* Q_new */ +#endif Scale_sig( old_inp_12k8_fx, (Word16) ( preemp_start_idx - old_inp_12k8_fx ), sub( *Q_new, st->q_inp ) ); /* Q_new */ cldfbScale.hb_scale = cldfbScale.lb_scale; diff --git a/lib_enc/ivas_core_pre_proc_fx.c b/lib_enc/ivas_core_pre_proc_fx.c index 623b38e6897d070920ad1d445b424c850292c7b1..5246e2026918bdef1b32fcd08c32b165c0e9bd8e 100644 --- a/lib_enc/ivas_core_pre_proc_fx.c +++ b/lib_enc/ivas_core_pre_proc_fx.c @@ -1071,9 +1071,11 @@ ivas_error ivas_compute_core_buffers_fx( } st->Q_max_16k[i] = shift; move16(); - +#ifndef FIX_2015_PREMPH_SAT_ALT Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, *Q_new ); - +#else + Copy_Scale_sig32_16( sig_out, preemp_start_idx, preemp_len, add( *Q_new, 1 ) ); +#endif Scale_sig( old_inp_16k_fx, (Word16) ( preemp_start_idx - old_inp_16k_fx ), *Q_new ); } ELSE IF( GT_32( input_Fs, 8000 ) ) /* keep memory up-to-date in case of bitrate switching */