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"
12 #define _(a) NSLocalizedString(a,NULL)
14 static int FormatSettings[4][10] =
15 { { HB_MUX_MP4 | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC,
16 HB_MUX_MP4 | HB_VCODEC_X264 | HB_ACODEC_FAAC,
19 { HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
20 HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_AC3,
21 HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_LAME,
22 HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_AC3},
23 { HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS,
24 HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
27 { HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC,
28 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_AC3,
29 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
30 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS,
31 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_FAAC,
32 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_AC3,
33 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_LAME,
34 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_VORBIS,
38 /* We setup the toolbar values here */
39 static NSString* MyDocToolbarIdentifier = @"My Document Toolbar Identifier";
40 static NSString* ToggleDrawerIdentifier = @"Toggle Drawer Item Identifier";
41 static NSString* StartEncodingIdentifier = @"Start Encoding Item Identifier";
42 static NSString* PauseEncodingIdentifier = @"Pause Encoding Item Identifier";
43 static NSString* ShowQueueIdentifier = @"Show Queue Item Identifier";
44 static NSString* AddToQueueIdentifier = @"Add to Queue Item Identifier";
45 static NSString* DebugOutputIdentifier = @"Debug Output Item Identifier";
46 static NSString* ChooseSourceIdentifier = @"Choose Source Item Identifier";
48 /*******************************
49 * HBController implementation *
50 *******************************/
51 @implementation HBController
56 [HBPreferencesController registerUserDefaults];
58 outputPanel = [[HBOutputPanelController alloc] init];
62 - (void) applicationDidFinishLaunching: (NSNotification *) notification
67 // Open debug output window now if it was visible when HB was closed
68 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"])
69 [self showDebugOutputPanel:nil];
72 int debugLevel = [[NSUserDefaults standardUserDefaults] boolForKey:@"ShowVerboseOutput"] ? HB_DEBUG_ALL : HB_DEBUG_NONE;
73 fHandle = hb_init(debugLevel, [[NSUserDefaults standardUserDefaults] boolForKey:@"CheckForUpdates"]);
75 // Set the Growl Delegate
76 HBController *hbGrowlDelegate = [[HBController alloc] init];
77 [GrowlApplicationBridge setGrowlDelegate: hbGrowlDelegate];
78 /* Init others controllers */
79 [fScanController SetHandle: fHandle];
80 [fPictureController SetHandle: fHandle];
81 [fQueueController SetHandle: fHandle];
83 fChapterTitlesDelegate = [[ChapterTitles alloc] init];
84 [fChapterTable setDataSource:fChapterTitlesDelegate];
86 /* Call UpdateUI every 2/10 sec */
87 [[NSRunLoop currentRunLoop] addTimer: [NSTimer
88 scheduledTimerWithTimeInterval: 0.2 target: self
89 selector: @selector( UpdateUI: ) userInfo: NULL repeats: FALSE]
90 forMode: NSModalPanelRunLoopMode];
92 if( ( build = hb_check_update( fHandle, &version ) ) > -1 )
94 /* Update available - tell the user */
96 NSBeginInformationalAlertSheet( _( @"Update is available" ),
97 _( @"Go get it!" ), _( @"Discard" ), NULL, fWindow, self,
98 @selector( UpdateAlertDone:returnCode:contextInfo: ),
99 NULL, NULL, [NSString stringWithFormat:
100 _( @"HandBrake %s (build %d) is now available for download." ),
106 /* Show scan panel ASAP */
107 [self performSelectorOnMainThread: @selector(ShowScanPanel:)
108 withObject: NULL waitUntilDone: NO];
111 - (NSApplicationTerminateReply) applicationShouldTerminate:
112 (NSApplication *) app
114 if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )
117 return NSTerminateCancel;
119 return NSTerminateNow;
122 - (void)applicationWillTerminate:(NSNotification *)aNotification
124 [outputPanel release];
129 - (void) awakeFromNib
133 [self TranslateStrings];
134 /* Initialize currentScanCount so HB can use it to
135 evaluate successive scans */
136 currentScanCount = 0;
138 /* Init User Presets .plist */
139 /* We declare the default NSFileManager into fileManager */
140 NSFileManager * fileManager = [NSFileManager defaultManager];
141 //presetPrefs = [[NSUserDefaults standardUserDefaults] retain];
142 /* we set the files and support paths here */
143 AppSupportDirectory = @"~/Library/Application Support/HandBrake";
144 AppSupportDirectory = [AppSupportDirectory stringByExpandingTildeInPath];
146 UserPresetsFile = @"~/Library/Application Support/HandBrake/UserPresets.plist";
147 UserPresetsFile = [UserPresetsFile stringByExpandingTildeInPath];
149 x264ProfilesFile = @"~/Library/Application Support/HandBrake/x264Profiles.plist";
150 x264ProfilesFile = [x264ProfilesFile stringByExpandingTildeInPath];
151 /* We check for the app support directory for media fork */
152 if ([fileManager fileExistsAtPath:AppSupportDirectory] == 0)
154 // If it doesnt exist yet, we create it here
155 [fileManager createDirectoryAtPath:AppSupportDirectory attributes:nil];
157 // We check for the presets.plist here
159 if ([fileManager fileExistsAtPath:UserPresetsFile] == 0)
162 [fileManager createFileAtPath:UserPresetsFile contents:nil attributes:nil];
165 // We check for the x264profiles.plist here
167 if ([fileManager fileExistsAtPath:x264ProfilesFile] == 0)
170 [fileManager createFileAtPath:x264ProfilesFile contents:nil attributes:nil];
174 UserPresetsFile = @"~/Library/Application Support/HandBrake/UserPresets.plist";
175 UserPresetsFile = [[UserPresetsFile stringByExpandingTildeInPath]retain];
177 UserPresets = [[NSMutableArray alloc] initWithContentsOfFile:UserPresetsFile];
178 if (nil == UserPresets)
180 UserPresets = [[NSMutableArray alloc] init];
181 [self AddFactoryPresets:NULL];
186 /* Show/Dont Show Presets drawer upon launch based
187 on user preference DefaultPresetsDrawerShow*/
188 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0)
190 [fPresetDrawer open];
196 [fDstFormatPopUp removeAllItems];
197 [fDstFormatPopUp addItemWithTitle: _( @"MP4 file" )];
198 [fDstFormatPopUp addItemWithTitle: _( @"AVI file" )];
199 [fDstFormatPopUp addItemWithTitle: _( @"OGM file" )];
200 [fDstFormatPopUp addItemWithTitle: _( @"MKV file" )];
201 [fDstFormatPopUp selectItemAtIndex: 0];
203 [self FormatPopUpChanged: NULL];
205 /* We enable the create chapters checkbox here since we are .mp4 */
206 [fCreateChapterMarkers setEnabled: YES];
207 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultChapterMarkers"] > 0)
209 [fCreateChapterMarkers setState: NSOnState];
215 [fDstFile2Field setStringValue: [NSString stringWithFormat:
216 @"%@/Desktop/Movie.mp4", NSHomeDirectory()]];
219 [fVidEncoderPopUp removeAllItems];
220 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
221 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
226 [fVidTargetSizeField setIntValue: 700];
227 [fVidBitrateField setIntValue: 1000];
229 [fVidQualityMatrix selectCell: fVidBitrateCell];
230 [self VideoMatrixChanged: NULL];
232 /* Video framerate */
233 [fVidRatePopUp removeAllItems];
234 [fVidRatePopUp addItemWithTitle: _( @"Same as source" )];
235 for( int i = 0; i < hb_video_rates_count; i++ )
237 if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]])
239 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
240 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Film)"]];
242 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]])
244 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
245 [NSString stringWithCString: hb_video_rates[i].string], @" (PAL Film/Video)"]];
247 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]])
249 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
250 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Video)"]];
254 [fVidRatePopUp addItemWithTitle:
255 [NSString stringWithCString: hb_video_rates[i].string]];
258 [fVidRatePopUp selectItemAtIndex: 0];
260 /* Picture Settings */
261 [fPicLabelPAROutp setStringValue: @""];
262 [fPicLabelPAROutputX setStringValue: @""];
263 [fPicSettingPARWidth setStringValue: @""];
264 [fPicSettingPARHeight setStringValue: @""];
266 /*Set detelecine to Off upon launch */
267 [fPicSettingDetelecine setStringValue: @"No"];
268 [fPicSettingDenoise setStringValue: @"0"];
271 [fAudBitratePopUp removeAllItems];
272 for( int i = 0; i < hb_audio_bitrates_count; i++ )
274 [fAudBitratePopUp addItemWithTitle:
275 [NSString stringWithCString: hb_audio_bitrates[i].string]];
278 [fAudBitratePopUp selectItemAtIndex: hb_audio_bitrates_default];
280 /* Audio samplerate */
281 [fAudRatePopUp removeAllItems];
282 for( int i = 0; i < hb_audio_rates_count; i++ )
284 [fAudRatePopUp addItemWithTitle:
285 [NSString stringWithCString: hb_audio_rates[i].string]];
287 [fAudRatePopUp selectItemAtIndex: hb_audio_rates_default];
290 [fStatusField setStringValue: @""];
293 /* Use new Toolbar start and pause here */
294 startButtonEnabled = NO;
296 AddToQueueButtonEnabled = NO;
297 pauseButtonEnabled = NO;
301 [fPresetsActionButton setMenu:fPresetsActionMenu];
303 /* We disable the Turbo 1st pass checkbox since we are not x264 */
304 [fVidTurboPassCheck setEnabled: NO];
305 [fVidTurboPassCheck setState: NSOffState];
308 /* lets get our default prefs here */
309 [self GetDefaultPresets: NULL];
310 /* lets initialize the current successful scancount here to 0 */
311 currentSuccessfulScanCount = 0;
316 // ============================================================
317 // NSToolbar Related Methods
318 // ============================================================
320 - (void) setupToolbar {
321 // Create a new toolbar instance, and attach it to our document window
322 NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: MyDocToolbarIdentifier] autorelease];
324 // Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults
325 [toolbar setAllowsUserCustomization: YES];
326 [toolbar setAutosavesConfiguration: YES];
327 [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
329 // We are the delegate
330 [toolbar setDelegate: self];
332 // Attach the toolbar to the document window
333 [fWindow setToolbar: toolbar];
336 - (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
337 // Required delegate method: Given an item identifier, this method returns an item
338 // The toolbar will use this method to obtain toolbar items that can be displayed in the customization sheet, or in the toolbar itself
339 NSToolbarItem *toolbarItem = nil;
341 if ([itemIdent isEqual: ToggleDrawerIdentifier]) {
342 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
344 // Set the text label to be displayed in the toolbar and customization palette
345 [toolbarItem setLabel: @"Toggle Presets"];
346 [toolbarItem setPaletteLabel: @"Toggler Presets"];
348 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
349 [toolbarItem setToolTip: @"Open/Close Preset Drawer"];
350 [toolbarItem setImage: [NSImage imageNamed: @"Drawer-List2"]];
352 // Tell the item what message to send when it is clicked
353 [toolbarItem setTarget: self];
354 [toolbarItem setAction: @selector(toggleDrawer)];
356 } else if ([itemIdent isEqual: StartEncodingIdentifier]) {
357 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
359 // Set the text label to be displayed in the toolbar and customization palette
360 [toolbarItem setLabel: @"Start"];
361 [toolbarItem setPaletteLabel: @"Start Encoding"];
363 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
364 [toolbarItem setToolTip: @"Start Encoding"];
365 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
367 // Tell the item what message to send when it is clicked
368 [toolbarItem setTarget: self];
369 [toolbarItem setAction: @selector(Rip:)];
373 } else if ([itemIdent isEqual: ShowQueueIdentifier]) {
374 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
376 // Set the text label to be displayed in the toolbar and customization palette
377 [toolbarItem setLabel: @"Show Queue"];
378 [toolbarItem setPaletteLabel: @"Show Queue"];
380 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
381 [toolbarItem setToolTip: @"Show Queue"];
382 [toolbarItem setImage: [NSImage imageNamed: @"Brushed Window"]];
384 // Tell the item what message to send when it is clicked
385 [toolbarItem setTarget: self];
386 [toolbarItem setAction: @selector(ShowQueuePanel:)];
388 } else if ([itemIdent isEqual: AddToQueueIdentifier]) {
389 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
391 // Set the text label to be displayed in the toolbar and customization palette
392 [toolbarItem setLabel: @"Add to Queue"];
393 [toolbarItem setPaletteLabel: @"Add to Queue"];
395 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
396 [toolbarItem setToolTip: @"Add to Queue"];
397 [toolbarItem setImage: [NSImage imageNamed: @"Add"]];
399 // Tell the item what message to send when it is clicked
400 [toolbarItem setTarget: self];
401 [toolbarItem setAction: @selector(AddToQueue:)];
404 } else if ([itemIdent isEqual: PauseEncodingIdentifier]) {
405 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
407 // Set the text label to be displayed in the toolbar and customization palette
408 [toolbarItem setLabel: @"Pause"];
409 [toolbarItem setPaletteLabel: @"Pause Encoding"];
411 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
412 [toolbarItem setToolTip: @"Pause Encoding"];
413 [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
415 // Tell the item what message to send when it is clicked
416 [toolbarItem setTarget: self];
417 [toolbarItem setAction: @selector(Pause:)];
419 } else if ([itemIdent isEqual: DebugOutputIdentifier]) {
420 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
422 // Set the text label to be displayed in the toolbar and customization palette
423 [toolbarItem setLabel: @"Activity Window"];
424 [toolbarItem setPaletteLabel: @"Show Activity Window"];
426 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
427 [toolbarItem setToolTip: @"Show Activity Window"];
428 [toolbarItem setImage: [NSImage imageNamed: @"Terminal"]];
430 // Tell the item what message to send when it is clicked
431 [toolbarItem setTarget: self];
432 [toolbarItem setAction: @selector(showDebugOutputPanel:)];
434 } else if ([itemIdent isEqual: ChooseSourceIdentifier]) {
435 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
437 // Set the text label to be displayed in the toolbar and customization palette
438 [toolbarItem setLabel: @"Source"];
439 [toolbarItem setPaletteLabel: @"Source"];
441 // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties
442 [toolbarItem setToolTip: @"Choose Video Source"];
443 [toolbarItem setImage: [NSImage imageNamed: @"Disc"]];
445 // Tell the item what message to send when it is clicked
446 [toolbarItem setTarget: self];
447 [toolbarItem setAction: @selector(ShowScanPanel:)];
450 //itemIdent refered to a toolbar item that is not provide or supported by us or cocoa
451 //Returning nil will inform the toolbar this kind of item is not supported
458 - (void) toggleDrawer {
459 [fPresetDrawer toggle:self];
462 - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar {
463 // Required delegate method: Returns the ordered list of items to be shown in the toolbar by default
464 // If during the toolbar's initialization, no overriding values are found in the user defaults, or if the
465 // user chooses to revert to the default items this set will be used
466 return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier, PauseEncodingIdentifier,
467 AddToQueueIdentifier, ShowQueueIdentifier,
468 NSToolbarFlexibleSpaceItemIdentifier,
469 NSToolbarSpaceItemIdentifier, DebugOutputIdentifier, ToggleDrawerIdentifier, nil];
472 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
473 // Required delegate method: Returns the list of all allowed items by identifier. By default, the toolbar
474 // does not assume any items are allowed, even the separator. So, every allowed item must be explicitly listed
475 // The set of allowed items is used to construct the customization palette
476 return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier,
477 DebugOutputIdentifier, NSToolbarCustomizeToolbarItemIdentifier,
478 NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, ChooseSourceIdentifier,
479 NSToolbarSeparatorItemIdentifier,ToggleDrawerIdentifier, nil];
482 - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem {
483 // Optional method: This message is sent to us since we are the target of some toolbar item actions
485 if ([[toolbarItem itemIdentifier] isEqual: ToggleDrawerIdentifier]) {
488 if ([[toolbarItem itemIdentifier] isEqual: StartEncodingIdentifier]) {
489 enable = startButtonEnabled;
491 [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];
492 [toolbarItem setLabel: @"Cancel"];
493 [toolbarItem setPaletteLabel: @"Cancel"];
494 [toolbarItem setToolTip: @"Cancel Encoding"];
497 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
498 [toolbarItem setLabel: @"Start"];
499 [toolbarItem setPaletteLabel: @"Start Encoding"];
500 [toolbarItem setToolTip: @"Start Encoding"];
504 if ([[toolbarItem itemIdentifier] isEqual: PauseEncodingIdentifier]) {
505 enable = pauseButtonEnabled;
507 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
508 [toolbarItem setLabel: @"Resume"];
509 [toolbarItem setPaletteLabel: @"Resume Encoding"];
510 [toolbarItem setToolTip: @"Resume Encoding"];
513 [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
514 [toolbarItem setLabel: @"Pause"];
515 [toolbarItem setPaletteLabel: @"Pause Encoding"];
516 [toolbarItem setToolTip: @"Pause Encoding"];
519 if ([[toolbarItem itemIdentifier] isEqual: DebugOutputIdentifier]) {
522 if ([[toolbarItem itemIdentifier] isEqual: ShowQueueIdentifier]) {
525 if ([[toolbarItem itemIdentifier] isEqual: AddToQueueIdentifier]) {
526 enable = AddToQueueButtonEnabled;
528 if ([[toolbarItem itemIdentifier] isEqual: ChooseSourceIdentifier]) {
534 // register a test notification and make
535 // it enabled by default
536 #define SERVICE_NAME @"Encode Done"
537 - (NSDictionary *)registrationDictionaryForGrowl
539 NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
540 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL,
541 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT,
544 return registrationDictionary;
546 - (void) TranslateStrings
548 [fSrcDVD1Field setStringValue: _( @"DVD:" )];
549 [fSrcTitleField setStringValue: _( @"Title:" )];
550 [fSrcChapterField setStringValue: _( @"Chapters:" )];
551 [fSrcChapterToField setStringValue: _( @"to" )];
552 [fSrcDuration1Field setStringValue: _( @"Duration:" )];
554 [fDstFormatField setStringValue: _( @"File format:" )];
555 [fDstCodecsField setStringValue: _( @"Codecs:" )];
556 [fDstFile1Field setStringValue: _( @"File:" )];
557 [fDstBrowseButton setTitle: _( @"Browse" )];
559 [fVidRateField setStringValue: _( @"Framerate (fps):" )];
560 [fVidEncoderField setStringValue: _( @"Encoder:" )];
561 [fVidQualityField setStringValue: _( @"Quality:" )];
564 /***********************************************************************
566 ***********************************************************************
567 * Shows a progression bar on the dock icon, filled according to
568 * 'progress' (0.0 <= progress <= 1.0).
569 * Called with progress < 0.0 or progress > 1.0, restores the original
571 **********************************************************************/
572 - (void) UpdateDockIcon: (float) progress
576 NSBitmapImageRep * bmp;
578 uint32_t black = htonl( 0x000000FF );
579 uint32_t red = htonl( 0xFF0000FF );
580 uint32_t white = htonl( 0xFFFFFFFF );
581 int row_start, row_end;
584 /* Get application original icon */
585 icon = [NSImage imageNamed: @"NSApplicationIcon"];
587 if( progress < 0.0 || progress > 1.0 )
589 [NSApp setApplicationIconImage: icon];
593 /* Get it in a raw bitmap form */
594 tiff = [icon TIFFRepresentationUsingCompression:
595 NSTIFFCompressionNone factor: 1.0];
596 bmp = [NSBitmapImageRep imageRepWithData: tiff];
598 /* Draw the progression bar */
599 /* It's pretty simple (ugly?) now, but I'm no designer */
601 row_start = 3 * (int) [bmp size].height / 4;
602 row_end = 7 * (int) [bmp size].height / 8;
604 for( i = row_start; i < row_start + 2; i++ )
606 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
607 for( j = 0; j < (int) [bmp size].width; j++ )
612 for( i = row_start + 2; i < row_end - 2; i++ )
614 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
617 for( j = 2; j < (int) [bmp size].width - 2; j++ )
619 if( j < 2 + (int) ( ( [bmp size].width - 4.0 ) * progress ) )
631 for( i = row_end - 2; i < row_end; i++ )
633 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
634 for( j = 0; j < (int) [bmp size].width; j++ )
640 /* Now update the dock icon */
641 tiff = [bmp TIFFRepresentationUsingCompression:
642 NSTIFFCompressionNone factor: 1.0];
643 icon = [[NSImage alloc] initWithData: tiff];
644 [NSApp setApplicationIconImage: icon];
648 - (void) UpdateUI: (NSTimer *) timer
652 list = hb_get_titles( fHandle );
653 /* check to see if there has been a new scan done
654 this bypasses the constraints of HB_STATE_WORKING
655 not allowing setting a newly scanned source */
656 int checkScanCount = hb_get_scancount( fHandle );
657 if (checkScanCount > currentScanCount)
660 currentScanCount = checkScanCount;
661 [fScanController Cancel: NULL];
662 [fScanIndicator setIndeterminate: NO];
663 [fScanIndicator setDoubleValue: 0.0];
664 [fScanIndicator setHidden: YES];
665 [fScanController Cancel: NULL];
666 [self ShowNewScan: NULL];
674 hb_get_state( fHandle, &s );
681 #define p s.param.scanning
682 case HB_STATE_SCANNING:
684 [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
685 _( @"Scanning title %d of %d..." ),
686 p.title_cur, p.title_count]];
687 [fScanIndicator setIndeterminate: NO];
688 [fScanIndicator setDoubleValue: 100.0 * ( p.title_cur - 1 ) /
694 #define p s.param.scandone
695 case HB_STATE_SCANDONE:
698 [fScanIndicator setIndeterminate: NO];
699 [fScanIndicator setDoubleValue: 0.0];
700 [fScanIndicator setHidden: YES];
701 [fScanController Cancel: NULL];
702 [self ShowNewScan: NULL];
707 #define p s.param.working
708 case HB_STATE_WORKING:
710 float progress_total;
711 NSMutableString * string;
712 /* Currently, p.job_cur and p.job_count get screwed up when adding
713 jobs during encoding, if they cannot be fixed in libhb, will implement a
714 nasty but working cocoa solution */
715 /* Update text field */
716 string = [NSMutableString stringWithFormat: _( @"Encoding: task %d of %d, %.2f %%" ), p.job_cur, p.job_count, 100.0 * p.progress];
720 [string appendFormat:
721 _( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)" ),
722 p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds];
724 [fStatusField setStringValue: string];
727 progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
728 [fRipIndicator setIndeterminate: NO];
729 [fRipIndicator setDoubleValue: 100.0 * progress_total];
731 /* Update dock icon */
732 [self UpdateDockIcon: progress_total];
734 /* new toolbar controls */
735 pauseButtonEnabled = YES;
737 startButtonEnabled = YES;
744 #define p s.param.muxing
745 case HB_STATE_MUXING:
747 NSMutableString * string;
749 /* Update text field */
750 string = [NSMutableString stringWithFormat:
752 [fStatusField setStringValue: string];
755 [fRipIndicator setIndeterminate: YES];
756 [fRipIndicator startAnimation: nil];
758 /* Update dock icon */
759 [self UpdateDockIcon: 1.0];
761 //[fPauseButton setEnabled: YES];
762 //[fPauseButton setTitle: _( @"Pause" )];
763 //[fRipButton setEnabled: YES];
764 // [fRipButton setTitle: _( @"Cancel" )];
769 case HB_STATE_PAUSED:
770 //[fStatusField setStringValue: _( @"Paused" )];
771 //[fPauseButton setEnabled: YES];
772 //[fPauseButton setTitle: _( @"Resume" )];
773 //[fRipButton setEnabled: YES];
774 //[fRipButton setTitle: _( @"Cancel" )];
775 /* new toolbar controls */
776 pauseButtonEnabled = YES;
778 startButtonEnabled = YES;
782 case HB_STATE_WORKDONE:
784 [fStatusField setStringValue: _( @"Done." )];
785 [fRipIndicator setIndeterminate: NO];
786 [fRipIndicator setDoubleValue: 0.0];
787 //[fRipButton setTitle: _( @"Start" )];
789 /* Restore dock icon */
790 [self UpdateDockIcon: -1.0];
792 //[fPauseButton setEnabled: NO];
793 //[fPauseButton setTitle: _( @"Pause" )];
794 // [fRipButton setEnabled: YES];
795 // [fRipButton setTitle: _( @"Start" )];
796 /* new toolbar controls */
797 pauseButtonEnabled = NO;
799 startButtonEnabled = YES;
801 NSRect frame = [fWindow frame];
802 if (frame.size.width <= 591)
803 frame.size.width = 591;
804 frame.size.height += -44;
805 frame.origin.y -= -44;
806 [fWindow setFrame:frame display:YES animate:YES];
810 while( ( job = hb_job( fHandle, 0 ) ) )
812 hb_rem( fHandle, job );
814 /* Check to see if the encode state has not been cancelled
815 to determine if we should check for encode done notifications */
816 if (fEncodeState != 2) {
817 /* If Growl Notification or Window and Growl has been selected */
818 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] ||
819 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
821 /*Growl Notification*/
822 [self showGrowlDoneNotification: NULL];
824 /* If Alert Window or Window and Growl has been selected */
825 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
826 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
828 /*On Screen Notification*/
831 status = NSRunAlertPanel(@"Put down that cocktail...",@"your HandBrake encode is done!", @"OK", nil, nil);
832 [NSApp requestUserAttention:NSCriticalRequest];
833 if ( status == NSAlertDefaultReturn )
835 [self EnableUI: YES];
840 [self EnableUI: YES];
842 /* If sleep has been selected */
843 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
846 NSDictionary* errorDict;
847 NSAppleEventDescriptor* returnDescriptor = NULL;
848 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
849 @"tell application \"Finder\" to sleep"];
850 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
851 [scriptObject release];
852 [self EnableUI: YES];
854 /* If Shutdown has been selected */
855 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
858 NSDictionary* errorDict;
859 NSAppleEventDescriptor* returnDescriptor = NULL;
860 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
861 @"tell application \"Finder\" to shut down"];
862 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
863 [scriptObject release];
864 [self EnableUI: YES];
867 // MetaX insertion via AppleScript
868 if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
870 NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", [fDstFile2Field stringValue], @"\")"]];
871 [myScript executeAndReturnError: nil];
879 [self EnableUI: YES];
885 /* Lets show the queue status
886 here in the main window*/
887 int queue_count = hb_count( fHandle );
890 [fQueueStatus setStringValue: [NSString stringWithFormat:
891 @"%d task%s in the queue",
892 queue_count, ( queue_count > 1 ) ? "s" : ""]];
896 [fQueueStatus setStringValue: @""];
899 [[NSRunLoop currentRunLoop] addTimer: [NSTimer
900 scheduledTimerWithTimeInterval: 0.5 target: self
901 selector: @selector( UpdateUI: ) userInfo: NULL repeats: FALSE]
902 forMode: NSModalPanelRunLoopMode];
904 - (IBAction) ShowNewScan:(id)sender
908 int indxpri=0; // Used to search the longuest title (default in combobox)
909 int longuestpri=0; // Used to search the longuest title (default in combobox)
911 list = hb_get_titles( fHandle );
913 if( !hb_list_count( list ) )
915 /* We display a message if a valid dvd source was not chosen */
916 if (sourceDisplayName)
918 /* Temporary string if til restoring old source is fixed */
919 [fSrcDVD2Field setStringValue: @"Not A Valid Source"];
920 //[fSrcDVD2Field setStringValue: [NSString stringWithFormat: @"%s", sourceDisplayName]];
924 [fSrcDVD2Field setStringValue: @"No Valid Title Found"];
929 /* We increment the successful scancount here by one,
930 which we use at the end of this function to tell the gui
931 if this is the first successful scan since launch and whether
932 or not we should set all settings to the defaults */
933 currentSuccessfulScanCount++;
935 [fSrcTitlePopUp removeAllItems];
936 for( int i = 0; i < hb_list_count( list ); i++ )
938 title = (hb_title_t *) hb_list_item( list, i );
939 /*Set DVD Name at top of window*/
940 [fSrcDVD2Field setStringValue:[NSString stringWithUTF8String: title->name]];
942 currentSource = [NSString stringWithUTF8String: title->dvd];
945 /* Use the dvd name in the default output field here
946 May want to add code to remove blank spaces for some dvd names*/
947 /* Check to see if the last destination has been set,use if so, if not, use Desktop */
948 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"])
950 [fDstFile2Field setStringValue: [NSString stringWithFormat:
951 @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],[NSString
952 stringWithUTF8String: title->name]]];
956 [fDstFile2Field setStringValue: [NSString stringWithFormat:
957 @"%@/Desktop/%@.mp4", NSHomeDirectory(),[NSString
958 stringWithUTF8String: title->name]]];
962 if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds)
964 longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds;
969 int format = [fDstFormatPopUp indexOfSelectedItem];
975 /*Get Default MP4 File Extension for mpeg4 (.mp4 or .m4v) from prefs*/
976 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
994 NSString * string = [fDstFile2Field stringValue];
995 /* Add/replace File Output name to the correct extension*/
996 if( [string characterAtIndex: [string length] - 4] == '.' )
998 [fDstFile2Field setStringValue: [NSString stringWithFormat:
999 @"%@.%s", [string substringToIndex: [string length] - 4],
1004 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1005 @"%@.%s", string, ext]];
1009 [fSrcTitlePopUp addItemWithTitle: [NSString
1010 stringWithFormat: @"%d - %02dh%02dm%02ds",
1011 title->index, title->hours, title->minutes,
1015 // Select the longuest title
1016 [fSrcTitlePopUp selectItemAtIndex: indxpri];
1017 [self TitlePopUpChanged: NULL];
1018 /* We set the auto crop in the main window to value "1" just as in PictureController,
1019 as it does not seem to be taken from any job-> variable */
1020 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
1024 [self EnableUI: YES];
1026 startButtonEnabled = YES;
1028 AddToQueueButtonEnabled = YES;
1029 pauseButtonEnabled = NO;
1031 /* we record the current source name here in case the next scan is unsuccessful,
1032 then we can replace the scan progress with the old name if necessary */
1033 sourceDisplayName = [NSString stringWithFormat:[fSrcDVD2Field stringValue]];
1035 /* if its the initial successful scan after awakeFromNib */
1036 if (currentSuccessfulScanCount == 1)
1038 [self SelectDefaultPreset: NULL];
1045 -(IBAction)showGrowlDoneNotification:(id)sender
1049 [GrowlApplicationBridge
1050 notifyWithTitle:@"Put down that cocktail..."
1051 description:@"your HandBrake encode is done!"
1052 notificationName:SERVICE_NAME
1058 - (void) EnableUI: (bool) b
1060 NSControl * controls[] =
1061 { fSrcDVD1Field, fSrcTitleField, fSrcTitlePopUp,
1062 fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField,
1063 fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field,
1064 fDstFormatField, fDstFormatPopUp, fDstCodecsField,
1065 fDstCodecsPopUp, fDstFile1Field, fDstFile2Field,
1066 fDstBrowseButton, fVidRateField, fVidRatePopUp,
1067 fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
1068 fVidQualityMatrix, fVidGrayscaleCheck, fSubField, fSubPopUp,
1069 fAudLang1Field, fAudLang1PopUp, fAudLang2Field, fAudLang2PopUp,
1070 fAudTrack1MixLabel, fAudTrack1MixPopUp, fAudTrack2MixLabel, fAudTrack2MixPopUp,
1071 fAudRateField, fAudRatePopUp, fAudBitrateField,
1072 fAudBitratePopUp, fPictureButton,fQueueStatus,
1073 fPicSrcWidth,fPicSrcHeight,fPicSettingWidth,fPicSettingHeight,
1074 fPicSettingARkeep,fPicSettingDeinterlace,fPicSettingARkeepDsply,
1075 fPicSettingDeinterlaceDsply,fPicLabelSettings,fPicLabelSrc,fPicLabelOutp,
1076 fPicLabelAr,fPicLabelDeinter,fPicLabelSrcX,fPicLabelOutputX,
1077 fPicLabelPAROutp,fPicLabelPAROutputX,fPicSettingPARWidth,fPicSettingPARHeight,
1078 fPicSettingPARDsply,fPicLabelAnamorphic,tableView,fPresetsAdd,fPresetsDelete,
1079 fCreateChapterMarkers,fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel,
1080 fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp,fX264optNfpskipLabel,fX264optNfpskipSwitch,
1081 fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp,
1082 fX264optTrellisLabel,fX264optTrellisPopUp,fX264optMixedRefsLabel,fX264optMixedRefsSwitch,
1083 fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp,
1084 fX264optWeightBLabel,fX264optWeightBSwitch,fX264optBRDOLabel,fX264optBRDOSwitch,
1085 fX264optBPyramidLabel,fX264optBPyramidSwitch,fX264optBiMELabel,fX264optBiMESwitch,
1086 fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel,
1087 fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch,
1088 fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp,fVidTurboPassCheck,fDstMpgLargeFileCheck,fPicSettingAutoCropLabel,
1089 fPicSettingAutoCropDsply,fPicSettingDetelecine,fPicSettingDetelecineLabel,fPicSettingDenoiseLabel};
1091 for( unsigned i = 0;
1092 i < sizeof( controls ) / sizeof( NSControl * ); i++ )
1094 if( [[controls[i] className] isEqualToString: @"NSTextField"] )
1096 NSTextField * tf = (NSTextField *) controls[i];
1097 if( ![tf isBezeled] )
1099 [tf setTextColor: b ? [NSColor controlTextColor] :
1100 [NSColor disabledControlTextColor]];
1104 [controls[i] setEnabled: b];
1110 /* if we're enabling the interface, check if the audio mixdown controls need to be enabled or not */
1111 /* these will have been enabled by the mass control enablement above anyway, so we're sense-checking it here */
1112 [self SetEnabledStateOfAudioMixdownControls: NULL];
1116 [tableView setEnabled: NO];
1120 [self VideoMatrixChanged: NULL];
1123 - (IBAction) ShowScanPanel: (id) sender
1125 [fScanController Show];
1128 - (IBAction) OpenMainWindow: (id) sender
1130 [fWindow makeKeyAndOrderFront:nil];
1131 [fWindow setReleasedWhenClosed: YES];
1133 - (BOOL) windowShouldClose: (id) sender
1136 /* See if we are currently running */
1138 hb_get_state( fHandle, &s );
1139 if ( s.state == HB_STATE_WORKING)
1141 /* If we are running, leave in memory when closing main window */
1142 [fWindow setReleasedWhenClosed: NO];
1148 /* Stop the application when the user closes the window */
1149 [NSApp terminate: self];
1155 - (IBAction) VideoMatrixChanged: (id) sender;
1157 bool target, bitrate, quality;
1159 target = bitrate = quality = false;
1160 if( [fVidQualityMatrix isEnabled] )
1162 switch( [fVidQualityMatrix selectedRow] )
1175 [fVidTargetSizeField setEnabled: target];
1176 [fVidBitrateField setEnabled: bitrate];
1177 [fVidQualitySlider setEnabled: quality];
1178 [fVidTwoPassCheck setEnabled: !quality &&
1179 [fVidQualityMatrix isEnabled]];
1182 [fVidTwoPassCheck setState: NSOffState];
1183 [fVidTurboPassCheck setHidden: YES];
1184 [fVidTurboPassCheck setState: NSOffState];
1187 [self QualitySliderChanged: sender];
1188 [self CalculateBitrate: sender];
1189 [self CustomSettingUsed: sender];
1192 - (IBAction) QualitySliderChanged: (id) sender
1194 [fVidConstantCell setTitle: [NSString stringWithFormat:
1195 _( @"Constant quality: %.0f %%" ), 100.0 *
1196 [fVidQualitySlider floatValue]]];
1197 [self CustomSettingUsed: sender];
1200 - (IBAction) BrowseFile: (id) sender
1202 /* Open a panel to let the user choose and update the text field */
1203 NSSavePanel * panel = [NSSavePanel savePanel];
1204 /* We get the current file name and path from the destination field here */
1205 [panel beginSheetForDirectory: [[fDstFile2Field stringValue] stringByDeletingLastPathComponent] file: [[fDstFile2Field stringValue] lastPathComponent]
1206 modalForWindow: fWindow modalDelegate: self
1207 didEndSelector: @selector( BrowseFileDone:returnCode:contextInfo: )
1211 - (void) BrowseFileDone: (NSSavePanel *) sheet
1212 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1214 if( returnCode == NSOKButton )
1216 [fDstFile2Field setStringValue: [sheet filename]];
1221 - (IBAction) ShowPicturePanel: (id) sender
1223 hb_list_t * list = hb_get_titles( fHandle );
1224 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1225 [fSrcTitlePopUp indexOfSelectedItem] );
1227 /* Resize the panel */
1229 newSize.width = 246 + title->width;
1230 newSize.height = 80 + title->height;
1231 [fPicturePanel setContentSize: newSize];
1233 [fPictureController SetTitle: title];
1235 [NSApp beginSheet: fPicturePanel modalForWindow: fWindow
1236 modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
1237 [NSApp runModalForWindow: fPicturePanel];
1238 [NSApp endSheet: fPicturePanel];
1239 [fPicturePanel orderOut: self];
1240 [self CalculatePictureSizing: sender];
1243 - (IBAction) ShowQueuePanel: (id) sender
1245 /* Update the OutlineView */
1246 [fQueueController Update: sender];
1248 /* Show the panel */
1249 [NSApp beginSheet: fQueuePanel modalForWindow: fWindow
1250 modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
1251 [NSApp runModalForWindow: fQueuePanel];
1252 [NSApp endSheet: fQueuePanel];
1253 [fQueuePanel orderOut: self];
1258 hb_list_t * list = hb_get_titles( fHandle );
1259 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1260 [fSrcTitlePopUp indexOfSelectedItem] );
1261 hb_job_t * job = title->job;
1264 /* Chapter selection */
1265 job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
1266 job->chapter_end = [fSrcChapterEndPopUp indexOfSelectedItem] + 1;
1268 /* Format and codecs */
1269 int format = [fDstFormatPopUp indexOfSelectedItem];
1270 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1271 job->mux = FormatSettings[format][codecs] & HB_MUX_MASK;
1272 job->vcodec = FormatSettings[format][codecs] & HB_VCODEC_MASK;
1273 job->acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
1274 /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
1275 if ([fDstFormatPopUp indexOfSelectedItem] == 0)
1277 /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being
1278 mpeg4 and the checkbox being checked
1279 *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/
1280 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0 && [fDstMpgLargeFileCheck state] == NSOnState)
1282 job->largeFileSize = 1;
1286 job->largeFileSize = 0;
1289 if ([fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 3)
1291 /* We set the chapter marker extraction here based on the format being
1292 mpeg4 or mkv and the checkbox being checked */
1293 if ([fCreateChapterMarkers state] == NSOnState)
1295 job->chapter_markers = 1;
1299 job->chapter_markers = 0;
1302 if( ( job->vcodec & HB_VCODEC_FFMPEG ) &&
1303 [fVidEncoderPopUp indexOfSelectedItem] > 0 )
1305 job->vcodec = HB_VCODEC_XVID;
1307 if( job->vcodec & HB_VCODEC_X264 )
1309 if ([fVidEncoderPopUp indexOfSelectedItem] > 0 )
1311 /* Just use new Baseline Level 3.0
1312 Lets Deprecate Baseline Level 1.3h264_level*/
1313 job->h264_level = 30;
1314 job->mux = HB_MUX_IPOD;
1315 /* move sanity check for iPod Encoding here */
1316 job->pixel_ratio = 0 ;
1320 /* Set this flag to switch from Constant Quantizer(default) to Constant Rate Factor Thanks jbrjake
1321 Currently only used with Constant Quality setting*/
1322 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0 && [fVidQualityMatrix selectedRow] == 2)
1327 /* Below Sends x264 options to the core library if x264 is selected*/
1328 /* Lets use this as per Nyx, Thanks Nyx!*/
1329 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1330 /* Turbo first pass if two pass and Turbo First pass is selected */
1331 if( [fVidTwoPassCheck state] == NSOnState && [fVidTurboPassCheck state] == NSOnState )
1333 /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
1334 NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:weightb=0:trellis=0:no-fast-pskip=0:8x8dct=0";
1335 /* append the "Turbo" string variable to the existing opts string.
1336 Note: the "Turbo" string must be appended, not prepended to work properly*/
1337 NSString *firstPassOptStringCombined = [[fDisplayX264Options stringValue] stringByAppendingString:firstPassOptStringTurbo];
1338 strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
1342 strcpy(job->x264opts, [[fDisplayX264Options stringValue] UTF8String]);
1345 job->h264_13 = [fVidEncoderPopUp indexOfSelectedItem];
1348 /* Video settings */
1349 if( [fVidRatePopUp indexOfSelectedItem] > 0 )
1351 job->vrate = 27000000;
1352 job->vrate_base = hb_video_rates[[fVidRatePopUp
1353 indexOfSelectedItem]-1].rate;
1357 job->vrate = title->rate;
1358 job->vrate_base = title->rate_base;
1361 switch( [fVidQualityMatrix selectedRow] )
1365 Bitrate should already have been calculated and displayed
1366 in fVidBitrateField, so let's just use it */
1368 job->vquality = -1.0;
1369 job->vbitrate = [fVidBitrateField intValue];
1372 job->vquality = [fVidQualitySlider floatValue];
1377 job->grayscale = ( [fVidGrayscaleCheck state] == NSOnState );
1381 /* Subtitle settings */
1382 job->subtitle = [fSubPopUp indexOfSelectedItem] - 1;
1384 /* Audio tracks and mixdowns */
1385 /* check for the condition where track 2 has an audio selected, but track 1 does not */
1386 /* we will use track 2 as track 1 in this scenario */
1387 if ([fAudLang1PopUp indexOfSelectedItem] > 0)
1389 job->audios[0] = [fAudLang1PopUp indexOfSelectedItem] - 1;
1390 job->audios[1] = [fAudLang2PopUp indexOfSelectedItem] - 1; /* will be -1 if "none" is selected */
1391 job->audios[2] = -1;
1392 job->audio_mixdowns[0] = [[fAudTrack1MixPopUp selectedItem] tag];
1393 job->audio_mixdowns[1] = [[fAudTrack2MixPopUp selectedItem] tag];
1395 else if ([fAudLang2PopUp indexOfSelectedItem] > 0)
1397 job->audios[0] = [fAudLang2PopUp indexOfSelectedItem] - 1;
1398 job->audio_mixdowns[0] = [[fAudTrack2MixPopUp selectedItem] tag];
1399 job->audios[1] = -1;
1403 job->audios[0] = -1;
1406 /* Audio settings */
1407 job->arate = hb_audio_rates[[fAudRatePopUp
1408 indexOfSelectedItem]].rate;
1409 job->abitrate = [[fAudBitratePopUp selectedItem] tag];
1411 /* TODO: Filter settings */
1414 hb_list_close( &job->filters );
1416 job->filters = hb_list_init();
1419 if ([[fPicSettingDetelecine stringValue] isEqualToString: @"Yes"])
1421 hb_list_add( job->filters, &hb_filter_detelecine );
1425 if( job->deinterlace == 1)
1427 if ([fPicSettingDeinterlace intValue] == 1)
1429 /* Run old deinterlacer by default */
1430 hb_filter_deinterlace.settings = "-1";
1431 hb_list_add( job->filters, &hb_filter_deinterlace );
1433 if ([fPicSettingDeinterlace intValue] == 2)
1435 /* Yadif mode 0 (1-pass with spatial deinterlacing.) */
1436 hb_filter_deinterlace.settings = "0";
1437 hb_list_add( job->filters, &hb_filter_deinterlace );
1439 if ([fPicSettingDeinterlace intValue] == 3)
1441 /* Yadif (1-pass w/o spatial deinterlacing) and Mcdeint */
1442 hb_filter_deinterlace.settings = "2:-1:1";
1443 hb_list_add( job->filters, &hb_filter_deinterlace );
1445 if ([fPicSettingDeinterlace intValue] == 4)
1447 /* Yadif (2-pass w/ spatial deinterlacing) and Mcdeint*/
1448 hb_filter_deinterlace.settings = "1:-1:1";
1449 hb_list_add( job->filters, &hb_filter_deinterlace );
1455 if ([fPicSettingDenoise intValue] == 1) // Weak in popup
1457 hb_filter_denoise.settings = "2:1:2:3";
1458 hb_list_add( job->filters, &hb_filter_denoise );
1460 else if ([fPicSettingDenoise intValue] == 2) // Medium in popup
1462 hb_filter_denoise.settings = "3:2:2:3";
1463 hb_list_add( job->filters, &hb_filter_denoise );
1465 else if ([fPicSettingDenoise intValue] == 3) // Strong in popup
1467 hb_filter_denoise.settings = "7:7:5:5";
1468 hb_list_add( job->filters, &hb_filter_denoise );
1475 - (IBAction) AddToQueue: (id) sender
1477 /* We get the destination directory from the destingation field here */
1478 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1479 /* We check for a valid destination here */
1480 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1482 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1487 hb_list_t * list = hb_get_titles( fHandle );
1488 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1489 [fSrcTitlePopUp indexOfSelectedItem] );
1490 hb_job_t * job = title->job;
1494 /* Destination file */
1495 job->file = [[fDstFile2Field stringValue] UTF8String];
1497 if( [fVidTwoPassCheck state] == NSOnState )
1500 hb_add( fHandle, job );
1503 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1504 strcpy(job->x264opts, [[fDisplayX264Options stringValue] UTF8String]);
1506 hb_add( fHandle, job );
1511 hb_add( fHandle, job );
1514 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1515 /* Lets try to update stuff, taken from remove in the queue controller */
1516 [fQueueController performSelectorOnMainThread: @selector( Update: )
1517 withObject: sender waitUntilDone: NO];
1521 - (IBAction) Rip: (id) sender
1523 /* Rip or Cancel ? */
1524 // if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )
1527 [self Cancel: sender];
1530 /* if there is no job in the queue, then add it to the queue and rip
1531 otherwise, there are already jobs in queue, so just rip the queue */
1532 int count = hb_count( fHandle );
1535 [self AddToQueue: sender];
1538 /* We check for duplicate name here */
1539 if( [[NSFileManager defaultManager] fileExistsAtPath:
1540 [fDstFile2Field stringValue]] )
1542 NSBeginCriticalAlertSheet( _( @"File already exists" ),
1543 _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
1544 @selector( OverwriteAlertDone:returnCode:contextInfo: ),
1545 NULL, NULL, [NSString stringWithFormat:
1546 _( @"Do you want to overwrite %@?" ),
1547 [fDstFile2Field stringValue]] );
1550 /* We get the destination directory from the destination field here */
1551 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1552 /* We check for a valid destination here */
1553 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1555 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1559 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1567 - (void) OverwriteAlertDone: (NSWindow *) sheet
1568 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1570 if( returnCode == NSAlertAlternateReturn )
1576 - (void) UpdateAlertDone: (NSWindow *) sheet
1577 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1579 if( returnCode == NSAlertAlternateReturn )
1581 /* Show scan panel */
1582 [self performSelectorOnMainThread: @selector(ShowScanPanel:)
1583 withObject: NULL waitUntilDone: NO];
1587 /* Go to HandBrake homepage and exit */
1588 [self OpenHomepage: NULL];
1589 [NSApp terminate: self];
1594 /* Let libhb do the job */
1595 hb_start( fHandle );
1596 /*set the fEncodeState State */
1599 /* Disable interface */
1600 //[self EnableUI: NO];
1601 // [fPauseButton setEnabled: NO];
1602 // [fRipButton setEnabled: NO];
1603 pauseButtonEnabled = NO;
1604 startButtonEnabled = NO;
1605 NSRect frame = [fWindow frame];
1606 if (frame.size.width <= 591)
1607 frame.size.width = 591;
1608 frame.size.height += 44;
1609 frame.origin.y -= 44;
1610 [fWindow setFrame:frame display:YES animate:YES];
1613 - (IBAction) Cancel: (id) sender
1615 NSBeginCriticalAlertSheet( _( @"Cancel - Are you sure?" ),
1616 _( @"Keep working" ), _( @"Cancel encoding" ), NULL, fWindow, self,
1617 @selector( _Cancel:returnCode:contextInfo: ), NULL, NULL,
1618 _( @"Encoding won't be recoverable." ) );
1621 - (void) _Cancel: (NSWindow *) sheet
1622 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1624 if( returnCode == NSAlertAlternateReturn )
1627 // [fPauseButton setEnabled: NO];
1628 // [fRipButton setEnabled: NO];
1629 pauseButtonEnabled = NO;
1630 startButtonEnabled = NO;
1631 /*set the fEncodeState State */
1636 - (IBAction) Pause: (id) sender
1638 // [fPauseButton setEnabled: NO];
1639 // [fRipButton setEnabled: NO];
1641 // if( [[fPauseButton title] isEqualToString: _( @"Resume" )] )
1642 pauseButtonEnabled = NO;
1643 startButtonEnabled = NO;
1647 hb_resume( fHandle );
1651 hb_pause( fHandle );
1655 - (IBAction) TitlePopUpChanged: (id) sender
1657 hb_list_t * list = hb_get_titles( fHandle );
1658 hb_title_t * title = (hb_title_t*)
1659 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1662 /* If Auto Naming is on. We create an output filename of dvd name - title number */
1663 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0)
1665 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1666 @"%@/%@-%d.%@", [[fDstFile2Field stringValue] stringByDeletingLastPathComponent],
1667 [NSString stringWithUTF8String: title->name],
1668 [fSrcTitlePopUp indexOfSelectedItem] + 1,
1669 [[fDstFile2Field stringValue] pathExtension]]];
1672 /* Update chapter popups */
1673 [fSrcChapterStartPopUp removeAllItems];
1674 [fSrcChapterEndPopUp removeAllItems];
1675 for( int i = 0; i < hb_list_count( title->list_chapter ); i++ )
1677 [fSrcChapterStartPopUp addItemWithTitle: [NSString
1678 stringWithFormat: @"%d", i + 1]];
1679 [fSrcChapterEndPopUp addItemWithTitle: [NSString
1680 stringWithFormat: @"%d", i + 1]];
1682 [fSrcChapterStartPopUp selectItemAtIndex: 0];
1683 [fSrcChapterEndPopUp selectItemAtIndex:
1684 hb_list_count( title->list_chapter ) - 1];
1685 [self ChapterPopUpChanged: NULL];
1687 /* Start Get and set the initial pic size for display */
1688 hb_job_t * job = title->job;
1690 /* Turn Deinterlace on/off depending on the preference */
1691 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultDeinterlaceOn"] > 0)
1693 job->deinterlace = 1;
1697 job->deinterlace = 0;
1700 /* Pixel Ratio Setting */
1701 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PixelRatio"])
1704 job->pixel_ratio = 1 ;
1708 job->pixel_ratio = 0 ;
1710 /*Set Source Size Fields Here */
1711 [fPicSrcWidth setStringValue: [NSString stringWithFormat:
1712 @"%d", fTitle->width]];
1713 [fPicSrcHeight setStringValue: [NSString stringWithFormat:
1714 @"%d", fTitle->height]];
1716 /* We get the originial output picture width and height and put them
1717 in variables for use with some presets later on */
1718 PicOrigOutputWidth = job->width;
1719 PicOrigOutputHeight = job->height;
1720 AutoCropTop = job->crop[0];
1721 AutoCropBottom = job->crop[1];
1722 AutoCropLeft = job->crop[2];
1723 AutoCropRight = job->crop[3];
1724 /* we test getting the max output value for pic sizing here to be used later*/
1725 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
1726 @"%d", PicOrigOutputWidth]];
1727 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
1728 @"%d", PicOrigOutputHeight]];
1729 /* we run the picture size values through
1730 CalculatePictureSizing to get all picture size
1732 [self CalculatePictureSizing: NULL];
1733 /* Run Through EncoderPopUpChanged to see if there
1734 needs to be any pic value modifications based on encoder settings */
1735 //[self EncoderPopUpChanged: NULL];
1736 /* END Get and set the initial pic size for display */
1738 /* Update subtitle popups */
1739 hb_subtitle_t * subtitle;
1740 [fSubPopUp removeAllItems];
1741 [fSubPopUp addItemWithTitle: @"None"];
1742 for( int i = 0; i < hb_list_count( title->list_subtitle ); i++ )
1744 subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle, i );
1746 /* We cannot use NSPopUpButton's addItemWithTitle because
1747 it checks for duplicate entries */
1748 [[fSubPopUp menu] addItemWithTitle: [NSString stringWithCString:
1749 subtitle->lang] action: NULL keyEquivalent: @""];
1751 [fSubPopUp selectItemAtIndex: 0];
1753 /* Update chapter table */
1754 [fChapterTitlesDelegate resetWithTitle:title];
1755 [fChapterTable reloadData];
1757 /* Update audio popups */
1758 [self AddAllAudioTracksToPopUp: fAudLang1PopUp];
1759 [self AddAllAudioTracksToPopUp: fAudLang2PopUp];
1760 /* search for the first instance of our prefs default language for track 1, and set track 2 to "none" */
1761 NSString * audioSearchPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"];
1762 [self SelectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1];
1763 [self SelectAudioTrackInPopUp: fAudLang2PopUp searchPrefixString: NULL selectIndexIfNotFound: 0];
1765 /* changing the title may have changed the audio channels on offer, */
1766 /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
1767 [self AudioTrackPopUpChanged: fAudLang1PopUp];
1768 [self AudioTrackPopUpChanged: fAudLang2PopUp];
1769 /* lets call tableViewSelected to make sure that any preset we have selected is enforced after a title change */
1770 [self tableViewSelected:NULL];
1773 - (IBAction) ChapterPopUpChanged: (id) sender
1776 /* If start chapter popup is greater than end chapter popup,
1777 we set the end chapter popup to the same as start chapter popup */
1778 if ([fSrcChapterStartPopUp indexOfSelectedItem] > [fSrcChapterEndPopUp indexOfSelectedItem])
1780 [fSrcChapterEndPopUp selectItemAtIndex: [fSrcChapterStartPopUp indexOfSelectedItem]];
1785 hb_list_t * list = hb_get_titles( fHandle );
1786 hb_title_t * title = (hb_title_t *)
1787 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1789 hb_chapter_t * chapter;
1790 int64_t duration = 0;
1791 for( int i = [fSrcChapterStartPopUp indexOfSelectedItem];
1792 i <= [fSrcChapterEndPopUp indexOfSelectedItem]; i++ )
1794 chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
1795 duration += chapter->duration;
1798 duration /= 90000; /* pts -> seconds */
1799 [fSrcDuration2Field setStringValue: [NSString stringWithFormat:
1800 @"%02lld:%02lld:%02lld", duration / 3600, ( duration / 60 ) % 60,
1803 [self CalculateBitrate: sender];
1806 - (IBAction) FormatPopUpChanged: (id) sender
1808 NSString * string = [fDstFile2Field stringValue];
1809 int format = [fDstFormatPopUp indexOfSelectedItem];
1811 /* Initially set the large file (64 bit formatting) output checkbox to hidden */
1812 [fDstMpgLargeFileCheck setHidden: YES];
1813 /* Update the codecs popup */
1814 [fDstCodecsPopUp removeAllItems];
1818 /*Get Default MP4 File Extension*/
1819 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
1827 [fDstCodecsPopUp addItemWithTitle:
1828 _( @"MPEG-4 Video / AAC Audio" )];
1829 [fDstCodecsPopUp addItemWithTitle:
1830 _( @"AVC/H.264 Video / AAC Audio" )];
1831 /* We enable the create chapters checkbox here since we are .mp4*/
1832 [fCreateChapterMarkers setEnabled: YES];
1833 /* We show the Large File (64 bit formatting) checkbox since we are .mp4
1834 if we have enabled the option in the global preferences*/
1835 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0)
1837 [fDstMpgLargeFileCheck setHidden: NO];
1841 /* if not enable in global preferences, we additionaly sanity check that the
1842 hidden checkbox is set to off. */
1843 [fDstMpgLargeFileCheck setState: NSOffState];
1848 [fDstCodecsPopUp addItemWithTitle:
1849 _( @"MPEG-4 Video / MP3 Audio" )];
1850 [fDstCodecsPopUp addItemWithTitle:
1851 _( @"MPEG-4 Video / AC-3 Audio" )];
1852 [fDstCodecsPopUp addItemWithTitle:
1853 _( @"AVC/H.264 Video / MP3 Audio" )];
1854 [fDstCodecsPopUp addItemWithTitle:
1855 _( @"AVC/H.264 Video / AC-3 Audio" )];
1856 /* We disable the create chapters checkbox here since we are NOT .mp4
1857 and make sure it is unchecked*/
1858 [fCreateChapterMarkers setEnabled: NO];
1859 [fCreateChapterMarkers setState: NSOffState];
1863 [fDstCodecsPopUp addItemWithTitle:
1864 _( @"MPEG-4 Video / Vorbis Audio" )];
1865 [fDstCodecsPopUp addItemWithTitle:
1866 _( @"MPEG-4 Video / MP3 Audio" )];
1867 /* We disable the create chapters checkbox here since we are NOT .mp4
1868 and make sure it is unchecked*/
1869 [fCreateChapterMarkers setEnabled: NO];
1870 [fCreateChapterMarkers setState: NSOffState];
1874 [fDstCodecsPopUp addItemWithTitle:
1875 _( @"MPEG-4 Video / AAC Audio" )];
1876 [fDstCodecsPopUp addItemWithTitle:
1877 _( @"MPEG-4 Video / AC-3 Audio" )];
1878 [fDstCodecsPopUp addItemWithTitle:
1879 _( @"MPEG-4 Video / MP3 Audio" )];
1880 [fDstCodecsPopUp addItemWithTitle:
1881 _( @"MPEG-4 Video / Vorbis Audio" )];
1883 [fDstCodecsPopUp addItemWithTitle:
1884 _( @"AVC/H.264 Video / AAC Audio" )];
1885 [fDstCodecsPopUp addItemWithTitle:
1886 _( @"AVC/H.264 Video / AC-3 Audio" )];
1887 [fDstCodecsPopUp addItemWithTitle:
1888 _( @"AVC/H.264 Video / MP3 Audio" )];
1889 [fDstCodecsPopUp addItemWithTitle:
1890 _( @"AVC/H.264 Video / Vorbis Audio" )];
1891 /* We disable the create chapters checkbox here since we are NOT .mp4
1892 and make sure it is unchecked*/
1893 [fCreateChapterMarkers setEnabled: YES];
1896 [self CodecsPopUpChanged: NULL];
1898 /* Add/replace to the correct extension */
1899 if( [string characterAtIndex: [string length] - 4] == '.' )
1901 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1902 @"%@.%s", [string substringToIndex: [string length] - 4],
1907 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1908 @"%@.%s", string, ext]];
1911 /* changing the format may mean that we can / can't offer mono or 6ch, */
1912 /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
1913 [self AudioTrackPopUpChanged: fAudLang1PopUp];
1914 [self AudioTrackPopUpChanged: fAudLang2PopUp];
1915 /* We call the method to properly enable/disable turbo 2 pass */
1916 [self TwoPassCheckboxChanged: sender];
1917 /* We call method method to change UI to reflect whether a preset is used or not*/
1918 [self CustomSettingUsed: sender];
1922 - (IBAction) CodecsPopUpChanged: (id) sender
1924 int format = [fDstFormatPopUp indexOfSelectedItem];
1925 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1926 [fX264optView setHidden: YES];
1927 [fX264optViewTitleLabel setStringValue: @"Only Used With The x264 (H.264) Codec"];
1930 /* Update the encoder popup*/
1931 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
1933 /* MPEG-4 -> H.264 */
1934 [fVidEncoderPopUp removeAllItems];
1935 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 Main)"];
1936 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 iPod)"];
1937 [fVidEncoderPopUp selectItemAtIndex: 0];
1938 [fX264optView setHidden: NO];
1939 [fX264optViewTitleLabel setStringValue: @""];
1944 else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) )
1946 /* H.264 -> MPEG-4 */
1947 [fVidEncoderPopUp removeAllItems];
1948 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
1949 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
1950 [fVidEncoderPopUp selectItemAtIndex: 0];
1954 if( FormatSettings[format][codecs] & HB_ACODEC_AC3 )
1956 /* AC-3 pass-through: disable samplerate and bitrate */
1957 [fAudRatePopUp setEnabled: NO];
1958 [fAudBitratePopUp setEnabled: NO];
1962 [fAudRatePopUp setEnabled: YES];
1963 [fAudBitratePopUp setEnabled: YES];
1965 /* changing the codecs on offer may mean that we can / can't offer mono or 6ch, */
1966 /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
1967 [self AudioTrackPopUpChanged: fAudLang1PopUp];
1968 [self AudioTrackPopUpChanged: fAudLang2PopUp];
1970 [self CalculateBitrate: sender];
1971 [self TwoPassCheckboxChanged: sender];
1974 - (IBAction) EncoderPopUpChanged: (id) sender
1977 /* Check to see if we need to modify the job pic values based on x264 (iPod) encoder selection */
1978 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [fDstCodecsPopUp indexOfSelectedItem] == 1 && [fVidEncoderPopUp indexOfSelectedItem] == 1)
1980 hb_job_t * job = fTitle->job;
1981 job->pixel_ratio = 0 ;
1983 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPicSizeAutoiPod"] > 0)
1986 if (job->width > 640)
1990 job->keep_ratio = 1;
1991 hb_fix_aspect( job, HB_KEEP_WIDTH );
1994 /* Make sure the 64bit formatting checkbox is off */
1995 [fDstMpgLargeFileCheck setState: NSOffState];
1998 [self CalculatePictureSizing: sender];
1999 [self TwoPassCheckboxChanged: sender];
2002 - (IBAction) TwoPassCheckboxChanged: (id) sender
2004 /* check to see if x264 is chosen */
2005 int format = [fDstFormatPopUp indexOfSelectedItem];
2006 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2007 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
2009 if( [fVidTwoPassCheck state] == NSOnState)
2011 [fVidTurboPassCheck setHidden: NO];
2015 [fVidTurboPassCheck setHidden: YES];
2016 [fVidTurboPassCheck setState: NSOffState];
2018 /* Make sure Two Pass is checked if Turbo is checked */
2019 if( [fVidTurboPassCheck state] == NSOnState)
2021 [fVidTwoPassCheck setState: NSOnState];
2026 [fVidTurboPassCheck setHidden: YES];
2027 [fVidTurboPassCheck setState: NSOffState];
2030 /* We call method method to change UI to reflect whether a preset is used or not*/
2031 [self CustomSettingUsed: sender];
2034 - (IBAction ) VideoFrameRateChanged: (id) sender
2036 /* We call method method to CalculatePictureSizing to error check detelecine*/
2037 [self CalculatePictureSizing: sender];
2039 /* We call method method to change UI to reflect whether a preset is used or not*/
2040 [self CustomSettingUsed: sender];
2043 - (IBAction) SetEnabledStateOfAudioMixdownControls: (id) sender
2046 /* enable/disable the mixdown text and popupbutton for audio track 1 */
2047 [fAudTrack1MixPopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
2048 [fAudTrack1MixLabel setTextColor: ([fAudLang1PopUp indexOfSelectedItem] == 0) ?
2049 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2051 /* enable/disable the mixdown text and popupbutton for audio track 2 */
2052 [fAudTrack2MixPopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
2053 [fAudTrack2MixLabel setTextColor: ([fAudLang2PopUp indexOfSelectedItem] == 0) ?
2054 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2058 - (IBAction) AddAllAudioTracksToPopUp: (id) sender
2061 hb_list_t * list = hb_get_titles( fHandle );
2062 hb_title_t * title = (hb_title_t*)
2063 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
2067 [sender removeAllItems];
2068 [sender addItemWithTitle: _( @"None" )];
2069 for( int i = 0; i < hb_list_count( title->list_audio ); i++ )
2071 audio = (hb_audio_t *) hb_list_item( title->list_audio, i );
2072 [[sender menu] addItemWithTitle:
2073 [NSString stringWithCString: audio->lang]
2074 action: NULL keyEquivalent: @""];
2076 [sender selectItemAtIndex: 0];
2080 - (IBAction) SelectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound
2083 /* this method can be used to find a language, or a language-and-source-format combination, by passing in the appropriate string */
2084 /* e.g. to find the first French track, pass in an NSString * of "Francais" */
2085 /* e.g. to find the first English 5.1 AC3 track, pass in an NSString * of "English (AC3) (5.1 ch)" */
2086 /* if no matching track is found, then selectIndexIfNotFound is used to choose which track to select instead */
2088 if (searchPrefixString != NULL)
2091 for( int i = 0; i < [sender numberOfItems]; i++ )
2093 /* Try to find the desired search string */
2094 if ([[[sender itemAtIndex: i] title] hasPrefix:searchPrefixString])
2096 [sender selectItemAtIndex: i];
2100 /* couldn't find the string, so select the requested "search string not found" item */
2101 /* index of 0 means select the "none" item */
2102 /* index of 1 means select the first audio track */
2103 [sender selectItemAtIndex: selectIndexIfNotFound];
2107 /* if no search string is provided, then select the selectIndexIfNotFound item */
2108 [sender selectItemAtIndex: selectIndexIfNotFound];
2113 - (IBAction) AudioTrackPopUpChanged: (id) sender
2115 /* utility function to call AudioTrackPopUpChanged without passing in a mixdown-to-use */
2116 [self AudioTrackPopUpChanged: sender mixdownToUse: 0];
2119 - (IBAction) AudioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse
2122 /* make sure we have a selected title before continuing */
2123 if (fTitle == NULL) return;
2125 /* find out if audio track 1 or 2 was changed - this is passed to us in the tag of the sender */
2126 /* the sender will have been either fAudLang1PopUp (tag = 0) or fAudLang2PopUp (tag = 1) */
2127 int thisAudio = [sender tag];
2129 /* get the index of the selected audio */
2130 int thisAudioIndex = [sender indexOfSelectedItem] - 1;
2132 /* Handbrake can't currently cope with ripping the same source track twice */
2133 /* So, if this audio is also selected in the other audio track popup, set that popup's selection to "none" */
2134 /* get a reference to the two audio track popups */
2135 NSPopUpButton * thisAudioPopUp = (thisAudio == 1 ? fAudLang2PopUp : fAudLang1PopUp);
2136 NSPopUpButton * otherAudioPopUp = (thisAudio == 1 ? fAudLang1PopUp : fAudLang2PopUp);
2137 /* if the same track is selected in the other audio popup, then select "none" in that popup */
2138 /* unless, of course, both are selected as "none!" */
2139 if ([thisAudioPopUp indexOfSelectedItem] != 0 && [thisAudioPopUp indexOfSelectedItem] == [otherAudioPopUp indexOfSelectedItem]) {
2140 [otherAudioPopUp selectItemAtIndex: 0];
2141 [self AudioTrackPopUpChanged: otherAudioPopUp];
2144 /* pointer for the hb_audio_s struct we will use later on */
2147 /* find out what the currently-selected output audio codec is */
2148 int format = [fDstFormatPopUp indexOfSelectedItem];
2149 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2150 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2152 /* pointer to this track's mixdown NSPopUpButton */
2153 NSTextField * mixdownTextField;
2154 NSPopUpButton * mixdownPopUp;
2156 /* find our mixdown NSTextField and NSPopUpButton */
2159 mixdownTextField = fAudTrack1MixLabel;
2160 mixdownPopUp = fAudTrack1MixPopUp;
2164 mixdownTextField = fAudTrack2MixLabel;
2165 mixdownPopUp = fAudTrack2MixPopUp;
2168 /* delete the previous audio mixdown options */
2169 [mixdownPopUp removeAllItems];
2171 /* check if the audio mixdown controls need their enabled state changing */
2172 [self SetEnabledStateOfAudioMixdownControls: NULL];
2174 if (thisAudioIndex != -1)
2178 audio = (hb_audio_t *) hb_list_item( fTitle->list_audio, thisAudioIndex );
2182 /* find out if our selected output audio codec supports mono and / or 6ch */
2183 /* we also check for an input codec of AC3 or DCA,
2184 as they are the only libraries able to do the mixdown to mono / conversion to 6-ch */
2185 /* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
2186 but this may change in the future, so they are separated for flexibility */
2187 int audioCodecsSupportMono = ((audio->codec == HB_ACODEC_AC3 ||
2188 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2189 int audioCodecsSupport6Ch = ((audio->codec == HB_ACODEC_AC3 ||
2190 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2192 /* check for AC-3 passthru */
2193 if (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
2195 [[mixdownPopUp menu] addItemWithTitle:
2196 [NSString stringWithCString: "AC3 Passthru"]
2197 action: NULL keyEquivalent: @""];
2202 /* add the appropriate audio mixdown menuitems to the popupbutton */
2203 /* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
2204 so that we can reference the mixdown later */
2206 /* keep a track of the min and max mixdowns we used, so we can select the best match later */
2207 int minMixdownUsed = 0;
2208 int maxMixdownUsed = 0;
2210 /* get the input channel layout without any lfe channels */
2211 int layout = audio->input_channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
2213 /* do we want to add a mono option? */
2214 if (audioCodecsSupportMono == 1) {
2215 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2216 [NSString stringWithCString: hb_audio_mixdowns[0].human_readable_name]
2217 action: NULL keyEquivalent: @""];
2218 [menuItem setTag: hb_audio_mixdowns[0].amixdown];
2219 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[0].amixdown;
2220 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[0].amixdown);
2223 /* do we want to add a stereo option? */
2224 /* offer stereo if we have a mono source and non-mono-supporting codecs, as otherwise we won't have a mixdown at all */
2225 /* also offer stereo if we have a stereo-or-better source */
2226 if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO) {
2227 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2228 [NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name]
2229 action: NULL keyEquivalent: @""];
2230 [menuItem setTag: hb_audio_mixdowns[1].amixdown];
2231 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[1].amixdown;
2232 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[1].amixdown);
2235 /* do we want to add a dolby surround (DPL1) option? */
2236 if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY) {
2237 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2238 [NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name]
2239 action: NULL keyEquivalent: @""];
2240 [menuItem setTag: hb_audio_mixdowns[2].amixdown];
2241 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[2].amixdown;
2242 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[2].amixdown);
2245 /* do we want to add a dolby pro logic 2 (DPL2) option? */
2246 if (layout == HB_INPUT_CH_LAYOUT_3F2R) {
2247 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2248 [NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name]
2249 action: NULL keyEquivalent: @""];
2250 [menuItem setTag: hb_audio_mixdowns[3].amixdown];
2251 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[3].amixdown;
2252 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[3].amixdown);
2255 /* do we want to add a 6-channel discrete option? */
2256 if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE)) {
2257 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2258 [NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name]
2259 action: NULL keyEquivalent: @""];
2260 [menuItem setTag: hb_audio_mixdowns[4].amixdown];
2261 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[4].amixdown;
2262 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[4].amixdown);
2265 /* auto-select the best mixdown based on our saved mixdown preference */
2267 /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
2268 /* ultimately this should be a prefs option */
2271 /* if we passed in a mixdown to use - in order to load a preset - then try and use it */
2272 if (mixdownToUse > 0)
2274 useMixdown = mixdownToUse;
2278 useMixdown = HB_AMIXDOWN_DOLBYPLII;
2281 /* if useMixdown > maxMixdownUsed, then use maxMixdownUsed */
2282 if (useMixdown > maxMixdownUsed) useMixdown = maxMixdownUsed;
2284 /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
2285 if (useMixdown < minMixdownUsed) useMixdown = minMixdownUsed;
2287 /* select the (possibly-amended) preferred mixdown */
2288 [mixdownPopUp selectItemWithTag: useMixdown];
2290 /* lets call the AudioTrackMixdownChanged method here to determine appropriate bitrates, etc. */
2291 [self AudioTrackMixdownChanged: NULL];
2298 /* see if the new audio track choice will change the bitrate we need */
2299 [self CalculateBitrate: sender];
2302 - (IBAction) AudioTrackMixdownChanged: (id) sender
2305 /* find out what the currently-selected output audio codec is */
2306 int format = [fDstFormatPopUp indexOfSelectedItem];
2307 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2308 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2310 /* storage variable for the min and max bitrate allowed for this codec */
2316 case HB_ACODEC_FAAC:
2317 /* check if we have a 6ch discrete conversion in either audio track */
2318 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2320 /* FAAC is happy using our min bitrate of 32 kbps, even for 6ch */
2322 /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
2328 /* FAAC is happy using our min bitrate of 32 kbps for stereo or mono */
2330 /* FAAC won't honour anything more than 160 for stereo, so let's not offer it */
2331 /* note: haven't dealt with mono separately here, FAAC will just use the max it can */
2336 case HB_ACODEC_LAME:
2337 /* Lame is happy using our min bitrate of 32 kbps */
2339 /* Lame won't encode if the bitrate is higher than 320 kbps */
2343 case HB_ACODEC_VORBIS:
2344 /* Vorbis causes a crash if we use a bitrate below 48 kbps */
2346 /* Vorbis can cope with 384 kbps quite happily, even for stereo */
2351 /* AC3 passthru disables the bitrate dropdown anyway, so we might as well just use the min and max bitrate */
2357 [fAudBitratePopUp removeAllItems];
2359 for( int i = 0; i < hb_audio_bitrates_count; i++ )
2361 if (hb_audio_bitrates[i].rate >= minbitrate && hb_audio_bitrates[i].rate <= maxbitrate)
2363 /* add a new menuitem for this bitrate */
2364 id<NSMenuItem> menuItem = [[fAudBitratePopUp menu] addItemWithTitle:
2365 [NSString stringWithCString: hb_audio_bitrates[i].string]
2366 action: NULL keyEquivalent: @""];
2367 /* set its tag to be the actual bitrate as an integer, so we can retrieve it later */
2368 [menuItem setTag: hb_audio_bitrates[i].rate];
2372 /* select the default bitrate (but use 384 for 6-ch AAC) */
2373 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2375 [fAudBitratePopUp selectItemWithTag: 384];
2379 [fAudBitratePopUp selectItemWithTag: hb_audio_bitrates[hb_audio_bitrates_default].rate];
2383 /* lets set the picture size back to the max from right after title scan
2384 Lets use an IBAction here as down the road we could always use a checkbox
2385 in the gui to easily take the user back to max. Remember, the compiler
2386 resolves IBActions down to -(void) during compile anyway */
2387 - (IBAction) RevertPictureSizeToMax: (id) sender
2389 hb_job_t * job = fTitle->job;
2390 /* We use the output picture width and height
2391 as calculated from libhb right after title is set
2392 in TitlePopUpChanged */
2393 job->width = PicOrigOutputWidth;
2394 job->height = PicOrigOutputHeight;
2395 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
2397 /* Here we use the auto crop values determined right after scan */
2398 job->crop[0] = AutoCropTop;
2399 job->crop[1] = AutoCropBottom;
2400 job->crop[2] = AutoCropLeft;
2401 job->crop[3] = AutoCropRight;
2404 [self CalculatePictureSizing: sender];
2405 /* We call method method to change UI to reflect whether a preset is used or not*/
2406 [self CustomSettingUsed: sender];
2410 /* Get and Display Current Pic Settings in main window */
2411 - (IBAction) CalculatePictureSizing: (id) sender
2415 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
2416 @"%d", fTitle->job->width]];
2417 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
2418 @"%d", fTitle->job->height]];
2419 [fPicSettingARkeep setStringValue: [NSString stringWithFormat:
2420 @"%d", fTitle->job->keep_ratio]];
2421 //[fPicSettingDeinterlace setStringValue: [NSString stringWithFormat:
2422 // @"%d", fTitle->job->deinterlace]];
2423 [fPicSettingPAR setStringValue: [NSString stringWithFormat:
2424 @"%d", fTitle->job->pixel_ratio]];
2426 if (fTitle->job->pixel_ratio == 1)
2428 int titlewidth = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
2429 int arpwidth = fTitle->job->pixel_aspect_width;
2430 int arpheight = fTitle->job->pixel_aspect_height;
2431 int displayparwidth = titlewidth * arpwidth / arpheight;
2432 int displayparheight = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
2433 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
2434 @"%d", titlewidth]];
2435 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
2436 @"%d", displayparheight]];
2437 [fPicLabelPAROutp setStringValue: @"Anamorphic Output:"];
2438 [fPicLabelPAROutputX setStringValue: @"x"];
2439 [fPicSettingPARWidth setStringValue: [NSString stringWithFormat:
2440 @"%d", displayparwidth]];
2441 [fPicSettingPARHeight setStringValue: [NSString stringWithFormat:
2442 @"%d", displayparheight]];
2444 fTitle->job->keep_ratio = 0;
2448 [fPicLabelPAROutp setStringValue: @""];
2449 [fPicLabelPAROutputX setStringValue: @""];
2450 [fPicSettingPARWidth setStringValue: @""];
2451 [fPicSettingPARHeight setStringValue: @""];
2453 if ([fPicSettingDeinterlace intValue] == 0)
2455 fTitle->job->deinterlace = 0;
2459 fTitle->job->deinterlace = 1;
2463 /* Set ON/Off values for the deinterlace/keep aspect ratio according to boolean */
2464 if (fTitle->job->keep_ratio > 0)
2466 [fPicSettingARkeepDsply setStringValue: @"On"];
2470 [fPicSettingARkeepDsply setStringValue: @"Off"];
2473 if ([fPicSettingDeinterlace intValue] == 0)
2475 [fPicSettingDeinterlaceDsply setStringValue: @"Off"];
2477 else if ([fPicSettingDeinterlace intValue] == 1)
2479 [fPicSettingDeinterlaceDsply setStringValue: @"Fast"];
2481 else if ([fPicSettingDeinterlace intValue] == 2)
2483 [fPicSettingDeinterlaceDsply setStringValue: @"Slow"];
2485 else if ([fPicSettingDeinterlace intValue] == 3)
2487 [fPicSettingDeinterlaceDsply setStringValue: @"Slower"];
2489 else if ([fPicSettingDeinterlace intValue] == 4)
2491 [fPicSettingDeinterlaceDsply setStringValue: @"Slowest"];
2494 if ([fPicSettingDenoise intValue] == 0)
2496 [fPicSettingDenoiseDsply setStringValue: @"Off"];
2498 else if ([fPicSettingDenoise intValue] == 1)
2500 [fPicSettingDenoiseDsply setStringValue: @"Weak"];
2502 else if ([fPicSettingDenoise intValue] == 2)
2504 [fPicSettingDenoiseDsply setStringValue: @"Medium"];
2506 else if ([fPicSettingDenoise intValue] == 3)
2508 [fPicSettingDenoiseDsply setStringValue: @"Strong"];
2511 if (fTitle->job->pixel_ratio > 0)
2513 [fPicSettingPARDsply setStringValue: @"On"];
2517 [fPicSettingPARDsply setStringValue: @"Off"];
2519 /* Set the display field for crop as per boolean */
2520 if ([[fPicSettingAutoCrop stringValue] isEqualToString: @"0"])
2522 [fPicSettingAutoCropDsply setStringValue: @"Custom"];
2526 [fPicSettingAutoCropDsply setStringValue: @"Auto"];
2528 /* check video framerate and turn off detelecine if necessary */
2529 if (fTitle->rate_base == 1126125 || [[fVidRatePopUp titleOfSelectedItem] isEqualToString: @"23.976 (NTSC Film)"])
2531 [fPicSettingDetelecine setStringValue: @"No"];
2536 /* below will trigger the preset, if selected, to be
2537 changed to "Custom". Lets comment out for now until
2538 we figure out a way to determine if the picture values
2539 changed modify the preset values */
2540 //[self CustomSettingUsed: sender];
2543 - (IBAction) CalculateBitrate: (id) sender
2545 if( !fHandle || [fVidQualityMatrix selectedRow] != 0 )
2550 hb_list_t * list = hb_get_titles( fHandle );
2551 hb_title_t * title = (hb_title_t *) hb_list_item( list,
2552 [fSrcTitlePopUp indexOfSelectedItem] );
2553 hb_job_t * job = title->job;
2557 [fVidBitrateField setIntValue: hb_calc_bitrate( job,
2558 [fVidTargetSizeField intValue] )];
2563 /* Method to determine if we should change the UI
2564 To reflect whether or not a Preset is being used or if
2565 the user is using "Custom" settings by determining the sender*/
2566 - (IBAction) CustomSettingUsed: (id) sender
2568 if ([sender stringValue] != NULL)
2570 /* Deselect the currently selected Preset if there is one*/
2571 [tableView deselectRow:[tableView selectedRow]];
2572 [[fPresetsActionMenu itemAtIndex:0] setEnabled: NO];
2573 /* Change UI to show "Custom" settings are being used */
2574 [fPresetSelectedDisplay setStringValue: @"Custom"];
2576 curUserPresetChosenNum = nil;
2583 - (IBAction) X264AdvancedOptionsSet: (id) sender
2585 /*Set opt widget values here*/
2587 /*B-Frames fX264optBframesPopUp*/
2589 [fX264optBframesPopUp removeAllItems];
2590 [fX264optBframesPopUp addItemWithTitle:@"Default (0)"];
2593 [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2596 /*Reference Frames fX264optRefPopUp*/
2597 [fX264optRefPopUp removeAllItems];
2598 [fX264optRefPopUp addItemWithTitle:@"Default (1)"];
2601 [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2604 /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/
2605 [fX264optNfpskipSwitch setState:0];
2607 /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/
2608 [fX264optNodctdcmtSwitch setState:0];
2610 /*Sub Me fX264optSubmePopUp*/
2611 [fX264optSubmePopUp removeAllItems];
2612 [fX264optSubmePopUp addItemWithTitle:@"Default (4)"];
2615 [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2618 /*Trellis fX264optTrellisPopUp*/
2619 [fX264optTrellisPopUp removeAllItems];
2620 [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"];
2623 [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2626 /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/
2627 [fX264optMixedRefsSwitch setState:0];
2629 /*Motion Estimation fX264optMotionEstPopUp*/
2630 [fX264optMotionEstPopUp removeAllItems];
2631 [fX264optMotionEstPopUp addItemWithTitle:@"Default (Hexagon)"];
2632 [fX264optMotionEstPopUp addItemWithTitle:@"Diamond"];
2633 [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"];
2634 [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"];
2635 [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"];
2637 /*Motion Estimation range fX264optMERangePopUp*/
2638 [fX264optMERangePopUp removeAllItems];
2639 [fX264optMERangePopUp addItemWithTitle:@"Default (16)"];
2642 [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2645 /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/
2646 [fX264optWeightBSwitch setState:0];
2648 /*B-Frame Rate Distortion Optimization fX264optBRDOSwitch BOOLEAN*/
2649 [fX264optBRDOSwitch setState:0];
2651 /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/
2652 [fX264optBPyramidSwitch setState:0];
2654 /*Bidirectional Motion Estimation Refinement fX264optBiMESwitch BOOLEAN*/
2655 [fX264optBiMESwitch setState:0];
2657 /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/
2658 [fX264optDirectPredPopUp removeAllItems];
2659 [fX264optDirectPredPopUp addItemWithTitle:@"Default (Spatial)"];
2660 [fX264optDirectPredPopUp addItemWithTitle:@"None"];
2661 [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"];
2662 [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"];
2663 [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"];
2666 [fX264optAlphaDeblockPopUp removeAllItems];
2667 [fX264optAlphaDeblockPopUp addItemWithTitle:@"Default (0)"];
2670 [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2674 [fX264optBetaDeblockPopUp removeAllItems];
2675 [fX264optBetaDeblockPopUp addItemWithTitle:@"Default (0)"];
2678 [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2681 /* Analysis fX264optAnalysePopUp */
2682 [fX264optAnalysePopUp removeAllItems];
2683 [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */
2684 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */
2685 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */
2687 /* 8x8 DCT fX264op8x8dctSwitch */
2688 [fX264opt8x8dctSwitch setState:0];
2690 /* CABAC fX264opCabacSwitch */
2691 [fX264optCabacSwitch setState:1];
2693 /* Standardize the option string */
2694 [self X264AdvancedOptionsStandardizeOptString: NULL];
2695 /* Set Current GUI Settings based on newly standardized string */
2696 [self X264AdvancedOptionsSetCurrentSettings: NULL];
2699 - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender
2701 /* Set widgets depending on the opt string in field */
2702 NSString * thisOpt; // The separated option such as "bframes=3"
2703 NSString * optName = @""; // The option name such as "bframes"
2704 NSString * optValue = @"";// The option value such as "3"
2705 NSString * changedOptString = @"";
2706 NSArray *currentOptsArray;
2708 /*First, we get an opt string to process */
2709 NSString *currentOptString = [fDisplayX264Options stringValue];
2711 /*verify there is an opt string to process */
2712 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
2713 if (currentOptRange.location != NSNotFound)
2715 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
2716 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
2718 /*iterate through the array and get <opts> and <values*/
2719 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
2721 int currentOptsArrayCount = [currentOptsArray count];
2722 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
2724 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
2726 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
2727 if (splitOptRange.location != NSNotFound)
2729 optName = [thisOpt substringToIndex:splitOptRange.location];
2730 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
2732 /* Standardize the names here depending on whats in the string */
2733 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
2734 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue];
2736 else // No value given so we use a default of "1"
2739 /* Standardize the names here depending on whats in the string */
2740 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
2741 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
2744 /* Construct New String for opts here */
2745 if ([thisOpt isEqualToString:@""])
2747 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
2751 if ([changedOptString isEqualToString:@""])
2753 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
2757 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
2763 /* Change the option string to reflect the new standardized option string */
2764 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
2767 - (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString
2769 if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"])
2771 cleanOptNameString = @"ref";
2774 /*No Fast PSkip nofast_pskip*/
2775 if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"])
2777 cleanOptNameString = @"no-fast-pskip";
2780 /*No Dict Decimate*/
2781 if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"])
2783 cleanOptNameString = @"no-dct-decimate";
2787 if ([cleanOptNameString isEqualToString:@"subme"])
2789 cleanOptNameString = @"subq";
2793 if ([cleanOptNameString isEqualToString:@"me-range"] || [cleanOptNameString isEqualToString:@"me_range"])
2794 cleanOptNameString = @"merange";
2797 if ([cleanOptNameString isEqualToString:@"weight-b"] || [cleanOptNameString isEqualToString:@"weight_b"])
2799 cleanOptNameString = @"weightb";
2803 if ([cleanOptNameString isEqualToString:@"b-rdo"] || [cleanOptNameString isEqualToString:@"b_rdo"])
2805 cleanOptNameString = @"brdo";
2809 if ([cleanOptNameString isEqualToString:@"b_pyramid"])
2811 cleanOptNameString = @"b-pyramid";
2814 /*Direct Prediction*/
2815 if ([cleanOptNameString isEqualToString:@"direct-pred"] || [cleanOptNameString isEqualToString:@"direct_pred"])
2817 cleanOptNameString = @"direct";
2821 if ([cleanOptNameString isEqualToString:@"filter"])
2823 cleanOptNameString = @"deblock";
2827 if ([cleanOptNameString isEqualToString:@"partitions"])
2829 cleanOptNameString = @"analyse";
2833 return cleanOptNameString;
2836 - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender
2838 /* Set widgets depending on the opt string in field */
2839 NSString * thisOpt; // The separated option such as "bframes=3"
2840 NSString * optName = @""; // The option name such as "bframes"
2841 NSString * optValue = @"";// The option value such as "3"
2842 NSArray *currentOptsArray;
2844 /*First, we get an opt string to process */
2845 //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
2846 NSString *currentOptString = [fDisplayX264Options stringValue];
2848 /*verify there is an opt string to process */
2849 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
2850 if (currentOptRange.location != NSNotFound)
2852 /* lets clean the opt string here to standardize any names*/
2853 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
2854 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
2856 /*iterate through the array and get <opts> and <values*/
2857 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
2859 int currentOptsArrayCount = [currentOptsArray count];
2861 /*iterate through the array and get <opts> and <values*/
2862 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
2864 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
2865 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
2867 if (splitOptRange.location != NSNotFound)
2869 optName = [thisOpt substringToIndex:splitOptRange.location];
2870 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
2872 /*Run through the available widgets for x264 opts and set them, as you add widgets,
2873 they need to be added here. This should be moved to its own method probably*/
2875 /*bframes NSPopUpButton*/
2876 if ([optName isEqualToString:@"bframes"])
2878 [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1];
2880 /*ref NSPopUpButton*/
2881 if ([optName isEqualToString:@"ref"])
2883 [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1];
2885 /*No Fast PSkip NSPopUpButton*/
2886 if ([optName isEqualToString:@"no-fast-pskip"])
2888 [fX264optNfpskipSwitch setState:[optValue intValue]];
2890 /*No Dict Decimate NSPopUpButton*/
2891 if ([optName isEqualToString:@"no-dct-decimate"])
2893 [fX264optNodctdcmtSwitch setState:[optValue intValue]];
2895 /*Sub Me NSPopUpButton*/
2896 if ([optName isEqualToString:@"subq"])
2898 [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1];
2900 /*Trellis NSPopUpButton*/
2901 if ([optName isEqualToString:@"trellis"])
2903 [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1];
2905 /*Mixed Refs NSButton*/
2906 if ([optName isEqualToString:@"mixed-refs"])
2908 [fX264optMixedRefsSwitch setState:[optValue intValue]];
2910 /*Motion Estimation NSPopUpButton*/
2911 if ([optName isEqualToString:@"me"])
2913 if ([optValue isEqualToString:@"dia"])
2914 [fX264optMotionEstPopUp selectItemAtIndex:1];
2915 else if ([optValue isEqualToString:@"hex"])
2916 [fX264optMotionEstPopUp selectItemAtIndex:2];
2917 else if ([optValue isEqualToString:@"umh"])
2918 [fX264optMotionEstPopUp selectItemAtIndex:3];
2919 else if ([optValue isEqualToString:@"esa"])
2920 [fX264optMotionEstPopUp selectItemAtIndex:4];
2922 /*ME Range NSPopUpButton*/
2923 if ([optName isEqualToString:@"merange"])
2925 [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3];
2927 /*Weighted B-Frames NSPopUpButton*/
2928 if ([optName isEqualToString:@"weightb"])
2930 [fX264optWeightBSwitch setState:[optValue intValue]];
2932 /*BRDO NSPopUpButton*/
2933 if ([optName isEqualToString:@"brdo"])
2935 [fX264optBRDOSwitch setState:[optValue intValue]];
2937 /*B Pyramid NSPopUpButton*/
2938 if ([optName isEqualToString:@"b-pyramid"])
2940 [fX264optBPyramidSwitch setState:[optValue intValue]];
2942 /*Bidirectional Motion Estimation Refinement NSPopUpButton*/
2943 if ([optName isEqualToString:@"bime"])
2945 [fX264optBiMESwitch setState:[optValue intValue]];
2947 /*Direct B-frame Prediction NSPopUpButton*/
2948 if ([optName isEqualToString:@"direct"])
2950 if ([optValue isEqualToString:@"none"])
2951 [fX264optDirectPredPopUp selectItemAtIndex:1];
2952 else if ([optValue isEqualToString:@"spatial"])
2953 [fX264optDirectPredPopUp selectItemAtIndex:2];
2954 else if ([optValue isEqualToString:@"temporal"])
2955 [fX264optDirectPredPopUp selectItemAtIndex:3];
2956 else if ([optValue isEqualToString:@"auto"])
2957 [fX264optDirectPredPopUp selectItemAtIndex:4];
2959 /*Deblocking NSPopUpButtons*/
2960 if ([optName isEqualToString:@"deblock"])
2962 NSString * alphaDeblock = @"";
2963 NSString * betaDeblock = @"";
2965 NSRange splitDeblock = [optValue rangeOfString:@","];
2966 alphaDeblock = [optValue substringToIndex:splitDeblock.location];
2967 betaDeblock = [optValue substringFromIndex:splitDeblock.location + 1];
2969 if ([alphaDeblock isEqualToString:@"0"] && [betaDeblock isEqualToString:@"0"])
2971 [fX264optAlphaDeblockPopUp selectItemAtIndex:0];
2972 [fX264optBetaDeblockPopUp selectItemAtIndex:0];
2976 if (![alphaDeblock isEqualToString:@"0"])
2978 [fX264optAlphaDeblockPopUp selectItemAtIndex:[alphaDeblock intValue]+7];
2982 [fX264optAlphaDeblockPopUp selectItemAtIndex:7];
2985 if (![betaDeblock isEqualToString:@"0"])
2987 [fX264optBetaDeblockPopUp selectItemAtIndex:[betaDeblock intValue]+7];
2991 [fX264optBetaDeblockPopUp selectItemAtIndex:7];
2995 /* Analysis NSPopUpButton */
2996 if ([optName isEqualToString:@"analyse"])
2998 if ([optValue isEqualToString:@"p8x8,b8x8,i8x8,i4x4"])
3000 [fX264optAnalysePopUp selectItemAtIndex:0];
3002 if ([optValue isEqualToString:@"none"])
3004 [fX264optAnalysePopUp selectItemAtIndex:1];
3006 if ([optValue isEqualToString:@"all"])
3008 [fX264optAnalysePopUp selectItemAtIndex:2];
3011 /* 8x8 DCT NSButton */
3012 if ([optName isEqualToString:@"8x8dct"])
3014 [fX264opt8x8dctSwitch setState:[optValue intValue]];
3016 /* CABAC NSButton */
3017 if ([optName isEqualToString:@"cabac"])
3019 [fX264optCabacSwitch setState:[optValue intValue]];
3026 - (IBAction) X264AdvancedOptionsChanged: (id) sender
3028 /*Determine which outlet is being used and set optName to process accordingly */
3029 NSString * optNameToChange = @""; // The option name such as "bframes"
3031 if (sender == fX264optBframesPopUp)
3033 optNameToChange = @"bframes";
3035 if (sender == fX264optRefPopUp)
3037 optNameToChange = @"ref";
3039 if (sender == fX264optNfpskipSwitch)
3041 optNameToChange = @"no-fast-pskip";
3043 if (sender == fX264optNodctdcmtSwitch)
3045 optNameToChange = @"no-dct-decimate";
3047 if (sender == fX264optSubmePopUp)
3049 optNameToChange = @"subq";
3051 if (sender == fX264optTrellisPopUp)
3053 optNameToChange = @"trellis";
3055 if (sender == fX264optMixedRefsSwitch)
3057 optNameToChange = @"mixed-refs";
3059 if (sender == fX264optMotionEstPopUp)
3061 optNameToChange = @"me";
3063 if (sender == fX264optMERangePopUp)
3065 optNameToChange = @"merange";
3067 if (sender == fX264optWeightBSwitch)
3069 optNameToChange = @"weightb";
3071 if (sender == fX264optBRDOSwitch)
3073 optNameToChange = @"brdo";
3075 if (sender == fX264optBPyramidSwitch)
3077 optNameToChange = @"b-pyramid";
3079 if (sender == fX264optBiMESwitch)
3081 optNameToChange = @"bime";
3083 if (sender == fX264optDirectPredPopUp)
3085 optNameToChange = @"direct";
3087 if (sender == fX264optAlphaDeblockPopUp)
3089 optNameToChange = @"deblock";
3091 if (sender == fX264optBetaDeblockPopUp)
3093 optNameToChange = @"deblock";
3095 if (sender == fX264optAnalysePopUp)
3097 optNameToChange = @"analyse";
3099 if (sender == fX264opt8x8dctSwitch)
3101 optNameToChange = @"8x8dct";
3103 if (sender == fX264optCabacSwitch)
3105 optNameToChange = @"cabac";
3108 /* Set widgets depending on the opt string in field */
3109 NSString * thisOpt; // The separated option such as "bframes=3"
3110 NSString * optName = @""; // The option name such as "bframes"
3111 NSString * optValue = @"";// The option value such as "3"
3112 NSArray *currentOptsArray;
3114 /*First, we get an opt string to process */
3115 //EXAMPLE: NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
3116 NSString *currentOptString = [fDisplayX264Options stringValue];
3118 /*verify there is an occurrence of the opt specified by the sender to change */
3119 /*take care of any multi-value opt names here. This is extremely kludgy, but test for functionality
3120 and worry about pretty later */
3122 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
3123 the first character of the opt string (hence the ":") */
3124 NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange];
3125 NSRange currentOptRange = [currentOptString rangeOfString:checkOptNameToChange];
3126 /*Then we create a pattern to check for "<beginning of line>"optNameToChange"=" to modify the option to
3127 see if the name falls at the beginning of the line, where we would not have the ":" as a pattern to test against*/
3128 NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange];
3129 NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning];
3130 if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0)
3132 /* Create new empty opt string*/
3133 NSString *changedOptString = @"";
3135 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
3136 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
3138 /*iterate through the array and get <opts> and <values*/
3140 int currentOptsArrayCount = [currentOptsArray count];
3141 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
3143 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
3144 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
3146 if (splitOptRange.location != NSNotFound)
3148 optName = [thisOpt substringToIndex:splitOptRange.location];
3149 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
3151 /*Run through the available widgets for x264 opts and set them, as you add widgets,
3152 they need to be added here. This should be moved to its own method probably*/
3154 /*If the optNameToChange is found, appropriately change the value or delete it if
3155 "Unspecified" is set.*/
3156 if ([optName isEqualToString:optNameToChange])
3158 if ([optNameToChange isEqualToString:@"deblock"])
3160 if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7)))
3166 thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0];
3169 else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
3171 if ([sender state] == 0)
3177 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
3180 else if ([optNameToChange isEqualToString:@"cabac"])
3182 if ([sender state] == 1)
3188 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0];
3191 else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string
3195 else if ([optNameToChange isEqualToString:@"me"])
3197 switch ([sender indexOfSelectedItem])
3200 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"];
3204 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"];
3208 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"];
3212 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"];
3219 else if ([optNameToChange isEqualToString:@"direct"])
3221 switch ([sender indexOfSelectedItem])
3224 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
3228 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"];
3232 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"];
3236 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"];
3243 else if ([optNameToChange isEqualToString:@"analyse"])
3245 switch ([sender indexOfSelectedItem])
3248 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
3252 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
3259 else if ([optNameToChange isEqualToString:@"merange"])
3261 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
3263 else // we have a valid value to change, so change it
3265 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
3270 /* Construct New String for opts here */
3271 if ([thisOpt isEqualToString:@""])
3273 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
3277 if ([changedOptString isEqualToString:@""])
3279 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
3283 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
3288 /* Change the option string to reflect the new mod settings */
3289 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
3291 else // if none exists, add it to the string
3293 if ([[fDisplayX264Options stringValue] isEqualToString: @""])
3295 if ([optNameToChange isEqualToString:@"me"])
3297 switch ([sender indexOfSelectedItem])
3300 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3301 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
3305 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3306 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
3310 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3311 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
3315 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3316 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
3323 else if ([optNameToChange isEqualToString:@"direct"])
3325 switch ([sender indexOfSelectedItem])
3328 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3329 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3333 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3334 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
3338 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3339 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
3343 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3344 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
3351 else if ([optNameToChange isEqualToString:@"analyse"])
3353 switch ([sender indexOfSelectedItem])
3356 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3357 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3361 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3362 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
3370 else if ([optNameToChange isEqualToString:@"merange"])
3372 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3373 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
3375 else if ([optNameToChange isEqualToString:@"deblock"])
3377 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]];
3379 else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) {
3380 if ([sender state] == 0)
3382 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
3386 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3387 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3390 else if ([optNameToChange isEqualToString:@"cabac"])
3392 if ([sender state] == 1)
3394 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
3398 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3399 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3404 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3405 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
3410 if ([optNameToChange isEqualToString:@"me"])
3412 switch ([sender indexOfSelectedItem])
3415 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3416 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3417 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
3421 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3422 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3423 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
3427 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3428 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3429 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
3433 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3434 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3435 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
3442 else if ([optNameToChange isEqualToString:@"direct"])
3444 switch ([sender indexOfSelectedItem])
3447 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3448 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3449 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3453 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3454 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3455 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
3459 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3460 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3461 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
3465 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3466 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3467 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
3474 else if ([optNameToChange isEqualToString:@"analyse"])
3476 switch ([sender indexOfSelectedItem])
3479 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3480 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3481 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3485 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3486 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3487 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
3495 else if ([optNameToChange isEqualToString:@"merange"])
3497 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3498 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
3500 else if ([optNameToChange isEqualToString:@"deblock"])
3502 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", [NSString stringWithFormat:[fDisplayX264Options stringValue]], [NSString stringWithFormat:optNameToChange], [NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]];
3504 else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
3506 if ([sender state] == 0)
3508 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
3512 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3513 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3516 else if ([optNameToChange isEqualToString:@"cabac"])
3518 if ([sender state] == 1)
3520 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
3524 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3525 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3530 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3531 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
3536 /* We now need to reset the opt widgets since we changed some stuff */
3537 [self X264AdvancedOptionsSet:NULL];
3541 /* We use this method to recreate new, updated factory
3543 - (IBAction)AddFactoryPresets:(id)sender
3545 /* First, we delete any existing built in presets */
3546 [self DeleteFactoryPresets: sender];
3547 /* Then, we re-create new built in presets programmatically CreateIpodOnlyPreset*/
3548 [UserPresets addObject:[self CreateNormalPreset]];
3549 [UserPresets addObject:[self CreateClassicPreset]];
3550 [UserPresets addObject:[self CreateQuickTimePreset]];
3551 [UserPresets addObject:[self CreateIpodLowPreset]];
3552 [UserPresets addObject:[self CreateIpodHighPreset]];
3553 [UserPresets addObject:[self CreateAppleTVPreset]];
3554 [UserPresets addObject:[self CreateiPhonePreset]];
3555 [UserPresets addObject:[self CreatePSThreePreset]];
3556 [UserPresets addObject:[self CreatePSPPreset]];
3557 [UserPresets addObject:[self CreateFilmPreset]];
3558 [UserPresets addObject:[self CreateTelevisionPreset]];
3559 [UserPresets addObject:[self CreateAnimationPreset]];
3560 [UserPresets addObject:[self CreateBedlamPreset]];
3561 [UserPresets addObject:[self CreateDeuxSixQuatrePreset]];
3562 [UserPresets addObject:[self CreateBrokePreset]];
3563 [UserPresets addObject:[self CreateBlindPreset]];
3564 [UserPresets addObject:[self CreateCRFPreset]];
3568 - (IBAction)DeleteFactoryPresets:(id)sender
3571 NSEnumerator *enumerator = [UserPresets objectEnumerator];
3575 NSMutableArray *tempArray;
3578 tempArray = [NSMutableArray array];
3579 /* we look here to see if the preset is we move on to the next one */
3580 while ( tempObject = [enumerator nextObject] )
3582 /* if the preset is "Factory" then we put it in the array of
3583 presets to delete */
3584 if ([[tempObject objectForKey:@"Type"] intValue] == 0)
3586 [tempArray addObject:tempObject];
3590 [UserPresets removeObjectsInArray:tempArray];
3591 [tableView reloadData];
3596 - (IBAction) ShowAddPresetPanel: (id) sender
3598 /* Deselect the currently selected Preset if there is one*/
3599 [tableView deselectRow:[tableView selectedRow]];
3601 /* Populate the preset picture settings popup here */
3602 [fPresetNewPicSettingsPopUp removeAllItems];
3603 [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
3604 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
3605 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
3606 [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];
3608 /* Erase info from the input fields fPresetNewDesc*/
3609 [fPresetNewName setStringValue: @""];
3610 [fPresetNewDesc setStringValue: @""];
3611 /* Show the panel */
3612 [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow
3613 modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
3614 [NSApp runModalForWindow: fAddPresetPanel];
3615 [NSApp endSheet: fAddPresetPanel];
3616 [fAddPresetPanel orderOut: self];
3620 - (IBAction) CloseAddPresetPanel: (id) sender
3626 - (IBAction)AddUserPreset:(id)sender
3629 /* Here we create a custom user preset */
3630 [UserPresets addObject:[self CreatePreset]];
3631 /* Erase info from the input fields */
3632 [fPresetNewName setStringValue: @""];
3633 [fPresetNewDesc setStringValue: @""];
3634 /* We stop the modal window for the new preset */
3644 /* We Sort the Presets By Factory or Custom */
3645 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
3646 ascending:YES] autorelease];
3647 /* We Sort the Presets Alphabetically by name */
3648 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
3649 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
3650 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
3651 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
3652 [UserPresets setArray:sortedArray];
3655 /* We Reload the New Table data for presets */
3656 [tableView reloadData];
3657 /* We save all of the preset data here */
3661 - (IBAction)InsertPreset:(id)sender
3663 int index = [tableView selectedRow];
3664 [UserPresets insertObject:[self CreatePreset] atIndex:index];
3665 [tableView reloadData];
3669 - (NSDictionary *)CreatePreset
3671 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3672 /* Get the New Preset Name from the field in the AddPresetPanel */
3673 [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
3674 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3675 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
3676 /*Set whether or not this is default, at creation set to 0*/
3677 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3678 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3679 [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
3680 /* Get New Preset Description from the field in the AddPresetPanel*/
3681 [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
3683 [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
3684 /* Chapter Markers fCreateChapterMarkers*/
3685 [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
3686 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
3687 [preset setObject:[NSNumber numberWithInt:[fDstMpgLargeFileCheck state]] forKey:@"Mp4LargeFile"];
3689 [preset setObject:[fDstCodecsPopUp titleOfSelectedItem] forKey:@"FileCodecs"];
3691 [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
3692 /* x264 Option String */
3693 [preset setObject:[fDisplayX264Options stringValue] forKey:@"x264Option"];
3695 [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
3696 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3697 [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
3698 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3700 /* Video framerate */
3701 [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
3703 [preset setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
3704 /* 2 Pass Encoding */
3705 [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
3706 /* Turbo 2 pass Encoding fVidTurboPassCheck*/
3707 [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
3708 /*Picture Settings*/
3709 hb_job_t * job = fTitle->job;
3710 /* Basic Picture Settings */
3711 /* Use Max Picture settings for whatever the dvd is.*/
3712 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3713 [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
3714 [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
3715 [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
3716 [preset setObject:[NSNumber numberWithInt:[fPicSettingDeinterlace intValue]] forKey:@"PictureDeinterlace"];
3717 [preset setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
3718 [preset setObject:[fPicSettingDetelecine stringValue] forKey:@"PictureDetelecine"];
3719 [preset setObject:[NSNumber numberWithInt:[fPicSettingDenoise intValue]] forKey:@"PictureDenoise"];
3720 /* Set crop settings here */
3721 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3722 [preset setObject:[NSNumber numberWithInt:[fPicSettingAutoCrop intValue]] forKey:@"PictureAutoCrop"];
3724 [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
3725 [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
3726 [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
3727 [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
3730 /* Audio Sample Rate*/
3731 [preset setObject:[fAudRatePopUp titleOfSelectedItem] forKey:@"AudioSampleRate"];
3732 /* Audio Bitrate Rate*/
3733 [preset setObject:[fAudBitratePopUp titleOfSelectedItem] forKey:@"AudioBitRate"];
3735 [preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
3738 [preset autorelease];
3743 - (NSDictionary *)CreateIpodLowPreset
3745 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3746 /* Get the New Preset Name from the field in the AddPresetPanel */
3747 [preset setObject:@"iPod Low-Rez" forKey:@"PresetName"];
3748 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3749 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3750 /*Set whether or not this is default, at creation set to 0*/
3751 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3752 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3753 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3754 /* Get the New Preset Description from the field in the AddPresetPanel */
3755 [preset setObject:@"HandBrake's low resolution settings for the iPod. Optimized for great playback on the iPod screen, with smaller file size." forKey:@"PresetDescription"];
3757 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3758 /* Chapter Markers*/
3759 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3761 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3763 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3764 /* x264 Option String */
3765 [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"];
3767 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3768 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3769 [preset setObject:@"700" forKey:@"VideoAvgBitrate"];
3770 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3772 /* Video framerate */
3773 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3775 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3776 /* 2 Pass Encoding */
3777 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3779 /*Picture Settings*/
3780 //hb_job_t * job = fTitle->job;
3781 /* Basic Picture Settings */
3782 /* Use Max Picture settings for whatever the dvd is.*/
3783 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3784 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3785 [preset setObject:[NSNumber numberWithInt:320] forKey:@"PictureWidth"];
3786 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3787 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3788 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3789 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3790 /* Set crop settings here */
3791 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3792 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3793 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3794 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3795 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3798 /* Audio Sample Rate*/
3799 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3800 /* Audio Bitrate Rate*/
3801 [preset setObject:@"160" forKey:@"AudioBitRate"];
3803 [preset setObject:@"None" forKey:@"Subtitles"];
3806 [preset autorelease];
3812 - (NSDictionary *)CreateIpodHighPreset
3814 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3815 /* Get the New Preset Name from the field in the AddPresetPanel */
3816 [preset setObject:@"iPod High-Rez" forKey:@"PresetName"];
3817 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3818 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3819 /*Set whether or not this is default, at creation set to 0*/
3820 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3821 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3822 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3823 /* Get the New Preset Description from the field in the AddPresetPanel */
3824 [preset setObject:@"HandBrake's high resolution settings for the iPod. Good video quality, great for viewing on a TV using your iPod" forKey:@"PresetDescription"];
3826 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3827 /* Chapter Markers*/
3828 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3830 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3832 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3833 /* x264 Option String */
3834 [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"];
3836 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3837 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3838 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
3839 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3841 /* Video framerate */
3842 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3844 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3845 /* 2 Pass Encoding */
3846 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3848 /*Picture Settings*/
3849 //hb_job_t * job = fTitle->job;
3850 /* Basic Picture Settings */
3851 /* Use Max Picture settings for whatever the dvd is.*/
3852 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3853 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
3854 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3855 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3856 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3857 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3858 /* Set crop settings here */
3859 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3860 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3861 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3862 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3863 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3864 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3867 /* Audio Sample Rate*/
3868 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3869 /* Audio Bitrate Rate*/
3870 [preset setObject:@"160" forKey:@"AudioBitRate"];
3872 [preset setObject:@"None" forKey:@"Subtitles"];
3875 [preset autorelease];
3880 - (NSDictionary *)CreateAppleTVPreset
3882 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3883 /* Get the New Preset Name from the field in the AddPresetPanel */
3884 [preset setObject:@"AppleTV" forKey:@"PresetName"];
3885 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3886 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3887 /*Set whether or not this is default, at creation set to 0*/
3888 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3889 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3890 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3891 /* Get the New Preset Description from the field in the AddPresetPanel */
3892 [preset setObject:@"HandBrake's settings for the AppleTV. Provides a good balance between quality and file size, and optimizes performance." forKey:@"PresetDescription"];
3894 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3895 /* Chapter Markers*/
3896 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3898 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3900 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3901 /* x264 Option String (We can use this to tweak the appleTV output)*/
3902 [preset setObject:@"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2" forKey:@"x264Option"];
3904 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3905 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3906 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3907 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3909 /* Video framerate */
3910 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3912 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3913 /* 2 Pass Encoding */
3914 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3916 /*Picture Settings*/
3917 /* For AppleTV we only want to retain UsesMaxPictureSettings
3918 which depend on the source dvd picture settings, so we don't
3919 record the current dvd's picture info since it will vary from
3921 //hb_job_t * job = fTitle->job;
3922 //hb_job_t * job = title->job;
3923 /* Basic Picture Settings */
3924 /* Use Max Picture settings for whatever the dvd is.*/
3925 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3926 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3927 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3928 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3929 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3930 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3931 /* Set crop settings here */
3932 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3933 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3934 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3935 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3936 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3939 /* Audio Sample Rate*/
3940 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3941 /* Audio Bitrate Rate*/
3942 [preset setObject:@"160" forKey:@"AudioBitRate"];
3944 [preset setObject:@"None" forKey:@"Subtitles"];
3947 [preset autorelease];
3952 - (NSDictionary *)CreatePSThreePreset
3954 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3955 /* Get the New Preset Name from the field in the AddPresetPanel */
3956 [preset setObject:@"PS3" forKey:@"PresetName"];
3957 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3958 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3959 /*Set whether or not this is default, at creation set to 0*/
3960 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3961 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3962 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3963 /* Get the New Preset Description from the field in the AddPresetPanel */
3964 [preset setObject:@"HandBrake's settings for the Sony PlayStation 3." forKey:@"PresetDescription"];
3966 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3967 /* Chapter Markers*/
3968 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3970 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3972 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3973 /* x264 Option String (We can use this to tweak the appleTV output)*/
3974 [preset setObject:@"level=41:subme=5:me=umh" forKey:@"x264Option"];
3976 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3977 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3978 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3979 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3981 /* Video framerate */
3982 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3984 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3985 /* 2 Pass Encoding */
3986 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3988 /*Picture Settings*/
3989 /* For PS3 we only want to retain UsesMaxPictureSettings
3990 which depend on the source dvd picture settings, so we don't
3991 record the current dvd's picture info since it will vary from
3993 /* Use Max Picture settings for whatever the dvd is.*/
3994 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3995 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3996 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3997 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3998 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3999 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4000 /* Set crop settings here */
4001 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4002 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4003 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4004 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4005 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4008 /* Audio Sample Rate*/
4009 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4010 /* Audio Bitrate Rate*/
4011 [preset setObject:@"160" forKey:@"AudioBitRate"];
4013 [preset setObject:@"None" forKey:@"Subtitles"];
4016 [preset autorelease];
4020 - (NSDictionary *)CreatePSPPreset
4022 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4023 /* Get the New Preset Name from the field in the AddPresetPanel */
4024 [preset setObject:@"PSP" forKey:@"PresetName"];
4025 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
4026 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4027 /*Set whether or not this is default, at creation set to 0*/
4028 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4029 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4030 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4031 /* Get the New Preset Description from the field in the AddPresetPanel */
4032 [preset setObject:@"HandBrake's settings for the Sony PlayStation Portable." forKey:@"PresetDescription"];
4034 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4035 /* Chapter Markers*/
4036 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4038 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4040 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4041 /* x264 Option String (We can use this to tweak the appleTV output)*/
4042 [preset setObject:@"" forKey:@"x264Option"];
4044 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4045 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4046 [preset setObject:@"1024" forKey:@"VideoAvgBitrate"];
4047 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4049 /* Video framerate */
4050 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4052 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4053 /* 2 Pass Encoding */
4054 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4056 /*Picture Settings*/
4057 /* For PS3 we only want to retain UsesMaxPictureSettings
4058 which depend on the source dvd picture settings, so we don't
4059 record the current dvd's picture info since it will vary from
4061 /* Use Max Picture settings for whatever the dvd is.*/
4062 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4063 [preset setObject:@"368" forKey:@"PictureWidth"];
4064 [preset setObject:@"208" forKey:@"PictureHeight"];
4065 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4066 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4067 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4068 /* Set crop settings here */
4069 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4070 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4071 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4072 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4073 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4074 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4077 /* Audio Sample Rate*/
4078 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4079 /* Audio Bitrate Rate*/
4080 [preset setObject:@"128" forKey:@"AudioBitRate"];
4082 [preset setObject:@"None" forKey:@"Subtitles"];
4085 [preset autorelease];
4090 - (NSDictionary *)CreateNormalPreset
4092 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4093 /* Get the New Preset Name from the field in the AddPresetPanel */
4094 [preset setObject:@"Normal" forKey:@"PresetName"];
4095 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4096 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4097 /*Set whether or not this is default, at creation set to 0*/
4098 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"];
4099 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4100 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4101 /* Get the New Preset Description from the field in the AddPresetPanel */
4102 [preset setObject:@"HandBrake's normal, default settings." forKey:@"PresetDescription"];
4104 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4105 /* Chapter Markers*/
4106 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4108 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4110 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4111 /* x264 Option String */
4112 [preset setObject:@"ref=2:bframes=2:subme=5:me=umh" forKey:@"x264Option"];
4114 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4115 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4116 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
4117 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4119 /* Video framerate */
4120 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4122 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4123 /* 2 Pass Encoding */
4124 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4125 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4127 /*Picture Settings*/
4128 //hb_job_t * job = fTitle->job;
4129 /* Basic Picture Settings */
4130 /* Use Max Picture settings for whatever the dvd is.*/
4131 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4132 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4133 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4134 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4135 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4136 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4137 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4138 /* Set crop settings here */
4139 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4140 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4141 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4142 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4143 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4146 /* Audio Sample Rate*/
4147 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4148 /* Audio Bitrate Rate*/
4149 [preset setObject:@"160" forKey:@"AudioBitRate"];
4151 [preset setObject:@"None" forKey:@"Subtitles"];
4154 [preset autorelease];
4159 - (NSDictionary *)CreateClassicPreset
4161 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4162 /* Get the New Preset Name from the field in the AddPresetPanel */
4163 [preset setObject:@"Classic" forKey:@"PresetName"];
4164 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4165 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4166 /*Set whether or not this is default, at creation set to 0*/
4167 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4168 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4169 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4170 /* Get the New Preset Description from the field in the AddPresetPanel */
4171 [preset setObject:@"HandBrake's traditional, faster, lower-quality settings." forKey:@"PresetDescription"];
4173 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4174 /* Chapter Markers*/
4175 [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
4177 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4179 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4180 /* x264 Option String */
4181 [preset setObject:@"" forKey:@"x264Option"];
4183 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4184 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4185 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
4186 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4188 /* Video framerate */
4189 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4191 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4192 /* 2 Pass Encoding */
4193 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4195 /*Picture Settings*/
4196 //hb_job_t * job = fTitle->job;
4197 /* Basic Picture Settings */
4198 /* Use Max Picture settings for whatever the dvd is.*/
4199 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4200 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4201 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4202 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4203 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4204 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4205 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4206 /* Set crop settings here */
4207 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4208 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4209 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4210 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4211 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4214 /* Audio Sample Rate*/
4215 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4216 /* Audio Bitrate Rate*/
4217 [preset setObject:@"160" forKey:@"AudioBitRate"];
4219 [preset setObject:@"None" forKey:@"Subtitles"];
4222 [preset autorelease];
4227 - (NSDictionary *)CreateFilmPreset
4229 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4230 /* Get the New Preset Name from the field in the AddPresetPanel */
4231 [preset setObject:@"Film" forKey:@"PresetName"];
4232 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4233 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4234 /*Set whether or not this is default, at creation set to 0*/
4235 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4236 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4237 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4238 /* Get the New Preset Description from the field in the AddPresetPanel */
4239 [preset setObject:@"HandBrake's preset for feature films." forKey:@"PresetDescription"];
4241 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4242 /* Chapter Markers*/
4243 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4245 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4247 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4248 /* x264 Option String */
4249 [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"];
4251 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4252 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4253 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4254 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4256 /* Video framerate */
4257 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4259 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4260 /* 2 Pass Encoding */
4261 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4262 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4264 /*Picture Settings*/
4265 //hb_job_t * job = fTitle->job;
4266 /* Basic Picture Settings */
4267 /* Use Max Picture settings for whatever the dvd is.*/
4268 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4269 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4270 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4271 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4272 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4273 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4274 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4275 /* Set crop settings here */
4276 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4277 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4278 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4279 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4280 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4283 /* Audio Sample Rate*/
4284 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4285 /* Audio Bitrate Rate*/
4286 [preset setObject:@"160" forKey:@"AudioBitRate"];
4288 [preset setObject:@"None" forKey:@"Subtitles"];
4291 [preset autorelease];
4296 - (NSDictionary *)CreateTelevisionPreset
4298 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4299 /* Get the New Preset Name from the field in the AddPresetPanel */
4300 [preset setObject:@"Television" forKey:@"PresetName"];
4301 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4302 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4303 /*Set whether or not this is default, at creation set to 0*/
4304 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4305 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4306 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4307 /* Get the New Preset Description from the field in the AddPresetPanel */
4308 [preset setObject:@"HandBrake's settings for video from television." forKey:@"PresetDescription"];
4310 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4311 /* Chapter Markers*/
4312 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4314 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4316 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4317 /* x264 Option String */
4318 [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"];
4320 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4321 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4322 [preset setObject:@"1300" forKey:@"VideoAvgBitrate"];
4323 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4325 /* Video framerate */
4326 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4328 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4329 /* 2 Pass Encoding */
4330 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4331 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4333 /*Picture Settings*/
4334 //hb_job_t * job = fTitle->job;
4335 /* Basic Picture Settings */
4336 /* Use Max Picture settings for whatever the dvd is.*/
4337 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4338 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4339 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4340 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4341 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4342 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
4343 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4344 /* Set crop settings here */
4345 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4346 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4347 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4348 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4349 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4352 /* Audio Sample Rate*/
4353 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4354 /* Audio Bitrate Rate*/
4355 [preset setObject:@"160" forKey:@"AudioBitRate"];
4357 [preset setObject:@"None" forKey:@"Subtitles"];
4360 [preset autorelease];
4365 - (NSDictionary *)CreateAnimationPreset
4367 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4368 /* Get the New Preset Name from the field in the AddPresetPanel */
4369 [preset setObject:@"Animation" forKey:@"PresetName"];
4370 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4371 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4372 /*Set whether or not this is default, at creation set to 0*/
4373 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4374 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4375 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4376 /* Get the New Preset Description from the field in the AddPresetPanel */
4377 [preset setObject:@"HandBrake's settings for cartoons, anime, and CGI." forKey:@"PresetDescription"];
4379 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4380 /* Chapter Markers*/
4381 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4383 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4385 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4386 /* x264 Option String */
4387 [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"];
4389 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4390 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4391 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
4392 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4394 /* Video framerate */
4395 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4397 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4398 /* 2 Pass Encoding */
4399 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4400 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4402 /*Picture Settings*/
4403 //hb_job_t * job = fTitle->job;
4404 /* Basic Picture Settings */
4405 /* Use Max Picture settings for whatever the dvd is.*/
4406 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4407 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4408 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4409 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4410 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4411 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
4412 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4413 /* Set crop settings here */
4414 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4415 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4416 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4417 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4418 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4421 /* Audio Sample Rate*/
4422 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4423 /* Audio Bitrate Rate*/
4424 [preset setObject:@"160" forKey:@"AudioBitRate"];
4426 [preset setObject:@"None" forKey:@"Subtitles"];
4429 [preset autorelease];
4434 - (NSDictionary *)CreateQuickTimePreset
4436 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4437 /* Get the New Preset Name from the field in the AddPresetPanel */
4438 [preset setObject:@"QuickTime" forKey:@"PresetName"];
4439 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4440 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4441 /*Set whether or not this is default, at creation set to 0*/
4442 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4443 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4444 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4445 /* Get the New Preset Description from the field in the AddPresetPanel */
4446 [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"];
4448 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4449 /* Chapter Markers*/
4450 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4452 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4454 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4455 /* x264 Option String */
4456 [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"];
4458 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4459 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4460 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4461 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4463 /* Video framerate */
4464 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4466 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4467 /* 2 Pass Encoding */
4468 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4469 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4471 /*Picture Settings*/
4472 //hb_job_t * job = fTitle->job;
4473 /* Basic Picture Settings */
4474 /* Use Max Picture settings for whatever the dvd is.*/
4475 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4476 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4477 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4478 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4479 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4480 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4481 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4482 /* Set crop settings here */
4483 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4484 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4485 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4486 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4487 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4490 /* Audio Sample Rate*/
4491 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4492 /* Audio Bitrate Rate*/
4493 [preset setObject:@"160" forKey:@"AudioBitRate"];
4495 [preset setObject:@"None" forKey:@"Subtitles"];
4498 [preset autorelease];
4503 - (NSDictionary *)CreateBedlamPreset
4505 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4506 /* Get the New Preset Name from the field in the AddPresetPanel */
4507 [preset setObject:@"Bedlam" forKey:@"PresetName"];
4508 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4509 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4510 /*Set whether or not this is default, at creation set to 0*/
4511 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4512 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4513 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4514 /* Get the New Preset Description from the field in the AddPresetPanel */
4515 [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"];
4517 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4518 /* Chapter Markers*/
4519 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4521 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4523 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4524 /* x264 Option String */
4525 [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"];
4527 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4528 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4529 [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
4530 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4532 /* Video framerate */
4533 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4535 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4536 /* 2 Pass Encoding */
4537 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4538 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4540 /*Picture Settings*/
4541 //hb_job_t * job = fTitle->job;
4542 /* Basic Picture Settings */
4543 /* Use Max Picture settings for whatever the dvd is.*/
4544 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4545 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4546 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4547 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4548 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4549 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4550 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4551 /* Set crop settings here */
4552 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4553 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4554 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4555 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4556 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4559 /* Audio Sample Rate*/
4560 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4561 /* Audio Bitrate Rate*/
4562 [preset setObject:@"160" forKey:@"AudioBitRate"];
4564 [preset setObject:@"None" forKey:@"Subtitles"];
4567 [preset autorelease];
4572 - (NSDictionary *)CreateiPhonePreset
4574 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4575 /* Get the New Preset Name from the field in the AddPresetPanel */
4576 [preset setObject:@"iPhone" forKey:@"PresetName"];
4577 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4578 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4579 /*Set whether or not this is default, at creation set to 0*/
4580 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4581 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4582 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4583 /* Get the New Preset Description from the field in the AddPresetPanel */
4584 [preset setObject:@"HandBrake's settings for the iPhone." forKey:@"PresetDescription"];
4586 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4587 /* Chapter Markers*/
4588 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4590 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4592 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
4593 /* x264 Option String */
4594 [preset setObject:@"cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1" forKey:@"x264Option"];
4596 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4597 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4598 [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
4599 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4601 /* Video framerate */
4602 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4604 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4605 /* 2 Pass Encoding */
4606 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4608 /*Picture Settings*/
4609 //hb_job_t * job = fTitle->job;
4610 /* Basic Picture Settings */
4611 /* Use Max Picture settings for whatever the dvd is.*/
4612 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4613 [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
4614 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4615 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4616 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4617 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4618 /* Set crop settings here */
4619 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4620 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4621 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4622 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4623 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4624 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4627 /* Audio Sample Rate*/
4628 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4629 /* Audio Bitrate Rate*/
4630 [preset setObject:@"128" forKey:@"AudioBitRate"];
4632 [preset setObject:@"None" forKey:@"Subtitles"];
4635 [preset autorelease];
4640 - (NSDictionary *)CreateDeuxSixQuatrePreset
4642 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4643 /* Get the New Preset Name from the field in the AddPresetPanel */
4644 [preset setObject:@"Deux Six Quatre" forKey:@"PresetName"];
4645 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4646 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4647 /*Set whether or not this is default, at creation set to 0*/
4648 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4649 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4650 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4651 /* Get the New Preset Description from the field in the AddPresetPanel */
4652 [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"];
4654 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4655 /* Chapter Markers*/
4656 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4658 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4660 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4661 /* x264 Option String */
4662 [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"];
4664 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4665 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4666 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
4667 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4669 /* Video framerate */
4670 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4672 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4673 /* 2 Pass Encoding */
4674 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4675 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4677 /*Picture Settings*/
4678 //hb_job_t * job = fTitle->job;
4679 /* Basic Picture Settings */
4680 /* Use Max Picture settings for whatever the dvd is.*/
4681 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4682 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4683 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4684 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4685 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4686 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4687 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4688 /* Set crop settings here */
4689 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4690 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4691 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4692 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4693 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4696 /* Audio Sample Rate*/
4697 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4698 /* Audio Bitrate Rate*/
4699 [preset setObject:@"160" forKey:@"AudioBitRate"];
4701 [preset setObject:@"None" forKey:@"Subtitles"];
4704 [preset autorelease];
4709 - (NSDictionary *)CreateBrokePreset
4711 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4712 /* Get the New Preset Name from the field in the AddPresetPanel */
4713 [preset setObject:@"Broke" forKey:@"PresetName"];
4714 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4715 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4716 /*Set whether or not this is default, at creation set to 0*/
4717 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4718 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4719 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4720 /* Get the New Preset Description from the field in the AddPresetPanel */
4721 [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"];
4723 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4724 /* Chapter Markers*/
4725 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4727 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4729 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4730 /* x264 Option String */
4731 [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"];
4733 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoQualityType"];
4734 [preset setObject:@"695" forKey:@"VideoTargetSize"];
4735 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
4736 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4738 /* Video framerate */
4739 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4741 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4742 /* 2 Pass Encoding */
4743 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4744 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4746 /*Picture Settings*/
4747 //hb_job_t * job = fTitle->job;
4748 /* Basic Picture Settings */
4749 /* Use Max Picture settings for whatever the dvd is.*/
4750 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4751 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4752 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
4753 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4754 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4755 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4756 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4757 /* Set crop settings here */
4758 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4759 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4760 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4761 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4762 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4765 /* Audio Sample Rate*/
4766 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4767 /* Audio Bitrate Rate*/
4768 [preset setObject:@"128" forKey:@"AudioBitRate"];
4770 [preset setObject:@"None" forKey:@"Subtitles"];
4773 [preset autorelease];
4778 - (NSDictionary *)CreateBlindPreset
4780 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4781 /* Get the New Preset Name from the field in the AddPresetPanel */
4782 [preset setObject:@"Blind" forKey:@"PresetName"];
4783 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4784 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4785 /*Set whether or not this is default, at creation set to 0*/
4786 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4787 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4788 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4789 /* Get the New Preset Description from the field in the AddPresetPanel */
4790 [preset setObject:@"HandBrake's preset for impatient people who don't care about picture quality." forKey:@"PresetDescription"];
4792 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4793 /* Chapter Markers*/
4794 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4796 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4798 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4799 /* x264 Option String */
4800 [preset setObject:@"" forKey:@"x264Option"];
4802 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4803 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4804 [preset setObject:@"512" forKey:@"VideoAvgBitrate"];
4805 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4807 /* Video framerate */
4808 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4810 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4811 /* 2 Pass Encoding */
4812 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4813 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4815 /*Picture Settings*/
4816 //hb_job_t * job = fTitle->job;
4817 /* Basic Picture Settings */
4818 /* Use Max Picture settings for whatever the dvd is.*/
4819 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4820 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4821 [preset setObject:[NSNumber numberWithInt:512] forKey:@"PictureWidth"];
4822 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4823 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4824 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4825 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4826 /* Set crop settings here */
4827 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4828 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4829 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4830 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4831 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4834 /* Audio Sample Rate*/
4835 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4836 /* Audio Bitrate Rate*/
4837 [preset setObject:@"128" forKey:@"AudioBitRate"];
4839 [preset setObject:@"None" forKey:@"Subtitles"];
4842 [preset autorelease];
4847 - (NSDictionary *)CreateCRFPreset
4849 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4850 /* Get the New Preset Name from the field in the AddPresetPanel */
4851 [preset setObject:@"Constant Quality Rate" forKey:@"PresetName"];
4852 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4853 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4854 /*Set whether or not this is default, at creation set to 0*/
4855 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4856 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4857 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4858 /* Get the New Preset Description from the field in the AddPresetPanel */
4859 [preset setObject:@"HandBrake's preset for consistently excellent quality in one pass, with the downside of entirely unpredictable file sizes and bitrates." forKey:@"PresetDescription"];
4861 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4862 /* Chapter Markers*/
4863 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4865 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4867 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4868 /* x264 Option String */
4869 [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"];
4871 [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
4872 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4873 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4874 [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
4876 /* Video framerate */
4877 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4879 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4880 /* 2 Pass Encoding */
4881 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4882 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4884 /*Picture Settings*/
4885 //hb_job_t * job = fTitle->job;
4886 /* Basic Picture Settings */
4887 /* Use Max Picture settings for whatever the dvd is.*/
4888 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4889 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4890 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4891 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4892 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4893 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4894 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4895 /* Set crop settings here */
4896 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4897 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4898 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4899 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4900 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4903 /* Audio Sample Rate*/
4904 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4905 /* Audio Bitrate Rate*/
4906 [preset setObject:@"160" forKey:@"AudioBitRate"];
4908 [preset setObject:@"None" forKey:@"Subtitles"];
4911 [preset autorelease];
4917 - (IBAction)DeletePreset:(id)sender
4920 NSEnumerator *enumerator;
4922 NSMutableArray *tempArray;
4925 if ( [tableView numberOfSelectedRows] == 0 )
4927 /* Alert user before deleting preset */
4928 /* Comment out for now, tie to user pref eventually */
4931 status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected preset?", @"OK", @"Cancel", nil);
4933 if ( status == NSAlertDefaultReturn ) {
4934 enumerator = [tableView selectedRowEnumerator];
4935 tempArray = [NSMutableArray array];
4937 while ( (index = [enumerator nextObject]) ) {
4938 tempObject = [UserPresets objectAtIndex:[index intValue]];
4939 [tempArray addObject:tempObject];
4942 [UserPresets removeObjectsInArray:tempArray];
4943 [tableView reloadData];
4948 - (IBAction)GetDefaultPresets:(id)sender
4951 NSEnumerator *enumerator = [UserPresets objectEnumerator];
4953 while (tempObject = [enumerator nextObject])
4955 NSDictionary *thisPresetDict = tempObject;
4956 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
4958 presetHbDefault = i;
4960 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
4962 presetUserDefault = i;
4968 - (IBAction)SetDefaultPreset:(id)sender
4971 NSEnumerator *enumerator = [UserPresets objectEnumerator];
4973 /* First make sure the old user specified default preset is removed */
4974 while (tempObject = [enumerator nextObject])
4976 /* make sure we are not removing the default HB preset */
4977 if ([[[UserPresets objectAtIndex:i] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
4979 [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4983 /* Second, go ahead and set the appropriate user specfied preset */
4984 /* we get the chosen preset from the UserPresets array */
4985 if ([[[UserPresets objectAtIndex:[tableView selectedRow]] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
4987 [[UserPresets objectAtIndex:[tableView selectedRow]] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];
4989 presetUserDefault = [tableView selectedRow];
4991 /* We save all of the preset data here */
4993 /* We Reload the New Table data for presets */
4994 [tableView reloadData];
4997 - (IBAction)SelectDefaultPreset:(id)sender
4999 /* if there is a user specified default, we use it */
5000 if (presetUserDefault)
5002 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetUserDefault] byExtendingSelection:NO];
5003 [self tableViewSelected:NULL];
5005 else if (presetHbDefault) //else we use the built in default presetHbDefault
5007 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetHbDefault] byExtendingSelection:NO];
5008 [self tableViewSelected:NULL];
5012 - (IBAction)tableViewSelected:(id)sender
5014 /* Since we cannot disable the presets tableView in terms of clickability
5015 we will use the enabled state of the add presets button to determine whether
5016 or not clicking on a preset will do anything */
5017 if ([fPresetsAdd isEnabled])
5019 if ([tableView selectedRow] >= 0)
5021 /* we get the chosen preset from the UserPresets array */
5022 chosenPreset = [UserPresets objectAtIndex:[tableView selectedRow]];
5023 curUserPresetChosenNum = [sender selectedRow];
5024 /* we set the preset display field in main window here */
5025 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
5026 if ([[chosenPreset objectForKey:@"Default"] intValue] == 1)
5028 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@ (Default)",[chosenPreset valueForKey:@"PresetName"]]];
5032 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
5035 [fDstFormatPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileFormat"]]];
5036 [self FormatPopUpChanged: NULL];
5038 /* Chapter Markers*/
5039 [fCreateChapterMarkers setState:[[chosenPreset objectForKey:@"ChapterMarkers"] intValue]];
5040 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
5041 [fDstMpgLargeFileCheck setState:[[chosenPreset objectForKey:@"Mp4LargeFile"] intValue]];
5043 [fDstCodecsPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileCodecs"]]];
5044 [self CodecsPopUpChanged: NULL];
5046 [fVidEncoderPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoEncoder"]]];
5048 /* We can show the preset options here in the gui if we want to
5049 so we check to see it the user has specified it in the prefs */
5050 [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]];
5052 [self X264AdvancedOptionsSet:NULL];
5054 /* Lets run through the following functions to get variables set there */
5055 [self EncoderPopUpChanged: NULL];
5057 [self CalculateBitrate: NULL];
5060 [fVidQualityMatrix selectCellAtRow:[[chosenPreset objectForKey:@"VideoQualityType"] intValue] column:0];
5062 [fVidTargetSizeField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoTargetSize"]]];
5063 [fVidBitrateField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoAvgBitrate"]]];
5065 [fVidQualitySlider setFloatValue: [[chosenPreset valueForKey:@"VideoQualitySlider"] floatValue]];
5066 [self VideoMatrixChanged: NULL];
5068 /* Video framerate */
5069 [fVidRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoFramerate"]]];
5072 [fVidGrayscaleCheck setState:[[chosenPreset objectForKey:@"VideoGrayScale"] intValue]];
5074 /* 2 Pass Encoding */
5075 [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
5076 [self TwoPassCheckboxChanged: NULL];
5077 /* Turbo 1st pass for 2 Pass Encoding */
5078 [fVidTurboPassCheck setState:[[chosenPreset objectForKey:@"VideoTurboTwoPass"] intValue]];
5082 /* Audio Sample Rate*/
5083 [fAudRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioSampleRate"]]];
5084 /* Audio Bitrate Rate*/
5085 [fAudBitratePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioBitRate"]]];
5087 [fSubPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"Subtitles"]]];
5089 /* Picture Settings */
5090 /* Look to see if we apply these here in objectForKey:@"UsesPictureSettings"] */
5091 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] > 0)
5093 hb_job_t * job = fTitle->job;
5094 /* Check to see if we should use the max picture setting for the current title*/
5095 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"] intValue] == 1)
5097 /* Use Max Picture settings for whatever the dvd is.*/
5098 [self RevertPictureSizeToMax: NULL];
5099 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
5100 if (job->keep_ratio == 1)
5102 hb_fix_aspect( job, HB_KEEP_WIDTH );
5103 if( job->height > fTitle->height )
5105 job->height = fTitle->height;
5106 hb_fix_aspect( job, HB_KEEP_HEIGHT );
5109 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
5111 else // Apply picture settings that were in effect at the time the preset was saved
5113 job->width = [[chosenPreset objectForKey:@"PictureWidth"] intValue];
5114 job->height = [[chosenPreset objectForKey:@"PictureHeight"] intValue];
5115 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
5116 if (job->keep_ratio == 1)
5118 hb_fix_aspect( job, HB_KEEP_WIDTH );
5119 if( job->height > fTitle->height )
5121 job->height = fTitle->height;
5122 hb_fix_aspect( job, HB_KEEP_HEIGHT );
5125 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
5126 [fPicSettingDeinterlace setStringValue: [NSString stringWithFormat: @"%d",[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]]];
5128 if ([chosenPreset objectForKey:@"PictureDetelecine"])
5130 [fPicSettingDetelecine setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PictureDetelecine"]]];
5132 if ([chosenPreset objectForKey:@"PictureDenoise"])
5134 [fPicSettingDenoise setStringValue: [NSString stringWithFormat: @"%d",[[chosenPreset objectForKey:@"PictureDenoise"] intValue]]];
5136 /* If Cropping is set to custom, then recall all four crop values from
5137 when the preset was created and apply them */
5138 if ([[chosenPreset objectForKey:@"PictureAutoCrop"] intValue] == 0)
5140 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
5143 /* Here we use the custom crop values saved at the time the preset was saved */
5144 job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"] intValue];
5145 job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"] intValue];
5146 job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"] intValue];
5147 job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"] intValue];
5150 else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
5152 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
5154 /* Here we use the auto crop values determined right after scan */
5155 job->crop[0] = AutoCropTop;
5156 job->crop[1] = AutoCropBottom;
5157 job->crop[2] = AutoCropLeft;
5158 job->crop[3] = AutoCropRight;
5162 [self CalculatePictureSizing: NULL];
5166 [[fPresetsActionMenu itemAtIndex:0] setEnabled: YES];
5173 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
5175 return [UserPresets count];
5178 /* we use this to determine display characteristics for
5179 each table cell based on content currently only used to
5180 show the built in presets in a blue font. */
5181 - (void)tableView:(NSTableView *)aTableView
5182 willDisplayCell:(id)aCell
5183 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
5185 NSDictionary *userPresetDict = [UserPresets objectAtIndex:rowIndex];
5188 NSColor *shadowColor;
5189 txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]];
5190 /* First, we check to see if its a selected row, if so, we use white since its highlighted in blue */
5191 if ([[aTableView selectedRowIndexes] containsIndex:rowIndex] && ([tableView editedRow] != rowIndex))
5194 fontColor = [NSColor whiteColor];
5195 shadowColor = [NSColor colorWithDeviceRed:(127.0/255.0) green:(140.0/255.0) blue:(160.0/255.0) alpha:1.0];
5199 /* We set the properties of unselected rows */
5200 /* if built-in preset (defined by "type" == 0) we use a blue font */
5201 if ([[userPresetDict objectForKey:@"Type"] intValue] == 0)
5203 fontColor = [NSColor blueColor];
5205 else // User created preset, use a black font
5207 fontColor = [NSColor blackColor];
5211 /* We check to see if this is the HB default, if so, color it appropriately */
5212 if (!presetUserDefault && presetHbDefault && rowIndex == presetHbDefault)
5214 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
5216 /* We check to see if this is the User Specified default, if so, color it appropriately */
5217 if (presetUserDefault && rowIndex == presetUserDefault)
5219 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
5222 [aCell setTextColor:fontColor];
5223 [aCell setFont:txtFont];
5224 /* this shadow stuff (like mail app) for some reason looks crappy, commented out
5225 temporarily in case we want to resurrect it */
5227 NSShadow *shadow = [[NSShadow alloc] init];
5228 NSSize shadowOffset = { width: 1.0, height: -1.5};
5229 [shadow setShadowOffset:shadowOffset];
5230 [shadow setShadowColor:shadowColor];
5235 /* Method to display tooltip with the description for each preset, if available */
5236 - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell
5237 rect:(NSRectPointer)aRect tableColumn:(NSTableColumn *)aTableColumn
5238 row:(int)rowIndex mouseLocation:(NSPoint)aPos
5240 /* initialize the tooltip contents variable */
5242 /* if there is a description for the preset, we show it in the tooltip */
5243 if ([[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"])
5245 loc_tip = [NSString stringWithFormat: @"%@",[[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"]];
5250 loc_tip = @"No description available";
5256 - (id)tableView:(NSTableView *)aTableView
5257 objectValueForTableColumn:(NSTableColumn *)aTableColumn
5260 id theRecord, theValue;
5262 theRecord = [UserPresets objectAtIndex:rowIndex];
5263 theValue = [theRecord objectForKey:[aTableColumn identifier]];
5267 // NSTableDataSource method that we implement to edit values directly in the table...
5268 - (void)tableView:(NSTableView *)aTableView
5269 setObjectValue:(id)anObject
5270 forTableColumn:(NSTableColumn *)aTableColumn
5275 theRecord = [UserPresets objectAtIndex:rowIndex];
5276 [theRecord setObject:anObject forKey:@"PresetName"];
5277 /* We Sort the Presets By Factory or Custom */
5278 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
5279 ascending:YES] autorelease];
5280 /* We Sort the Presets Alphabetically by name */
5281 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
5282 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
5283 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
5284 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
5285 [UserPresets setArray:sortedArray];
5286 /* We Reload the New Table data for presets */
5287 [tableView reloadData];
5288 /* We save all of the preset data here */
5295 [UserPresets writeToFile:UserPresetsFile atomically:YES];
5296 /* We get the default preset in case it changed */
5297 [self GetDefaultPresets: NULL];
5303 - (void) controlTextDidBeginEditing: (NSNotification *) notification
5305 [self CalculateBitrate: NULL];
5308 - (void) controlTextDidEndEditing: (NSNotification *) notification
5310 [self CalculateBitrate: NULL];
5313 - (void) controlTextDidChange: (NSNotification *) notification
5315 [self CalculateBitrate: NULL];
5318 - (IBAction) OpenHomepage: (id) sender
5320 [[NSWorkspace sharedWorkspace] openURL: [NSURL
5321 URLWithString:@"http://handbrake.m0k.org/"]];
5324 - (IBAction) OpenForums: (id) sender
5326 [[NSWorkspace sharedWorkspace] openURL: [NSURL
5327 URLWithString:@"http://handbrake.m0k.org/forum/"]];
5329 - (IBAction) OpenUserGuide: (id) sender
5331 [[NSWorkspace sharedWorkspace] openURL: [NSURL
5332 URLWithString:@"http://handbrake.m0k.org/trac/wiki/HandBrakeGuide"]];
5336 * Shows debug output window.
5338 - (IBAction)showDebugOutputPanel:(id)sender
5340 [outputPanel showOutputPanel:sender];
5344 * Creates preferences controller, shows preferences window modally, and
5345 * releases the controller after user has closed the window.
5347 - (IBAction)showPreferencesWindow:(id)sender
5349 HBPreferencesController *controller = [[HBPreferencesController alloc] init];
5350 [controller runModal:nil];
5351 [controller release];