From: Ukn Unknown <4031821+uknunknown@users.noreply.github.com> Date: Sun, 26 Oct 2025 05:53:15 +0000 (-0700) Subject: fixes coverity 637369 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b23983f5dafff006ee83908915193c49deacca5;p=thirdparty%2Ftvheadend.git fixes coverity 637369 - threshold was defined as double representing the maximum representation that can fit in a int64_t later on --- diff --git a/src/transcoding/codec/internals.h b/src/transcoding/codec/internals.h index 9e7d89221..57d306428 100644 --- a/src/transcoding/codec/internals.h +++ b/src/transcoding/codec/internals.h @@ -168,11 +168,14 @@ AV_DICT_SET_INT((s), (d), "b", bitrate, AV_DICT_DONT_OVERWRITE); \ } while (0) +// Defines the maximum global quality value to avoid exceeding int64_t limits after multiplication +#define GLOBAL_QUALITY_MAX ((double)((1ULL) << 56)) + #define AV_DICT_SET_GLOBAL_QUALITY(s, d, v, a) \ do { \ AV_DICT_SET_FLAGS((s), (d), "+qscale"); \ int64_t global_quality = 0; \ - if (((v) <= (INT64_MAX / FF_QP2LAMBDA) && (v) > 0) || ((v) == 0 && (a) <= (INT64_MAX / FF_QP2LAMBDA))) \ + if (((v) <= GLOBAL_QUALITY_MAX && (v) > 0.0) || ((v) == 0.0 && (a) <= GLOBAL_QUALITY_MAX)) \ global_quality = (int64_t)(((v) ? (v) : (a)) * FF_QP2LAMBDA); \ else \ tvherror_transcode((s), "global_quality value too large to fit in int64_t: %g", ((v) ? (v) : (a)) * FF_QP2LAMBDA); \