From: jstebbins Date: Fri, 17 Dec 2010 16:31:54 +0000 (+0000) Subject: prevent crash with strict ana and non-mod-2 dimensions. X-Git-Url: http://git.osdn.jp/view?a=commitdiff_plain;h=bd48bff38ee978ac17f47f9302c90ffa9d7cefe7;p=handbrake-jp%2Fhandbrake-jp-git.git prevent crash with strict ana and non-mod-2 dimensions. and make par computation in loose ana a little more accurate. git-svn-id: svn://localhost/HandBrake/trunk@3710 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/libhb/hb.c b/libhb/hb.c index 3d669f2b..da09ea0a 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -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; diff --git a/libhb/work.c b/libhb/work.c index cf8d4d46..9504d4dd 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -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 ); } }