History

avfilter/vf_blend: add few more modes

Paul B Mahol committed 5 years ago

Commit a6737611 parent 1ad47824 files · +24 −4Browse files

Unified · Split

4 files
  1. doc/filters.texi +7 −3
  2. libavfilter/blend.h +4 −0
  3. libavfilter/blend_modes.c +4 −0
  4. libavfilter/vf_blend.c +9 −1
doc/filters.texi+7−3
@@ -7531,24 +7531,27 @@ of @var{all_mode}. Default value is @code{normal}. · 7530 unmodified lines
7531Available values for component modes are:7531Available values for component modes are:
7532@table @samp7532@table @samp
7533@item addition7533@item addition
7534@item grainmerge
7535@item and7534@item and
7536@item average7535@item average
7536@item bleach
7537@item burn7537@item burn
7538@item darken7538@item darken
7539@item difference7539@item difference
7540@item grainextract
7541@item divide7540@item divide
7542@item dodge7541@item dodge
7543@item freeze
7544@item exclusion7542@item exclusion
7545@item extremity7543@item extremity
7544@item freeze
7546@item geometric7545@item geometric
7547@item glow7546@item glow
7547@item grainextract
7548@item grainmerge
7548@item hardlight7549@item hardlight
7549@item hardmix7550@item hardmix
7551@item hardoverlay
7550@item harmonic7552@item harmonic
7551@item heat7553@item heat
7554@item interpolate
7552@item lighten7555@item lighten
7553@item linearlight7556@item linearlight
7554@item multiply7557@item multiply
@@ -7563,6 +7566,7 @@ Available values for component modes are: · 8 unmodified lines
7563@item screen7566@item screen
7564@item softdifference7567@item softdifference
7565@item softlight7568@item softlight
7569@item stain
7566@item subtract7570@item subtract
7567@item vividlight7571@item vividlight
7568@item xor7572@item xor
libavfilter/blend.h+4−0
@@ -62,6 +62,10 @@ enum BlendMode { · 61 unmodified lines
62 BLEND_SOFTDIFFERENCE,62 BLEND_SOFTDIFFERENCE,
63 BLEND_GEOMETRIC,63 BLEND_GEOMETRIC,
64 BLEND_HARMONIC,64 BLEND_HARMONIC,
65 BLEND_BLEACH,
66 BLEND_STAIN,
67 BLEND_INTERPOLATE,
68 BLEND_HARDOVERLAY,
65 BLEND_NB69 BLEND_NB
66};70};
67 71
libavfilter/blend_modes.c+4−0
@@ -145,3 +145,7 @@ fn(linearlight,CLIP((B < HALF) ? B + 2 * A - MAX : B + 2 * (A - HALF))) · 144 unmodified lines
145fn(softdifference,CLIP((A > B) ? (B == MAX) ? 0 : (A - B) * MAX / (MAX - B) : (B == 0) ? 0 : (B - A) * MAX / B))145fn(softdifference,CLIP((A > B) ? (B == MAX) ? 0 : (A - B) * MAX / (MAX - B) : (B == 0) ? 0 : (B - A) * MAX / B))
146fn(geometric, GEOMETRIC(A, B))146fn(geometric, GEOMETRIC(A, B))
147fn(harmonic, A == 0 && B == 0 ? 0 : 2LL * A * B / (A + B))147fn(harmonic, A == 0 && B == 0 ? 0 : 2LL * A * B / (A + B))
148fn(bleach, (MAX - B) + (MAX - A) - MAX)
149fn(stain, 2 * MAX - A - B)
150fn(interpolate,lrintf(MAX * (2 - cosf(A * M_PI / MAX) - cosf(B * M_PI / MAX)) * 0.25f))
151fn(hardoverlay,A == MAX ? MAX : FFMIN(MAX, MAX * B / (2 * MAX - 2 * A) * (A > HALF) + 2 * A * B / MAX * (A <= HALF)))
libavfilter/vf_blend.c+9−1
@@ -134,6 +134,10 @@ static const AVOption blend_options[] = { · 133 unmodified lines
134 { "softdifference","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTDIFFERENCE}, 0, 0, FLAGS, "mode" },134 { "softdifference","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTDIFFERENCE}, 0, 0, FLAGS, "mode" },
135 { "geometric", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GEOMETRIC}, 0, 0, FLAGS, "mode" },135 { "geometric", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GEOMETRIC}, 0, 0, FLAGS, "mode" },
136 { "harmonic", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARMONIC}, 0, 0, FLAGS, "mode" },136 { "harmonic", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARMONIC}, 0, 0, FLAGS, "mode" },
137 { "bleach", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_BLEACH}, 0, 0, FLAGS, "mode" },
138 { "stain", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_STAIN}, 0, 0, FLAGS, "mode" },
139 { "interpolate","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_INTERPOLATE},0, 0, FLAGS, "mode" },
140 { "hardoverlay","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_HARDOVERLAY},0, 0, FLAGS, "mode" },
137 { "c0_expr", "set color component #0 expression", OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },141 { "c0_expr", "set color component #0 expression", OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
138 { "c1_expr", "set color component #1 expression", OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },142 { "c1_expr", "set color component #1 expression", OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
139 { "c2_expr", "set color component #2 expression", OFFSET(params[2].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },143 { "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) · 257 unmodified lines
397 case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \401 case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \
398 case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \402 case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \
399 case BLEND_XOR: param->blend = blend_xor_##depth##bit; break; \403 case BLEND_XOR: param->blend = blend_xor_##depth##bit; break; \
400 case BLEND_SOFTDIFFERENCE:param->blend = blend_softdifference_##depth##bit; break;\404 case BLEND_SOFTDIFFERENCE:param->blend=blend_softdifference_##depth##bit;break; \
401 case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \405 case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \
402 case BLEND_HARMONIC: param->blend = blend_harmonic_##depth##bit; break; \406 case BLEND_HARMONIC: param->blend = blend_harmonic_##depth##bit; break; \
407 case BLEND_BLEACH: param->blend = blend_bleach_##depth##bit; break; \
408 case BLEND_STAIN: param->blend = blend_stain_##depth##bit; break; \
409 case BLEND_INTERPOLATE: param->blend = blend_interpolate_##depth##bit; break; \
410 case BLEND_HARDOVERLAY: param->blend = blend_hardoverlay_##depth##bit; break; \
403 } \411 } \
404}412}
405DEFINE_INIT_BLEND_FUNC(8, 8)413DEFINE_INIT_BLEND_FUNC(8, 8)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t