diff options
Diffstat (limited to 'libmpcodecs/vf_dsize.c')
-rw-r--r-- | libmpcodecs/vf_dsize.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/libmpcodecs/vf_dsize.c b/libmpcodecs/vf_dsize.c index 7772b3732d..d46d22ebb2 100644 --- a/libmpcodecs/vf_dsize.c +++ b/libmpcodecs/vf_dsize.c @@ -39,29 +39,31 @@ static int config(struct vf_instance *vf, int width, int height, int d_width, int d_height, unsigned int flags, unsigned int outfmt) { + int w = vf->priv->w; + int h = vf->priv->h; if (vf->priv->aspect < 0.001) { // did the user input aspect or w,h params - if (vf->priv->w == 0) vf->priv->w = d_width; - if (vf->priv->h == 0) vf->priv->h = d_height; - if (vf->priv->w == -1) vf->priv->w = width; - if (vf->priv->h == -1) vf->priv->h = height; - if (vf->priv->w == -2) vf->priv->w = vf->priv->h * (double)d_width / d_height; - if (vf->priv->w == -3) vf->priv->w = vf->priv->h * (double)width / height; - if (vf->priv->h == -2) vf->priv->h = vf->priv->w * (double)d_height / d_width; - if (vf->priv->h == -3) vf->priv->h = vf->priv->w * (double)height / width; + if (w == 0) w = d_width; + if (h == 0) h = d_height; + if (w == -1) w = width; + if (h == -1) h = height; + if (w == -2) w = h * (double)d_width / d_height; + if (w == -3) w = h * (double)width / height; + if (h == -2) h = w * (double)d_height / d_width; + if (h == -3) h = w * (double)height / width; if (vf->priv->method > -1) { double aspect = (vf->priv->method & 2) ? ((double)height / width) : ((double)d_height / d_width); - if ((vf->priv->h > vf->priv->w * aspect) ^ (vf->priv->method & 1)) { - vf->priv->h = vf->priv->w * aspect; + if ((h > w * aspect) ^ (vf->priv->method & 1)) { + h = w * aspect; } else { - vf->priv->w = vf->priv->h / aspect; + w = h / aspect; } } if (vf->priv->round > 1) { // round up - vf->priv->w += (vf->priv->round - 1 - (vf->priv->w - 1) % vf->priv->round); - vf->priv->h += (vf->priv->round - 1 - (vf->priv->h - 1) % vf->priv->round); + w += (vf->priv->round - 1 - (w - 1) % vf->priv->round); + h += (vf->priv->round - 1 - (h - 1) % vf->priv->round); } - d_width = vf->priv->w; - d_height = vf->priv->h; + d_width = w; + d_height = h; } else { if (vf->priv->aspect * height > width) { d_width = height * vf->priv->aspect + .5; |