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,