[FFmpeg-devel] [PATCH] swscale: set sane alpha blending defaults

wm4 nfxjfg at googlemail.com
Sun Aug 30 17:34:50 CEST 2015


The old default for alpha -> non-alpha conversion was discarding the
alpha channel without. This meant that parts of the image which were not
meant to be visible became visible. This was a problem for video which
actually contained and used alpha. It can affect PNGs with an alpha
channel as well - PNGs often have garbage data in completely transparent
regions of the image.

Change the default to blend with black, which gives generally expected
results.

Fixes track issue #4746.
---
 libswscale/options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libswscale/options.c b/libswscale/options.c
index 18a6594..717b6a4 100644
--- a/libswscale/options.c
+++ b/libswscale/options.c
@@ -78,7 +78,7 @@ static const AVOption swscale_options[] = {
     { "gamma",           "gamma correct scaling", OFFSET(gamma_flag),        AV_OPT_TYPE_INT,    { .i64  = 0                  }, 0,       INT_MAX,        VE, "gamma" },
     { "true",            "enable",                        0,                 AV_OPT_TYPE_CONST,  { .i64  = 1                  }, INT_MIN, INT_MAX,        VE, "gamma" },
     { "false",           "disable",                       0,                 AV_OPT_TYPE_CONST,  { .i64  = 0                  }, INT_MIN, INT_MAX,        VE, "gamma" },
-    { "alphablend",      "mode for alpha -> non alpha",   OFFSET(alphablend),AV_OPT_TYPE_INT,    { .i64  = SWS_ALPHA_BLEND_NONE}, 0,       SWS_ALPHA_BLEND_NB-1, VE, "alphablend" },
+    { "alphablend",      "mode for alpha -> non alpha",   OFFSET(alphablend),AV_OPT_TYPE_INT,    { .i64  = SWS_ALPHA_BLEND_UNIFORM}, 0,       SWS_ALPHA_BLEND_NB-1, VE, "alphablend" },
     { "none",            "ignore alpha",                  0,                 AV_OPT_TYPE_CONST,  { .i64  = SWS_ALPHA_BLEND_NONE}, INT_MIN, INT_MAX,       VE, "alphablend" },
     { "uniform_color",   "blend onto a uniform color",    0,                 AV_OPT_TYPE_CONST,  { .i64  = SWS_ALPHA_BLEND_UNIFORM},INT_MIN, INT_MAX,     VE, "alphablend" },
     { "checkerboard",    "blend onto a checkerboard",     0,                 AV_OPT_TYPE_CONST,  { .i64  = SWS_ALPHA_BLEND_CHECKERBOARD},INT_MIN, INT_MAX,     VE, "alphablend" },
-- 
2.5.0



More information about the ffmpeg-devel mailing list