aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/swscale_internal.h
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-10-10 11:57:44 +0200
committerNiklas Haas <git@haasn.dev>2024-11-21 12:47:43 +0100
commit10d1be262126f1699a89b54cf5f23a5370c57cb5 (patch)
tree74220475712f9494a548f87ca2713d5bd4f3c1e6 /libswscale/swscale_internal.h
parent55d5eae411b5b29e27ab0b4fbbeac71f656a69b3 (diff)
downloadffmpeg-10d1be262126f1699a89b54cf5f23a5370c57cb5.tar.gz
swscale/internal: use static_assert for enforcing offsets
Instead of sprinkling av_assert0 into random init functions. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
Diffstat (limited to 'libswscale/swscale_internal.h')
-rw-r--r--libswscale/swscale_internal.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 0035168997..0ab4e67270 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -22,6 +22,7 @@
#define SWSCALE_SWSCALE_INTERNAL_H
#include <stdatomic.h>
+#include <assert.h>
#include "config.h"
#include "swscale.h"
@@ -705,6 +706,16 @@ struct SwsInternal {
};
//FIXME check init (where 0)
+static_assert(offsetof(SwsInternal, redDither) + DITHER32_INT == offsetof(SwsInternal, dither32),
+ "dither32 must be at the same offset as redDither + DITHER32_INT");
+
+#if ARCH_X86_64
+/* x86 yuv2gbrp uses the SwsInternal for yuv coefficients
+ if struct offsets change the asm needs to be updated too */
+static_assert(offsetof(SwsInternal, yuv2rgb_y_offset) == 40292,
+ "yuv2rgb_y_offset must be updated in x86 asm");
+#endif
+
SwsFunc ff_yuv2rgb_get_func_ptr(SwsInternal *c);
int ff_yuv2rgb_c_init_tables(SwsInternal *c, const int inv_table[4],
int fullRange, int brightness,