OSDN Git Service

prevent crash with strict ana and non-mod-2 dimensions.
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 17 Dec 2010 16:31:54 +0000 (16:31 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 17 Dec 2010 16:31:54 +0000 (16:31 +0000)
and make par computation in loose ana a little more accurate.

git-svn-id: svn://localhost/HandBrake/trunk@3710 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/hb.c
libhb/work.c

index 3d669f2..da09ea0 100644 (file)
@@ -963,10 +963,12 @@ void hb_set_anamorphic_size( hb_job_t * job,
     {
         case 1:
             /* Strict anamorphic */
-            *output_width = cropped_width;
-            *output_height = cropped_height;
-            *output_par_width = title->pixel_aspect_width;
-            *output_par_height = title->pixel_aspect_height;
+            *output_width  = MULTIPLE_MOD( cropped_width, 2 );
+            *output_height = MULTIPLE_MOD( cropped_height, 2 );
+            // adjust the source PAR for new width/height
+            // new PAR = source PAR * ( old width / new_width ) * ( new_height / old_height )
+            pixel_aspect_width = title->pixel_aspect_width * cropped_width * (*output_height);            
+            pixel_aspect_height = title->pixel_aspect_height * (*output_width) * cropped_height;
         break;
 
         case 2:
@@ -1007,8 +1009,8 @@ void hb_set_anamorphic_size( hb_job_t * job,
             /* The film AR is the source's display width / cropped source height.
                The output display width is the output height * film AR.
                The output PAR is the output display width / output storage width. */
-            pixel_aspect_width = height * source_display_width / cropped_height;
-            pixel_aspect_height = width;
+            pixel_aspect_width = height * cropped_width * pixel_aspect_width;
+            pixel_aspect_height = width * cropped_height * pixel_aspect_height;
 
             /* Pass the results back to the caller */
             *output_width = width;
index cf8d4d4..9504d4d 100644 (file)
@@ -449,6 +449,7 @@ static void do_job( hb_job_t * job, int cpu_count )
                 job->anamorphic.par_width >>= 1;
                 job->anamorphic.par_height >>= 1;
             }
+            hb_reduce( &job->anamorphic.par_width, &job->anamorphic.par_height, job->anamorphic.par_width, job->anamorphic.par_height );
         }
     }