avfilter/vf_scale: simplify alignment code

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
pull/55/head
Michael Niedermayer 11 years ago
parent 1e48c39ece
commit 214a3b8bf9
  1. 13
      libavfilter/vf_scale.c

@ -273,22 +273,17 @@ static int config_props(AVFilterLink *outlink)
h = scale->h; h = scale->h;
/* Check if it is requested that the result has to be divisible by a some /* Check if it is requested that the result has to be divisible by a some
* factor (w or h = -n with n being the factor). After we got the factor, * factor (w or h = -n with n being the factor). */
* we set w/h back to -1 so that the automatic scaling is done. */
factor_w = 1; factor_w = 1;
factor_h = 1; factor_h = 1;
if (w < -1) { if (w < -1) {
factor_w = -w; factor_w = -w;
w = -1;
scale->w = -1;
} }
if (h < -1) { if (h < -1) {
factor_h = -h; factor_h = -h;
h = -1;
scale->h = -1;
} }
if (w == -1 && h == -1) if (w < 0 && h < 0)
scale->w = scale->h = 0; scale->w = scale->h = 0;
if (!(w = scale->w)) if (!(w = scale->w))
@ -299,9 +294,9 @@ static int config_props(AVFilterLink *outlink)
/* Make sure that the result is divisible by the factor we determined /* 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 * earlier. If no factor was set, it is nothing will happen as the default
* factor is 1 */ * factor is 1 */
if (w == -1) if (w < 0)
w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w; w = av_rescale(h, inlink->w, inlink->h * factor_w) * factor_w;
if (h == -1) if (h < 0)
h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h; h = av_rescale(w, inlink->h, inlink->w * factor_h) * factor_h;
/* Note that force_original_aspect_ratio may overwrite the previous set /* Note that force_original_aspect_ratio may overwrite the previous set

Loading…
Cancel
Save