summaryrefslogtreecommitdiff
path: root/libavfilter/vf_scale.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-25 16:48:13 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-25 16:48:13 +0100
commit1e48c39ece3ec790dad9a0e308ebe1a77b2f08ba (patch)
treead4a241e602ef2cd6b01e257d333fc141ce359d0 /libavfilter/vf_scale.c
parent682ddb89cf15a7d5cc1a1a37156703c8abdcc872 (diff)
avfilter/vf_scale: do aspect ratio and scale factor compensation together
Fixes rounding error Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_scale.c')
-rw-r--r--libavfilter/vf_scale.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 945ed121dd..bb5cd39a78 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -295,16 +295,14 @@ static int config_props(AVFilterLink *outlink)
w = inlink->w;
if (!(h = scale->h))
h = inlink->h;
- if (w == -1)
- w = av_rescale(h, inlink->w, inlink->h);
- if (h == -1)
- h = av_rescale(w, inlink->h, inlink->w);
/* Make sure that the result is divisible by the factor we determined
* earlier. If no factor was set, it is nothing will happen as the default
* factor is 1 */
- w = (w / factor_w) * factor_w;
- h = (h / factor_h) * factor_h;
+ if (w == -1)
+ w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w;
+ if (h == -1)
+ h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h;
/* Note that force_original_aspect_ratio may overwrite the previous set
* dimensions so that it is not divisible by the set factors anymore. */