History

avfilter/vf_blend: add few more modes

Paul B Mahol committed 5 years ago

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

Showing the changes to libavfilter (3 of 4 files). Show all

Unified · Split

3 files
  1. libavfilter/blend.h +4 −0
  2. libavfilter/blend_modes.c +4 −0
  3. libavfilter/vf_blend.c +9 −1
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