avfilter/vf_blend: add harmonic mode

This commit is contained in:
Paul B Mahol 2021-09-29 19:19:06 +02:00
parent 8ebcff9111
commit df163487d0
4 changed files with 5 additions and 0 deletions

View File

@ -7547,6 +7547,7 @@ Available values for component modes are:
@item glow
@item hardlight
@item hardmix
@item harmonic
@item heat
@item lighten
@item linearlight

View File

@ -61,6 +61,7 @@ enum BlendMode {
BLEND_EXTREMITY,
BLEND_SOFTDIFFERENCE,
BLEND_GEOMETRIC,
BLEND_HARMONIC,
BLEND_NB
};

View File

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

View File

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