PR #21594 opened by Zhao Zhili (quink) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21594 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21594.patch
The 'sws_dither' and 'alphablend' options access 'SwsDither' and 'SwsAlphaBlend' enum fields as integers. This is unsafe when the code is compiled with -fshort-enums, as the enum size might be smaller than an int. Since the 'dither' and 'alpha_blend' struct members are part of the public API, their types cannot be easily changed. To ensure safe integer access and maintain ABI compatibility across different compiler settings, a MAX_ENUM value is added to force the enums to a 32-bit underlying type. >From aa03934bcaf51b3d4e6ff5da1abf64c4cd14a885 Mon Sep 17 00:00:00 2001 From: Zhao Zhili <[email protected]> Date: Mon, 26 Jan 2026 23:50:50 +0800 Subject: [PATCH] swscale/swscale: force SwsDither and SwsAlphaBlend to 32 bits The 'sws_dither' and 'alphablend' options access 'SwsDither' and 'SwsAlphaBlend' enum fields as integers. This is unsafe when the code is compiled with -fshort-enums, as the enum size might be smaller than an int. Since the 'dither' and 'alpha_blend' struct members are part of the public API, their types cannot be easily changed. To ensure safe integer access and maintain ABI compatibility across different compiler settings, a MAX_ENUM value is added to force the enums to a 32-bit underlying type. --- libswscale/swscale.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libswscale/swscale.h b/libswscale/swscale.h index 345e5458ce..495d500f14 100644 --- a/libswscale/swscale.h +++ b/libswscale/swscale.h @@ -82,6 +82,7 @@ typedef enum SwsDither { SWS_DITHER_A_DITHER, /* arithmetic addition */ SWS_DITHER_X_DITHER, /* arithmetic xor */ SWS_DITHER_NB, /* not part of the ABI */ + SWS_DITHER_MAX_ENUM = 0x7FFFFFFF, /* force size to 32 bits, not a valid dither type */ } SwsDither; typedef enum SwsAlphaBlend { @@ -89,6 +90,7 @@ typedef enum SwsAlphaBlend { SWS_ALPHA_BLEND_UNIFORM, SWS_ALPHA_BLEND_CHECKERBOARD, SWS_ALPHA_BLEND_NB, /* not part of the ABI */ + SWS_ALPHA_BLEND_MAX_ENUM = 0x7FFFFFFF, /* force size to 32 bits, not a valid blend mode */ } SwsAlphaBlend; typedef enum SwsFlags { -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
