diff options
author | ritsuka <[email protected]> | 2014-12-20 18:56:10 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2014-12-20 18:56:10 +0000 |
commit | f1846aaeac294291862156447bff495c1f016613 (patch) | |
tree | 8e183230e25b056e87c406d3eb1c9bf9332219f4 /macosx/HBPreviewGenerator.m | |
parent | 4ced50fce98afc403c48a1f06a2f8f05d2d79c96 (diff) |
MacGui: integrated HBPicture in HBPictureController and started to move things over to HBJob.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6628 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPreviewGenerator.m')
-rw-r--r-- | macosx/HBPreviewGenerator.m | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/macosx/HBPreviewGenerator.m b/macosx/HBPreviewGenerator.m index 3e9adbe9b..f089ade22 100644 --- a/macosx/HBPreviewGenerator.m +++ b/macosx/HBPreviewGenerator.m @@ -7,9 +7,11 @@ #import "HBPreviewGenerator.h" #import "HBUtilities.h" -#import "HBCore.h" #import "Controller.h" +#import "HBCore.h" +#import "HBJob.h" + typedef enum EncodeState : NSUInteger { EncodeStateIdle, EncodeStateWorking, @@ -20,8 +22,8 @@ typedef enum EncodeState : NSUInteger { @property (nonatomic, readonly, retain) NSMutableDictionary *picturePreviews; @property (nonatomic, readonly) NSUInteger imagesCount; -@property (nonatomic, readonly) hb_handle_t *handle; -@property (nonatomic, readonly) hb_title_t *title; +@property (nonatomic, readonly) HBCore *scanCore; +@property (nonatomic, readonly) HBJob *job; @property (nonatomic) HBCore *core; @property (nonatomic, getter=isCancelled) BOOL cancelled; @@ -33,13 +35,13 @@ typedef enum EncodeState : NSUInteger { @implementation HBPreviewGenerator -- (id) initWithHandle: (hb_handle_t *) handle andTitle: (hb_title_t *) title +- (instancetype)initWithCore:(HBCore *)core job:(HBJob *)job { self = [super init]; if (self) { - _handle = handle; - _title = title; + _scanCore = core; + _job = job; _picturePreviews = [[NSMutableDictionary alloc] init]; _imagesCount = [[[NSUserDefaults standardUserDefaults] objectForKey:@"PreviewsNumber"] intValue]; } @@ -65,10 +67,13 @@ typedef enum EncodeState : NSUInteger { if (!theImage) { + HBFilters *filters = self.job.filters; + BOOL deinterlace = (filters.deinterlace && !filters.useDecomb) || (filters.decomb && filters.useDecomb); + theImage = [HBPreviewGenerator makeImageForPicture:index - libhb:self.handle - title:self.title - deinterlace:self.deinterlace]; + libhb:self.scanCore.hb_handle + picture:self.job.picture + deinterlace:deinterlace]; if (cache && theImage) [self.picturePreviews setObject:theImage forKey:@(index)]; } @@ -99,23 +104,24 @@ typedef enum EncodeState : NSUInteger { */ + (NSImage *) makeImageForPicture: (NSUInteger) pictureIndex libhb: (hb_handle_t *) handle - title: (hb_title_t *) title + picture: (HBPicture *) picture deinterlace: (BOOL) deinterlace { NSImage *img = nil; hb_geometry_settings_t geo; memset(&geo, 0, sizeof(geo)); - geo.geometry.width = title->job->width; - geo.geometry.height = title->job->height; + geo.geometry.width = picture.width; + geo.geometry.height = picture.height; // HBPreviewController will scale the image later, // ignore the par. geo.geometry.par.num = 1; geo.geometry.par.den = 1; - memcpy(geo.crop, title->job->crop, sizeof(int[4])); + int crop[4] = {picture.cropTop, picture.cropBottom, picture.cropLeft, picture.cropRight}; + memcpy(geo.crop, crop, sizeof(int[4])); hb_image_t *image; - image = hb_get_preview2(handle, title->index, (int)pictureIndex, &geo, deinterlace); + image = hb_get_preview2(handle, picture.title.hb_title->index, (int)pictureIndex, &geo, deinterlace); if (image) { @@ -196,7 +202,7 @@ typedef enum EncodeState : NSUInteger { if (self.core || index >= self.imagesCount) return NO; - hb_job_t *job = self.title->job; + hb_job_t *job = self.job.title.hb_title->job; /* Generate the file url and directories. */ if (job->mux & HB_MUX_MASK_MP4) @@ -235,6 +241,7 @@ typedef enum EncodeState : NSUInteger { int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue]; self.core = [[[HBCore alloc] initWithLoggingLevel:loggingLevel] autorelease]; + self.core.name = @"PreviewCore"; /* * If scanning we need to do some extra setup of the job. |