summaryrefslogtreecommitdiff
path: root/libavfilter/vf_scale_cuda.c
diff options
context:
space:
mode:
authorGyan Doshi <ffmpeg@gyani.pro>2019-12-02 21:11:21 +0530
committerGyan Doshi <ffmpeg@gyani.pro>2019-12-08 16:12:31 +0530
commit1b4f473d181abaa0ff4e2d63862f61763a5a6860 (patch)
tree5422676836648b8e68264bf35c236e4442363610 /libavfilter/vf_scale_cuda.c
parentff2b75d94cee65e47db7a56f3924497016e5b420 (diff)
avfilter/scale.c: factorize ff_scale_eval_dimensions
Adjustment of evaluated values shifted to ff_adjust_scale_dimensions Shifted code for force_original_aspect_ratio and force_divisble_by from vf_scale so it is now available for scale_cuda, scale_npp and scale_vaapi as well.
Diffstat (limited to 'libavfilter/vf_scale_cuda.c')
-rw-r--r--libavfilter/vf_scale_cuda.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/libavfilter/vf_scale_cuda.c b/libavfilter/vf_scale_cuda.c
index 0a73ea1422..cca68dd835 100644
--- a/libavfilter/vf_scale_cuda.c
+++ b/libavfilter/vf_scale_cuda.c
@@ -82,6 +82,9 @@ typedef struct CUDAScaleContext {
char *w_expr; ///< width expression string
char *h_expr; ///< height expression string
+ int force_original_aspect_ratio;
+ int force_divisible_by;
+
CUcontext cu_ctx;
CUmodule cu_module;
CUfunction cu_func_uchar;
@@ -305,6 +308,9 @@ static av_cold int cudascale_config_props(AVFilterLink *outlink)
&w, &h)) < 0)
goto fail;
+ ff_scale_adjust_dimensions(inlink, &w, &h,
+ s->force_original_aspect_ratio, s->force_divisible_by);
+
if (((int64_t)h * inlink->w) > INT_MAX ||
((int64_t)w * inlink->h) > INT_MAX)
av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
@@ -536,6 +542,11 @@ fail:
static const AVOption options[] = {
{ "w", "Output video width", OFFSET(w_expr), AV_OPT_TYPE_STRING, { .str = "iw" }, .flags = FLAGS },
{ "h", "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, { .str = "ih" }, .flags = FLAGS },
+ { "force_original_aspect_ratio", "decrease or increase w/h if necessary to keep the original AR", OFFSET(force_original_aspect_ratio), AV_OPT_TYPE_INT, { .i64 = 0}, 0, 2, FLAGS, "force_oar" },
+ { "disable", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 0 }, 0, 0, FLAGS, "force_oar" },
+ { "decrease", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, FLAGS, "force_oar" },
+ { "increase", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = 2 }, 0, 0, FLAGS, "force_oar" },
+ { "force_divisible_by", "enforce that the output resolution is divisible by a defined integer when force_original_aspect_ratio is used", OFFSET(force_divisible_by), AV_OPT_TYPE_INT, { .i64 = 1}, 1, 256, FLAGS },
{ NULL },
};