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)."),