114 char color_string[128] =
"black";
122 sscanf(args,
"%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255s",
136 for (i = 0; i < 4; i++) {
148 int ret, is_packed_rgba;
149 double var_values[
VARS_NB], res;
155 var_values[
VAR_PI] = M_PI;
162 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
173 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
179 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
186 NULL, NULL, NULL, NULL, NULL, 0, ctx);
187 pad->
x = var_values[
VAR_X] = res;
190 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
192 pad->
y = var_values[
VAR_Y] = res;
196 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
198 pad->
x = var_values[
VAR_X] = res;
201 if (pad->
w < 0 || pad->
h < 0 || pad->
x < 0 || pad->
y < 0) {
211 pad->
w &= ~((1 << pad->
hsub) - 1);
212 pad->
h &= ~((1 << pad->
vsub) - 1);
213 pad->
x &= ~((1 << pad->
hsub) - 1);
214 pad->
y &= ~((1 << pad->
vsub) - 1);
216 pad->
in_w = inlink->
w & ~((1 << pad->
hsub) - 1);
217 pad->
in_h = inlink->
h & ~((1 << pad->
vsub) - 1);
219 memcpy(rgba_color, pad->
color,
sizeof(rgba_color));
221 inlink->
format, rgba_color, &is_packed_rgba, NULL);
224 inlink->
w, inlink->
h, pad->
w, pad->
h, pad->
x, pad->
y,
226 is_packed_rgba ?
"rgba" :
"yuva");
228 if (pad->
x < 0 || pad->
y < 0 ||
229 pad->
w <= 0 || pad->
h <= 0 ||
230 (
unsigned)pad->
x + (
unsigned)inlink->
w > pad->
w ||
231 (
unsigned)pad->
y + (
unsigned)inlink->
h > pad->
h) {
233 "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n",
234 pad->
x, pad->
y, pad->
x + inlink->
w, pad->
y + inlink->
h, pad->
w, pad->
h);
242 "Error when evaluating the expression '%s'\n", expr);
261 w + (pad->
w - pad->
in_w),
262 h + (pad->
h - pad->
in_h));
271 for (plane = 0; plane < 4 && picref->
data[plane]; plane++) {
272 int hsub = (plane == 1 || plane == 2) ? pad->
hsub : 0;
273 int vsub = (plane == 1 || plane == 2) ? pad->
vsub : 0;
276 (pad->
y >> vsub) * picref->
linesize[plane];
284 int64_t x_in_buf, y_in_buf;
286 x_in_buf = outpicref->
data[plane] - outpicref->
buf->
data[plane]
287 + (x >> hsub) * pad ->line_step[plane]
288 + (y >> vsub) * outpicref->
linesize [plane];
290 if(x_in_buf < 0 || x_in_buf % pad->line_step[plane])
296 y_in_buf = x_in_buf / outpicref->
buf->
linesize[plane];
299 if( y_in_buf<<vsub >= outpicref->
buf->
h
300 || x_in_buf<<hsub >= outpicref->
buf->
w)
309 int plane, needs_copy;
316 for (plane = 0; plane < 4 && out->
data[plane]; plane++) {
317 int hsub = (plane == 1 || plane == 2) ? pad->
hsub : 0;
318 int vsub = (plane == 1 || plane == 2) ? pad->
vsub : 0;
326 (pad->
y >> vsub) * out->
linesize [plane];
328 if (
does_clip(pad, out, plane, hsub, vsub, 0, 0) ||
329 does_clip(pad, out, plane, hsub, vsub, 0, pad->
h - 1) ||
330 does_clip(pad, out, plane, hsub, vsub, pad->
w - 1, 0) ||
331 does_clip(pad, out, plane, hsub, vsub, pad->
w - 1, pad->
h - 1))
334 needs_copy = plane < 4 && out->
data[plane];
356 0, 0, pad->
w, pad->
y);
360 if (pad->
h > pad->
y + pad->
in_h) {
363 0, pad->
y + pad->
in_h, pad->
w, pad->
h - pad->
y - pad->
in_h);
379 pad->
x + pad->
in_w, pad->
y, pad->
w - pad->
x - pad->
in_w,
408 .description =
NULL_IF_CONFIG_SMALL(
"Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
415 .
inputs = avfilter_vf_pad_inputs,
417 .
outputs = avfilter_vf_pad_outputs,
uint8_t * data[8]
buffer data for each plane/channel
static int filter_frame(AVFilterLink *inlink, AVFilterBufferRef *in)
int vsub
chroma subsampling values
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
static const AVFilterPad outputs[]
packed RGB 8:8:8, 24bpp, RGBRGB...
int h
agreed upon image height
int in_h
width and height for the padded input video, which has to be aligned to the chroma values in order to...
int ff_filter_frame(AVFilterLink *link, AVFilterBufferRef *frame)
Send a frame of data to the next filter.
Various defines for YUV<->RGB conversion.
static const AVFilterPad avfilter_vf_pad_outputs[]
static int config_output(AVFilterLink *outlink)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
int h
width and height of the allocated buffer
char w_expr[256]
width expression string
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
char h_expr[256]
height expression string
const char * name
Pad name.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
int linesize[8]
number of bytes per line
static const char *const var_names[]
void avfilter_unref_bufferp(AVFilterBufferRef **ref)
Remove a reference to a buffer and set the pointer to NULL.
char y_expr[256]
height expression string
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
static av_cold int init(AVFilterContext *ctx, const char *args)
int av_parse_color(uint8_t *rgba_color, const char *color_string, int slen, void *log_ctx)
Put the RGBA values that correspond to color_string in rgba_color.
A filter pad used for either input or output.
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.
AVFilterBufferRef * ff_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
AVFilterBuffer * buf
the buffer that this is a reference to
#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
static int config_input(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,...)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
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.
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
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
int y
offsets of the input area with respect to the padded area
packed RGB 8:8:8, 24bpp, BGRBGR...
AVFilterContext * src
source filter
int format
agreed upon media format
A reference to an AVFilterBuffer.
static int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, int hsub, int vsub, int x, int y)
static const AVFilterPad avfilter_vf_pad_inputs[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
static const AVFilterPad inputs[]
void ff_copy_rectangle(uint8_t *dst[4], int dst_linesize[4], uint8_t *src[4], int src_linesize[4], int pixelstep[4], int hsub, int vsub, int x, int y, int y2, int w, int h)
uint8_t color[4]
color expressed either in YUVA or RGBA colorspace for the padding area
const char * name
filter name
AVFilterLink ** outputs
array of pointers to output links
static AVFilterBufferRef * get_video_buffer(AVFilterLink *inlink, int perms, int w, int h)
static int query_formats(AVFilterContext *ctx)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
common internal and external API header
void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
static const uint8_t color[]
#define AV_PERM_WRITE
can write to the buffer
AVFilterContext * dst
dest filter
int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], enum AVPixelFormat pix_fmt, uint8_t rgba_color[4], int *is_packed_rgba, uint8_t rgba_map_ptr[4])
uint8_t * data[8]
picture/audio data for each plane
int h
output dimensions, a value of 0 will result in the input size
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
char x_expr[256]
width expression string
static av_cold void uninit(AVFilterContext *ctx)
void ff_draw_rectangle(uint8_t *dst[4], int dst_linesize[4], uint8_t *src[4], int pixelstep[4], int hsub, int vsub, int x, int y, int w, int h)
AVPixelFormat
Pixel format.
#define AV_PERM_NEG_LINESIZES
the buffer requested can have negative linesizes
simple arithmetic expression evaluator