[FFmpeg-cvslog] avfilter/vf_blend: add harmonic mode

Paul B Mahol git at videolan.org
Wed Sep 29 20:34:56 EEST 2021


ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Wed Sep 29 19:19:06 2021 +0200| [df163487d0a71d7f65f7602e4df6ab68e8fcc0fa] | committer: Paul B Mahol

avfilter/vf_blend: add harmonic mode

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=df163487d0a71d7f65f7602e4df6ab68e8fcc0fa
---

 doc/filters.texi          | 1 +
 libavfilter/blend.h       | 1 +
 libavfilter/blend_modes.c | 1 +
 libavfilter/vf_blend.c    | 2 ++
 4 files changed, 5 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index 9bac3feb33..0813232480 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -7547,6 +7547,7 @@ Available values for component modes are:
 @item glow
 @item hardlight
 @item hardmix
+ at item harmonic
 @item heat
 @item lighten
 @item linearlight
diff --git a/libavfilter/blend.h b/libavfilter/blend.h
index a955126687..85c287a5d8 100644
--- a/libavfilter/blend.h
+++ b/libavfilter/blend.h
@@ -61,6 +61,7 @@ enum BlendMode {
     BLEND_EXTREMITY,
     BLEND_SOFTDIFFERENCE,
     BLEND_GEOMETRIC,
+    BLEND_HARMONIC,
     BLEND_NB
 };
 
diff --git a/libavfilter/blend_modes.c b/libavfilter/blend_modes.c
index 9236559d19..9ab2d4420a 100644
--- a/libavfilter/blend_modes.c
+++ b/libavfilter/blend_modes.c
@@ -144,3 +144,4 @@ fn(vividlight, (A < HALF) ? BURN(2 * A, B) : DODGE(2 * (A - HALF), B))
 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))
diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c
index c00fb12839..09a10ff0e0 100644
--- a/libavfilter/vf_blend.c
+++ b/libavfilter/vf_blend.c
@@ -133,6 +133,7 @@ static const AVOption blend_options[] = {
     { "xor",        "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_XOR},        0, 0, FLAGS, "mode" },
     { "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" },
     { "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 },
@@ -398,6 +399,7 @@ static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param)
     case BLEND_XOR:          param->blend = blend_xor_##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;   \
     }                                                                                 \
 }
 DEFINE_INIT_BLEND_FUNC(8, 8)



More information about the ffmpeg-cvslog mailing list