]> granicus.if.org Git - handbrake/commitdiff
libhb: simplify job initialization
authorjstebbins <jstebbins.hb@gmail.com>
Sat, 3 Jan 2015 18:01:28 +0000 (18:01 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Sat, 3 Jan 2015 18:01:28 +0000 (18:01 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6683 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/common.c
libhb/hb.c

index 50e52734c56d7009bb19e8b35cd221130c29524b..fed775b4be21b8d4ceb4260d411c4db2c506c10b 100644 (file)
@@ -2980,32 +2980,16 @@ static void job_setup(hb_job_t * job, hb_title_t * title)
     /* Autocrop by default. Gnark gnark */
     memcpy( job->crop, title->crop, 4 * sizeof( int ) );
 
-    /* Preserve a source's pixel aspect, if it's available. */
-    if (title->geometry.par.num && title->geometry.par.den)
-    {
-        job->par = title->geometry.par;
-    }
-    else if (title->dar.num && title->dar.den)
-    {
-        hb_reduce(&job->par.num, &job->par.den,
-                  title->geometry.height * title->dar.num,
-                  title->geometry.width * title->dar.den);
-    }
-
-    job->width = title->geometry.width - title->crop[2] - title->crop[3];
-    job->height = title->geometry.height - title->crop[0] - title->crop[1];
 
     hb_geometry_t resultGeo, srcGeo;
     hb_geometry_settings_t uiGeo;
 
-    memset(&uiGeo, 0, sizeof(uiGeo));
-    srcGeo.width = title->geometry.width;
-    srcGeo.height = title->geometry.height;
-    srcGeo.par = title->geometry.par;
+    srcGeo = title->geometry;
 
-    uiGeo.geometry.width = job->width;
-    uiGeo.geometry.height = job->height;
-    uiGeo.geometry.par = job->par;
+    memset(&uiGeo, 0, sizeof(uiGeo));
+    memcpy(uiGeo.crop, title->crop, 4 * sizeof( int ));
+    uiGeo.geometry.width = srcGeo.width - uiGeo.crop[2] - uiGeo.crop[3];
+    uiGeo.geometry.height = srcGeo.height - uiGeo.crop[0] - uiGeo.crop[1];
     uiGeo.mode = HB_ANAMORPHIC_NONE;
     uiGeo.keep = HB_KEEP_DISPLAY_ASPECT;
 
index e9d5e38dabb870ee77556138a6aa6e614dd932d7..73dbd448ca387983686b5efb7598835ba99a6ae7 100644 (file)
@@ -909,6 +909,16 @@ void hb_set_anamorphic_size2(hb_geometry_t *src_geo,
     double storage_aspect = (double)cropped_width / cropped_height;
     int mod = geo->modulus ? EVEN(geo->modulus) : 2;
 
+    // Sanitize PAR
+    if (geo->geometry.par.num == 0 || geo->geometry.par.den == 0)
+    {
+        geo->geometry.par.num = geo->geometry.par.den = 1;
+    }
+    if (src_geo->par.num == 0 || src_geo->par.den == 0)
+    {
+        src_geo->par.num = src_geo->par.den = 1;
+    }
+
     // Use 64 bits to avoid overflow till the final hb_reduce() call
     hb_reduce(&in_par.num, &in_par.den,
               geo->geometry.par.num, geo->geometry.par.den);
@@ -1160,7 +1170,8 @@ void hb_set_anamorphic_size2(hb_geometry_t *src_geo,
     hb_limit_rational64(&dst_par_num, &dst_par_den,
                         dst_par_num, dst_par_den, 65535);
 
-    /* If the user is directling updating PAR, don't override his values */
+    // If the user is directling updating PAR, don't override his values.
+    // I.e. don't even reduce the values.
     hb_reduce(&out_par.num, &out_par.den, dst_par_num, dst_par_den);
     if (geo->mode == HB_ANAMORPHIC_CUSTOM && !keep_display_aspect &&
         out_par.num == in_par.num && out_par.den == in_par.den)