+ case 0: // Non-anamorphic
+
+ if( width && height )
+ {
+ job->width = width;
+ job->height = height;
+ }
+ else if( width )
+ {
+ job->width = width;
+ hb_fix_aspect( job, HB_KEEP_WIDTH );
+ }
+ else if( height )
+ {
+ job->height = height;
+ hb_fix_aspect( job, HB_KEEP_HEIGHT );
+ }
+ else if( !width && !height )
+ {
+ hb_fix_aspect( job, HB_KEEP_WIDTH );
+ }
+
+ break;
+
+ case 1: // Strict anammorphic
+ job->anamorphic.mode = anamorphic_mode;
+ break;
+
+ case 2: // Loose anamorphic
+ job->anamorphic.mode = 2;
+
+ if (modulus)
+ {
+ job->anamorphic.modulus = modulus;
+ }
+
+ if( itu_par )
+ {
+ job->anamorphic.itu_par = itu_par;
+ }
+
+ if( width )
+ {
+ job->width = width;
+ }
+ else if( !width && !height )
+ {
+ /* Default to full width when one isn't specified for loose anamorphic */
+ job->width = title->width - job->crop[2] - job->crop[3];
+ }
+
+ break;
+
+ case 3: // Custom Anamorphic 3: Power User Jamboree
+ job->anamorphic.mode = 3;
+
+ if (modulus)
+ {
+ job->anamorphic.modulus = modulus;
+ }
+
+ if( itu_par )
+ {
+ job->anamorphic.itu_par = itu_par;
+ }
+
+ if( par_width && par_height )
+ {
+ job->anamorphic.par_width = par_width;
+ job->anamorphic.par_height = par_height;
+ }
+
+ 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];
+
+ /* XXX -- I'm assuming people want to keep the source
+ display AR even though they might have already
+ 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 / (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.
+
+ * First off, PAR gets ignored. (err make this reality)
+ * Height will be respected over all other settings,
+ * If it isn't set, display_width will be followed.
+ * If it isn't set, width will be followed. */
+ if( height )
+ {
+ /* We scale the display width to the new height */
+ display_width = (int)( (double)height * display_aspect );
+ }
+ else if( display_width )
+ {
+ /* We scale the height to the new display width */
+ height = (int)( (double)display_width / display_aspect );
+ }
+ }
+
+ if( display_width )
+ {
+ /* Adjust the PAR to create the new display width
+ from the default job width. */
+ job->anamorphic.dar_width = display_width;
+
+ job->anamorphic.dar_height = height ?
+ height :
+ title->height - job->crop[0] - job->crop[1];
+ }
+
+ if( width && height )
+ {
+ /* Use these storage dimensions */
+ job->width = width;
+ job->height = height;
+ }
+ else if( width )
+ {
+ /* Use just this storage width */
+ job->width = width;
+ job->height = title->height - job->crop[0] - job->crop[1];
+ }
+ else if( height )
+ {
+ /* Use just this storage height. */
+ job->height = height;
+ job->width = title->width - job->crop[2] - job->crop[3];
+ }
+ else if( !width && !height )
+ {
+ /* Assume source dimensions after cropping. */
+ job->width = title->width - job->crop[2] - job->crop[3];
+ job->height = title->height - job->crop[0] - job->crop[1];
+ }
+
+ break;