Commit 6c176696 authored by sagnowski's avatar sagnowski
Browse files

Merge branch '2173-ubsan-in-jbm-pcmdsp-apa-fx-c' into 'main'

Resolve "UBSAN in jbm_pcmdsp_apa_fx.c"

Closes #2173

See merge request !2506
parents 120c6cd3 b5bbda93
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@
#define FIX_2178_FL_TO_FX_WITH_OBJ_EDIT_FILE_INTERFACE       /* Nokia: Fixes float  to fx conversion in decoder app with object edit file interface */
#define FIX_2070_JBM_TC_CHANNEL_RESCALING_ISSUE              /* Eri/Orange: scale_sig32 problem on p_tc_fx[] */

#define FIX_2173_UBSAN_IN_JBM_PCMDSP_APA                     /* FhG: Fix UBSAN problems in jbm_pcmdsp_apa_fx.c */
#define FIX_1947_DEC_HIGH_MLD_FOR_STEREO2MONO                /* FhG: Make Q-factor of synth_16_fx and output_16_fx dynamic to prevent overflow in HQ_CORE mode */
/* ################### End FIXES switches ########################### */

+9 −1
Original line number Diff line number Diff line
@@ -127,7 +127,11 @@ struct apa_state_t
    UWord16 qualityred;      /* quality reduction threshold */
    UWord16 qualityrise;     /* quality rising for adaptive quality thresholds */

#ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA
    Word16 last_pitch; /* last pitch/sync position */
#else
    UWord16 last_pitch;     /* last pitch/sync position */
#endif
    UWord16 bad_frame_count;  /* # frames before quality threshold is lowered */
    UWord16 good_frame_count; /* # scaled frames */

@@ -1392,7 +1396,11 @@ static Word8 logarithmic_search_fx( const apa_state_t *ps,

    DO
    {
#ifdef FIX_2173_UBSAN_IN_JBM_PCMDSP_APA
        coeff_max = INT32_MIN; /* will always be overwritten with result of first correlation */
#else
        coeff_max = 0x80000000; /* will always be overwritten with result of first correlation */
#endif
        move32();

        FOR( i = s_start; i < s_start + inlen; i += css * ps->num_channels )