vf_pad.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 vmrsss
3  * Copyright (c) 2009 Stefano Sabatini
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
27 #include "avfilter.h"
28 #include "libavutil/avstring.h"
29 #include "libavutil/eval.h"
30 #include "libavutil/pixdesc.h"
31 #include "libavutil/colorspace.h"
32 #include "libavutil/avassert.h"
33 #include "libavutil/imgutils.h"
34 #include "libavutil/parseutils.h"
35 #include "libavutil/mathematics.h"
36 #include "drawutils.h"
37 
38 static const char *var_names[] = {
39  "PI",
40  "PHI",
41  "E",
42  "in_w", "iw",
43  "in_h", "ih",
44  "out_w", "ow",
45  "out_h", "oh",
46  "x",
47  "y",
48  "a",
49  "hsub",
50  "vsub",
51  NULL
52 };
53 
54 enum var_name {
68 };
69 
71 {
72  static const enum PixelFormat pix_fmts[] = {
76 
83 
85  };
86 
88  return 0;
89 }
90 
91 typedef struct {
92  int w, h;
93  int x, y;
94  int in_w, in_h;
95 
96  char w_expr[256];
97  char h_expr[256];
98  char x_expr[256];
99  char y_expr[256];
100 
101  uint8_t color[4];
102  uint8_t *line[4];
103  int line_step[4];
104  int hsub, vsub;
106 } PadContext;
107 
108 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
109 {
110  PadContext *pad = ctx->priv;
111  char color_string[128] = "black";
112 
113  av_strlcpy(pad->w_expr, "iw", sizeof(pad->w_expr));
114  av_strlcpy(pad->h_expr, "ih", sizeof(pad->h_expr));
115  av_strlcpy(pad->x_expr, "0" , sizeof(pad->w_expr));
116  av_strlcpy(pad->y_expr, "0" , sizeof(pad->h_expr));
117 
118  if (args)
119  sscanf(args, "%255[^:]:%255[^:]:%255[^:]:%255[^:]:%255s",
120  pad->w_expr, pad->h_expr, pad->x_expr, pad->y_expr, color_string);
121 
122  if (av_parse_color(pad->color, color_string, -1, ctx) < 0)
123  return AVERROR(EINVAL);
124 
125  return 0;
126 }
127 
128 static av_cold void uninit(AVFilterContext *ctx)
129 {
130  PadContext *pad = ctx->priv;
131  int i;
132 
133  for (i = 0; i < 4; i++) {
134  av_freep(&pad->line[i]);
135  pad->line_step[i] = 0;
136  }
137 }
138 
139 static int config_input(AVFilterLink *inlink)
140 {
141  AVFilterContext *ctx = inlink->dst;
142  PadContext *pad = ctx->priv;
143  const AVPixFmtDescriptor *pix_desc = &av_pix_fmt_descriptors[inlink->format];
144  uint8_t rgba_color[4];
145  int ret, is_packed_rgba;
146  double var_values[VARS_NB], res;
147  char *expr;
148 
149  pad->hsub = pix_desc->log2_chroma_w;
150  pad->vsub = pix_desc->log2_chroma_h;
151 
152  var_values[VAR_PI] = M_PI;
153  var_values[VAR_PHI] = M_PHI;
154  var_values[VAR_E] = M_E;
155  var_values[VAR_IN_W] = var_values[VAR_IW] = inlink->w;
156  var_values[VAR_IN_H] = var_values[VAR_IH] = inlink->h;
157  var_values[VAR_OUT_W] = var_values[VAR_OW] = NAN;
158  var_values[VAR_OUT_H] = var_values[VAR_OH] = NAN;
159  var_values[VAR_A] = (double) inlink->w / inlink->h;
160  var_values[VAR_HSUB] = 1<<pad->hsub;
161  var_values[VAR_VSUB] = 1<<pad->vsub;
162 
163  /* evaluate width and height */
164  av_expr_parse_and_eval(&res, (expr = pad->w_expr),
165  var_names, var_values,
166  NULL, NULL, NULL, NULL, NULL, 0, ctx);
167  pad->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
168  if ((ret = av_expr_parse_and_eval(&res, (expr = pad->h_expr),
169  var_names, var_values,
170  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
171  goto eval_fail;
172  pad->h = var_values[VAR_OUT_H] = var_values[VAR_OH] = res;
173  /* evaluate the width again, as it may depend on the evaluated output height */
174  if ((ret = av_expr_parse_and_eval(&res, (expr = pad->w_expr),
175  var_names, var_values,
176  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
177  goto eval_fail;
178  pad->w = var_values[VAR_OUT_W] = var_values[VAR_OW] = res;
179 
180  /* evaluate x and y */
181  av_expr_parse_and_eval(&res, (expr = pad->x_expr),
182  var_names, var_values,
183  NULL, NULL, NULL, NULL, NULL, 0, ctx);
184  pad->x = var_values[VAR_X] = res;
185  if ((ret = av_expr_parse_and_eval(&res, (expr = pad->y_expr),
186  var_names, var_values,
187  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
188  goto eval_fail;
189  pad->y = var_values[VAR_Y] = res;
190  /* evaluate x again, as it may depend on the evaluated y value */
191  if ((ret = av_expr_parse_and_eval(&res, (expr = pad->x_expr),
192  var_names, var_values,
193  NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
194  goto eval_fail;
195  pad->x = var_values[VAR_X] = res;
196 
197  /* sanity check params */
198  if (pad->w < 0 || pad->h < 0 || pad->x < 0 || pad->y < 0) {
199  av_log(ctx, AV_LOG_ERROR, "Negative values are not acceptable.\n");
200  return AVERROR(EINVAL);
201  }
202 
203  if (!pad->w)
204  pad->w = inlink->w;
205  if (!pad->h)
206  pad->h = inlink->h;
207 
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);
212 
213  pad->in_w = inlink->w & ~((1 << pad->hsub) - 1);
214  pad->in_h = inlink->h & ~((1 << pad->vsub) - 1);
215 
216  memcpy(rgba_color, pad->color, sizeof(rgba_color));
217  ff_fill_line_with_color(pad->line, pad->line_step, pad->w, pad->color,
218  inlink->format, rgba_color, &is_packed_rgba, NULL);
219 
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,
222  pad->color[0], pad->color[1], pad->color[2], pad->color[3],
223  is_packed_rgba ? "rgba" : "yuva");
224 
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) {
229  av_log(ctx, AV_LOG_ERROR,
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);
232  return AVERROR(EINVAL);
233  }
234 
235  return 0;
236 
237 eval_fail:
238  av_log(NULL, AV_LOG_ERROR,
239  "Error when evaluating the expression '%s'\n", expr);
240  return ret;
241 
242 }
243 
244 static int config_output(AVFilterLink *outlink)
245 {
246  PadContext *pad = outlink->src->priv;
247 
248  outlink->w = pad->w;
249  outlink->h = pad->h;
250  return 0;
251 }
252 
253 static AVFilterBufferRef *get_video_buffer(AVFilterLink *inlink, int perms, int w, int h)
254 {
255  PadContext *pad = inlink->dst->priv;
256 
257  AVFilterBufferRef *picref = avfilter_get_video_buffer(inlink->dst->outputs[0], perms,
258  w + (pad->w - pad->in_w),
259  h + (pad->h - pad->in_h));
260  int plane;
261 
262  picref->video->w = w;
263  picref->video->h = h;
264 
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;
268 
269  picref->data[plane] += (pad->x >> hsub) * pad->line_step[plane] +
270  (pad->y >> vsub) * picref->linesize[plane];
271  }
272 
273  return picref;
274 }
275 
276 static int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, int hsub, int vsub, int x, int y)
277 {
278  int64_t x_in_buf, y_in_buf;
279 
280  x_in_buf = outpicref->data[plane] - outpicref->buf->data[plane]
281  + (x >> hsub) * pad ->line_step[plane]
282  + (y >> vsub) * outpicref->linesize [plane];
283 
284  if(x_in_buf < 0 || x_in_buf % pad->line_step[plane])
285  return 1;
286  x_in_buf /= pad->line_step[plane];
287 
288  av_assert0(outpicref->buf->linesize[plane]>0); //while reference can use negative linesize the main buffer should not
289 
290  y_in_buf = x_in_buf / outpicref->buf->linesize[plane];
291  x_in_buf %= outpicref->buf->linesize[plane];
292 
293  if( y_in_buf<<vsub >= outpicref->buf->h
294  || x_in_buf<<hsub >= outpicref->buf->w)
295  return 1;
296  return 0;
297 }
298 
299 static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
300 {
301  PadContext *pad = inlink->dst->priv;
302  AVFilterBufferRef *outpicref = avfilter_ref_buffer(inpicref, ~0);
303  AVFilterBufferRef *for_next_filter;
304  int plane;
305 
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;
309 
310  av_assert0(outpicref->buf->w>0 && outpicref->buf->h>0);
311 
312  if(outpicref->format != outpicref->buf->format) //unsupported currently
313  break;
314 
315  outpicref->data[plane] -= (pad->x >> hsub) * pad ->line_step[plane]
316  + (pad->y >> vsub) * outpicref->linesize [plane];
317 
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)
322  )
323  break;
324  }
325  pad->needs_copy= plane < 4 && outpicref->data[plane];
326  if(pad->needs_copy){
327  av_log(inlink->dst, AV_LOG_DEBUG, "Direct padding impossible allocating new frame\n");
328  avfilter_unref_buffer(outpicref);
330  FFMAX(inlink->w, pad->w),
331  FFMAX(inlink->h, pad->h));
332  avfilter_copy_buffer_ref_props(outpicref, inpicref);
333  }
334 
335  inlink->dst->outputs[0]->out_buf = outpicref;
336 
337  outpicref->video->w = pad->w;
338  outpicref->video->h = pad->h;
339 
340  for_next_filter = avfilter_ref_buffer(outpicref, ~0);
341  avfilter_start_frame(inlink->dst->outputs[0], for_next_filter);
342 }
343 
344 static void end_frame(AVFilterLink *link)
345 {
346  avfilter_end_frame(link->dst->outputs[0]);
349 }
350 
351 static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)
352 {
353  PadContext *pad = link->dst->priv;
354  int bar_y, bar_h = 0;
355 
356  if (slice_dir * before_slice == 1 && y == pad->y) {
357  /* top bar */
358  bar_y = 0;
359  bar_h = pad->y;
360  } else if (slice_dir * before_slice == -1 && (y + h) == (pad->y + pad->in_h)) {
361  /* bottom bar */
362  bar_y = pad->y + pad->in_h;
363  bar_h = pad->h - pad->in_h - pad->y;
364  }
365 
366  if (bar_h) {
368  link->dst->outputs[0]->out_buf->linesize,
369  pad->line, pad->line_step, pad->hsub, pad->vsub,
370  0, bar_y, pad->w, bar_h);
371  avfilter_draw_slice(link->dst->outputs[0], bar_y, bar_h, slice_dir);
372  }
373 }
374 
375 static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
376 {
377  PadContext *pad = link->dst->priv;
378  AVFilterBufferRef *outpic = link->dst->outputs[0]->out_buf;
379  AVFilterBufferRef *inpic = link->cur_buf;
380 
381  y += pad->y;
382 
383  y &= ~((1 << pad->vsub) - 1);
384  h &= ~((1 << pad->vsub) - 1);
385 
386  if (!h)
387  return;
388  draw_send_bar_slice(link, y, h, slice_dir, 1);
389 
390  /* left border */
391  ff_draw_rectangle(outpic->data, outpic->linesize, pad->line, pad->line_step,
392  pad->hsub, pad->vsub, 0, y, pad->x, h);
393 
394  if(pad->needs_copy){
395  ff_copy_rectangle(outpic->data, outpic->linesize,
396  inpic->data, inpic->linesize, pad->line_step,
397  pad->hsub, pad->vsub,
398  pad->x, y, y-pad->y, inpic->video->w, h);
399  }
400 
401  /* right border */
402  ff_draw_rectangle(outpic->data, outpic->linesize,
403  pad->line, pad->line_step, pad->hsub, pad->vsub,
404  pad->x + pad->in_w, y, pad->w - pad->x - pad->in_w, h);
405  avfilter_draw_slice(link->dst->outputs[0], y, h, slice_dir);
406 
407  draw_send_bar_slice(link, y, h, slice_dir, -1);
408 }
409 
411  .name = "pad",
412  .description = NULL_IF_CONFIG_SMALL("Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
413 
414  .priv_size = sizeof(PadContext),
415  .init = init,
416  .uninit = uninit,
418 
419  .inputs = (AVFilterPad[]) {{ .name = "default",
420  .type = AVMEDIA_TYPE_VIDEO,
421  .config_props = config_input,
422  .get_video_buffer = get_video_buffer,
423  .start_frame = start_frame,
424  .draw_slice = draw_slice,
425  .end_frame = end_frame, },
426  { .name = NULL}},
427 
428  .outputs = (AVFilterPad[]) {{ .name = "default",
429  .type = AVMEDIA_TYPE_VIDEO,
430  .config_props = config_output, },
431  { .name = NULL}},
432 };
uint8_t * data[8]
buffer data for each plane/channel
Definition: avfilter.h:62
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:68
int format
media format
Definition: avfilter.h:77
AVFilterBufferRef * avfilter_get_video_buffer(AVFilterLink *link, int perms, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: avfilter.c:289
Definition: vf_pad.c:55
int vsub
chroma subsampling values
Definition: vf_pad.c:104
AVFilterBufferRefVideoProps * video
video buffer specific properties
Definition: avfilter.h:141
int linesize[8]
number of bytes per line
Definition: avfilter.h:127
misc image utilities
static void avfilter_copy_buffer_ref_props(AVFilterBufferRef *dst, AVFilterBufferRef *src)
Copy properties of src to dst, without copying the actual data.
Definition: avfilter.h:148
int in_h
width and height for the padded input video, which has to be aligned to the chroma values in order to...
Definition: vf_pad.c:94
int x
Definition: vf_pad.c:93
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV422P and setting color_...
Definition: pixfmt.h:77
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:71
Various defines for YUV<->RGB conversion.
static int config_output(AVFilterLink *outlink)
Definition: vf_pad.c:244
Definition: vf_pad.c:62
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:66
int h
width and height of the allocated buffer
Definition: avfilter.h:78
char w_expr[256]
width expression string
Definition: vf_pad.c:96
int w
Definition: vf_pad.c:92
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
Definition: mem.c:147
char h_expr[256]
height expression string
Definition: vf_pad.c:97
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV444P and setting color_...
Definition: pixfmt.h:78
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:64
#define av_cold
Definition: attributes.h:71
int linesize[8]
number of bytes per line
Definition: avfilter.h:63
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:70
Definition: vf_pad.c:64
void avfilter_end_frame(AVFilterLink *link)
Notifie the next filter that the current frame has finished.
Definition: avfilter.c:430
Definition: vf_pad.c:59
char y_expr[256]
height expression string
Definition: vf_pad.c:99
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:95
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of PIX_FMT_YUV420P and setting color_...
Definition: pixfmt.h:76
var_name
Definition: vf_boxblur.c:43
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.
Definition: parseutils.c:301
A filter pad used for either input or output.
Definition: avfilter.h:312
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.
Definition: eval.c:524
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])
Definition: drawutils.c:26
void avfilter_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: defaults.c:234
int h
image height
Definition: avfilter.h:108
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:75
#define AVERROR(e)
Definition: error.h:43
AVFilterBuffer * buf
the buffer that this is a reference to
Definition: avfilter.h:125
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:191
void * priv
private data for use by the filter
Definition: avfilter.h:553
static int config_input(AVFilterLink *inlink)
Definition: vf_pad.c:139
Definition: graph2dot.c:39
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
Definition: log.c:140
AVFilterFormats * avfilter_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:90
const AVPixFmtDescriptor av_pix_fmt_descriptors[PIX_FMT_NB]
The array of all the pixel format descriptors.
Definition: pixdesc.c:119
#define FFMAX(a, b)
Definition: common.h:53
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.
Definition: avstring.c:64
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:69
Definition: vf_pad.c:56
#define NAN
Definition: mathematics.h:54
static void start_frame(AVFilterLink *inlink, AVFilterBufferRef *inpicref)
Definition: vf_pad.c:299
#define M_E
Definition: ratecontrol.c:39
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of PIX_FMT_YUV440P and setting color_range ...
Definition: pixfmt.h:100
Definition: vf_pad.c:58
AVFilter avfilter_vf_pad
Definition: vf_pad.c:410
int y
offsets of the input area with respect to the padded area
Definition: vf_pad.c:93
int in_w
Definition: vf_pad.c:94
Definition: vf_pad.c:60
static void end_frame(AVFilterLink *link)
Definition: vf_pad.c:344
void avfilter_draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Send a slice to the next filter.
Definition: avfilter.c:447
void avfilter_unref_buffer(AVFilterBufferRef *ref)
Remove a reference to a buffer.
Definition: avfilter.c:73
A reference to an AVFilterBuffer.
Definition: avfilter.h:124
NULL
Definition: eval.c:50
static int does_clip(PadContext *pad, AVFilterBufferRef *outpicref, int plane, int hsub, int vsub, int x, int y)
Definition: vf_pad.c:276
misc drawing utilities
static const char * var_names[]
Definition: vf_pad.c:38
Definition: vf_pad.c:67
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:55
static void draw_slice(AVFilterLink *link, int y, int h, int slice_dir)
Definition: vf_pad.c:375
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:92
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:111
int needs_copy
Definition: vf_pad.c:105
Filter definition.
Definition: avfilter.h:497
AVFilterBufferRef * avfilter_ref_buffer(AVFilterBufferRef *ref, int pmask)
Add a new reference to a buffer.
Definition: avfilter.c:47
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)
Definition: drawutils.c:99
void avfilter_start_frame(AVFilterLink *link, AVFilterBufferRef *picref)
Notify the next filter of the start of a frame.
Definition: avfilter.c:400
uint8_t color[4]
color expressed either in YUVA or RGBA colorspace for the padding area
Definition: vf_pad.c:101
#define M_PHI
Definition: mathematics.h:42
Definition: vf_pad.c:63
const char * name
filter name
Definition: avfilter.h:498
Definition: vf_pad.c:61
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:67
misc parsing utilities
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:551
static AVFilterBufferRef * get_video_buffer(AVFilterLink *inlink, int perms, int w, int h)
Definition: vf_pad.c:253
static int query_formats(AVFilterContext *ctx)
Definition: vf_pad.c:70
PixelFormat
Pixel format.
Definition: pixfmt.h:62
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:125
Definition: vf_pad.c:57
uint8_t * line[4]
Definition: vf_pad.c:102
static const uint8_t color[]
Definition: log.c:44
static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
Definition: vf_pad.c:108
#define AV_PERM_WRITE
can write to the buffer
Definition: avfilter.h:82
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:66
uint8_t * data[8]
picture/audio data for each plane
Definition: avfilter.h:126
int format
media format
Definition: avfilter.h:128
int h
output dimensions, a value of 0 will result in the input size
Definition: vf_pad.c:92
int line_step[4]
Definition: vf_pad.c:103
An instance of a filter.
Definition: avfilter.h:538
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:93
#define AV_LOG_INFO
Definition: log.h:119
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:94
char x_expr[256]
width expression string
Definition: vf_pad.c:98
int hsub
Definition: vf_pad.c:104
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_pad.c:128
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)
Definition: drawutils.c:79
#define M_PI
Definition: cos_tablegen.c:28
#define AV_PERM_NEG_LINESIZES
the buffer requested can have negative linesizes
Definition: avfilter.h:86
simple arithmetic expression evaluator
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
static void draw_send_bar_slice(AVFilterLink *link, int y, int h, int slice_dir, int before_slice)
Definition: vf_pad.c:351