diff options
-rw-r--r-- | gtk/src/hb-backend.c | 8 | ||||
-rw-r--r-- | libhb/common.c | 46 | ||||
-rw-r--r-- | libhb/common.h | 10 | ||||
-rw-r--r-- | libhb/hb.c | 2 | ||||
-rw-r--r-- | libhb/work.c | 8 | ||||
-rw-r--r-- | macosx/Controller.m | 32 | ||||
-rw-r--r-- | macosx/HBQueueController.mm | 2 | ||||
-rw-r--r-- | macosx/PictureController.m | 41 | ||||
-rw-r--r-- | test/test.c | 8 |
9 files changed, 91 insertions, 66 deletions
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c index fb76aa7c2..feef2b7fe 100644 --- a/gtk/src/hb-backend.c +++ b/gtk/src/hb-backend.c @@ -3487,7 +3487,7 @@ ghb_set_scale(signal_user_data_t *ud, gint mode) job->anamorphic.mode = pic_par; // The scaler crashes if the dimensions are not divisible by 2 // Align mod 2. And so does something in x264_encoder_headers() - job->anamorphic.modulus = mod; + job->modulus = mod; job->anamorphic.par_width = title->pixel_aspect_width; job->anamorphic.par_height = title->pixel_aspect_height; job->anamorphic.dar_width = 0; @@ -3630,7 +3630,7 @@ set_preview_job_settings(hb_job_t *job, GValue *settings) job->crop[3] = ghb_settings_get_int(settings, "PictureRightCrop"); job->anamorphic.mode = ghb_settings_combo_int(settings, "PicturePAR"); - job->anamorphic.modulus = + job->modulus = ghb_settings_combo_int(settings, "PictureModulus"); job->width = ghb_settings_get_int(settings, "scale_width"); job->height = ghb_settings_get_int(settings, "scale_height"); @@ -3647,7 +3647,7 @@ set_preview_job_settings(hb_job_t *job, GValue *settings) job->crop[1] = 0; job->crop[2] = 0; job->crop[3] = 0; - job->anamorphic.modulus = 2; + job->modulus = 2; } gboolean decomb_deint = ghb_settings_get_boolean(settings, "PictureDecombDeinterlace"); @@ -4356,7 +4356,7 @@ add_job(hb_handle_t *h, GValue *js, gint unique_id, gint titleindex) gboolean keep_aspect; keep_aspect = ghb_settings_get_boolean(js, "PictureKeepRatio"); job->anamorphic.mode = ghb_settings_combo_int(js, "PicturePAR"); - job->anamorphic.modulus = ghb_settings_combo_int(js, "PictureModulus"); + job->modulus = ghb_settings_combo_int(js, "PictureModulus"); if (job->anamorphic.mode) { job->anamorphic.par_width = title->pixel_aspect_width; diff --git a/libhb/common.c b/libhb/common.c index ce983987f..06fdedded 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -119,6 +119,9 @@ void hb_fix_aspect( hb_job_t * job, int keep ) { hb_title_t * title = job->title; int i; + int min_width; + int min_height; + int modulus; /* don't do anything unless the title has complete size info */ if ( title->height == 0 || title->width == 0 || title->aspect == 0 ) @@ -129,44 +132,47 @@ void hb_fix_aspect( hb_job_t * job, int keep ) return; } - /* Sanity checks: - Widths and heights must be multiples of 16 and greater than or - equal to 16 - Crop values must be multiples of 2, greater than or equal to 0 - and less than half of the dimension */ - job->width = MULTIPLE_16( job->width ); - job->height = MULTIPLE_16( job->height ); - job->width = MAX( 16, job->width ); - job->height = MAX( 16, job->height ); + // min_width and min_height should be multiples of modulus + min_width = 32; + min_height = 32; + modulus = job->modulus ? job->modulus : 16; + for( i = 0; i < 4; i++ ) { - job->crop[i] = EVEN( job->crop[i] ); - job->crop[i] = MAX( 0, job->crop[i] ); + // Sanity check crop values are zero or positive multiples of 2 if( i < 2 ) { - /* Top, bottom */ - job->crop[i] = MIN( job->crop[i], ( title->height / 2 ) - 2 ); + // Top, bottom + job->crop[i] = MIN( EVEN( job->crop[i] ), EVEN( ( title->height / 2 ) - ( min_height / 2 ) ) ); + job->crop[i] = MAX( 0, job->crop[i] ); } else { - /* Left, right */ - job->crop[i] = MIN( job->crop[i], ( title->width / 2 ) - 2 ); + // Left, right + job->crop[i] = MIN( EVEN( job->crop[i] ), EVEN( ( title->width / 2 ) - ( min_width / 2 ) ) ); + job->crop[i] = MAX( 0, job->crop[i] ); } } double par = (double)title->width / ( (double)title->height * title->aspect ); double cropped_sar = (double)( title->height - job->crop[0] - job->crop[1] ) / - (double)(title->width - job->crop[2] - job->crop[3] ); + (double)( title->width - job->crop[2] - job->crop[3] ); double ar = par * cropped_sar; + + // Dimensions must be greater than minimum and multiple of modulus if( keep == HB_KEEP_WIDTH ) { - job->height = MULTIPLE_16( (uint64_t)( (double)job->width * ar ) ); - job->height = MAX( 16, job->height ); + job->width = MULTIPLE_MOD( job->width, modulus ); + job->width = MAX( min_width, job->width ); + job->height = MULTIPLE_MOD( (uint64_t)( (double)job->width * ar ), modulus ); + job->height = MAX( min_height, job->height ); } else { - job->width = MULTIPLE_16( (uint64_t)( (double)job->height / ar ) ); - job->width = MAX( 16, job->width ); + job->height = MULTIPLE_MOD( job->height, modulus ); + job->height = MAX( min_height, job->height ); + job->width = MULTIPLE_MOD( (uint64_t)( (double)job->height / ar ), modulus ); + job->width = MAX( min_width, job->width ); } } diff --git a/libhb/common.h b/libhb/common.h index ec45250da..0c06ba967 100644 --- a/libhb/common.h +++ b/libhb/common.h @@ -166,14 +166,14 @@ struct hb_job_s /* Picture settings: crop: must be multiples of 2 (top/bottom/left/right) deinterlace: 0 or 1 - width: must be a multiple of 16 - height: must be a multiple of 16 + width: must be a multiple of 2 + height: must be a multiple of 2 keep_ratio: used by UIs grayscale: black and white encoding pixel_ratio: store pixel aspect ratio in the video pixel_aspect_width: numerator for pixel aspect ratio pixel_aspect_height: denominator for pixel aspect ratio - modulus: set a number besides 16 for dimensions to be multiples of + modulus: set a number for dimensions to be multiples of maxWidth: keep width below this maxHeight: keep height below this */ int crop[4]; @@ -187,7 +187,6 @@ struct hb_job_s struct { int mode; - int modulus; int itu_par; int par_width; int par_height; @@ -195,7 +194,8 @@ struct hb_job_s int dar_height; int keep_display_aspect; } anamorphic; - + + int modulus; int maxWidth; int maxHeight; diff --git a/libhb/hb.c b/libhb/hb.c index e4e42d350..0541b9fa7 100644 --- a/libhb/hb.c +++ b/libhb/hb.c @@ -660,7 +660,7 @@ void hb_set_anamorphic_size( hb_job_t * job, int cropped_width = title->width - job->crop[2] - job->crop[3] ; int cropped_height = title->height - job->crop[0] - job->crop[1] ; double storage_aspect = (double)cropped_width / (double)cropped_height; - int mod = job->anamorphic.modulus ? job->anamorphic.modulus : 16; + int mod = job->modulus ? job->modulus : 16; double aspect = title->aspect; int pixel_aspect_width = job->anamorphic.par_width; diff --git a/libhb/work.c b/libhb/work.c index 7a923a192..5a660bcee 100644 --- a/libhb/work.c +++ b/libhb/work.c @@ -212,13 +212,9 @@ void hb_display_job_info( hb_job_t * job ) { hb_log( " + keeping source display aspect ratio"); } - if( job->anamorphic.modulus != 16 ) - { - hb_log( " + modulus: %i", job->anamorphic.modulus ); - } - hb_log( " + storage dimensions: %d * %d -> %d * %d, crop %d/%d/%d/%d", + hb_log( " + storage dimensions: %d * %d -> %d * %d, crop %d/%d/%d/%d, mod %i", title->width, title->height, job->width, job->height, - job->crop[0], job->crop[1], job->crop[2], job->crop[3] ); + job->crop[0], job->crop[1], job->crop[2], job->crop[3], job->modulus ); if( job->anamorphic.itu_par ) { hb_log( " + using ITU pixel aspect ratio values"); diff --git a/macosx/Controller.m b/macosx/Controller.m index 545a263a8..0715bff0e 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -2320,10 +2320,11 @@ fWorkingCount = 0; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"]; + [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->modulus] forKey:@"PictureModulus"]; /* if we are custom anamorphic, store the exact storage, par and display dims */ if (fTitle->job->anamorphic.mode == 3) { - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.modulus] forKey:@"PicturePARModulus"]; + [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->modulus] forKey:@"PicturePARModulus"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PicturePARStorageWidth"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PicturePARStorageHeight"]; @@ -2954,6 +2955,7 @@ fWorkingCount = 0; } + //job->modulus = [[queueToApply objectForKey:@"PictureModulus"] intValue]; /* we check to make sure the presets width/height does not exceed the sources width/height */ if (fTitle->width < [[queueToApply objectForKey:@"PictureWidth"] intValue] || fTitle->height < [[queueToApply objectForKey:@"PictureHeight"] intValue]) @@ -2980,7 +2982,7 @@ fWorkingCount = 0; } } job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"] intValue]; - + job->modulus = [[queueToApply objectForKey:@"PictureModulus"] intValue]; [self writeToActivityLog: "applyQueueSettingsToMainWindow: picture sizing set up"]; @@ -3080,7 +3082,6 @@ fWorkingCount = 0; /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */ [fPictureController SetTitle:fTitle]; - [fPictureController SetTitle:fTitle]; [self calculatePictureSizing:nil]; [self writeToActivityLog: "applyQueueSettingsToMainWindow: picture filters set up"]; @@ -3722,13 +3723,14 @@ bool one_burned = FALSE; job->keep_ratio = [[queueToApply objectForKey:@"PictureKeepRatio"] intValue]; job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"] intValue]; + job->modulus = [[queueToApply objectForKey:@"PictureModulus"] intValue]; if ([[queueToApply objectForKey:@"PicturePAR"] intValue] == 3) { /* insert our custom values here for capuj */ job->width = [[queueToApply objectForKey:@"PicturePARStorageWidth"] intValue]; job->height = [[queueToApply objectForKey:@"PicturePARStorageHeight"] intValue]; - job->anamorphic.modulus = [[queueToApply objectForKey:@"PicturePARModulus"] intValue]; + job->modulus = [[queueToApply objectForKey:@"PicturePARModulus"] intValue]; job->anamorphic.par_width = [[queueToApply objectForKey:@"PicturePARPixelWidth"] intValue]; job->anamorphic.par_height = [[queueToApply objectForKey:@"PicturePARPixelHeight"] intValue]; @@ -5198,8 +5200,14 @@ the user is using "Custom" settings by determining the sender*/ fTitle->job->keep_ratio = 0; } - [fPictureSizeField setStringValue: [NSString stringWithFormat:@"Picture Size: %@", [fPictureController getPictureSizeInfoString]]]; - + if (fTitle->job->anamorphic.mode != 1) // we are not strict so show the modulus + { + [fPictureSizeField setStringValue: [NSString stringWithFormat:@"Picture Size: %@, Modulus: %d", [fPictureController getPictureSizeInfoString], fTitle->job->modulus]]; + } + else + { + [fPictureSizeField setStringValue: [NSString stringWithFormat:@"Picture Size: %@", [fPictureController getPictureSizeInfoString]]]; + } NSString *picCropping; /* Set the display field for crop as per boolean */ if (![fPictureController autoCrop]) @@ -7097,7 +7105,16 @@ return YES; } - + /* Set modulus */ + if ([chosenPreset objectForKey:@"PictureModulus"]) + { + job->modulus = [[chosenPreset objectForKey:@"PictureModulus"] intValue]; + } + else + { + job->modulus = 16; + } + /* Check to see if the objectForKey:@"UsesPictureSettings is 2 which is "Use Max for the source */ if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"] intValue] == 1) { @@ -7472,6 +7489,7 @@ return YES; [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"]; [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"]; [preset setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"]; + [preset setObject:[NSNumber numberWithInt:fTitle->job->modulus] forKey:@"PictureModulus"]; /* Set crop settings here */ [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"]; diff --git a/macosx/HBQueueController.mm b/macosx/HBQueueController.mm index 9321b1dd8..9f7ce38a0 100644 --- a/macosx/HBQueueController.mm +++ b/macosx/HBQueueController.mm @@ -1189,6 +1189,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; [finalString appendString: @"Destination: " withAttributes:detailBoldAttr]; [finalString appendString: [item objectForKey:@"DestinationPath"] withAttributes:detailAttr]; [finalString appendString:@"\n" withAttributes:detailAttr]; + /* Fifth Line Picture Details*/ NSString * pictureInfo; pictureInfo = [NSString stringWithFormat:@"%@", [item objectForKey:@"PictureSizingSummary"]]; @@ -1196,6 +1197,7 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; { pictureInfo = [pictureInfo stringByAppendingString:@" Keep Aspect Ratio"]; } + if ([[item objectForKey:@"VideoGrayScale"] intValue] == 1) { pictureInfo = [pictureInfo stringByAppendingString:@", Grayscale"]; diff --git a/macosx/PictureController.m b/macosx/PictureController.m index e70ec80eb..b02dab729 100644 --- a/macosx/PictureController.m +++ b/macosx/PictureController.m @@ -150,8 +150,6 @@ [fParHeightLabel setHidden: NO]; [fDisplayWidthField setHidden: NO]; [fDisplayWidthLabel setHidden: NO]; - [fModulusLabel setHidden: NO]; - [fModulusPopUp setHidden: NO]; /* adjust/move keep ar checkbox */ [fRatioLabel setHidden: YES]; [fRatioLabel2 setHidden: NO]; @@ -192,8 +190,6 @@ [fParHeightLabel setHidden: YES]; [fDisplayWidthField setHidden: YES]; [fDisplayWidthLabel setHidden: YES]; - [fModulusLabel setHidden: YES]; - [fModulusPopUp setHidden: YES]; /* adjust/move keep ar checkbox */ [fRatioLabel setHidden: NO]; [fRatioLabel2 setHidden: YES]; @@ -532,15 +528,16 @@ [fModulusPopUp addItemWithTitle: @"8"]; [fModulusPopUp addItemWithTitle: @"4"]; [fModulusPopUp addItemWithTitle: @"2"]; - if (job->anamorphic.mode == 3) + if (job->modulus) { - [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->anamorphic.modulus]]; + [fModulusPopUp selectItemWithTitle: [NSString stringWithFormat:@"%d",job->modulus]]; } else { - [fModulusPopUp selectItemWithTitle: @"16"]; + [fModulusPopUp selectItemAtIndex: 0]; } + /* We initially set the previous state of keep ar to on */ keepAspectRatioPreviousState = 1; if (!autoCrop) @@ -648,8 +645,24 @@ - (IBAction) SettingsChanged: (id) sender { hb_job_t * job = fTitle->job; - [fModulusPopUp setEnabled:NO]; - job->anamorphic.modulus = 16; + + /* if we are anything but strict anamorphic */ + if ([fAnamorphicPopUp indexOfSelectedItem] != 1) + { + [fModulusLabel setHidden:NO]; + [fModulusPopUp setHidden:NO]; + } + else + { + /* we are strict so hide the mod popup since libhb uses mod 2 for strict anamorphic*/ + [fModulusLabel setHidden:YES]; + [fModulusPopUp setHidden:YES]; + } + + job->modulus = [[fModulusPopUp titleOfSelectedItem] intValue]; + + [fWidthStepper setIncrement: job->modulus]; + [fHeightStepper setIncrement: job->modulus]; /* Since custom anamorphic allows for a height setting > fTitle->height * check to make sure it is returned to fTitle->height for all other modes @@ -687,14 +700,6 @@ job->anamorphic.par_width = titleParWidth; job->anamorphic.par_height = titleParHeight; [fRatioLabel setHidden: NO]; - - [fWidthStepper setIncrement: 16]; - [fHeightStepper setIncrement: 16]; - } - else - { - [fWidthStepper setIncrement: [[fModulusPopUp titleOfSelectedItem] intValue]]; - [fHeightStepper setIncrement: [[fModulusPopUp titleOfSelectedItem] intValue]]; } if( [fAnamorphicPopUp indexOfSelectedItem] > 0 ) @@ -752,9 +757,7 @@ job->anamorphic.mode = 3; /* Set the status of our custom ana only widgets accordingly */ - /* for mod 3 we can use modulus other than 16 */ [fModulusPopUp setEnabled:YES]; - job->anamorphic.modulus = [[fModulusPopUp titleOfSelectedItem] intValue]; [fWidthStepper setEnabled: YES]; [fWidthField setEnabled: YES]; diff --git a/test/test.c b/test/test.c index bb0637eb7..bb2730182 100644 --- a/test/test.c +++ b/test/test.c @@ -1134,7 +1134,7 @@ static int HandleEvents( hb_handle_t * h ) if (modulus) { - job->anamorphic.modulus = modulus; + job->modulus = modulus; } if( itu_par ) @@ -1159,7 +1159,7 @@ static int HandleEvents( hb_handle_t * h ) if (modulus) { - job->anamorphic.modulus = modulus; + job->modulus = modulus; } if( itu_par ) @@ -2327,8 +2327,8 @@ static void ShowHelp() " --itu-par Use wider, ITU pixel aspect values for loose and\n" " custom anamorphic, useful with underscanned sources\n" " --modulus Set the number you want the scaled pixel dimensions\n" - " <number> to divide cleanly by, for loose and custom\n" - " anamorphic modes (default: 16)\n" + " <number> to divide cleanly by. Does not affect strict\n" + " anamorphic mode, which is always mod 2 (default: 16)\n" " -M --color-matrix Set the color space signaled by the output\n" " <601 or 709> (Bt.601 is mostly for SD content, Bt.709 for HD,\n" " default: set by resolution)\n" |