diff options
author | Paul B Mahol <onemda@gmail.com> | 2021-09-30 01:20:18 +0200 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2021-09-30 01:22:48 +0200 |
commit | a673761ce8bad005f2eb7b0dc584854a10b96e18 (patch) | |
tree | 39c847afd38bfc4731da6a10dce4cd5d8e571b40 /libavfilter | |
parent | 1ad4782d2a17d9fed38c0356f1c9f790973eec01 (diff) | |
download | ffmpeg-a673761ce8bad005f2eb7b0dc584854a10b96e18.tar.gz |
avfilter/vf_blend: add few more modes
Diffstat (limited to 'libavfilter')
-rw-r--r-- | libavfilter/blend.h | 4 | ||||
-rw-r--r-- | libavfilter/blend_modes.c | 4 | ||||
-rw-r--r-- | libavfilter/vf_blend.c | 10 |
3 files changed, 17 insertions, 1 deletions
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) |