95 #define OFFSET(x) offsetof(ScaleContext, x)
96 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
115 static const char *shorthand[] = {
"w",
"h",
NULL };
117 const char *args0 = args;
119 scale->
class = &scale_class;
135 "Size and width/height expressions cannot be set at the same time.\n");
143 "Invalid size '%s'\n", scale->
size_str);
146 snprintf(buf,
sizeof(buf)-1,
"%d", scale->
w);
148 snprintf(buf,
sizeof(buf)-1,
"%d", scale->
h);
220 double var_values[
VARS_NB], res;
228 var_values[
VAR_A] = (double) inlink->
w / inlink->
h;
256 if (w < -1 || h < -1) {
260 if (w == -1 && h == -1)
261 scale->
w = scale->
h = 0;
272 if (w > INT_MAX || h > INT_MAX ||
273 (h * inlink->
w) > INT_MAX ||
274 (w * inlink->
h) > INT_MAX)
290 if (inlink->
w == outlink->
w && inlink->
h == outlink->
h &&
295 outlink->
w, outlink->
h, outfmt,
300 outlink->
w, outlink->
h/2, outfmt,
305 outlink->
w, outlink->
h/2, outfmt,
307 if (!scale->
sws || !scale->
isws[0] || !scale->
isws[1])
316 av_log(ctx,
AV_LOG_VERBOSE,
"w:%d h:%d fmt:%s sar:%d/%d -> w:%d h:%d fmt:%s sar:%d/%d flags:0x%0x\n",
326 "Error when evaluating the expression '%s'.\n"
327 "Maybe the expression for out_w:'%s' or for out_h:'%s' is self-referencing.\n",
337 int in_stride[4],out_stride[4];
341 int vsub= ((i+1)&2) ? scale->
vsub : 0;
342 in_stride[i] = cur_pic->
linesize[i] * mul;
343 out_stride[i] = out_buf->
linesize[i] * mul;
344 in[i] = cur_pic->
data[i] + ((y>>vsub)+field) * cur_pic->
linesize[i];
345 out[i] = out_buf->
data[i] + field * out_buf->
linesize[i];
348 in[1] = cur_pic->
data[1];
350 out[1] = out_buf->
data[1];
352 return sws_scale(sws, in, in_stride, y/mul, h,
368 snprintf(buf,
sizeof(buf)-1,
"%d", outlink->
w);
370 snprintf(buf,
sizeof(buf)-1,
"%d", outlink->
h);
437 .description =
NULL_IF_CONFIG_SMALL(
"Scale the input video to width:height size and/or convert the image format."),
446 .
inputs = avfilter_vf_scale_inputs,
447 .
outputs = avfilter_vf_scale_outputs,
448 .priv_class = &scale_class,