63 static const char *
const var_names[] = {
"X",
"Y",
"W",
"H",
"SW",
"SH",
"T",
"N",
"A",
"B",
"TOP",
"BOTTOM",
NULL };
64 enum {
VAR_X,
VAR_Y,
VAR_W,
VAR_H,
VAR_SW,
VAR_SH,
VAR_T,
VAR_N,
VAR_A,
VAR_B,
VAR_TOP,
VAR_BOTTOM,
VAR_VARS_NB };
73 const uint8_t *bottom,
int bottom_linesize,
92 #define OFFSET(x) offsetof(BlendContext, x)
93 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
141 const uint8_t *bottom,
int bottom_linesize,
148 #define DEFINE_BLEND(name, expr) \
149 static void blend_## name(const uint8_t *top, int top_linesize, \
150 const uint8_t *bottom, int bottom_linesize, \
151 uint8_t *dst, int dst_linesize, \
152 int width, int height, FilterParams *param) \
154 double opacity = param->opacity; \
157 for (i = 0; i < height; i++) { \
158 for (j = 0; j < width; j++) { \
159 dst[j] = top[j] + ((expr) - top[j]) * opacity; \
161 dst += dst_linesize; \
162 top += top_linesize; \
163 bottom += bottom_linesize; \
170 #define MULTIPLY(x, a, b) (x * ((a * b) / 255))
171 #define SCREEN(x, a, b) (255 - x * ((255 - a) * (255 - b) / 255))
172 #define BURN(a, b) ((a == 0) ? a : FFMAX(0, 255 - ((255 - b) << 8) / a))
173 #define DODGE(a, b) ((a == 255) ? a : FFMIN(255, ((b << 8) / (255 - a))))
183 DEFINE_BLEND(hardlight, (
B < 128) ? MULTIPLY(2,
B, A) : SCREEN(2, B, A))
189 DEFINE_BLEND(softlight, (A > 127) ? B + (255 - B) * (A - 127.5) / 127.5 * (0.5 -
FFABS(B - 127.5) / 255): B - B * ((127.5 - A) / 127.5) * (0.5 -
FFABS(B - 127.5)/255))
199 static
void blend_expr(const
uint8_t *top,
int top_linesize,
200 const
uint8_t *bottom,
int bottom_linesize,
206 double *values = param->values;
209 for (y = 0; y <
height; y++) {
211 for (x = 0; x <
width; x++) {
219 bottom += bottom_linesize;
236 switch (param->
mode) {
273 param->
blend = blend_expr;
305 if (toplink->
w != bottomlink->
w ||
306 toplink->
h != bottomlink->
h ||
310 "(size %dx%d, SAR %d:%d) do not match the corresponding "
311 "second input link %s parameters (%dx%d, SAR %d:%d)\n",
321 outlink->
w = toplink->
w;
322 outlink->
h = toplink->
h;
372 for (plane = 0; plane < b->
nb_planes; plane++) {
373 int hsub = plane == 1 || plane == 2 ? b->
hsub : 0;
374 int vsub = plane == 1 || plane == 2 ? b->
vsub : 0;
381 param = &b->
params[plane];
389 bottom, bottom_buf->
linesize[plane],
390 dst, dst_buf->
linesize[plane], outw, outh, param);
407 AVFrame *top_buf, *bottom_buf, *out_buf;
467 .priv_class = &blend_class,