summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2021-09-30 01:20:18 +0200
committerPaul B Mahol <onemda@gmail.com>2021-09-30 01:22:48 +0200
commita673761ce8bad005f2eb7b0dc584854a10b96e18 (patch)
tree39c847afd38bfc4731da6a10dce4cd5d8e571b40
parent1ad4782d2a17d9fed38c0356f1c9f790973eec01 (diff)
avfilter/vf_blend: add few more modes
-rw-r--r--doc/filters.texi10
-rw-r--r--libavfilter/blend.h4
-rw-r--r--libavfilter/blend_modes.c4
-rw-r--r--libavfilter/vf_blend.c10
4 files changed, 24 insertions, 4 deletions
diff --git a/doc/filters.texi b/doc/filters.texi
index 0813232480..cbec749ce8 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7531,24 +7531,27 @@ of @var{all_mode}. Default value is @code{normal}.
Available values for component modes are:
@table @samp
@item addition
-@item grainmerge
@item and
@item average
+@item bleach
@item burn
@item darken
@item difference
-@item grainextract
@item divide
@item dodge
-@item freeze
@item exclusion
@item extremity
+@item freeze
@item geometric
@item glow
+@item grainextract
+@item grainmerge
@item hardlight
@item hardmix
+@item hardoverlay
@item harmonic
@item heat
+@item interpolate
@item lighten
@item linearlight
@item multiply
@@ -7563,6 +7566,7 @@ Available values for component modes are:
@item screen
@item softdifference
@item softlight
+@item stain
@item subtract
@item vividlight
@item xor
diff --git a/libavfilter/blend.h b/libavfilter/blend.h
index 85c287a5d8..ff417650cf 100644
--- a/libavfilter/blend.h
+++ b/libavfilter/blend.h
@@ -62,6 +62,10 @@ enum BlendMode {
BLEND_SOFTDIFFERENCE,
BLEND_GEOMETRIC,
BLEND_HARMONIC,
+ BLEND_BLEACH,
+ BLEND_STAIN,
+ BLEND_INTERPOLATE,
+ BLEND_HARDOVERLAY,
BLEND_NB
};
diff --git a/libavfilter/blend_modes.c b/libavfilter/blend_modes.c
index 9ab2d4420a..64cd6e8a54 100644
--- a/libavfilter/blend_modes.c
+++ b/libavfilter/blend_modes.c
@@ -145,3 +145,7 @@ fn(linearlight,CLIP((B < HALF) ? B + 2 * A - MAX : B + 2 * (A - HALF)))
fn(softdifference,CLIP((A > B) ? (B == MAX) ? 0 : (A - B) * MAX / (MAX - B) : (B == 0) ? 0 : (B - A) * MAX / B))
fn(geometric, GEOMETRIC(A, B))
fn(harmonic, A == 0 && B == 0 ? 0 : 2LL * A * B / (A + B))
+fn(bleach, (MAX - B) + (MAX - A) - MAX)
+fn(stain, 2 * MAX - A - B)
+fn(interpolate,lrintf(MAX * (2 - cosf(A * M_PI / MAX) - cosf(B * M_PI / MAX)) * 0.25f))
+fn(hardoverlay,A == MAX ? MAX : FFMIN(MAX, MAX * B / (2 * MAX - 2 * A) * (A > HALF) + 2 * A * B / MAX * (A <= HALF)))
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index 09a10ff0e0..ddfd6cf0f0 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -134,6 +134,10 @@ static const AVOption blend_options[] = {
{ "softdifference","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTDIFFERENCE}, 0, 0, FLAGS, "mode" },
{ "geometric", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GEOMETRIC}, 0, 0, FLAGS, "mode" },
{ "harmonic", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARMONIC}, 0, 0, FLAGS, "mode" },
+ { "bleach", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_BLEACH}, 0, 0, FLAGS, "mode" },
+ { "stain", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_STAIN}, 0, 0, FLAGS, "mode" },
+ { "interpolate","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_INTERPOLATE},0, 0, FLAGS, "mode" },
+ { "hardoverlay","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDOVERLAY},0, 0, FLAGS, "mode" },
{ "c0_expr", "set color component #0 expression", OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{ "c1_expr", "set color component #1 expression", OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
{ "c2_expr", "set color component #2 expression", OFFSET(params[2].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
@@ -397,9 +401,13 @@ static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param)
case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \
case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \
case BLEND_XOR: param->blend = blend_xor_##depth##bit; break; \
- case BLEND_SOFTDIFFERENCE:param->blend = blend_softdifference_##depth##bit; break;\
+ case BLEND_SOFTDIFFERENCE:param->blend=blend_softdifference_##depth##bit;break; \
case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \
case BLEND_HARMONIC: param->blend = blend_harmonic_##depth##bit; break; \
+ case BLEND_BLEACH: param->blend = blend_bleach_##depth##bit; break; \
+ case BLEND_STAIN: param->blend = blend_stain_##depth##bit; break; \
+ case BLEND_INTERPOLATE: param->blend = blend_interpolate_##depth##bit; break; \
+ case BLEND_HARDOVERLAY: param->blend = blend_hardoverlay_##depth##bit; break; \
} \
}
DEFINE_INIT_BLEND_FUNC(8, 8)