]> git.sesse.net Git - x264/commitdiff
Fix resize filter rounding code
authorJames Darnley <james.darnley@gmail.com>
Sun, 21 Nov 2010 09:50:48 +0000 (10:50 +0100)
committerFiona Glaser <fiona@x264.com>
Mon, 22 Nov 2010 15:04:45 +0000 (07:04 -0800)
filters/video/resize.c

index 04b5e73a6390fb7cf8f22a4e622964973320418b..aec53e15c9edbdf33665d3c2e69bbf13f241f265 100644 (file)
@@ -205,10 +205,10 @@ static int pick_closest_supported_csp( int csp )
 
 static int round_dbl( double val, int precision, int b_truncate )
 {
-    int ret = (int)(val / precision) * precision;
-    if( !b_truncate && (val - ret) >= (precision/2) ) // use the remainder if we're not truncating it
-        ret += precision;
-    return ret;
+    if( b_truncate )
+        return trunc(val / precision) * precision;
+    else
+        return round(val / precision) * precision;
 }
 
 static int handle_opts( const char **optlist, char **opts, video_info_t *info, resizer_hnd_t *h )