79 "repeat",
"endall",
"pass"
105 enum OverlayFormat { OVERLAY_FORMAT_YUV420, OVERLAY_FORMAT_YUV422, OVERLAY_FORMAT_YUV444, OVERLAY_FORMAT_RGB, OVERLAY_FORMAT_NB} format;
110 int main_pix_step[4];
111 int overlay_pix_step[4];
135 return (
int)d & ~((1 << chroma_sub) - 1);
157 NULL, NULL, NULL, NULL, 0, log_ctx);
160 "Error when evaluating the expression '%s' for %s\n",
176 if (!strcmp(cmd,
"x"))
178 else if (!strcmp(cmd,
"y"))
203 static const enum AVPixelFormat overlay_pix_fmts_yuv420[] = {
210 static const enum AVPixelFormat overlay_pix_fmts_yuv422[] = {
217 static const enum AVPixelFormat overlay_pix_fmts_yuv444[] = {
237 case OVERLAY_FORMAT_YUV420:
241 case OVERLAY_FORMAT_YUV422:
245 case OVERLAY_FORMAT_YUV444:
249 case OVERLAY_FORMAT_RGB:
325 "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s eof_action:%s\n",
352 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
358 #define UNPREMULTIPLY_ALPHA(x, y) ((((x) << 16) - ((x) << 9) + (x)) / ((((x) + (y)) << 8) - ((x) + (y)) - (y) * (x)))
368 int i, imax, j, jmax, k, kmax;
369 const int src_w = src->
width;
370 const int src_h = src->
height;
371 const int dst_w = dst->
width;
372 const int dst_h = dst->
height;
374 if (x >= dst_w || x+src_w < 0 ||
375 y >= dst_h || y+src_h < 0)
397 for (imax =
FFMIN(-y + dst_h, src_h); i < imax; i++) {
400 d = dp + (x+j) * dstep;
402 for (jmax =
FFMIN(-x + dst_w, src_w); j < jmax; j++) {
407 if (main_has_alpha && alpha != 0 && alpha != 255) {
423 d[dr] =
FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha);
424 d[dg] =
FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha);
425 d[db] =
FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha);
427 if (main_has_alpha) {
447 if (main_has_alpha) {
455 for (imax =
FFMIN(-y + dst_h, src_h); i < imax; i++) {
460 for (jmax =
FFMIN(-x + dst_w, src_w); j < jmax; j++) {
462 if (alpha != 0 && alpha != 255) {
483 for (i = 0; i < 3; i++) {
484 int hsub = i ? s->
hsub : 0;
485 int vsub = i ? s->
vsub : 0;
499 for (jmax =
FFMIN(-yp + dst_hp, src_hp); j < jmax; j++) {
505 for (kmax =
FFMIN(-xp + dst_wp, src_wp); k < kmax; k++) {
506 int alpha_v, alpha_h,
alpha;
509 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
510 alpha = (a[0] + a[src->
linesize[3]] +
512 }
else if (hsub || vsub) {
513 alpha_h = hsub && k+1 < src_wp ?
514 (a[0] + a[1]) >> 1 : a[0];
515 alpha_v = vsub && j+1 < src_hp ?
516 (a[0] + a[src->
linesize[3]]) >> 1 : a[0];
517 alpha = (alpha_v + alpha_h) >> 1;
522 if (main_has_alpha && alpha != 0 && alpha != 255) {
525 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
526 alpha_d = (d[0] + d[src->
linesize[3]] +
528 }
else if (hsub || vsub) {
529 alpha_h = hsub && k+1 < src_wp ?
530 (d[0] + d[1]) >> 1 : d[0];
531 alpha_v = vsub && j+1 < src_hp ?
532 (d[0] + d[src->
linesize[3]]) >> 1 : d[0];
533 alpha_d = (alpha_v + alpha_h) >> 1;
545 ap += (1 << vsub) * src->
linesize[3];
595 "The rgb option is deprecated and is overriding the format option, use format instead\n");
596 s->
format = OVERLAY_FORMAT_RGB;
611 #define OFFSET(x) offsetof(OverlayContext, x)
612 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
617 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
624 {
"init",
"eval expressions once during initialization", 0,
AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags =
FLAGS, .unit =
"eval" },
626 {
"rgb",
"force packed RGB in input and output (deprecated)",
OFFSET(allow_packed_rgb),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1,
FLAGS },
627 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(dinput.shortest),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
FLAGS },
628 {
"format",
"set output format",
OFFSET(format),
AV_OPT_TYPE_INT, {.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1,
FLAGS,
"format" },
633 {
"repeatlast",
"repeat overlay of the last overlay frame",
OFFSET(dinput.repeatlast),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1,
FLAGS },
672 .priv_class = &overlay_class,
675 .
inputs = avfilter_vf_overlay_inputs,
676 .
outputs = avfilter_vf_overlay_outputs,