[FFmpeg-devel] [PATCH 09/19] swscale/internal: use static_assert for enforcing offsets
Niklas Haas
ffmpeg at haasn.xyz
Sun Oct 13 22:16:18 EEST 2024
On Sun, 13 Oct 2024 18:46:32 +0200 Michael Niedermayer <michael at niedermayer.cc> wrote:
> On Fri, Oct 11, 2024 at 12:26:56AM +0200, Niklas Haas wrote:
> > From: Niklas Haas <git at haasn.dev>
> >
> > Instead of sprinkling av_assert0 into random init functions.
> >
> > Sponsored-by: Sovereign Tech Fund
> > Signed-off-by: Niklas Haas <git at haasn.dev>
> > ---
> > libswscale/swscale_internal.h | 9 +++++++++
> > libswscale/utils.c | 3 ++-
> > 2 files changed, 11 insertions(+), 1 deletion(-)
>
> braks build on ARM
>
> make
> CC libswscale/alphablend.o
> In file included from src/libavutil/internal.h:39:0,
> from src/libavutil/common.h:50,
> from src/libavutil/avutil.h:301,
> from src/libswscale/swscale.h:33,
> from src/libswscale/swscale_internal.h:28,
> from src/libswscale/alphablend.c:21:
> src/libswscale/swscale_internal.h:713:1: error: static assertion failed: "yuv2rgb_y_offset must be updated in x86 asm"
> static_assert(offsetof(SwsInternal, yuv2rgb_y_offset) == 40292,
> ^
> make: *** [src/ffbuild/common.mak:81: libswscale/alphablend.o] Error 1
Fixed by
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index e4cdc1c7a5..a43259515c 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -675,10 +675,12 @@ struct SwsInternal {
static_assert(offsetof(SwsInternal, redDither) + DITHER32_INT == offsetof(SwsInternal, dither32),
"dither32 must be at the same offset as redDither + DITHER32_INT");
+#if ARCH_X86
/* 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) == 40348,
"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],
More information about the ffmpeg-devel
mailing list