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"];
270 [fAudBitratePopUp removeAllItems];
271 for( int i = 0; i < hb_audio_bitrates_count; i++ )
273 [fAudBitratePopUp addItemWithTitle:
274 [NSString stringWithCString: hb_audio_bitrates[i].string]];
277 [fAudBitratePopUp selectItemAtIndex: hb_audio_bitrates_default];
279 /* Audio samplerate */
280 [fAudRatePopUp removeAllItems];
281 for( int i = 0; i < hb_audio_rates_count; i++ )
283 [fAudRatePopUp addItemWithTitle:
284 [NSString stringWithCString: hb_audio_rates[i].string]];
286 [fAudRatePopUp selectItemAtIndex: hb_audio_rates_default];
289 [fStatusField setStringValue: @""];
292 /* Use new Toolbar start and pause here */
293 startButtonEnabled = NO;
295 AddToQueueButtonEnabled = NO;
296 pauseButtonEnabled = NO;
300 [fPresetsActionButton setMenu:fPresetsActionMenu];
302 /* We disable the Turbo 1st pass checkbox since we are not x264 */
303 [fVidTurboPassCheck setEnabled: NO];
304 [fVidTurboPassCheck setState: NSOffState];
307 /* lets get our default prefs here */
308 [self GetDefaultPresets: NULL];
309 /* lets initialize the current successful scancount here to 0 */
310 currentSuccessfulScanCount = 0;
315 // ============================================================
316 // NSToolbar Related Methods
317 // ============================================================
319 - (void) setupToolbar {
320 // Create a new toolbar instance, and attach it to our document window
321 NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: MyDocToolbarIdentifier] autorelease];
323 // Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults
324 [toolbar setAllowsUserCustomization: YES];
325 [toolbar setAutosavesConfiguration: YES];
326 [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
328 // We are the delegate
329 [toolbar setDelegate: self];
331 // Attach the toolbar to the document window
332 [fWindow setToolbar: toolbar];
335 - (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
336 // Required delegate method: Given an item identifier, this method returns an item
337 // The toolbar will use this method to obtain toolbar items that can be displayed in the customization sheet, or in the toolbar itself
338 NSToolbarItem *toolbarItem = nil;
340 if ([itemIdent isEqual: ToggleDrawerIdentifier]) {
341 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
343 // Set the text label to be displayed in the toolbar and customization palette
344 [toolbarItem setLabel: @"Toggle Presets"];
345 [toolbarItem setPaletteLabel: @"Toggler Presets"];
347 // 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
348 [toolbarItem setToolTip: @"Open/Close Preset Drawer"];
349 [toolbarItem setImage: [NSImage imageNamed: @"Drawer-List2"]];
351 // Tell the item what message to send when it is clicked
352 [toolbarItem setTarget: self];
353 [toolbarItem setAction: @selector(toggleDrawer)];
355 } else if ([itemIdent isEqual: StartEncodingIdentifier]) {
356 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
358 // Set the text label to be displayed in the toolbar and customization palette
359 [toolbarItem setLabel: @"Start"];
360 [toolbarItem setPaletteLabel: @"Start Encoding"];
362 // 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
363 [toolbarItem setToolTip: @"Start Encoding"];
364 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
366 // Tell the item what message to send when it is clicked
367 [toolbarItem setTarget: self];
368 [toolbarItem setAction: @selector(Rip:)];
372 } else if ([itemIdent isEqual: ShowQueueIdentifier]) {
373 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
375 // Set the text label to be displayed in the toolbar and customization palette
376 [toolbarItem setLabel: @"Show Queue"];
377 [toolbarItem setPaletteLabel: @"Show Queue"];
379 // 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
380 [toolbarItem setToolTip: @"Show Queue"];
381 [toolbarItem setImage: [NSImage imageNamed: @"Brushed Window"]];
383 // Tell the item what message to send when it is clicked
384 [toolbarItem setTarget: self];
385 [toolbarItem setAction: @selector(ShowQueuePanel:)];
387 } else if ([itemIdent isEqual: AddToQueueIdentifier]) {
388 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
390 // Set the text label to be displayed in the toolbar and customization palette
391 [toolbarItem setLabel: @"Add to Queue"];
392 [toolbarItem setPaletteLabel: @"Add to Queue"];
394 // 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
395 [toolbarItem setToolTip: @"Add to Queue"];
396 [toolbarItem setImage: [NSImage imageNamed: @"Add"]];
398 // Tell the item what message to send when it is clicked
399 [toolbarItem setTarget: self];
400 [toolbarItem setAction: @selector(AddToQueue:)];
403 } else if ([itemIdent isEqual: PauseEncodingIdentifier]) {
404 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
406 // Set the text label to be displayed in the toolbar and customization palette
407 [toolbarItem setLabel: @"Pause"];
408 [toolbarItem setPaletteLabel: @"Pause Encoding"];
410 // 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
411 [toolbarItem setToolTip: @"Pause Encoding"];
412 [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
414 // Tell the item what message to send when it is clicked
415 [toolbarItem setTarget: self];
416 [toolbarItem setAction: @selector(Pause:)];
418 } else if ([itemIdent isEqual: DebugOutputIdentifier]) {
419 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
421 // Set the text label to be displayed in the toolbar and customization palette
422 [toolbarItem setLabel: @"Activity Window"];
423 [toolbarItem setPaletteLabel: @"Show Activity Window"];
425 // 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
426 [toolbarItem setToolTip: @"Show Activity Window"];
427 [toolbarItem setImage: [NSImage imageNamed: @"Terminal"]];
429 // Tell the item what message to send when it is clicked
430 [toolbarItem setTarget: self];
431 [toolbarItem setAction: @selector(showDebugOutputPanel:)];
433 } else if ([itemIdent isEqual: ChooseSourceIdentifier]) {
434 toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease];
436 // Set the text label to be displayed in the toolbar and customization palette
437 [toolbarItem setLabel: @"Source"];
438 [toolbarItem setPaletteLabel: @"Source"];
440 // 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
441 [toolbarItem setToolTip: @"Choose Video Source"];
442 [toolbarItem setImage: [NSImage imageNamed: @"Disc"]];
444 // Tell the item what message to send when it is clicked
445 [toolbarItem setTarget: self];
446 [toolbarItem setAction: @selector(ShowScanPanel:)];
449 //itemIdent refered to a toolbar item that is not provide or supported by us or cocoa
450 //Returning nil will inform the toolbar this kind of item is not supported
457 - (void) toggleDrawer {
458 [fPresetDrawer toggle:self];
461 - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar {
462 // Required delegate method: Returns the ordered list of items to be shown in the toolbar by default
463 // If during the toolbar's initialization, no overriding values are found in the user defaults, or if the
464 // user chooses to revert to the default items this set will be used
465 return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier, PauseEncodingIdentifier,
466 AddToQueueIdentifier, ShowQueueIdentifier,
467 NSToolbarFlexibleSpaceItemIdentifier,
468 NSToolbarSpaceItemIdentifier, DebugOutputIdentifier, ToggleDrawerIdentifier, nil];
471 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar {
472 // Required delegate method: Returns the list of all allowed items by identifier. By default, the toolbar
473 // does not assume any items are allowed, even the separator. So, every allowed item must be explicitly listed
474 // The set of allowed items is used to construct the customization palette
475 return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier,
476 DebugOutputIdentifier, NSToolbarCustomizeToolbarItemIdentifier,
477 NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, ChooseSourceIdentifier,
478 NSToolbarSeparatorItemIdentifier,ToggleDrawerIdentifier, nil];
481 - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem {
482 // Optional method: This message is sent to us since we are the target of some toolbar item actions
484 if ([[toolbarItem itemIdentifier] isEqual: ToggleDrawerIdentifier]) {
487 if ([[toolbarItem itemIdentifier] isEqual: StartEncodingIdentifier]) {
488 enable = startButtonEnabled;
490 [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];
491 [toolbarItem setLabel: @"Cancel"];
492 [toolbarItem setPaletteLabel: @"Cancel"];
493 [toolbarItem setToolTip: @"Cancel Encoding"];
496 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
497 [toolbarItem setLabel: @"Start"];
498 [toolbarItem setPaletteLabel: @"Start Encoding"];
499 [toolbarItem setToolTip: @"Start Encoding"];
503 if ([[toolbarItem itemIdentifier] isEqual: PauseEncodingIdentifier]) {
504 enable = pauseButtonEnabled;
506 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
507 [toolbarItem setLabel: @"Resume"];
508 [toolbarItem setPaletteLabel: @"Resume Encoding"];
509 [toolbarItem setToolTip: @"Resume Encoding"];
512 [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
513 [toolbarItem setLabel: @"Pause"];
514 [toolbarItem setPaletteLabel: @"Pause Encoding"];
515 [toolbarItem setToolTip: @"Pause Encoding"];
518 if ([[toolbarItem itemIdentifier] isEqual: DebugOutputIdentifier]) {
521 if ([[toolbarItem itemIdentifier] isEqual: ShowQueueIdentifier]) {
524 if ([[toolbarItem itemIdentifier] isEqual: AddToQueueIdentifier]) {
525 enable = AddToQueueButtonEnabled;
527 if ([[toolbarItem itemIdentifier] isEqual: ChooseSourceIdentifier]) {
533 // register a test notification and make
534 // it enabled by default
535 #define SERVICE_NAME @"Encode Done"
536 - (NSDictionary *)registrationDictionaryForGrowl
538 NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
539 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL,
540 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT,
543 return registrationDictionary;
545 - (void) TranslateStrings
547 [fSrcDVD1Field setStringValue: _( @"DVD:" )];
548 [fSrcTitleField setStringValue: _( @"Title:" )];
549 [fSrcChapterField setStringValue: _( @"Chapters:" )];
550 [fSrcChapterToField setStringValue: _( @"to" )];
551 [fSrcDuration1Field setStringValue: _( @"Duration:" )];
553 [fDstFormatField setStringValue: _( @"File format:" )];
554 [fDstCodecsField setStringValue: _( @"Codecs:" )];
555 [fDstFile1Field setStringValue: _( @"File:" )];
556 [fDstBrowseButton setTitle: _( @"Browse" )];
558 [fVidRateField setStringValue: _( @"Framerate (fps):" )];
559 [fVidEncoderField setStringValue: _( @"Encoder:" )];
560 [fVidQualityField setStringValue: _( @"Quality:" )];
563 /***********************************************************************
565 ***********************************************************************
566 * Shows a progression bar on the dock icon, filled according to
567 * 'progress' (0.0 <= progress <= 1.0).
568 * Called with progress < 0.0 or progress > 1.0, restores the original
570 **********************************************************************/
571 - (void) UpdateDockIcon: (float) progress
575 NSBitmapImageRep * bmp;
577 uint32_t black = htonl( 0x000000FF );
578 uint32_t red = htonl( 0xFF0000FF );
579 uint32_t white = htonl( 0xFFFFFFFF );
580 int row_start, row_end;
583 /* Get application original icon */
584 icon = [NSImage imageNamed: @"NSApplicationIcon"];
586 if( progress < 0.0 || progress > 1.0 )
588 [NSApp setApplicationIconImage: icon];
592 /* Get it in a raw bitmap form */
593 tiff = [icon TIFFRepresentationUsingCompression:
594 NSTIFFCompressionNone factor: 1.0];
595 bmp = [NSBitmapImageRep imageRepWithData: tiff];
597 /* Draw the progression bar */
598 /* It's pretty simple (ugly?) now, but I'm no designer */
600 row_start = 3 * (int) [bmp size].height / 4;
601 row_end = 7 * (int) [bmp size].height / 8;
603 for( i = row_start; i < row_start + 2; i++ )
605 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
606 for( j = 0; j < (int) [bmp size].width; j++ )
611 for( i = row_start + 2; i < row_end - 2; i++ )
613 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
616 for( j = 2; j < (int) [bmp size].width - 2; j++ )
618 if( j < 2 + (int) ( ( [bmp size].width - 4.0 ) * progress ) )
630 for( i = row_end - 2; i < row_end; i++ )
632 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
633 for( j = 0; j < (int) [bmp size].width; j++ )
639 /* Now update the dock icon */
640 tiff = [bmp TIFFRepresentationUsingCompression:
641 NSTIFFCompressionNone factor: 1.0];
642 icon = [[NSImage alloc] initWithData: tiff];
643 [NSApp setApplicationIconImage: icon];
647 - (void) UpdateUI: (NSTimer *) timer
651 list = hb_get_titles( fHandle );
652 /* check to see if there has been a new scan done
653 this bypasses the constraints of HB_STATE_WORKING
654 not allowing setting a newly scanned source */
655 int checkScanCount = hb_get_scancount( fHandle );
656 if (checkScanCount > currentScanCount)
659 currentScanCount = checkScanCount;
660 [fScanController Cancel: NULL];
661 [fScanIndicator setIndeterminate: NO];
662 [fScanIndicator setDoubleValue: 0.0];
663 [fScanIndicator setHidden: YES];
664 [fScanController Cancel: NULL];
665 [self ShowNewScan: NULL];
673 hb_get_state( fHandle, &s );
680 #define p s.param.scanning
681 case HB_STATE_SCANNING:
683 [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
684 _( @"Scanning title %d of %d..." ),
685 p.title_cur, p.title_count]];
686 [fScanIndicator setIndeterminate: NO];
687 [fScanIndicator setDoubleValue: 100.0 * ( p.title_cur - 1 ) /
693 #define p s.param.scandone
694 case HB_STATE_SCANDONE:
697 [fScanIndicator setIndeterminate: NO];
698 [fScanIndicator setDoubleValue: 0.0];
699 [fScanIndicator setHidden: YES];
700 [fScanController Cancel: NULL];
701 [self ShowNewScan: NULL];
706 #define p s.param.working
707 case HB_STATE_WORKING:
709 float progress_total;
710 NSMutableString * string;
711 /* Currently, p.job_cur and p.job_count get screwed up when adding
712 jobs during encoding, if they cannot be fixed in libhb, will implement a
713 nasty but working cocoa solution */
714 /* Update text field */
715 string = [NSMutableString stringWithFormat: _( @"Encoding: task %d of %d, %.2f %%" ), p.job_cur, p.job_count, 100.0 * p.progress];
719 [string appendFormat:
720 _( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)" ),
721 p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds];
723 [fStatusField setStringValue: string];
726 progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
727 [fRipIndicator setIndeterminate: NO];
728 [fRipIndicator setDoubleValue: 100.0 * progress_total];
730 /* Update dock icon */
731 [self UpdateDockIcon: progress_total];
733 /* new toolbar controls */
734 pauseButtonEnabled = YES;
736 startButtonEnabled = YES;
743 #define p s.param.muxing
744 case HB_STATE_MUXING:
746 NSMutableString * string;
748 /* Update text field */
749 string = [NSMutableString stringWithFormat:
751 [fStatusField setStringValue: string];
754 [fRipIndicator setIndeterminate: YES];
755 [fRipIndicator startAnimation: nil];
757 /* Update dock icon */
758 [self UpdateDockIcon: 1.0];
760 //[fPauseButton setEnabled: YES];
761 //[fPauseButton setTitle: _( @"Pause" )];
762 //[fRipButton setEnabled: YES];
763 // [fRipButton setTitle: _( @"Cancel" )];
768 case HB_STATE_PAUSED:
769 //[fStatusField setStringValue: _( @"Paused" )];
770 //[fPauseButton setEnabled: YES];
771 //[fPauseButton setTitle: _( @"Resume" )];
772 //[fRipButton setEnabled: YES];
773 //[fRipButton setTitle: _( @"Cancel" )];
774 /* new toolbar controls */
775 pauseButtonEnabled = YES;
777 startButtonEnabled = YES;
781 case HB_STATE_WORKDONE:
783 [fStatusField setStringValue: _( @"Done." )];
784 [fRipIndicator setIndeterminate: NO];
785 [fRipIndicator setDoubleValue: 0.0];
786 //[fRipButton setTitle: _( @"Start" )];
788 /* Restore dock icon */
789 [self UpdateDockIcon: -1.0];
791 //[fPauseButton setEnabled: NO];
792 //[fPauseButton setTitle: _( @"Pause" )];
793 // [fRipButton setEnabled: YES];
794 // [fRipButton setTitle: _( @"Start" )];
795 /* new toolbar controls */
796 pauseButtonEnabled = NO;
798 startButtonEnabled = YES;
800 NSRect frame = [fWindow frame];
801 if (frame.size.width <= 591)
802 frame.size.width = 591;
803 frame.size.height += -44;
804 frame.origin.y -= -44;
805 [fWindow setFrame:frame display:YES animate:YES];
809 while( ( job = hb_job( fHandle, 0 ) ) )
811 hb_rem( fHandle, job );
813 /* Check to see if the encode state has not been cancelled
814 to determine if we should check for encode done notifications */
815 if (fEncodeState != 2) {
816 /* If Growl Notification or Window and Growl has been selected */
817 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] ||
818 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
820 /*Growl Notification*/
821 [self showGrowlDoneNotification: NULL];
823 /* If Alert Window or Window and Growl has been selected */
824 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
825 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
827 /*On Screen Notification*/
830 status = NSRunAlertPanel(@"Put down that cocktail...",@"your HandBrake encode is done!", @"OK", nil, nil);
831 [NSApp requestUserAttention:NSCriticalRequest];
832 if ( status == NSAlertDefaultReturn )
834 [self EnableUI: YES];
839 [self EnableUI: YES];
841 /* If sleep has been selected */
842 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
845 NSDictionary* errorDict;
846 NSAppleEventDescriptor* returnDescriptor = NULL;
847 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
848 @"tell application \"Finder\" to sleep"];
849 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
850 [scriptObject release];
851 [self EnableUI: YES];
853 /* If Shutdown has been selected */
854 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
857 NSDictionary* errorDict;
858 NSAppleEventDescriptor* returnDescriptor = NULL;
859 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
860 @"tell application \"Finder\" to shut down"];
861 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
862 [scriptObject release];
863 [self EnableUI: YES];
866 // MetaX insertion via AppleScript
867 if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
869 NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", [fDstFile2Field stringValue], @"\")"]];
870 [myScript executeAndReturnError: nil];
878 [self EnableUI: YES];
884 /* Lets show the queue status
885 here in the main window*/
886 int queue_count = hb_count( fHandle );
889 [fQueueStatus setStringValue: [NSString stringWithFormat:
890 @"%d task%s in the queue",
891 queue_count, ( queue_count > 1 ) ? "s" : ""]];
895 [fQueueStatus setStringValue: @""];
898 [[NSRunLoop currentRunLoop] addTimer: [NSTimer
899 scheduledTimerWithTimeInterval: 0.5 target: self
900 selector: @selector( UpdateUI: ) userInfo: NULL repeats: FALSE]
901 forMode: NSModalPanelRunLoopMode];
903 - (IBAction) ShowNewScan:(id)sender
907 int indxpri=0; // Used to search the longuest title (default in combobox)
908 int longuestpri=0; // Used to search the longuest title (default in combobox)
910 list = hb_get_titles( fHandle );
912 if( !hb_list_count( list ) )
914 /* We display a message if a valid dvd source was not chosen */
915 if (sourceDisplayName)
917 /* Temporary string if til restoring old source is fixed */
918 [fSrcDVD2Field setStringValue: @"Not A Valid Source"];
919 //[fSrcDVD2Field setStringValue: [NSString stringWithFormat: @"%s", sourceDisplayName]];
923 [fSrcDVD2Field setStringValue: @"No Valid Title Found"];
928 /* We increment the successful scancount here by one,
929 which we use at the end of this function to tell the gui
930 if this is the first successful scan since launch and whether
931 or not we should set all settings to the defaults */
932 currentSuccessfulScanCount++;
934 [fSrcTitlePopUp removeAllItems];
935 for( int i = 0; i < hb_list_count( list ); i++ )
937 title = (hb_title_t *) hb_list_item( list, i );
938 /*Set DVD Name at top of window*/
939 [fSrcDVD2Field setStringValue:[NSString stringWithUTF8String: title->name]];
941 currentSource = [NSString stringWithUTF8String: title->dvd];
944 /* Use the dvd name in the default output field here
945 May want to add code to remove blank spaces for some dvd names*/
946 /* Check to see if the last destination has been set,use if so, if not, use Desktop */
947 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"])
949 [fDstFile2Field setStringValue: [NSString stringWithFormat:
950 @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],[NSString
951 stringWithUTF8String: title->name]]];
955 [fDstFile2Field setStringValue: [NSString stringWithFormat:
956 @"%@/Desktop/%@.mp4", NSHomeDirectory(),[NSString
957 stringWithUTF8String: title->name]]];
961 if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds)
963 longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds;
968 int format = [fDstFormatPopUp indexOfSelectedItem];
974 /*Get Default MP4 File Extension for mpeg4 (.mp4 or .m4v) from prefs*/
975 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
993 NSString * string = [fDstFile2Field stringValue];
994 /* Add/replace File Output name to the correct extension*/
995 if( [string characterAtIndex: [string length] - 4] == '.' )
997 [fDstFile2Field setStringValue: [NSString stringWithFormat:
998 @"%@.%s", [string substringToIndex: [string length] - 4],
1003 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1004 @"%@.%s", string, ext]];
1008 [fSrcTitlePopUp addItemWithTitle: [NSString
1009 stringWithFormat: @"%d - %02dh%02dm%02ds",
1010 title->index, title->hours, title->minutes,
1014 // Select the longuest title
1015 [fSrcTitlePopUp selectItemAtIndex: indxpri];
1016 [self TitlePopUpChanged: NULL];
1017 /* We set the auto crop in the main window to value "1" just as in PictureController,
1018 as it does not seem to be taken from any job-> variable */
1019 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
1023 [self EnableUI: YES];
1025 startButtonEnabled = YES;
1027 AddToQueueButtonEnabled = YES;
1028 pauseButtonEnabled = NO;
1030 /* we record the current source name here in case the next scan is unsuccessful,
1031 then we can replace the scan progress with the old name if necessary */
1032 sourceDisplayName = [NSString stringWithFormat:[fSrcDVD2Field stringValue]];
1034 /* if its the initial successful scan after awakeFromNib */
1035 if (currentSuccessfulScanCount == 1)
1037 [self SelectDefaultPreset: NULL];
1044 -(IBAction)showGrowlDoneNotification:(id)sender
1048 [GrowlApplicationBridge
1049 notifyWithTitle:@"Put down that cocktail..."
1050 description:@"your HandBrake encode is done!"
1051 notificationName:SERVICE_NAME
1057 - (void) EnableUI: (bool) b
1059 NSControl * controls[] =
1060 { fSrcDVD1Field, fSrcTitleField, fSrcTitlePopUp,
1061 fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField,
1062 fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field,
1063 fDstFormatField, fDstFormatPopUp, fDstCodecsField,
1064 fDstCodecsPopUp, fDstFile1Field, fDstFile2Field,
1065 fDstBrowseButton, fVidRateField, fVidRatePopUp,
1066 fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
1067 fVidQualityMatrix, fVidGrayscaleCheck, fSubField, fSubPopUp,
1068 fAudLang1Field, fAudLang1PopUp, fAudLang2Field, fAudLang2PopUp,
1069 fAudTrack1MixLabel, fAudTrack1MixPopUp, fAudTrack2MixLabel, fAudTrack2MixPopUp,
1070 fAudRateField, fAudRatePopUp, fAudBitrateField,
1071 fAudBitratePopUp, fPictureButton,fQueueStatus,
1072 fPicSrcWidth,fPicSrcHeight,fPicSettingWidth,fPicSettingHeight,
1073 fPicSettingARkeep,fPicSettingDeinterlace,fPicSettingARkeepDsply,
1074 fPicSettingDeinterlaceDsply,fPicLabelSettings,fPicLabelSrc,fPicLabelOutp,
1075 fPicLabelAr,fPicLabelDeinter,fPicLabelSrcX,fPicLabelOutputX,
1076 fPicLabelPAROutp,fPicLabelPAROutputX,fPicSettingPARWidth,fPicSettingPARHeight,
1077 fPicSettingPARDsply,fPicLabelAnamorphic,tableView,fPresetsAdd,fPresetsDelete,
1078 fCreateChapterMarkers,fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel,
1079 fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp,fX264optNfpskipLabel,fX264optNfpskipSwitch,
1080 fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp,
1081 fX264optTrellisLabel,fX264optTrellisPopUp,fX264optMixedRefsLabel,fX264optMixedRefsSwitch,
1082 fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp,
1083 fX264optWeightBLabel,fX264optWeightBSwitch,fX264optBRDOLabel,fX264optBRDOSwitch,
1084 fX264optBPyramidLabel,fX264optBPyramidSwitch,fX264optBiMELabel,fX264optBiMESwitch,
1085 fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel,
1086 fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch,
1087 fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp,fVidTurboPassCheck,fDstMpgLargeFileCheck,fPicSettingAutoCropLabel,
1088 fPicSettingAutoCropDsply,fPicSettingDetelecine,fPicSettingDetelecineLabel};
1090 for( unsigned i = 0;
1091 i < sizeof( controls ) / sizeof( NSControl * ); i++ )
1093 if( [[controls[i] className] isEqualToString: @"NSTextField"] )
1095 NSTextField * tf = (NSTextField *) controls[i];
1096 if( ![tf isBezeled] )
1098 [tf setTextColor: b ? [NSColor controlTextColor] :
1099 [NSColor disabledControlTextColor]];
1103 [controls[i] setEnabled: b];
1109 /* if we're enabling the interface, check if the audio mixdown controls need to be enabled or not */
1110 /* these will have been enabled by the mass control enablement above anyway, so we're sense-checking it here */
1111 [self SetEnabledStateOfAudioMixdownControls: NULL];
1115 [tableView setEnabled: NO];
1119 [self VideoMatrixChanged: NULL];
1122 - (IBAction) ShowScanPanel: (id) sender
1124 [fScanController Show];
1127 - (IBAction) OpenMainWindow: (id) sender
1129 [fWindow makeKeyAndOrderFront:nil];
1130 [fWindow setReleasedWhenClosed: YES];
1132 - (BOOL) windowShouldClose: (id) sender
1135 /* See if we are currently running */
1137 hb_get_state( fHandle, &s );
1138 if ( s.state == HB_STATE_WORKING)
1140 /* If we are running, leave in memory when closing main window */
1141 [fWindow setReleasedWhenClosed: NO];
1147 /* Stop the application when the user closes the window */
1148 [NSApp terminate: self];
1154 - (IBAction) VideoMatrixChanged: (id) sender;
1156 bool target, bitrate, quality;
1158 target = bitrate = quality = false;
1159 if( [fVidQualityMatrix isEnabled] )
1161 switch( [fVidQualityMatrix selectedRow] )
1174 [fVidTargetSizeField setEnabled: target];
1175 [fVidBitrateField setEnabled: bitrate];
1176 [fVidQualitySlider setEnabled: quality];
1177 [fVidTwoPassCheck setEnabled: !quality &&
1178 [fVidQualityMatrix isEnabled]];
1181 [fVidTwoPassCheck setState: NSOffState];
1184 [self QualitySliderChanged: sender];
1185 [self CalculateBitrate: sender];
1186 [self CustomSettingUsed: sender];
1189 - (IBAction) QualitySliderChanged: (id) sender
1191 [fVidConstantCell setTitle: [NSString stringWithFormat:
1192 _( @"Constant quality: %.0f %%" ), 100.0 *
1193 [fVidQualitySlider floatValue]]];
1194 [self CustomSettingUsed: sender];
1197 - (IBAction) BrowseFile: (id) sender
1199 /* Open a panel to let the user choose and update the text field */
1200 NSSavePanel * panel = [NSSavePanel savePanel];
1201 /* We get the current file name and path from the destination field here */
1202 [panel beginSheetForDirectory: [[fDstFile2Field stringValue] stringByDeletingLastPathComponent] file: [[fDstFile2Field stringValue] lastPathComponent]
1203 modalForWindow: fWindow modalDelegate: self
1204 didEndSelector: @selector( BrowseFileDone:returnCode:contextInfo: )
1208 - (void) BrowseFileDone: (NSSavePanel *) sheet
1209 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1211 if( returnCode == NSOKButton )
1213 [fDstFile2Field setStringValue: [sheet filename]];
1218 - (IBAction) ShowPicturePanel: (id) sender
1220 hb_list_t * list = hb_get_titles( fHandle );
1221 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1222 [fSrcTitlePopUp indexOfSelectedItem] );
1224 /* Resize the panel */
1226 newSize.width = 246 + title->width;
1227 newSize.height = 80 + title->height;
1228 [fPicturePanel setContentSize: newSize];
1230 [fPictureController SetTitle: title];
1232 [NSApp beginSheet: fPicturePanel modalForWindow: fWindow
1233 modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
1234 [NSApp runModalForWindow: fPicturePanel];
1235 [NSApp endSheet: fPicturePanel];
1236 [fPicturePanel orderOut: self];
1237 [self CalculatePictureSizing: sender];
1240 - (IBAction) ShowQueuePanel: (id) sender
1242 /* Update the OutlineView */
1243 [fQueueController Update: sender];
1245 /* Show the panel */
1246 [NSApp beginSheet: fQueuePanel modalForWindow: fWindow
1247 modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
1248 [NSApp runModalForWindow: fQueuePanel];
1249 [NSApp endSheet: fQueuePanel];
1250 [fQueuePanel orderOut: self];
1255 hb_list_t * list = hb_get_titles( fHandle );
1256 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1257 [fSrcTitlePopUp indexOfSelectedItem] );
1258 hb_job_t * job = title->job;
1261 /* Chapter selection */
1262 job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
1263 job->chapter_end = [fSrcChapterEndPopUp indexOfSelectedItem] + 1;
1265 /* Format and codecs */
1266 int format = [fDstFormatPopUp indexOfSelectedItem];
1267 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1268 job->mux = FormatSettings[format][codecs] & HB_MUX_MASK;
1269 job->vcodec = FormatSettings[format][codecs] & HB_VCODEC_MASK;
1270 job->acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
1271 /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
1272 if ([fDstFormatPopUp indexOfSelectedItem] == 0)
1274 /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being
1275 mpeg4 and the checkbox being checked
1276 *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/
1277 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0 && [fDstMpgLargeFileCheck state] == NSOnState)
1279 job->largeFileSize = 1;
1283 job->largeFileSize = 0;
1286 if ([fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 3)
1288 /* We set the chapter marker extraction here based on the format being
1289 mpeg4 or mkv and the checkbox being checked */
1290 if ([fCreateChapterMarkers state] == NSOnState)
1292 job->chapter_markers = 1;
1296 job->chapter_markers = 0;
1299 if( ( job->vcodec & HB_VCODEC_FFMPEG ) &&
1300 [fVidEncoderPopUp indexOfSelectedItem] > 0 )
1302 job->vcodec = HB_VCODEC_XVID;
1304 if( job->vcodec & HB_VCODEC_X264 )
1306 if ([fVidEncoderPopUp indexOfSelectedItem] > 0 )
1308 /* Just use new Baseline Level 3.0
1309 Lets Deprecate Baseline Level 1.3h264_level*/
1310 job->h264_level = 30;
1311 job->mux = HB_MUX_IPOD;
1312 /* move sanity check for iPod Encoding here */
1313 job->pixel_ratio = 0 ;
1317 /* Set this flag to switch from Constant Quantizer(default) to Constant Rate Factor Thanks jbrjake
1318 Currently only used with Constant Quality setting*/
1319 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0 && [fVidQualityMatrix selectedRow] == 2)
1324 /* Below Sends x264 options to the core library if x264 is selected*/
1325 /* Lets use this as per Nyx, Thanks Nyx!*/
1326 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1327 /* Turbo first pass if two pass and Turbo First pass is selected */
1328 if( [fVidTwoPassCheck state] == NSOnState && [fVidTurboPassCheck state] == NSOnState )
1330 /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
1331 NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:weightb=0:trellis=0:no-fast-pskip=0:8x8dct=0";
1332 /* append the "Turbo" string variable to the existing opts string.
1333 Note: the "Turbo" string must be appended, not prepended to work properly*/
1334 NSString *firstPassOptStringCombined = [[fDisplayX264Options stringValue] stringByAppendingString:firstPassOptStringTurbo];
1335 strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
1339 strcpy(job->x264opts, [[fDisplayX264Options stringValue] UTF8String]);
1342 job->h264_13 = [fVidEncoderPopUp indexOfSelectedItem];
1345 /* Video settings */
1346 if( [fVidRatePopUp indexOfSelectedItem] > 0 )
1348 job->vrate = 27000000;
1349 job->vrate_base = hb_video_rates[[fVidRatePopUp
1350 indexOfSelectedItem]-1].rate;
1354 job->vrate = title->rate;
1355 job->vrate_base = title->rate_base;
1358 switch( [fVidQualityMatrix selectedRow] )
1362 Bitrate should already have been calculated and displayed
1363 in fVidBitrateField, so let's just use it */
1365 job->vquality = -1.0;
1366 job->vbitrate = [fVidBitrateField intValue];
1369 job->vquality = [fVidQualitySlider floatValue];
1374 job->grayscale = ( [fVidGrayscaleCheck state] == NSOnState );
1378 /* Subtitle settings */
1379 job->subtitle = [fSubPopUp indexOfSelectedItem] - 1;
1381 /* Audio tracks and mixdowns */
1382 /* check for the condition where track 2 has an audio selected, but track 1 does not */
1383 /* we will use track 2 as track 1 in this scenario */
1384 if ([fAudLang1PopUp indexOfSelectedItem] > 0)
1386 job->audios[0] = [fAudLang1PopUp indexOfSelectedItem] - 1;
1387 job->audios[1] = [fAudLang2PopUp indexOfSelectedItem] - 1; /* will be -1 if "none" is selected */
1388 job->audios[2] = -1;
1389 job->audio_mixdowns[0] = [[fAudTrack1MixPopUp selectedItem] tag];
1390 job->audio_mixdowns[1] = [[fAudTrack2MixPopUp selectedItem] tag];
1392 else if ([fAudLang2PopUp indexOfSelectedItem] > 0)
1394 job->audios[0] = [fAudLang2PopUp indexOfSelectedItem] - 1;
1395 job->audio_mixdowns[0] = [[fAudTrack2MixPopUp selectedItem] tag];
1396 job->audios[1] = -1;
1400 job->audios[0] = -1;
1403 /* Audio settings */
1404 job->arate = hb_audio_rates[[fAudRatePopUp
1405 indexOfSelectedItem]].rate;
1406 job->abitrate = [[fAudBitratePopUp selectedItem] tag];
1408 /* TODO: Filter settings */
1411 hb_list_close( &job->filters );
1413 job->filters = hb_list_init();
1416 if ([[fPicSettingDetelecine stringValue] isEqualToString: @"Yes"])
1418 hb_list_add( job->filters, &hb_filter_detelecine );
1422 if( job->deinterlace == 1)
1424 if ([fPicSettingDeinterlace intValue] == 1)
1426 /* Run old deinterlacer by default */
1427 hb_filter_deinterlace.settings = "-1";
1428 hb_list_add( job->filters, &hb_filter_deinterlace );
1430 if ([fPicSettingDeinterlace intValue] == 2)
1432 /* Yadif mode 0 (1-pass with spatial deinterlacing.) */
1433 hb_filter_deinterlace.settings = "0";
1434 hb_list_add( job->filters, &hb_filter_deinterlace );
1436 if ([fPicSettingDeinterlace intValue] == 3)
1438 /* Yadif (1-pass w/o spatial deinterlacing) and Mcdeint */
1439 hb_filter_deinterlace.settings = "2:-1:1";
1440 hb_list_add( job->filters, &hb_filter_deinterlace );
1442 if ([fPicSettingDeinterlace intValue] == 4)
1444 /* Yadif (2-pass w/ spatial deinterlacing) and Mcdeint Slow Mode*/
1445 hb_filter_deinterlace.settings = "1:-1:2";
1446 hb_list_add( job->filters, &hb_filter_deinterlace );
1454 - (IBAction) AddToQueue: (id) sender
1456 /* We get the destination directory from the destingation field here */
1457 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1458 /* We check for a valid destination here */
1459 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1461 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1466 hb_list_t * list = hb_get_titles( fHandle );
1467 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1468 [fSrcTitlePopUp indexOfSelectedItem] );
1469 hb_job_t * job = title->job;
1473 /* Destination file */
1474 job->file = [[fDstFile2Field stringValue] UTF8String];
1476 if( [fVidTwoPassCheck state] == NSOnState )
1479 hb_add( fHandle, job );
1482 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1483 strcpy(job->x264opts, [[fDisplayX264Options stringValue] UTF8String]);
1485 hb_add( fHandle, job );
1490 hb_add( fHandle, job );
1493 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1494 /* Lets try to update stuff, taken from remove in the queue controller */
1495 [fQueueController performSelectorOnMainThread: @selector( Update: )
1496 withObject: sender waitUntilDone: NO];
1500 - (IBAction) Rip: (id) sender
1502 /* Rip or Cancel ? */
1503 // if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )
1506 [self Cancel: sender];
1509 /* if there is no job in the queue, then add it to the queue and rip
1510 otherwise, there are already jobs in queue, so just rip the queue */
1511 int count = hb_count( fHandle );
1514 [self AddToQueue: sender];
1517 /* We check for duplicate name here */
1518 if( [[NSFileManager defaultManager] fileExistsAtPath:
1519 [fDstFile2Field stringValue]] )
1521 NSBeginCriticalAlertSheet( _( @"File already exists" ),
1522 _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
1523 @selector( OverwriteAlertDone:returnCode:contextInfo: ),
1524 NULL, NULL, [NSString stringWithFormat:
1525 _( @"Do you want to overwrite %@?" ),
1526 [fDstFile2Field stringValue]] );
1529 /* We get the destination directory from the destination field here */
1530 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1531 /* We check for a valid destination here */
1532 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1534 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1538 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1546 - (void) OverwriteAlertDone: (NSWindow *) sheet
1547 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1549 if( returnCode == NSAlertAlternateReturn )
1555 - (void) UpdateAlertDone: (NSWindow *) sheet
1556 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1558 if( returnCode == NSAlertAlternateReturn )
1560 /* Show scan panel */
1561 [self performSelectorOnMainThread: @selector(ShowScanPanel:)
1562 withObject: NULL waitUntilDone: NO];
1566 /* Go to HandBrake homepage and exit */
1567 [self OpenHomepage: NULL];
1568 [NSApp terminate: self];
1573 /* Let libhb do the job */
1574 hb_start( fHandle );
1575 /*set the fEncodeState State */
1578 /* Disable interface */
1579 //[self EnableUI: NO];
1580 // [fPauseButton setEnabled: NO];
1581 // [fRipButton setEnabled: NO];
1582 pauseButtonEnabled = NO;
1583 startButtonEnabled = NO;
1584 NSRect frame = [fWindow frame];
1585 if (frame.size.width <= 591)
1586 frame.size.width = 591;
1587 frame.size.height += 44;
1588 frame.origin.y -= 44;
1589 [fWindow setFrame:frame display:YES animate:YES];
1592 - (IBAction) Cancel: (id) sender
1594 NSBeginCriticalAlertSheet( _( @"Cancel - Are you sure?" ),
1595 _( @"Keep working" ), _( @"Cancel encoding" ), NULL, fWindow, self,
1596 @selector( _Cancel:returnCode:contextInfo: ), NULL, NULL,
1597 _( @"Encoding won't be recoverable." ) );
1600 - (void) _Cancel: (NSWindow *) sheet
1601 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1603 if( returnCode == NSAlertAlternateReturn )
1606 // [fPauseButton setEnabled: NO];
1607 // [fRipButton setEnabled: NO];
1608 pauseButtonEnabled = NO;
1609 startButtonEnabled = NO;
1610 /*set the fEncodeState State */
1615 - (IBAction) Pause: (id) sender
1617 // [fPauseButton setEnabled: NO];
1618 // [fRipButton setEnabled: NO];
1620 // if( [[fPauseButton title] isEqualToString: _( @"Resume" )] )
1621 pauseButtonEnabled = NO;
1622 startButtonEnabled = NO;
1626 hb_resume( fHandle );
1630 hb_pause( fHandle );
1634 - (IBAction) TitlePopUpChanged: (id) sender
1636 hb_list_t * list = hb_get_titles( fHandle );
1637 hb_title_t * title = (hb_title_t*)
1638 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1641 /* If Auto Naming is on. We create an output filename of dvd name - title number */
1642 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0)
1644 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1645 @"%@/%@-%d.%@", [[fDstFile2Field stringValue] stringByDeletingLastPathComponent],
1646 [NSString stringWithUTF8String: title->name],
1647 [fSrcTitlePopUp indexOfSelectedItem] + 1,
1648 [[fDstFile2Field stringValue] pathExtension]]];
1651 /* Update chapter popups */
1652 [fSrcChapterStartPopUp removeAllItems];
1653 [fSrcChapterEndPopUp removeAllItems];
1654 for( int i = 0; i < hb_list_count( title->list_chapter ); i++ )
1656 [fSrcChapterStartPopUp addItemWithTitle: [NSString
1657 stringWithFormat: @"%d", i + 1]];
1658 [fSrcChapterEndPopUp addItemWithTitle: [NSString
1659 stringWithFormat: @"%d", i + 1]];
1661 [fSrcChapterStartPopUp selectItemAtIndex: 0];
1662 [fSrcChapterEndPopUp selectItemAtIndex:
1663 hb_list_count( title->list_chapter ) - 1];
1664 [self ChapterPopUpChanged: NULL];
1666 /* Start Get and set the initial pic size for display */
1667 hb_job_t * job = title->job;
1669 /* Turn Deinterlace on/off depending on the preference */
1670 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultDeinterlaceOn"] > 0)
1672 job->deinterlace = 1;
1676 job->deinterlace = 0;
1679 /* Pixel Ratio Setting */
1680 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PixelRatio"])
1683 job->pixel_ratio = 1 ;
1687 job->pixel_ratio = 0 ;
1689 /*Set Source Size Fields Here */
1690 [fPicSrcWidth setStringValue: [NSString stringWithFormat:
1691 @"%d", fTitle->width]];
1692 [fPicSrcHeight setStringValue: [NSString stringWithFormat:
1693 @"%d", fTitle->height]];
1695 /* We get the originial output picture width and height and put them
1696 in variables for use with some presets later on */
1697 PicOrigOutputWidth = job->width;
1698 PicOrigOutputHeight = job->height;
1699 AutoCropTop = job->crop[0];
1700 AutoCropBottom = job->crop[1];
1701 AutoCropLeft = job->crop[2];
1702 AutoCropRight = job->crop[3];
1703 /* we test getting the max output value for pic sizing here to be used later*/
1704 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
1705 @"%d", PicOrigOutputWidth]];
1706 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
1707 @"%d", PicOrigOutputHeight]];
1708 /* we run the picture size values through
1709 CalculatePictureSizing to get all picture size
1711 [self CalculatePictureSizing: NULL];
1712 /* Run Through EncoderPopUpChanged to see if there
1713 needs to be any pic value modifications based on encoder settings */
1714 //[self EncoderPopUpChanged: NULL];
1715 /* END Get and set the initial pic size for display */
1717 /* Update subtitle popups */
1718 hb_subtitle_t * subtitle;
1719 [fSubPopUp removeAllItems];
1720 [fSubPopUp addItemWithTitle: @"None"];
1721 for( int i = 0; i < hb_list_count( title->list_subtitle ); i++ )
1723 subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle, i );
1725 /* We cannot use NSPopUpButton's addItemWithTitle because
1726 it checks for duplicate entries */
1727 [[fSubPopUp menu] addItemWithTitle: [NSString stringWithCString:
1728 subtitle->lang] action: NULL keyEquivalent: @""];
1730 [fSubPopUp selectItemAtIndex: 0];
1732 /* Update chapter table */
1733 [fChapterTitlesDelegate resetWithTitle:title];
1734 [fChapterTable reloadData];
1736 /* Update audio popups */
1737 [self AddAllAudioTracksToPopUp: fAudLang1PopUp];
1738 [self AddAllAudioTracksToPopUp: fAudLang2PopUp];
1739 /* search for the first instance of our prefs default language for track 1, and set track 2 to "none" */
1740 NSString * audioSearchPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"];
1741 [self SelectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1];
1742 [self SelectAudioTrackInPopUp: fAudLang2PopUp searchPrefixString: NULL selectIndexIfNotFound: 0];
1744 /* changing the title may have changed the audio channels on offer, */
1745 /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
1746 [self AudioTrackPopUpChanged: fAudLang1PopUp];
1747 [self AudioTrackPopUpChanged: fAudLang2PopUp];
1748 /* lets call tableViewSelected to make sure that any preset we have selected is enforced after a title change */
1749 [self tableViewSelected:NULL];
1752 - (IBAction) ChapterPopUpChanged: (id) sender
1755 /* If start chapter popup is greater than end chapter popup,
1756 we set the end chapter popup to the same as start chapter popup */
1757 if ([fSrcChapterStartPopUp indexOfSelectedItem] > [fSrcChapterEndPopUp indexOfSelectedItem])
1759 [fSrcChapterEndPopUp selectItemAtIndex: [fSrcChapterStartPopUp indexOfSelectedItem]];
1764 hb_list_t * list = hb_get_titles( fHandle );
1765 hb_title_t * title = (hb_title_t *)
1766 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1768 hb_chapter_t * chapter;
1769 int64_t duration = 0;
1770 for( int i = [fSrcChapterStartPopUp indexOfSelectedItem];
1771 i <= [fSrcChapterEndPopUp indexOfSelectedItem]; i++ )
1773 chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
1774 duration += chapter->duration;
1777 duration /= 90000; /* pts -> seconds */
1778 [fSrcDuration2Field setStringValue: [NSString stringWithFormat:
1779 @"%02lld:%02lld:%02lld", duration / 3600, ( duration / 60 ) % 60,
1782 [self CalculateBitrate: sender];
1785 - (IBAction) FormatPopUpChanged: (id) sender
1787 NSString * string = [fDstFile2Field stringValue];
1788 int format = [fDstFormatPopUp indexOfSelectedItem];
1790 /* Initially set the large file (64 bit formatting) output checkbox to hidden */
1791 [fDstMpgLargeFileCheck setHidden: YES];
1792 /* Update the codecs popup */
1793 [fDstCodecsPopUp removeAllItems];
1797 /*Get Default MP4 File Extension*/
1798 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
1806 [fDstCodecsPopUp addItemWithTitle:
1807 _( @"MPEG-4 Video / AAC Audio" )];
1808 [fDstCodecsPopUp addItemWithTitle:
1809 _( @"AVC/H.264 Video / AAC Audio" )];
1810 /* We enable the create chapters checkbox here since we are .mp4*/
1811 [fCreateChapterMarkers setEnabled: YES];
1812 /* We show the Large File (64 bit formatting) checkbox since we are .mp4
1813 if we have enabled the option in the global preferences*/
1814 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0)
1816 [fDstMpgLargeFileCheck setHidden: NO];
1820 /* if not enable in global preferences, we additionaly sanity check that the
1821 hidden checkbox is set to off. */
1822 [fDstMpgLargeFileCheck setState: NSOffState];
1827 [fDstCodecsPopUp addItemWithTitle:
1828 _( @"MPEG-4 Video / MP3 Audio" )];
1829 [fDstCodecsPopUp addItemWithTitle:
1830 _( @"MPEG-4 Video / AC-3 Audio" )];
1831 [fDstCodecsPopUp addItemWithTitle:
1832 _( @"AVC/H.264 Video / MP3 Audio" )];
1833 [fDstCodecsPopUp addItemWithTitle:
1834 _( @"AVC/H.264 Video / AC-3 Audio" )];
1835 /* We disable the create chapters checkbox here since we are NOT .mp4
1836 and make sure it is unchecked*/
1837 [fCreateChapterMarkers setEnabled: NO];
1838 [fCreateChapterMarkers setState: NSOffState];
1842 [fDstCodecsPopUp addItemWithTitle:
1843 _( @"MPEG-4 Video / Vorbis Audio" )];
1844 [fDstCodecsPopUp addItemWithTitle:
1845 _( @"MPEG-4 Video / MP3 Audio" )];
1846 /* We disable the create chapters checkbox here since we are NOT .mp4
1847 and make sure it is unchecked*/
1848 [fCreateChapterMarkers setEnabled: NO];
1849 [fCreateChapterMarkers setState: NSOffState];
1853 [fDstCodecsPopUp addItemWithTitle:
1854 _( @"MPEG-4 Video / AAC Audio" )];
1855 [fDstCodecsPopUp addItemWithTitle:
1856 _( @"MPEG-4 Video / AC-3 Audio" )];
1857 [fDstCodecsPopUp addItemWithTitle:
1858 _( @"MPEG-4 Video / MP3 Audio" )];
1859 [fDstCodecsPopUp addItemWithTitle:
1860 _( @"MPEG-4 Video / Vorbis Audio" )];
1862 [fDstCodecsPopUp addItemWithTitle:
1863 _( @"AVC/H.264 Video / AAC Audio" )];
1864 [fDstCodecsPopUp addItemWithTitle:
1865 _( @"AVC/H.264 Video / AC-3 Audio" )];
1866 [fDstCodecsPopUp addItemWithTitle:
1867 _( @"AVC/H.264 Video / MP3 Audio" )];
1868 [fDstCodecsPopUp addItemWithTitle:
1869 _( @"AVC/H.264 Video / Vorbis Audio" )];
1870 /* We disable the create chapters checkbox here since we are NOT .mp4
1871 and make sure it is unchecked*/
1872 [fCreateChapterMarkers setEnabled: YES];
1875 [self CodecsPopUpChanged: NULL];
1877 /* Add/replace to the correct extension */
1878 if( [string characterAtIndex: [string length] - 4] == '.' )
1880 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1881 @"%@.%s", [string substringToIndex: [string length] - 4],
1886 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1887 @"%@.%s", string, ext]];
1890 /* changing the format may mean that we can / can't offer mono or 6ch, */
1891 /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
1892 [self AudioTrackPopUpChanged: fAudLang1PopUp];
1893 [self AudioTrackPopUpChanged: fAudLang2PopUp];
1894 /* We call the method to properly enable/disable turbo 2 pass */
1895 [self TwoPassCheckboxChanged: sender];
1896 /* We call method method to change UI to reflect whether a preset is used or not*/
1897 [self CustomSettingUsed: sender];
1901 - (IBAction) CodecsPopUpChanged: (id) sender
1903 int format = [fDstFormatPopUp indexOfSelectedItem];
1904 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1905 [fX264optView setHidden: YES];
1906 [fX264optViewTitleLabel setStringValue: @"Only Used With The x264 (H.264) Codec"];
1909 /* Update the encoder popup*/
1910 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
1912 /* MPEG-4 -> H.264 */
1913 [fVidEncoderPopUp removeAllItems];
1914 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 Main)"];
1915 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 iPod)"];
1916 [fVidEncoderPopUp selectItemAtIndex: 0];
1917 [fX264optView setHidden: NO];
1918 [fX264optViewTitleLabel setStringValue: @""];
1923 else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) )
1925 /* H.264 -> MPEG-4 */
1926 [fVidEncoderPopUp removeAllItems];
1927 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
1928 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
1929 [fVidEncoderPopUp selectItemAtIndex: 0];
1933 if( FormatSettings[format][codecs] & HB_ACODEC_AC3 )
1935 /* AC-3 pass-through: disable samplerate and bitrate */
1936 [fAudRatePopUp setEnabled: NO];
1937 [fAudBitratePopUp setEnabled: NO];
1941 [fAudRatePopUp setEnabled: YES];
1942 [fAudBitratePopUp setEnabled: YES];
1944 /* changing the codecs on offer may mean that we can / can't offer mono or 6ch, */
1945 /* so call AudioTrackPopUpChanged for both audio tracks to update the mixdown popups */
1946 [self AudioTrackPopUpChanged: fAudLang1PopUp];
1947 [self AudioTrackPopUpChanged: fAudLang2PopUp];
1949 [self CalculateBitrate: sender];
1950 [self TwoPassCheckboxChanged: sender];
1953 - (IBAction) EncoderPopUpChanged: (id) sender
1956 /* Check to see if we need to modify the job pic values based on x264 (iPod) encoder selection */
1957 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [fDstCodecsPopUp indexOfSelectedItem] == 1 && [fVidEncoderPopUp indexOfSelectedItem] == 1)
1959 hb_job_t * job = fTitle->job;
1960 job->pixel_ratio = 0 ;
1962 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPicSizeAutoiPod"] > 0)
1965 if (job->width > 640)
1969 job->keep_ratio = 1;
1970 hb_fix_aspect( job, HB_KEEP_WIDTH );
1973 /* Make sure the 64bit formatting checkbox is off */
1974 [fDstMpgLargeFileCheck setState: NSOffState];
1977 [self CalculatePictureSizing: sender];
1978 [self TwoPassCheckboxChanged: sender];
1981 - (IBAction) TwoPassCheckboxChanged: (id) sender
1983 /* check to see if x264 is chosen */
1984 int format = [fDstFormatPopUp indexOfSelectedItem];
1985 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1986 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
1988 if( [fVidTwoPassCheck state] == NSOnState)
1990 [fVidTurboPassCheck setHidden: NO];
1994 [fVidTurboPassCheck setHidden: YES];
1995 [fVidTurboPassCheck setState: NSOffState];
1997 /* Make sure Two Pass is checked if Turbo is checked */
1998 if( [fVidTurboPassCheck state] == NSOnState)
2000 [fVidTwoPassCheck setState: NSOnState];
2005 [fVidTurboPassCheck setHidden: YES];
2006 [fVidTurboPassCheck setState: NSOffState];
2009 /* We call method method to change UI to reflect whether a preset is used or not*/
2010 [self CustomSettingUsed: sender];
2013 - (IBAction ) VideoFrameRateChanged: (id) sender
2015 /* We call method method to CalculatePictureSizing to error check detelecine*/
2016 [self CalculatePictureSizing: sender];
2018 /* We call method method to change UI to reflect whether a preset is used or not*/
2019 [self CustomSettingUsed: sender];
2022 - (IBAction) SetEnabledStateOfAudioMixdownControls: (id) sender
2025 /* enable/disable the mixdown text and popupbutton for audio track 1 */
2026 [fAudTrack1MixPopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
2027 [fAudTrack1MixLabel setTextColor: ([fAudLang1PopUp indexOfSelectedItem] == 0) ?
2028 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2030 /* enable/disable the mixdown text and popupbutton for audio track 2 */
2031 [fAudTrack2MixPopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
2032 [fAudTrack2MixLabel setTextColor: ([fAudLang2PopUp indexOfSelectedItem] == 0) ?
2033 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2037 - (IBAction) AddAllAudioTracksToPopUp: (id) sender
2040 hb_list_t * list = hb_get_titles( fHandle );
2041 hb_title_t * title = (hb_title_t*)
2042 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
2046 [sender removeAllItems];
2047 [sender addItemWithTitle: _( @"None" )];
2048 for( int i = 0; i < hb_list_count( title->list_audio ); i++ )
2050 audio = (hb_audio_t *) hb_list_item( title->list_audio, i );
2051 [[sender menu] addItemWithTitle:
2052 [NSString stringWithCString: audio->lang]
2053 action: NULL keyEquivalent: @""];
2055 [sender selectItemAtIndex: 0];
2059 - (IBAction) SelectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound
2062 /* this method can be used to find a language, or a language-and-source-format combination, by passing in the appropriate string */
2063 /* e.g. to find the first French track, pass in an NSString * of "Francais" */
2064 /* e.g. to find the first English 5.1 AC3 track, pass in an NSString * of "English (AC3) (5.1 ch)" */
2065 /* if no matching track is found, then selectIndexIfNotFound is used to choose which track to select instead */
2067 if (searchPrefixString != NULL)
2070 for( int i = 0; i < [sender numberOfItems]; i++ )
2072 /* Try to find the desired search string */
2073 if ([[[sender itemAtIndex: i] title] hasPrefix:searchPrefixString])
2075 [sender selectItemAtIndex: i];
2079 /* couldn't find the string, so select the requested "search string not found" item */
2080 /* index of 0 means select the "none" item */
2081 /* index of 1 means select the first audio track */
2082 [sender selectItemAtIndex: selectIndexIfNotFound];
2086 /* if no search string is provided, then select the selectIndexIfNotFound item */
2087 [sender selectItemAtIndex: selectIndexIfNotFound];
2092 - (IBAction) AudioTrackPopUpChanged: (id) sender
2094 /* utility function to call AudioTrackPopUpChanged without passing in a mixdown-to-use */
2095 [self AudioTrackPopUpChanged: sender mixdownToUse: 0];
2098 - (IBAction) AudioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse
2101 /* make sure we have a selected title before continuing */
2102 if (fTitle == NULL) return;
2104 /* find out if audio track 1 or 2 was changed - this is passed to us in the tag of the sender */
2105 /* the sender will have been either fAudLang1PopUp (tag = 0) or fAudLang2PopUp (tag = 1) */
2106 int thisAudio = [sender tag];
2108 /* get the index of the selected audio */
2109 int thisAudioIndex = [sender indexOfSelectedItem] - 1;
2111 /* Handbrake can't currently cope with ripping the same source track twice */
2112 /* So, if this audio is also selected in the other audio track popup, set that popup's selection to "none" */
2113 /* get a reference to the two audio track popups */
2114 NSPopUpButton * thisAudioPopUp = (thisAudio == 1 ? fAudLang2PopUp : fAudLang1PopUp);
2115 NSPopUpButton * otherAudioPopUp = (thisAudio == 1 ? fAudLang1PopUp : fAudLang2PopUp);
2116 /* if the same track is selected in the other audio popup, then select "none" in that popup */
2117 /* unless, of course, both are selected as "none!" */
2118 if ([thisAudioPopUp indexOfSelectedItem] != 0 && [thisAudioPopUp indexOfSelectedItem] == [otherAudioPopUp indexOfSelectedItem]) {
2119 [otherAudioPopUp selectItemAtIndex: 0];
2120 [self AudioTrackPopUpChanged: otherAudioPopUp];
2123 /* pointer for the hb_audio_s struct we will use later on */
2126 /* find out what the currently-selected output audio codec is */
2127 int format = [fDstFormatPopUp indexOfSelectedItem];
2128 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2129 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2131 /* pointer to this track's mixdown NSPopUpButton */
2132 NSTextField * mixdownTextField;
2133 NSPopUpButton * mixdownPopUp;
2135 /* find our mixdown NSTextField and NSPopUpButton */
2138 mixdownTextField = fAudTrack1MixLabel;
2139 mixdownPopUp = fAudTrack1MixPopUp;
2143 mixdownTextField = fAudTrack2MixLabel;
2144 mixdownPopUp = fAudTrack2MixPopUp;
2147 /* delete the previous audio mixdown options */
2148 [mixdownPopUp removeAllItems];
2150 /* check if the audio mixdown controls need their enabled state changing */
2151 [self SetEnabledStateOfAudioMixdownControls: NULL];
2153 if (thisAudioIndex != -1)
2157 audio = (hb_audio_t *) hb_list_item( fTitle->list_audio, thisAudioIndex );
2161 /* find out if our selected output audio codec supports mono and / or 6ch */
2162 /* we also check for an input codec of AC3 or DCA,
2163 as they are the only libraries able to do the mixdown to mono / conversion to 6-ch */
2164 /* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
2165 but this may change in the future, so they are separated for flexibility */
2166 int audioCodecsSupportMono = ((audio->codec == HB_ACODEC_AC3 ||
2167 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2168 int audioCodecsSupport6Ch = ((audio->codec == HB_ACODEC_AC3 ||
2169 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2171 /* check for AC-3 passthru */
2172 if (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
2174 [[mixdownPopUp menu] addItemWithTitle:
2175 [NSString stringWithCString: "AC3 Passthru"]
2176 action: NULL keyEquivalent: @""];
2181 /* add the appropriate audio mixdown menuitems to the popupbutton */
2182 /* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
2183 so that we can reference the mixdown later */
2185 /* keep a track of the min and max mixdowns we used, so we can select the best match later */
2186 int minMixdownUsed = 0;
2187 int maxMixdownUsed = 0;
2189 /* get the input channel layout without any lfe channels */
2190 int layout = audio->input_channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
2192 /* do we want to add a mono option? */
2193 if (audioCodecsSupportMono == 1) {
2194 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2195 [NSString stringWithCString: hb_audio_mixdowns[0].human_readable_name]
2196 action: NULL keyEquivalent: @""];
2197 [menuItem setTag: hb_audio_mixdowns[0].amixdown];
2198 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[0].amixdown;
2199 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[0].amixdown);
2202 /* do we want to add a stereo option? */
2203 /* offer stereo if we have a mono source and non-mono-supporting codecs, as otherwise we won't have a mixdown at all */
2204 /* also offer stereo if we have a stereo-or-better source */
2205 if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO) {
2206 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2207 [NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name]
2208 action: NULL keyEquivalent: @""];
2209 [menuItem setTag: hb_audio_mixdowns[1].amixdown];
2210 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[1].amixdown;
2211 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[1].amixdown);
2214 /* do we want to add a dolby surround (DPL1) option? */
2215 if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY) {
2216 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2217 [NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name]
2218 action: NULL keyEquivalent: @""];
2219 [menuItem setTag: hb_audio_mixdowns[2].amixdown];
2220 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[2].amixdown;
2221 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[2].amixdown);
2224 /* do we want to add a dolby pro logic 2 (DPL2) option? */
2225 if (layout == HB_INPUT_CH_LAYOUT_3F2R) {
2226 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2227 [NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name]
2228 action: NULL keyEquivalent: @""];
2229 [menuItem setTag: hb_audio_mixdowns[3].amixdown];
2230 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[3].amixdown;
2231 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[3].amixdown);
2234 /* do we want to add a 6-channel discrete option? */
2235 if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE)) {
2236 id<NSMenuItem> menuItem = [[mixdownPopUp menu] addItemWithTitle:
2237 [NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name]
2238 action: NULL keyEquivalent: @""];
2239 [menuItem setTag: hb_audio_mixdowns[4].amixdown];
2240 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[4].amixdown;
2241 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[4].amixdown);
2244 /* auto-select the best mixdown based on our saved mixdown preference */
2246 /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
2247 /* ultimately this should be a prefs option */
2250 /* if we passed in a mixdown to use - in order to load a preset - then try and use it */
2251 if (mixdownToUse > 0)
2253 useMixdown = mixdownToUse;
2257 useMixdown = HB_AMIXDOWN_DOLBYPLII;
2260 /* if useMixdown > maxMixdownUsed, then use maxMixdownUsed */
2261 if (useMixdown > maxMixdownUsed) useMixdown = maxMixdownUsed;
2263 /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
2264 if (useMixdown < minMixdownUsed) useMixdown = minMixdownUsed;
2266 /* select the (possibly-amended) preferred mixdown */
2267 [mixdownPopUp selectItemWithTag: useMixdown];
2269 /* lets call the AudioTrackMixdownChanged method here to determine appropriate bitrates, etc. */
2270 [self AudioTrackMixdownChanged: NULL];
2277 /* see if the new audio track choice will change the bitrate we need */
2278 [self CalculateBitrate: sender];
2281 - (IBAction) AudioTrackMixdownChanged: (id) sender
2284 /* find out what the currently-selected output audio codec is */
2285 int format = [fDstFormatPopUp indexOfSelectedItem];
2286 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2287 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2289 /* storage variable for the min and max bitrate allowed for this codec */
2295 case HB_ACODEC_FAAC:
2296 /* check if we have a 6ch discrete conversion in either audio track */
2297 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2299 /* FAAC is happy using our min bitrate of 32 kbps, even for 6ch */
2301 /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
2307 /* FAAC is happy using our min bitrate of 32 kbps for stereo or mono */
2309 /* FAAC won't honour anything more than 160 for stereo, so let's not offer it */
2310 /* note: haven't dealt with mono separately here, FAAC will just use the max it can */
2315 case HB_ACODEC_LAME:
2316 /* Lame is happy using our min bitrate of 32 kbps */
2318 /* Lame won't encode if the bitrate is higher than 320 kbps */
2322 case HB_ACODEC_VORBIS:
2323 /* Vorbis causes a crash if we use a bitrate below 48 kbps */
2325 /* Vorbis can cope with 384 kbps quite happily, even for stereo */
2330 /* AC3 passthru disables the bitrate dropdown anyway, so we might as well just use the min and max bitrate */
2336 [fAudBitratePopUp removeAllItems];
2338 for( int i = 0; i < hb_audio_bitrates_count; i++ )
2340 if (hb_audio_bitrates[i].rate >= minbitrate && hb_audio_bitrates[i].rate <= maxbitrate)
2342 /* add a new menuitem for this bitrate */
2343 id<NSMenuItem> menuItem = [[fAudBitratePopUp menu] addItemWithTitle:
2344 [NSString stringWithCString: hb_audio_bitrates[i].string]
2345 action: NULL keyEquivalent: @""];
2346 /* set its tag to be the actual bitrate as an integer, so we can retrieve it later */
2347 [menuItem setTag: hb_audio_bitrates[i].rate];
2351 /* select the default bitrate (but use 384 for 6-ch AAC) */
2352 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2354 [fAudBitratePopUp selectItemWithTag: 384];
2358 [fAudBitratePopUp selectItemWithTag: hb_audio_bitrates[hb_audio_bitrates_default].rate];
2362 /* lets set the picture size back to the max from right after title scan
2363 Lets use an IBAction here as down the road we could always use a checkbox
2364 in the gui to easily take the user back to max. Remember, the compiler
2365 resolves IBActions down to -(void) during compile anyway */
2366 - (IBAction) RevertPictureSizeToMax: (id) sender
2368 hb_job_t * job = fTitle->job;
2369 /* We use the output picture width and height
2370 as calculated from libhb right after title is set
2371 in TitlePopUpChanged */
2372 job->width = PicOrigOutputWidth;
2373 job->height = PicOrigOutputHeight;
2374 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
2376 /* Here we use the auto crop values determined right after scan */
2377 job->crop[0] = AutoCropTop;
2378 job->crop[1] = AutoCropBottom;
2379 job->crop[2] = AutoCropLeft;
2380 job->crop[3] = AutoCropRight;
2383 [self CalculatePictureSizing: sender];
2384 /* We call method method to change UI to reflect whether a preset is used or not*/
2385 [self CustomSettingUsed: sender];
2389 /* Get and Display Current Pic Settings in main window */
2390 - (IBAction) CalculatePictureSizing: (id) sender
2394 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
2395 @"%d", fTitle->job->width]];
2396 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
2397 @"%d", fTitle->job->height]];
2398 [fPicSettingARkeep setStringValue: [NSString stringWithFormat:
2399 @"%d", fTitle->job->keep_ratio]];
2400 //[fPicSettingDeinterlace setStringValue: [NSString stringWithFormat:
2401 // @"%d", fTitle->job->deinterlace]];
2402 [fPicSettingPAR setStringValue: [NSString stringWithFormat:
2403 @"%d", fTitle->job->pixel_ratio]];
2405 if (fTitle->job->pixel_ratio == 1)
2407 int titlewidth = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
2408 int arpwidth = fTitle->job->pixel_aspect_width;
2409 int arpheight = fTitle->job->pixel_aspect_height;
2410 int displayparwidth = titlewidth * arpwidth / arpheight;
2411 int displayparheight = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
2412 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
2413 @"%d", titlewidth]];
2414 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
2415 @"%d", displayparheight]];
2416 [fPicLabelPAROutp setStringValue: @"Anamorphic Output:"];
2417 [fPicLabelPAROutputX setStringValue: @"x"];
2418 [fPicSettingPARWidth setStringValue: [NSString stringWithFormat:
2419 @"%d", displayparwidth]];
2420 [fPicSettingPARHeight setStringValue: [NSString stringWithFormat:
2421 @"%d", displayparheight]];
2423 fTitle->job->keep_ratio = 0;
2427 [fPicLabelPAROutp setStringValue: @""];
2428 [fPicLabelPAROutputX setStringValue: @""];
2429 [fPicSettingPARWidth setStringValue: @""];
2430 [fPicSettingPARHeight setStringValue: @""];
2432 if ([fPicSettingDeinterlace intValue] == 0)
2434 fTitle->job->deinterlace = 0;
2438 fTitle->job->deinterlace = 1;
2442 /* Set ON/Off values for the deinterlace/keep aspect ratio according to boolean */
2443 if (fTitle->job->keep_ratio > 0)
2445 [fPicSettingARkeepDsply setStringValue: @"On"];
2449 [fPicSettingARkeepDsply setStringValue: @"Off"];
2452 if ([fPicSettingDeinterlace intValue] == 0)
2454 [fPicSettingDeinterlaceDsply setStringValue: @"Off"];
2456 else if ([fPicSettingDeinterlace intValue] == 1)
2458 [fPicSettingDeinterlaceDsply setStringValue: @"Fast"];
2460 else if ([fPicSettingDeinterlace intValue] == 2)
2462 [fPicSettingDeinterlaceDsply setStringValue: @"Slow"];
2464 else if ([fPicSettingDeinterlace intValue] == 3)
2466 [fPicSettingDeinterlaceDsply setStringValue: @"Slower"];
2468 else if ([fPicSettingDeinterlace intValue] == 4)
2470 [fPicSettingDeinterlaceDsply setStringValue: @"Slowest"];
2473 if (fTitle->job->pixel_ratio > 0)
2475 [fPicSettingPARDsply setStringValue: @"On"];
2479 [fPicSettingPARDsply setStringValue: @"Off"];
2481 /* Set the display field for crop as per boolean */
2482 if ([[fPicSettingAutoCrop stringValue] isEqualToString: @"0"])
2484 [fPicSettingAutoCropDsply setStringValue: @"Custom"];
2488 [fPicSettingAutoCropDsply setStringValue: @"Auto"];
2490 /* check video framerate and turn off detelecine if necessary */
2491 if (fTitle->rate_base == 1126125 || [[fVidRatePopUp titleOfSelectedItem] isEqualToString: @"23.976 (NTSC Film)"])
2493 [fPicSettingDetelecine setStringValue: @"No"];
2498 /* below will trigger the preset, if selected, to be
2499 changed to "Custom". Lets comment out for now until
2500 we figure out a way to determine if the picture values
2501 changed modify the preset values */
2502 //[self CustomSettingUsed: sender];
2505 - (IBAction) CalculateBitrate: (id) sender
2507 if( !fHandle || [fVidQualityMatrix selectedRow] != 0 )
2512 hb_list_t * list = hb_get_titles( fHandle );
2513 hb_title_t * title = (hb_title_t *) hb_list_item( list,
2514 [fSrcTitlePopUp indexOfSelectedItem] );
2515 hb_job_t * job = title->job;
2519 [fVidBitrateField setIntValue: hb_calc_bitrate( job,
2520 [fVidTargetSizeField intValue] )];
2525 /* Method to determine if we should change the UI
2526 To reflect whether or not a Preset is being used or if
2527 the user is using "Custom" settings by determining the sender*/
2528 - (IBAction) CustomSettingUsed: (id) sender
2530 if ([sender stringValue] != NULL)
2532 /* Deselect the currently selected Preset if there is one*/
2533 [tableView deselectRow:[tableView selectedRow]];
2534 [[fPresetsActionMenu itemAtIndex:0] setEnabled: NO];
2535 /* Change UI to show "Custom" settings are being used */
2536 [fPresetSelectedDisplay setStringValue: @"Custom"];
2538 curUserPresetChosenNum = nil;
2545 - (IBAction) X264AdvancedOptionsSet: (id) sender
2547 /*Set opt widget values here*/
2549 /*B-Frames fX264optBframesPopUp*/
2551 [fX264optBframesPopUp removeAllItems];
2552 [fX264optBframesPopUp addItemWithTitle:@"Default (0)"];
2555 [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2558 /*Reference Frames fX264optRefPopUp*/
2559 [fX264optRefPopUp removeAllItems];
2560 [fX264optRefPopUp addItemWithTitle:@"Default (1)"];
2563 [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2566 /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/
2567 [fX264optNfpskipSwitch setState:0];
2569 /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/
2570 [fX264optNodctdcmtSwitch setState:0];
2572 /*Sub Me fX264optSubmePopUp*/
2573 [fX264optSubmePopUp removeAllItems];
2574 [fX264optSubmePopUp addItemWithTitle:@"Default (4)"];
2577 [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2580 /*Trellis fX264optTrellisPopUp*/
2581 [fX264optTrellisPopUp removeAllItems];
2582 [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"];
2585 [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2588 /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/
2589 [fX264optMixedRefsSwitch setState:0];
2591 /*Motion Estimation fX264optMotionEstPopUp*/
2592 [fX264optMotionEstPopUp removeAllItems];
2593 [fX264optMotionEstPopUp addItemWithTitle:@"Default (Hexagon)"];
2594 [fX264optMotionEstPopUp addItemWithTitle:@"Diamond"];
2595 [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"];
2596 [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"];
2597 [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"];
2599 /*Motion Estimation range fX264optMERangePopUp*/
2600 [fX264optMERangePopUp removeAllItems];
2601 [fX264optMERangePopUp addItemWithTitle:@"Default (16)"];
2604 [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2607 /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/
2608 [fX264optWeightBSwitch setState:0];
2610 /*B-Frame Rate Distortion Optimization fX264optBRDOSwitch BOOLEAN*/
2611 [fX264optBRDOSwitch setState:0];
2613 /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/
2614 [fX264optBPyramidSwitch setState:0];
2616 /*Bidirectional Motion Estimation Refinement fX264optBiMESwitch BOOLEAN*/
2617 [fX264optBiMESwitch setState:0];
2619 /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/
2620 [fX264optDirectPredPopUp removeAllItems];
2621 [fX264optDirectPredPopUp addItemWithTitle:@"Default (Spatial)"];
2622 [fX264optDirectPredPopUp addItemWithTitle:@"None"];
2623 [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"];
2624 [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"];
2625 [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"];
2628 [fX264optAlphaDeblockPopUp removeAllItems];
2629 [fX264optAlphaDeblockPopUp addItemWithTitle:@"Default (0)"];
2632 [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2636 [fX264optBetaDeblockPopUp removeAllItems];
2637 [fX264optBetaDeblockPopUp addItemWithTitle:@"Default (0)"];
2640 [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
2643 /* Analysis fX264optAnalysePopUp */
2644 [fX264optAnalysePopUp removeAllItems];
2645 [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */
2646 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */
2647 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */
2649 /* 8x8 DCT fX264op8x8dctSwitch */
2650 [fX264opt8x8dctSwitch setState:0];
2652 /* CABAC fX264opCabacSwitch */
2653 [fX264optCabacSwitch setState:1];
2655 /* Standardize the option string */
2656 [self X264AdvancedOptionsStandardizeOptString: NULL];
2657 /* Set Current GUI Settings based on newly standardized string */
2658 [self X264AdvancedOptionsSetCurrentSettings: NULL];
2661 - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender
2663 /* Set widgets depending on the opt string in field */
2664 NSString * thisOpt; // The separated option such as "bframes=3"
2665 NSString * optName = @""; // The option name such as "bframes"
2666 NSString * optValue = @"";// The option value such as "3"
2667 NSString * changedOptString = @"";
2668 NSArray *currentOptsArray;
2670 /*First, we get an opt string to process */
2671 NSString *currentOptString = [fDisplayX264Options stringValue];
2673 /*verify there is an opt string to process */
2674 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
2675 if (currentOptRange.location != NSNotFound)
2677 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
2678 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
2680 /*iterate through the array and get <opts> and <values*/
2681 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
2683 int currentOptsArrayCount = [currentOptsArray count];
2684 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
2686 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
2688 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
2689 if (splitOptRange.location != NSNotFound)
2691 optName = [thisOpt substringToIndex:splitOptRange.location];
2692 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
2694 /* Standardize the names here depending on whats in the string */
2695 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
2696 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue];
2698 else // No value given so we use a default of "1"
2701 /* Standardize the names here depending on whats in the string */
2702 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
2703 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
2706 /* Construct New String for opts here */
2707 if ([thisOpt isEqualToString:@""])
2709 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
2713 if ([changedOptString isEqualToString:@""])
2715 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
2719 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
2725 /* Change the option string to reflect the new standardized option string */
2726 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
2729 - (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString
2731 if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"])
2733 cleanOptNameString = @"ref";
2736 /*No Fast PSkip nofast_pskip*/
2737 if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"])
2739 cleanOptNameString = @"no-fast-pskip";
2742 /*No Dict Decimate*/
2743 if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"])
2745 cleanOptNameString = @"no-dct-decimate";
2749 if ([cleanOptNameString isEqualToString:@"subme"])
2751 cleanOptNameString = @"subq";
2755 if ([cleanOptNameString isEqualToString:@"me-range"] || [cleanOptNameString isEqualToString:@"me_range"])
2756 cleanOptNameString = @"merange";
2759 if ([cleanOptNameString isEqualToString:@"weight-b"] || [cleanOptNameString isEqualToString:@"weight_b"])
2761 cleanOptNameString = @"weightb";
2765 if ([cleanOptNameString isEqualToString:@"b-rdo"] || [cleanOptNameString isEqualToString:@"b_rdo"])
2767 cleanOptNameString = @"brdo";
2771 if ([cleanOptNameString isEqualToString:@"b_pyramid"])
2773 cleanOptNameString = @"b-pyramid";
2776 /*Direct Prediction*/
2777 if ([cleanOptNameString isEqualToString:@"direct-pred"] || [cleanOptNameString isEqualToString:@"direct_pred"])
2779 cleanOptNameString = @"direct";
2783 if ([cleanOptNameString isEqualToString:@"filter"])
2785 cleanOptNameString = @"deblock";
2789 if ([cleanOptNameString isEqualToString:@"partitions"])
2791 cleanOptNameString = @"analyse";
2795 return cleanOptNameString;
2798 - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender
2800 /* Set widgets depending on the opt string in field */
2801 NSString * thisOpt; // The separated option such as "bframes=3"
2802 NSString * optName = @""; // The option name such as "bframes"
2803 NSString * optValue = @"";// The option value such as "3"
2804 NSArray *currentOptsArray;
2806 /*First, we get an opt string to process */
2807 //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
2808 NSString *currentOptString = [fDisplayX264Options stringValue];
2810 /*verify there is an opt string to process */
2811 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
2812 if (currentOptRange.location != NSNotFound)
2814 /* lets clean the opt string here to standardize any names*/
2815 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
2816 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
2818 /*iterate through the array and get <opts> and <values*/
2819 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
2821 int currentOptsArrayCount = [currentOptsArray count];
2823 /*iterate through the array and get <opts> and <values*/
2824 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
2826 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
2827 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
2829 if (splitOptRange.location != NSNotFound)
2831 optName = [thisOpt substringToIndex:splitOptRange.location];
2832 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
2834 /*Run through the available widgets for x264 opts and set them, as you add widgets,
2835 they need to be added here. This should be moved to its own method probably*/
2837 /*bframes NSPopUpButton*/
2838 if ([optName isEqualToString:@"bframes"])
2840 [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1];
2842 /*ref NSPopUpButton*/
2843 if ([optName isEqualToString:@"ref"])
2845 [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1];
2847 /*No Fast PSkip NSPopUpButton*/
2848 if ([optName isEqualToString:@"no-fast-pskip"])
2850 [fX264optNfpskipSwitch setState:[optValue intValue]];
2852 /*No Dict Decimate NSPopUpButton*/
2853 if ([optName isEqualToString:@"no-dct-decimate"])
2855 [fX264optNodctdcmtSwitch setState:[optValue intValue]];
2857 /*Sub Me NSPopUpButton*/
2858 if ([optName isEqualToString:@"subq"])
2860 [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1];
2862 /*Trellis NSPopUpButton*/
2863 if ([optName isEqualToString:@"trellis"])
2865 [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1];
2867 /*Mixed Refs NSButton*/
2868 if ([optName isEqualToString:@"mixed-refs"])
2870 [fX264optMixedRefsSwitch setState:[optValue intValue]];
2872 /*Motion Estimation NSPopUpButton*/
2873 if ([optName isEqualToString:@"me"])
2875 if ([optValue isEqualToString:@"dia"])
2876 [fX264optMotionEstPopUp selectItemAtIndex:1];
2877 else if ([optValue isEqualToString:@"hex"])
2878 [fX264optMotionEstPopUp selectItemAtIndex:2];
2879 else if ([optValue isEqualToString:@"umh"])
2880 [fX264optMotionEstPopUp selectItemAtIndex:3];
2881 else if ([optValue isEqualToString:@"esa"])
2882 [fX264optMotionEstPopUp selectItemAtIndex:4];
2884 /*ME Range NSPopUpButton*/
2885 if ([optName isEqualToString:@"merange"])
2887 [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3];
2889 /*Weighted B-Frames NSPopUpButton*/
2890 if ([optName isEqualToString:@"weightb"])
2892 [fX264optWeightBSwitch setState:[optValue intValue]];
2894 /*BRDO NSPopUpButton*/
2895 if ([optName isEqualToString:@"brdo"])
2897 [fX264optBRDOSwitch setState:[optValue intValue]];
2899 /*B Pyramid NSPopUpButton*/
2900 if ([optName isEqualToString:@"b-pyramid"])
2902 [fX264optBPyramidSwitch setState:[optValue intValue]];
2904 /*Bidirectional Motion Estimation Refinement NSPopUpButton*/
2905 if ([optName isEqualToString:@"bime"])
2907 [fX264optBiMESwitch setState:[optValue intValue]];
2909 /*Direct B-frame Prediction NSPopUpButton*/
2910 if ([optName isEqualToString:@"direct"])
2912 if ([optValue isEqualToString:@"none"])
2913 [fX264optDirectPredPopUp selectItemAtIndex:1];
2914 else if ([optValue isEqualToString:@"spatial"])
2915 [fX264optDirectPredPopUp selectItemAtIndex:2];
2916 else if ([optValue isEqualToString:@"temporal"])
2917 [fX264optDirectPredPopUp selectItemAtIndex:3];
2918 else if ([optValue isEqualToString:@"auto"])
2919 [fX264optDirectPredPopUp selectItemAtIndex:4];
2921 /*Deblocking NSPopUpButtons*/
2922 if ([optName isEqualToString:@"deblock"])
2924 NSString * alphaDeblock = @"";
2925 NSString * betaDeblock = @"";
2927 NSRange splitDeblock = [optValue rangeOfString:@","];
2928 alphaDeblock = [optValue substringToIndex:splitDeblock.location];
2929 betaDeblock = [optValue substringFromIndex:splitDeblock.location + 1];
2931 if ([alphaDeblock isEqualToString:@"0"] && [betaDeblock isEqualToString:@"0"])
2933 [fX264optAlphaDeblockPopUp selectItemAtIndex:0];
2934 [fX264optBetaDeblockPopUp selectItemAtIndex:0];
2938 if (![alphaDeblock isEqualToString:@"0"])
2940 [fX264optAlphaDeblockPopUp selectItemAtIndex:[alphaDeblock intValue]+7];
2944 [fX264optAlphaDeblockPopUp selectItemAtIndex:7];
2947 if (![betaDeblock isEqualToString:@"0"])
2949 [fX264optBetaDeblockPopUp selectItemAtIndex:[betaDeblock intValue]+7];
2953 [fX264optBetaDeblockPopUp selectItemAtIndex:7];
2957 /* Analysis NSPopUpButton */
2958 if ([optName isEqualToString:@"analyse"])
2960 if ([optValue isEqualToString:@"p8x8,b8x8,i8x8,i4x4"])
2962 [fX264optAnalysePopUp selectItemAtIndex:0];
2964 if ([optValue isEqualToString:@"none"])
2966 [fX264optAnalysePopUp selectItemAtIndex:1];
2968 if ([optValue isEqualToString:@"all"])
2970 [fX264optAnalysePopUp selectItemAtIndex:2];
2973 /* 8x8 DCT NSButton */
2974 if ([optName isEqualToString:@"8x8dct"])
2976 [fX264opt8x8dctSwitch setState:[optValue intValue]];
2978 /* CABAC NSButton */
2979 if ([optName isEqualToString:@"cabac"])
2981 [fX264optCabacSwitch setState:[optValue intValue]];
2988 - (IBAction) X264AdvancedOptionsChanged: (id) sender
2990 /*Determine which outlet is being used and set optName to process accordingly */
2991 NSString * optNameToChange = @""; // The option name such as "bframes"
2993 if (sender == fX264optBframesPopUp)
2995 optNameToChange = @"bframes";
2997 if (sender == fX264optRefPopUp)
2999 optNameToChange = @"ref";
3001 if (sender == fX264optNfpskipSwitch)
3003 optNameToChange = @"no-fast-pskip";
3005 if (sender == fX264optNodctdcmtSwitch)
3007 optNameToChange = @"no-dct-decimate";
3009 if (sender == fX264optSubmePopUp)
3011 optNameToChange = @"subq";
3013 if (sender == fX264optTrellisPopUp)
3015 optNameToChange = @"trellis";
3017 if (sender == fX264optMixedRefsSwitch)
3019 optNameToChange = @"mixed-refs";
3021 if (sender == fX264optMotionEstPopUp)
3023 optNameToChange = @"me";
3025 if (sender == fX264optMERangePopUp)
3027 optNameToChange = @"merange";
3029 if (sender == fX264optWeightBSwitch)
3031 optNameToChange = @"weightb";
3033 if (sender == fX264optBRDOSwitch)
3035 optNameToChange = @"brdo";
3037 if (sender == fX264optBPyramidSwitch)
3039 optNameToChange = @"b-pyramid";
3041 if (sender == fX264optBiMESwitch)
3043 optNameToChange = @"bime";
3045 if (sender == fX264optDirectPredPopUp)
3047 optNameToChange = @"direct";
3049 if (sender == fX264optAlphaDeblockPopUp)
3051 optNameToChange = @"deblock";
3053 if (sender == fX264optBetaDeblockPopUp)
3055 optNameToChange = @"deblock";
3057 if (sender == fX264optAnalysePopUp)
3059 optNameToChange = @"analyse";
3061 if (sender == fX264opt8x8dctSwitch)
3063 optNameToChange = @"8x8dct";
3065 if (sender == fX264optCabacSwitch)
3067 optNameToChange = @"cabac";
3070 /* Set widgets depending on the opt string in field */
3071 NSString * thisOpt; // The separated option such as "bframes=3"
3072 NSString * optName = @""; // The option name such as "bframes"
3073 NSString * optValue = @"";// The option value such as "3"
3074 NSArray *currentOptsArray;
3076 /*First, we get an opt string to process */
3077 //EXAMPLE: NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
3078 NSString *currentOptString = [fDisplayX264Options stringValue];
3080 /*verify there is an occurrence of the opt specified by the sender to change */
3081 /*take care of any multi-value opt names here. This is extremely kludgy, but test for functionality
3082 and worry about pretty later */
3084 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
3085 the first character of the opt string (hence the ":") */
3086 NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange];
3087 NSRange currentOptRange = [currentOptString rangeOfString:checkOptNameToChange];
3088 /*Then we create a pattern to check for "<beginning of line>"optNameToChange"=" to modify the option to
3089 see if the name falls at the beginning of the line, where we would not have the ":" as a pattern to test against*/
3090 NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange];
3091 NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning];
3092 if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0)
3094 /* Create new empty opt string*/
3095 NSString *changedOptString = @"";
3097 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
3098 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
3100 /*iterate through the array and get <opts> and <values*/
3102 int currentOptsArrayCount = [currentOptsArray count];
3103 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
3105 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
3106 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
3108 if (splitOptRange.location != NSNotFound)
3110 optName = [thisOpt substringToIndex:splitOptRange.location];
3111 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
3113 /*Run through the available widgets for x264 opts and set them, as you add widgets,
3114 they need to be added here. This should be moved to its own method probably*/
3116 /*If the optNameToChange is found, appropriately change the value or delete it if
3117 "Unspecified" is set.*/
3118 if ([optName isEqualToString:optNameToChange])
3120 if ([optNameToChange isEqualToString:@"deblock"])
3122 if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7)))
3128 thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0];
3131 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"] )
3133 if ([sender state] == 0)
3139 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
3142 else if ([optNameToChange isEqualToString:@"cabac"])
3144 if ([sender state] == 1)
3150 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0];
3153 else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string
3157 else if ([optNameToChange isEqualToString:@"me"])
3159 switch ([sender indexOfSelectedItem])
3162 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"];
3166 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"];
3170 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"];
3174 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"];
3181 else if ([optNameToChange isEqualToString:@"direct"])
3183 switch ([sender indexOfSelectedItem])
3186 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
3190 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"];
3194 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"];
3198 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"];
3205 else if ([optNameToChange isEqualToString:@"analyse"])
3207 switch ([sender indexOfSelectedItem])
3210 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
3214 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
3221 else if ([optNameToChange isEqualToString:@"merange"])
3223 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
3225 else // we have a valid value to change, so change it
3227 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
3232 /* Construct New String for opts here */
3233 if ([thisOpt isEqualToString:@""])
3235 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
3239 if ([changedOptString isEqualToString:@""])
3241 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
3245 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
3250 /* Change the option string to reflect the new mod settings */
3251 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
3253 else // if none exists, add it to the string
3255 if ([[fDisplayX264Options stringValue] isEqualToString: @""])
3257 if ([optNameToChange isEqualToString:@"me"])
3259 switch ([sender indexOfSelectedItem])
3262 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3263 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
3267 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3268 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
3272 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3273 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
3277 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3278 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
3285 else if ([optNameToChange isEqualToString:@"direct"])
3287 switch ([sender indexOfSelectedItem])
3290 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3291 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3295 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3296 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
3300 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3301 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
3305 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3306 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
3313 else if ([optNameToChange isEqualToString:@"analyse"])
3315 switch ([sender indexOfSelectedItem])
3318 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3319 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3323 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3324 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
3332 else if ([optNameToChange isEqualToString:@"merange"])
3334 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3335 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
3337 else if ([optNameToChange isEqualToString:@"deblock"])
3339 [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]]];
3341 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"] ) {
3342 if ([sender state] == 0)
3344 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
3348 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3349 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3352 else if ([optNameToChange isEqualToString:@"cabac"])
3354 if ([sender state] == 1)
3356 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
3360 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3361 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3366 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
3367 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
3372 if ([optNameToChange isEqualToString:@"me"])
3374 switch ([sender indexOfSelectedItem])
3377 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3378 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3379 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
3383 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3384 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3385 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
3389 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3390 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3391 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
3395 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3396 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3397 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
3404 else if ([optNameToChange isEqualToString:@"direct"])
3406 switch ([sender indexOfSelectedItem])
3409 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3410 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3411 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3415 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3416 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3417 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
3421 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3422 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3423 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
3427 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3428 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3429 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
3436 else if ([optNameToChange isEqualToString:@"analyse"])
3438 switch ([sender indexOfSelectedItem])
3441 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3442 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3443 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
3447 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
3448 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
3449 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
3457 else if ([optNameToChange isEqualToString:@"merange"])
3459 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3460 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
3462 else if ([optNameToChange isEqualToString:@"deblock"])
3464 [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]]];
3466 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"] )
3468 if ([sender state] == 0)
3470 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
3474 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3475 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3478 else if ([optNameToChange isEqualToString:@"cabac"])
3480 if ([sender state] == 1)
3482 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
3486 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3487 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
3492 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
3493 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
3498 /* We now need to reset the opt widgets since we changed some stuff */
3499 [self X264AdvancedOptionsSet:NULL];
3503 /* We use this method to recreate new, updated factory
3505 - (IBAction)AddFactoryPresets:(id)sender
3507 /* First, we delete any existing built in presets */
3508 [self DeleteFactoryPresets: sender];
3509 /* Then, we re-create new built in presets programmatically CreateIpodOnlyPreset*/
3510 [UserPresets addObject:[self CreateNormalPreset]];
3511 [UserPresets addObject:[self CreateClassicPreset]];
3512 [UserPresets addObject:[self CreateQuickTimePreset]];
3513 [UserPresets addObject:[self CreateIpodLowPreset]];
3514 [UserPresets addObject:[self CreateIpodHighPreset]];
3515 [UserPresets addObject:[self CreateAppleTVPreset]];
3516 [UserPresets addObject:[self CreateiPhonePreset]];
3517 [UserPresets addObject:[self CreatePSThreePreset]];
3518 [UserPresets addObject:[self CreatePSPPreset]];
3519 [UserPresets addObject:[self CreateFilmPreset]];
3520 [UserPresets addObject:[self CreateTelevisionPreset]];
3521 [UserPresets addObject:[self CreateAnimationPreset]];
3522 [UserPresets addObject:[self CreateBedlamPreset]];
3523 [UserPresets addObject:[self CreateDeuxSixQuatrePreset]];
3524 [UserPresets addObject:[self CreateBrokePreset]];
3525 [UserPresets addObject:[self CreateBlindPreset]];
3526 [UserPresets addObject:[self CreateCRFPreset]];
3530 - (IBAction)DeleteFactoryPresets:(id)sender
3533 NSEnumerator *enumerator = [UserPresets objectEnumerator];
3537 NSMutableArray *tempArray;
3540 tempArray = [NSMutableArray array];
3541 /* we look here to see if the preset is we move on to the next one */
3542 while ( tempObject = [enumerator nextObject] )
3544 /* if the preset is "Factory" then we put it in the array of
3545 presets to delete */
3546 if ([[tempObject objectForKey:@"Type"] intValue] == 0)
3548 [tempArray addObject:tempObject];
3552 [UserPresets removeObjectsInArray:tempArray];
3553 [tableView reloadData];
3558 - (IBAction) ShowAddPresetPanel: (id) sender
3560 /* Deselect the currently selected Preset if there is one*/
3561 [tableView deselectRow:[tableView selectedRow]];
3563 /* Populate the preset picture settings popup here */
3564 [fPresetNewPicSettingsPopUp removeAllItems];
3565 [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
3566 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
3567 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
3568 [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];
3570 /* Erase info from the input fields fPresetNewDesc*/
3571 [fPresetNewName setStringValue: @""];
3572 [fPresetNewDesc setStringValue: @""];
3573 /* Show the panel */
3574 [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow
3575 modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
3576 [NSApp runModalForWindow: fAddPresetPanel];
3577 [NSApp endSheet: fAddPresetPanel];
3578 [fAddPresetPanel orderOut: self];
3582 - (IBAction) CloseAddPresetPanel: (id) sender
3588 - (IBAction)AddUserPreset:(id)sender
3591 /* Here we create a custom user preset */
3592 [UserPresets addObject:[self CreatePreset]];
3593 /* Erase info from the input fields */
3594 [fPresetNewName setStringValue: @""];
3595 [fPresetNewDesc setStringValue: @""];
3596 /* We stop the modal window for the new preset */
3606 /* We Sort the Presets By Factory or Custom */
3607 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
3608 ascending:YES] autorelease];
3609 /* We Sort the Presets Alphabetically by name */
3610 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
3611 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
3612 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
3613 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
3614 [UserPresets setArray:sortedArray];
3617 /* We Reload the New Table data for presets */
3618 [tableView reloadData];
3619 /* We save all of the preset data here */
3623 - (IBAction)InsertPreset:(id)sender
3625 int index = [tableView selectedRow];
3626 [UserPresets insertObject:[self CreatePreset] atIndex:index];
3627 [tableView reloadData];
3631 - (NSDictionary *)CreatePreset
3633 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3634 /* Get the New Preset Name from the field in the AddPresetPanel */
3635 [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
3636 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3637 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
3638 /*Set whether or not this is default, at creation set to 0*/
3639 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3640 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3641 [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
3642 /* Get New Preset Description from the field in the AddPresetPanel*/
3643 [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
3645 [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
3646 /* Chapter Markers fCreateChapterMarkers*/
3647 [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
3648 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
3649 [preset setObject:[NSNumber numberWithInt:[fDstMpgLargeFileCheck state]] forKey:@"Mp4LargeFile"];
3651 [preset setObject:[fDstCodecsPopUp titleOfSelectedItem] forKey:@"FileCodecs"];
3653 [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
3654 /* x264 Option String */
3655 [preset setObject:[fDisplayX264Options stringValue] forKey:@"x264Option"];
3657 [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
3658 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3659 [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
3660 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3662 /* Video framerate */
3663 [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
3665 [preset setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
3666 /* 2 Pass Encoding */
3667 [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
3668 /* Turbo 2 pass Encoding fVidTurboPassCheck*/
3669 [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
3670 /*Picture Settings*/
3671 hb_job_t * job = fTitle->job;
3672 /* Basic Picture Settings */
3673 /* Use Max Picture settings for whatever the dvd is.*/
3674 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3675 [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
3676 [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
3677 [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
3678 [preset setObject:[NSNumber numberWithInt:[fPicSettingDeinterlace intValue]] forKey:@"PictureDeinterlace"];
3679 [preset setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
3680 /* Set crop settings here */
3681 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3682 [preset setObject:[NSNumber numberWithInt:[fPicSettingAutoCrop intValue]] forKey:@"PictureAutoCrop"];
3684 [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
3685 [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
3686 [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
3687 [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
3690 /* Audio Sample Rate*/
3691 [preset setObject:[fAudRatePopUp titleOfSelectedItem] forKey:@"AudioSampleRate"];
3692 /* Audio Bitrate Rate*/
3693 [preset setObject:[fAudBitratePopUp titleOfSelectedItem] forKey:@"AudioBitRate"];
3695 [preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
3698 [preset autorelease];
3703 - (NSDictionary *)CreateIpodLowPreset
3705 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3706 /* Get the New Preset Name from the field in the AddPresetPanel */
3707 [preset setObject:@"iPod Low-Rez" forKey:@"PresetName"];
3708 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3709 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3710 /*Set whether or not this is default, at creation set to 0*/
3711 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3712 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3713 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3714 /* Get the New Preset Description from the field in the AddPresetPanel */
3715 [preset setObject:@"HandBrake's low resolution settings for the iPod. Optimized for great playback on the iPod screen, with smaller file size." forKey:@"PresetDescription"];
3717 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3718 /* Chapter Markers*/
3719 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3721 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3723 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3724 /* x264 Option String */
3725 [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"];
3727 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3728 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3729 [preset setObject:@"700" forKey:@"VideoAvgBitrate"];
3730 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3732 /* Video framerate */
3733 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3735 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3736 /* 2 Pass Encoding */
3737 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3739 /*Picture Settings*/
3740 //hb_job_t * job = fTitle->job;
3741 /* Basic Picture Settings */
3742 /* Use Max Picture settings for whatever the dvd is.*/
3743 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3744 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3745 [preset setObject:[NSNumber numberWithInt:320] forKey:@"PictureWidth"];
3746 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3747 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3748 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3749 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3750 /* Set crop settings here */
3751 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3752 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3753 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3754 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3755 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3758 /* Audio Sample Rate*/
3759 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3760 /* Audio Bitrate Rate*/
3761 [preset setObject:@"160" forKey:@"AudioBitRate"];
3763 [preset setObject:@"None" forKey:@"Subtitles"];
3766 [preset autorelease];
3772 - (NSDictionary *)CreateIpodHighPreset
3774 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3775 /* Get the New Preset Name from the field in the AddPresetPanel */
3776 [preset setObject:@"iPod High-Rez" forKey:@"PresetName"];
3777 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3778 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3779 /*Set whether or not this is default, at creation set to 0*/
3780 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3781 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3782 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3783 /* Get the New Preset Description from the field in the AddPresetPanel */
3784 [preset setObject:@"HandBrake's high resolution settings for the iPod. Good video quality, great for viewing on a TV using your iPod" forKey:@"PresetDescription"];
3786 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3787 /* Chapter Markers*/
3788 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3790 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3792 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3793 /* x264 Option String */
3794 [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"];
3796 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3797 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3798 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
3799 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3801 /* Video framerate */
3802 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3804 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3805 /* 2 Pass Encoding */
3806 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3808 /*Picture Settings*/
3809 //hb_job_t * job = fTitle->job;
3810 /* Basic Picture Settings */
3811 /* Use Max Picture settings for whatever the dvd is.*/
3812 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3813 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
3814 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3815 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3816 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3817 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3818 /* Set crop settings here */
3819 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3820 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3821 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3822 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3823 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3824 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3827 /* Audio Sample Rate*/
3828 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3829 /* Audio Bitrate Rate*/
3830 [preset setObject:@"160" forKey:@"AudioBitRate"];
3832 [preset setObject:@"None" forKey:@"Subtitles"];
3835 [preset autorelease];
3840 - (NSDictionary *)CreateAppleTVPreset
3842 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3843 /* Get the New Preset Name from the field in the AddPresetPanel */
3844 [preset setObject:@"AppleTV" forKey:@"PresetName"];
3845 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3846 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3847 /*Set whether or not this is default, at creation set to 0*/
3848 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3849 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3850 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3851 /* Get the New Preset Description from the field in the AddPresetPanel */
3852 [preset setObject:@"HandBrake's settings for the AppleTV. Provides a good balance between quality and file size, and optimizes performance." forKey:@"PresetDescription"];
3854 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3855 /* Chapter Markers*/
3856 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3858 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3860 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3861 /* x264 Option String (We can use this to tweak the appleTV output)*/
3862 [preset setObject:@"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2" forKey:@"x264Option"];
3864 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3865 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3866 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3867 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3869 /* Video framerate */
3870 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3872 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3873 /* 2 Pass Encoding */
3874 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3876 /*Picture Settings*/
3877 /* For AppleTV we only want to retain UsesMaxPictureSettings
3878 which depend on the source dvd picture settings, so we don't
3879 record the current dvd's picture info since it will vary from
3881 //hb_job_t * job = fTitle->job;
3882 //hb_job_t * job = title->job;
3883 /* Basic Picture Settings */
3884 /* Use Max Picture settings for whatever the dvd is.*/
3885 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3886 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3887 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3888 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3889 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3890 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3891 /* Set crop settings here */
3892 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3893 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3894 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3895 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3896 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3899 /* Audio Sample Rate*/
3900 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3901 /* Audio Bitrate Rate*/
3902 [preset setObject:@"160" forKey:@"AudioBitRate"];
3904 [preset setObject:@"None" forKey:@"Subtitles"];
3907 [preset autorelease];
3912 - (NSDictionary *)CreatePSThreePreset
3914 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3915 /* Get the New Preset Name from the field in the AddPresetPanel */
3916 [preset setObject:@"PS3" forKey:@"PresetName"];
3917 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3918 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3919 /*Set whether or not this is default, at creation set to 0*/
3920 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3921 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3922 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3923 /* Get the New Preset Description from the field in the AddPresetPanel */
3924 [preset setObject:@"HandBrake's settings for the Sony PlayStation 3." forKey:@"PresetDescription"];
3926 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3927 /* Chapter Markers*/
3928 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3930 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3932 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3933 /* x264 Option String (We can use this to tweak the appleTV output)*/
3934 [preset setObject:@"level=41:subme=5:me=umh" forKey:@"x264Option"];
3936 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3937 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3938 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3939 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3941 /* Video framerate */
3942 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3944 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3945 /* 2 Pass Encoding */
3946 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3948 /*Picture Settings*/
3949 /* For PS3 we only want to retain UsesMaxPictureSettings
3950 which depend on the source dvd picture settings, so we don't
3951 record the current dvd's picture info since it will vary from
3953 /* Use Max Picture settings for whatever the dvd is.*/
3954 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3955 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3956 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3957 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3958 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3959 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3960 /* Set crop settings here */
3961 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3962 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3963 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3964 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3965 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3968 /* Audio Sample Rate*/
3969 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3970 /* Audio Bitrate Rate*/
3971 [preset setObject:@"160" forKey:@"AudioBitRate"];
3973 [preset setObject:@"None" forKey:@"Subtitles"];
3976 [preset autorelease];
3980 - (NSDictionary *)CreatePSPPreset
3982 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3983 /* Get the New Preset Name from the field in the AddPresetPanel */
3984 [preset setObject:@"PSP" forKey:@"PresetName"];
3985 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3986 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3987 /*Set whether or not this is default, at creation set to 0*/
3988 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3989 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3990 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3991 /* Get the New Preset Description from the field in the AddPresetPanel */
3992 [preset setObject:@"HandBrake's settings for the Sony PlayStation Portable." forKey:@"PresetDescription"];
3994 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3995 /* Chapter Markers*/
3996 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3998 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4000 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4001 /* x264 Option String (We can use this to tweak the appleTV output)*/
4002 [preset setObject:@"" forKey:@"x264Option"];
4004 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4005 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4006 [preset setObject:@"1024" forKey:@"VideoAvgBitrate"];
4007 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4009 /* Video framerate */
4010 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4012 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4013 /* 2 Pass Encoding */
4014 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4016 /*Picture Settings*/
4017 /* For PS3 we only want to retain UsesMaxPictureSettings
4018 which depend on the source dvd picture settings, so we don't
4019 record the current dvd's picture info since it will vary from
4021 /* Use Max Picture settings for whatever the dvd is.*/
4022 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4023 [preset setObject:@"368" forKey:@"PictureWidth"];
4024 [preset setObject:@"208" forKey:@"PictureHeight"];
4025 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4026 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4027 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4028 /* Set crop settings here */
4029 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4030 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4031 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4032 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4033 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4034 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4037 /* Audio Sample Rate*/
4038 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4039 /* Audio Bitrate Rate*/
4040 [preset setObject:@"128" forKey:@"AudioBitRate"];
4042 [preset setObject:@"None" forKey:@"Subtitles"];
4045 [preset autorelease];
4050 - (NSDictionary *)CreateNormalPreset
4052 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4053 /* Get the New Preset Name from the field in the AddPresetPanel */
4054 [preset setObject:@"Normal" forKey:@"PresetName"];
4055 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4056 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4057 /*Set whether or not this is default, at creation set to 0*/
4058 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"];
4059 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4060 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4061 /* Get the New Preset Description from the field in the AddPresetPanel */
4062 [preset setObject:@"HandBrake's normal, default settings." forKey:@"PresetDescription"];
4064 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4065 /* Chapter Markers*/
4066 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4068 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4070 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4071 /* x264 Option String */
4072 [preset setObject:@"ref=2:bframes=2:subme=5:me=umh" forKey:@"x264Option"];
4074 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4075 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4076 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
4077 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4079 /* Video framerate */
4080 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4082 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4083 /* 2 Pass Encoding */
4084 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4085 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4087 /*Picture Settings*/
4088 //hb_job_t * job = fTitle->job;
4089 /* Basic Picture Settings */
4090 /* Use Max Picture settings for whatever the dvd is.*/
4091 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4092 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4093 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4094 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4095 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4096 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4097 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4098 /* Set crop settings here */
4099 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4100 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4101 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4102 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4103 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4106 /* Audio Sample Rate*/
4107 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4108 /* Audio Bitrate Rate*/
4109 [preset setObject:@"160" forKey:@"AudioBitRate"];
4111 [preset setObject:@"None" forKey:@"Subtitles"];
4114 [preset autorelease];
4119 - (NSDictionary *)CreateClassicPreset
4121 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4122 /* Get the New Preset Name from the field in the AddPresetPanel */
4123 [preset setObject:@"Classic" forKey:@"PresetName"];
4124 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4125 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4126 /*Set whether or not this is default, at creation set to 0*/
4127 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4128 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4129 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4130 /* Get the New Preset Description from the field in the AddPresetPanel */
4131 [preset setObject:@"HandBrake's traditional, faster, lower-quality settings." forKey:@"PresetDescription"];
4133 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4134 /* Chapter Markers*/
4135 [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
4137 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4139 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4140 /* x264 Option String */
4141 [preset setObject:@"" forKey:@"x264Option"];
4143 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4144 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4145 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
4146 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4148 /* Video framerate */
4149 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4151 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4152 /* 2 Pass Encoding */
4153 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4155 /*Picture Settings*/
4156 //hb_job_t * job = fTitle->job;
4157 /* Basic Picture Settings */
4158 /* Use Max Picture settings for whatever the dvd is.*/
4159 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4160 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4161 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4162 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4163 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4164 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4165 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4166 /* Set crop settings here */
4167 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4168 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4169 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4170 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4171 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4174 /* Audio Sample Rate*/
4175 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4176 /* Audio Bitrate Rate*/
4177 [preset setObject:@"160" forKey:@"AudioBitRate"];
4179 [preset setObject:@"None" forKey:@"Subtitles"];
4182 [preset autorelease];
4187 - (NSDictionary *)CreateFilmPreset
4189 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4190 /* Get the New Preset Name from the field in the AddPresetPanel */
4191 [preset setObject:@"Film" forKey:@"PresetName"];
4192 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4193 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4194 /*Set whether or not this is default, at creation set to 0*/
4195 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4196 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4197 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4198 /* Get the New Preset Description from the field in the AddPresetPanel */
4199 [preset setObject:@"HandBrake's preset for feature films." forKey:@"PresetDescription"];
4201 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4202 /* Chapter Markers*/
4203 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4205 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4207 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4208 /* x264 Option String */
4209 [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"];
4211 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4212 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4213 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4214 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4216 /* Video framerate */
4217 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4219 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4220 /* 2 Pass Encoding */
4221 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4222 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4224 /*Picture Settings*/
4225 //hb_job_t * job = fTitle->job;
4226 /* Basic Picture Settings */
4227 /* Use Max Picture settings for whatever the dvd is.*/
4228 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4229 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4230 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4231 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4232 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4233 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4234 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4235 /* Set crop settings here */
4236 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4237 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4238 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4239 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4240 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4243 /* Audio Sample Rate*/
4244 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4245 /* Audio Bitrate Rate*/
4246 [preset setObject:@"160" forKey:@"AudioBitRate"];
4248 [preset setObject:@"None" forKey:@"Subtitles"];
4251 [preset autorelease];
4256 - (NSDictionary *)CreateTelevisionPreset
4258 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4259 /* Get the New Preset Name from the field in the AddPresetPanel */
4260 [preset setObject:@"Television" forKey:@"PresetName"];
4261 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4262 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4263 /*Set whether or not this is default, at creation set to 0*/
4264 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4265 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4266 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4267 /* Get the New Preset Description from the field in the AddPresetPanel */
4268 [preset setObject:@"HandBrake's settings for video from television." forKey:@"PresetDescription"];
4270 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4271 /* Chapter Markers*/
4272 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4274 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4276 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4277 /* x264 Option String */
4278 [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"];
4280 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4281 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4282 [preset setObject:@"1300" forKey:@"VideoAvgBitrate"];
4283 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4285 /* Video framerate */
4286 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4288 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4289 /* 2 Pass Encoding */
4290 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4291 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4293 /*Picture Settings*/
4294 //hb_job_t * job = fTitle->job;
4295 /* Basic Picture Settings */
4296 /* Use Max Picture settings for whatever the dvd is.*/
4297 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4298 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4299 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4300 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4301 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4302 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
4303 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4304 /* Set crop settings here */
4305 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4306 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4307 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4308 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4309 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4312 /* Audio Sample Rate*/
4313 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4314 /* Audio Bitrate Rate*/
4315 [preset setObject:@"160" forKey:@"AudioBitRate"];
4317 [preset setObject:@"None" forKey:@"Subtitles"];
4320 [preset autorelease];
4325 - (NSDictionary *)CreateAnimationPreset
4327 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4328 /* Get the New Preset Name from the field in the AddPresetPanel */
4329 [preset setObject:@"Animation" forKey:@"PresetName"];
4330 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4331 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4332 /*Set whether or not this is default, at creation set to 0*/
4333 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4334 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4335 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4336 /* Get the New Preset Description from the field in the AddPresetPanel */
4337 [preset setObject:@"HandBrake's settings for cartoons, anime, and CGI." forKey:@"PresetDescription"];
4339 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4340 /* Chapter Markers*/
4341 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4343 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4345 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4346 /* x264 Option String */
4347 [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"];
4349 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4350 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4351 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
4352 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4354 /* Video framerate */
4355 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4357 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4358 /* 2 Pass Encoding */
4359 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4360 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4362 /*Picture Settings*/
4363 //hb_job_t * job = fTitle->job;
4364 /* Basic Picture Settings */
4365 /* Use Max Picture settings for whatever the dvd is.*/
4366 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4367 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4368 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4369 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4370 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4371 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
4372 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4373 /* Set crop settings here */
4374 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4375 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4376 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4377 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4378 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4381 /* Audio Sample Rate*/
4382 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4383 /* Audio Bitrate Rate*/
4384 [preset setObject:@"160" forKey:@"AudioBitRate"];
4386 [preset setObject:@"None" forKey:@"Subtitles"];
4389 [preset autorelease];
4394 - (NSDictionary *)CreateQuickTimePreset
4396 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4397 /* Get the New Preset Name from the field in the AddPresetPanel */
4398 [preset setObject:@"QuickTime" forKey:@"PresetName"];
4399 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4400 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4401 /*Set whether or not this is default, at creation set to 0*/
4402 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4403 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4404 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4405 /* Get the New Preset Description from the field in the AddPresetPanel */
4406 [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"];
4408 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4409 /* Chapter Markers*/
4410 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4412 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4414 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4415 /* x264 Option String */
4416 [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"];
4418 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4419 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4420 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4421 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4423 /* Video framerate */
4424 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4426 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4427 /* 2 Pass Encoding */
4428 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4429 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4431 /*Picture Settings*/
4432 //hb_job_t * job = fTitle->job;
4433 /* Basic Picture Settings */
4434 /* Use Max Picture settings for whatever the dvd is.*/
4435 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4436 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4437 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4438 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4439 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4440 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4441 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4442 /* Set crop settings here */
4443 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4444 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4445 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4446 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4447 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4450 /* Audio Sample Rate*/
4451 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4452 /* Audio Bitrate Rate*/
4453 [preset setObject:@"160" forKey:@"AudioBitRate"];
4455 [preset setObject:@"None" forKey:@"Subtitles"];
4458 [preset autorelease];
4463 - (NSDictionary *)CreateBedlamPreset
4465 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4466 /* Get the New Preset Name from the field in the AddPresetPanel */
4467 [preset setObject:@"Bedlam" forKey:@"PresetName"];
4468 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4469 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4470 /*Set whether or not this is default, at creation set to 0*/
4471 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4472 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4473 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4474 /* Get the New Preset Description from the field in the AddPresetPanel */
4475 [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"];
4477 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4478 /* Chapter Markers*/
4479 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4481 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4483 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4484 /* x264 Option String */
4485 [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"];
4487 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4488 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4489 [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
4490 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4492 /* Video framerate */
4493 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4495 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4496 /* 2 Pass Encoding */
4497 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4498 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4500 /*Picture Settings*/
4501 //hb_job_t * job = fTitle->job;
4502 /* Basic Picture Settings */
4503 /* Use Max Picture settings for whatever the dvd is.*/
4504 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4505 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4506 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4507 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4508 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4509 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4510 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4511 /* Set crop settings here */
4512 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4513 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4514 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4515 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4516 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4519 /* Audio Sample Rate*/
4520 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4521 /* Audio Bitrate Rate*/
4522 [preset setObject:@"160" forKey:@"AudioBitRate"];
4524 [preset setObject:@"None" forKey:@"Subtitles"];
4527 [preset autorelease];
4532 - (NSDictionary *)CreateiPhonePreset
4534 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4535 /* Get the New Preset Name from the field in the AddPresetPanel */
4536 [preset setObject:@"iPhone" forKey:@"PresetName"];
4537 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4538 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4539 /*Set whether or not this is default, at creation set to 0*/
4540 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4541 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4542 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4543 /* Get the New Preset Description from the field in the AddPresetPanel */
4544 [preset setObject:@"HandBrake's settings for the iPhone." forKey:@"PresetDescription"];
4546 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4547 /* Chapter Markers*/
4548 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4550 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4552 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
4553 /* x264 Option String */
4554 [preset setObject:@"cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1" forKey:@"x264Option"];
4556 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4557 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4558 [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
4559 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4561 /* Video framerate */
4562 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4564 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4565 /* 2 Pass Encoding */
4566 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4568 /*Picture Settings*/
4569 //hb_job_t * job = fTitle->job;
4570 /* Basic Picture Settings */
4571 /* Use Max Picture settings for whatever the dvd is.*/
4572 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4573 [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
4574 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4575 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4576 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4577 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4578 /* Set crop settings here */
4579 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4580 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4581 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4582 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4583 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4584 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4587 /* Audio Sample Rate*/
4588 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4589 /* Audio Bitrate Rate*/
4590 [preset setObject:@"128" forKey:@"AudioBitRate"];
4592 [preset setObject:@"None" forKey:@"Subtitles"];
4595 [preset autorelease];
4600 - (NSDictionary *)CreateDeuxSixQuatrePreset
4602 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4603 /* Get the New Preset Name from the field in the AddPresetPanel */
4604 [preset setObject:@"Deux Six Quatre" forKey:@"PresetName"];
4605 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4606 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4607 /*Set whether or not this is default, at creation set to 0*/
4608 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4609 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4610 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4611 /* Get the New Preset Description from the field in the AddPresetPanel */
4612 [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"];
4614 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4615 /* Chapter Markers*/
4616 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4618 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4620 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4621 /* x264 Option String */
4622 [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"];
4624 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4625 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4626 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
4627 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4629 /* Video framerate */
4630 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4632 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4633 /* 2 Pass Encoding */
4634 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4635 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4637 /*Picture Settings*/
4638 //hb_job_t * job = fTitle->job;
4639 /* Basic Picture Settings */
4640 /* Use Max Picture settings for whatever the dvd is.*/
4641 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4642 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4643 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4644 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4645 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4646 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4647 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4648 /* Set crop settings here */
4649 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4650 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4651 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4652 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4653 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4656 /* Audio Sample Rate*/
4657 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4658 /* Audio Bitrate Rate*/
4659 [preset setObject:@"160" forKey:@"AudioBitRate"];
4661 [preset setObject:@"None" forKey:@"Subtitles"];
4664 [preset autorelease];
4669 - (NSDictionary *)CreateBrokePreset
4671 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4672 /* Get the New Preset Name from the field in the AddPresetPanel */
4673 [preset setObject:@"Broke" forKey:@"PresetName"];
4674 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4675 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4676 /*Set whether or not this is default, at creation set to 0*/
4677 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4678 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4679 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4680 /* Get the New Preset Description from the field in the AddPresetPanel */
4681 [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"];
4683 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4684 /* Chapter Markers*/
4685 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4687 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4689 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4690 /* x264 Option String */
4691 [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"];
4693 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoQualityType"];
4694 [preset setObject:@"695" forKey:@"VideoTargetSize"];
4695 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
4696 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4698 /* Video framerate */
4699 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4701 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4702 /* 2 Pass Encoding */
4703 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4704 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4706 /*Picture Settings*/
4707 //hb_job_t * job = fTitle->job;
4708 /* Basic Picture Settings */
4709 /* Use Max Picture settings for whatever the dvd is.*/
4710 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4711 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4712 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
4713 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4714 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4715 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4716 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4717 /* Set crop settings here */
4718 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4719 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4720 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4721 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4722 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4725 /* Audio Sample Rate*/
4726 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4727 /* Audio Bitrate Rate*/
4728 [preset setObject:@"128" forKey:@"AudioBitRate"];
4730 [preset setObject:@"None" forKey:@"Subtitles"];
4733 [preset autorelease];
4738 - (NSDictionary *)CreateBlindPreset
4740 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4741 /* Get the New Preset Name from the field in the AddPresetPanel */
4742 [preset setObject:@"Blind" forKey:@"PresetName"];
4743 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4744 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4745 /*Set whether or not this is default, at creation set to 0*/
4746 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4747 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4748 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4749 /* Get the New Preset Description from the field in the AddPresetPanel */
4750 [preset setObject:@"HandBrake's preset for impatient people who don't care about picture quality." forKey:@"PresetDescription"];
4752 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4753 /* Chapter Markers*/
4754 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4756 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4758 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4759 /* x264 Option String */
4760 [preset setObject:@"" forKey:@"x264Option"];
4762 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4763 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4764 [preset setObject:@"512" forKey:@"VideoAvgBitrate"];
4765 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4767 /* Video framerate */
4768 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4770 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4771 /* 2 Pass Encoding */
4772 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4773 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4775 /*Picture Settings*/
4776 //hb_job_t * job = fTitle->job;
4777 /* Basic Picture Settings */
4778 /* Use Max Picture settings for whatever the dvd is.*/
4779 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4780 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4781 [preset setObject:[NSNumber numberWithInt:512] forKey:@"PictureWidth"];
4782 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4783 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4784 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4785 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4786 /* Set crop settings here */
4787 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4788 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4789 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4790 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4791 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4794 /* Audio Sample Rate*/
4795 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4796 /* Audio Bitrate Rate*/
4797 [preset setObject:@"128" forKey:@"AudioBitRate"];
4799 [preset setObject:@"None" forKey:@"Subtitles"];
4802 [preset autorelease];
4807 - (NSDictionary *)CreateCRFPreset
4809 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4810 /* Get the New Preset Name from the field in the AddPresetPanel */
4811 [preset setObject:@"Constant Quality Rate" forKey:@"PresetName"];
4812 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4813 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4814 /*Set whether or not this is default, at creation set to 0*/
4815 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4816 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4817 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4818 /* Get the New Preset Description from the field in the AddPresetPanel */
4819 [preset setObject:@"HandBrake's preset for consistently excellent quality in one pass, with the downside of entirely unpredictable file sizes and bitrates." forKey:@"PresetDescription"];
4821 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4822 /* Chapter Markers*/
4823 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4825 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4827 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4828 /* x264 Option String */
4829 [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"];
4831 [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
4832 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4833 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4834 [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
4836 /* Video framerate */
4837 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4839 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4840 /* 2 Pass Encoding */
4841 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4842 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4844 /*Picture Settings*/
4845 //hb_job_t * job = fTitle->job;
4846 /* Basic Picture Settings */
4847 /* Use Max Picture settings for whatever the dvd is.*/
4848 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4849 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4850 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4851 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4852 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4853 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4854 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4855 /* Set crop settings here */
4856 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4857 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4858 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4859 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4860 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4863 /* Audio Sample Rate*/
4864 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4865 /* Audio Bitrate Rate*/
4866 [preset setObject:@"160" forKey:@"AudioBitRate"];
4868 [preset setObject:@"None" forKey:@"Subtitles"];
4871 [preset autorelease];
4877 - (IBAction)DeletePreset:(id)sender
4880 NSEnumerator *enumerator;
4882 NSMutableArray *tempArray;
4885 if ( [tableView numberOfSelectedRows] == 0 )
4887 /* Alert user before deleting preset */
4888 /* Comment out for now, tie to user pref eventually */
4891 status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected preset?", @"OK", @"Cancel", nil);
4893 if ( status == NSAlertDefaultReturn ) {
4894 enumerator = [tableView selectedRowEnumerator];
4895 tempArray = [NSMutableArray array];
4897 while ( (index = [enumerator nextObject]) ) {
4898 tempObject = [UserPresets objectAtIndex:[index intValue]];
4899 [tempArray addObject:tempObject];
4902 [UserPresets removeObjectsInArray:tempArray];
4903 [tableView reloadData];
4908 - (IBAction)GetDefaultPresets:(id)sender
4911 NSEnumerator *enumerator = [UserPresets objectEnumerator];
4913 while (tempObject = [enumerator nextObject])
4915 NSDictionary *thisPresetDict = tempObject;
4916 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
4918 presetHbDefault = i;
4920 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
4922 presetUserDefault = i;
4928 - (IBAction)SetDefaultPreset:(id)sender
4931 NSEnumerator *enumerator = [UserPresets objectEnumerator];
4933 /* First make sure the old user specified default preset is removed */
4934 while (tempObject = [enumerator nextObject])
4936 /* make sure we are not removing the default HB preset */
4937 if ([[[UserPresets objectAtIndex:i] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
4939 [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4943 /* Second, go ahead and set the appropriate user specfied preset */
4944 /* we get the chosen preset from the UserPresets array */
4945 if ([[[UserPresets objectAtIndex:[tableView selectedRow]] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
4947 [[UserPresets objectAtIndex:[tableView selectedRow]] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];
4949 presetUserDefault = [tableView selectedRow];
4951 /* We save all of the preset data here */
4953 /* We Reload the New Table data for presets */
4954 [tableView reloadData];
4957 - (IBAction)SelectDefaultPreset:(id)sender
4959 /* if there is a user specified default, we use it */
4960 if (presetUserDefault)
4962 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetUserDefault] byExtendingSelection:NO];
4963 [self tableViewSelected:NULL];
4965 else if (presetHbDefault) //else we use the built in default presetHbDefault
4967 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetHbDefault] byExtendingSelection:NO];
4968 [self tableViewSelected:NULL];
4972 - (IBAction)tableViewSelected:(id)sender
4974 /* Since we cannot disable the presets tableView in terms of clickability
4975 we will use the enabled state of the add presets button to determine whether
4976 or not clicking on a preset will do anything */
4977 if ([fPresetsAdd isEnabled])
4979 if ([tableView selectedRow] >= 0)
4981 /* we get the chosen preset from the UserPresets array */
4982 chosenPreset = [UserPresets objectAtIndex:[tableView selectedRow]];
4983 curUserPresetChosenNum = [sender selectedRow];
4984 /* we set the preset display field in main window here */
4985 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
4986 if ([[chosenPreset objectForKey:@"Default"] intValue] == 1)
4988 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@ (Default)",[chosenPreset valueForKey:@"PresetName"]]];
4992 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
4995 [fDstFormatPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileFormat"]]];
4996 [self FormatPopUpChanged: NULL];
4998 /* Chapter Markers*/
4999 [fCreateChapterMarkers setState:[[chosenPreset objectForKey:@"ChapterMarkers"] intValue]];
5000 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
5001 [fDstMpgLargeFileCheck setState:[[chosenPreset objectForKey:@"Mp4LargeFile"] intValue]];
5003 [fDstCodecsPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileCodecs"]]];
5004 [self CodecsPopUpChanged: NULL];
5006 [fVidEncoderPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoEncoder"]]];
5008 /* We can show the preset options here in the gui if we want to
5009 so we check to see it the user has specified it in the prefs */
5010 [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]];
5012 [self X264AdvancedOptionsSet:NULL];
5014 /* Lets run through the following functions to get variables set there */
5015 [self EncoderPopUpChanged: NULL];
5017 [self CalculateBitrate: NULL];
5020 [fVidQualityMatrix selectCellAtRow:[[chosenPreset objectForKey:@"VideoQualityType"] intValue] column:0];
5022 [fVidTargetSizeField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoTargetSize"]]];
5023 [fVidBitrateField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoAvgBitrate"]]];
5025 [fVidQualitySlider setFloatValue: [[chosenPreset valueForKey:@"VideoQualitySlider"] floatValue]];
5026 [self VideoMatrixChanged: NULL];
5028 /* Video framerate */
5029 [fVidRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoFramerate"]]];
5032 [fVidGrayscaleCheck setState:[[chosenPreset objectForKey:@"VideoGrayScale"] intValue]];
5034 /* 2 Pass Encoding */
5035 [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
5036 [self TwoPassCheckboxChanged: NULL];
5037 /* Turbo 1st pass for 2 Pass Encoding */
5038 [fVidTurboPassCheck setState:[[chosenPreset objectForKey:@"VideoTurboTwoPass"] intValue]];
5042 /* Audio Sample Rate*/
5043 [fAudRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioSampleRate"]]];
5044 /* Audio Bitrate Rate*/
5045 [fAudBitratePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioBitRate"]]];
5047 [fSubPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"Subtitles"]]];
5049 /* Picture Settings */
5050 /* Look to see if we apply these here in objectForKey:@"UsesPictureSettings"] */
5051 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] > 0)
5053 hb_job_t * job = fTitle->job;
5054 /* Check to see if we should use the max picture setting for the current title*/
5055 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"] intValue] == 1)
5057 /* Use Max Picture settings for whatever the dvd is.*/
5058 [self RevertPictureSizeToMax: NULL];
5059 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
5060 if (job->keep_ratio == 1)
5062 hb_fix_aspect( job, HB_KEEP_WIDTH );
5064 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
5068 job->width = [[chosenPreset objectForKey:@"PictureWidth"] intValue];
5069 job->height = [[chosenPreset objectForKey:@"PictureHeight"] intValue];
5070 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
5071 if (job->keep_ratio == 1)
5073 hb_fix_aspect( job, HB_KEEP_WIDTH );
5075 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
5076 [fPicSettingDeinterlace setStringValue: [NSString stringWithFormat: @"%d",[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]]];
5077 /* If Cropping is set to custom, then recall all four crop values from
5078 when the preset was created and apply them */
5079 if ([[chosenPreset objectForKey:@"PictureAutoCrop"] intValue] == 0)
5081 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
5084 /* Here we use the custom crop values saved at the time the preset was saved */
5085 job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"] intValue];
5086 job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"] intValue];
5087 job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"] intValue];
5088 job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"] intValue];
5091 else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
5093 [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat:
5095 /* Here we use the auto crop values determined right after scan */
5096 job->crop[0] = AutoCropTop;
5097 job->crop[1] = AutoCropBottom;
5098 job->crop[2] = AutoCropLeft;
5099 job->crop[3] = AutoCropRight;
5103 [self CalculatePictureSizing: NULL];
5107 [[fPresetsActionMenu itemAtIndex:0] setEnabled: YES];
5114 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
5116 return [UserPresets count];
5119 /* we use this to determine display characteristics for
5120 each table cell based on content currently only used to
5121 show the built in presets in a blue font. */
5122 - (void)tableView:(NSTableView *)aTableView
5123 willDisplayCell:(id)aCell
5124 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
5126 NSDictionary *userPresetDict = [UserPresets objectAtIndex:rowIndex];
5129 NSColor *shadowColor;
5130 txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]];
5131 /* First, we check to see if its a selected row, if so, we use white since its highlighted in blue */
5132 if ([[aTableView selectedRowIndexes] containsIndex:rowIndex] && ([tableView editedRow] != rowIndex))
5135 fontColor = [NSColor whiteColor];
5136 shadowColor = [NSColor colorWithDeviceRed:(127.0/255.0) green:(140.0/255.0) blue:(160.0/255.0) alpha:1.0];
5140 /* We set the properties of unselected rows */
5141 /* if built-in preset (defined by "type" == 0) we use a blue font */
5142 if ([[userPresetDict objectForKey:@"Type"] intValue] == 0)
5144 fontColor = [NSColor blueColor];
5146 else // User created preset, use a black font
5148 fontColor = [NSColor blackColor];
5152 /* We check to see if this is the HB default, if so, color it appropriately */
5153 if (!presetUserDefault && presetHbDefault && rowIndex == presetHbDefault)
5155 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
5157 /* We check to see if this is the User Specified default, if so, color it appropriately */
5158 if (presetUserDefault && rowIndex == presetUserDefault)
5160 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
5163 [aCell setTextColor:fontColor];
5164 [aCell setFont:txtFont];
5165 /* this shadow stuff (like mail app) for some reason looks crappy, commented out
5166 temporarily in case we want to resurrect it */
5168 NSShadow *shadow = [[NSShadow alloc] init];
5169 NSSize shadowOffset = { width: 1.0, height: -1.5};
5170 [shadow setShadowOffset:shadowOffset];
5171 [shadow setShadowColor:shadowColor];
5176 /* Method to display tooltip with the description for each preset, if available */
5177 - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell
5178 rect:(NSRectPointer)aRect tableColumn:(NSTableColumn *)aTableColumn
5179 row:(int)rowIndex mouseLocation:(NSPoint)aPos
5181 /* initialize the tooltip contents variable */
5183 /* if there is a description for the preset, we show it in the tooltip */
5184 if ([[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"])
5186 loc_tip = [NSString stringWithFormat: @"%@",[[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"]];
5191 loc_tip = @"No description available";
5197 - (id)tableView:(NSTableView *)aTableView
5198 objectValueForTableColumn:(NSTableColumn *)aTableColumn
5201 id theRecord, theValue;
5203 theRecord = [UserPresets objectAtIndex:rowIndex];
5204 theValue = [theRecord objectForKey:[aTableColumn identifier]];
5208 // NSTableDataSource method that we implement to edit values directly in the table...
5209 - (void)tableView:(NSTableView *)aTableView
5210 setObjectValue:(id)anObject
5211 forTableColumn:(NSTableColumn *)aTableColumn
5216 theRecord = [UserPresets objectAtIndex:rowIndex];
5217 [theRecord setObject:anObject forKey:@"PresetName"];
5218 /* We Sort the Presets By Factory or Custom */
5219 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
5220 ascending:YES] autorelease];
5221 /* We Sort the Presets Alphabetically by name */
5222 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
5223 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
5224 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
5225 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
5226 [UserPresets setArray:sortedArray];
5227 /* We Reload the New Table data for presets */
5228 [tableView reloadData];
5229 /* We save all of the preset data here */
5236 [UserPresets writeToFile:UserPresetsFile atomically:YES];
5237 /* We get the default preset in case it changed */
5238 [self GetDefaultPresets: NULL];
5244 - (void) controlTextDidBeginEditing: (NSNotification *) notification
5246 [self CalculateBitrate: NULL];
5249 - (void) controlTextDidEndEditing: (NSNotification *) notification
5251 [self CalculateBitrate: NULL];
5254 - (void) controlTextDidChange: (NSNotification *) notification
5256 [self CalculateBitrate: NULL];
5259 - (IBAction) OpenHomepage: (id) sender
5261 [[NSWorkspace sharedWorkspace] openURL: [NSURL
5262 URLWithString:@"http://handbrake.m0k.org/"]];
5265 - (IBAction) OpenForums: (id) sender
5267 [[NSWorkspace sharedWorkspace] openURL: [NSURL
5268 URLWithString:@"http://handbrake.m0k.org/forum/"]];
5270 - (IBAction) OpenUserGuide: (id) sender
5272 [[NSWorkspace sharedWorkspace] openURL: [NSURL
5273 URLWithString:@"http://handbrake.m0k.org/trac/wiki/HandBrakeGuide"]];
5277 * Shows debug output window.
5279 - (IBAction)showDebugOutputPanel:(id)sender
5281 [outputPanel showOutputPanel:sender];
5285 * Creates preferences controller, shows preferences window modally, and
5286 * releases the controller after user has closed the window.
5288 - (IBAction)showPreferencesWindow:(id)sender
5290 HBPreferencesController *controller = [[HBPreferencesController alloc] init];
5291 [controller runModal:nil];
5292 [controller release];