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
75317531 Available values for component modes are:
75327532 @table @samp
75337533 @item addition
7534−@item grainmerge
75357534 @item and
75367535 @item average
7536+@item bleach
75377537 @item burn
75387538 @item darken
75397539 @item difference
7540−@item grainextract
75417540 @item divide
75427541 @item dodge
7543−@item freeze
75447542 @item exclusion
75457543 @item extremity
7544+@item freeze
75467545 @item geometric
75477546 @item glow
7547+@item grainextract
7548+@item grainmerge
75487549 @item hardlight
75497550 @item hardmix
7551+@item hardoverlay
75507552 @item harmonic
75517553 @item heat
7554+@item interpolate
75527555 @item lighten
75537556 @item linearlight
75547557 @item multiply
@@ -7563,6 +7566,7 @@ Available values for component modes are: · 8 unmodified lines
75637566 @item screen
75647567 @item softdifference
75657568 @item softlight
7569+@item stain
75667570 @item subtract
75677571 @item vividlight
75687572 @item xor
libavfilter/blend.h+4−0
@@ -62,6 +62,10 @@ enum BlendMode { · 61 unmodified lines
6262 BLEND_SOFTDIFFERENCE,
6363 BLEND_GEOMETRIC,
6464 BLEND_HARMONIC,
65+ BLEND_BLEACH,
66+ BLEND_STAIN,
67+ BLEND_INTERPOLATE,
68+ BLEND_HARDOVERLAY,
6569 BLEND_NB
6670 };
6771
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
145145 fn(softdifference,CLIP((A > B) ? (B == MAX) ? 0 : (A - B) * MAX / (MAX - B) : (B == 0) ? 0 : (B - A) * MAX / B))
146146 fn(geometric, GEOMETRIC(A, B))
147147 fn(harmonic, A == 0 && B == 0 ? 0 : 2LL * A * B / (A + B))
148+fn(bleach, (MAX - B) + (MAX - A) - MAX)
149+fn(stain, 2 * MAX - A - B)
150+fn(interpolate,lrintf(MAX * (2 - cosf(A * M_PI / MAX) - cosf(B * M_PI / MAX)) * 0.25f))
151+fn(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
134134 { "softdifference","", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_SOFTDIFFERENCE}, 0, 0, FLAGS, "mode" },
135135 { "geometric", "", 0, AV_OPT_TYPE_CONST, {.i64=BLEND_GEOMETRIC}, 0, 0, FLAGS, "mode" },
136136 { "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" },
137141 { "c0_expr", "set color component #0 expression", OFFSET(params[0].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
138142 { "c1_expr", "set color component #1 expression", OFFSET(params[1].expr_str), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 0, FLAGS },
139143 { "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
397401 case BLEND_SUBTRACT: param->blend = blend_subtract_##depth##bit; break; \
398402 case BLEND_VIVIDLIGHT: param->blend = blend_vividlight_##depth##bit; break; \
399403 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; \
401405 case BLEND_GEOMETRIC: param->blend = blend_geometric_##depth##bit; break; \
402406 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; \
403411 } \
404412 }
405413 DEFINE_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