70 "repeat",
"endall",
"pass"
138 var_values[
VAR_PI ] = M_PI;
160 "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s eof_action:%s\n",
168 if (s->
x < 0 || s->
y < 0 ||
172 "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
176 (
int)var_values[
VAR_MAIN_W], (
int)var_values[VAR_MAIN_H]);
183 "Error when evaluating the expression '%s'\n", expr);
205 int overlay_end_y = y + src->
height;
210 start_y =
FFMAX(y, 0);
211 height = end_y - start_y;
220 for (i = 0; i <
height; i++) {
222 for (j = 0; j <
width; j++) {
223 d[
r] = (d[
r] * (0xff - s[3]) + s[0] * s[3] + 128) >> 8;
224 d[1] = (d[1] * (0xff - s[3]) + s[1] * s[3] + 128) >> 8;
225 d[
b] = (d[
b] * (0xff - s[3]) + s[2] * s[3] + 128) >> 8;
233 for (i = 0; i < 3; i++) {
234 int hsub = i ? s->
hsub : 0;
235 int vsub = i ? s->
vsub : 0;
237 (start_y >> vsub) * dst->
linesize[i];
240 int wp =
FFALIGN(width, 1<<hsub) >> hsub;
241 int hp =
FFALIGN(height, 1<<vsub) >> vsub;
243 sp += ((-y) >> vsub) * src->
linesize[i];
246 for (j = 0; j < hp; j++) {
248 for (k = 0; k < wp; k++) {
250 int alpha_v, alpha_h, alpha;
251 if (hsub && vsub && j+1 < hp && k+1 < wp) {
252 alpha = (a[0] + a[src->
linesize[3]] +
254 }
else if (hsub || vsub) {
255 alpha_h = hsub && k+1 < wp ?
256 (a[0] + a[1]) >> 1 : a[0];
257 alpha_v = vsub && j+1 < hp ?
258 (a[0] + a[src->
linesize[3]]) >> 1 : a[0];
259 alpha = (alpha_v + alpha_h) >> 1;
262 *d = (*d * (0xff - alpha) + *s++ * alpha + 128) >> 8;
268 ap += (1 << vsub) * src->
linesize[3];
366 #define OFFSET(x) offsetof(OverlayContext, x)
367 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
369 {
"x",
"Horizontal position of the left edge of the overlaid video on the "
371 {
"y",
"Vertical position of the top edge of the overlaid video on the "
373 {
"eof_action",
"Action to take when encountering EOF from secondary input ",
425 .priv_class = &overlay_class,
static void blend_frame(AVFilterContext *ctx, AVFrame *dst, AVFrame *src, int x, int y)
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)
static const AVFilterPad outputs[]
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
int h
agreed upon image height
static int handle_overlay_eof(AVFilterContext *ctx)
static const AVFilterPad avfilter_vf_overlay_inputs[]
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int filter_frame_main(AVFilterLink *inlink, AVFrame *frame)
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 * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVFilterLink ** inputs
array of pointers to input links
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static const char *const var_names[]
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
A link between two filters.
int av_expr_parse_and_eval(double *d, const char *s, const char *const *const_names, const double *const_values, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), void *opaque, int log_offset, void *log_ctx)
Parse and evaluate an expression.
int width
width and height of the video frame
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void * priv
private data for use by the filter
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)
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
AVFilterFormats * in_formats
Lists of formats supported by the input and output filters respectively.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare 2 timestamps each in its own timebases.
int w
agreed upon image width
static int output_frame(AVFilterContext *ctx)
static const AVFilterPad avfilter_vf_overlay_outputs[]
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterContext * src
source filter
static const AVClass overlay_class
int format
agreed upon media format
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static av_cold void uninit(AVFilterContext *ctx)
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
int max_plane_step[4]
steps per pixel for each plane
int y
position of overlayed picture
Describe the class of an AVClass context structure.
static const AVFilterPad inputs[]
rational number numerator/denominator
static const char * eof_action_str[]
const char * name
Filter name.
static int query_formats(AVFilterContext *ctx)
AVFilterLink ** outputs
array of pointers to output links
static const AVOption options[]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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
struct AVFilterPad AVFilterPad
AVFilterContext * dst
dest filter
static int config_output(AVFilterLink *outlink)
static int filter_frame_overlay(AVFilterLink *inlink, AVFrame *frame)
int ff_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
#define FFSWAP(type, a, b)
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
AVFilterFormats * out_formats
simple arithmetic expression evaluator
enum EOFAction eof_action
action to take on EOF from source