OSDN Git Service

fix some floating point rounding errors in aspect ratio calculations
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 5 Dec 2008 16:02:38 +0000 (16:02 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 5 Dec 2008 16:02:38 +0000 (16:02 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@2009 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb.c
libhb/scan.c

index 0589248..31b45c2 100644 (file)
@@ -589,7 +589,7 @@ void hb_set_anamorphic_size( hb_job_t * job,
     if ( job->maxWidth && (job->maxWidth < job->width) )
         width = job->maxWidth;
 
-    height = (double)width / storage_aspect;
+    height = ((double)width / storage_aspect) + 0.5;
     if ( job->maxHeight && (job->maxHeight < height) )
         height = job->maxHeight;
 
index 631fa43..6459c1d 100644 (file)
@@ -200,7 +200,7 @@ static void ScanFunc( void * _data )
             !job->pixel_aspect_width && !job->pixel_aspect_height)
         {
             hb_reduce( &job->pixel_aspect_width, &job->pixel_aspect_height,
-                       (int)(title->aspect * title->height), title->width );
+                       (int)(title->aspect * title->height + 0.5), title->width );
         }
 
         job->width = title->width - job->crop[2] - job->crop[3];
@@ -686,14 +686,14 @@ skip_preview:
             // aspect ratio from the DVD metadata. So, if the aspect computed
             // from the PAR is different from the container's aspect we use
             // the container's aspect & recompute the PAR from it.
-            if( title->container_aspect && title->aspect != title->container_aspect )
+            if( title->container_aspect && (int)(title->aspect * 9) != (int)(title->container_aspect * 9) )
             {
                 hb_log("scan: content PAR gives wrong aspect %.2f; "
                        "using container aspect %.2f", title->aspect,
                        title->container_aspect );
                 title->aspect = title->container_aspect;
                 hb_reduce( &title->pixel_aspect_width, &title->pixel_aspect_height,
-                           (int)(title->aspect * title->height), title->width );
+                           (int)(title->aspect * title->height + 0.5), title->width );
             }
         }