1 /* $Id: Controller.mm,v 1.79 2005/11/04 19:41:32 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.m0k.org/>.
5 It may be used under the terms of the GNU General Public License. */
7 #include "Controller.h"
8 #include "a52dec/a52.h"
9 #import "HBOutputPanelController.h"
10 #import "HBPreferencesController.h"
11 /* Added to integrate scanning into HBController */
12 #include <IOKit/IOKitLib.h>
13 #include <IOKit/storage/IOMedia.h>
14 #include <IOKit/storage/IODVDMedia.h>
15 #include "HBDVDDetector.h"
16 #include "dvdread/dvd_reader.h"
18 #define _(a) NSLocalizedString(a,NULL)
20 static int FormatSettings[4][10] =
21 { { HB_MUX_MP4 | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC,
22 HB_MUX_MP4 | HB_VCODEC_X264 | HB_ACODEC_FAAC,
25 { HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
26 HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_AC3,
27 HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_LAME,
28 HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_AC3},
29 { HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS,
30 HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
33 { HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC,
34 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_AC3,
35 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
36 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS,
37 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_FAAC,
38 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_AC3,
39 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_LAME,
40 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_VORBIS,
45 /* We setup the toolbar values here */
46 static NSString * ToggleDrawerIdentifier = @"Toggle Drawer Item Identifier";
47 static NSString * StartEncodingIdentifier = @"Start Encoding Item Identifier";
48 static NSString * PauseEncodingIdentifier = @"Pause Encoding Item Identifier";
49 static NSString * ShowQueueIdentifier = @"Show Queue Item Identifier";
50 static NSString * AddToQueueIdentifier = @"Add to Queue Item Identifier";
51 static NSString * ShowActivityIdentifier = @"Debug Output Item Identifier";
52 static NSString * ChooseSourceIdentifier = @"Choose Source Item Identifier";
55 /*******************************
56 * HBController implementation *
57 *******************************/
58 @implementation HBController
63 [HBPreferencesController registerUserDefaults];
65 outputPanel = [[HBOutputPanelController alloc] init];
66 fPictureController = [[PictureController alloc] initWithDelegate:self];
67 fQueueController = [[HBQueueController alloc] init];
68 fAdvancedOptions = [[HBAdvancedController alloc] init];
69 fPreferencesController = [[HBPreferencesController alloc] init];
73 - (void) applicationDidFinishLaunching: (NSNotification *) notification
79 int debugLevel = [[NSUserDefaults standardUserDefaults] boolForKey:@"ShowVerboseOutput"] ? HB_DEBUG_ALL : HB_DEBUG_NONE;
80 fHandle = hb_init(debugLevel, [[NSUserDefaults standardUserDefaults] boolForKey:@"CheckForUpdates"]);
82 // Set the Growl Delegate
83 [GrowlApplicationBridge setGrowlDelegate: self];
84 /* Init others controllers */
85 [fPictureController SetHandle: fHandle];
86 [fQueueController setHandle: fHandle];
87 [fQueueController setHBController: self];
89 fChapterTitlesDelegate = [[ChapterTitles alloc] init];
90 [fChapterTable setDataSource:fChapterTitlesDelegate];
92 /* Call UpdateUI every 1/2 sec */
93 [[NSRunLoop currentRunLoop] addTimer: [NSTimer
94 scheduledTimerWithTimeInterval: 0.5 target: self
95 selector: @selector( updateUI: ) userInfo: NULL repeats: YES]
96 forMode: NSEventTrackingRunLoopMode];
98 if( ( build = hb_check_update( fHandle, &version ) ) > -1 )
100 /* Update available - tell the user */
102 NSBeginInformationalAlertSheet( _( @"Update is available" ),
103 _( @"Go get it!" ), _( @"Discard" ), NULL, fWindow, self,
104 @selector( updateAlertDone:returnCode:contextInfo: ),
105 NULL, NULL, [NSString stringWithFormat:
106 _( @"HandBrake %s (build %d) is now available for download." ),
112 // Open debug output window now if it was visible when HB was closed
113 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"])
114 [self showDebugOutputPanel:nil];
116 // Open queue window now if it was visible when HB was closed
117 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QueueWindowIsOpen"])
118 [self showQueueWindow:nil];
120 [self openMainWindow:nil];
122 /* Show scan panel ASAP */
123 [self performSelectorOnMainThread: @selector(showScanPanel:)
124 withObject: NULL waitUntilDone: NO];
127 - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app
129 // Warn if encoding a movie
131 hb_get_state( fHandle, &s );
132 hb_job_t * job = hb_current_job( fHandle );
133 if ( job && ( s.state != HB_STATE_IDLE ) )
135 hb_job_t * job = hb_current_job( fHandle );
136 int result = NSRunCriticalAlertPanel(
137 NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
138 NSLocalizedString(@"%@ is currently encoding. If you quit HandBrake, your movie will be lost. Do you want to quit anyway?", nil),
139 NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil,
140 job ? [NSString stringWithUTF8String:job->title->name] : @"A movie" );
142 if (result == NSAlertDefaultReturn)
144 [self doCancelCurrentJob];
145 return NSTerminateNow;
148 return NSTerminateCancel;
151 // Warn if items still in the queue
152 else if ( hb_count( fHandle ) > 0 )
154 int result = NSRunCriticalAlertPanel(
155 NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
156 NSLocalizedString(@"One or more encodes are queued for encoding. Do you want to quit anyway?", nil),
157 NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil);
159 if ( result == NSAlertDefaultReturn )
160 return NSTerminateNow;
162 return NSTerminateCancel;
165 return NSTerminateNow;
168 - (void)applicationWillTerminate:(NSNotification *)aNotification
170 [outputPanel release];
171 [fQueueController release];
176 - (void) awakeFromNib
179 [fWindow setExcludedFromWindowsMenu:YES];
180 [fAdvancedOptions setView:fAdvancedView];
182 /* Initialize currentScanCount so HB can use it to
183 evaluate successive scans */
184 currentScanCount = 0;
186 /* Init UserPresets .plist */
189 fRipIndicatorShown = NO; // initially out of view in the nib
191 /* Show/Dont Show Presets drawer upon launch based
192 on user preference DefaultPresetsDrawerShow*/
193 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0)
195 [fPresetDrawer open];
200 [fDstFormatPopUp removeAllItems];
201 [fDstFormatPopUp addItemWithTitle: _( @"MP4 file" )];
202 [fDstFormatPopUp addItemWithTitle: _( @"AVI file" )];
203 [fDstFormatPopUp addItemWithTitle: _( @"OGM file" )];
204 [fDstFormatPopUp addItemWithTitle: _( @"MKV file" )];
205 [fDstFormatPopUp selectItemAtIndex: 0];
207 [self formatPopUpChanged: NULL];
209 /* We enable the create chapters checkbox here since we are .mp4 */
210 [fCreateChapterMarkers setEnabled: YES];
211 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultChapterMarkers"] > 0)
213 [fCreateChapterMarkers setState: NSOnState];
219 [fDstFile2Field setStringValue: [NSString stringWithFormat:
220 @"%@/Desktop/Movie.mp4", NSHomeDirectory()]];
223 [fVidEncoderPopUp removeAllItems];
224 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
225 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
230 [fVidTargetSizeField setIntValue: 700];
231 [fVidBitrateField setIntValue: 1000];
233 [fVidQualityMatrix selectCell: fVidBitrateCell];
234 [self videoMatrixChanged: NULL];
236 /* Video framerate */
237 [fVidRatePopUp removeAllItems];
238 [fVidRatePopUp addItemWithTitle: _( @"Same as source" )];
239 for( int i = 0; i < hb_video_rates_count; i++ )
241 if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]])
243 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
244 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Film)"]];
246 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]])
248 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
249 [NSString stringWithCString: hb_video_rates[i].string], @" (PAL Film/Video)"]];
251 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]])
253 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
254 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Video)"]];
258 [fVidRatePopUp addItemWithTitle:
259 [NSString stringWithCString: hb_video_rates[i].string]];
262 [fVidRatePopUp selectItemAtIndex: 0];
264 /* Picture Settings */
265 [fPicLabelPAROutputX setStringValue: @""];
266 [fPicSettingPARWidth setStringValue: @""];
267 [fPicSettingPARHeight setStringValue: @""];
269 /* Set Auto Crop to On at launch */
270 [fPictureController setAutoCrop:YES];
273 [fAudBitratePopUp removeAllItems];
274 for( int i = 0; i < hb_audio_bitrates_count; i++ )
276 [fAudBitratePopUp addItemWithTitle:
277 [NSString stringWithCString: hb_audio_bitrates[i].string]];
280 [fAudBitratePopUp selectItemAtIndex: hb_audio_bitrates_default];
282 /* Audio samplerate */
283 [fAudRatePopUp removeAllItems];
284 for( int i = 0; i < hb_audio_rates_count; i++ )
286 [fAudRatePopUp addItemWithTitle:
287 [NSString stringWithCString: hb_audio_rates[i].string]];
289 [fAudRatePopUp selectItemAtIndex: hb_audio_rates_default];
292 [fStatusField setStringValue: @""];
297 [fPresetsActionButton setMenu:fPresetsActionMenu];
299 /* We disable the Turbo 1st pass checkbox since we are not x264 */
300 [fVidTurboPassCheck setEnabled: NO];
301 [fVidTurboPassCheck setState: NSOffState];
304 /* lets get our default prefs here */
305 [self getDefaultPresets: NULL];
306 /* lets initialize the current successful scancount here to 0 */
307 currentSuccessfulScanCount = 0;
311 - (void) loadPresets {
312 /* We declare the default NSFileManager into fileManager */
313 NSFileManager * fileManager = [NSFileManager defaultManager];
314 /* we set the files and support paths here */
315 AppSupportDirectory = @"~/Library/Application Support/HandBrake";
316 AppSupportDirectory = [AppSupportDirectory stringByExpandingTildeInPath];
317 //UserPresetsFile = @"~/Library/Application Support/HandBrake/UserPresets.plist";
318 //UserPresetsFile = [UserPresetsFile stringByExpandingTildeInPath];
319 /* We check for the app support directory for handbrake */
320 if ([fileManager fileExistsAtPath:AppSupportDirectory] == 0)
322 // If it doesnt exist yet, we create it here
323 [fileManager createDirectoryAtPath:AppSupportDirectory attributes:nil];
325 /* We check for the presets.plist here */
326 if ([fileManager fileExistsAtPath:UserPresetsFile] == 0)
328 [fileManager createFileAtPath:UserPresetsFile contents:nil attributes:nil];
330 UserPresetsFile = @"~/Library/Application Support/HandBrake/UserPresets.plist";
331 UserPresetsFile = [[UserPresetsFile stringByExpandingTildeInPath]retain];
333 UserPresets = [[NSMutableArray alloc] initWithContentsOfFile:UserPresetsFile];
334 if (nil == UserPresets)
336 UserPresets = [[NSMutableArray alloc] init];
337 [self addFactoryPresets:NULL];
342 // ============================================================
343 // NSToolbar Related Methods
344 // ============================================================
346 - (void) setupToolbar {
347 toolbar = [[[NSToolbar alloc] initWithIdentifier: @"HandBrake Toolbar"] autorelease];
349 [toolbar setAllowsUserCustomization: YES];
350 [toolbar setAutosavesConfiguration: YES];
351 [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
353 [toolbar setDelegate: self];
355 [fWindow setToolbar: toolbar];
358 - (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier:
359 (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
360 NSToolbarItem * item = [[NSToolbarItem alloc] initWithItemIdentifier: itemIdent];
362 if ([itemIdent isEqualToString: ToggleDrawerIdentifier])
364 [item setLabel: @"Toggle Presets"];
365 [item setPaletteLabel: @"Toggler Presets"];
366 [item setToolTip: @"Open/Close Preset Drawer"];
367 [item setImage: [NSImage imageNamed: @"Drawer-List2"]];
368 [item setTarget: self];
369 [item setAction: @selector(toggleDrawer:)];
370 [item setAutovalidates: NO];
372 else if ([itemIdent isEqualToString: StartEncodingIdentifier])
374 [item setLabel: @"Start"];
375 [item setPaletteLabel: @"Start Encoding"];
376 [item setToolTip: @"Start Encoding"];
377 [item setImage: [NSImage imageNamed: @"Play"]];
378 [item setTarget: self];
379 [item setAction: @selector(Rip:)];
381 else if ([itemIdent isEqualToString: ShowQueueIdentifier])
383 [item setLabel: @"Show Queue"];
384 [item setPaletteLabel: @"Show Queue"];
385 [item setToolTip: @"Show Queue"];
386 [item setImage: [NSImage imageNamed: @"Brushed Window"]];
387 [item setTarget: self];
388 [item setAction: @selector(showQueueWindow:)];
389 [item setAutovalidates: NO];
391 else if ([itemIdent isEqualToString: AddToQueueIdentifier])
393 [item setLabel: @"Add to Queue"];
394 [item setPaletteLabel: @"Add to Queue"];
395 [item setToolTip: @"Add to Queue"];
396 [item setImage: [NSImage imageNamed: @"Add"]];
397 [item setTarget: self];
398 [item setAction: @selector(addToQueue:)];
400 else if ([itemIdent isEqualToString: PauseEncodingIdentifier])
402 [item setLabel: @"Pause"];
403 [item setPaletteLabel: @"Pause Encoding"];
404 [item setToolTip: @"Pause Encoding"];
405 [item setImage: [NSImage imageNamed: @"Pause"]];
406 [item setTarget: self];
407 [item setAction: @selector(Pause:)];
409 else if ([itemIdent isEqualToString: ShowActivityIdentifier]) {
410 [item setLabel: @"Activity Window"];
411 [item setPaletteLabel: @"Show Activity Window"];
412 [item setToolTip: @"Show Activity Window"];
413 [item setImage: [NSImage imageNamed: @"Terminal"]];
414 [item setTarget: self];
415 [item setAction: @selector(showDebugOutputPanel:)];
416 [item setAutovalidates: NO];
418 else if ([itemIdent isEqualToString: ChooseSourceIdentifier])
420 [item setLabel: @"Source"];
421 [item setPaletteLabel: @"Source"];
422 [item setToolTip: @"Choose Video Source"];
423 [item setImage: [NSImage imageNamed: @"Disc"]];
424 [item setTarget: self];
425 [item setAction: @selector(showScanPanel:)];
426 [item setAutovalidates: NO];
437 - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
439 return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier,
440 PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
441 NSToolbarSpaceItemIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier, nil];
444 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
446 return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier,
447 ChooseSourceIdentifier, ShowQueueIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier,
448 NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
449 NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
452 - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
454 NSString * ident = [toolbarItem itemIdentifier];
459 hb_get_state2( fHandle, &s );
461 if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING)
463 if ([ident isEqualToString: StartEncodingIdentifier])
465 [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];
466 [toolbarItem setLabel: @"Stop"];
467 [toolbarItem setPaletteLabel: @"Stop"];
468 [toolbarItem setToolTip: @"Stop Encoding"];
471 if ([ident isEqualToString: PauseEncodingIdentifier])
473 [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
474 [toolbarItem setLabel: @"Pause"];
475 [toolbarItem setPaletteLabel: @"Pause Encoding"];
476 [toolbarItem setToolTip: @"Pause Encoding"];
480 if ([ident isEqualToString: AddToQueueIdentifier])
483 else if (s.state == HB_STATE_PAUSED)
485 if ([ident isEqualToString: PauseEncodingIdentifier])
487 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
488 [toolbarItem setLabel: @"Resume"];
489 [toolbarItem setPaletteLabel: @"Resume Encoding"];
490 [toolbarItem setToolTip: @"Resume Encoding"];
493 if ([ident isEqualToString: StartEncodingIdentifier])
495 if ([ident isEqualToString: AddToQueueIdentifier])
498 else if (s.state == HB_STATE_SCANNING)
500 else if (s.state == HB_STATE_WORKDONE || s.state == HB_STATE_SCANDONE || SuccessfulScan)
502 if ([ident isEqualToString: StartEncodingIdentifier])
504 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
505 if (hb_count(fHandle) > 0)
506 [toolbarItem setLabel: @"Start Queue"];
508 [toolbarItem setLabel: @"Start"];
509 [toolbarItem setPaletteLabel: @"Start Encoding"];
510 [toolbarItem setToolTip: @"Start Encoding"];
513 if ([ident isEqualToString: AddToQueueIdentifier])
519 if ([ident isEqualToString: ShowQueueIdentifier])
521 if ([ident isEqualToString: ToggleDrawerIdentifier])
523 if ([ident isEqualToString: ChooseSourceIdentifier])
525 if ([ident isEqualToString: ShowActivityIdentifier])
531 - (BOOL) validateMenuItem: (NSMenuItem *) menuItem
533 SEL action = [menuItem action];
536 hb_get_state2( fHandle, &s );
540 if (action == @selector(addToQueue:) || action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:))
541 return SuccessfulScan && [fWindow attachedSheet] == nil;
543 if (action == @selector(showScanPanel:))
545 if (s.state == HB_STATE_SCANNING)
548 return [fWindow attachedSheet] == nil;
550 if (action == @selector(selectDefaultPreset:))
551 return [tableView selectedRow] >= 0 && [fWindow attachedSheet] == nil;
552 if (action == @selector(Pause:))
554 if (s.state == HB_STATE_WORKING)
556 if(![[menuItem title] isEqualToString:@"Pause Encoding"])
557 [menuItem setTitle:@"Pause Encoding"];
560 else if (s.state == HB_STATE_PAUSED)
562 if(![[menuItem title] isEqualToString:@"Resume Encoding"])
563 [menuItem setTitle:@"Resume Encoding"];
569 if (action == @selector(Rip:))
570 if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING || s.state == HB_STATE_PAUSED)
572 if(![[menuItem title] isEqualToString:@"Stop Encoding"])
573 [menuItem setTitle:@"Stop Encoding"];
576 else if (SuccessfulScan)
578 if(![[menuItem title] isEqualToString:@"Start Encoding"])
579 [menuItem setTitle:@"Start Encoding"];
580 return [fWindow attachedSheet] == nil;
590 // register a test notification and make
591 // it enabled by default
592 #define SERVICE_NAME @"Encode Done"
593 - (NSDictionary *)registrationDictionaryForGrowl
595 NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
596 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL,
597 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT,
600 return registrationDictionary;
603 - (void) TranslateStrings
605 [fSrcTitleField setStringValue: _( @"Title:" )];
606 [fSrcChapterField setStringValue: _( @"Chapters:" )];
607 [fSrcChapterToField setStringValue: _( @"to" )];
608 [fSrcDuration1Field setStringValue: _( @"Duration:" )];
610 [fDstFormatField setStringValue: _( @"Format:" )];
611 [fDstCodecsField setStringValue: _( @"Codecs:" )];
612 [fDstFile1Field setStringValue: _( @"File:" )];
613 [fDstBrowseButton setTitle: _( @"Browse" )];
615 [fVidRateField setStringValue: _( @"Framerate (fps):" )];
616 [fVidEncoderField setStringValue: _( @"Encoder:" )];
617 [fVidQualityField setStringValue: _( @"Quality:" )];
620 /***********************************************************************
622 ***********************************************************************
623 * Shows a progression bar on the dock icon, filled according to
624 * 'progress' (0.0 <= progress <= 1.0).
625 * Called with progress < 0.0 or progress > 1.0, restores the original
627 **********************************************************************/
628 - (void) UpdateDockIcon: (float) progress
632 NSBitmapImageRep * bmp;
634 uint32_t black = htonl( 0x000000FF );
635 uint32_t red = htonl( 0xFF0000FF );
636 uint32_t white = htonl( 0xFFFFFFFF );
637 int row_start, row_end;
640 /* Get application original icon */
641 icon = [NSImage imageNamed: @"NSApplicationIcon"];
643 if( progress < 0.0 || progress > 1.0 )
645 [NSApp setApplicationIconImage: icon];
649 /* Get it in a raw bitmap form */
650 tiff = [icon TIFFRepresentationUsingCompression:
651 NSTIFFCompressionNone factor: 1.0];
652 bmp = [NSBitmapImageRep imageRepWithData: tiff];
654 /* Draw the progression bar */
655 /* It's pretty simple (ugly?) now, but I'm no designer */
657 row_start = 3 * (int) [bmp size].height / 4;
658 row_end = 7 * (int) [bmp size].height / 8;
660 for( i = row_start; i < row_start + 2; i++ )
662 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
663 for( j = 0; j < (int) [bmp size].width; j++ )
668 for( i = row_start + 2; i < row_end - 2; i++ )
670 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
673 for( j = 2; j < (int) [bmp size].width - 2; j++ )
675 if( j < 2 + (int) ( ( [bmp size].width - 4.0 ) * progress ) )
687 for( i = row_end - 2; i < row_end; i++ )
689 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
690 for( j = 0; j < (int) [bmp size].width; j++ )
696 /* Now update the dock icon */
697 tiff = [bmp TIFFRepresentationUsingCompression:
698 NSTIFFCompressionNone factor: 1.0];
699 icon = [[NSImage alloc] initWithData: tiff];
700 [NSApp setApplicationIconImage: icon];
704 - (void) updateUI: (NSTimer *) timer
708 list = hb_get_titles( fHandle );
709 /* check to see if there has been a new scan done
710 this bypasses the constraints of HB_STATE_WORKING
711 not allowing setting a newly scanned source */
712 int checkScanCount = hb_get_scancount( fHandle );
713 if (checkScanCount > currentScanCount)
716 currentScanCount = checkScanCount;
717 //[fScanController Cancel: NULL];
718 [fScanIndicator setIndeterminate: NO];
719 [fScanIndicator setDoubleValue: 0.0];
720 [fScanIndicator setHidden: YES];
722 [self showNewScan: NULL];
726 hb_get_state( fHandle, &s );
733 #define p s.param.scanning
734 case HB_STATE_SCANNING:
736 [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
737 _( @"Scanning title %d of %d..." ),
738 p.title_cur, p.title_count]];
739 [fScanIndicator setIndeterminate: NO];
740 [fScanIndicator setDoubleValue: 100.0 * ( p.title_cur - 1 ) /
746 #define p s.param.scandone
747 case HB_STATE_SCANDONE:
750 [fScanIndicator setIndeterminate: NO];
751 [fScanIndicator setDoubleValue: 0.0];
752 [fScanIndicator setHidden: YES];
753 [self showNewScan: NULL];
754 [toolbar validateVisibleItems];
759 #define p s.param.working
760 case HB_STATE_WORKING:
762 float progress_total;
763 NSMutableString * string;
764 /* Currently, p.job_cur and p.job_count get screwed up when adding
765 jobs during encoding, if they cannot be fixed in libhb, will implement a
766 nasty but working cocoa solution */
767 /* Update text field */
768 string = [NSMutableString stringWithFormat: _( @"Encoding: task %d of %d, %.2f %%" ), p.job_cur, p.job_count, 100.0 * p.progress];
772 [string appendFormat:
773 _( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)" ),
774 p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds];
776 [fStatusField setStringValue: string];
779 progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
780 [fRipIndicator setIndeterminate: NO];
781 [fRipIndicator setDoubleValue: 100.0 * progress_total];
783 // If progress bar hasn't been revealed at the bottom of the window, do
784 // that now. This code used to be in doRip. I moved it to here to handle
785 // the case where hb_start is called by HBQueueController and not from
787 if (!fRipIndicatorShown)
789 NSRect frame = [fWindow frame];
790 if (frame.size.width <= 591)
791 frame.size.width = 591;
792 frame.size.height += 36;
793 frame.origin.y -= 36;
794 [fWindow setFrame:frame display:YES animate:YES];
795 fRipIndicatorShown = YES;
798 /* Update dock icon */
799 [self UpdateDockIcon: progress_total];
801 // Has current job changed? That means the queue has probably changed as
803 if (fLastKnownCurrentJob != hb_current_job(fHandle))
805 fLastKnownCurrentJob = hb_current_job(fHandle);
806 [fQueueController updateQueueUI];
808 [fQueueController updateCurrentJobUI];
814 #define p s.param.muxing
815 case HB_STATE_MUXING:
817 NSMutableString * string;
819 /* Update text field */
820 string = [NSMutableString stringWithFormat:
822 [fStatusField setStringValue: string];
825 [fRipIndicator setIndeterminate: YES];
826 [fRipIndicator startAnimation: nil];
828 /* Update dock icon */
829 [self UpdateDockIcon: 1.0];
831 // Pass along the info to HBQueueController
832 [fQueueController updateCurrentJobUI];
838 case HB_STATE_PAUSED:
839 [fStatusField setStringValue: _( @"Paused" )];
841 // Pass along the info to HBQueueController
842 [fQueueController updateCurrentJobUI];
846 case HB_STATE_WORKDONE:
848 // HB_STATE_WORKDONE happpens as a result of hblib finishing all its jobs
849 // or someone calling hb_stop. In the latter case, hb_stop does not clear
850 // out the remaining passes/jobs in the queue. We'll do that here.
852 // Delete all remaining scans of this job, ie, delete whole encodes.
854 while( ( job = hb_job( fHandle, 0 ) ) && (job->sequence_id != 0) )
855 hb_rem( fHandle, job );
857 // Start processing back up if jobs still left in queue
858 if (hb_count(fHandle) > 0)
862 // Validate the toolbar (hack). The toolbar will usually get autovalidated
863 // before we had the chance to restart the queue, hence it will now be in
865 [toolbar validateVisibleItems];
869 [fStatusField setStringValue: _( @"Done." )];
870 [fRipIndicator setIndeterminate: NO];
871 [fRipIndicator setDoubleValue: 0.0];
872 [toolbar validateVisibleItems];
874 /* Restore dock icon */
875 [self UpdateDockIcon: -1.0];
877 if (fRipIndicatorShown)
879 NSRect frame = [fWindow frame];
880 if (frame.size.width <= 591)
881 frame.size.width = 591;
882 frame.size.height += -36;
883 frame.origin.y -= -36;
884 [fWindow setFrame:frame display:YES animate:YES];
885 fRipIndicatorShown = NO;
888 // Queue has been modified so update the UI
889 fLastKnownCurrentJob = nil;
890 [fQueueController updateQueueUI];
891 [fQueueController updateCurrentJobUI];
893 /* Check to see if the encode state has not been cancelled
894 to determine if we should check for encode done notifications */
895 if (fEncodeState != 2) {
896 /* If Growl Notification or Window and Growl has been selected */
897 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] ||
898 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
900 /*Growl Notification*/
901 [self showGrowlDoneNotification: NULL];
903 /* If Alert Window or Window and Growl has been selected */
904 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
905 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
907 /*On Screen Notification*/
910 status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake encode is done!", @"OK", nil, nil);
911 [NSApp requestUserAttention:NSCriticalRequest];
912 if ( status == NSAlertDefaultReturn )
914 [self enableUI: YES];
919 [self enableUI: YES];
921 /* If sleep has been selected */
922 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
925 NSDictionary* errorDict;
926 NSAppleEventDescriptor* returnDescriptor = NULL;
927 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
928 @"tell application \"Finder\" to sleep"];
929 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
930 [scriptObject release];
931 [self enableUI: YES];
933 /* If Shutdown has been selected */
934 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
937 NSDictionary* errorDict;
938 NSAppleEventDescriptor* returnDescriptor = NULL;
939 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
940 @"tell application \"Finder\" to shut down"];
941 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
942 [scriptObject release];
943 [self enableUI: YES];
946 // MetaX insertion via AppleScript
947 if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
949 NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", [fDstFile2Field stringValue], @"\")"]];
950 [myScript executeAndReturnError: nil];
958 [self enableUI: YES];
964 /* Lets show the queue status here in the main window */
965 int queue_count = hb_count( fHandle );
968 [fQueueStatus setStringValue: [NSString stringWithFormat:
969 @"%d pass%s in the queue",
970 queue_count, ( queue_count > 1 ) ? "es" : ""]];
974 [fQueueStatus setStringValue: @""];
978 - (IBAction) showNewScan:(id)sender
982 int indxpri=0; // Used to search the longuest title (default in combobox)
983 int longuestpri=0; // Used to search the longuest title (default in combobox)
985 list = hb_get_titles( fHandle );
987 if( !hb_list_count( list ) )
989 /* We display a message if a valid dvd source was not chosen */
990 [fSrcDVD2Field setStringValue: @"No Valid Title Found"];
995 /* We increment the successful scancount here by one,
996 which we use at the end of this function to tell the gui
997 if this is the first successful scan since launch and whether
998 or not we should set all settings to the defaults */
1001 currentSuccessfulScanCount++;
1003 [self enableUI: YES];
1005 [toolbar validateVisibleItems];
1007 [fSrcTitlePopUp removeAllItems];
1008 for( int i = 0; i < hb_list_count( list ); i++ )
1010 title = (hb_title_t *) hb_list_item( list, i );
1011 /*Set DVD Name at top of window*/
1012 [fSrcDVD2Field setStringValue:[NSString stringWithUTF8String: title->name]];
1014 currentSource = [NSString stringWithUTF8String: title->dvd];
1017 /* Use the dvd name in the default output field here
1018 May want to add code to remove blank spaces for some dvd names*/
1019 /* Check to see if the last destination has been set,use if so, if not, use Desktop */
1020 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"])
1022 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1023 @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],[NSString
1024 stringWithUTF8String: title->name]]];
1028 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1029 @"%@/Desktop/%@.mp4", NSHomeDirectory(),[NSString
1030 stringWithUTF8String: title->name]]];
1034 if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds)
1036 longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds;
1041 int format = [fDstFormatPopUp indexOfSelectedItem];
1047 /*Get Default MP4 File Extension for mpeg4 (.mp4 or .m4v) from prefs*/
1048 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
1069 NSString * string = [fDstFile2Field stringValue];
1070 /* Add/replace File Output name to the correct extension*/
1071 if( [string characterAtIndex: [string length] - 4] == '.' )
1073 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1074 @"%@.%s", [string substringToIndex: [string length] - 4],
1079 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1080 @"%@.%s", string, ext]];
1084 [fSrcTitlePopUp addItemWithTitle: [NSString
1085 stringWithFormat: @"%d - %02dh%02dm%02ds",
1086 title->index, title->hours, title->minutes,
1090 // Select the longuest title
1091 [fSrcTitlePopUp selectItemAtIndex: indxpri];
1092 [self titlePopUpChanged: NULL];
1096 [self enableUI: YES];
1098 /* we record the current source name here in case the next scan is unsuccessful,
1099 then we can replace the scan progress with the old name if necessary */
1100 sourceDisplayName = [NSString stringWithFormat:[fSrcDVD2Field stringValue]];
1102 /* if its the initial successful scan after awakeFromNib */
1103 if (currentSuccessfulScanCount == 1)
1105 [self selectDefaultPreset: NULL];
1106 /* if Deinterlace upon launch is specified in the prefs, then set to 1 for "Fast",
1107 if not, then set to 0 for none */
1108 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultDeinterlaceOn"] > 0)
1109 [fPictureController setDeinterlace:1];
1111 [fPictureController setDeinterlace:0];
1117 -(IBAction)showGrowlDoneNotification:(id)sender
1119 [GrowlApplicationBridge
1120 notifyWithTitle:@"Put down that cocktail..."
1121 description:@"your HandBrake encode is done!"
1122 notificationName:SERVICE_NAME
1129 - (void) enableUI: (bool) b
1131 NSControl * controls[] =
1132 { fSrcTitleField, fSrcTitlePopUp,
1133 fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField,
1134 fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field,
1135 fDstFormatField, fDstFormatPopUp, fDstCodecsField,
1136 fDstCodecsPopUp, fDstFile1Field, fDstFile2Field,
1137 fDstBrowseButton, fVidRateField, fVidRatePopUp,
1138 fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
1139 fVidQualityMatrix, fVidGrayscaleCheck, fSubField, fSubPopUp,
1140 fAudLang1Field, fAudLang1PopUp, fAudLang2Field, fAudLang2PopUp,
1141 fAudTrack1MixLabel, fAudTrack1MixPopUp, fAudTrack2MixLabel, fAudTrack2MixPopUp,
1142 fAudRateField, fAudRatePopUp, fAudBitrateField,
1143 fAudBitratePopUp, fPictureButton,fQueueStatus,
1144 fPicSrcWidth,fPicSrcHeight,fPicSettingWidth,fPicSettingHeight,fPicSettingARkeep,
1145 fPicSettingDeinterlace,fPicLabelSettings,fPicLabelSrc,fPicLabelOutp,
1146 fPicLabelAr,fPicLabelDeinterlace,fPicLabelSrcX,fPicLabelOutputX,
1147 fPicLabelPAROutputX,fPicSettingPARWidth,fPicSettingPARHeight,
1148 fPicSettingPAR,fPicLabelAnamorphic,tableView,fPresetsAdd,fPresetsDelete,
1149 fCreateChapterMarkers,fVidTurboPassCheck,fDstMpgLargeFileCheck,fPicLabelAutoCrop,
1150 fPicSettingAutoCrop,fPicSettingDetelecine,fPicLabelDetelecine,fPicLabelDenoise,fPicSettingDenoise,fSubForcedCheck,};
1152 for( unsigned i = 0;
1153 i < sizeof( controls ) / sizeof( NSControl * ); i++ )
1155 if( [[controls[i] className] isEqualToString: @"NSTextField"] )
1157 NSTextField * tf = (NSTextField *) controls[i];
1158 if( ![tf isBezeled] )
1160 [tf setTextColor: b ? [NSColor controlTextColor] :
1161 [NSColor disabledControlTextColor]];
1165 [controls[i] setEnabled: b];
1171 /* if we're enabling the interface, check if the audio mixdown controls need to be enabled or not */
1172 /* these will have been enabled by the mass control enablement above anyway, so we're sense-checking it here */
1173 [self setEnabledStateOfAudioMixdownControls: NULL];
1177 [tableView setEnabled: NO];
1181 [self videoMatrixChanged: NULL];
1182 [fAdvancedOptions enableUI:b];
1185 - (IBAction) showScanPanel: (id) sender
1187 [self enableUI: NO];
1189 [self browseSources:NULL];
1192 - (void) browseSources: (id) sender
1194 NSOpenPanel * panel;
1196 panel = [NSOpenPanel openPanel];
1197 [panel setAllowsMultipleSelection: NO];
1198 [panel setCanChooseFiles: YES];
1199 [panel setCanChooseDirectories: YES ];
1200 NSString * sourceDirectory;
1201 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"])
1203 sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"];
1207 sourceDirectory = @"~/Desktop";
1208 sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
1210 [panel beginSheetForDirectory: sourceDirectory file: nil types: nil
1211 modalForWindow: fWindow modalDelegate: self
1212 didEndSelector: @selector( browseSourcesDone:returnCode:contextInfo: )
1216 - (void) browseSourcesDone: (NSOpenPanel *) sheet
1217 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1219 /* User selected a file to open */
1220 if( returnCode == NSOKButton )
1222 [fSrcDVD2Field setStringValue: _( @"Opening a new source ..." )];
1223 [fScanIndicator setHidden: NO];
1224 [fScanIndicator setIndeterminate: YES];
1225 [fScanIndicator startAnimation: nil];
1227 /* we set the last source directory in the prefs here */
1228 NSString *sourceDirectory = [[[sheet filenames] objectAtIndex: 0] stringByDeletingLastPathComponent];
1229 [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"];
1231 NSString *path = [[sheet filenames] objectAtIndex: 0];
1232 HBDVDDetector *detector = [HBDVDDetector detectorForPath:path];
1233 if( [detector isVideoDVD] )
1235 // The chosen path was actually on a DVD, so use the raw block
1236 // device path instead.
1237 path = [detector devicePath];
1240 hb_scan( fHandle, [path UTF8String], 0 );
1242 else // User clicked Cancel in browse window
1244 /* if we have a title loaded up */
1245 if ([[fSrcDVD2Field stringValue] length] > 0)
1247 [self enableUI: YES];
1252 - (IBAction) openMainWindow: (id) sender
1254 [fWindow makeKeyAndOrderFront:nil];
1255 [fWindow setReleasedWhenClosed: YES];
1258 - (BOOL) windowShouldClose: (id) sender
1260 [fWindow setReleasedWhenClosed: NO];
1264 - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
1267 [fWindow makeKeyAndOrderFront:nil];
1268 [fWindow setReleasedWhenClosed: YES];
1276 - (IBAction) videoMatrixChanged: (id) sender;
1278 bool target, bitrate, quality;
1280 target = bitrate = quality = false;
1281 if( [fVidQualityMatrix isEnabled] )
1283 switch( [fVidQualityMatrix selectedRow] )
1296 [fVidTargetSizeField setEnabled: target];
1297 [fVidBitrateField setEnabled: bitrate];
1298 [fVidQualitySlider setEnabled: quality];
1299 [fVidTwoPassCheck setEnabled: !quality &&
1300 [fVidQualityMatrix isEnabled]];
1303 [fVidTwoPassCheck setState: NSOffState];
1304 [fVidTurboPassCheck setHidden: YES];
1305 [fVidTurboPassCheck setState: NSOffState];
1308 [self qualitySliderChanged: sender];
1309 [self calculateBitrate: sender];
1310 [self customSettingUsed: sender];
1313 - (IBAction) qualitySliderChanged: (id) sender
1315 [fVidConstantCell setTitle: [NSString stringWithFormat:
1316 _( @"Constant quality: %.0f %%" ), 100.0 *
1317 [fVidQualitySlider floatValue]]];
1318 [self customSettingUsed: sender];
1321 - (IBAction) browseFile: (id) sender
1323 /* Open a panel to let the user choose and update the text field */
1324 NSSavePanel * panel = [NSSavePanel savePanel];
1325 /* We get the current file name and path from the destination field here */
1326 [panel beginSheetForDirectory: [[fDstFile2Field stringValue] stringByDeletingLastPathComponent] file: [[fDstFile2Field stringValue] lastPathComponent]
1327 modalForWindow: fWindow modalDelegate: self
1328 didEndSelector: @selector( browseFileDone:returnCode:contextInfo: )
1332 - (void) browseFileDone: (NSSavePanel *) sheet
1333 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1335 if( returnCode == NSOKButton )
1337 [fDstFile2Field setStringValue: [sheet filename]];
1341 - (IBAction) showPicturePanel: (id) sender
1343 hb_list_t * list = hb_get_titles( fHandle );
1344 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1345 [fSrcTitlePopUp indexOfSelectedItem] );
1346 [fPictureController showPanelInWindow:fWindow forTitle:title];
1349 - (void)pictureSettingsDidChange {
1350 [self calculatePictureSizing: NULL];
1355 hb_list_t * list = hb_get_titles( fHandle );
1356 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1357 [fSrcTitlePopUp indexOfSelectedItem] );
1358 hb_job_t * job = title->job;
1361 /* Chapter selection */
1362 job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
1363 job->chapter_end = [fSrcChapterEndPopUp indexOfSelectedItem] + 1;
1365 /* Format and codecs */
1366 int format = [fDstFormatPopUp indexOfSelectedItem];
1367 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1368 job->mux = FormatSettings[format][codecs] & HB_MUX_MASK;
1369 job->vcodec = FormatSettings[format][codecs] & HB_VCODEC_MASK;
1370 job->acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
1371 /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
1372 if ([fDstFormatPopUp indexOfSelectedItem] == 0)
1374 /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being
1375 mpeg4 and the checkbox being checked
1376 *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/
1377 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0 && [fDstMpgLargeFileCheck state] == NSOnState)
1379 job->largeFileSize = 1;
1383 job->largeFileSize = 0;
1386 if ([fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 3)
1388 /* We set the chapter marker extraction here based on the format being
1389 mpeg4 or mkv and the checkbox being checked */
1390 if ([fCreateChapterMarkers state] == NSOnState)
1392 job->chapter_markers = 1;
1396 job->chapter_markers = 0;
1399 if( ( job->vcodec & HB_VCODEC_FFMPEG ) &&
1400 [fVidEncoderPopUp indexOfSelectedItem] > 0 )
1402 job->vcodec = HB_VCODEC_XVID;
1404 if( job->vcodec & HB_VCODEC_X264 )
1406 if ([fVidEncoderPopUp indexOfSelectedItem] > 0 )
1408 /* Just use new Baseline Level 3.0
1409 Lets Deprecate Baseline Level 1.3h264_level*/
1410 job->h264_level = 30;
1411 job->mux = HB_MUX_IPOD;
1412 /* move sanity check for iPod Encoding here */
1413 job->pixel_ratio = 0 ;
1417 /* Set this flag to switch from Constant Quantizer(default) to Constant Rate Factor Thanks jbrjake
1418 Currently only used with Constant Quality setting*/
1419 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0 && [fVidQualityMatrix selectedRow] == 2)
1424 /* Below Sends x264 options to the core library if x264 is selected*/
1425 /* Lets use this as per Nyx, Thanks Nyx!*/
1426 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1427 /* Turbo first pass if two pass and Turbo First pass is selected */
1428 if( [fVidTwoPassCheck state] == NSOnState && [fVidTurboPassCheck state] == NSOnState )
1430 /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
1431 NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0";
1432 /* append the "Turbo" string variable to the existing opts string.
1433 Note: the "Turbo" string must be appended, not prepended to work properly*/
1434 NSString *firstPassOptStringCombined = [[fAdvancedOptions optionsString] stringByAppendingString:firstPassOptStringTurbo];
1435 strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
1439 strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]);
1442 job->h264_13 = [fVidEncoderPopUp indexOfSelectedItem];
1445 /* Video settings */
1446 if( [fVidRatePopUp indexOfSelectedItem] > 0 )
1448 job->vrate = 27000000;
1449 job->vrate_base = hb_video_rates[[fVidRatePopUp
1450 indexOfSelectedItem]-1].rate;
1454 job->vrate = title->rate;
1455 job->vrate_base = title->rate_base;
1458 switch( [fVidQualityMatrix selectedRow] )
1462 Bitrate should already have been calculated and displayed
1463 in fVidBitrateField, so let's just use it */
1465 job->vquality = -1.0;
1466 job->vbitrate = [fVidBitrateField intValue];
1469 job->vquality = [fVidQualitySlider floatValue];
1474 job->grayscale = ( [fVidGrayscaleCheck state] == NSOnState );
1476 /* Subtitle settings */
1477 job->subtitle = [fSubPopUp indexOfSelectedItem] - 2;
1479 /* Audio tracks and mixdowns */
1480 /* check for the condition where track 2 has an audio selected, but track 1 does not */
1481 /* we will use track 2 as track 1 in this scenario */
1482 if ([fAudLang1PopUp indexOfSelectedItem] > 0)
1484 job->audios[0] = [fAudLang1PopUp indexOfSelectedItem] - 1;
1485 job->audios[1] = [fAudLang2PopUp indexOfSelectedItem] - 1; /* will be -1 if "none" is selected */
1486 job->audios[2] = -1;
1487 job->audio_mixdowns[0] = [[fAudTrack1MixPopUp selectedItem] tag];
1488 job->audio_mixdowns[1] = [[fAudTrack2MixPopUp selectedItem] tag];
1490 else if ([fAudLang2PopUp indexOfSelectedItem] > 0)
1492 job->audios[0] = [fAudLang2PopUp indexOfSelectedItem] - 1;
1493 job->audio_mixdowns[0] = [[fAudTrack2MixPopUp selectedItem] tag];
1494 job->audios[1] = -1;
1498 job->audios[0] = -1;
1501 /* Audio settings */
1502 job->arate = hb_audio_rates[[fAudRatePopUp
1503 indexOfSelectedItem]].rate;
1504 job->abitrate = [[fAudBitratePopUp selectedItem] tag];
1506 job->filters = hb_list_init();
1509 if ([fPictureController detelecine])
1511 hb_list_add( job->filters, &hb_filter_detelecine );
1515 if ([fPictureController deinterlace] == 1)
1517 /* Run old deinterlacer by default */
1518 hb_filter_deinterlace.settings = "-1";
1519 hb_list_add( job->filters, &hb_filter_deinterlace );
1521 else if ([fPictureController deinterlace] == 2)
1523 /* Yadif mode 0 (1-pass with spatial deinterlacing.) */
1524 hb_filter_deinterlace.settings = "0";
1525 hb_list_add( job->filters, &hb_filter_deinterlace );
1527 else if ([fPictureController deinterlace] == 3)
1529 /* Yadif (1-pass w/o spatial deinterlacing) and Mcdeint */
1530 hb_filter_deinterlace.settings = "2:-1:1";
1531 hb_list_add( job->filters, &hb_filter_deinterlace );
1533 else if ([fPictureController deinterlace] == 4)
1535 /* Yadif (2-pass w/ spatial deinterlacing) and Mcdeint*/
1536 hb_filter_deinterlace.settings = "1:-1:1";
1537 hb_list_add( job->filters, &hb_filter_deinterlace );
1542 if ([fPictureController denoise] == 1) // Weak in popup
1544 hb_filter_denoise.settings = "2:1:2:3";
1545 hb_list_add( job->filters, &hb_filter_denoise );
1547 else if ([fPictureController denoise] == 2) // Medium in popup
1549 hb_filter_denoise.settings = "3:2:2:3";
1550 hb_list_add( job->filters, &hb_filter_denoise );
1552 else if ([fPictureController denoise] == 3) // Strong in popup
1554 hb_filter_denoise.settings = "7:7:5:5";
1555 hb_list_add( job->filters, &hb_filter_denoise );
1562 /* addToQueue: puts up an alert before ultimately calling doAddToQueue
1564 - (IBAction) addToQueue: (id) sender
1566 /* We get the destination directory from the destination field here */
1567 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1568 /* We check for a valid destination here */
1569 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1571 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1575 /* We check for duplicate name here */
1576 if( [[NSFileManager defaultManager] fileExistsAtPath:
1577 [fDstFile2Field stringValue]] )
1579 NSBeginCriticalAlertSheet( _( @"File already exists" ),
1580 _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
1581 @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
1582 NULL, NULL, [NSString stringWithFormat:
1583 _( @"Do you want to overwrite %@?" ),
1584 [fDstFile2Field stringValue]] );
1585 // overwriteAddToQueueAlertDone: will be called when the alert is dismissed.
1589 [self doAddToQueue];
1593 /* overwriteAddToQueueAlertDone: called from the alert posted by addToQueue that asks
1594 the user if they want to overwrite an exiting movie file.
1596 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
1597 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1599 if( returnCode == NSAlertAlternateReturn )
1600 [self doAddToQueue];
1603 - (void) doAddToQueue
1605 hb_list_t * list = hb_get_titles( fHandle );
1606 hb_title_t * title = (hb_title_t *) hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1607 hb_job_t * job = title->job;
1609 // Assign a sequence number, starting at zero, to each job added so they can
1610 // be lumped together in the UI.
1611 job->sequence_id = -1;
1615 /* Destination file */
1616 job->file = [[fDstFile2Field stringValue] UTF8String];
1618 if( [fSubForcedCheck state] == NSOnState )
1619 job->subtitle_force = 1;
1621 job->subtitle_force = 0;
1624 * subtitle of -1 is a scan
1626 if( job->subtitle == -1 )
1631 * When subtitle scan is enabled do a fast pre-scan job
1632 * which will determine which subtitles to enable, if any.
1635 x264opts_tmp = job->x264opts;
1638 job->x264opts = NULL;
1640 job->indepth_scan = 1;
1642 job->select_subtitle = (hb_subtitle_t**)malloc(sizeof(hb_subtitle_t*));
1643 *(job->select_subtitle) = NULL;
1646 * Add the pre-scan job
1648 job->sequence_id++; // for job grouping
1649 hb_add( fHandle, job );
1651 job->x264opts = x264opts_tmp;
1654 job->select_subtitle = NULL;
1656 /* No subtitle were selected, so reset the subtitle to -1 (which before
1657 * this point meant we were scanning
1659 if( job->subtitle == -2 )
1662 if( [fVidTwoPassCheck state] == NSOnState )
1664 hb_subtitle_t **subtitle_tmp = job->select_subtitle;
1665 job->indepth_scan = 0;
1668 job->sequence_id++; // for job grouping
1669 hb_add( fHandle, job );
1672 job->sequence_id++; // for job grouping
1674 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1675 strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]);
1677 job->select_subtitle = subtitle_tmp;
1679 hb_add( fHandle, job );
1683 job->indepth_scan = 0;
1685 job->sequence_id++; // for job grouping
1686 hb_add( fHandle, job );
1689 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1690 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1691 /* Lets try to update stuff, taken from remove in the queue controller */
1692 [fQueueController performSelectorOnMainThread: @selector( updateQueueUI )
1693 withObject: NULL waitUntilDone: NO];
1696 /* Rip: puts up an alert before ultimately calling doRip
1698 - (IBAction) Rip: (id) sender
1700 /* Rip or Cancel ? */
1702 hb_get_state2( fHandle, &s );
1704 if(s.state == HB_STATE_WORKING || s.state == HB_STATE_PAUSED)
1706 [self Cancel: sender];
1710 // If there are jobs in the queue, then this is a rip the queue
1712 if (hb_count( fHandle ) > 0)
1718 // Before adding jobs to the queue, check for a valid destination.
1720 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1721 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1723 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1727 /* We check for duplicate name here */
1728 if( [[NSFileManager defaultManager] fileExistsAtPath:[fDstFile2Field stringValue]] )
1730 NSBeginCriticalAlertSheet( _( @"File already exists" ),
1731 _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
1732 @selector( overWriteAlertDone:returnCode:contextInfo: ),
1733 NULL, NULL, [NSString stringWithFormat:
1734 _( @"Do you want to overwrite %@?" ),
1735 [fDstFile2Field stringValue]] );
1737 // overWriteAlertDone: will be called when the alert is dismissed. It will call doRip.
1741 /* if there are no jobs in the queue, then add this one to the queue and rip
1742 otherwise, just rip the queue */
1743 if( hb_count( fHandle ) == 0)
1745 [self doAddToQueue];
1748 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1749 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1754 /* overWriteAlertDone: called from the alert posted by Rip: that asks the user if they
1755 want to overwrite an exiting movie file.
1757 - (void) overWriteAlertDone: (NSWindow *) sheet
1758 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1760 if( returnCode == NSAlertAlternateReturn )
1762 /* if there are no jobs in the queue, then add this one to the queue and rip
1763 otherwise, just rip the queue */
1764 if( hb_count( fHandle ) == 0 )
1766 [self doAddToQueue];
1769 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1770 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1775 - (void) updateAlertDone: (NSWindow *) sheet
1776 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1778 if( returnCode == NSAlertAlternateReturn )
1780 /* Show scan panel */
1781 [self performSelectorOnMainThread: @selector(showScanPanel:)
1782 withObject: NULL waitUntilDone: NO];
1786 /* Go to HandBrake homepage and exit */
1787 [self openHomepage: NULL];
1788 [NSApp terminate: self];
1793 /* Let libhb do the job */
1794 hb_start( fHandle );
1795 /*set the fEncodeState State */
1803 //------------------------------------------------------------------------------------
1804 // Cancels the current job and proceeds with the next one in the queue.
1805 //------------------------------------------------------------------------------------
1806 - (void) doCancelCurrentJob
1808 // Stop the current job. hb_stop will only cancel the current pass and then set
1809 // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
1810 // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
1811 // remaining passes of the job and then start the queue back up if there are any
1815 fEncodeState = 2; // don't alert at end of processing since this was a cancel
1819 //------------------------------------------------------------------------------------
1820 // Displays an alert asking user if the want to cancel encoding of current job.
1821 // Cancel: returns immediately after posting the alert. Later, when the user
1822 // acknowledges the alert, doCancelCurrentJob is called.
1823 //------------------------------------------------------------------------------------
1824 - (IBAction)Cancel: (id)sender
1826 if (!fHandle) return;
1828 hb_job_t * job = hb_current_job(fHandle);
1831 NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Do you want to stop encoding of %@?", nil),
1832 [NSString stringWithUTF8String:job->title->name]];
1834 // Which window to attach the sheet to?
1835 NSWindow * docWindow;
1836 if ([sender respondsToSelector: @selector(window)])
1837 docWindow = [sender window];
1839 docWindow = fWindow;
1841 NSBeginCriticalAlertSheet(
1843 NSLocalizedString(@"Keep Encoding", nil), NSLocalizedString(@"Stop Encoding", nil), nil, docWindow, self,
1844 nil, @selector(didDimissCancelCurrentJob:returnCode:contextInfo:), nil,
1845 NSLocalizedString(@"Your movie will be lost if you don't continue encoding.", nil),
1846 [NSString stringWithUTF8String:job->title->name]);
1848 // didDimissCancelCurrentJob:returnCode:contextInfo: will be called when the dialog is dismissed
1850 // N.B.: didDimissCancelCurrentJob:returnCode:contextInfo: is designated as the dismiss
1851 // selector to prevent a crash. As a dismiss selector, the alert window will
1852 // have already be dismissed. If we don't do it this way, the dismissing of
1853 // the alert window will cause the table view to be redrawn at a point where
1854 // current job has been deleted by hblib but we don't know about it yet. This
1855 // is a prime example of wy we need to NOT be relying on hb_current_job!!!!
1858 - (void) didDimissCancelCurrentJob: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
1860 if (returnCode == NSAlertAlternateReturn)
1861 [self doCancelCurrentJob];
1868 - (IBAction) Pause: (id) sender
1871 hb_get_state2( fHandle, &s );
1873 if( s.state == HB_STATE_PAUSED )
1875 hb_resume( fHandle );
1879 hb_pause( fHandle );
1883 - (IBAction) titlePopUpChanged: (id) sender
1885 hb_list_t * list = hb_get_titles( fHandle );
1886 hb_title_t * title = (hb_title_t*)
1887 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1890 /* If Auto Naming is on. We create an output filename of dvd name - title number */
1891 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0)
1893 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1894 @"%@/%@-%d.%@", [[fDstFile2Field stringValue] stringByDeletingLastPathComponent],
1895 [NSString stringWithUTF8String: title->name],
1897 [[fDstFile2Field stringValue] pathExtension]]];
1900 /* Update chapter popups */
1901 [fSrcChapterStartPopUp removeAllItems];
1902 [fSrcChapterEndPopUp removeAllItems];
1903 for( int i = 0; i < hb_list_count( title->list_chapter ); i++ )
1905 [fSrcChapterStartPopUp addItemWithTitle: [NSString
1906 stringWithFormat: @"%d", i + 1]];
1907 [fSrcChapterEndPopUp addItemWithTitle: [NSString
1908 stringWithFormat: @"%d", i + 1]];
1910 [fSrcChapterStartPopUp selectItemAtIndex: 0];
1911 [fSrcChapterEndPopUp selectItemAtIndex:
1912 hb_list_count( title->list_chapter ) - 1];
1913 [self chapterPopUpChanged: NULL];
1915 /* Start Get and set the initial pic size for display */
1916 hb_job_t * job = title->job;
1918 /* Turn Deinterlace on/off depending on the preference */
1919 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultDeinterlaceOn"] > 0)
1921 [fPictureController setDeinterlace:1];
1925 [fPictureController setDeinterlace:0];
1928 /* Pixel Ratio Setting */
1929 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PixelRatio"])
1931 job->pixel_ratio = 1 ;
1935 job->pixel_ratio = 0 ;
1937 /*Set Source Size Fields Here */
1938 [fPicSrcWidth setStringValue: [NSString stringWithFormat:
1939 @"%d", fTitle->width]];
1940 [fPicSrcHeight setStringValue: [NSString stringWithFormat:
1941 @"%d", fTitle->height]];
1943 /* Set Auto Crop to on upon selecting a new title */
1944 [fPictureController setAutoCrop:YES];
1946 /* We get the originial output picture width and height and put them
1947 in variables for use with some presets later on */
1948 PicOrigOutputWidth = job->width;
1949 PicOrigOutputHeight = job->height;
1950 AutoCropTop = job->crop[0];
1951 AutoCropBottom = job->crop[1];
1952 AutoCropLeft = job->crop[2];
1953 AutoCropRight = job->crop[3];
1954 /* we test getting the max output value for pic sizing here to be used later*/
1955 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
1956 @"%d", PicOrigOutputWidth]];
1957 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
1958 @"%d", PicOrigOutputHeight]];
1959 /* we run the picture size values through
1960 calculatePictureSizing to get all picture size
1962 [self calculatePictureSizing: NULL];
1963 /* Run Through encoderPopUpChanged to see if there
1964 needs to be any pic value modifications based on encoder settings */
1965 //[self encoderPopUpChanged: NULL];
1966 /* END Get and set the initial pic size for display */
1968 /* Update subtitle popups */
1969 hb_subtitle_t * subtitle;
1970 [fSubPopUp removeAllItems];
1971 [fSubPopUp addItemWithTitle: @"None"];
1972 [fSubPopUp addItemWithTitle: @"Autoselect"];
1973 for( int i = 0; i < hb_list_count( title->list_subtitle ); i++ )
1975 subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle, i );
1977 /* We cannot use NSPopUpButton's addItemWithTitle because
1978 it checks for duplicate entries */
1979 [[fSubPopUp menu] addItemWithTitle: [NSString stringWithCString:
1980 subtitle->lang] action: NULL keyEquivalent: @""];
1982 [fSubPopUp selectItemAtIndex: 0];
1984 [self subtitleSelectionChanged: NULL];
1986 /* Update chapter table */
1987 [fChapterTitlesDelegate resetWithTitle:title];
1988 [fChapterTable reloadData];
1990 /* Update audio popups */
1991 [self addAllAudioTracksToPopUp: fAudLang1PopUp];
1992 [self addAllAudioTracksToPopUp: fAudLang2PopUp];
1993 /* search for the first instance of our prefs default language for track 1, and set track 2 to "none" */
1994 NSString * audioSearchPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"];
1995 [self selectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1];
1996 [self selectAudioTrackInPopUp: fAudLang2PopUp searchPrefixString: NULL selectIndexIfNotFound: 0];
1998 /* changing the title may have changed the audio channels on offer, */
1999 /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
2000 [self audioTrackPopUpChanged: fAudLang1PopUp];
2001 [self audioTrackPopUpChanged: fAudLang2PopUp];
2002 /* lets call tableViewSelected to make sure that any preset we have selected is enforced after a title change */
2003 [self tableViewSelected:NULL];
2006 - (IBAction) chapterPopUpChanged: (id) sender
2009 /* If start chapter popup is greater than end chapter popup,
2010 we set the end chapter popup to the same as start chapter popup */
2011 if ([fSrcChapterStartPopUp indexOfSelectedItem] > [fSrcChapterEndPopUp indexOfSelectedItem])
2013 [fSrcChapterEndPopUp selectItemAtIndex: [fSrcChapterStartPopUp indexOfSelectedItem]];
2017 hb_list_t * list = hb_get_titles( fHandle );
2018 hb_title_t * title = (hb_title_t *)
2019 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
2021 hb_chapter_t * chapter;
2022 int64_t duration = 0;
2023 for( int i = [fSrcChapterStartPopUp indexOfSelectedItem];
2024 i <= [fSrcChapterEndPopUp indexOfSelectedItem]; i++ )
2026 chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
2027 duration += chapter->duration;
2030 duration /= 90000; /* pts -> seconds */
2031 [fSrcDuration2Field setStringValue: [NSString stringWithFormat:
2032 @"%02lld:%02lld:%02lld", duration / 3600, ( duration / 60 ) % 60,
2035 [self calculateBitrate: sender];
2038 - (IBAction) formatPopUpChanged: (id) sender
2040 NSString * string = [fDstFile2Field stringValue];
2041 int format = [fDstFormatPopUp indexOfSelectedItem];
2043 /* Initially set the large file (64 bit formatting) output checkbox to hidden */
2044 [fDstMpgLargeFileCheck setHidden: YES];
2045 /* Update the codecs popup */
2046 [fDstCodecsPopUp removeAllItems];
2050 /*Get Default MP4 File Extension*/
2051 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
2059 [fDstCodecsPopUp addItemWithTitle:
2060 _( @"MPEG-4 Video / AAC Audio" )];
2061 [fDstCodecsPopUp addItemWithTitle:
2062 _( @"AVC/H.264 Video / AAC Audio" )];
2063 /* We enable the create chapters checkbox here since we are .mp4*/
2064 [fCreateChapterMarkers setEnabled: YES];
2065 /* We show the Large File (64 bit formatting) checkbox since we are .mp4
2066 if we have enabled the option in the global preferences*/
2067 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0)
2069 [fDstMpgLargeFileCheck setHidden: NO];
2073 /* if not enable in global preferences, we additionaly sanity check that the
2074 hidden checkbox is set to off. */
2075 [fDstMpgLargeFileCheck setState: NSOffState];
2080 [fDstCodecsPopUp addItemWithTitle:
2081 _( @"MPEG-4 Video / MP3 Audio" )];
2082 [fDstCodecsPopUp addItemWithTitle:
2083 _( @"MPEG-4 Video / AC-3 Audio" )];
2084 [fDstCodecsPopUp addItemWithTitle:
2085 _( @"AVC/H.264 Video / MP3 Audio" )];
2086 [fDstCodecsPopUp addItemWithTitle:
2087 _( @"AVC/H.264 Video / AC-3 Audio" )];
2088 /* We disable the create chapters checkbox here since we are NOT .mp4
2089 and make sure it is unchecked*/
2090 [fCreateChapterMarkers setEnabled: NO];
2091 [fCreateChapterMarkers setState: NSOffState];
2095 [fDstCodecsPopUp addItemWithTitle:
2096 _( @"MPEG-4 Video / Vorbis Audio" )];
2097 [fDstCodecsPopUp addItemWithTitle:
2098 _( @"MPEG-4 Video / MP3 Audio" )];
2099 /* We disable the create chapters checkbox here since we are NOT .mp4
2100 and make sure it is unchecked*/
2101 [fCreateChapterMarkers setEnabled: NO];
2102 [fCreateChapterMarkers setState: NSOffState];
2106 [fDstCodecsPopUp addItemWithTitle:
2107 _( @"MPEG-4 Video / AAC Audio" )];
2108 [fDstCodecsPopUp addItemWithTitle:
2109 _( @"MPEG-4 Video / AC-3 Audio" )];
2110 [fDstCodecsPopUp addItemWithTitle:
2111 _( @"MPEG-4 Video / MP3 Audio" )];
2112 [fDstCodecsPopUp addItemWithTitle:
2113 _( @"MPEG-4 Video / Vorbis Audio" )];
2115 [fDstCodecsPopUp addItemWithTitle:
2116 _( @"AVC/H.264 Video / AAC Audio" )];
2117 [fDstCodecsPopUp addItemWithTitle:
2118 _( @"AVC/H.264 Video / AC-3 Audio" )];
2119 [fDstCodecsPopUp addItemWithTitle:
2120 _( @"AVC/H.264 Video / MP3 Audio" )];
2121 [fDstCodecsPopUp addItemWithTitle:
2122 _( @"AVC/H.264 Video / Vorbis Audio" )];
2123 /* We enable the create chapters checkbox here since */
2124 [fCreateChapterMarkers setEnabled: YES];
2127 [self codecsPopUpChanged: NULL];
2129 /* Add/replace to the correct extension */
2130 if( [string characterAtIndex: [string length] - 4] == '.' )
2132 [fDstFile2Field setStringValue: [NSString stringWithFormat:
2133 @"%@.%s", [string substringToIndex: [string length] - 4],
2138 [fDstFile2Field setStringValue: [NSString stringWithFormat:
2139 @"%@.%s", string, ext]];
2142 /* changing the format may mean that we can / can't offer mono or 6ch, */
2143 /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
2144 [self audioTrackPopUpChanged: fAudLang1PopUp];
2145 [self audioTrackPopUpChanged: fAudLang2PopUp];
2146 /* We call the method to properly enable/disable turbo 2 pass */
2147 [self twoPassCheckboxChanged: sender];
2148 /* We call method method to change UI to reflect whether a preset is used or not*/
2149 [self customSettingUsed: sender];
2153 - (IBAction) codecsPopUpChanged: (id) sender
2155 int format = [fDstFormatPopUp indexOfSelectedItem];
2156 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2158 [fAdvancedOptions setHidden:YES];
2160 /* Update the encoder popup*/
2161 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
2163 /* MPEG-4 -> H.264 */
2164 [fVidEncoderPopUp removeAllItems];
2165 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 Main)"];
2166 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 iPod)"];
2167 [fVidEncoderPopUp selectItemAtIndex: 0];
2168 [fAdvancedOptions setHidden:NO];
2171 else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) )
2173 /* H.264 -> MPEG-4 */
2174 [fVidEncoderPopUp removeAllItems];
2175 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
2176 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
2177 [fVidEncoderPopUp selectItemAtIndex: 0];
2181 if( FormatSettings[format][codecs] & HB_ACODEC_AC3 )
2183 /* AC-3 pass-through: disable samplerate and bitrate */
2184 [fAudRatePopUp setEnabled: NO];
2185 [fAudBitratePopUp setEnabled: NO];
2189 [fAudRatePopUp setEnabled: YES];
2190 [fAudBitratePopUp setEnabled: YES];
2192 /* changing the codecs on offer may mean that we can / can't offer mono or 6ch, */
2193 /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
2194 [self audioTrackPopUpChanged: fAudLang1PopUp];
2195 [self audioTrackPopUpChanged: fAudLang2PopUp];
2197 [self calculateBitrate: sender];
2198 [self twoPassCheckboxChanged: sender];
2201 - (IBAction) encoderPopUpChanged: (id) sender
2204 /* Check to see if we need to modify the job pic values based on x264 (iPod) encoder selection */
2205 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [fDstCodecsPopUp indexOfSelectedItem] == 1 && [fVidEncoderPopUp indexOfSelectedItem] == 1)
2207 hb_job_t * job = fTitle->job;
2208 job->pixel_ratio = 0 ;
2210 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPicSizeAutoiPod"] > 0)
2213 if (job->width > 640)
2217 job->keep_ratio = 1;
2218 hb_fix_aspect( job, HB_KEEP_WIDTH );
2221 /* Make sure the 64bit formatting checkbox is off */
2222 [fDstMpgLargeFileCheck setState: NSOffState];
2225 [self calculatePictureSizing: sender];
2226 [self twoPassCheckboxChanged: sender];
2229 - (IBAction) twoPassCheckboxChanged: (id) sender
2231 /* check to see if x264 is chosen */
2232 int format = [fDstFormatPopUp indexOfSelectedItem];
2233 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2234 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
2236 if( [fVidTwoPassCheck state] == NSOnState)
2238 [fVidTurboPassCheck setHidden: NO];
2242 [fVidTurboPassCheck setHidden: YES];
2243 [fVidTurboPassCheck setState: NSOffState];
2245 /* Make sure Two Pass is checked if Turbo is checked */
2246 if( [fVidTurboPassCheck state] == NSOnState)
2248 [fVidTwoPassCheck setState: NSOnState];
2253 [fVidTurboPassCheck setHidden: YES];
2254 [fVidTurboPassCheck setState: NSOffState];
2257 /* We call method method to change UI to reflect whether a preset is used or not*/
2258 [self customSettingUsed: sender];
2261 - (IBAction ) videoFrameRateChanged: (id) sender
2263 /* We call method method to calculatePictureSizing to error check detelecine*/
2264 [self calculatePictureSizing: sender];
2266 /* We call method method to change UI to reflect whether a preset is used or not*/
2267 [self customSettingUsed: sender];
2270 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender
2273 /* enable/disable the mixdown text and popupbutton for audio track 1 */
2274 [fAudTrack1MixPopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
2275 [fAudTrack1MixLabel setTextColor: ([fAudLang1PopUp indexOfSelectedItem] == 0) ?
2276 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2278 /* enable/disable the mixdown text and popupbutton for audio track 2 */
2279 [fAudTrack2MixPopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
2280 [fAudTrack2MixLabel setTextColor: ([fAudLang2PopUp indexOfSelectedItem] == 0) ?
2281 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2285 - (IBAction) addAllAudioTracksToPopUp: (id) sender
2288 hb_list_t * list = hb_get_titles( fHandle );
2289 hb_title_t * title = (hb_title_t*)
2290 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
2294 [sender removeAllItems];
2295 [sender addItemWithTitle: _( @"None" )];
2296 for( int i = 0; i < hb_list_count( title->list_audio ); i++ )
2298 audio = (hb_audio_t *) hb_list_item( title->list_audio, i );
2299 [[sender menu] addItemWithTitle:
2300 [NSString stringWithCString: audio->lang]
2301 action: NULL keyEquivalent: @""];
2303 [sender selectItemAtIndex: 0];
2307 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound
2310 /* this method can be used to find a language, or a language-and-source-format combination, by passing in the appropriate string */
2311 /* e.g. to find the first French track, pass in an NSString * of "Francais" */
2312 /* e.g. to find the first English 5.1 AC3 track, pass in an NSString * of "English (AC3) (5.1 ch)" */
2313 /* if no matching track is found, then selectIndexIfNotFound is used to choose which track to select instead */
2315 if (searchPrefixString != NULL)
2318 for( int i = 0; i < [sender numberOfItems]; i++ )
2320 /* Try to find the desired search string */
2321 if ([[[sender itemAtIndex: i] title] hasPrefix:searchPrefixString])
2323 [sender selectItemAtIndex: i];
2327 /* couldn't find the string, so select the requested "search string not found" item */
2328 /* index of 0 means select the "none" item */
2329 /* index of 1 means select the first audio track */
2330 [sender selectItemAtIndex: selectIndexIfNotFound];
2334 /* if no search string is provided, then select the selectIndexIfNotFound item */
2335 [sender selectItemAtIndex: selectIndexIfNotFound];
2340 - (IBAction) audioTrackPopUpChanged: (id) sender
2342 /* utility function to call audioTrackPopUpChanged without passing in a mixdown-to-use */
2343 [self audioTrackPopUpChanged: sender mixdownToUse: 0];
2346 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse
2349 /* make sure we have a selected title before continuing */
2350 if (fTitle == NULL) return;
2352 /* find out if audio track 1 or 2 was changed - this is passed to us in the tag of the sender */
2353 /* the sender will have been either fAudLang1PopUp (tag = 0) or fAudLang2PopUp (tag = 1) */
2354 int thisAudio = [sender tag];
2356 /* get the index of the selected audio */
2357 int thisAudioIndex = [sender indexOfSelectedItem] - 1;
2359 /* Handbrake can't currently cope with ripping the same source track twice */
2360 /* So, if this audio is also selected in the other audio track popup, set that popup's selection to "none" */
2361 /* get a reference to the two audio track popups */
2362 NSPopUpButton * thisAudioPopUp = (thisAudio == 1 ? fAudLang2PopUp : fAudLang1PopUp);
2363 NSPopUpButton * otherAudioPopUp = (thisAudio == 1 ? fAudLang1PopUp : fAudLang2PopUp);
2364 /* if the same track is selected in the other audio popup, then select "none" in that popup */
2365 /* unless, of course, both are selected as "none!" */
2366 if ([thisAudioPopUp indexOfSelectedItem] != 0 && [thisAudioPopUp indexOfSelectedItem] == [otherAudioPopUp indexOfSelectedItem]) {
2367 [otherAudioPopUp selectItemAtIndex: 0];
2368 [self audioTrackPopUpChanged: otherAudioPopUp];
2371 /* pointer for the hb_audio_s struct we will use later on */
2374 /* find out what the currently-selected output audio codec is */
2375 int format = [fDstFormatPopUp indexOfSelectedItem];
2376 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2377 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2379 /* pointer to this track's mixdown NSPopUpButton */
2380 NSTextField * mixdownTextField;
2381 NSPopUpButton * mixdownPopUp;
2383 /* find our mixdown NSTextField and NSPopUpButton */
2386 mixdownTextField = fAudTrack1MixLabel;
2387 mixdownPopUp = fAudTrack1MixPopUp;
2391 mixdownTextField = fAudTrack2MixLabel;
2392 mixdownPopUp = fAudTrack2MixPopUp;
2395 /* delete the previous audio mixdown options */
2396 [mixdownPopUp removeAllItems];
2398 /* check if the audio mixdown controls need their enabled state changing */
2399 [self setEnabledStateOfAudioMixdownControls: NULL];
2401 if (thisAudioIndex != -1)
2405 audio = (hb_audio_t *) hb_list_item( fTitle->list_audio, thisAudioIndex );
2409 /* find out if our selected output audio codec supports mono and / or 6ch */
2410 /* we also check for an input codec of AC3 or DCA,
2411 as they are the only libraries able to do the mixdown to mono / conversion to 6-ch */
2412 /* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
2413 but this may change in the future, so they are separated for flexibility */
2414 int audioCodecsSupportMono = ((audio->codec == HB_ACODEC_AC3 ||
2415 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2416 int audioCodecsSupport6Ch = ((audio->codec == HB_ACODEC_AC3 ||
2417 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2419 /* check for AC-3 passthru */
2420 if (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
2422 [[mixdownPopUp menu] addItemWithTitle:
2423 [NSString stringWithCString: "AC3 Passthru"]
2424 action: NULL keyEquivalent: @""];
2429 /* add the appropriate audio mixdown menuitems to the popupbutton */
2430 /* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
2431 so that we can reference the mixdown later */
2433 /* keep a track of the min and max mixdowns we used, so we can select the best match later */
2434 int minMixdownUsed = 0;
2435 int maxMixdownUsed = 0;
2437 /* get the input channel layout without any lfe channels */
2438 int layout = audio->input_channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
2440 /* do we want to add a mono option? */
2441 if (audioCodecsSupportMono == 1) {
2442 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2443 [NSString stringWithCString: hb_audio_mixdowns[0].human_readable_name]
2444 action: NULL keyEquivalent: @""];
2445 [menuItem setTag: hb_audio_mixdowns[0].amixdown];
2446 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[0].amixdown;
2447 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[0].amixdown);
2450 /* do we want to add a stereo option? */
2451 /* offer stereo if we have a mono source and non-mono-supporting codecs, as otherwise we won't have a mixdown at all */
2452 /* also offer stereo if we have a stereo-or-better source */
2453 if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO) {
2454 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2455 [NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name]
2456 action: NULL keyEquivalent: @""];
2457 [menuItem setTag: hb_audio_mixdowns[1].amixdown];
2458 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[1].amixdown;
2459 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[1].amixdown);
2462 /* do we want to add a dolby surround (DPL1) option? */
2463 if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY) {
2464 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2465 [NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name]
2466 action: NULL keyEquivalent: @""];
2467 [menuItem setTag: hb_audio_mixdowns[2].amixdown];
2468 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[2].amixdown;
2469 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[2].amixdown);
2472 /* do we want to add a dolby pro logic 2 (DPL2) option? */
2473 if (layout == HB_INPUT_CH_LAYOUT_3F2R) {
2474 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2475 [NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name]
2476 action: NULL keyEquivalent: @""];
2477 [menuItem setTag: hb_audio_mixdowns[3].amixdown];
2478 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[3].amixdown;
2479 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[3].amixdown);
2482 /* do we want to add a 6-channel discrete option? */
2483 if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE)) {
2484 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2485 [NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name]
2486 action: NULL keyEquivalent: @""];
2487 [menuItem setTag: hb_audio_mixdowns[4].amixdown];
2488 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[4].amixdown;
2489 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[4].amixdown);
2492 /* auto-select the best mixdown based on our saved mixdown preference */
2494 /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
2495 /* ultimately this should be a prefs option */
2498 /* if we passed in a mixdown to use - in order to load a preset - then try and use it */
2499 if (mixdownToUse > 0)
2501 useMixdown = mixdownToUse;
2505 useMixdown = HB_AMIXDOWN_DOLBYPLII;
2508 /* if useMixdown > maxMixdownUsed, then use maxMixdownUsed */
2509 if (useMixdown > maxMixdownUsed) useMixdown = maxMixdownUsed;
2511 /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
2512 if (useMixdown < minMixdownUsed) useMixdown = minMixdownUsed;
2514 /* select the (possibly-amended) preferred mixdown */
2515 [mixdownPopUp selectItemWithTag: useMixdown];
2517 /* lets call the audioTrackMixdownChanged method here to determine appropriate bitrates, etc. */
2518 [self audioTrackMixdownChanged: NULL];
2525 /* see if the new audio track choice will change the bitrate we need */
2526 [self calculateBitrate: sender];
2529 - (IBAction) audioTrackMixdownChanged: (id) sender
2532 /* find out what the currently-selected output audio codec is */
2533 int format = [fDstFormatPopUp indexOfSelectedItem];
2534 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2535 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2537 /* storage variable for the min and max bitrate allowed for this codec */
2543 case HB_ACODEC_FAAC:
2544 /* check if we have a 6ch discrete conversion in either audio track */
2545 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2547 /* FAAC is happy using our min bitrate of 32 kbps, even for 6ch */
2549 /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
2555 /* FAAC is happy using our min bitrate of 32 kbps for stereo or mono */
2557 /* FAAC won't honour anything more than 160 for stereo, so let's not offer it */
2558 /* note: haven't dealt with mono separately here, FAAC will just use the max it can */
2563 case HB_ACODEC_LAME:
2564 /* Lame is happy using our min bitrate of 32 kbps */
2566 /* Lame won't encode if the bitrate is higher than 320 kbps */
2570 case HB_ACODEC_VORBIS:
2571 /* Vorbis causes a crash if we use a bitrate below 48 kbps */
2573 /* Vorbis can cope with 384 kbps quite happily, even for stereo */
2578 /* AC3 passthru disables the bitrate dropdown anyway, so we might as well just use the min and max bitrate */
2584 [fAudBitratePopUp removeAllItems];
2586 for( int i = 0; i < hb_audio_bitrates_count; i++ )
2588 if (hb_audio_bitrates[i].rate >= minbitrate && hb_audio_bitrates[i].rate <= maxbitrate)
2590 /* add a new menuitem for this bitrate */
2591 id<NSMenuItem> menuItem = [[fAudBitratePopUp menu] addItemWithTitle:
2592 [NSString stringWithCString: hb_audio_bitrates[i].string]
2593 action: NULL keyEquivalent: @""];
2594 /* set its tag to be the actual bitrate as an integer, so we can retrieve it later */
2595 [menuItem setTag: hb_audio_bitrates[i].rate];
2599 /* select the default bitrate (but use 384 for 6-ch AAC) */
2600 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2602 [fAudBitratePopUp selectItemWithTag: 384];
2606 [fAudBitratePopUp selectItemWithTag: hb_audio_bitrates[hb_audio_bitrates_default].rate];
2611 - (IBAction) subtitleSelectionChanged: (id) sender
2613 if ([fSubPopUp indexOfSelectedItem] == 0)
2615 [fSubForcedCheck setState: NSOffState];
2616 [fSubForcedCheck setEnabled: NO];
2620 [fSubForcedCheck setEnabled: YES];
2625 /* lets set the picture size back to the max from right after title scan
2626 Lets use an IBAction here as down the road we could always use a checkbox
2627 in the gui to easily take the user back to max. Remember, the compiler
2628 resolves IBActions down to -(void) during compile anyway */
2629 - (IBAction) revertPictureSizeToMax: (id) sender
2631 hb_job_t * job = fTitle->job;
2632 /* We use the output picture width and height
2633 as calculated from libhb right after title is set
2634 in TitlePopUpChanged */
2635 job->width = PicOrigOutputWidth;
2636 job->height = PicOrigOutputHeight;
2637 [fPictureController setAutoCrop:YES];
2638 /* Here we use the auto crop values determined right after scan */
2639 job->crop[0] = AutoCropTop;
2640 job->crop[1] = AutoCropBottom;
2641 job->crop[2] = AutoCropLeft;
2642 job->crop[3] = AutoCropRight;
2645 [self calculatePictureSizing: sender];
2646 /* We call method method to change UI to reflect whether a preset is used or not*/
2647 [self customSettingUsed: sender];
2651 /* Get and Display Current Pic Settings in main window */
2652 - (IBAction) calculatePictureSizing: (id) sender
2654 [fPicSettingWidth setStringValue: [NSString stringWithFormat:@"%d", fTitle->job->width]];
2655 [fPicSettingHeight setStringValue: [NSString stringWithFormat:@"%d", fTitle->job->height]];
2657 if (fTitle->job->pixel_ratio == 1)
2659 int titlewidth = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
2660 int arpwidth = fTitle->job->pixel_aspect_width;
2661 int arpheight = fTitle->job->pixel_aspect_height;
2662 int displayparwidth = titlewidth * arpwidth / arpheight;
2663 int displayparheight = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
2665 [fPicSettingWidth setStringValue: [NSString stringWithFormat:@"%d", titlewidth]];
2666 [fPicSettingHeight setStringValue: [NSString stringWithFormat:@"%d", displayparheight]];
2667 [fPicLabelPAROutputX setStringValue: @"x"];
2668 [fPicSettingPARWidth setStringValue: [NSString stringWithFormat:@"%d", displayparwidth]];
2669 [fPicSettingPARHeight setStringValue: [NSString stringWithFormat:@"%d", displayparheight]];
2671 fTitle->job->keep_ratio = 0;
2675 [fPicLabelPAROutputX setStringValue: @""];
2676 [fPicSettingPARWidth setStringValue: @""];
2677 [fPicSettingPARHeight setStringValue: @""];
2680 /* Set ON/Off values for the deinterlace/keep aspect ratio according to boolean */
2681 if (fTitle->job->keep_ratio > 0)
2683 [fPicSettingARkeep setStringValue: @"On"];
2687 [fPicSettingARkeep setStringValue: @"Off"];
2690 if ([fPictureController detelecine]) {
2691 [fPicSettingDetelecine setStringValue: @"Yes"];
2694 [fPicSettingDetelecine setStringValue: @"No"];
2698 if ([fPictureController deinterlace] == 0)
2700 [fPicSettingDeinterlace setStringValue: @"Off"];
2702 else if ([fPictureController deinterlace] == 1)
2704 [fPicSettingDeinterlace setStringValue: @"Fast"];
2706 else if ([fPictureController deinterlace] == 2)
2708 [fPicSettingDeinterlace setStringValue: @"Slow"];
2710 else if ([fPictureController deinterlace] == 3)
2712 [fPicSettingDeinterlace setStringValue: @"Slower"];
2714 else if ([fPictureController deinterlace] ==4)
2716 [fPicSettingDeinterlace setStringValue: @"Slowest"];
2719 if ([fPictureController denoise] == 0)
2721 [fPicSettingDenoise setStringValue: @"Off"];
2723 else if ([fPictureController denoise] == 1)
2725 [fPicSettingDenoise setStringValue: @"Weak"];
2727 else if ([fPictureController denoise] == 2)
2729 [fPicSettingDenoise setStringValue: @"Medium"];
2731 else if ([fPictureController denoise] == 3)
2733 [fPicSettingDenoise setStringValue: @"Strong"];
2736 if (fTitle->job->pixel_ratio > 0)
2738 [fPicSettingPAR setStringValue: @""];
2742 [fPicSettingPAR setStringValue: @"Off"];
2744 /* Set the display field for crop as per boolean */
2745 if (![fPictureController autoCrop])
2747 [fPicSettingAutoCrop setStringValue: @"Custom"];
2751 [fPicSettingAutoCrop setStringValue: @"Auto"];
2753 /* check video framerate and turn off detelecine if necessary */
2754 if (fTitle->rate_base == 1126125 || [[fVidRatePopUp titleOfSelectedItem] isEqualToString: @"23.976 (NTSC Film)"])
2756 [fPictureController setDetelecine:0];
2761 /* below will trigger the preset, if selected, to be
2762 changed to "Custom". Lets comment out for now until
2763 we figure out a way to determine if the picture values
2764 changed modify the preset values */
2765 //[self customSettingUsed: sender];
2768 - (IBAction) calculateBitrate: (id) sender
2770 if( !fHandle || [fVidQualityMatrix selectedRow] != 0 || !SuccessfulScan )
2775 hb_list_t * list = hb_get_titles( fHandle );
2776 hb_title_t * title = (hb_title_t *) hb_list_item( list,
2777 [fSrcTitlePopUp indexOfSelectedItem] );
2778 hb_job_t * job = title->job;
2782 [fVidBitrateField setIntValue: hb_calc_bitrate( job,
2783 [fVidTargetSizeField intValue] )];
2786 /* Method to determine if we should change the UI
2787 To reflect whether or not a Preset is being used or if
2788 the user is using "Custom" settings by determining the sender*/
2789 - (IBAction) customSettingUsed: (id) sender
2791 if ([sender stringValue] != NULL)
2793 /* Deselect the currently selected Preset if there is one*/
2794 [tableView deselectRow:[tableView selectedRow]];
2795 [[fPresetsActionMenu itemAtIndex:0] setEnabled: NO];
2796 /* Change UI to show "Custom" settings are being used */
2797 [fPresetSelectedDisplay setStringValue: @"Custom"];
2799 curUserPresetChosenNum = nil;
2804 /* We use this method to recreate new, updated factory
2806 - (IBAction)addFactoryPresets:(id)sender
2808 /* First, we delete any existing built in presets */
2809 [self deleteFactoryPresets: sender];
2810 /* Then, we re-create new built in presets programmatically CreateIpodOnlyPreset*/
2811 [UserPresets addObject:[self createNormalPreset]];
2812 [UserPresets addObject:[self createClassicPreset]];
2813 [UserPresets addObject:[self createQuickTimePreset]];
2814 [UserPresets addObject:[self createIpodLowPreset]];
2815 [UserPresets addObject:[self createIpodHighPreset]];
2816 [UserPresets addObject:[self createAppleTVPreset]];
2817 [UserPresets addObject:[self createiPhonePreset]];
2818 [UserPresets addObject:[self createPSThreePreset]];
2819 [UserPresets addObject:[self createPSPPreset]];
2820 [UserPresets addObject:[self createFilmPreset]];
2821 [UserPresets addObject:[self createTelevisionPreset]];
2822 [UserPresets addObject:[self createAnimationPreset]];
2823 [UserPresets addObject:[self createBedlamPreset]];
2824 [UserPresets addObject:[self createDeuxSixQuatrePreset]];
2825 [UserPresets addObject:[self createBrokePreset]];
2826 [UserPresets addObject:[self createBlindPreset]];
2827 [UserPresets addObject:[self createCRFPreset]];
2831 - (IBAction)deleteFactoryPresets:(id)sender
2834 NSEnumerator *enumerator = [UserPresets objectEnumerator];
2838 NSMutableArray *tempArray;
2841 tempArray = [NSMutableArray array];
2842 /* we look here to see if the preset is we move on to the next one */
2843 while ( tempObject = [enumerator nextObject] )
2845 /* if the preset is "Factory" then we put it in the array of
2846 presets to delete */
2847 if ([[tempObject objectForKey:@"Type"] intValue] == 0)
2849 [tempArray addObject:tempObject];
2853 [UserPresets removeObjectsInArray:tempArray];
2854 [tableView reloadData];
2859 - (IBAction) showAddPresetPanel: (id) sender
2861 /* Deselect the currently selected Preset if there is one*/
2862 [tableView deselectRow:[tableView selectedRow]];
2864 /* Populate the preset picture settings popup here */
2865 [fPresetNewPicSettingsPopUp removeAllItems];
2866 [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
2867 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
2868 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
2869 [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];
2871 /* Erase info from the input fields fPresetNewDesc*/
2872 [fPresetNewName setStringValue: @""];
2873 [fPresetNewDesc setStringValue: @""];
2874 /* Show the panel */
2875 [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
2878 - (IBAction) closeAddPresetPanel: (id) sender
2880 [NSApp endSheet: fAddPresetPanel];
2881 [fAddPresetPanel orderOut: self];
2884 - (IBAction)addUserPreset:(id)sender
2886 if (![[fPresetNewName stringValue] length])
2887 NSRunAlertPanel(@"Warning!", @"You need to insert a name for the preset.", @"OK", nil , nil);
2890 /* Here we create a custom user preset */
2891 [UserPresets addObject:[self createPreset]];
2894 [self closeAddPresetPanel:NULL];
2901 /* We Sort the Presets By Factory or Custom */
2902 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
2903 ascending:YES] autorelease];
2904 /* We Sort the Presets Alphabetically by name */
2905 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
2906 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
2907 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
2908 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
2909 [UserPresets setArray:sortedArray];
2912 /* We Reload the New Table data for presets */
2913 [tableView reloadData];
2914 /* We save all of the preset data here */
2918 - (IBAction)insertPreset:(id)sender
2920 int index = [tableView selectedRow];
2921 [UserPresets insertObject:[self createPreset] atIndex:index];
2922 [tableView reloadData];
2926 - (NSDictionary *)createPreset
2928 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
2929 /* Get the New Preset Name from the field in the AddPresetPanel */
2930 [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
2931 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
2932 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
2933 /*Set whether or not this is default, at creation set to 0*/
2934 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
2935 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
2936 [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
2937 /* Get New Preset Description from the field in the AddPresetPanel*/
2938 [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
2940 [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
2941 /* Chapter Markers fCreateChapterMarkers*/
2942 [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
2943 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
2944 [preset setObject:[NSNumber numberWithInt:[fDstMpgLargeFileCheck state]] forKey:@"Mp4LargeFile"];
2946 [preset setObject:[fDstCodecsPopUp titleOfSelectedItem] forKey:@"FileCodecs"];
2948 [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
2949 /* x264 Option String */
2950 [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
2952 [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
2953 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
2954 [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
2955 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
2957 /* Video framerate */
2958 [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
2960 [preset setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
2961 /* 2 Pass Encoding */
2962 [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
2963 /* Turbo 2 pass Encoding fVidTurboPassCheck*/
2964 [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
2965 /*Picture Settings*/
2966 hb_job_t * job = fTitle->job;
2967 /* Basic Picture Settings */
2968 /* Use Max Picture settings for whatever the dvd is.*/
2969 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
2970 [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
2971 [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
2972 [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
2973 [preset setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
2974 [preset setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
2975 [preset setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
2976 [preset setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
2977 /* Set crop settings here */
2978 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
2979 [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
2981 [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
2982 [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
2983 [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
2984 [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
2987 /* Audio Sample Rate*/
2988 [preset setObject:[fAudRatePopUp titleOfSelectedItem] forKey:@"AudioSampleRate"];
2989 /* Audio Bitrate Rate*/
2990 [preset setObject:[fAudBitratePopUp titleOfSelectedItem] forKey:@"AudioBitRate"];
2992 [preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
2995 [preset autorelease];
3000 - (NSDictionary *)createIpodLowPreset
3002 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3003 /* Get the New Preset Name from the field in the AddPresetPanel */
3004 [preset setObject:@"iPod Low-Rez" forKey:@"PresetName"];
3005 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3006 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3007 /*Set whether or not this is default, at creation set to 0*/
3008 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3009 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3010 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3011 /* Get the New Preset Description from the field in the AddPresetPanel */
3012 [preset setObject:@"HandBrake's low resolution settings for the iPod. Optimized for great playback on the iPod screen, with smaller file size." forKey:@"PresetDescription"];
3014 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3015 /* Chapter Markers*/
3016 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3018 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3020 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3021 /* x264 Option String */
3022 [preset setObject:@"keyint=300:keyint-min=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1" forKey:@"x264Option"];
3024 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3025 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3026 [preset setObject:@"700" forKey:@"VideoAvgBitrate"];
3027 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3029 /* Video framerate */
3030 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3032 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3033 /* 2 Pass Encoding */
3034 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3036 /*Picture Settings*/
3037 //hb_job_t * job = fTitle->job;
3038 /* Basic Picture Settings */
3039 /* Use Max Picture settings for whatever the dvd is.*/
3040 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3041 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3042 [preset setObject:[NSNumber numberWithInt:320] forKey:@"PictureWidth"];
3043 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3044 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3045 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3046 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3047 /* Set crop settings here */
3048 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3049 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3050 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3051 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3052 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3055 /* Audio Sample Rate*/
3056 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3057 /* Audio Bitrate Rate*/
3058 [preset setObject:@"160" forKey:@"AudioBitRate"];
3060 [preset setObject:@"None" forKey:@"Subtitles"];
3063 [preset autorelease];
3069 - (NSDictionary *)createIpodHighPreset
3071 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3072 /* Get the New Preset Name from the field in the AddPresetPanel */
3073 [preset setObject:@"iPod High-Rez" forKey:@"PresetName"];
3074 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3075 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3076 /*Set whether or not this is default, at creation set to 0*/
3077 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3078 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3079 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3080 /* Get the New Preset Description from the field in the AddPresetPanel */
3081 [preset setObject:@"HandBrake's high resolution settings for the iPod. Good video quality, great for viewing on a TV using your iPod" forKey:@"PresetDescription"];
3083 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3084 /* Chapter Markers*/
3085 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3087 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3089 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3090 /* x264 Option String */
3091 [preset setObject:@"keyint=300:keyint-min=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1" forKey:@"x264Option"];
3093 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3094 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3095 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
3096 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3098 /* Video framerate */
3099 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3101 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3102 /* 2 Pass Encoding */
3103 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3105 /*Picture Settings*/
3106 //hb_job_t * job = fTitle->job;
3107 /* Basic Picture Settings */
3108 /* Use Max Picture settings for whatever the dvd is.*/
3109 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3110 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
3111 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3112 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3113 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3114 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3115 /* Set crop settings here */
3116 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3117 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3118 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3119 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3120 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3121 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3124 /* Audio Sample Rate*/
3125 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3126 /* Audio Bitrate Rate*/
3127 [preset setObject:@"160" forKey:@"AudioBitRate"];
3129 [preset setObject:@"None" forKey:@"Subtitles"];
3132 [preset autorelease];
3137 - (NSDictionary *)createAppleTVPreset
3139 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3140 /* Get the New Preset Name from the field in the AddPresetPanel */
3141 [preset setObject:@"AppleTV" forKey:@"PresetName"];
3142 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3143 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3144 /*Set whether or not this is default, at creation set to 0*/
3145 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3146 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3147 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3148 /* Get the New Preset Description from the field in the AddPresetPanel */
3149 [preset setObject:@"HandBrake's settings for the AppleTV. Provides a good balance between quality and file size, and optimizes performance." forKey:@"PresetDescription"];
3151 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3152 /* Chapter Markers*/
3153 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3155 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3157 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3158 /* x264 Option String (We can use this to tweak the appleTV output)*/
3159 [preset setObject:@"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2:cabac=0" forKey:@"x264Option"];
3161 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3162 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3163 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3164 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3166 /* Video framerate */
3167 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3169 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3170 /* 2 Pass Encoding */
3171 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3173 /*Picture Settings*/
3174 /* For AppleTV we only want to retain UsesMaxPictureSettings
3175 which depend on the source dvd picture settings, so we don't
3176 record the current dvd's picture info since it will vary from
3178 //hb_job_t * job = fTitle->job;
3179 //hb_job_t * job = title->job;
3180 /* Basic Picture Settings */
3181 /* Use Max Picture settings for whatever the dvd is.*/
3182 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3183 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3184 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3185 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3186 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3187 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3188 /* Set crop settings here */
3189 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3190 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3191 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3192 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3193 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3196 /* Audio Sample Rate*/
3197 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3198 /* Audio Bitrate Rate*/
3199 [preset setObject:@"160" forKey:@"AudioBitRate"];
3201 [preset setObject:@"None" forKey:@"Subtitles"];
3204 [preset autorelease];
3209 - (NSDictionary *)createPSThreePreset
3211 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3212 /* Get the New Preset Name from the field in the AddPresetPanel */
3213 [preset setObject:@"PS3" forKey:@"PresetName"];
3214 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3215 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3216 /*Set whether or not this is default, at creation set to 0*/
3217 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3218 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3219 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3220 /* Get the New Preset Description from the field in the AddPresetPanel */
3221 [preset setObject:@"HandBrake's settings for the Sony PlayStation 3." forKey:@"PresetDescription"];
3223 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3224 /* Chapter Markers*/
3225 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3227 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3229 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3230 /* x264 Option String (We can use this to tweak the appleTV output)*/
3231 [preset setObject:@"level=41:subme=5:me=umh" forKey:@"x264Option"];
3233 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3234 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3235 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3236 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3238 /* Video framerate */
3239 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3241 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3242 /* 2 Pass Encoding */
3243 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3245 /*Picture Settings*/
3246 /* For PS3 we only want to retain UsesMaxPictureSettings
3247 which depend on the source dvd picture settings, so we don't
3248 record the current dvd's picture info since it will vary from
3250 /* Use Max Picture settings for whatever the dvd is.*/
3251 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3252 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3253 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3254 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3255 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3256 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3257 /* Set crop settings here */
3258 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3259 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3260 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3261 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3262 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3265 /* Audio Sample Rate*/
3266 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3267 /* Audio Bitrate Rate*/
3268 [preset setObject:@"160" forKey:@"AudioBitRate"];
3270 [preset setObject:@"None" forKey:@"Subtitles"];
3273 [preset autorelease];
3277 - (NSDictionary *)createPSPPreset
3279 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3280 /* Get the New Preset Name from the field in the AddPresetPanel */
3281 [preset setObject:@"PSP" forKey:@"PresetName"];
3282 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3283 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3284 /*Set whether or not this is default, at creation set to 0*/
3285 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3286 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3287 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3288 /* Get the New Preset Description from the field in the AddPresetPanel */
3289 [preset setObject:@"HandBrake's settings for the Sony PlayStation Portable." forKey:@"PresetDescription"];
3291 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3292 /* Chapter Markers*/
3293 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3295 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
3297 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
3298 /* x264 Option String (We can use this to tweak the appleTV output)*/
3299 [preset setObject:@"" forKey:@"x264Option"];
3301 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3302 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3303 [preset setObject:@"1024" forKey:@"VideoAvgBitrate"];
3304 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3306 /* Video framerate */
3307 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3309 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3310 /* 2 Pass Encoding */
3311 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3313 /*Picture Settings*/
3314 /* For PS3 we only want to retain UsesMaxPictureSettings
3315 which depend on the source dvd picture settings, so we don't
3316 record the current dvd's picture info since it will vary from
3318 /* Use Max Picture settings for whatever the dvd is.*/
3319 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3320 [preset setObject:@"368" forKey:@"PictureWidth"];
3321 [preset setObject:@"208" forKey:@"PictureHeight"];
3322 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3323 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3324 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3325 /* Set crop settings here */
3326 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3327 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3328 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3329 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3330 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3331 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3334 /* Audio Sample Rate*/
3335 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3336 /* Audio Bitrate Rate*/
3337 [preset setObject:@"128" forKey:@"AudioBitRate"];
3339 [preset setObject:@"None" forKey:@"Subtitles"];
3342 [preset autorelease];
3347 - (NSDictionary *)createNormalPreset
3349 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3350 /* Get the New Preset Name from the field in the AddPresetPanel */
3351 [preset setObject:@"Normal" forKey:@"PresetName"];
3352 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3353 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3354 /*Set whether or not this is default, at creation set to 0*/
3355 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"];
3356 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3357 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3358 /* Get the New Preset Description from the field in the AddPresetPanel */
3359 [preset setObject:@"HandBrake's normal, default settings." forKey:@"PresetDescription"];
3361 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3362 /* Chapter Markers*/
3363 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3365 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3367 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3368 /* x264 Option String */
3369 [preset setObject:@"ref=2:bframes=2:subme=5:me=umh" forKey:@"x264Option"];
3371 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3372 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3373 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
3374 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3376 /* Video framerate */
3377 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3379 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3380 /* 2 Pass Encoding */
3381 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3382 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3384 /*Picture Settings*/
3385 //hb_job_t * job = fTitle->job;
3386 /* Basic Picture Settings */
3387 /* Use Max Picture settings for whatever the dvd is.*/
3388 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3389 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3390 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3391 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3392 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3393 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3394 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3395 /* Set crop settings here */
3396 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3397 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3398 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3399 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3400 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3403 /* Audio Sample Rate*/
3404 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3405 /* Audio Bitrate Rate*/
3406 [preset setObject:@"160" forKey:@"AudioBitRate"];
3408 [preset setObject:@"None" forKey:@"Subtitles"];
3411 [preset autorelease];
3416 - (NSDictionary *)createClassicPreset
3418 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3419 /* Get the New Preset Name from the field in the AddPresetPanel */
3420 [preset setObject:@"Classic" forKey:@"PresetName"];
3421 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3422 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3423 /*Set whether or not this is default, at creation set to 0*/
3424 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3425 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3426 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3427 /* Get the New Preset Description from the field in the AddPresetPanel */
3428 [preset setObject:@"HandBrake's traditional, faster, lower-quality settings." forKey:@"PresetDescription"];
3430 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3431 /* Chapter Markers*/
3432 [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
3434 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
3436 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
3437 /* x264 Option String */
3438 [preset setObject:@"" forKey:@"x264Option"];
3440 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3441 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3442 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
3443 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3445 /* Video framerate */
3446 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3448 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3449 /* 2 Pass Encoding */
3450 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3452 /*Picture Settings*/
3453 //hb_job_t * job = fTitle->job;
3454 /* Basic Picture Settings */
3455 /* Use Max Picture settings for whatever the dvd is.*/
3456 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3457 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3458 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3459 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3460 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3461 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3462 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3463 /* Set crop settings here */
3464 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3465 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3466 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3467 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3468 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3471 /* Audio Sample Rate*/
3472 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3473 /* Audio Bitrate Rate*/
3474 [preset setObject:@"160" forKey:@"AudioBitRate"];
3476 [preset setObject:@"None" forKey:@"Subtitles"];
3479 [preset autorelease];
3484 - (NSDictionary *)createFilmPreset
3486 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3487 /* Get the New Preset Name from the field in the AddPresetPanel */
3488 [preset setObject:@"Film" forKey:@"PresetName"];
3489 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3490 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3491 /*Set whether or not this is default, at creation set to 0*/
3492 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3493 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3494 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3495 /* Get the New Preset Description from the field in the AddPresetPanel */
3496 [preset setObject:@"HandBrake's preset for feature films." forKey:@"PresetDescription"];
3498 [preset setObject:@"MKV file" forKey:@"FileFormat"];
3499 /* Chapter Markers*/
3500 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3502 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
3504 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3505 /* x264 Option String */
3506 [preset setObject:@"ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:no-fast-pskip" forKey:@"x264Option"];
3508 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3509 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3510 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
3511 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3513 /* Video framerate */
3514 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3516 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3517 /* 2 Pass Encoding */
3518 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3519 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3521 /*Picture Settings*/
3522 //hb_job_t * job = fTitle->job;
3523 /* Basic Picture Settings */
3524 /* Use Max Picture settings for whatever the dvd is.*/
3525 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3526 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3527 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3528 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3529 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3530 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3531 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3532 /* Set crop settings here */
3533 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3534 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3535 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3536 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3537 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3540 /* Audio Sample Rate*/
3541 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3542 /* Audio Bitrate Rate*/
3543 [preset setObject:@"160" forKey:@"AudioBitRate"];
3545 [preset setObject:@"None" forKey:@"Subtitles"];
3548 [preset autorelease];
3553 - (NSDictionary *)createTelevisionPreset
3555 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3556 /* Get the New Preset Name from the field in the AddPresetPanel */
3557 [preset setObject:@"Television" forKey:@"PresetName"];
3558 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3559 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3560 /*Set whether or not this is default, at creation set to 0*/
3561 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3562 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3563 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3564 /* Get the New Preset Description from the field in the AddPresetPanel */
3565 [preset setObject:@"HandBrake's settings for video from television." forKey:@"PresetDescription"];
3567 [preset setObject:@"MKV file" forKey:@"FileFormat"];
3568 /* Chapter Markers*/
3569 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3571 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3573 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3574 /* x264 Option String */
3575 [preset setObject:@"ref=3:mixed-refs:bframes=6:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip" forKey:@"x264Option"];
3577 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3578 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3579 [preset setObject:@"1300" forKey:@"VideoAvgBitrate"];
3580 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3582 /* Video framerate */
3583 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3585 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3586 /* 2 Pass Encoding */
3587 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3588 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3590 /*Picture Settings*/
3591 //hb_job_t * job = fTitle->job;
3592 /* Basic Picture Settings */
3593 /* Use Max Picture settings for whatever the dvd is.*/
3594 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3595 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3596 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3597 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3598 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3599 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
3600 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3601 /* Set crop settings here */
3602 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3603 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3604 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3605 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3606 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3609 /* Audio Sample Rate*/
3610 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3611 /* Audio Bitrate Rate*/
3612 [preset setObject:@"160" forKey:@"AudioBitRate"];
3614 [preset setObject:@"None" forKey:@"Subtitles"];
3617 [preset autorelease];
3622 - (NSDictionary *)createAnimationPreset
3624 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3625 /* Get the New Preset Name from the field in the AddPresetPanel */
3626 [preset setObject:@"Animation" forKey:@"PresetName"];
3627 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3628 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3629 /*Set whether or not this is default, at creation set to 0*/
3630 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3631 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3632 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3633 /* Get the New Preset Description from the field in the AddPresetPanel */
3634 [preset setObject:@"HandBrake's settings for cartoons, anime, and CGI." forKey:@"PresetDescription"];
3636 [preset setObject:@"MKV file" forKey:@"FileFormat"];
3637 /* Chapter Markers*/
3638 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3640 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3642 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3643 /* x264 Option String */
3644 [preset setObject:@"ref=5:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2" forKey:@"x264Option"];
3646 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3647 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3648 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
3649 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3651 /* Video framerate */
3652 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3654 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3655 /* 2 Pass Encoding */
3656 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3657 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3659 /*Picture Settings*/
3660 //hb_job_t * job = fTitle->job;
3661 /* Basic Picture Settings */
3662 /* Use Max Picture settings for whatever the dvd is.*/
3663 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3664 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3665 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3666 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3667 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3668 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
3669 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3670 /* Set crop settings here */
3671 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3672 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3673 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3674 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3675 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3678 /* Audio Sample Rate*/
3679 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3680 /* Audio Bitrate Rate*/
3681 [preset setObject:@"160" forKey:@"AudioBitRate"];
3683 [preset setObject:@"None" forKey:@"Subtitles"];
3686 [preset autorelease];
3691 - (NSDictionary *)createQuickTimePreset
3693 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3694 /* Get the New Preset Name from the field in the AddPresetPanel */
3695 [preset setObject:@"QuickTime" forKey:@"PresetName"];
3696 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3697 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3698 /*Set whether or not this is default, at creation set to 0*/
3699 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3700 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3701 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3702 /* Get the New Preset Description from the field in the AddPresetPanel */
3703 [preset setObject:@"HandBrake's high quality settings for use with QuickTime. It can be slow, so use it when the Normal preset doesn't look good enough." forKey:@"PresetDescription"];
3705 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3706 /* Chapter Markers*/
3707 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3709 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3711 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3712 /* x264 Option String */
3713 [preset setObject:@"ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:me=umh:subme=5:analyse=all:8x8dct:trellis=1:no-fast-pskip" forKey:@"x264Option"];
3715 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3716 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3717 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
3718 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3720 /* Video framerate */
3721 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3723 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3724 /* 2 Pass Encoding */
3725 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3726 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3728 /*Picture Settings*/
3729 //hb_job_t * job = fTitle->job;
3730 /* Basic Picture Settings */
3731 /* Use Max Picture settings for whatever the dvd is.*/
3732 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3733 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3734 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3735 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3736 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3737 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3738 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3739 /* Set crop settings here */
3740 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3741 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3742 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3743 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3744 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3747 /* Audio Sample Rate*/
3748 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3749 /* Audio Bitrate Rate*/
3750 [preset setObject:@"160" forKey:@"AudioBitRate"];
3752 [preset setObject:@"None" forKey:@"Subtitles"];
3755 [preset autorelease];
3760 - (NSDictionary *)createBedlamPreset
3762 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3763 /* Get the New Preset Name from the field in the AddPresetPanel */
3764 [preset setObject:@"Bedlam" forKey:@"PresetName"];
3765 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3766 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3767 /*Set whether or not this is default, at creation set to 0*/
3768 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3769 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3770 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3771 /* Get the New Preset Description from the field in the AddPresetPanel */
3772 [preset setObject:@"HandBrake's settings maxed out for slowest encoding and highest quality. Use at your own risk. So slow it's not just insane...it's a trip to the looney bin." forKey:@"PresetDescription"];
3774 [preset setObject:@"MKV file" forKey:@"FileFormat"];
3775 /* Chapter Markers*/
3776 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3778 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
3780 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3781 /* x264 Option String */
3782 [preset setObject:@"ref=16:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:me-range=64:analyse=all:8x8dct:trellis=2:no-fast-pskip:no-dct-decimate:filter=-2,-1" forKey:@"x264Option"];
3784 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3785 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3786 [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
3787 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3789 /* Video framerate */
3790 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3792 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3793 /* 2 Pass Encoding */
3794 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3795 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3797 /*Picture Settings*/
3798 //hb_job_t * job = fTitle->job;
3799 /* Basic Picture Settings */
3800 /* Use Max Picture settings for whatever the dvd is.*/
3801 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3802 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3803 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3804 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3805 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3806 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3807 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3808 /* Set crop settings here */
3809 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3810 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3811 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3812 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3813 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3816 /* Audio Sample Rate*/
3817 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3818 /* Audio Bitrate Rate*/
3819 [preset setObject:@"160" forKey:@"AudioBitRate"];
3821 [preset setObject:@"None" forKey:@"Subtitles"];
3824 [preset autorelease];
3829 - (NSDictionary *)createiPhonePreset
3831 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3832 /* Get the New Preset Name from the field in the AddPresetPanel */
3833 [preset setObject:@"iPhone" forKey:@"PresetName"];
3834 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3835 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3836 /*Set whether or not this is default, at creation set to 0*/
3837 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3838 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3839 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3840 /* Get the New Preset Description from the field in the AddPresetPanel */
3841 [preset setObject:@"HandBrake's settings for the iPhone." forKey:@"PresetDescription"];
3843 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3844 /* Chapter Markers*/
3845 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3847 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3849 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3850 /* x264 Option String */
3851 [preset setObject:@"cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1" forKey:@"x264Option"];
3853 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3854 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3855 [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
3856 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3858 /* Video framerate */
3859 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3861 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3862 /* 2 Pass Encoding */
3863 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3865 /*Picture Settings*/
3866 //hb_job_t * job = fTitle->job;
3867 /* Basic Picture Settings */
3868 /* Use Max Picture settings for whatever the dvd is.*/
3869 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3870 [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
3871 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3872 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3873 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3874 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3875 /* Set crop settings here */
3876 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3877 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3878 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3879 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3880 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3881 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3884 /* Audio Sample Rate*/
3885 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3886 /* Audio Bitrate Rate*/
3887 [preset setObject:@"128" forKey:@"AudioBitRate"];
3889 [preset setObject:@"None" forKey:@"Subtitles"];
3892 [preset autorelease];
3897 - (NSDictionary *)createDeuxSixQuatrePreset
3899 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3900 /* Get the New Preset Name from the field in the AddPresetPanel */
3901 [preset setObject:@"Deux Six Quatre" forKey:@"PresetName"];
3902 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3903 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3904 /*Set whether or not this is default, at creation set to 0*/
3905 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3906 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3907 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3908 /* Get the New Preset Description from the field in the AddPresetPanel */
3909 [preset setObject:@"HandBrake's preset for true high profile x264 quality. A good balance of quality and speed, based on community standards found in the wild. This preset will give you a much better sense of x264's capabilities than vanilla main profile." forKey:@"PresetDescription"];
3911 [preset setObject:@"MKV file" forKey:@"FileFormat"];
3912 /* Chapter Markers*/
3913 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3915 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
3917 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3918 /* x264 Option String */
3919 [preset setObject:@"ref=5:mixed-refs:bframes=3:bime:weightb:b-rdo:b-pyramid:me=umh:subme=7:trellis=1:analyse=all:8x8dct:no-fast-pskip" forKey:@"x264Option"];
3921 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3922 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3923 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
3924 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3926 /* Video framerate */
3927 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3929 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3930 /* 2 Pass Encoding */
3931 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
3932 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
3934 /*Picture Settings*/
3935 //hb_job_t * job = fTitle->job;
3936 /* Basic Picture Settings */
3937 /* Use Max Picture settings for whatever the dvd is.*/
3938 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3939 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3940 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3941 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3942 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3943 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3944 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3945 /* Set crop settings here */
3946 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3947 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3948 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3949 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3950 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3953 /* Audio Sample Rate*/
3954 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3955 /* Audio Bitrate Rate*/
3956 [preset setObject:@"160" forKey:@"AudioBitRate"];
3958 [preset setObject:@"None" forKey:@"Subtitles"];
3961 [preset autorelease];
3966 - (NSDictionary *)createBrokePreset
3968 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3969 /* Get the New Preset Name from the field in the AddPresetPanel */
3970 [preset setObject:@"Broke" forKey:@"PresetName"];
3971 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3972 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3973 /*Set whether or not this is default, at creation set to 0*/
3974 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3975 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3976 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3977 /* Get the New Preset Description from the field in the AddPresetPanel */
3978 [preset setObject:@"HandBrake's preset for people without a lot of money to waste on hard drives. Tries to maximize quality for burning to CDs, so you can party like it's 1999." forKey:@"PresetDescription"];
3980 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3981 /* Chapter Markers*/
3982 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3984 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3986 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3987 /* x264 Option String */
3988 [preset setObject:@"ref=3:mixed-refs:bframes=6:bime:weightb:b-rdo:b-pyramid:direct=auto:me=umh:subme=6:trellis=1:analyse=all:8x8dct:no-fast-pskip" forKey:@"x264Option"];
3990 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoQualityType"];
3991 [preset setObject:@"695" forKey:@"VideoTargetSize"];
3992 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
3993 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3995 /* Video framerate */
3996 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3998 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3999 /* 2 Pass Encoding */
4000 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4001 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4003 /*Picture Settings*/
4004 //hb_job_t * job = fTitle->job;
4005 /* Basic Picture Settings */
4006 /* Use Max Picture settings for whatever the dvd is.*/
4007 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4008 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4009 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
4010 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4011 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4012 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4013 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4014 /* Set crop settings here */
4015 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4016 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4017 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4018 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4019 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4022 /* Audio Sample Rate*/
4023 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4024 /* Audio Bitrate Rate*/
4025 [preset setObject:@"128" forKey:@"AudioBitRate"];
4027 [preset setObject:@"None" forKey:@"Subtitles"];
4030 [preset autorelease];
4035 - (NSDictionary *)createBlindPreset
4037 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4038 /* Get the New Preset Name from the field in the AddPresetPanel */
4039 [preset setObject:@"Blind" forKey:@"PresetName"];
4040 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4041 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4042 /*Set whether or not this is default, at creation set to 0*/
4043 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4044 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4045 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4046 /* Get the New Preset Description from the field in the AddPresetPanel */
4047 [preset setObject:@"HandBrake's preset for impatient people who don't care about picture quality." forKey:@"PresetDescription"];
4049 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4050 /* Chapter Markers*/
4051 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4053 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4055 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4056 /* x264 Option String */
4057 [preset setObject:@"" forKey:@"x264Option"];
4059 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4060 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4061 [preset setObject:@"512" forKey:@"VideoAvgBitrate"];
4062 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4064 /* Video framerate */
4065 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4067 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4068 /* 2 Pass Encoding */
4069 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4070 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4072 /*Picture Settings*/
4073 //hb_job_t * job = fTitle->job;
4074 /* Basic Picture Settings */
4075 /* Use Max Picture settings for whatever the dvd is.*/
4076 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4077 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4078 [preset setObject:[NSNumber numberWithInt:512] forKey:@"PictureWidth"];
4079 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4080 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4081 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4082 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4083 /* Set crop settings here */
4084 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4085 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4086 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4087 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4088 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4091 /* Audio Sample Rate*/
4092 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4093 /* Audio Bitrate Rate*/
4094 [preset setObject:@"128" forKey:@"AudioBitRate"];
4096 [preset setObject:@"None" forKey:@"Subtitles"];
4099 [preset autorelease];
4104 - (NSDictionary *)createCRFPreset
4106 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4107 /* Get the New Preset Name from the field in the AddPresetPanel */
4108 [preset setObject:@"Constant Quality Rate" forKey:@"PresetName"];
4109 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4110 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4111 /*Set whether or not this is default, at creation set to 0*/
4112 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4113 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4114 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4115 /* Get the New Preset Description from the field in the AddPresetPanel */
4116 [preset setObject:@"HandBrake's preset for consistently excellent quality in one pass, with the downside of entirely unpredictable file sizes and bitrates." forKey:@"PresetDescription"];
4118 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4119 /* Chapter Markers*/
4120 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4122 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4124 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4125 /* x264 Option String */
4126 [preset setObject:@"ref=3:mixed-refs:bframes=3:b-pyramid:b-rdo:bime:weightb:filter=-2,-1:subme=6:trellis=1:analyse=all:8x8dct:me=umh" forKey:@"x264Option"];
4128 [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
4129 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4130 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4131 [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
4133 /* Video framerate */
4134 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4136 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4137 /* 2 Pass Encoding */
4138 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4139 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4141 /*Picture Settings*/
4142 //hb_job_t * job = fTitle->job;
4143 /* Basic Picture Settings */
4144 /* Use Max Picture settings for whatever the dvd is.*/
4145 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4146 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4147 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4148 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4149 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4150 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4151 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4152 /* Set crop settings here */
4153 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4154 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4155 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4156 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4157 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4160 /* Audio Sample Rate*/
4161 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4162 /* Audio Bitrate Rate*/
4163 [preset setObject:@"160" forKey:@"AudioBitRate"];
4165 [preset setObject:@"None" forKey:@"Subtitles"];
4168 [preset autorelease];
4174 - (IBAction)deletePreset:(id)sender
4177 NSEnumerator *enumerator;
4179 NSMutableArray *tempArray;
4182 if ( [tableView numberOfSelectedRows] == 0 )
4184 /* Alert user before deleting preset */
4185 /* Comment out for now, tie to user pref eventually */
4188 status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected preset?", @"OK", @"Cancel", nil);
4190 if ( status == NSAlertDefaultReturn ) {
4191 enumerator = [tableView selectedRowEnumerator];
4192 tempArray = [NSMutableArray array];
4194 while ( (index = [enumerator nextObject]) ) {
4195 tempObject = [UserPresets objectAtIndex:[index intValue]];
4196 [tempArray addObject:tempObject];
4199 [UserPresets removeObjectsInArray:tempArray];
4200 [tableView reloadData];
4205 - (IBAction)getDefaultPresets:(id)sender
4208 NSEnumerator *enumerator = [UserPresets objectEnumerator];
4210 while (tempObject = [enumerator nextObject])
4212 NSDictionary *thisPresetDict = tempObject;
4213 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
4215 presetHbDefault = i;
4217 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
4219 presetUserDefault = i;
4225 - (IBAction)setDefaultPreset:(id)sender
4228 NSEnumerator *enumerator = [UserPresets objectEnumerator];
4230 /* First make sure the old user specified default preset is removed */
4231 while (tempObject = [enumerator nextObject])
4233 /* make sure we are not removing the default HB preset */
4234 if ([[[UserPresets objectAtIndex:i] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
4236 [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4240 /* Second, go ahead and set the appropriate user specfied preset */
4241 /* we get the chosen preset from the UserPresets array */
4242 if ([[[UserPresets objectAtIndex:[tableView selectedRow]] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
4244 [[UserPresets objectAtIndex:[tableView selectedRow]] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];
4246 presetUserDefault = [tableView selectedRow];
4248 /* We save all of the preset data here */
4250 /* We Reload the New Table data for presets */
4251 [tableView reloadData];
4254 - (IBAction)selectDefaultPreset:(id)sender
4256 /* if there is a user specified default, we use it */
4257 if (presetUserDefault)
4259 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetUserDefault] byExtendingSelection:NO];
4260 [self tableViewSelected:NULL];
4262 else if (presetHbDefault) //else we use the built in default presetHbDefault
4264 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetHbDefault] byExtendingSelection:NO];
4265 [self tableViewSelected:NULL];
4269 - (IBAction)tableViewSelected:(id)sender
4271 /* Since we cannot disable the presets tableView in terms of clickability
4272 we will use the enabled state of the add presets button to determine whether
4273 or not clicking on a preset will do anything */
4274 if ([fPresetsAdd isEnabled])
4276 if ([tableView selectedRow] >= 0)
4278 /* we get the chosen preset from the UserPresets array */
4279 chosenPreset = [UserPresets objectAtIndex:[tableView selectedRow]];
4280 curUserPresetChosenNum = [sender selectedRow];
4281 /* we set the preset display field in main window here */
4282 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
4283 if ([[chosenPreset objectForKey:@"Default"] intValue] == 1)
4285 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@ (Default)",[chosenPreset valueForKey:@"PresetName"]]];
4289 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
4292 [fDstFormatPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileFormat"]]];
4293 [self formatPopUpChanged: NULL];
4295 /* Chapter Markers*/
4296 [fCreateChapterMarkers setState:[[chosenPreset objectForKey:@"ChapterMarkers"] intValue]];
4297 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
4298 [fDstMpgLargeFileCheck setState:[[chosenPreset objectForKey:@"Mp4LargeFile"] intValue]];
4300 [fDstCodecsPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileCodecs"]]];
4301 [self codecsPopUpChanged: NULL];
4303 [fVidEncoderPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoEncoder"]]];
4305 /* We can show the preset options here in the gui if we want to
4306 so we check to see it the user has specified it in the prefs */
4307 [fAdvancedOptions setOptions: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]];
4309 /* Lets run through the following functions to get variables set there */
4310 [self encoderPopUpChanged: NULL];
4312 [self calculateBitrate: NULL];
4315 [fVidQualityMatrix selectCellAtRow:[[chosenPreset objectForKey:@"VideoQualityType"] intValue] column:0];
4317 [fVidTargetSizeField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoTargetSize"]]];
4318 [fVidBitrateField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoAvgBitrate"]]];
4320 [fVidQualitySlider setFloatValue: [[chosenPreset valueForKey:@"VideoQualitySlider"] floatValue]];
4321 [self videoMatrixChanged: NULL];
4323 /* Video framerate */
4324 [fVidRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoFramerate"]]];
4327 [fVidGrayscaleCheck setState:[[chosenPreset objectForKey:@"VideoGrayScale"] intValue]];
4329 /* 2 Pass Encoding */
4330 [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
4331 [self twoPassCheckboxChanged: NULL];
4332 /* Turbo 1st pass for 2 Pass Encoding */
4333 [fVidTurboPassCheck setState:[[chosenPreset objectForKey:@"VideoTurboTwoPass"] intValue]];
4337 /* Audio Sample Rate*/
4338 [fAudRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioSampleRate"]]];
4339 /* Audio Bitrate Rate*/
4340 [fAudBitratePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioBitRate"]]];
4342 [fSubPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"Subtitles"]]];
4344 /* Picture Settings */
4345 /* Look to see if we apply these here in objectForKey:@"UsesPictureSettings"] */
4346 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] > 0)
4348 hb_job_t * job = fTitle->job;
4349 /* Check to see if we should use the max picture setting for the current title*/
4350 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"] intValue] == 1)
4352 /* Use Max Picture settings for whatever the dvd is.*/
4353 [self revertPictureSizeToMax: NULL];
4354 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
4355 if (job->keep_ratio == 1)
4357 hb_fix_aspect( job, HB_KEEP_WIDTH );
4358 if( job->height > fTitle->height )
4360 job->height = fTitle->height;
4361 hb_fix_aspect( job, HB_KEEP_HEIGHT );
4364 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
4366 else // Apply picture settings that were in effect at the time the preset was saved
4368 job->width = [[chosenPreset objectForKey:@"PictureWidth"] intValue];
4369 job->height = [[chosenPreset objectForKey:@"PictureHeight"] intValue];
4370 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
4371 if (job->keep_ratio == 1)
4373 hb_fix_aspect( job, HB_KEEP_WIDTH );
4374 if( job->height > fTitle->height )
4376 job->height = fTitle->height;
4377 hb_fix_aspect( job, HB_KEEP_HEIGHT );
4380 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
4381 [fPictureController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
4383 if ([chosenPreset objectForKey:@"PictureDetelecine"])
4385 [fPictureController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
4387 if ([chosenPreset objectForKey:@"PictureDenoise"])
4389 [fPictureController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
4391 /* If Cropping is set to custom, then recall all four crop values from
4392 when the preset was created and apply them */
4393 if ([[chosenPreset objectForKey:@"PictureAutoCrop"] intValue] == 0)
4395 [fPictureController setAutoCrop:NO];
4397 /* Here we use the custom crop values saved at the time the preset was saved */
4398 job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"] intValue];
4399 job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"] intValue];
4400 job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"] intValue];
4401 job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"] intValue];
4404 else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
4406 [fPictureController setAutoCrop:YES];
4407 /* Here we use the auto crop values determined right after scan */
4408 job->crop[0] = AutoCropTop;
4409 job->crop[1] = AutoCropBottom;
4410 job->crop[2] = AutoCropLeft;
4411 job->crop[3] = AutoCropRight;
4415 [self calculatePictureSizing: NULL];
4419 [[fPresetsActionMenu itemAtIndex:0] setEnabled: YES];
4426 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
4428 return [UserPresets count];
4431 /* we use this to determine display characteristics for
4432 each table cell based on content currently only used to
4433 show the built in presets in a blue font. */
4434 - (void)tableView:(NSTableView *)aTableView
4435 willDisplayCell:(id)aCell
4436 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
4438 NSDictionary *userPresetDict = [UserPresets objectAtIndex:rowIndex];
4441 NSColor *shadowColor;
4442 txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]];
4443 /* First, we check to see if its a selected row, if so, we use white since its highlighted in blue */
4444 if ([[aTableView selectedRowIndexes] containsIndex:rowIndex] && ([tableView editedRow] != rowIndex))
4447 fontColor = [NSColor whiteColor];
4448 shadowColor = [NSColor colorWithDeviceRed:(127.0/255.0) green:(140.0/255.0) blue:(160.0/255.0) alpha:1.0];
4452 /* We set the properties of unselected rows */
4453 /* if built-in preset (defined by "type" == 0) we use a blue font */
4454 if ([[userPresetDict objectForKey:@"Type"] intValue] == 0)
4456 fontColor = [NSColor blueColor];
4458 else // User created preset, use a black font
4460 fontColor = [NSColor blackColor];
4464 /* We check to see if this is the HB default, if so, color it appropriately */
4465 if (!presetUserDefault && presetHbDefault && rowIndex == presetHbDefault)
4467 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
4469 /* We check to see if this is the User Specified default, if so, color it appropriately */
4470 if (presetUserDefault && rowIndex == presetUserDefault)
4472 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
4475 [aCell setTextColor:fontColor];
4476 [aCell setFont:txtFont];
4477 /* this shadow stuff (like mail app) for some reason looks crappy, commented out
4478 temporarily in case we want to resurrect it */
4480 NSShadow *shadow = [[NSShadow alloc] init];
4481 NSSize shadowOffset = { width: 1.0, height: -1.5};
4482 [shadow setShadowOffset:shadowOffset];
4483 [shadow setShadowColor:shadowColor];
4488 /* Method to display tooltip with the description for each preset, if available */
4489 - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell
4490 rect:(NSRectPointer)aRect tableColumn:(NSTableColumn *)aTableColumn
4491 row:(int)rowIndex mouseLocation:(NSPoint)aPos
4493 /* initialize the tooltip contents variable */
4495 /* if there is a description for the preset, we show it in the tooltip */
4496 if ([[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"])
4498 loc_tip = [NSString stringWithFormat: @"%@",[[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"]];
4503 loc_tip = @"No description available";
4509 - (id)tableView:(NSTableView *)aTableView
4510 objectValueForTableColumn:(NSTableColumn *)aTableColumn
4513 id theRecord, theValue;
4515 theRecord = [UserPresets objectAtIndex:rowIndex];
4516 theValue = [theRecord objectForKey:[aTableColumn identifier]];
4520 // NSTableDataSource method that we implement to edit values directly in the table...
4521 - (void)tableView:(NSTableView *)aTableView
4522 setObjectValue:(id)anObject
4523 forTableColumn:(NSTableColumn *)aTableColumn
4528 theRecord = [UserPresets objectAtIndex:rowIndex];
4529 [theRecord setObject:anObject forKey:@"PresetName"];
4530 /* We Sort the Presets By Factory or Custom */
4531 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
4532 ascending:YES] autorelease];
4533 /* We Sort the Presets Alphabetically by name */
4534 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
4535 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
4536 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
4537 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
4538 [UserPresets setArray:sortedArray];
4539 /* We Reload the New Table data for presets */
4540 [tableView reloadData];
4541 /* We save all of the preset data here */
4547 [UserPresets writeToFile:UserPresetsFile atomically:YES];
4548 /* We get the default preset in case it changed */
4549 [self getDefaultPresets: NULL];
4553 - (void) controlTextDidChange: (NSNotification *) notification
4555 [self calculateBitrate: NULL];
4558 - (IBAction) openHomepage: (id) sender
4560 [[NSWorkspace sharedWorkspace] openURL: [NSURL
4561 URLWithString:@"http://handbrake.m0k.org/"]];
4564 - (IBAction) openForums: (id) sender
4566 [[NSWorkspace sharedWorkspace] openURL: [NSURL
4567 URLWithString:@"http://handbrake.m0k.org/forum/"]];
4569 - (IBAction) openUserGuide: (id) sender
4571 [[NSWorkspace sharedWorkspace] openURL: [NSURL
4572 URLWithString:@"http://handbrake.m0k.org/trac/wiki/HandBrakeGuide"]];
4576 * Shows debug output window.
4578 - (IBAction)showDebugOutputPanel:(id)sender
4580 [outputPanel showOutputPanel:sender];
4584 * Shows preferences window modally.
4586 - (IBAction) showPreferencesWindow: (id) sender
4588 NSWindow * window = [fPreferencesController window];
4589 if (![window isVisible])
4592 [window makeKeyAndOrderFront: nil];
4596 * Shows queue window.
4598 - (IBAction) showQueueWindow:(id)sender
4600 [fQueueController showQueueWindow:sender];
4604 - (IBAction) toggleDrawer:(id)sender {
4605 [fPresetDrawer toggle:self];