Commit b8c0cf78 authored by Paul B Mahol's avatar Paul B Mahol

avfilter/vf_blend: add linearlight and glow mode

Signed-off-by: 's avatarPaul B Mahol <onemda@gmail.com>
parent ce1761db
......@@ -2748,9 +2748,11 @@ Available values for component modes are:
@item divide
@item dodge
@item exclusion
@item glow
@item hardlight
@item hardmix
@item lighten
@item linearlight
@item multiply
@item negation
@item normal
......
......@@ -60,6 +60,8 @@ enum BlendMode {
BLEND_VIVIDLIGHT,
BLEND_XOR,
BLEND_HARDMIX,
BLEND_LINEARLIGHT,
BLEND_GLOW,
BLEND_NB
};
......@@ -117,9 +119,11 @@ typedef struct {
{ "divide", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DIVIDE}, 0, 0, FLAGS, "mode" },\
{ "dodge", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_DODGE}, 0, 0, FLAGS, "mode" },\
{ "exclusion", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_EXCLUSION}, 0, 0, FLAGS, "mode" },\
{ "glow", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GLOW}, 0, 0, FLAGS, "mode" },\
{ "hardlight", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDLIGHT}, 0, 0, FLAGS, "mode" },\
{ "hardmix", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDMIX}, 0, 0, FLAGS, "mode" },\
{ "lighten", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LIGHTEN}, 0, 0, FLAGS, "mode" },\
{ "linearlight","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_LINEARLIGHT},0, 0, FLAGS, "mode" },\
{ "multiply", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_MULTIPLY}, 0, 0, FLAGS, "mode" },\
{ "negation", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NEGATION}, 0, 0, FLAGS, "mode" },\
{ "normal", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_NORMAL}, 0, 0, FLAGS, "mode" },\
......@@ -214,10 +218,12 @@ DEFINE_BLEND(exclusion, A + B - 2 * A * B / 255)
DEFINE_BLEND(pinlight, (B < 128) ? FFMIN(A, 2 * B) : FFMAX(A, 2 * (B - 128)))
DEFINE_BLEND(phoenix, FFMIN(A, B) - FFMAX(A, B) + 255)
DEFINE_BLEND(reflect, (B == 255) ? B : FFMIN(255, (A * A / (255 - B))))
DEFINE_BLEND(glow, (A == 255) ? A : FFMIN(255, (B * B / (255 - A))))
DEFINE_BLEND(and, A & B)
DEFINE_BLEND(or, A | B)
DEFINE_BLEND(xor, A ^ B)
DEFINE_BLEND(vividlight, (A < 128) ? BURN(2 * A, B) : DODGE(2 * (A - 128), B))
DEFINE_BLEND(linearlight,av_clip_uint8((B < 128) ? B + 2 * A - 255 : B + 2 * (A - 128)))
static void blend_expr(const uint8_t *top, int top_linesize,
const uint8_t *bottom, int bottom_linesize,
......@@ -328,9 +334,11 @@ static av_cold int init(AVFilterContext *ctx)
case BLEND_DIVIDE: param->blend = blend_divide; break;
case BLEND_DODGE: param->blend = blend_dodge; break;
case BLEND_EXCLUSION: param->blend = blend_exclusion; break;
case BLEND_GLOW: param->blend = blend_glow; break;
case BLEND_HARDLIGHT: param->blend = blend_hardlight; break;
case BLEND_HARDMIX: param->blend = blend_hardmix; break;
case BLEND_LIGHTEN: param->blend = blend_lighten; break;
case BLEND_LINEARLIGHT:param->blend = blend_linearlight;break;
case BLEND_MULTIPLY: param->blend = blend_multiply; break;
case BLEND_NEGATION: param->blend = blend_negation; break;
case BLEND_NORMAL: param->blend = blend_normal; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment