[MPlayer-dev-eng] vf_dsize rounding error

Alan Curry pacman at TheWorld.com
Thu May 4 19:49:44 CEST 2006


In -vf dsize, resolution is calculated as a float and then assigned to an int
without any explicit rounding, so unlucky sizes can be computed as X.999999
and rounded down, ending up 1 less than the correct size. It would be better
to round to the nearest int.

Index: libmpcodecs/vf_dsize.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/vf_dsize.c,v
retrieving revision 1.4
diff -u -r1.4 vf_dsize.c
--- libmpcodecs/vf_dsize.c	20 Dec 2005 17:38:43 -0000	1.4
+++ libmpcodecs/vf_dsize.c	4 May 2006 17:38:06 -0000
@@ -46,10 +46,10 @@
 		d_height = vf->priv->h;
 	} else {
 		if (vf->priv->aspect * height > width) {
-			d_width = height * vf->priv->aspect;
+			d_width = height * vf->priv->aspect + .5;
 			d_height = height;
 		} else {
-			d_height = width / vf->priv->aspect;
+			d_height = width / vf->priv->aspect + .5;
 			d_width = width;
 		}
 	}




More information about the MPlayer-dev-eng mailing list