OSDN Git Service

Adds a keep_display_aspect toggle to the job->anamorphic struct in order to fix a...
authorjbrjake <jbrjake@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 6 Jun 2009 17:02:17 +0000 (17:02 +0000)
committerjbrjake <jbrjake@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sat, 6 Jun 2009 17:02:17 +0000 (17:02 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@2492 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.h
libhb/hb.c
libhb/work.c
test/test.c

index f677d8b..e6d0566 100644 (file)
@@ -181,6 +181,7 @@ struct hb_job_s
         int             par_height;
         int             dar_width;
         int             dar_height;
+        int             keep_display_aspect;
     } anamorphic;
     
     int             maxWidth;
index c65cc58..2311902 100644 (file)
@@ -801,11 +801,19 @@ void hb_set_anamorphic_size( hb_job_t * job,
                    this is an output PAR, to correct a source, and it should not be assumed
                    that it properly creates a display aspect ratio when applied to the source,
                    which could easily be stored in a different resolution. */
-                   
-                int output_display_width = width * (double)pixel_aspect_width /
-                    (double)pixel_aspect_height;
-                pixel_aspect_width = output_display_width;
-                pixel_aspect_height = width;
+                if( job->anamorphic.keep_display_aspect )
+                {
+                    /* We can ignore the possibility of a PAR change */
+                    pixel_aspect_width = height * ( (double)source_display_width / (double)cropped_height );
+                    pixel_aspect_height = width;
+                }
+                else
+                {
+                    int output_display_width = width * (double)pixel_aspect_width /
+                        (double)pixel_aspect_height;
+                    pixel_aspect_width = output_display_width;
+                    pixel_aspect_height = width;
+                }
             }
             
             /* Back to caller */
index e99feaa..53d9e27 100644 (file)
@@ -205,9 +205,21 @@ void hb_display_job_info( hb_job_t * job )
     if( job->anamorphic.mode )
     {
         hb_log( "   + %s anamorphic", job->anamorphic.mode == 1 ? "strict" : job->anamorphic.mode == 2? "loose" : "custom" );
+        if( job->anamorphic.mode == 3 && job->anamorphic.keep_display_aspect )
+        {
+            hb_log( "     + keeping source display aspect ratio"); 
+        }
+        if( job->anamorphic.modulus != 16 )
+        {
+            hb_log( "     + modulus: %i", job->anamorphic.modulus ); 
+        }
         hb_log( "     + storage dimensions: %d * %d -> %d * %d, crop %d/%d/%d/%d",
                     title->width, title->height, job->width, job->height,
                     job->crop[0], job->crop[1], job->crop[2], job->crop[3] );
+        if( job->anamorphic.itu_par )
+        {
+            hb_log( "     + using ITU pixel aspect ratio values"); 
+        }
         hb_log( "     + pixel aspect ratio: %i / %i", job->anamorphic.par_width, job->anamorphic.par_height );
         hb_log( "     + display dimensions: %.0f * %i",
             (float)( job->width * job->anamorphic.par_width / job->anamorphic.par_height ), job->height );
index d956966..94404d2 100644 (file)
@@ -1105,6 +1105,8 @@ static int HandleEvents( hb_handle_t * h )
                     
                     if( keep_display_aspect )
                     {
+                        job->anamorphic.keep_display_aspect = 1;
+                        
                         /* First, what *is* the display aspect? */
                         int cropped_width = title->width - job->crop[2] - job->crop[3];
                         int cropped_height = title->height - job->crop[0] - job->crop[1];
@@ -1114,8 +1116,7 @@ static int HandleEvents( hb_handle_t * h )
                            asked for ITU values instead. */
                         float source_display_width = (float)cropped_width *
                             (float)title->pixel_aspect_width / (float)title->pixel_aspect_height;
-                        float display_aspect = source_display_width / cropped_height;
-                        
+                        float display_aspect = source_display_width / (float)cropped_height;
                         /* When keeping display aspect, we have to rank some values
                            by priority in order to consistently handle situations
                            when more than one might be specified by default.
@@ -1134,24 +1135,6 @@ static int HandleEvents( hb_handle_t * h )
                             /* We scale the height to the new display width */
                             height = (int)( (double)display_width / display_aspect );
                         }
-                        else if( width )
-                        {
-                            /* We assume the source height minus cropping, round
-                               to a mod-friendly number, figure out the proper
-                               display width at that height, and adjust the PAR
-                               to create that display width from the new source width. */
-                            int temp_height;
-                            temp_height = title->height - job->crop[0] - job->crop[1];
-                            int temp_modulus;
-                            if( modulus )
-                                temp_modulus = modulus;
-                            else
-                                temp_modulus = 16;
-                            
-                            temp_height = MULTIPLE_MOD( temp_height, temp_modulus );
-                            job->anamorphic.par_width =  (int)( (double)temp_height * display_aspect );
-                            job->anamorphic.par_height = width;
-                        }
                     }
                     
                     if( display_width )