diff options
author | Paul B Mahol <onemda@gmail.com> | 2021-09-29 19:10:29 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-09-29 19:33:59 +0200 |
commit | 8ebcff91118e7b533318b6244d58143da347ce10 (patch) | |
tree | 185e4d31e7d8e46ca120f61b6894079f2598edb4 | |
parent | f3b07b8b124c78d6f5f8189621900b73b268e1be (diff) | |
download | ffmpeg-8ebcff91118e7b533318b6244d58143da347ce10.tar.gz |
avfilter/vf_blend: add geometric mode
-rw-r--r-- | doc/filters.texi | 1 | ||||
-rw-r--r-- | libavfilter/blend.h | 1 | ||||
-rw-r--r-- | libavfilter/blend_modes.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_blend.c | 2 |
4 files changed, 8 insertions, 0 deletions
diff --git a/doc/filters.texi b/doc/filters.texi index b7912b6567..9bac3feb33 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -7543,6 +7543,7 @@ Available values for component modes are: @item freeze @item exclusion @item extremity +@item geometric @item glow @item hardlight @item hardmix diff --git a/libavfilter/blend.h b/libavfilter/blend.h index a9a436a6da..a955126687 100644 --- a/libavfilter/blend.h +++ b/libavfilter/blend.h @@ -60,6 +60,7 @@ enum BlendMode { BLEND_FREEZE, BLEND_EXTREMITY, BLEND_SOFTDIFFERENCE, + BLEND_GEOMETRIC, BLEND_NB }; diff --git a/libavfilter/blend_modes.c b/libavfilter/blend_modes.c index d75560185c..9236559d19 100644 --- a/libavfilter/blend_modes.c +++ b/libavfilter/blend_modes.c @@ -52,6 +52,7 @@ #undef SCREEN #undef BURN #undef DODGE +#undef GEOMETRIC #undef INT2FLOAT #undef FLOAT2INT #undef MDIV @@ -61,6 +62,7 @@ #define SCREEN(x, a, b) (MAX - (x) * ((MAX - (a)) * (MAX - (b)) / MAX)) #define BURN(a, b) (((a) == 0) ? (a) : FFMAX(0, MAX - ((MAX - (b)) << DEPTH) / (a))) #define DODGE(a, b) (((a) == MAX) ? (a) : FFMIN(MAX, (((b) << DEPTH) / (MAX - (a))))) +#define GEOMETRIC(a, b) (lrintf(sqrtf((unsigned)A * B))) #define INT2FLOAT(x) (x) #define FLOAT2INT(x) (x) #define MDIV (0.125f * (1 << DEPTH)) @@ -69,6 +71,7 @@ #define SCREEN(x, a, b) (1.0 - (x) * ((1.0 - (a)) * (1.0 - (b)) / 1.0)) #define BURN(a, b) (((a) <= 0.0) ? (a) : FFMAX(0.0, 1.0 - (1.0 - (b)) / (a))) #define DODGE(a, b) (((a) >= 1.0) ? (a) : FFMIN(1.0, ((b) / (1.0 - (a))))) +#define GEOMETRIC(a, b) (sqrtf(fmaxf(A, 0) * fmaxf(B, 0))) #define INT2FLOAT(x) av_int2float(x) #define FLOAT2INT(x) av_float2int(x) #define MDIV 0.125f @@ -140,3 +143,4 @@ fn(xor, INT2FLOAT(FLOAT2INT(A) ^ FLOAT2INT(B))) 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)) diff --git a/libavfilter/vf_blend.c b/libavfilter/vf_blend.c index 43595a1363..c00fb12839 100644 --- a/libavfilter/vf_blend.c +++ b/libavfilter/vf_blend.c @@ -132,6 +132,7 @@ static const AVOption blend_options[] = { { "vividlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_VIVIDLIGHT}, 0, 0, FLAGS, "mode" }, { "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" }, { "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 }, @@ -396,6 +397,7 @@ static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param) 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_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \ } \ } DEFINE_INIT_BLEND_FUNC(8, 8) |