summaryrefslogtreecommitdiffstats
path: root/macosx/HBPreviewController.m
diff options
context:
space:
mode:
authorritsuka <[email protected]>2013-11-02 18:09:06 +0000
committerritsuka <[email protected]>2013-11-02 18:09:06 +0000
commitb94f4686f052a9129c54b0bb5af39d6e86554872 (patch)
tree0a8f2e4b3e8dd0e55f9cb4c63dd5d7cbd4fb171d /macosx/HBPreviewController.m
parent4da46e1fe6b357db3434553f67acf06e3a0ac58b (diff)
MacGUI: refactor PictureController. kill a bit of dead code (~500 lines), switch some ivars to properties, hide the private methods and rework the deinterlace logic. Plus UI alignment.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5869 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBPreviewController.m')
-rw-r--r--macosx/HBPreviewController.m20
1 files changed, 14 insertions, 6 deletions
diff --git a/macosx/HBPreviewController.m b/macosx/HBPreviewController.m
index 8ea8c9bb3..49e01fd87 100644
--- a/macosx/HBPreviewController.m
+++ b/macosx/HBPreviewController.m
@@ -8,7 +8,6 @@
#import "Controller.h"
#define BORDER_SIZE 2.0
-#define HB_NUM_HBLIB_PICTURES 20 // # of preview pictures libhb should generate
@implementation QTMovieView (HBExtensions)
- (void) mouseMoved:(NSEvent *)theEvent
@@ -47,7 +46,7 @@
// go away.
[self window];
- fPicturePreviews = [[NSMutableDictionary dictionaryWithCapacity: HB_NUM_HBLIB_PICTURES] retain];
+ fPicturePreviews = [[NSMutableDictionary alloc] init];
/* Init libhb with check for updates libhb style set to "0" so its ignored and lets sparkle take care of it */
int loggingLevel = [[[NSUserDefaults standardUserDefaults] objectForKey:@"LoggingLevel"] intValue];
fPreviewLibhb = hb_init(loggingLevel, 0);
@@ -590,7 +589,7 @@
// makeImageForPicture crops the image generated by libhb stripping off the gray
// border around the content. This is the low-level method that generates the image.
// -imageForPicture calls this function whenever it can't find an image in its cache.
-+ (NSImage *) makeImageForPicture: (NSInteger)pictureIndex
+- (NSImage *) makeImageForPicture: (NSInteger)pictureIndex
libhb:(hb_handle_t*)handle
title:(hb_title_t*)title
{
@@ -609,8 +608,17 @@
buffer = (uint8_t *) realloc( buffer, bufferSize );
}
+ // Enable and the disable deinterlace just for preview if deinterlace
+ // or decomb filters are enabled
+ int deinterlaceStatus = title->job->deinterlace;
+
+ if (self.deinterlacePreview)
+ title->job->deinterlace = 1;
+
hb_get_preview( handle, title->job, (int)pictureIndex, buffer );
+ title->job->deinterlace = deinterlaceStatus;
+
// Create an NSBitmapImageRep and copy the libhb image into it, converting it from
// libhb's format to one suitable for NSImage. Along the way, we'll strip off the
// border around libhb's image.
@@ -663,7 +671,7 @@
NSImage * theImage = [fPicturePreviews objectForKey:key];
if (!theImage)
{
- theImage = [PreviewController makeImageForPicture:pictureIndex libhb:fHandle title:fTitle];
+ theImage = [self makeImageForPicture:pictureIndex libhb:fHandle title:fTitle];
[fPicturePreviews setObject:theImage forKey:key];
}
return theImage;
@@ -1328,7 +1336,7 @@
long long result;
result = time.timeValue / time.timeScale; // second
- frame = (time.timeValue % time.timeScale) / 100;
+ frame = (int)(time.timeValue % time.timeScale) / 100;
second = result % 60;
@@ -1337,7 +1345,7 @@
result = result / 60; // hour
hour = result % 24;
- days = result;
+ days = (int)result;
smtpeTimeCodeString = [NSString stringWithFormat:@"%02d:%02d:%02d", hour, minute, second]; // hh:mm:ss
return smtpeTimeCodeString;