Commit 701835f0 authored by multrus's avatar multrus
Browse files

fix for UBSAN issue in RC context mapping

parent 867217ee
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -162,6 +162,7 @@
/*#define FIX_I4_OL_PITCH*/                             /* fix open-loop pitch used for EVS core switching */
#define TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR      /* FhG: Temporary workaround for incorrect implementation of decoder flush with split rendering */
#define NONBE_1122_KEEP_EVS_MODE_UNCHANGED              /* FhG: Disables fix for issue 1122 in EVS mode to keep BE tests green. This switch should be removed once the 1122 fix is added to EVS via a CR.  */
#define FIX_1464_UBSAN_RC_CONTEXT_MAP                   /* FhG: BE UBSAN fix for float issue 1464 in the TCX range coder */

/* #################### End BE switches ################################## */

+8 −0
Original line number Diff line number Diff line
@@ -560,7 +560,11 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(
    else /* if(!hm_cfg) */
    {
        int16_t c, rateQ;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        uint32_t s;
#else
        uint16_t s;
#endif

        /* Rate flag */
        if ( nbbits > 400 )
@@ -664,7 +668,11 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS(

            s = s << 4; /*Shift old 4 bits*/
            s = s + c;  /*replace last 4 bits*/
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            t = (uint16_t) ( s & 0xFF );
#else
            t = s & 0xFF;
#endif
        }

        /* Decode signs */
+16 −0
Original line number Diff line number Diff line
@@ -870,7 +870,11 @@ void RCcontextMapping_encode2_no_mem_s17_LCS(
    {
        int16_t cp;
        int16_t esc_nb, rateQ;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        uint32_t s;
#else
        uint16_t s;
#endif

        /* Rate flag */
        if ( nbbits > 400 )
@@ -964,7 +968,11 @@ void RCcontextMapping_encode2_no_mem_s17_LCS(

            /*Shift old 4 bits, replace last 4 bits*/
            s = ( s << 4 ) + cp;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            t = (uint16_t) ( s & 0xFF );
#else
            t = s & 0xFF;
#endif

        } /*end of the 2-tuples loop*/
    }
@@ -1236,7 +1244,11 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
    else /* if (!hm_cfg) */
    {
        int16_t esc_nb, cp, rateQ;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
        uint32_t s;
#else
        uint16_t s;
#endif
        int16_t tot_bits2;
        int16_t overflow_flag = 0;

@@ -1338,7 +1350,11 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS(
            }
            /*shift old bits and replace last 4 bits*/
            s = ( s << 4 ) + cp;
#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP
            t = (uint16_t) ( s & 0xFF );
#else
            t = s & 0xFF;
#endif

        } /*end of the 2-tuples loop*/