From 017163c332acd2a1477dc703f68dbefadebbaaa1 Mon Sep 17 00:00:00 2001 From: Markus Multrus Date: Thu, 7 Aug 2025 21:04:45 +0200 Subject: [PATCH] port of patch --- lib_com/options.h | 1 + lib_dec/jbm_jb4sb.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib_com/options.h b/lib_com/options.h index 31f712963..26476f7b0 100644 --- a/lib_com/options.h +++ b/lib_com/options.h @@ -189,6 +189,7 @@ #define NONBE_FIX_1028_1DB_TCX_LEVEL_DROP /* VA: Harmonize the logic setting LP weighting factor between TCX encoder and TCX decoder */ #define CONF_DISTATT /* Eri: Make distance attenuation configurable */ #define FIX_1052_EXT_OUTPUT /* VA: issue 1052: define EXT decoder output configuration for stereo and MC formats */ +#define NONBE_1215_FIX_JBM_MAX_SCALING /* FhG: issue 1215: Fix assert hit in a specific VoIP decoder config. Caused by integer overflow in max scaling calculation. */ #define NONBE_FIX_1070_USAN_SEGFAULT_MC_TO_BIN_BTSW_HEADROT /* fix 1070 USAN: nullptr-with-offset and Segfaults in 7_1_4 to BINAURAL and BINAURAL_ROOM_REVERB decoding with bitrate switching and head rotation*/ diff --git a/lib_dec/jbm_jb4sb.c b/lib_dec/jbm_jb4sb.c index 1c6fdf0fc..8d45414cb 100644 --- a/lib_dec/jbm_jb4sb.c +++ b/lib_dec/jbm_jb4sb.c @@ -807,7 +807,15 @@ static void JB4_adaptActivePlayout( ( dropRateMax - dropRateMin ) / dropGapMax + dropRateMin; *scale = ( 1000 - rate ) / 10; +#ifdef NONBE_1215_FIX_JBM_MAX_SCALING + /* Limit max scaling to the duration of one frame. APA will not exceed this limit + * anyway due to the 50% limitation of APA_MIN_SCALE and APA_MAX_SCALE. Limiting + * the value to a sensible range here avoids integer overflows at later stages when + * converting maxScaling from milliseconds to samples. */ + *maxScaling = JB4_MIN( currPlayoutDelay - targetMax, 1000 / IVAS_NUM_FRAMES_PER_SEC ); +#else *maxScaling = currPlayoutDelay - targetMax; +#endif } } } @@ -823,7 +831,15 @@ static void JB4_adaptActivePlayout( currPlayoutDelay < targetMaxStretch && currPlayoutDelay < (uint32_t) ( 110 + h->rfDelay / 4 ) ) { *scale = 120; +#ifdef NONBE_1215_FIX_JBM_MAX_SCALING + /* Limit max scaling to the duration of one frame. APA will not exceed this limit + * anyway due to the 50% limitation of APA_MIN_SCALE and APA_MAX_SCALE. Limiting + * the value to a sensible range here avoids integer overflows at later stages when + * converting maxScaling from milliseconds to samples. */ + *maxScaling = JB4_MIN( targetMaxStretch - currPlayoutDelay, 1000 / IVAS_NUM_FRAMES_PER_SEC ); +#else *maxScaling = targetMaxStretch - currPlayoutDelay; +#endif } } -- GitLab