95 #define OFFSET(x) offsetof(PadContext, x)
96 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
103 {
"x",
"set the x offset expression for the input image position",
OFFSET(x_expr),
AV_OPT_TYPE_STRING, {.str =
"0"}, CHAR_MIN, CHAR_MAX,
FLAGS },
104 {
"y",
"set the y offset expression for the input image position",
OFFSET(y_expr),
AV_OPT_TYPE_STRING, {.str =
"0"}, CHAR_MIN, CHAR_MAX,
FLAGS },
114 static const char *shorthand[] = {
"width",
"height",
"x",
"y",
"color",
NULL };
117 pad->
class = &pad_class;
140 double var_values[
VARS_NB], res;
150 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
178 pad->
x = var_values[
VAR_X] = res;
183 pad->
y = var_values[
VAR_Y] = res;
189 pad->
x = var_values[
VAR_X] = res;
192 if (pad->
w < 0 || pad->
h < 0 || pad->
x < 0 || pad->
y < 0) {
210 inlink->
w, inlink->
h, pad->
w, pad->
h, pad->
x, pad->
y,
213 if (pad->
x < 0 || pad->
y < 0 ||
214 pad->
w <= 0 || pad->
h <= 0 ||
215 (
unsigned)pad->
x + (
unsigned)inlink->
w > pad->
w ||
216 (
unsigned)pad->
y + (
unsigned)inlink->
h > pad->
h) {
218 "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n",
219 pad->
x, pad->
y, pad->
x + inlink->
w, pad->
y + inlink->
h, pad->
w, pad->
h);
227 "Error when evaluating the expression '%s'\n", expr);
247 w + (pad->
w - pad->
in_w) + 4*align,
248 h + (pad->
h - pad->
in_h));
257 for (plane = 0; plane < 4 && picref->
data[plane]; plane++)
266 int64_t x_in_buf, y_in_buf;
268 x_in_buf = outpicref->
data[plane] - outpicref->
buf->
data[plane]
270 + (y >> vsub) * outpicref->
linesize[plane];
272 if(x_in_buf < 0 || x_in_buf % pad->draw.pixelstep[plane])
278 y_in_buf = x_in_buf / outpicref->
buf->
linesize[plane];
281 if( y_in_buf<<vsub >= outpicref->
buf->
h
282 || x_in_buf<<hsub >= outpicref->
buf->
w)
291 int plane, needs_copy;
298 for (plane = 0; plane < 4 && out->
data[plane] && pad->
draw.
pixelstep[plane]; plane++) {
310 if (
does_clip(pad, out, plane, hsub, vsub, 0, 0) ||
311 does_clip(pad, out, plane, hsub, vsub, 0, pad->
h - 1) ||
312 does_clip(pad, out, plane, hsub, vsub, pad->
w - 1, 0) ||
313 does_clip(pad, out, plane, hsub, vsub, pad->
w - 1, pad->
h - 1))
338 0, 0, pad->
w, pad->
y);
342 if (pad->
h > pad->
y + pad->
in_h) {
345 0, pad->
y + pad->
in_h, pad->
w, pad->
h - pad->
y - pad->
in_h);
360 pad->
x + pad->
in_w, pad->
y, pad->
w - pad->
x - pad->
in_w,
389 .description =
NULL_IF_CONFIG_SMALL(
"Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
396 .
inputs = avfilter_vf_pad_inputs,
398 .
outputs = avfilter_vf_pad_outputs,
399 .priv_class = &pad_class,