diff options
author | jstebbins <[email protected]> | 2014-12-16 16:50:50 +0000 |
---|---|---|
committer | jstebbins <[email protected]> | 2014-12-16 16:50:50 +0000 |
commit | f56efd7b52c89da8cac55b4d4a187f2c87fdfee6 (patch) | |
tree | 24eacb856704fa8e4b8b8f0edc76568916f70255 /macosx | |
parent | d0a975e42dcab93e1d2eead350fb1ba3951d977c (diff) |
json: add json APIs
There are several changes to job and title structs that break
current windows interop code. The interop code should be changed
such that it only uses json APIs. So if there is any missing
features (or bugs) in these APIs, please let me know.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6602 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.m | 61 | ||||
-rw-r--r-- | macosx/HBPicture.h | 12 | ||||
-rw-r--r-- | macosx/HBPreviewController.m | 12 | ||||
-rw-r--r-- | macosx/HBPreviewGenerator.m | 11 | ||||
-rw-r--r-- | macosx/HBVideo.m | 6 | ||||
-rw-r--r-- | macosx/HBVideoController.m | 4 | ||||
-rw-r--r-- | macosx/PictureController.m | 80 |
7 files changed, 100 insertions, 86 deletions
diff --git a/macosx/Controller.m b/macosx/Controller.m index 4ceddb617..f7a291e6d 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -2091,8 +2091,8 @@ static void queueFSEventStreamCallback( [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.keep_display_aspect] forKey:@"PictureKeepRatio"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.mode] forKey:@"PicturePAR"]; [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->modulus] forKey:@"PictureModulus"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.par_width] forKey:@"PicturePARPixelWidth"]; - [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->anamorphic.par_height] forKey:@"PicturePARPixelHeight"]; + [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->par.num] forKey:@"PicturePARPixelWidth"]; + [queueFileJob setObject:[NSNumber numberWithInt:fTitle->job->par.den] forKey:@"PicturePARPixelHeight"]; /* Text summaries of various settings */ [queueFileJob setObject:[NSString stringWithString:[self pictureSettingsSummary]] @@ -2154,8 +2154,8 @@ static void queueFSEventStreamCallback( /* Codecs */ /* Framerate */ - [queueFileJob setObject:[NSNumber numberWithInt:title->rate] forKey:@"JobVrate"]; - [queueFileJob setObject:[NSNumber numberWithInt:title->rate_base] forKey:@"JobVrateBase"]; + [queueFileJob setObject:[NSNumber numberWithInt:title->vrate.num] forKey:@"JobVrate"]; + [queueFileJob setObject:[NSNumber numberWithInt:title->vrate.den] forKey:@"JobVrateBase"]; /* we need to auto relase the queueFileJob and return it */ [queueFileJob autorelease]; @@ -2845,7 +2845,7 @@ static void queueFSEventStreamCallback( /* Add Crop/Scale filter */ hb_filter_object_t *filter = hb_filter_init( HB_FILTER_CROP_SCALE ); hb_add_filter( job, filter, [[NSString stringWithFormat:@"%d:%d:%d:%d:%d:%d", - job->width,job->height, + job->width, job->height, job->crop[0], job->crop[1], job->crop[2], job->crop[3]] UTF8String] ); } @@ -3020,9 +3020,8 @@ static void queueFSEventStreamCallback( job->anamorphic.keep_display_aspect = [[queueToApply objectForKey:@"PictureKeepRatio"] intValue]; job->anamorphic.mode = [[queueToApply objectForKey:@"PicturePAR"] intValue]; job->modulus = [[queueToApply objectForKey:@"PictureModulus"] intValue]; - job->anamorphic.par_width = [[queueToApply objectForKey:@"PicturePARPixelWidth"] intValue]; - job->anamorphic.par_height = [[queueToApply objectForKey:@"PicturePARPixelHeight"] intValue]; - job->anamorphic.dar_width = job->anamorphic.dar_height = 0; + job->par.num = [[queueToApply objectForKey:@"PicturePARPixelWidth"] intValue]; + job->par.den = [[queueToApply objectForKey:@"PicturePARPixelHeight"] intValue]; /* Here we use the crop values saved at the time the preset was saved */ job->crop[0] = [[queueToApply objectForKey:@"PictureTopCrop"] intValue]; @@ -3343,7 +3342,7 @@ static void queueFSEventStreamCallback( /* Add Crop/Scale filter */ filter = hb_filter_init( HB_FILTER_CROP_SCALE ); hb_add_filter( job, filter, [[NSString stringWithFormat:@"%d:%d:%d:%d:%d:%d", - job->width,job->height, + job->width, job->height, job->crop[0], job->crop[1], job->crop[2], job->crop[3]] UTF8String] ); @@ -3829,7 +3828,7 @@ static void queueFSEventStreamCallback( /* For point a to point b frame encoding, set the start and end fields to 0 and the title duration * announced fps in seconds respectively */ [fSrcFrameStartEncodingField setStringValue: [NSString stringWithFormat: @"%d", 1]]; //[fSrcFrameEndEncodingField setStringValue: [NSString stringWithFormat: @"%d", ((title->hours * 3600) + (title->minutes * 60) + (title->seconds)) * 24]]; - [fSrcFrameEndEncodingField setStringValue: [NSString stringWithFormat: @"%d", duration * (title->rate / title->rate_base)]]; + [fSrcFrameEndEncodingField setStringValue: [NSString stringWithFormat: @"%d", duration * (title->vrate.num / title->vrate.den)]]; /* Update encode start / stop variables */ @@ -3986,7 +3985,7 @@ static void queueFSEventStreamCallback( hb_title_t * title = (hb_title_t*) hb_list_item( list, (int)[fSrcTitlePopUp indexOfSelectedItem] ); - int duration = ([fSrcFrameEndEncodingField intValue] - [fSrcFrameStartEncodingField intValue]) / (title->rate / title->rate_base); + int duration = ([fSrcFrameEndEncodingField intValue] - [fSrcFrameStartEncodingField intValue]) / (title->vrate.num / title->vrate.den); [fSrcDuration2Field setStringValue: [NSString stringWithFormat: @"%02d:%02d:%02d", duration / 3600, ( duration / 60 ) % 60, duration % 60]]; @@ -4301,8 +4300,8 @@ the user is using "Custom" settings by determining the sender*/ * height, width, keep ar, anamorphic and crop settings. * picture filters are handled separately below. */ - int maxWidth = fTitle->width - job->crop[2] - job->crop[3]; - int maxHeight = fTitle->height - job->crop[0] - job->crop[1]; + int maxWidth = fTitle->geometry.width - job->crop[2] - job->crop[3]; + int maxHeight = fTitle->geometry.height - job->crop[0] - job->crop[1]; job->maxWidth = job->maxHeight = 0; /* Check to see if the objectForKey:@"UsesPictureSettings is greater than 0, as 0 means use picture sizing "None" * ( 2 is use max for source and 1 is use exact size when the preset was created ) and the @@ -4334,8 +4333,8 @@ the user is using "Custom" settings by determining the sender*/ } /* crop may have changed, reset maxWidth/maxHeight */ - maxWidth = fTitle->width - job->crop[2] - job->crop[3]; - maxHeight = fTitle->height - job->crop[0] - job->crop[1]; + maxWidth = fTitle->geometry.width - job->crop[2] - job->crop[3]; + maxHeight = fTitle->geometry.height - job->crop[0] - job->crop[1]; /* Set modulus */ if ([chosenPreset objectForKey:@"PictureModulus"]) @@ -4351,8 +4350,8 @@ the user is using "Custom" settings by determining the sender*/ * Assume max picture settings initially */ job->anamorphic.mode = [[chosenPreset objectForKey:@"PicturePAR"] intValue]; - job->width = fTitle->width - job->crop[2] - job->crop[3]; - job->height = fTitle->height - job->crop[0] - job->crop[1]; + job->width = fTitle->geometry.width - job->crop[2] - job->crop[3]; + job->height = fTitle->geometry.height - job->crop[0] - job->crop[1]; job->anamorphic.keep_display_aspect = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue]; /* Check to see if the objectForKey:@"UsesPictureSettings" is 2, @@ -4392,12 +4391,28 @@ the user is using "Custom" settings by determining the sender*/ if (job->maxHeight == 0 || job->maxHeight > maxHeight) job->maxHeight = maxHeight; - int width, height, par_width, par_height; - hb_set_anamorphic_size(job, &width, &height, &par_width, &par_height); - job->width = width; - job->height = height; - job->anamorphic.par_width = par_width; - job->anamorphic.par_height = par_height; + hb_geometry_t srcGeo, resultGeo; + hb_geometry_settings_t uiGeo; + + srcGeo.width = fTitle->geometry.width; + srcGeo.height = fTitle->geometry.height; + srcGeo.par = fTitle->geometry.par; + + uiGeo.mode = job->anamorphic.mode; + uiGeo.keep = !!job->anamorphic.keep_display_aspect * HB_KEEP_DISPLAY_ASPECT; + uiGeo.itu_par = 0; + uiGeo.modulus = job->modulus; + memcpy(uiGeo.crop, job->crop, sizeof(int[4])); + uiGeo.geometry.width = job->width; + uiGeo.geometry.height = job->height; + uiGeo.geometry.par = job->par; + uiGeo.maxWidth = job->maxWidth; + uiGeo.maxHeight = job->maxHeight; + hb_set_anamorphic_size2(&srcGeo, &uiGeo, &resultGeo); + + job->width = resultGeo.width; + job->height = resultGeo.height; + job->par = resultGeo.par; /* we call SetTitle: in fPictureController so we get an instant update in the Picture Settings window */ [fPictureController setTitle:fTitle]; diff --git a/macosx/HBPicture.h b/macosx/HBPicture.h index 24c695877..beb045768 100644 --- a/macosx/HBPicture.h +++ b/macosx/HBPicture.h @@ -24,10 +24,14 @@ anamorphic { mode keepDisplayAspect - par_width - par_height - dar_width - dar_height + par { + num + den + } + dar { + num + den + } } modulus */ diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m index 43128ac20..2d4174ef7 100644 --- a/macosx/HBPreviewController.m +++ b/macosx/HBPreviewController.m @@ -671,35 +671,35 @@ typedef enum ViewMode : NSUInteger { NSSize imageScaledSize = [fPreviewImage size]; [self.pictureLayer setContents:fPreviewImage]; - NSSize displaySize = NSMakeSize( ( CGFloat )title->width, ( CGFloat )title->height ); + NSSize displaySize = NSMakeSize( ( CGFloat )title->geometry.width, ( CGFloat )title->geometry.height ); NSString *sizeInfoString; /* Set the picture size display fields below the Preview Picture*/ int display_width; - display_width = title->job->width * title->job->anamorphic.par_width / title->job->anamorphic.par_height; + display_width = title->job->width * title->job->par.num / title->job->par.den; if (title->job->anamorphic.mode == HB_ANAMORPHIC_STRICT) // Original PAR Implementation { sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Strict", - title->width, title->height, title->job->width, title->job->height, display_width, title->job->height]; + title->geometry.width, title->geometry.height, title->job->width, title->job->height, display_width, title->job->height]; } else if (title->job->anamorphic.mode == HB_ANAMORPHIC_LOOSE) // Loose Anamorphic { sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Loose", - title->width, title->height, title->job->width, title->job->height, display_width, title->job->height]; + title->geometry.width, title->geometry.height, title->job->width, title->job->height, display_width, title->job->height]; } else if (title->job->anamorphic.mode == HB_ANAMORPHIC_CUSTOM) // Custom Anamorphic { sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d, Anamorphic: %dx%d Custom", - title->width, title->height, title->job->width, title->job->height, display_width, title->job->height]; + title->geometry.width, title->geometry.height, title->job->width, title->job->height, display_width, title->job->height]; } else // No Anamorphic { sizeInfoString = [NSString stringWithFormat: @"Source: %dx%d, Output: %dx%d", - title->width, title->height, title->job->width, title->job->height]; + title->geometry.width, title->geometry.height, title->job->width, title->job->height]; } displaySize.width = display_width; displaySize.height = title->job->height; diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index ccbe7473c..3e9adbe9b 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -104,13 +104,14 @@ typedef enum EncodeState : NSUInteger { { NSImage *img = nil; - hb_ui_geometry_t geo; - geo.width = title->job->width; - geo.height = title->job->height; + hb_geometry_settings_t geo; + memset(&geo, 0, sizeof(geo)); + geo.geometry.width = title->job->width; + geo.geometry.height = title->job->height; // HBPreviewController will scale the image later, // ignore the par. - geo.par.num = 1; - geo.par.den = 1; + geo.geometry.par.num = 1; + geo.geometry.par.den = 1; memcpy(geo.crop, title->job->crop, sizeof(int[4])); hb_image_t *image; diff --git a/macosx/HBVideo.m b/macosx/HBVideo.m index 0319174f7..b697dc773 100644 --- a/macosx/HBVideo.m +++ b/macosx/HBVideo.m @@ -776,8 +776,8 @@ else { /* same as source */ - fps_num = title->rate; - fps_den = title->rate_base; + fps_num = title->vrate.num; + fps_den = title->vrate.den; if (self.frameRateMode == 1) { // CFR @@ -996,4 +996,4 @@ } } -@end
\ No newline at end of file +@end diff --git a/macosx/HBVideoController.m b/macosx/HBVideoController.m index 6bcbfb4c2..4bbd1499e 100644 --- a/macosx/HBVideoController.m +++ b/macosx/HBVideoController.m @@ -726,8 +726,8 @@ NSString *HBVideoEncoderChangedNotification = @"HBVideoEncoderChangedNotificatio else { /* same as source */ - fps_num = title->rate; - fps_den = title->rate_base; + fps_num = title->vrate.num; + fps_den = title->vrate.den; if ([fFramerateMatrix selectedRow] == 1) { // CFR diff --git a/macosx/PictureController.m b/macosx/PictureController.m index 7472307aa..779cff60e 100644 --- a/macosx/PictureController.m +++ b/macosx/PictureController.m @@ -289,23 +289,22 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; [fCropLeftField setEditable: !self.autoCrop]; [fCropRightField setEditable: !self.autoCrop]; - [fWidthStepper setMaxValue: title->width - job->crop[2] - job->crop[3]]; + [fWidthStepper setMaxValue: title->geometry.width - job->crop[2] - job->crop[3]]; [fWidthStepper setIntValue: job->width]; [fWidthField setIntValue: job->width]; - [fHeightStepper setMaxValue: title->height - job->crop[0] - job->crop[1]]; + [fHeightStepper setMaxValue: title->geometry.height - job->crop[0] - job->crop[1]]; [fHeightStepper setIntValue: job->height]; [fHeightField setIntValue: job->height]; - [fCropTopStepper setMaxValue: title->height/2-2]; - [fCropBottomStepper setMaxValue: title->height/2-2]; - [fCropLeftStepper setMaxValue: title->width/2-2]; - [fCropRightStepper setMaxValue: title->width/2-2]; + [fCropTopStepper setMaxValue: title->geometry.height/2-2]; + [fCropBottomStepper setMaxValue: title->geometry.height/2-2]; + [fCropLeftStepper setMaxValue: title->geometry.width/2-2]; + [fCropRightStepper setMaxValue: title->geometry.width/2-2]; - [fParWidthField setIntValue: job->anamorphic.par_width]; - [fParHeightField setIntValue: job->anamorphic.par_height]; + [fParWidthField setIntValue: job->par.num]; + [fParHeightField setIntValue: job->par.den]; int display_width; - display_width = job->width * job->anamorphic.par_width / - job->anamorphic.par_height; + display_width = job->width * job->par.num / job->par.den; [fDisplayWidthField setIntValue: display_width]; [fPreviewController setTitle:title]; @@ -676,15 +675,15 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; if (sender == fParWidthField || sender == fParHeightField) { - job->anamorphic.par_width = [fParWidthField intValue]; - job->anamorphic.par_height = [fParHeightField intValue]; + job->par.num = [fParWidthField intValue]; + job->par.den = [fParHeightField intValue]; } if (sender == fDisplayWidthField) { dar_updated = 1; - job->anamorphic.dar_width = [fDisplayWidthField intValue]; - job->anamorphic.dar_height = [fHeightStepper intValue]; + job->par.num = [fDisplayWidthField intValue]; + job->par.den = [fWidthField intValue]; } if (sender == fCropMatrix) @@ -721,35 +720,35 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; { job->crop[0] = [fCropTopStepper intValue]; [fCropTopField setIntValue: job->crop[0]]; - [fHeightStepper setMaxValue: fTitle->height - job->crop[0] - job->crop[1]]; + [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; } if (sender == fCropBottomStepper) { job->crop[1] = [fCropBottomStepper intValue]; [fCropBottomField setIntValue: job->crop[1]]; - [fHeightStepper setMaxValue: fTitle->height - job->crop[0] - job->crop[1]]; + [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; } if (sender == fCropLeftStepper) { job->crop[2] = [fCropLeftStepper intValue]; [fCropLeftField setIntValue: job->crop[2]]; - [fWidthStepper setMaxValue: fTitle->width - job->crop[2] - job->crop[3]]; + [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; } if (sender == fCropRightStepper) { job->crop[3] = [fCropRightStepper intValue]; [fCropRightField setIntValue: job->crop[3]]; - [fWidthStepper setMaxValue: fTitle->width - job->crop[2] - job->crop[3]]; + [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; } if (sender == fCropTopField) { int cropValue = [fCropTopField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->height/2-2)) + if (cropValue >= 0 && (cropValue <= fTitle->geometry.height/2-2)) { job->crop[0] = cropValue; [fCropTopStepper setIntValue:cropValue]; - [fHeightStepper setMaxValue: fTitle->height - job->crop[0] - job->crop[1]]; + [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; } else { @@ -759,11 +758,11 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; else if (sender == fCropBottomField) { int cropValue = [fCropBottomField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->height/2-2)) + if (cropValue >= 0 && (cropValue <= fTitle->geometry.height/2-2)) { job->crop[1] = cropValue; [fCropBottomStepper setIntValue:cropValue]; - [fHeightStepper setMaxValue: fTitle->height - job->crop[0] - job->crop[1]]; + [fHeightStepper setMaxValue: fTitle->geometry.height - job->crop[0] - job->crop[1]]; } else { @@ -773,11 +772,11 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; else if (sender == fCropLeftField) { int cropValue = [fCropLeftField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->width/2-2)) + if (cropValue >= 0 && (cropValue <= fTitle->geometry.width/2-2)) { job->crop[2] = cropValue; [fCropLeftStepper setIntValue:cropValue]; - [fWidthStepper setMaxValue: fTitle->width - job->crop[2] - job->crop[3]]; + [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; } else { @@ -787,11 +786,11 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; else if (sender == fCropRightField) { int cropValue = [fCropRightField intValue]; - if (cropValue >= 0 && (cropValue <= fTitle->width/2-2)) + if (cropValue >= 0 && (cropValue <= fTitle->geometry.width/2-2)) { job->crop[3] = cropValue; [fCropRightStepper setIntValue:cropValue]; - [fWidthStepper setMaxValue: fTitle->width - job->crop[2] - job->crop[3]]; + [fWidthStepper setMaxValue: fTitle->geometry.width - job->crop[2] - job->crop[3]]; } else { @@ -802,40 +801,35 @@ static void *HBPictureControllerContext = &HBPictureControllerContext; keep |= !!job->anamorphic.keep_display_aspect * HB_KEEP_DISPLAY_ASPECT; hb_geometry_t srcGeo, resultGeo; - hb_ui_geometry_t uiGeo; + hb_geometry_settings_t uiGeo; - srcGeo.width = fTitle->width; - srcGeo.height = fTitle->height; - srcGeo.par.num = fTitle->pixel_aspect_width; - srcGeo.par.den = fTitle->pixel_aspect_height; + srcGeo.width = fTitle->geometry.width; + srcGeo.height = fTitle->geometry.height; + srcGeo.par = fTitle->geometry.par; uiGeo.mode = job->anamorphic.mode; uiGeo.keep = keep; uiGeo.itu_par = 0; uiGeo.modulus = job->modulus; memcpy(uiGeo.crop, job->crop, sizeof(int[4])); - uiGeo.width = job->width; - uiGeo.height = job->height; + uiGeo.geometry.width = job->width; + uiGeo.geometry.height = job->height; /* Modulus added to maxWidth/maxHeight to allow a small amount of * upscaling to the next mod boundary. */ - uiGeo.maxWidth = fTitle->width - job->crop[2] - job->crop[3] + job->modulus - 1; - uiGeo.maxHeight = fTitle->height - job->crop[0] - job->crop[1] + job->modulus - 1; - uiGeo.par.num = job->anamorphic.par_width; - uiGeo.par.den = job->anamorphic.par_height; - uiGeo.dar.num = 0; - uiGeo.dar.den = 0; + uiGeo.maxWidth = fTitle->geometry.width - job->crop[2] - job->crop[3] + job->modulus - 1; + uiGeo.maxHeight = fTitle->geometry.height - job->crop[0] - job->crop[1] + job->modulus - 1; + uiGeo.geometry.par = job->par; if (job->anamorphic.mode == HB_ANAMORPHIC_CUSTOM && dar_updated) { - uiGeo.dar.num = job->anamorphic.dar_width; - uiGeo.dar.den = job->anamorphic.dar_height; + uiGeo.geometry.par.num = [fDisplayWidthField intValue]; + uiGeo.geometry.par.den = uiGeo.geometry.width; } hb_set_anamorphic_size2(&srcGeo, &uiGeo, &resultGeo); job->width = resultGeo.width; job->height = resultGeo.height; - job->anamorphic.par_width = resultGeo.par.num; - job->anamorphic.par_height = resultGeo.par.den; + job->par = resultGeo.par; int display_width; display_width = resultGeo.width * resultGeo.par.num / resultGeo.par.den; |