summaryrefslogtreecommitdiffstats
path: root/libhb/work.c
diff options
context:
space:
mode:
Diffstat (limited to 'libhb/work.c')
-rw-r--r--libhb/work.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/libhb/work.c b/libhb/work.c
index 5b3f914c2..70ca36a1e 100644
--- a/libhb/work.c
+++ b/libhb/work.c
@@ -128,6 +128,76 @@ static void do_job( hb_job_t * job, int cpu_count )
job->height=title->height-job->crop[0]-job->crop[1];
job->width=title->width-job->crop[2]-job->crop[3];
}
+ else if ( job->pixel_ratio == 2 )
+ {
+ /* "Loose" anamorphic.
+ - Uses mod16-compliant dimensions,
+ - Allows users to set the width
+ - Handles ITU pixel aspects
+ */
+ /* Use mod16 values for better compression */
+ job->width = MULTIPLE_16( job->width );
+ job->height = MULTIPLE_16( job->height );
+ job->width = MAX( 16, job->width );
+ job->height = MAX( 16, job->height );
+
+ /* Set up some variables to make the math easier to follow. */
+ int cropped_width = title->width - job->crop[2] - job->crop[3] ;
+ int cropped_height = title->height - job->crop[0] - job->crop[1] ;
+ int storage_aspect = cropped_width * HB_ASPECT_BASE / cropped_height;
+ int pixels = job->width * (job->width / storage_aspect * HB_ASPECT_BASE);
+
+ /* While keeping the DVD storage aspect, resize the job width and height
+ so they fit into the user's specified dimensions. */
+ hb_set_size(job, -1, pixels, 1);
+
+ if (cropped_width <= 706)
+ {
+ /* Handle ITU PARs */
+ if (title->height == 480)
+ {
+ /* It's NTSC */
+ if (title->aspect == 16)
+ {
+ /* It's widescreen */
+ job->pixel_aspect_width = 40;
+ job->pixel_aspect_height = 33;
+ }
+ else
+ {
+ /*It's 4:3 */
+ job->pixel_aspect_width = 10;
+ job->pixel_aspect_height = 11;
+ }
+ }
+ else if (title->height == 576)
+ {
+ /* It's PAL */
+ if(title->aspect == 16)
+ {
+ /* It's widescreen */
+ job->pixel_aspect_width = 16;
+ job->pixel_aspect_height = 11;
+ }
+ else
+ {
+ /* It's 4:3 */
+ job->pixel_aspect_width = 12;
+ job->pixel_aspect_height = 11;
+ }
+ }
+ }
+
+ /* Figure out what dimensions the source would display at. */
+ int source_display_width = cropped_width * ((float)job->pixel_aspect_width / (float)job->pixel_aspect_height) ;
+
+ /* 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. */
+ job->pixel_aspect_width = job->height * source_display_width / cropped_height;
+ job->pixel_aspect_height = job->width;
+
+ }
/* Keep width and height within these boundaries */
if (job->maxHeight && (job->height > job->maxHeight) )