111 char color_string[128] =
"black";
119 sscanf(args,
"%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255s",
133 for (i = 0; i < 4; i++) {
144 uint8_t rgba_color[4];
145 int ret, is_packed_rgba;
146 double var_values[
VARS_NB], res;
159 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
170 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
176 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
183 NULL, NULL, NULL, NULL, NULL, 0, ctx);
184 pad->
x = var_values[
VAR_X] = res;
187 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
189 pad->
y = var_values[
VAR_Y] = res;
193 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
195 pad->
x = var_values[
VAR_X] = res;
198 if (pad->
w < 0 || pad->
h < 0 || pad->
x < 0 || pad->
y < 0) {
208 pad->
w &= ~((1 << pad->
hsub) - 1);
209 pad->
h &= ~((1 << pad->
vsub) - 1);
210 pad->
x &= ~((1 << pad->
hsub) - 1);
211 pad->
y &= ~((1 << pad->
vsub) - 1);
213 pad->
in_w = inlink->
w & ~((1 << pad->
hsub) - 1);
214 pad->
in_h = inlink->
h & ~((1 << pad->
vsub) - 1);
216 memcpy(rgba_color, pad->
color,
sizeof(rgba_color));
218 inlink->
format, rgba_color, &is_packed_rgba, NULL);
220 av_log(ctx,
AV_LOG_INFO,
"w:%d h:%d -> w:%d h:%d x:%d y:%d color:0x%02X%02X%02X%02X[%s]\n",
221 inlink->
w, inlink->
h, pad->
w, pad->
h, pad->
x, pad->
y,
223 is_packed_rgba ?
"rgba" :
"yuva");
225 if (pad->
x < 0 || pad->
y < 0 ||
226 pad->
w <= 0 || pad->
h <= 0 ||
227 (
unsigned)pad->
x + (
unsigned)inlink->
w > pad->
w ||
228 (
unsigned)pad->
y + (
unsigned)inlink->
h > pad->
h) {
230 "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n",
231 pad->
x, pad->
y, pad->
x + inlink->
w, pad->
y + inlink->
h, pad->
w, pad->
h);
239 "Error when evaluating the expression '%s'\n", expr);
258 w + (pad->
w - pad->
in_w),
259 h + (pad->
h - pad->
in_h));
265 for (plane = 0; plane < 4 && picref->
data[plane]; plane++) {
266 int hsub = (plane == 1 || plane == 2) ? pad->
hsub : 0;
267 int vsub = (plane == 1 || plane == 2) ? pad->
vsub : 0;
270 (pad->
y >> vsub) * picref->
linesize[plane];
278 int64_t x_in_buf, y_in_buf;
280 x_in_buf = outpicref->
data[plane] - outpicref->
buf->
data[plane]
281 + (x >> hsub) * pad ->line_step[plane]
282 + (y >> vsub) * outpicref->
linesize [plane];
284 if(x_in_buf < 0 || x_in_buf % pad->line_step[plane])
290 y_in_buf = x_in_buf / outpicref->
buf->
linesize[plane];
293 if( y_in_buf<<vsub >= outpicref->
buf->
h
294 || x_in_buf<<hsub >= outpicref->
buf->
w)
306 for (plane = 0; plane < 4 && outpicref->
data[plane]; plane++) {
307 int hsub = (plane == 1 || plane == 2) ? pad->
hsub : 0;
308 int vsub = (plane == 1 || plane == 2) ? pad->
vsub : 0;
315 outpicref->
data[plane] -= (pad->
x >> hsub) * pad ->line_step[plane]
316 + (pad->
y >> vsub) * outpicref->
linesize [plane];
318 if(
does_clip(pad, outpicref, plane, hsub, vsub, 0, 0)
319 ||
does_clip(pad, outpicref, plane, hsub, vsub, 0, pad->
h-1)
320 ||
does_clip(pad, outpicref, plane, hsub, vsub, pad->
w-1, 0)
321 ||
does_clip(pad, outpicref, plane, hsub, vsub, pad->
w-1, pad->
h-1)
354 int bar_y, bar_h = 0;
356 if (slice_dir * before_slice == 1 && y == pad->
y) {
360 }
else if (slice_dir * before_slice == -1 && (y + h) == (pad->
y + pad->
in_h)) {
362 bar_y = pad->
y + pad->
in_h;
363 bar_h = pad->
h - pad->
in_h - pad->
y;
370 0, bar_y, pad->
w, bar_h);
383 y &= ~((1 << pad->
vsub) - 1);
384 h &= ~((1 << pad->
vsub) - 1);
398 pad->
x, y, y-pad->
y, inpic->
video->
w, h);
404 pad->
x + pad->
in_w, y, pad->
w - pad->
x - pad->
in_w, h);
412 .description =
NULL_IF_CONFIG_SMALL(
"Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
uint8_t * data[8]
buffer data for each plane/channel
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
int vsub
chroma subsampling values
AVFilterBufferRefVideoProps * video
video buffer specific properties
int linesize[8]
number of bytes per line
static void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
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...
AVFilterBufferRef * out_buf
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Various defines for YUV<->RGB conversion.
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 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
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
int linesize[8]
number of bytes per line
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
char y_expr[256]
height expression string
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
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.
int ff_fill_line_with_color(uint8_t *line[4], int pixel_step[4], int w, uint8_t dst_color[4], enum PixelFormat pix_fmt, uint8_t rgba_color[4], int *is_packed_rgba, uint8_t rgba_map_ptr[4])
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
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. ...
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,...)
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
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.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
int w
agreed upon image width
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
int y
offsets of the input area with respect to the padded area
AVFilterContext * src
source filter
static void end_frame(AVFilterLink *link)
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 int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, int hsub, int vsub, int x, int y)
static const char * var_names[]
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
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)
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
uint8_t color[4]
color expressed either in YUVA or RGBA colorspace for the padding area
const char * name
filter name
packed RGB 8:8:8, 24bpp, BGRBGR...
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)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static const uint8_t color[]
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
#define AV_PERM_WRITE
can write to the buffer
packed RGB 8:8:8, 24bpp, RGBRGB...
AVFilterContext * dst
dest filter
uint8_t * data[8]
picture/audio data for each plane
int h
output dimensions, a value of 0 will result in the input size
AVFilterBufferRef * cur_buf
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
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)
#define AV_PERM_NEG_LINESIZES
the buffer requested can have negative linesizes
simple arithmetic expression evaluator
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)