diff --git a/lib_com/options.h b/lib_com/options.h index efe87417fcd749fe3147c95f4c2c7de94f83865b..65874503fb5760e3681fa2f15f91d371849fd167 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -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 */ #define FIX_2272_OOB_INDEXING_IN_LTP_PIT_SEARCH /* FhG: fix OOB index USAN error in TCX LTP pitch search */ #define FIX_2274_OOB_INDEXING_IN_CORRMATRIX /* FhG: fix OOB indexing complaint */ #define FIX_2278_OOB_INDEXING_IN_CLOSED_LOOP_PIT_SEARCH /* FhG: fix oob indexing USAN complaint */ diff --git a/lib_dec/ACcontextMapping_dec.c b/lib_dec/ACcontextMapping_dec.c index 9b2ea07e817e83816ef7fc3c34666085455007c5..a51fc1434b0dd77050771c109b1c91fe0ea2a4f2 100644 --- a/lib_dec/ACcontextMapping_dec.c +++ b/lib_dec/ACcontextMapping_dec.c @@ -662,6 +662,9 @@ int16_t RCcontextMapping_decode2_no_mem_s17_LCS( c = 12 + esc_nb; } +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + s = s & 0x0F; +#endif s = s << 4; /*Shift old 4 bits*/ s = s + c; /*replace last 4 bits*/ t = s & 0xFF; diff --git a/lib_enc/ACcontextMapping_enc.c b/lib_enc/ACcontextMapping_enc.c index fc960d8a08ddaca9e0149fe7d54e590aec7f5ac7..dd635d87c40045263ff0a4d8f059cc8b4129056e 100644 --- a/lib_enc/ACcontextMapping_enc.c +++ b/lib_enc/ACcontextMapping_enc.c @@ -963,6 +963,9 @@ void RCcontextMapping_encode2_no_mem_s17_LCS( } /*Shift old 4 bits, replace last 4 bits*/ +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + s = s & 0x0F; +#endif s = ( s << 4 ) + cp; t = s & 0xFF; @@ -1336,7 +1339,11 @@ int16_t RCcontextMapping_encode2_estimate_no_mem_s17_LCS( { cp = 12 + esc_nb; } + /*shift old bits and replace last 4 bits*/ +#ifdef FIX_1464_UBSAN_RC_CONTEXT_MAP + s = s & 0x0F; +#endif s = ( s << 4 ) + cp; t = s & 0xFF;