130 for (i = 0; i < 4; i++) {
142 int ret, is_packed_rgba;
143 double var_values[
VARS_NB], res;
149 var_values[
VAR_PI] = M_PI;
156 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
167 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
173 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
180 NULL, NULL, NULL, NULL, NULL, 0, ctx);
181 s->
x = var_values[
VAR_X] = res;
184 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
186 s->
y = var_values[
VAR_Y] = res;
190 NULL, NULL, NULL, NULL, NULL, 0, ctx)) < 0)
192 s->
x = var_values[
VAR_X] = res;
195 if (s->
w < 0 || s->
h < 0 || s->
x < 0 || s->
y < 0) {
205 s->
w &= ~((1 << s->
hsub) - 1);
206 s->
h &= ~((1 << s->
vsub) - 1);
207 s->
x &= ~((1 << s->
hsub) - 1);
208 s->
y &= ~((1 << s->
vsub) - 1);
210 s->
in_w = inlink->
w & ~((1 << s->
hsub) - 1);
211 s->
in_h = inlink->
h & ~((1 << s->
vsub) - 1);
213 memcpy(rgba_color, s->
color,
sizeof(rgba_color));
215 inlink->
format, rgba_color, &is_packed_rgba, NULL);
218 inlink->
w, inlink->
h, s->
w, s->
h, s->
x, s->
y,
220 is_packed_rgba ?
"rgba" :
"yuva");
222 if (s->
x < 0 || s->
y < 0 ||
223 s->
w <= 0 || s->
h <= 0 ||
224 (
unsigned)s->
x + (
unsigned)inlink->
w > s->
w ||
225 (
unsigned)s->
y + (
unsigned)inlink->
h > s->
h) {
227 "Input area %d:%d:%d:%d not within the padded area 0:0:%d:%d or zero-sized\n",
228 s->
x, s->
y, s->
x + inlink->
w, s->
y + inlink->
h, s->
w, s->
h);
236 "Error when evaluating the expression '%s'\n", expr);
255 w + (s->
w - s->
in_w),
256 h + (s->
h - s->
in_h));
265 for (plane = 0; plane < 4 && frame->
data[plane]; plane++) {
266 int hsub = (plane == 1 || plane == 2) ? s->
hsub : 0;
267 int vsub = (plane == 1 || plane == 2) ? s->
vsub : 0;
279 int planes[4] = { -1, -1, -1, -1}, *p = planes;
290 for (i = 0; i < FF_ARRAY_ELEMS(planes) && planes[i] >= 0; i++) {
291 int hsub = (planes[i] == 1 || planes[i] == 2) ? s->
hsub : 0;
292 int vsub = (planes[i] == 1 || planes[i] == 2) ? s->
vsub : 0;
300 ptrdiff_t req_start = (s->
x >> hsub) * s->
line_step[planes[i]] +
301 (s->
y >> vsub) * frame->
linesize[planes[i]];
302 ptrdiff_t req_end = ((s->
w - s->
x - frame->
width) >> hsub) *
304 (s->
y >> vsub) * frame->
linesize[planes[i]];
308 if (start - buf->
data < req_start ||
309 (buf->
data + buf->
size) - end < req_end)
312 #define SIGN(x) ((x) > 0 ? 1 : -1)
313 for (j = 0; j < FF_ARRAY_ELEMS(planes) && planes[j] >= 0; j++) {
314 int hsub1 = (planes[j] == 1 || planes[j] == 2) ? s->
hsub : 0;
321 if (
SIGN(start - end1) !=
SIGN(start - end1 - req_start) ||
322 SIGN(end - start1) !=
SIGN(end - start1 + req_end))
365 int hsub = (i == 1 || i == 2) ? s->
hsub : 0;
366 int vsub = (i == 1 || i == 2) ? s->
vsub : 0;
380 if (s->
h > s->
y + s->
in_h) {
410 #define OFFSET(x) offsetof(PadContext, x)
411 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM
415 {
"x",
"Horizontal position of the left edge of the input video in the "
417 {
"y",
"Vertical position of the top edge of the input video in the "
452 .description =
NULL_IF_CONFIG_SMALL(
"Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black)."),
455 .priv_class = &pad_class,
460 .
inputs = avfilter_vf_pad_inputs,
462 .
outputs = avfilter_vf_pad_outputs,