[FFmpeg-cvslog] avfilter/vf_blend: add few more modes
Paul B Mahol
git at videolan.org
Thu Sep 30 02:27:14 EEST 2021
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Thu Sep 30 01:20:18 2021 +0200| [a673761ce8bad005f2eb7b0dc584854a10b96e18] | committer: Paul B Mahol
avfilter/vf_blend: add few more modes
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a673761ce8bad005f2eb7b0dc584854a10b96e18
---
doc/filters.texi | 10 +++++++---
libavfilter/blend.h | 4 ++++
libavfilter/blend_modes.c | 4 ++++
libavfilter/vf_blend.c | 10 +++++++++-
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
- at item grainmerge
@item and
@item average
+ at item bleach
@item burn
@item darken
@item difference
- at item grainextract
@item divide
@item dodge
- at item freeze
@item exclusion
@item extremity
+ at item freeze
@item geometric
@item glow
+ at item grainextract
+ at item grainmerge
@item hardlight
@item hardmix
+ at item hardoverlay
@item harmonic
@item heat
+ at item interpolate
@item lighten
@item linearlight
@item multiply
@@ -7563,6 +7566,7 @@ Available values for component modes are:
@item screen
@item softdifference
@item softlight
+ at 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)
More information about the ffmpeg-cvslog
mailing list