From 3e04746ec335a2fe3839aab5f40ccd4528e279a0 Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Tue, 2 Jun 2015 19:12:45 +0000 Subject: [PATCH] avfilter/vf_blend: add hardmix mode Signed-off-by: Paul B Mahol --- doc/filters.texi | 1 + libavfilter/vf_blend.c | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/doc/filters.texi b/doc/filters.texi index a79979360a..333244df3b 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -2749,6 +2749,7 @@ Available values for component modes are: @item dodge @item exclusion @item hardlight +@item hardmix @item lighten @item multiply @item negation diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index 33d3f283d6..8cfab08797 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -59,6 +59,7 @@ enum BlendMode { BLEND_SUBTRACT, BLEND_VIVIDLIGHT, BLEND_XOR, + BLEND_HARDMIX, BLEND_NB }; @@ -117,6 +118,7 @@ typedef struct { { "dodge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE}, 0, 0, FLAGS, "mode" },\ { "exclusion", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION}, 0, 0, FLAGS, "mode" },\ { "hardlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT}, 0, 0, FLAGS, "mode" },\ + { "hardmix", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDMIX}, 0, 0, FLAGS, "mode" },\ { "lighten", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN}, 0, 0, FLAGS, "mode" },\ { "multiply", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY}, 0, 0, FLAGS, "mode" },\ { "negation", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION}, 0, 0, FLAGS, "mode" },\ @@ -201,6 +203,7 @@ DEFINE_BLEND(difference128, av_clip_uint8(128 + A - B)) DEFINE_BLEND(screen, SCREEN(1, A, B)) DEFINE_BLEND(overlay, (A < 128) ? MULTIPLY(2, A, B) : SCREEN(2, A, B)) DEFINE_BLEND(hardlight, (B < 128) ? MULTIPLY(2, B, A) : SCREEN(2, B, A)) +DEFINE_BLEND(hardmix, (A < (255 - B)) ? 0: 255) DEFINE_BLEND(darken, FFMIN(A, B)) DEFINE_BLEND(lighten, FFMAX(A, B)) DEFINE_BLEND(divide, av_clip_uint8(((float)A / ((float)B) * 255))) @@ -326,6 +329,7 @@ static av_cold int init(AVFilterContext *ctx) case BLEND_DODGE: param->blend = blend_dodge; break; case BLEND_EXCLUSION: param->blend = blend_exclusion; break; case BLEND_HARDLIGHT: param->blend = blend_hardlight; break; + case BLEND_HARDMIX: param->blend = blend_hardmix; break; case BLEND_LIGHTEN: param->blend = blend_lighten; break; case BLEND_MULTIPLY: param->blend = blend_multiply; break; case BLEND_NEGATION: param->blend = blend_negation; break;