]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Fixes coverity 637368
authorUkn Unknown <4031821+uknunknown@users.noreply.github.com>
Fri, 24 Oct 2025 19:17:19 +0000 (12:17 -0700)
committerFlole <Flole998@users.noreply.github.com>
Sat, 25 Oct 2025 00:28:32 +0000 (02:28 +0200)
- threshold was defined as double representing the maximum representation that can fit in a int64_t later on
- number is ridiculously large so is only a theoretical limit.

src/transcoding/codec/internals.h

index 34add314de627a39ea727be3f710097084932822..76fc72d12649999f6d42d7482c09648b22368ad4 100644 (file)
 #define AV_DICT_SET_FLAGS_GLOBAL_HEADER(s, d) \
     AV_DICT_SET_FLAGS((s), (d), "+global_header")
 
+// Defines the maximum bitrate value to avoid exceeding int64_t limits after multiplication
+#define BITRATE_MAX ((double)((1ULL) << 53))
+
 #define AV_DICT_SET_BIT_RATE(s, d, v) \
     do { \
         int64_t bitrate = 0; \
-        if ((v) <= (INT64_MAX / 1000) && (v) >= 0) \
-            bitrate = (int64_t)((v) * 1000); \
+        if ((v) <= BITRATE_MAX && (v) >= 0.0) \
+            bitrate = (int64_t)((v) * 1000.0); \
         else \
-            tvherror_transcode((s), "bitrate value too large to fit in int64_t: %g or negative", (v) * 1000); \
+            tvherror_transcode((s), "bitrate value too large to fit in int64_t: %g or negative", (v) * 1000.0); \
         AV_DICT_SET_INT((s), (d), "b", bitrate, AV_DICT_DONT_OVERWRITE); \
     } while (0)