* [FFmpeg-devel] [PR] swscale/swscale: force SwsDither and SwsAlphaBlend to 32 bits (PR #21594)
@ 2026-01-26 16:19 Zhao Zhili via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: Zhao Zhili via ffmpeg-devel @ 2026-01-26 16:19 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Zhao Zhili
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 <zhilizhao@tencent.com>
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 -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-01-26 16:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-26 16:19 [FFmpeg-devel] [PR] swscale/swscale: force SwsDither and SwsAlphaBlend to 32 bits (PR #21594) Zhao Zhili via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git