aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/vf_scale.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.c
parentff2b75d94cee65e47db7a56f3924497016e5b420 (diff)
downloadffmpeg-1b4f473d181abaa0ff4e2d63862f61763a5a6860.tar.gz
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.c')
-rw-r--r--libavfilter/vf_scale.c28
1 files changed, 3 insertions, 25 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 41ddec7661..b7f541be1f 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -237,31 +237,9 @@ static int config_props(AVFilterLink *outlink)
&w, &h)) < 0)
goto fail;
- /* Note that force_original_aspect_ratio may overwrite the previous set
- * dimensions so that it is not divisible by the set factors anymore
- * unless force_divisible_by is defined as well */
- if (scale->force_original_aspect_ratio) {
- int tmp_w = av_rescale(h, inlink->w, inlink->h);
- int tmp_h = av_rescale(w, inlink->h, inlink->w);
-
- if (scale->force_original_aspect_ratio == 1) {
- w = FFMIN(tmp_w, w);
- h = FFMIN(tmp_h, h);
- if (scale->force_divisible_by > 1) {
- // round down
- w = w / scale->force_divisible_by * scale->force_divisible_by;
- h = h / scale->force_divisible_by * scale->force_divisible_by;
- }
- } else {
- w = FFMAX(tmp_w, w);
- h = FFMAX(tmp_h, h);
- if (scale->force_divisible_by > 1) {
- // round up
- w = (w + scale->force_divisible_by - 1) / scale->force_divisible_by * scale->force_divisible_by;
- h = (h + scale->force_divisible_by - 1) / scale->force_divisible_by * scale->force_divisible_by;
- }
- }
- }
+ ff_scale_adjust_dimensions(inlink, &w, &h,
+ scale->force_original_aspect_ratio,
+ scale->force_divisible_by);
if (w > INT_MAX || h > INT_MAX ||
(h * inlink->w) > INT_MAX ||