diff options
author | jstebbins <[email protected]> | 2015-01-03 18:01:28 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2015-01-03 18:01:28 +0000 |
commit | 207a1c9599e13f9790a70b4784d290899d45bab8 (patch) | |
tree | fb705c262712f83f72db69199e159548fe091f67 | |
parent | e1301a6a4ece63bf195c3a86976ed29236d7b8c0 (diff) |
libhb: simplify job initialization
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6683 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | libhb/common.c | 26 | ||||
-rw-r--r-- | libhb/hb.c | 13 |
2 files changed, 17 insertions, 22 deletions
diff --git a/libhb/common.c b/libhb/common.c index 50e52734c..fed775b4b 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -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; diff --git a/libhb/hb.c b/libhb/hb.c index e9d5e38da..73dbd448c 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -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) |