80 "repeat",
"endall",
"pass"
150 return (
int)d & ~((1 << chroma_sub) - 1);
175 "Error when evaluating the expression '%s' for %s\n",
186 char *res,
int res_len,
int flags)
191 if (!strcmp(cmd,
"x"))
193 else if (!strcmp(cmd,
"y"))
218 static const enum AVPixelFormat overlay_pix_fmts_yuv420[] = {
225 static const enum AVPixelFormat overlay_pix_fmts_yuv422[] = {
232 static const enum AVPixelFormat overlay_pix_fmts_yuv444[] = {
340 "main w:%d h:%d fmt:%s overlay w:%d h:%d fmt:%s eof_action:%s\n",
367 #define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)
373 #define UNPREMULTIPLY_ALPHA(x, y) ((((x) << 16) - ((x) << 9) + (x)) / ((((x) + (y)) << 8) - ((x) + (y)) - (y) * (x)))
383 int i, imax, j, jmax, k, kmax;
384 const int src_w = src->
width;
385 const int src_h = src->
height;
386 const int dst_w = dst->
width;
387 const int dst_h = dst->
height;
389 if (x >= dst_w || x+src_w < 0 ||
390 y >= dst_h || y+src_h < 0)
412 for (imax =
FFMIN(-y + dst_h, src_h); i < imax; i++) {
415 d = dp + (x+j) * dstep;
417 for (jmax =
FFMIN(-x + dst_w, src_w); j < jmax; j++) {
422 if (main_has_alpha && alpha != 0 && alpha != 255) {
438 d[dr] =
FAST_DIV255(d[dr] * (255 - alpha) + s[sr] * alpha);
439 d[dg] =
FAST_DIV255(d[dg] * (255 - alpha) + s[sg] * alpha);
440 d[db] =
FAST_DIV255(d[db] * (255 - alpha) + s[sb] * alpha);
442 if (main_has_alpha) {
462 if (main_has_alpha) {
470 for (imax =
FFMIN(-y + dst_h, src_h); i < imax; i++) {
475 for (jmax =
FFMIN(-x + dst_w, src_w); j < jmax; j++) {
477 if (alpha != 0 && alpha != 255) {
498 for (i = 0; i < 3; i++) {
499 int hsub = i ? s->
hsub : 0;
500 int vsub = i ? s->
vsub : 0;
514 for (jmax =
FFMIN(-yp + dst_hp, src_hp); j < jmax; j++) {
520 for (kmax =
FFMIN(-xp + dst_wp, src_wp); k < kmax; k++) {
521 int alpha_v, alpha_h,
alpha;
524 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
525 alpha = (a[0] + a[src->
linesize[3]] +
527 }
else if (hsub || vsub) {
528 alpha_h = hsub && k+1 < src_wp ?
529 (a[0] + a[1]) >> 1 : a[0];
530 alpha_v = vsub && j+1 < src_hp ?
531 (a[0] + a[src->
linesize[3]]) >> 1 : a[0];
532 alpha = (alpha_v + alpha_h) >> 1;
537 if (main_has_alpha && alpha != 0 && alpha != 255) {
540 if (hsub && vsub && j+1 < src_hp && k+1 < src_wp) {
541 alpha_d = (d[0] + d[src->
linesize[3]] +
543 }
else if (hsub || vsub) {
544 alpha_h = hsub && k+1 < src_wp ?
545 (d[0] + d[1]) >> 1 : d[0];
546 alpha_v = vsub && j+1 < src_hp ?
547 (d[0] + d[src->
linesize[3]]) >> 1 : d[0];
548 alpha_d = (alpha_v + alpha_h) >> 1;
560 ap += (1 << vsub) * src->
linesize[3];
610 "The rgb option is deprecated and is overriding the format option, use format instead\n");
626 #define OFFSET(x) offsetof(OverlayContext, x)
627 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
632 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
641 {
"rgb",
"force packed RGB in input and output (deprecated)",
OFFSET(allow_packed_rgb),
AV_OPT_TYPE_INT, {.i64=0}, 0, 1,
FLAGS },
642 {
"shortest",
"force termination when the shortest input terminates",
OFFSET(dinput.shortest),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
FLAGS },
648 {
"repeatlast",
"repeat overlay of the last overlay frame",
OFFSET(dinput.repeatlast),
AV_OPT_TYPE_INT, {.i64=1}, 0, 1,
FLAGS },
687 .priv_class = &overlay_class,
690 .
inputs = avfilter_vf_overlay_inputs,
691 .
outputs = avfilter_vf_overlay_outputs,
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
This structure describes decoded (raw) audio or video data.
static int request_frame(AVFilterLink *outlink)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
static const AVFilterPad outputs[]
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
int h
agreed upon image height
static const AVFilterPad avfilter_vf_overlay_inputs[]
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
static const char *const eof_action_str[]
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
const char * name
Pad name.
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVFILTER_DEFINE_CLASS(overlay)
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
FFDualInputContext dinput
static AVFrame * do_blend(AVFilterContext *ctx, AVFrame *mainpic, const AVFrame *second)
timestamp utils, mostly useful for debugging/logging purposes
static const char *const var_names[]
static av_always_inline av_const int isnan(float x)
static void blend_image(AVFilterContext *ctx, AVFrame *dst, const AVFrame *src, int x, int y)
Blend image in src to destination buffer dst at position (x, y).
int shortest
terminate stream when the second input terminates
double var_values[VAR_VARS_NB]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
uint8_t overlay_rgba_map[4]
static double av_q2d(AVRational a)
Convert rational to double.
#define AV_LOG_VERBOSE
Detailed information.
A filter pad used for either input or output.
A link between two filters.
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
static double alpha(void *priv, double x, double y)
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define UNPREMULTIPLY_ALPHA(x, y)
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
void * priv
private data for use by the filter
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link...
static int config_input_overlay(AVFilterLink *inlink)
AVFilterFormats * in_formats
Lists of formats and channel layouts supported by the input and output filters respectively.
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
int w
agreed upon image width
static const AVFilterPad avfilter_vf_overlay_outputs[]
#define FF_CEIL_RSHIFT(a, b)
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterContext * src
source filter
AVFrame *(* process)(AVFilterContext *ctx, AVFrame *main, const AVFrame *second)
static av_cold int init(AVFilterContext *ctx)
int main_pix_step[4]
steps per pixel for each plane of the main output
int format
agreed upon media format
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
static const AVOption overlay_options[]
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
static av_cold void uninit(AVFilterContext *ctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
static int set_expr(AVExpr **pexpr, const char *expr, const char *option, void *log_ctx)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int y
position of overlayed picture
int repeatlast
repeat last second frame
Describe the class of an AVClass context structure.
uint8_t overlay_has_alpha
static const AVFilterPad inputs[]
uint8_t overlay_is_packed_rgb
const char * name
Filter name.
static int query_formats(AVFilterContext *ctx)
#define AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
Same as AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, except that the filter will have its filter_frame() c...
int overlay_pix_step[4]
steps per pixel for each plane of the overlay
AVFilterLink ** outputs
array of pointers to output links
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
#define FF_INLINK_IDX(link)
Find the index of a link.
static int normalize_xy(double d, int chroma_sub)
static int config_input_main(AVFilterLink *inlink)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
int vsub
chroma subsampling values
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
AVFilterContext * dst
dest filter
int64_t av_frame_get_pkt_pos(const AVFrame *frame)
static int config_output(AVFilterLink *outlink)
uint8_t main_is_packed_rgb
int eof_action
action to take on EOF from source
static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, char *res, int res_len, int flags)
static int filter_frame(AVFilterLink *inlink, AVFrame *inpicref)
static void eval_expr(AVFilterContext *ctx)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
AVPixelFormat
Pixel format.
int64_t frame_count
Number of past frames sent through the link.
#define AV_NOPTS_VALUE
Undefined timestamp value.
static enum AVPixelFormat alpha_pix_fmts[]
AVFilterFormats * out_formats
simple arithmetic expression evaluator