1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

avfilter/vf_blend: add few more modes

This commit is contained in:
Paul B Mahol 2021-09-30 01:20:18 +02:00
parent 1ad4782d2a
commit a673761ce8
4 changed files with 24 additions and 4 deletions

View File

@ -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

View File

@ -62,6 +62,10 @@ enum BlendMode {
BLEND_SOFTDIFFERENCE,
BLEND_GEOMETRIC,
BLEND_HARMONIC,
BLEND_BLEACH,
BLEND_STAIN,
BLEND_INTERPOLATE,
BLEND_HARDOVERLAY,
BLEND_NB
};

View File

@ -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)))

View File

@ -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 },
@ -400,6 +404,10 @@ static av_cold void init_blend_func_##depth##_##nbits##bit(FilterParams *param)
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)