]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
fixes coverity 637369
authorUkn Unknown <4031821+uknunknown@users.noreply.github.com>
Sun, 26 Oct 2025 05:53:15 +0000 (22:53 -0700)
committerFlole <Flole998@users.noreply.github.com>
Fri, 14 Nov 2025 16:29:08 +0000 (17:29 +0100)
- threshold was defined as double representing the maximum representation that can fit in a int64_t later on

src/transcoding/codec/internals.h

index 9e7d892217778f7f2d3388f04bf04e8a2317881c..57d3064282259847e049bdbd87aa8d6060fc5ad1 100644 (file)
         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); \