Special values are: 0 = original width/height -1 = keep original aspect This is in preparation for reusing the code for other QSV filters.
Unified · Split
| @@ -59,6 +59,11 @@ typedef struct VPPContext{ · 58 unmodified lines | ||
| 59 | 59 | mfxExtVPPMirroring mirroring_conf; |
| 60 | 60 | mfxExtVPPScaling scale_conf; |
| 61 | 61 | |
| 62 | + /** | |
| 63 | + * New dimensions. Special values are: | |
| 64 | + * 0 = original width/height | |
| 65 | + * -1 = keep original aspect | |
| 66 | + */ | |
| 62 | 67 | int out_width; |
| 63 | 68 | int out_height; |
| 64 | 69 | /** |
| @@ -127,10 +132,10 @@ static const AVOption options[] = { · 62 unmodified lines | ||
| 127 | 132 | { "cx", "set the x crop area expression", OFFSET(cx), AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, 0, 0, FLAGS }, |
| 128 | 133 | { "cy", "set the y crop area expression", OFFSET(cy), AV_OPT_TYPE_STRING, { .str = "(in_h-out_h)/2" }, 0, 0, FLAGS }, |
| 129 | 134 | |
| 130 | − { "w", "Output video width", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, | |
| 131 | − { "width", "Output video width", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, | |
| 132 | − { "h", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, | |
| 133 | − { "height", "Output video height", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, | |
| 135 | + { "w", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, | |
| 136 | + { "width", "Output video width(0=input video width, -1=keep input video aspect)", OFFSET(ow), AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS }, | |
| 137 | + { "h", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, | |
| 138 | + { "height", "Output video height(0=input video height, -1=keep input video aspect)", OFFSET(oh), AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS }, | |
| 134 | 139 | { "format", "Output pixel format", OFFSET(output_format_str), AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS }, |
| 135 | 140 | { "async_depth", "Internal parallelization depth, the higher the value the higher the latency.", OFFSET(async_depth), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, .flags = FLAGS }, |
| 136 | 141 | { "scale_mode", "scale & format conversion mode: 0=auto, 1=low power, 2=high quality", OFFSET(scale_mode), AV_OPT_TYPE_INT, { .i64 = MFX_SCALING_MODE_DEFAULT }, MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, .flags = FLAGS, "scale mode" }, |
| @@ -276,6 +281,7 @@ static int config_input(AVFilterLink *inlink) · 139 unmodified lines | ||
| 276 | 281 | AVFilterContext *ctx = inlink->dst; |
| 277 | 282 | VPPContext *vpp = ctx->priv; |
| 278 | 283 | int ret; |
| 284 | + int64_t ow, oh; | |
| 279 | 285 | |
| 280 | 286 | if (vpp->framerate.den == 0 || vpp->framerate.num == 0) |
| 281 | 287 | vpp->framerate = inlink->frame_rate; |
| @@ -289,11 +295,38 @@ static int config_input(AVFilterLink *inlink) · 7 unmodified lines | ||
| 289 | 295 | return ret; |
| 290 | 296 | } |
| 291 | 297 | |
| 292 | − if (vpp->out_height == 0 || vpp->out_width == 0) { | |
| 293 | − vpp->out_width = inlink->w; | |
| 294 | − vpp->out_height = inlink->h; | |
| 298 | + ow = vpp->out_width; | |
| 299 | + oh = vpp->out_height; | |
| 300 | + | |
| 301 | + /* sanity check params */ | |
| 302 | + if (ow < -1 || oh < -1) { | |
| 303 | + av_log(ctx, AV_LOG_ERROR, "Size values less than -1 are not acceptable.\n"); | |
| 304 | + return AVERROR(EINVAL); | |
| 295 | 305 | } |
| 296 | 306 | |
| 307 | + if (ow == -1 && oh == -1) | |
| 308 | + vpp->out_width = vpp->out_height = 0; | |
| 309 | + | |
| 310 | + if (!(ow = vpp->out_width)) | |
| 311 | + ow = inlink->w; | |
| 312 | + | |
| 313 | + if (!(oh = vpp->out_height)) | |
| 314 | + oh = inlink->h; | |
| 315 | + | |
| 316 | + if (ow == -1) | |
| 317 | + ow = av_rescale(oh, inlink->w, inlink->h); | |
| 318 | + | |
| 319 | + if (oh == -1) | |
| 320 | + oh = av_rescale(ow, inlink->h, inlink->w); | |
| 321 | + | |
| 322 | + if (ow > INT_MAX || oh > INT_MAX || | |
| 323 | + (oh * inlink->w) > INT_MAX || | |
| 324 | + (ow * inlink->h) > INT_MAX) | |
| 325 | + av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n"); | |
| 326 | + | |
| 327 | + vpp->out_width = ow; | |
| 328 | + vpp->out_height = oh; | |
| 329 | + | |
| 297 | 330 | if (vpp->use_crop) { |
| 298 | 331 | vpp->crop_x = FFMAX(vpp->crop_x, 0); |
| 299 | 332 | vpp->crop_y = FFMAX(vpp->crop_y, 0); |