66 int max_plane_step[4];
69 char x_expr[256], y_expr[256];
80 sscanf(args,
"%255[^:]:%255[^:]", over->
x_expr, over->
y_expr);
153 "main w:%d h:%d fmt:%s overlay x:%d y:%d w:%d h:%d fmt:%s\n",
160 if (over->
x < 0 || over->
y < 0 ||
164 "Overlay area (%d,%d)<->(%d,%d) not within the main area (0,0)<->(%d,%d) or zero-sized\n",
168 (
int)var_values[
VAR_MAIN_W], (
int)var_values[VAR_MAIN_H]);
175 "Error when evaluating the expression '%s'\n", expr);
189 (int64_t)tb2.
num * tb1.
den),
190 (int64_t)tb1.
den * tb2.
den, INT_MAX);
192 "main_tb:%d/%d overlay_tb:%d/%d -> tb:%d/%d exact:%d\n",
196 "Timestamp conversion inexact, timestamp information loss may occurr\n");
245 int x,
int y,
int w,
int h,
246 int slice_y,
int slice_w,
int slice_h)
251 int overlay_end_y = y+h;
252 int slice_end_y = slice_y+slice_h;
255 width =
FFMIN(slice_w - x, w);
256 end_y =
FFMIN(slice_end_y, overlay_end_y);
257 start_y =
FFMAX(y, slice_y);
258 height = end_y - start_y;
261 uint8_t *dp = dst->
data[0] + x * 3 + start_y * dst->
linesize[0];
262 uint8_t *
sp = src->
data[0];
266 sp += (slice_y - y) * src->
linesize[0];
268 uint8_t *d = dp, *s =
sp;
269 for (j = 0; j <
width; j++) {
270 d[
r] = (d[
r] * (0xff - s[3]) + s[0] * s[3] + 128) >> 8;
271 d[1] = (d[1] * (0xff - s[3]) + s[1] * s[3] + 128) >> 8;
272 d[
b] = (d[
b] * (0xff - s[3]) + s[2] * s[3] + 128) >> 8;
280 for (i = 0; i < 3; i++) {
281 int hsub = i ? over->
hsub : 0;
282 int vsub = i ? over->
vsub : 0;
283 uint8_t *dp = dst->
data[i] + (x >> hsub) +
284 (start_y >> vsub) * dst->
linesize[i];
285 uint8_t *
sp = src->
data[i];
286 uint8_t *ap = src->
data[3];
287 int wp =
FFALIGN(width, 1<<hsub) >> hsub;
288 int hp =
FFALIGN(height, 1<<vsub) >> vsub;
290 sp += ((slice_y - y) >> vsub) * src->
linesize[i];
291 ap += (slice_y - y) * src->
linesize[3];
293 for (j = 0; j < hp; j++) {
294 uint8_t *d = dp, *s =
sp, *
a = ap;
295 for (k = 0; k < wp; k++) {
297 int alpha_v, alpha_h, alpha;
298 if (hsub && vsub && j+1 < hp && k+1 < wp) {
299 alpha = (a[0] + a[src->
linesize[3]] +
301 }
else if (hsub || vsub) {
302 alpha_h = hsub && k+1 < wp ?
303 (a[0] + a[1]) >> 1 : a[0];
304 alpha_v = vsub && j+1 < hp ?
305 (a[0] + a[src->
linesize[3]]) >> 1 : a[0];
306 alpha = (alpha_v + alpha_h) >> 1;
309 *d = (*d * (0xff - alpha) + *s++ * alpha + 128) >> 8;
315 ap += (1 << vsub) * src->
linesize[3];
329 !(over->
x >= outpicref->
video->
w || over->
y >= outpicref->
video->
h ||
333 y, outpicref->
video->
w, h);
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
static AVFilterBufferRef * get_video_buffer(AVFilterLink *link, int perms, int w, int h)
int h
agreed upon image height
#define AV_LOG_WARNING
Something somehow does not look correct.
AVFilterBufferRef * out_buf
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static const char * var_names[]
static void null_end_frame(AVFilterLink *inlink)
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.
#define AV_PERM_READ
can read from the buffer
AVFilterLink ** inputs
array of pointers to input links
static void blend_slice(AVFilterContext *ctx, AVFilterBufferRef *dst, AVFilterBufferRef *src, int x, int y, int w, int h, int slice_y, int slice_w, int slice_h)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
static void end_frame(AVFilterLink *inlink)
int64_t pts
presentation timestamp.
A filter pad used for either input or output.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static void start_frame_overlay(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
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.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static void null_draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
#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)
int64_t av_gcd(int64_t a, int64_t b)
Return the greatest common divisor of a and b.
void av_log(void *avcl, int level, const char *fmt,...)
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
AVFilterFormats * in_formats
Lists of formats supported by the input and output filters respectively.
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int w
agreed upon image width
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
AVFilter avfilter_vf_overlay
static void draw_slice(AVFilterLink *inlink, int y, int h, int slice_dir)
AVFilterContext * src
source filter
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
int format
agreed upon media format
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
A reference to an AVFilterBuffer.
static av_cold void uninit(AVFilterContext *ctx)
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
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void avfilter_formats_ref(AVFilterFormats *formats, AVFilterFormats **ref)
Add *ref as a new reference to formats.
int y
position of overlayed picture
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
rational number numerator/denominator
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
int avfilter_request_frame(AVFilterLink *link)
Request an input frame from the filter at the other end of the link.
const char * name
filter name
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
static int query_formats(AVFilterContext *ctx)
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterLink ** outputs
array of pointers to output links
#define AV_PERM_PRESERVE
nobody else can overwrite the buffer
static int config_input_main(AVFilterLink *inlink)
AVFilterBufferRef * overpicref
int vsub
chroma subsampling values
#define AV_PERM_REUSE2
can output the buffer multiple times, modified each time
packed RGB 8:8:8, 24bpp, RGBRGB...
AVFilterContext * dst
dest filter
static int config_output(AVFilterLink *outlink)
uint8_t * data[8]
picture/audio data for each plane
AVFilterBufferRef * cur_buf
AVFilterFormats * out_formats
simple arithmetic expression evaluator
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)