80 "repeat",
"endall",
"pass"
136 return (
int)d & ~((1 << chroma_sub) - 1);
158 NULL, NULL, NULL, NULL, 0, log_ctx);
161 "Error when evaluating the expression '%s' for %s\n",
172 char *res,
int res_len,
int flags)
177 if (!strcmp(cmd,
"x"))
179 else if (!strcmp(cmd,
"y"))
204 static const enum AVPixelFormat overlay_pix_fmts_yuv420[] = {
211 static const enum AVPixelFormat overlay_pix_fmts_yuv422[] = {
218 static const enum AVPixelFormat overlay_pix_fmts_yuv444[] = {
238 case OVERLAY_FORMAT_YUV420:
242 case OVERLAY_FORMAT_YUV422:
246 case OVERLAY_FORMAT_YUV444:
250 case OVERLAY_FORMAT_RGB:
326 "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s eof_action:%s\n",
353 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
359 #define UNPREMULTIPLY_ALPHA(x, y) ((((x) << 16) - ((x) << 9) + (x)) / ((((x) + (y)) << 8) - ((x) + (y)) - (y) * (x)))
369 int i, imax, j, jmax, k, kmax;
370 const int src_w = src->
width;
371 const int src_h = src->
height;
372 const int dst_w = dst->
width;
373 const int dst_h = dst->
height;
375 if (x >= dst_w || x+src_w < 0 ||
376 y >= dst_h || y+src_h < 0)
398 for (imax =
FFMIN(-y + dst_h, src_h); i < imax; i++) {
401 d = dp + (x+j) * dstep;
403 for (jmax =
FFMIN(-x + dst_w, src_w); j < jmax; j++) {
408 if (main_has_alpha && alpha != 0 && alpha != 255) {
424 d[dr] =
FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha);
425 d[dg] =
FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha);
426 d[db] =
FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha);
428 if (main_has_alpha) {
448 if (main_has_alpha) {
456 for (imax =
FFMIN(-y + dst_h, src_h); i < imax; i++) {
461 for (jmax =
FFMIN(-x + dst_w, src_w); j < jmax; j++) {
463 if (alpha != 0 && alpha != 255) {
484 for (i = 0; i < 3; i++) {
485 int hsub = i ? s->
hsub : 0;
486 int vsub = i ? s->
vsub : 0;
500 for (jmax =
FFMIN(-yp + dst_hp, src_hp); j < jmax; j++) {
506 for (kmax =
FFMIN(-xp + dst_wp, src_wp); k < kmax; k++) {
507 int alpha_v, alpha_h,
alpha;
510 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
511 alpha = (a[0] + a[src->
linesize[3]] +
513 }
else if (hsub || vsub) {
514 alpha_h = hsub && k+1 < src_wp ?
515 (a[0] + a[1]) >> 1 : a[0];
516 alpha_v = vsub && j+1 < src_hp ?
517 (a[0] + a[src->
linesize[3]]) >> 1 : a[0];
518 alpha = (alpha_v + alpha_h) >> 1;
523 if (main_has_alpha && alpha != 0 && alpha != 255) {
526 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
527 alpha_d = (d[0] + d[src->
linesize[3]] +
529 }
else if (hsub || vsub) {
530 alpha_h = hsub && k+1 < src_wp ?
531 (d[0] + d[1]) >> 1 : d[0];
532 alpha_v = vsub && j+1 < src_hp ?
533 (d[0] + d[src->
linesize[3]]) >> 1 : d[0];
534 alpha_d = (alpha_v + alpha_h) >> 1;
546 ap += (1 << vsub) * src->
linesize[3];
596 "The rgb option is deprecated and is overriding the format option, use format instead\n");
597 s->
format = OVERLAY_FORMAT_RGB;
612 #define OFFSET(x) offsetof(OverlayContext, x)
613 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
618 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
625 {
"init",
"eval expressions once during initialization", 0,
AV_OPT_TYPE_CONST, {.i64=EVAL_MODE_INIT}, .flags =
FLAGS, .unit =
"eval" },
627 {
"rgb",
"force packed RGB in input and output (deprecated)",
OFFSET(allow_packed_rgb),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1,
FLAGS },
628 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(dinput.shortest),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
FLAGS },
629 {
"format",
"set output format",
OFFSET(format),
AV_OPT_TYPE_INT, {.i64=OVERLAY_FORMAT_YUV420}, 0, OVERLAY_FORMAT_NB-1,
FLAGS,
"format" },
634 {
"repeatlast",
"repeat overlay of the last overlay frame",
OFFSET(dinput.repeatlast),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1,
FLAGS },
673 .priv_class = &overlay_class,
676 .
inputs = avfilter_vf_overlay_inputs,
677 .
outputs = avfilter_vf_overlay_outputs,