1 /* $Id: Controller.mm,v 1.79 2005/11/04 19:41:32 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.m0k.org/>.
5 It may be used under the terms of the GNU General Public License. */
7 #include "Controller.h"
8 #include "a52dec/a52.h"
9 #import "HBOutputPanelController.h"
10 #import "HBPreferencesController.h"
11 /* Added to integrate scanning into HBController */
12 #include <IOKit/IOKitLib.h>
13 #include <IOKit/storage/IOMedia.h>
14 #include <IOKit/storage/IODVDMedia.h>
15 #include "HBDVDDetector.h"
16 #include "dvdread/dvd_reader.h"
18 #define _(a) NSLocalizedString(a,NULL)
20 static int FormatSettings[4][10] =
21 { { HB_MUX_MP4 | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC,
22 HB_MUX_MP4 | HB_VCODEC_X264 | HB_ACODEC_FAAC,
25 { HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_FAAC,
26 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_AC3,
27 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
28 HB_MUX_MKV | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS,
29 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_FAAC,
30 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_AC3,
31 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_LAME,
32 HB_MUX_MKV | HB_VCODEC_X264 | HB_ACODEC_VORBIS,
35 { HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
36 HB_MUX_AVI | HB_VCODEC_FFMPEG | HB_ACODEC_AC3,
37 HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_LAME,
38 HB_MUX_AVI | HB_VCODEC_X264 | HB_ACODEC_AC3},
39 { HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_VORBIS,
40 HB_MUX_OGM | HB_VCODEC_FFMPEG | HB_ACODEC_LAME,
44 /* We setup the toolbar values here */
45 static NSString * ToggleDrawerIdentifier = @"Toggle Drawer Item Identifier";
46 static NSString * StartEncodingIdentifier = @"Start Encoding Item Identifier";
47 static NSString * PauseEncodingIdentifier = @"Pause Encoding Item Identifier";
48 static NSString * ShowQueueIdentifier = @"Show Queue Item Identifier";
49 static NSString * AddToQueueIdentifier = @"Add to Queue Item Identifier";
50 static NSString * ShowActivityIdentifier = @"Debug Output Item Identifier";
51 static NSString * ChooseSourceIdentifier = @"Choose Source Item Identifier";
54 /*******************************
55 * HBController implementation *
56 *******************************/
57 @implementation HBController
62 [HBPreferencesController registerUserDefaults];
64 /* Check for check for the app support directory here as
65 * outputPanel needs it right away, as may other future methods
67 /* We declare the default NSFileManager into fileManager */
68 NSFileManager * fileManager = [NSFileManager defaultManager];
69 /* we set the files and support paths here */
70 AppSupportDirectory = @"~/Library/Application Support/HandBrake";
71 AppSupportDirectory = [AppSupportDirectory stringByExpandingTildeInPath];
72 /* We check for the app support directory for handbrake */
73 if ([fileManager fileExistsAtPath:AppSupportDirectory] == 0)
75 // If it doesnt exist yet, we create it here
76 [fileManager createDirectoryAtPath:AppSupportDirectory attributes:nil];
79 outputPanel = [[HBOutputPanelController alloc] init];
80 fPictureController = [[PictureController alloc] initWithDelegate:self];
81 fQueueController = [[HBQueueController alloc] init];
82 fAdvancedOptions = [[HBAdvancedController alloc] init];
83 fPreferencesController = [[HBPreferencesController alloc] init];
88 - (void) applicationDidFinishLaunching: (NSNotification *) notification
94 int debugLevel = [[NSUserDefaults standardUserDefaults] boolForKey:@"ShowVerboseOutput"] ? HB_DEBUG_ALL : HB_DEBUG_NONE;
95 fHandle = hb_init(debugLevel, [[NSUserDefaults standardUserDefaults] boolForKey:@"CheckForUpdates"]);
97 // Set the Growl Delegate
98 [GrowlApplicationBridge setGrowlDelegate: self];
99 /* Init others controllers */
100 [fPictureController SetHandle: fHandle];
101 [fQueueController setHandle: fHandle];
102 [fQueueController setHBController: self];
104 fChapterTitlesDelegate = [[ChapterTitles alloc] init];
105 [fChapterTable setDataSource:fChapterTitlesDelegate];
107 /* Call UpdateUI every 1/2 sec */
108 [[NSRunLoop currentRunLoop] addTimer: [NSTimer
109 scheduledTimerWithTimeInterval: 0.5 target: self
110 selector: @selector( updateUI: ) userInfo: NULL repeats: YES]
111 forMode: NSEventTrackingRunLoopMode];
113 // Open debug output window now if it was visible when HB was closed
114 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"OutputPanelIsOpen"])
115 [self showDebugOutputPanel:nil];
117 // Open queue window now if it was visible when HB was closed
118 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"QueueWindowIsOpen"])
119 [self showQueueWindow:nil];
121 [self openMainWindow:nil];
123 if( ( build = hb_check_update( fHandle, &version ) ) > -1 )
125 /* Update available - tell the user */
127 NSBeginInformationalAlertSheet( _( @"Update is available" ),
128 _( @"Go get it!" ), _( @"Discard" ), NULL, fWindow, self,
129 @selector( updateAlertDone:returnCode:contextInfo: ),
130 NULL, NULL, [NSString stringWithFormat:
131 _( @"HandBrake %s (build %d) is now available for download." ),
137 /* Show Browse Sources Window ASAP */
138 [self performSelectorOnMainThread: @selector(browseSources:)
139 withObject: NULL waitUntilDone: NO];
142 - (void) updateAlertDone: (NSWindow *) sheet
143 returnCode: (int) returnCode contextInfo: (void *) contextInfo
145 if( returnCode == NSAlertDefaultReturn )
147 /* Go to HandBrake homepage and exit */
148 [self openHomepage: NULL];
149 [NSApp terminate: self];
154 /* Show scan panel */
155 [self performSelectorOnMainThread: @selector(showScanPanel:)
156 withObject: NULL waitUntilDone: NO];
158 /* Go to HandBrake homepage and exit */
159 [self openHomepage: NULL];
160 [NSApp terminate: self];
164 - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app
166 // Warn if encoding a movie
168 hb_get_state( fHandle, &s );
169 hb_job_t * job = hb_current_job( fHandle );
170 if ( job && ( s.state != HB_STATE_IDLE ) )
172 hb_job_t * job = hb_current_job( fHandle );
173 int result = NSRunCriticalAlertPanel(
174 NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
175 NSLocalizedString(@"%@ is currently encoding. If you quit HandBrake, your movie will be lost. Do you want to quit anyway?", nil),
176 NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil,
177 job ? [NSString stringWithUTF8String:job->title->name] : @"A movie" );
179 if (result == NSAlertDefaultReturn)
181 [self doCancelCurrentJob];
182 return NSTerminateNow;
185 return NSTerminateCancel;
188 // Warn if items still in the queue
189 else if ( hb_count( fHandle ) > 0 )
191 int result = NSRunCriticalAlertPanel(
192 NSLocalizedString(@"Are you sure you want to quit HandBrake?", nil),
193 NSLocalizedString(@"One or more encodes are queued for encoding. Do you want to quit anyway?", nil),
194 NSLocalizedString(@"Quit", nil), NSLocalizedString(@"Don't Quit", nil), nil);
196 if ( result == NSAlertDefaultReturn )
197 return NSTerminateNow;
199 return NSTerminateCancel;
202 return NSTerminateNow;
205 - (void)applicationWillTerminate:(NSNotification *)aNotification
207 [outputPanel release];
208 [fQueueController release];
213 - (void) awakeFromNib
216 [fWindow setExcludedFromWindowsMenu:YES];
217 [fAdvancedOptions setView:fAdvancedView];
219 /* Initialize currentScanCount so HB can use it to
220 evaluate successive scans */
221 currentScanCount = 0;
223 /* Init UserPresets .plist */
226 fRipIndicatorShown = NO; // initially out of view in the nib
228 /* Show/Dont Show Presets drawer upon launch based
229 on user preference DefaultPresetsDrawerShow*/
230 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPresetsDrawerShow"] > 0)
232 [fPresetDrawer open];
237 [fDstFormatPopUp removeAllItems];
238 [fDstFormatPopUp addItemWithTitle: _( @"MP4 file" )];
239 [fDstFormatPopUp addItemWithTitle: _( @"MKV file" )];
240 [fDstFormatPopUp addItemWithTitle: _( @"AVI file" )];
241 [fDstFormatPopUp addItemWithTitle: _( @"OGM file" )];
242 [fDstFormatPopUp selectItemAtIndex: 0];
244 [self formatPopUpChanged: NULL];
246 /* We enable the create chapters checkbox here since we are .mp4 */
247 [fCreateChapterMarkers setEnabled: YES];
248 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultChapterMarkers"] > 0)
250 [fCreateChapterMarkers setState: NSOnState];
256 [fDstFile2Field setStringValue: [NSString stringWithFormat:
257 @"%@/Desktop/Movie.mp4", NSHomeDirectory()]];
260 [fVidEncoderPopUp removeAllItems];
261 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
262 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
267 [fVidTargetSizeField setIntValue: 700];
268 [fVidBitrateField setIntValue: 1000];
270 [fVidQualityMatrix selectCell: fVidBitrateCell];
271 [self videoMatrixChanged: NULL];
273 /* Video framerate */
274 [fVidRatePopUp removeAllItems];
275 [fVidRatePopUp addItemWithTitle: _( @"Same as source" )];
276 for( int i = 0; i < hb_video_rates_count; i++ )
278 if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]])
280 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
281 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Film)"]];
283 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]])
285 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
286 [NSString stringWithCString: hb_video_rates[i].string], @" (PAL Film/Video)"]];
288 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]])
290 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
291 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Video)"]];
295 [fVidRatePopUp addItemWithTitle:
296 [NSString stringWithCString: hb_video_rates[i].string]];
299 [fVidRatePopUp selectItemAtIndex: 0];
301 /* Picture Settings */
302 [fPicLabelPAROutputX setStringValue: @""];
303 [fPicSettingPARWidth setStringValue: @""];
304 [fPicSettingPARHeight setStringValue: @""];
306 /* Set Auto Crop to On at launch */
307 [fPictureController setAutoCrop:YES];
310 [fAudBitratePopUp removeAllItems];
311 for( int i = 0; i < hb_audio_bitrates_count; i++ )
313 [fAudBitratePopUp addItemWithTitle:
314 [NSString stringWithCString: hb_audio_bitrates[i].string]];
317 [fAudBitratePopUp selectItemAtIndex: hb_audio_bitrates_default];
319 /* Audio samplerate */
320 [fAudRatePopUp removeAllItems];
321 for( int i = 0; i < hb_audio_rates_count; i++ )
323 [fAudRatePopUp addItemWithTitle:
324 [NSString stringWithCString: hb_audio_rates[i].string]];
326 [fAudRatePopUp selectItemAtIndex: hb_audio_rates_default];
329 [fStatusField setStringValue: @""];
334 [fPresetsActionButton setMenu:fPresetsActionMenu];
336 /* We disable the Turbo 1st pass checkbox since we are not x264 */
337 [fVidTurboPassCheck setEnabled: NO];
338 [fVidTurboPassCheck setState: NSOffState];
341 /* lets get our default prefs here */
342 [self getDefaultPresets: NULL];
343 /* lets initialize the current successful scancount here to 0 */
344 currentSuccessfulScanCount = 0;
348 - (void) TranslateStrings
350 [fSrcTitleField setStringValue: _( @"Title:" )];
351 [fSrcChapterField setStringValue: _( @"Chapters:" )];
352 [fSrcChapterToField setStringValue: _( @"to" )];
353 [fSrcDuration1Field setStringValue: _( @"Duration:" )];
355 [fDstFormatField setStringValue: _( @"Format:" )];
356 [fDstCodecsField setStringValue: _( @"Codecs:" )];
357 [fDstFile1Field setStringValue: _( @"File:" )];
358 [fDstBrowseButton setTitle: _( @"Browse" )];
360 [fVidRateField setStringValue: _( @"Framerate (fps):" )];
361 [fVidEncoderField setStringValue: _( @"Encoder:" )];
362 [fVidQualityField setStringValue: _( @"Quality:" )];
366 - (void) enableUI: (bool) b
368 NSControl * controls[] =
369 { fSrcTitleField, fSrcTitlePopUp,
370 fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField,
371 fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field,
372 fDstFormatField, fDstFormatPopUp, fDstCodecsField,
373 fDstCodecsPopUp, fDstFile1Field, fDstFile2Field,
374 fDstBrowseButton, fVidRateField, fVidRatePopUp,
375 fVidEncoderField, fVidEncoderPopUp, fVidQualityField,
376 fVidQualityMatrix, fVidGrayscaleCheck, fSubField, fSubPopUp,
377 fAudLang1Field, fAudLang1PopUp, fAudLang2Field, fAudLang2PopUp,
378 fAudTrack1MixLabel, fAudTrack1MixPopUp, fAudTrack2MixLabel, fAudTrack2MixPopUp,
379 fAudRateField, fAudRatePopUp, fAudBitrateField,
380 fAudBitratePopUp, fPictureButton,fQueueStatus,
381 fPicSrcWidth,fPicSrcHeight,fPicSettingWidth,fPicSettingHeight,fPicSettingARkeep,
382 fPicSettingDeinterlace,fPicLabelSettings,fPicLabelSrc,fPicLabelOutp,
383 fPicLabelAr,fPicLabelDeinterlace,fPicLabelSrcX,fPicLabelOutputX,
384 fPicLabelPAROutputX,fPicSettingPARWidth,fPicSettingPARHeight,
385 fPicSettingPAR,fPicLabelAnamorphic,tableView,fPresetsAdd,fPresetsDelete,
386 fCreateChapterMarkers,fVidTurboPassCheck,fDstMpgLargeFileCheck,fPicLabelAutoCrop,
387 fPicSettingAutoCrop,fPicSettingDetelecine,fPicLabelDetelecine,fPicLabelDenoise,fPicSettingDenoise,
388 fSubForcedCheck,fPicSettingDeblock,fPicLabelDeblock,};
391 i < sizeof( controls ) / sizeof( NSControl * ); i++ )
393 if( [[controls[i] className] isEqualToString: @"NSTextField"] )
395 NSTextField * tf = (NSTextField *) controls[i];
396 if( ![tf isBezeled] )
398 [tf setTextColor: b ? [NSColor controlTextColor] :
399 [NSColor disabledControlTextColor]];
403 [controls[i] setEnabled: b];
409 /* if we're enabling the interface, check if the audio mixdown controls need to be enabled or not */
410 /* these will have been enabled by the mass control enablement above anyway, so we're sense-checking it here */
411 [self setEnabledStateOfAudioMixdownControls: NULL];
415 [tableView setEnabled: NO];
419 [self videoMatrixChanged: NULL];
420 [fAdvancedOptions enableUI:b];
424 /***********************************************************************
426 ***********************************************************************
427 * Shows a progression bar on the dock icon, filled according to
428 * 'progress' (0.0 <= progress <= 1.0).
429 * Called with progress < 0.0 or progress > 1.0, restores the original
431 **********************************************************************/
432 - (void) UpdateDockIcon: (float) progress
436 NSBitmapImageRep * bmp;
438 uint32_t black = htonl( 0x000000FF );
439 uint32_t red = htonl( 0xFF0000FF );
440 uint32_t white = htonl( 0xFFFFFFFF );
441 int row_start, row_end;
444 /* Get application original icon */
445 icon = [NSImage imageNamed: @"NSApplicationIcon"];
447 if( progress < 0.0 || progress > 1.0 )
449 [NSApp setApplicationIconImage: icon];
453 /* Get it in a raw bitmap form */
454 tiff = [icon TIFFRepresentationUsingCompression:
455 NSTIFFCompressionNone factor: 1.0];
456 bmp = [NSBitmapImageRep imageRepWithData: tiff];
458 /* Draw the progression bar */
459 /* It's pretty simple (ugly?) now, but I'm no designer */
461 row_start = 3 * (int) [bmp size].height / 4;
462 row_end = 7 * (int) [bmp size].height / 8;
464 for( i = row_start; i < row_start + 2; i++ )
466 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
467 for( j = 0; j < (int) [bmp size].width; j++ )
472 for( i = row_start + 2; i < row_end - 2; i++ )
474 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
477 for( j = 2; j < (int) [bmp size].width - 2; j++ )
479 if( j < 2 + (int) ( ( [bmp size].width - 4.0 ) * progress ) )
491 for( i = row_end - 2; i < row_end; i++ )
493 pen = (uint32_t *) ( [bmp bitmapData] + i * [bmp bytesPerRow] );
494 for( j = 0; j < (int) [bmp size].width; j++ )
500 /* Now update the dock icon */
501 tiff = [bmp TIFFRepresentationUsingCompression:
502 NSTIFFCompressionNone factor: 1.0];
503 icon = [[NSImage alloc] initWithData: tiff];
504 [NSApp setApplicationIconImage: icon];
508 - (void) updateUI: (NSTimer *) timer
512 list = hb_get_titles( fHandle );
513 /* check to see if there has been a new scan done
514 this bypasses the constraints of HB_STATE_WORKING
515 not allowing setting a newly scanned source */
516 int checkScanCount = hb_get_scancount( fHandle );
517 if (checkScanCount > currentScanCount)
520 currentScanCount = checkScanCount;
521 //[fScanController Cancel: NULL];
522 [fScanIndicator setIndeterminate: NO];
523 //[fScanIndicator setDoubleValue: 0.0];
524 //[fScanIndicator setHidden: YES];
526 [self showNewScan: NULL];
530 hb_get_state( fHandle, &s );
537 #define p s.param.scanning
538 case HB_STATE_SCANNING:
541 [fSrcDVD2Field setStringValue: [NSString stringWithFormat:
542 _( @"Scanning title %d of %d..." ),
543 p.title_cur, p.title_count]];
544 float scanprogress_total;
545 scanprogress_total = ( p.title_cur - 1 ) / p.title_count;
546 /* FIX ME: currently having an issue showing progress on the scan
547 * indicator, for now just set to barber pole.
549 //[fScanIndicator setHidden: NO];
550 [fScanIndicator setIndeterminate: YES];
551 //[fScanIndicator setDoubleValue: 100.0 * scanprogress_total];
556 #define p s.param.scandone
557 case HB_STATE_SCANDONE:
560 [fScanIndicator setIndeterminate: NO];
561 [fScanIndicator setDoubleValue: 0.0];
562 //[fScanIndicator setHidden: YES];
563 [self showNewScan: NULL];
564 [toolbar validateVisibleItems];
569 #define p s.param.working
570 case HB_STATE_WORKING:
572 float progress_total;
573 NSMutableString * string;
574 /* Currently, p.job_cur and p.job_count get screwed up when adding
575 jobs during encoding, if they cannot be fixed in libhb, will implement a
576 nasty but working cocoa solution */
577 /* Update text field */
578 string = [NSMutableString stringWithFormat: _( @"Encoding: task %d of %d, %.2f %%" ), p.job_cur, p.job_count, 100.0 * p.progress];
582 [string appendFormat:
583 _( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)" ),
584 p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds];
586 [fStatusField setStringValue: string];
589 progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count;
590 [fRipIndicator setIndeterminate: NO];
591 [fRipIndicator setDoubleValue: 100.0 * progress_total];
593 // If progress bar hasn't been revealed at the bottom of the window, do
594 // that now. This code used to be in doRip. I moved it to here to handle
595 // the case where hb_start is called by HBQueueController and not from
597 if (!fRipIndicatorShown)
599 NSRect frame = [fWindow frame];
600 if (frame.size.width <= 591)
601 frame.size.width = 591;
602 frame.size.height += 36;
603 frame.origin.y -= 36;
604 [fWindow setFrame:frame display:YES animate:YES];
605 fRipIndicatorShown = YES;
606 /* We check to see if we need to warn the user that the computer will go to sleep
607 or shut down when encoding is finished */
608 [self remindUserOfSleepOrShutdown];
611 /* Update dock icon */
612 [self UpdateDockIcon: progress_total];
614 // Has current job changed? That means the queue has probably changed as
616 [fQueueController hblibStateChanged: s];
622 #define p s.param.muxing
623 case HB_STATE_MUXING:
625 NSMutableString * string;
627 /* Update text field */
628 string = [NSMutableString stringWithFormat:
630 [fStatusField setStringValue: string];
633 [fRipIndicator setIndeterminate: YES];
634 [fRipIndicator startAnimation: nil];
636 /* Update dock icon */
637 [self UpdateDockIcon: 1.0];
639 // Pass along the info to HBQueueController
640 [fQueueController hblibStateChanged: s];
646 case HB_STATE_PAUSED:
647 [fStatusField setStringValue: _( @"Paused" )];
649 // Pass along the info to HBQueueController
650 [fQueueController hblibStateChanged: s];
654 case HB_STATE_WORKDONE:
656 // HB_STATE_WORKDONE happpens as a result of hblib finishing all its jobs
657 // or someone calling hb_stop. In the latter case, hb_stop does not clear
658 // out the remaining passes/jobs in the queue. We'll do that here.
660 // Delete all remaining scans of this job, ie, delete whole encodes.
662 while( ( job = hb_job( fHandle, 0 ) ) && (job->sequence_id != 0) )
663 hb_rem( fHandle, job );
665 // Start processing back up if jobs still left in queue
666 if (hb_count(fHandle) > 0)
670 // Validate the toolbar (hack). The toolbar will usually get autovalidated
671 // before we had the chance to restart the queue, hence it will now be in
673 [toolbar validateVisibleItems];
677 [fStatusField setStringValue: _( @"Done." )];
678 [fRipIndicator setIndeterminate: NO];
679 [fRipIndicator setDoubleValue: 0.0];
680 [toolbar validateVisibleItems];
682 /* Restore dock icon */
683 [self UpdateDockIcon: -1.0];
685 if (fRipIndicatorShown)
687 NSRect frame = [fWindow frame];
688 if (frame.size.width <= 591)
689 frame.size.width = 591;
690 frame.size.height += -36;
691 frame.origin.y -= -36;
692 [fWindow setFrame:frame display:YES animate:YES];
693 fRipIndicatorShown = NO;
696 // Pass along the info to HBQueueController
697 [fQueueController hblibStateChanged: s];
699 /* Check to see if the encode state has not been cancelled
700 to determine if we should check for encode done notifications */
701 if (fEncodeState != 2) {
702 /* If Growl Notification or Window and Growl has been selected */
703 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Growl Notification"] ||
704 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
706 /*Growl Notification*/
707 [self showGrowlDoneNotification: NULL];
709 /* If Alert Window or Window and Growl has been selected */
710 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window"] ||
711 [[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Alert Window And Growl"])
713 /*On Screen Notification*/
716 status = NSRunAlertPanel(@"Put down that cocktail...",@"Your HandBrake encode is done!", @"OK", nil, nil);
717 [NSApp requestUserAttention:NSCriticalRequest];
718 if ( status == NSAlertDefaultReturn )
720 [self enableUI: YES];
725 [self enableUI: YES];
727 /* If sleep has been selected */
728 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
731 NSDictionary* errorDict;
732 NSAppleEventDescriptor* returnDescriptor = NULL;
733 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
734 @"tell application \"Finder\" to sleep"];
735 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
736 [scriptObject release];
737 [self enableUI: YES];
739 /* If Shutdown has been selected */
740 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
743 NSDictionary* errorDict;
744 NSAppleEventDescriptor* returnDescriptor = NULL;
745 NSAppleScript* scriptObject = [[NSAppleScript alloc] initWithSource:
746 @"tell application \"Finder\" to shut down"];
747 returnDescriptor = [scriptObject executeAndReturnError: &errorDict];
748 [scriptObject release];
749 [self enableUI: YES];
752 // MetaX insertion via AppleScript
753 if([[NSUserDefaults standardUserDefaults] boolForKey: @"sendToMetaX"] == YES)
755 NSAppleScript *myScript = [[NSAppleScript alloc] initWithSource: [NSString stringWithFormat: @"%@%@%@", @"tell application \"MetaX\" to open (POSIX file \"", [fDstFile2Field stringValue], @"\")"]];
756 [myScript executeAndReturnError: nil];
764 [self enableUI: YES];
770 /* Lets show the queue status here in the main window */
771 int queue_count = hb_count( fHandle );
774 [fQueueStatus setStringValue: [NSString stringWithFormat:
775 @"%d pass%s in the queue",
776 queue_count, ( queue_count > 1 ) ? "es" : ""]];
780 [fQueueStatus setStringValue: @""];
787 // ============================================================
788 // NSToolbar Related Methods
789 // ============================================================
791 - (void) setupToolbar {
792 toolbar = [[[NSToolbar alloc] initWithIdentifier: @"HandBrake Toolbar"] autorelease];
794 [toolbar setAllowsUserCustomization: YES];
795 [toolbar setAutosavesConfiguration: YES];
796 [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
798 [toolbar setDelegate: self];
800 [fWindow setToolbar: toolbar];
803 - (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier:
804 (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted {
805 NSToolbarItem * item = [[NSToolbarItem alloc] initWithItemIdentifier: itemIdent];
807 if ([itemIdent isEqualToString: ToggleDrawerIdentifier])
809 [item setLabel: @"Toggle Presets"];
810 [item setPaletteLabel: @"Toggler Presets"];
811 [item setToolTip: @"Open/Close Preset Drawer"];
812 [item setImage: [NSImage imageNamed: @"Drawer"]];
813 [item setTarget: self];
814 [item setAction: @selector(toggleDrawer:)];
815 [item setAutovalidates: NO];
817 else if ([itemIdent isEqualToString: StartEncodingIdentifier])
819 [item setLabel: @"Start"];
820 [item setPaletteLabel: @"Start Encoding"];
821 [item setToolTip: @"Start Encoding"];
822 [item setImage: [NSImage imageNamed: @"Play"]];
823 [item setTarget: self];
824 [item setAction: @selector(Rip:)];
826 else if ([itemIdent isEqualToString: ShowQueueIdentifier])
828 [item setLabel: @"Show Queue"];
829 [item setPaletteLabel: @"Show Queue"];
830 [item setToolTip: @"Show Queue"];
831 [item setImage: [NSImage imageNamed: @"Queue"]];
832 [item setTarget: self];
833 [item setAction: @selector(showQueueWindow:)];
834 [item setAutovalidates: NO];
836 else if ([itemIdent isEqualToString: AddToQueueIdentifier])
838 [item setLabel: @"Add to Queue"];
839 [item setPaletteLabel: @"Add to Queue"];
840 [item setToolTip: @"Add to Queue"];
841 [item setImage: [NSImage imageNamed: @"AddToQueue"]];
842 [item setTarget: self];
843 [item setAction: @selector(addToQueue:)];
845 else if ([itemIdent isEqualToString: PauseEncodingIdentifier])
847 [item setLabel: @"Pause"];
848 [item setPaletteLabel: @"Pause Encoding"];
849 [item setToolTip: @"Pause Encoding"];
850 [item setImage: [NSImage imageNamed: @"Pause"]];
851 [item setTarget: self];
852 [item setAction: @selector(Pause:)];
854 else if ([itemIdent isEqualToString: ShowActivityIdentifier]) {
855 [item setLabel: @"Activity Window"];
856 [item setPaletteLabel: @"Show Activity Window"];
857 [item setToolTip: @"Show Activity Window"];
858 [item setImage: [NSImage imageNamed: @"ActivityWindow"]];
859 [item setTarget: self];
860 [item setAction: @selector(showDebugOutputPanel:)];
861 [item setAutovalidates: NO];
863 else if ([itemIdent isEqualToString: ChooseSourceIdentifier])
865 [item setLabel: @"Source"];
866 [item setPaletteLabel: @"Source"];
867 [item setToolTip: @"Choose Video Source"];
868 [item setImage: [NSImage imageNamed: @"Source"]];
869 [item setTarget: self];
870 [item setAction: @selector(browseSources:)];
881 - (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
883 return [NSArray arrayWithObjects: ChooseSourceIdentifier, NSToolbarSeparatorItemIdentifier, StartEncodingIdentifier,
884 PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
885 NSToolbarSpaceItemIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier, nil];
888 - (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
890 return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier,
891 ChooseSourceIdentifier, ShowQueueIdentifier, ShowActivityIdentifier, ToggleDrawerIdentifier,
892 NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
893 NSToolbarSpaceItemIdentifier, NSToolbarSeparatorItemIdentifier, nil];
896 - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
898 NSString * ident = [toolbarItem itemIdentifier];
903 hb_get_state2( fHandle, &s );
905 if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING)
907 if ([ident isEqualToString: StartEncodingIdentifier])
909 [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];
910 [toolbarItem setLabel: @"Stop"];
911 [toolbarItem setPaletteLabel: @"Stop"];
912 [toolbarItem setToolTip: @"Stop Encoding"];
915 if ([ident isEqualToString: PauseEncodingIdentifier])
917 [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];
918 [toolbarItem setLabel: @"Pause"];
919 [toolbarItem setPaletteLabel: @"Pause Encoding"];
920 [toolbarItem setToolTip: @"Pause Encoding"];
924 if ([ident isEqualToString: AddToQueueIdentifier])
927 else if (s.state == HB_STATE_PAUSED)
929 if ([ident isEqualToString: PauseEncodingIdentifier])
931 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
932 [toolbarItem setLabel: @"Resume"];
933 [toolbarItem setPaletteLabel: @"Resume Encoding"];
934 [toolbarItem setToolTip: @"Resume Encoding"];
937 if ([ident isEqualToString: StartEncodingIdentifier])
939 if ([ident isEqualToString: AddToQueueIdentifier])
942 else if (s.state == HB_STATE_SCANNING)
944 else if (s.state == HB_STATE_WORKDONE || s.state == HB_STATE_SCANDONE || SuccessfulScan)
946 if ([ident isEqualToString: StartEncodingIdentifier])
948 [toolbarItem setImage: [NSImage imageNamed: @"Play"]];
949 if (hb_count(fHandle) > 0)
950 [toolbarItem setLabel: @"Start Queue"];
952 [toolbarItem setLabel: @"Start"];
953 [toolbarItem setPaletteLabel: @"Start Encoding"];
954 [toolbarItem setToolTip: @"Start Encoding"];
957 if ([ident isEqualToString: AddToQueueIdentifier])
963 if ([ident isEqualToString: ShowQueueIdentifier])
965 if ([ident isEqualToString: ToggleDrawerIdentifier])
967 if ([ident isEqualToString: ChooseSourceIdentifier])
969 if ([ident isEqualToString: ShowActivityIdentifier])
975 - (BOOL) validateMenuItem: (NSMenuItem *) menuItem
977 SEL action = [menuItem action];
980 hb_get_state2( fHandle, &s );
984 if (action == @selector(addToQueue:) || action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:))
985 return SuccessfulScan && [fWindow attachedSheet] == nil;
987 if (action == @selector(browseSources:))
989 if (s.state == HB_STATE_SCANNING)
992 return [fWindow attachedSheet] == nil;
994 if (action == @selector(selectDefaultPreset:))
995 return [tableView selectedRow] >= 0 && [fWindow attachedSheet] == nil;
996 if (action == @selector(Pause:))
998 if (s.state == HB_STATE_WORKING)
1000 if(![[menuItem title] isEqualToString:@"Pause Encoding"])
1001 [menuItem setTitle:@"Pause Encoding"];
1004 else if (s.state == HB_STATE_PAUSED)
1006 if(![[menuItem title] isEqualToString:@"Resume Encoding"])
1007 [menuItem setTitle:@"Resume Encoding"];
1013 if (action == @selector(Rip:))
1014 if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING || s.state == HB_STATE_PAUSED)
1016 if(![[menuItem title] isEqualToString:@"Stop Encoding"])
1017 [menuItem setTitle:@"Stop Encoding"];
1020 else if (SuccessfulScan)
1022 if(![[menuItem title] isEqualToString:@"Start Encoding"])
1023 [menuItem setTitle:@"Start Encoding"];
1024 return [fWindow attachedSheet] == nil;
1035 // register a test notification and make
1036 // it enabled by default
1037 #define SERVICE_NAME @"Encode Done"
1038 - (NSDictionary *)registrationDictionaryForGrowl
1040 NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
1041 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL,
1042 [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT,
1045 return registrationDictionary;
1048 -(IBAction)showGrowlDoneNotification:(id)sender
1050 [GrowlApplicationBridge
1051 notifyWithTitle:@"Put down that cocktail..."
1052 description:@"your HandBrake encode is done!"
1053 notificationName:SERVICE_NAME
1061 #pragma mark Get New Source
1063 /*Opens the source browse window, called from Open Source widgets */
1064 - (IBAction) browseSources: (id) sender
1066 [self enableUI: NO];
1067 NSOpenPanel * panel;
1069 panel = [NSOpenPanel openPanel];
1070 [panel setAllowsMultipleSelection: NO];
1071 [panel setCanChooseFiles: YES];
1072 [panel setCanChooseDirectories: YES ];
1073 NSString * sourceDirectory;
1074 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"])
1076 sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"];
1080 sourceDirectory = @"~/Desktop";
1081 sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
1083 /* we open up the browse sources sheet here and call for browseSourcesDone after the sheet is closed
1084 * to evaluate whether we want to specify a title, we pass the sender in the contextInfo variable
1086 [panel beginSheetForDirectory: sourceDirectory file: nil types: nil
1087 modalForWindow: fWindow modalDelegate: self
1088 didEndSelector: @selector( browseSourcesDone:returnCode:contextInfo: )
1089 contextInfo: sender];
1092 - (void) browseSourcesDone: (NSOpenPanel *) sheet
1093 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1095 /* we convert the sender content of contextInfo back into a variable called sender
1096 * mostly just for consistency for evaluation later
1098 id sender = (id)contextInfo;
1099 /* User selected a file to open */
1100 if( returnCode == NSOKButton )
1103 NSString *scanPath = [[sheet filenames] objectAtIndex: 0];
1104 /* we set the last searched source directory in the prefs here */
1105 NSString *sourceDirectory = [scanPath stringByDeletingLastPathComponent];
1106 [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"];
1107 /* we order out sheet, which is the browse window as we need to open
1108 * the title selection sheet right away
1110 [sheet orderOut: self];
1112 if (sender == fOpenSourceTitleMMenu)
1114 /* We put the chosen source path in the source display text field for the
1115 * source title selection sheet in which the user specifies the specific title to be
1116 * scanned as well as the short source name in fSrcDsplyNameTitleScan just for display
1117 * purposes in the title panel
1120 [fScanSrcTitlePathField setStringValue: [NSString stringWithFormat:@"%@", scanPath]];
1121 NSString *displayTitlescanSourceName;
1123 if ([[scanPath lastPathComponent] isEqualToString: @"VIDEO_TS"])
1125 /* If VIDEO_TS Folder is chosen, choose its parent folder for the source display name
1126 we have to use the title->dvd value so we get the proper name of the volume if a physical dvd is the source*/
1127 displayTitlescanSourceName = [NSString stringWithFormat:[[scanPath stringByDeletingLastPathComponent] lastPathComponent]];
1131 /* if not the VIDEO_TS Folder, we can assume the chosen folder is the source name */
1132 displayTitlescanSourceName = [NSString stringWithFormat:[scanPath lastPathComponent]];
1134 /* we set the source display name in the title selection dialogue */
1135 [fSrcDsplyNameTitleScan setStringValue: [NSString stringWithFormat:@"%@", displayTitlescanSourceName]];
1136 /* We show the actual sheet where the user specifies the title to be scanned
1137 * as we are going to do a title specific scan
1139 [self showSourceTitleScanPanel:NULL];
1143 /* We are just doing a standard full source scan, so we specify "0" to libhb */
1144 NSString *path = [[sheet filenames] objectAtIndex: 0];
1145 [self performScan:path scanTitleNum:0];
1149 else // User clicked Cancel in browse window
1151 /* if we have a title loaded up */
1152 if ([[fSrcDVD2Field stringValue] length] > 0)
1154 [self enableUI: YES];
1159 /* Here we open the title selection sheet where we can specify an exact title to be scanned */
1160 - (IBAction) showSourceTitleScanPanel: (id) sender
1162 /* We default the title number to be scanned to "0" which results in a full source scan, unless the
1165 [fScanSrcTitleNumField setStringValue: @"0"];
1166 /* Show the panel */
1167 [NSApp beginSheet: fScanSrcTitlePanel modalForWindow: fWindow modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
1170 - (IBAction) closeSourceTitleScanPanel: (id) sender
1172 [NSApp endSheet: fScanSrcTitlePanel];
1173 [fScanSrcTitlePanel orderOut: self];
1177 if(sender == fScanSrcTitleOpenButton)
1179 /* We setup the scan status in the main window to indicate a source title scan */
1180 [fSrcDVD2Field setStringValue: _( @"Opening a new source title ..." )];
1181 //[fScanIndicator setHidden: NO];
1182 [fScanIndicator setIndeterminate: YES];
1183 [fScanIndicator startAnimation: nil];
1185 /* We use the performScan method to actually perform the specified scan passing the path and the title
1188 [self performScan:[fScanSrcTitlePathField stringValue] scanTitleNum:[fScanSrcTitleNumField intValue]];
1193 /* Here we actually tell hb_scan to perform the source scan, using the path to source and title number*/
1194 - (void) performScan:(NSString *) scanPath scanTitleNum: (int) scanTitleNum
1196 NSString *path = scanPath;
1197 HBDVDDetector *detector = [HBDVDDetector detectorForPath:path];
1198 if( [detector isVideoDVD] )
1200 // The chosen path was actually on a DVD, so use the raw block
1201 // device path instead.
1202 path = [detector devicePath];
1204 /* If there is no title number passed to scan, we use "0"
1205 * which causes the default behavior of a full source scan
1211 //[fScanIndicator setHidden: NO];
1212 hb_scan( fHandle, [path UTF8String], scanTitleNum );
1216 - (IBAction) showNewScan:(id)sender
1220 int indxpri=0; // Used to search the longuest title (default in combobox)
1221 int longuestpri=0; // Used to search the longuest title (default in combobox)
1223 list = hb_get_titles( fHandle );
1225 if( !hb_list_count( list ) )
1227 /* We display a message if a valid dvd source was not chosen */
1228 [fSrcDVD2Field setStringValue: @"No Valid Title Found"];
1229 SuccessfulScan = NO;
1233 /* We increment the successful scancount here by one,
1234 which we use at the end of this function to tell the gui
1235 if this is the first successful scan since launch and whether
1236 or not we should set all settings to the defaults */
1238 currentSuccessfulScanCount++;
1240 [toolbar validateVisibleItems];
1242 [fSrcTitlePopUp removeAllItems];
1243 for( int i = 0; i < hb_list_count( list ); i++ )
1245 title = (hb_title_t *) hb_list_item( list, i );
1247 currentSource = [NSString stringWithUTF8String: title->name];
1249 /* To get the source name as well as the default output name, first we check to see if
1250 the selected directory is the VIDEO_TS Directory */
1251 if ([[currentSource lastPathComponent] isEqualToString: @"VIDEO_TS"])
1253 /* If VIDEO_TS Folder is chosen, choose its parent folder for the source display name
1254 we have to use the title->dvd value so we get the proper name of the volume if a physical dvd is the source*/
1255 sourceDisplayName = [NSString stringWithFormat:[[[NSString stringWithUTF8String: title->dvd] stringByDeletingLastPathComponent] lastPathComponent]];
1259 /* if not the VIDEO_TS Folder, we can assume the chosen folder is the source name */
1260 sourceDisplayName = [NSString stringWithFormat:[currentSource lastPathComponent]];
1262 /*Set DVD Name at top of window*/
1263 [fSrcDVD2Field setStringValue:[NSString stringWithFormat: @"%@", sourceDisplayName]];
1265 /* Use the dvd name in the default output field here
1266 May want to add code to remove blank spaces for some dvd names*/
1267 /* Check to see if the last destination has been set,use if so, if not, use Desktop */
1268 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"])
1270 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1271 @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],sourceDisplayName]];
1275 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1276 @"%@/Desktop/%@.mp4", NSHomeDirectory(),sourceDisplayName]];
1279 if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds)
1281 longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds;
1285 [self formatPopUpChanged:NULL];
1287 [fSrcTitlePopUp addItemWithTitle: [NSString
1288 stringWithFormat: @"%d - %02dh%02dm%02ds",
1289 title->index, title->hours, title->minutes,
1293 // Select the longuest title
1294 [fSrcTitlePopUp selectItemAtIndex: indxpri];
1295 [self titlePopUpChanged: NULL];
1297 SuccessfulScan = YES;
1298 [self enableUI: YES];
1300 /* if its the initial successful scan after awakeFromNib */
1301 if (currentSuccessfulScanCount == 1)
1303 [self selectDefaultPreset: NULL];
1304 /* if Deinterlace upon launch is specified in the prefs, then set to 1 for "Fast",
1305 if not, then set to 0 for none */
1306 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultDeinterlaceOn"] > 0)
1307 [fPictureController setDeinterlace:1];
1309 [fPictureController setDeinterlace:0];
1317 #pragma mark New Output Destination
1319 - (IBAction) browseFile: (id) sender
1321 /* Open a panel to let the user choose and update the text field */
1322 NSSavePanel * panel = [NSSavePanel savePanel];
1323 /* We get the current file name and path from the destination field here */
1324 [panel beginSheetForDirectory: [[fDstFile2Field stringValue] stringByDeletingLastPathComponent] file: [[fDstFile2Field stringValue] lastPathComponent]
1325 modalForWindow: fWindow modalDelegate: self
1326 didEndSelector: @selector( browseFileDone:returnCode:contextInfo: )
1330 - (void) browseFileDone: (NSSavePanel *) sheet
1331 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1333 if( returnCode == NSOKButton )
1335 [fDstFile2Field setStringValue: [sheet filename]];
1341 #pragma mark Main Window Control
1343 - (IBAction) openMainWindow: (id) sender
1345 [fWindow makeKeyAndOrderFront:nil];
1348 - (BOOL) windowShouldClose: (id) sender
1353 - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
1356 [fWindow makeKeyAndOrderFront:nil];
1365 #pragma mark Job Handling
1370 hb_list_t * list = hb_get_titles( fHandle );
1371 hb_title_t * title = (hb_title_t *) hb_list_item( list,
1372 [fSrcTitlePopUp indexOfSelectedItem] );
1373 hb_job_t * job = title->job;
1376 /* Chapter selection */
1377 job->chapter_start = [fSrcChapterStartPopUp indexOfSelectedItem] + 1;
1378 job->chapter_end = [fSrcChapterEndPopUp indexOfSelectedItem] + 1;
1380 /* Format and codecs */
1381 int format = [fDstFormatPopUp indexOfSelectedItem];
1382 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
1383 job->mux = FormatSettings[format][codecs] & HB_MUX_MASK;
1384 job->vcodec = FormatSettings[format][codecs] & HB_VCODEC_MASK;
1385 job->acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
1386 /* If mpeg-4, then set mpeg-4 specific options like chapters and > 4gb file sizes */
1387 if ([fDstFormatPopUp indexOfSelectedItem] == 0)
1389 /* We set the largeFileSize (64 bit formatting) variable here to allow for > 4gb files based on the format being
1390 mpeg4 and the checkbox being checked
1391 *Note: this will break compatibility with some target devices like iPod, etc.!!!!*/
1392 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0 && [fDstMpgLargeFileCheck state] == NSOnState)
1394 job->largeFileSize = 1;
1398 job->largeFileSize = 0;
1401 if ([fDstFormatPopUp indexOfSelectedItem] == 0 || [fDstFormatPopUp indexOfSelectedItem] == 3)
1403 /* We set the chapter marker extraction here based on the format being
1404 mpeg4 or mkv and the checkbox being checked */
1405 if ([fCreateChapterMarkers state] == NSOnState)
1407 job->chapter_markers = 1;
1411 job->chapter_markers = 0;
1414 if( ( job->vcodec & HB_VCODEC_FFMPEG ) &&
1415 [fVidEncoderPopUp indexOfSelectedItem] > 0 )
1417 job->vcodec = HB_VCODEC_XVID;
1419 if( job->vcodec & HB_VCODEC_X264 )
1421 if ([fVidEncoderPopUp indexOfSelectedItem] > 0 )
1423 /* Just use new Baseline Level 3.0
1424 Lets Deprecate Baseline Level 1.3h264_level*/
1425 job->h264_level = 30;
1426 job->mux = HB_MUX_IPOD;
1427 /* move sanity check for iPod Encoding here */
1428 job->pixel_ratio = 0 ;
1432 /* Set this flag to switch from Constant Quantizer(default) to Constant Rate Factor Thanks jbrjake
1433 Currently only used with Constant Quality setting*/
1434 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultCrf"] > 0 && [fVidQualityMatrix selectedRow] == 2)
1439 /* Below Sends x264 options to the core library if x264 is selected*/
1440 /* Lets use this as per Nyx, Thanks Nyx!*/
1441 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1442 /* Turbo first pass if two pass and Turbo First pass is selected */
1443 if( [fVidTwoPassCheck state] == NSOnState && [fVidTurboPassCheck state] == NSOnState )
1445 /* pass the "Turbo" string to be appended to the existing x264 opts string into a variable for the first pass */
1446 NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0";
1447 /* append the "Turbo" string variable to the existing opts string.
1448 Note: the "Turbo" string must be appended, not prepended to work properly*/
1449 NSString *firstPassOptStringCombined = [[fAdvancedOptions optionsString] stringByAppendingString:firstPassOptStringTurbo];
1450 strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]);
1454 strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]);
1457 job->h264_13 = [fVidEncoderPopUp indexOfSelectedItem];
1460 /* Video settings */
1461 if( [fVidRatePopUp indexOfSelectedItem] > 0 )
1463 job->vrate = 27000000;
1464 job->vrate_base = hb_video_rates[[fVidRatePopUp
1465 indexOfSelectedItem]-1].rate;
1469 job->vrate = title->rate;
1470 job->vrate_base = title->rate_base;
1473 switch( [fVidQualityMatrix selectedRow] )
1477 Bitrate should already have been calculated and displayed
1478 in fVidBitrateField, so let's just use it */
1480 job->vquality = -1.0;
1481 job->vbitrate = [fVidBitrateField intValue];
1484 job->vquality = [fVidQualitySlider floatValue];
1489 job->grayscale = ( [fVidGrayscaleCheck state] == NSOnState );
1491 /* Subtitle settings */
1492 job->subtitle = [fSubPopUp indexOfSelectedItem] - 2;
1494 /* Audio tracks and mixdowns */
1495 /* check for the condition where track 2 has an audio selected, but track 1 does not */
1496 /* we will use track 2 as track 1 in this scenario */
1497 if ([fAudLang1PopUp indexOfSelectedItem] > 0)
1499 job->audios[0] = [fAudLang1PopUp indexOfSelectedItem] - 1;
1500 job->audios[1] = [fAudLang2PopUp indexOfSelectedItem] - 1; /* will be -1 if "none" is selected */
1501 job->audios[2] = -1;
1502 job->audio_mixdowns[0] = [[fAudTrack1MixPopUp selectedItem] tag];
1503 job->audio_mixdowns[1] = [[fAudTrack2MixPopUp selectedItem] tag];
1505 else if ([fAudLang2PopUp indexOfSelectedItem] > 0)
1507 job->audios[0] = [fAudLang2PopUp indexOfSelectedItem] - 1;
1508 job->audio_mixdowns[0] = [[fAudTrack2MixPopUp selectedItem] tag];
1509 job->audios[1] = -1;
1513 job->audios[0] = -1;
1516 /* Audio settings */
1517 job->arate = hb_audio_rates[[fAudRatePopUp
1518 indexOfSelectedItem]].rate;
1519 job->abitrate = [[fAudBitratePopUp selectedItem] tag];
1521 /* set vfr according to the Picture Window */
1522 if ([fPictureController vfr])
1532 job->filters = hb_list_init();
1535 if ([fPictureController detelecine])
1537 hb_list_add( job->filters, &hb_filter_detelecine );
1541 if ([fPictureController deinterlace] == 1)
1543 /* Run old deinterlacer by default */
1544 hb_filter_deinterlace.settings = "-1";
1545 hb_list_add( job->filters, &hb_filter_deinterlace );
1547 else if ([fPictureController deinterlace] == 2)
1549 /* Yadif mode 0 (1-pass with spatial deinterlacing.) */
1550 hb_filter_deinterlace.settings = "0";
1551 hb_list_add( job->filters, &hb_filter_deinterlace );
1553 else if ([fPictureController deinterlace] == 3)
1555 /* Yadif (1-pass w/o spatial deinterlacing) and Mcdeint */
1556 hb_filter_deinterlace.settings = "2:-1:1";
1557 hb_list_add( job->filters, &hb_filter_deinterlace );
1559 else if ([fPictureController deinterlace] == 4)
1561 /* Yadif (2-pass w/ spatial deinterlacing) and Mcdeint*/
1562 hb_filter_deinterlace.settings = "1:-1:1";
1563 hb_list_add( job->filters, &hb_filter_deinterlace );
1568 if ([fPictureController denoise] == 1) // Weak in popup
1570 hb_filter_denoise.settings = "2:1:2:3";
1571 hb_list_add( job->filters, &hb_filter_denoise );
1573 else if ([fPictureController denoise] == 2) // Medium in popup
1575 hb_filter_denoise.settings = "3:2:2:3";
1576 hb_list_add( job->filters, &hb_filter_denoise );
1578 else if ([fPictureController denoise] == 3) // Strong in popup
1580 hb_filter_denoise.settings = "7:7:5:5";
1581 hb_list_add( job->filters, &hb_filter_denoise );
1584 /* Deblock (uses pp7 default) */
1585 if ([fPictureController deblock])
1587 hb_list_add( job->filters, &hb_filter_deblock );
1594 /* addToQueue: puts up an alert before ultimately calling doAddToQueue
1596 - (IBAction) addToQueue: (id) sender
1598 /* We get the destination directory from the destination field here */
1599 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1600 /* We check for a valid destination here */
1601 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1603 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1607 /* We check for duplicate name here */
1608 if( [[NSFileManager defaultManager] fileExistsAtPath:
1609 [fDstFile2Field stringValue]] )
1611 NSBeginCriticalAlertSheet( _( @"File already exists" ),
1612 _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
1613 @selector( overwriteAddToQueueAlertDone:returnCode:contextInfo: ),
1614 NULL, NULL, [NSString stringWithFormat:
1615 _( @"Do you want to overwrite %@?" ),
1616 [fDstFile2Field stringValue]] );
1617 // overwriteAddToQueueAlertDone: will be called when the alert is dismissed.
1621 [self doAddToQueue];
1625 /* overwriteAddToQueueAlertDone: called from the alert posted by addToQueue that asks
1626 the user if they want to overwrite an exiting movie file.
1628 - (void) overwriteAddToQueueAlertDone: (NSWindow *) sheet
1629 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1631 if( returnCode == NSAlertAlternateReturn )
1632 [self doAddToQueue];
1635 - (void) doAddToQueue
1637 hb_list_t * list = hb_get_titles( fHandle );
1638 hb_title_t * title = (hb_title_t *) hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1639 hb_job_t * job = title->job;
1641 // Assign a sequence number, starting at zero, to each job added so they can
1642 // be lumped together in the UI.
1643 job->sequence_id = -1;
1647 /* Destination file */
1648 job->file = [[fDstFile2Field stringValue] UTF8String];
1650 if( [fSubForcedCheck state] == NSOnState )
1651 job->subtitle_force = 1;
1653 job->subtitle_force = 0;
1656 * subtitle of -1 is a scan
1658 if( job->subtitle == -1 )
1663 * When subtitle scan is enabled do a fast pre-scan job
1664 * which will determine which subtitles to enable, if any.
1667 x264opts_tmp = job->x264opts;
1670 job->x264opts = NULL;
1672 job->indepth_scan = 1;
1674 job->select_subtitle = (hb_subtitle_t**)malloc(sizeof(hb_subtitle_t*));
1675 *(job->select_subtitle) = NULL;
1678 * Add the pre-scan job
1680 job->sequence_id++; // for job grouping
1681 hb_add( fHandle, job );
1683 job->x264opts = x264opts_tmp;
1686 job->select_subtitle = NULL;
1688 /* No subtitle were selected, so reset the subtitle to -1 (which before
1689 * this point meant we were scanning
1691 if( job->subtitle == -2 )
1694 if( [fVidTwoPassCheck state] == NSOnState )
1696 hb_subtitle_t **subtitle_tmp = job->select_subtitle;
1697 job->indepth_scan = 0;
1700 * Do not autoselect subtitles on the first pass of a two pass
1702 job->select_subtitle = NULL;
1705 job->sequence_id++; // for job grouping
1706 hb_add( fHandle, job );
1709 job->sequence_id++; // for job grouping
1711 job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */
1712 strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]);
1714 job->select_subtitle = subtitle_tmp;
1716 hb_add( fHandle, job );
1720 job->indepth_scan = 0;
1722 job->sequence_id++; // for job grouping
1723 hb_add( fHandle, job );
1726 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1727 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1730 [fQueueController hblibJobListChanged];
1733 /* Rip: puts up an alert before ultimately calling doRip
1735 - (IBAction) Rip: (id) sender
1737 /* Rip or Cancel ? */
1739 hb_get_state2( fHandle, &s );
1741 if(s.state == HB_STATE_WORKING || s.state == HB_STATE_PAUSED)
1743 [self Cancel: sender];
1747 // If there are jobs in the queue, then this is a rip the queue
1749 if (hb_count( fHandle ) > 0)
1755 // Before adding jobs to the queue, check for a valid destination.
1757 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1758 if ([[NSFileManager defaultManager] fileExistsAtPath:destinationDirectory] == 0)
1760 NSRunAlertPanel(@"Warning!", @"This is not a valid destination directory!", @"OK", nil, nil);
1764 /* We check for duplicate name here */
1765 if( [[NSFileManager defaultManager] fileExistsAtPath:[fDstFile2Field stringValue]] )
1767 NSBeginCriticalAlertSheet( _( @"File already exists" ),
1768 _( @"Cancel" ), _( @"Overwrite" ), NULL, fWindow, self,
1769 @selector( overWriteAlertDone:returnCode:contextInfo: ),
1770 NULL, NULL, [NSString stringWithFormat:
1771 _( @"Do you want to overwrite %@?" ),
1772 [fDstFile2Field stringValue]] );
1774 // overWriteAlertDone: will be called when the alert is dismissed. It will call doRip.
1778 /* if there are no jobs in the queue, then add this one to the queue and rip
1779 otherwise, just rip the queue */
1780 if( hb_count( fHandle ) == 0)
1782 [self doAddToQueue];
1785 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1786 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1791 /* overWriteAlertDone: called from the alert posted by Rip: that asks the user if they
1792 want to overwrite an exiting movie file.
1794 - (void) overWriteAlertDone: (NSWindow *) sheet
1795 returnCode: (int) returnCode contextInfo: (void *) contextInfo
1797 if( returnCode == NSAlertAlternateReturn )
1799 /* if there are no jobs in the queue, then add this one to the queue and rip
1800 otherwise, just rip the queue */
1801 if( hb_count( fHandle ) == 0 )
1803 [self doAddToQueue];
1806 NSString *destinationDirectory = [[fDstFile2Field stringValue] stringByDeletingLastPathComponent];
1807 [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"];
1812 - (void) remindUserOfSleepOrShutdown
1814 if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Put Computer To Sleep"])
1816 /*Warn that computer will sleep after encoding*/
1819 reminduser = NSRunAlertPanel(@"The computer will sleep after encoding is done.",@"You have selected to sleep the computer after encoding. To turn off sleeping, go to the HandBrake preferences.", @"OK", @"Preferences...", nil);
1820 [NSApp requestUserAttention:NSCriticalRequest];
1821 if ( reminduser == NSAlertAlternateReturn )
1823 [self showPreferencesWindow:NULL];
1826 else if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"AlertWhenDone"] isEqualToString: @"Shut Down Computer"])
1828 /*Warn that computer will shut down after encoding*/
1831 reminduser = NSRunAlertPanel(@"The computer will shut down after encoding is done.",@"You have selected to shut down the computer after encoding. To turn off shut down, go to the HandBrake preferences.", @"OK", @"Preferences...", nil);
1832 [NSApp requestUserAttention:NSCriticalRequest];
1833 if ( reminduser == NSAlertAlternateReturn )
1835 [self showPreferencesWindow:NULL];
1844 /* Let libhb do the job */
1845 hb_start( fHandle );
1846 /*set the fEncodeState State */
1853 //------------------------------------------------------------------------------------
1854 // Removes all jobs from the queue. Does not cancel the current processing job.
1855 //------------------------------------------------------------------------------------
1856 - (void) doDeleteQueuedJobs
1859 while( ( job = hb_job( fHandle, 0 ) ) )
1860 hb_rem( fHandle, job );
1863 //------------------------------------------------------------------------------------
1864 // Cancels the current job and proceeds with the next one in the queue.
1865 //------------------------------------------------------------------------------------
1866 - (void) doCancelCurrentJob
1868 // Stop the current job. hb_stop will only cancel the current pass and then set
1869 // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we
1870 // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the
1871 // remaining passes of the job and then start the queue back up if there are any
1874 [fQueueController hblibWillStop];
1876 fEncodeState = 2; // don't alert at end of processing since this was a cancel
1880 //------------------------------------------------------------------------------------
1881 // Displays an alert asking user if the want to cancel encoding of current job.
1882 // Cancel: returns immediately after posting the alert. Later, when the user
1883 // acknowledges the alert, doCancelCurrentJob is called.
1884 //------------------------------------------------------------------------------------
1885 - (IBAction)Cancel: (id)sender
1887 if (!fHandle) return;
1889 hb_job_t * job = hb_current_job(fHandle);
1892 NSString * alertTitle = [NSString stringWithFormat:NSLocalizedString(@"Do you want to stop encoding of %@?", nil),
1893 [NSString stringWithUTF8String:job->title->name]];
1895 // Which window to attach the sheet to?
1896 NSWindow * docWindow;
1897 if ([sender respondsToSelector: @selector(window)])
1898 docWindow = [sender window];
1900 docWindow = fWindow;
1902 NSBeginCriticalAlertSheet(
1904 NSLocalizedString(@"Keep Encoding", nil),
1905 NSLocalizedString(@"Delete All", nil),
1906 NSLocalizedString(@"Stop Encoding", nil),
1908 nil, @selector(didDimissCancelCurrentJob:returnCode:contextInfo:), nil,
1909 NSLocalizedString(@"Your movie will be lost if you don't continue encoding.", nil),
1910 [NSString stringWithUTF8String:job->title->name]);
1912 // didDimissCancelCurrentJob:returnCode:contextInfo: will be called when the dialog is dismissed
1914 // N.B.: didDimissCancelCurrentJob:returnCode:contextInfo: is designated as the dismiss
1915 // selector to prevent a crash. As a dismiss selector, the alert window will
1916 // have already be dismissed. If we don't do it this way, the dismissing of
1917 // the alert window will cause the table view to be redrawn at a point where
1918 // current job has been deleted by hblib but we don't know about it yet. This
1919 // is a prime example of wy we need to NOT be relying on hb_current_job!!!!
1922 - (void) didDimissCancelCurrentJob: (NSWindow *)sheet returnCode: (int)returnCode contextInfo: (void *)contextInfo
1924 if (returnCode == NSAlertOtherReturn)
1925 [self doCancelCurrentJob];
1926 else if (returnCode == NSAlertAlternateReturn)
1928 [self doDeleteQueuedJobs];
1929 [self doCancelCurrentJob];
1937 - (IBAction) Pause: (id) sender
1940 hb_get_state2( fHandle, &s );
1942 if( s.state == HB_STATE_PAUSED )
1944 hb_resume( fHandle );
1948 hb_pause( fHandle );
1953 #pragma mark GUI Controls Changed Methods
1955 - (IBAction) titlePopUpChanged: (id) sender
1957 hb_list_t * list = hb_get_titles( fHandle );
1958 hb_title_t * title = (hb_title_t*)
1959 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
1962 /* If Auto Naming is on. We create an output filename of dvd name - title number */
1963 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultAutoNaming"] > 0)
1965 [fDstFile2Field setStringValue: [NSString stringWithFormat:
1966 @"%@/%@-%d.%@", [[fDstFile2Field stringValue] stringByDeletingLastPathComponent],
1967 [NSString stringWithUTF8String: title->name],
1969 [[fDstFile2Field stringValue] pathExtension]]];
1972 /* Update chapter popups */
1973 [fSrcChapterStartPopUp removeAllItems];
1974 [fSrcChapterEndPopUp removeAllItems];
1975 for( int i = 0; i < hb_list_count( title->list_chapter ); i++ )
1977 [fSrcChapterStartPopUp addItemWithTitle: [NSString
1978 stringWithFormat: @"%d", i + 1]];
1979 [fSrcChapterEndPopUp addItemWithTitle: [NSString
1980 stringWithFormat: @"%d", i + 1]];
1982 [fSrcChapterStartPopUp selectItemAtIndex: 0];
1983 [fSrcChapterEndPopUp selectItemAtIndex:
1984 hb_list_count( title->list_chapter ) - 1];
1985 [self chapterPopUpChanged: NULL];
1987 /* Start Get and set the initial pic size for display */
1988 hb_job_t * job = title->job;
1990 /* Turn Deinterlace on/off depending on the preference */
1991 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultDeinterlaceOn"] > 0)
1993 [fPictureController setDeinterlace:1];
1997 [fPictureController setDeinterlace:0];
2000 /* Pixel Ratio Setting */
2001 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PixelRatio"])
2003 job->pixel_ratio = 1 ;
2007 job->pixel_ratio = 0 ;
2009 /*Set Source Size Fields Here */
2010 [fPicSrcWidth setStringValue: [NSString stringWithFormat:
2011 @"%d", fTitle->width]];
2012 [fPicSrcHeight setStringValue: [NSString stringWithFormat:
2013 @"%d", fTitle->height]];
2015 /* Set Auto Crop to on upon selecting a new title */
2016 [fPictureController setAutoCrop:YES];
2018 /* We get the originial output picture width and height and put them
2019 in variables for use with some presets later on */
2020 PicOrigOutputWidth = job->width;
2021 PicOrigOutputHeight = job->height;
2022 AutoCropTop = job->crop[0];
2023 AutoCropBottom = job->crop[1];
2024 AutoCropLeft = job->crop[2];
2025 AutoCropRight = job->crop[3];
2026 /* we test getting the max output value for pic sizing here to be used later*/
2027 [fPicSettingWidth setStringValue: [NSString stringWithFormat:
2028 @"%d", PicOrigOutputWidth]];
2029 [fPicSettingHeight setStringValue: [NSString stringWithFormat:
2030 @"%d", PicOrigOutputHeight]];
2031 /* we run the picture size values through
2032 calculatePictureSizing to get all picture size
2034 [self calculatePictureSizing: NULL];
2035 /* Run Through encoderPopUpChanged to see if there
2036 needs to be any pic value modifications based on encoder settings */
2037 //[self encoderPopUpChanged: NULL];
2038 /* END Get and set the initial pic size for display */
2040 /* Update subtitle popups */
2041 hb_subtitle_t * subtitle;
2042 [fSubPopUp removeAllItems];
2043 [fSubPopUp addItemWithTitle: @"None"];
2044 [fSubPopUp addItemWithTitle: @"Autoselect"];
2045 for( int i = 0; i < hb_list_count( title->list_subtitle ); i++ )
2047 subtitle = (hb_subtitle_t *) hb_list_item( title->list_subtitle, i );
2049 /* We cannot use NSPopUpButton's addItemWithTitle because
2050 it checks for duplicate entries */
2051 [[fSubPopUp menu] addItemWithTitle: [NSString stringWithCString:
2052 subtitle->lang] action: NULL keyEquivalent: @""];
2054 [fSubPopUp selectItemAtIndex: 0];
2056 [self subtitleSelectionChanged: NULL];
2058 /* Update chapter table */
2059 [fChapterTitlesDelegate resetWithTitle:title];
2060 [fChapterTable reloadData];
2062 /* Update audio popups */
2063 [self addAllAudioTracksToPopUp: fAudLang1PopUp];
2064 [self addAllAudioTracksToPopUp: fAudLang2PopUp];
2065 /* search for the first instance of our prefs default language for track 1, and set track 2 to "none" */
2066 NSString * audioSearchPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"DefaultLanguage"];
2067 [self selectAudioTrackInPopUp: fAudLang1PopUp searchPrefixString: audioSearchPrefix selectIndexIfNotFound: 1];
2068 [self selectAudioTrackInPopUp: fAudLang2PopUp searchPrefixString: NULL selectIndexIfNotFound: 0];
2070 /* changing the title may have changed the audio channels on offer, */
2071 /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
2072 [self audioTrackPopUpChanged: fAudLang1PopUp];
2073 [self audioTrackPopUpChanged: fAudLang2PopUp];
2075 /* We repopulate the Video Framerate popup and show the detected framerate along with "Same as Source"*/
2076 [fVidRatePopUp removeAllItems];
2077 if (fTitle->rate_base == 1126125) // 23.976 NTSC Film
2079 [fVidRatePopUp addItemWithTitle: @"Same as source (23.976)"];
2081 else if (fTitle->rate_base == 1080000) // 25 PAL Film/Video
2083 [fVidRatePopUp addItemWithTitle: @"Same as source (25)"];
2085 else if (fTitle->rate_base == 900900) // 29.97 NTSC Video
2087 [fVidRatePopUp addItemWithTitle: @"Same as source (29.97)"];
2091 /* if none of the common dvd source framerates is detected, just use "Same as source" */
2092 [fVidRatePopUp addItemWithTitle: @"Same as source"];
2094 for( int i = 0; i < hb_video_rates_count; i++ )
2096 if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.3f",23.976]])
2098 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
2099 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Film)"]];
2101 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%d",25]])
2103 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
2104 [NSString stringWithCString: hb_video_rates[i].string], @" (PAL Film/Video)"]];
2106 else if ([[NSString stringWithCString: hb_video_rates[i].string] isEqualToString: [NSString stringWithFormat: @"%.2f",29.97]])
2108 [fVidRatePopUp addItemWithTitle:[NSString stringWithFormat: @"%@%@",
2109 [NSString stringWithCString: hb_video_rates[i].string], @" (NTSC Video)"]];
2113 [fVidRatePopUp addItemWithTitle:
2114 [NSString stringWithCString: hb_video_rates[i].string]];
2117 [fVidRatePopUp selectItemAtIndex: 0];
2119 /* lets call tableViewSelected to make sure that any preset we have selected is enforced after a title change */
2120 [self tableViewSelected:NULL];
2124 - (IBAction) chapterPopUpChanged: (id) sender
2127 /* If start chapter popup is greater than end chapter popup,
2128 we set the end chapter popup to the same as start chapter popup */
2129 if ([fSrcChapterStartPopUp indexOfSelectedItem] > [fSrcChapterEndPopUp indexOfSelectedItem])
2131 [fSrcChapterEndPopUp selectItemAtIndex: [fSrcChapterStartPopUp indexOfSelectedItem]];
2135 hb_list_t * list = hb_get_titles( fHandle );
2136 hb_title_t * title = (hb_title_t *)
2137 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
2139 hb_chapter_t * chapter;
2140 int64_t duration = 0;
2141 for( int i = [fSrcChapterStartPopUp indexOfSelectedItem];
2142 i <= [fSrcChapterEndPopUp indexOfSelectedItem]; i++ )
2144 chapter = (hb_chapter_t *) hb_list_item( title->list_chapter, i );
2145 duration += chapter->duration;
2148 duration /= 90000; /* pts -> seconds */
2149 [fSrcDuration2Field setStringValue: [NSString stringWithFormat:
2150 @"%02lld:%02lld:%02lld", duration / 3600, ( duration / 60 ) % 60,
2153 [self calculateBitrate: sender];
2156 - (IBAction) formatPopUpChanged: (id) sender
2158 NSString * string = [fDstFile2Field stringValue];
2159 NSString * selectedCodecs = [fDstCodecsPopUp titleOfSelectedItem];
2160 int format = [fDstFormatPopUp indexOfSelectedItem];
2162 /* Initially set the large file (64 bit formatting) output checkbox to hidden */
2163 [fDstMpgLargeFileCheck setHidden: YES];
2164 /* Update the codecs popup */
2165 [fDstCodecsPopUp removeAllItems];
2169 /*Get Default MP4 File Extension*/
2170 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0)
2179 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / AAC Audio" )];
2180 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / AAC Audio" )];
2182 /* We enable the create chapters checkbox here since we are .mp4*/
2183 [fCreateChapterMarkers setEnabled: YES];
2184 /* We show the Large File (64 bit formatting) checkbox since we are .mp4
2185 if we have enabled the option in the global preferences*/
2186 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AllowLargeFiles"] > 0)
2188 [fDstMpgLargeFileCheck setHidden: NO];
2192 /* if not enable in global preferences, we additionaly sanity check that the
2193 hidden checkbox is set to off. */
2194 [fDstMpgLargeFileCheck setState: NSOffState];
2200 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / AAC Audio" )];
2201 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / AC-3 Audio" )];
2202 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / MP3 Audio" )];
2203 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / Vorbis Audio" )];
2205 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / AAC Audio" )];
2206 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / AC-3 Audio" )];
2207 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / MP3 Audio" )];
2208 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / Vorbis Audio" )];
2209 /* We enable the create chapters checkbox here */
2210 [fCreateChapterMarkers setEnabled: YES];
2215 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / MP3 Audio" )];
2216 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / AC-3 Audio" )];
2217 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / MP3 Audio" )];
2218 [fDstCodecsPopUp addItemWithTitle:_( @"AVC/H.264 Video / AC-3 Audio" )];
2219 /* We disable the create chapters checkbox here and make sure it is unchecked*/
2220 [fCreateChapterMarkers setEnabled: NO];
2221 [fCreateChapterMarkers setState: NSOffState];
2226 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / Vorbis Audio" )];
2227 [fDstCodecsPopUp addItemWithTitle:_( @"MPEG-4 Video / MP3 Audio" )];
2228 /* We disable the create chapters checkbox here and make sure it is unchecked*/
2229 [fCreateChapterMarkers setEnabled: NO];
2230 [fCreateChapterMarkers setState: NSOffState];
2234 if ( SuccessfulScan ) {
2235 [fDstCodecsPopUp selectItemWithTitle:selectedCodecs];
2237 /* Add/replace to the correct extension */
2238 if( [string characterAtIndex: [string length] - 4] == '.' )
2240 [fDstFile2Field setStringValue: [NSString stringWithFormat:
2241 @"%@.%s", [string substringToIndex: [string length] - 4],
2246 [fDstFile2Field setStringValue: [NSString stringWithFormat:
2247 @"%@.%s", string, ext]];
2250 if ( [fDstCodecsPopUp selectedItem] == NULL )
2252 [fDstCodecsPopUp selectItemAtIndex:0];
2253 [self codecsPopUpChanged: NULL];
2255 /* changing the format may mean that we can / can't offer mono or 6ch, */
2256 /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
2257 [self audioTrackPopUpChanged: fAudLang1PopUp];
2258 [self audioTrackPopUpChanged: fAudLang2PopUp];
2259 /* We call the method to properly enable/disable turbo 2 pass */
2260 [self twoPassCheckboxChanged: sender];
2261 /* We call method method to change UI to reflect whether a preset is used or not*/
2265 [self customSettingUsed: sender];
2268 - (IBAction) codecsPopUpChanged: (id) sender
2270 int format = [fDstFormatPopUp indexOfSelectedItem];
2271 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2273 [fAdvancedOptions setHidden:YES];
2275 /* Update the encoder popup*/
2276 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
2278 /* MPEG-4 -> H.264 */
2279 [fVidEncoderPopUp removeAllItems];
2280 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 Main)"];
2281 [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 iPod)"];
2282 [fVidEncoderPopUp selectItemAtIndex: 0];
2283 [fAdvancedOptions setHidden:NO];
2286 else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) )
2288 /* H.264 -> MPEG-4 */
2289 [fVidEncoderPopUp removeAllItems];
2290 [fVidEncoderPopUp addItemWithTitle: @"FFmpeg"];
2291 [fVidEncoderPopUp addItemWithTitle: @"XviD"];
2292 [fVidEncoderPopUp selectItemAtIndex: 0];
2296 if( FormatSettings[format][codecs] & HB_ACODEC_AC3 )
2298 /* AC-3 pass-through: disable samplerate and bitrate */
2299 [fAudRatePopUp setEnabled: NO];
2300 [fAudBitratePopUp setEnabled: NO];
2304 [fAudRatePopUp setEnabled: YES];
2305 [fAudBitratePopUp setEnabled: YES];
2307 /* changing the codecs on offer may mean that we can / can't offer mono or 6ch, */
2308 /* so call audioTrackPopUpChanged for both audio tracks to update the mixdown popups */
2309 [self audioTrackPopUpChanged: fAudLang1PopUp];
2310 [self audioTrackPopUpChanged: fAudLang2PopUp];
2312 [self calculateBitrate: sender];
2313 [self twoPassCheckboxChanged: sender];
2316 - (IBAction) encoderPopUpChanged: (id) sender
2319 /* Check to see if we need to modify the job pic values based on x264 (iPod) encoder selection */
2320 if ([fDstFormatPopUp indexOfSelectedItem] == 0 && [fDstCodecsPopUp indexOfSelectedItem] == 1 && [fVidEncoderPopUp indexOfSelectedItem] == 1)
2322 hb_job_t * job = fTitle->job;
2323 job->pixel_ratio = 0 ;
2325 if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultPicSizeAutoiPod"] > 0)
2328 if (job->width > 640)
2332 job->keep_ratio = 1;
2333 hb_fix_aspect( job, HB_KEEP_WIDTH );
2336 /* Make sure the 64bit formatting checkbox is off */
2337 [fDstMpgLargeFileCheck setState: NSOffState];
2340 [self calculatePictureSizing: sender];
2341 [self twoPassCheckboxChanged: sender];
2344 /* Method to determine if we should change the UI
2345 To reflect whether or not a Preset is being used or if
2346 the user is using "Custom" settings by determining the sender*/
2347 - (IBAction) customSettingUsed: (id) sender
2349 if ([sender stringValue] != NULL)
2351 /* Deselect the currently selected Preset if there is one*/
2352 [tableView deselectRow:[tableView selectedRow]];
2353 [[fPresetsActionMenu itemAtIndex:0] setEnabled: NO];
2354 /* Change UI to show "Custom" settings are being used */
2355 [fPresetSelectedDisplay setStringValue: @"Custom"];
2357 curUserPresetChosenNum = nil;
2364 #pragma mark - Video
2366 - (IBAction) twoPassCheckboxChanged: (id) sender
2368 /* check to see if x264 is chosen */
2369 int format = [fDstFormatPopUp indexOfSelectedItem];
2370 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2371 if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) )
2373 if( [fVidTwoPassCheck state] == NSOnState)
2375 [fVidTurboPassCheck setHidden: NO];
2379 [fVidTurboPassCheck setHidden: YES];
2380 [fVidTurboPassCheck setState: NSOffState];
2382 /* Make sure Two Pass is checked if Turbo is checked */
2383 if( [fVidTurboPassCheck state] == NSOnState)
2385 [fVidTwoPassCheck setState: NSOnState];
2390 [fVidTurboPassCheck setHidden: YES];
2391 [fVidTurboPassCheck setState: NSOffState];
2394 /* We call method method to change UI to reflect whether a preset is used or not*/
2395 [self customSettingUsed: sender];
2398 - (IBAction ) videoFrameRateChanged: (id) sender
2400 /* We call method method to calculatePictureSizing to error check detelecine*/
2401 [self calculatePictureSizing: sender];
2403 /* We call method method to change UI to reflect whether a preset is used or not*/
2404 [self customSettingUsed: sender];
2406 - (IBAction) videoMatrixChanged: (id) sender;
2408 bool target, bitrate, quality;
2410 target = bitrate = quality = false;
2411 if( [fVidQualityMatrix isEnabled] )
2413 switch( [fVidQualityMatrix selectedRow] )
2426 [fVidTargetSizeField setEnabled: target];
2427 [fVidBitrateField setEnabled: bitrate];
2428 [fVidQualitySlider setEnabled: quality];
2429 [fVidTwoPassCheck setEnabled: !quality &&
2430 [fVidQualityMatrix isEnabled]];
2433 [fVidTwoPassCheck setState: NSOffState];
2434 [fVidTurboPassCheck setHidden: YES];
2435 [fVidTurboPassCheck setState: NSOffState];
2438 [self qualitySliderChanged: sender];
2439 [self calculateBitrate: sender];
2440 [self customSettingUsed: sender];
2443 - (IBAction) qualitySliderChanged: (id) sender
2445 [fVidConstantCell setTitle: [NSString stringWithFormat:
2446 _( @"Constant quality: %.0f %%" ), 100.0 *
2447 [fVidQualitySlider floatValue]]];
2448 [self customSettingUsed: sender];
2451 - (void) controlTextDidChange: (NSNotification *) notification
2453 [self calculateBitrate: NULL];
2456 - (IBAction) calculateBitrate: (id) sender
2458 if( !fHandle || [fVidQualityMatrix selectedRow] != 0 || !SuccessfulScan )
2463 hb_list_t * list = hb_get_titles( fHandle );
2464 hb_title_t * title = (hb_title_t *) hb_list_item( list,
2465 [fSrcTitlePopUp indexOfSelectedItem] );
2466 hb_job_t * job = title->job;
2470 [fVidBitrateField setIntValue: hb_calc_bitrate( job,
2471 [fVidTargetSizeField intValue] )];
2475 #pragma mark - Picture
2477 /* lets set the picture size back to the max from right after title scan
2478 Lets use an IBAction here as down the road we could always use a checkbox
2479 in the gui to easily take the user back to max. Remember, the compiler
2480 resolves IBActions down to -(void) during compile anyway */
2481 - (IBAction) revertPictureSizeToMax: (id) sender
2483 hb_job_t * job = fTitle->job;
2484 /* We use the output picture width and height
2485 as calculated from libhb right after title is set
2486 in TitlePopUpChanged */
2487 job->width = PicOrigOutputWidth;
2488 job->height = PicOrigOutputHeight;
2489 [fPictureController setAutoCrop:YES];
2490 /* Here we use the auto crop values determined right after scan */
2491 job->crop[0] = AutoCropTop;
2492 job->crop[1] = AutoCropBottom;
2493 job->crop[2] = AutoCropLeft;
2494 job->crop[3] = AutoCropRight;
2497 [self calculatePictureSizing: sender];
2498 /* We call method to change UI to reflect whether a preset is used or not*/
2499 [self customSettingUsed: sender];
2503 * Registers changes made in the Picture Settings Window.
2506 - (void)pictureSettingsDidChange {
2507 [self calculatePictureSizing: NULL];
2510 /* Get and Display Current Pic Settings in main window */
2511 - (IBAction) calculatePictureSizing: (id) sender
2513 [fPicSettingWidth setStringValue: [NSString stringWithFormat:@"%d", fTitle->job->width]];
2514 [fPicSettingHeight setStringValue: [NSString stringWithFormat:@"%d", fTitle->job->height]];
2516 if (fTitle->job->pixel_ratio == 1)
2518 int titlewidth = fTitle->width-fTitle->job->crop[2]-fTitle->job->crop[3];
2519 int arpwidth = fTitle->job->pixel_aspect_width;
2520 int arpheight = fTitle->job->pixel_aspect_height;
2521 int displayparwidth = titlewidth * arpwidth / arpheight;
2522 int displayparheight = fTitle->height-fTitle->job->crop[0]-fTitle->job->crop[1];
2524 [fPicSettingWidth setStringValue: [NSString stringWithFormat:@"%d", titlewidth]];
2525 [fPicSettingHeight setStringValue: [NSString stringWithFormat:@"%d", displayparheight]];
2526 [fPicLabelPAROutputX setStringValue: @"x"];
2527 [fPicSettingPARWidth setStringValue: [NSString stringWithFormat:@"%d", displayparwidth]];
2528 [fPicSettingPARHeight setStringValue: [NSString stringWithFormat:@"%d", displayparheight]];
2530 fTitle->job->keep_ratio = 0;
2534 [fPicLabelPAROutputX setStringValue: @""];
2535 [fPicSettingPARWidth setStringValue: @""];
2536 [fPicSettingPARHeight setStringValue: @""];
2539 /* Set ON/Off values for the deinterlace/keep aspect ratio according to boolean */
2540 if (fTitle->job->keep_ratio > 0)
2542 [fPicSettingARkeep setStringValue: @"On"];
2546 [fPicSettingARkeep setStringValue: @"Off"];
2549 if ([fPictureController detelecine]) {
2550 [fPicSettingDetelecine setStringValue: @"Yes"];
2553 [fPicSettingDetelecine setStringValue: @"No"];
2556 /* VFR (Variable Frame Rate) */
2557 if ([fPictureController vfr]) {
2558 /* vfr has to set the framerate to 29.97 (ntsc video)
2559 and disable the framerate popup */
2560 [fVidRatePopUp selectItemAtIndex: 8];
2561 [fVidRatePopUp setEnabled: NO];
2562 /* We change the string of the fps popup to warn that vfr is on Framerate (FPS): */
2563 [fVidRateField setStringValue: @"Framerate (VFR On):"];
2567 /* vfr is off, make sure the framerate popup is enabled */
2568 [fVidRatePopUp setEnabled: YES];
2569 /* and make sure the label for framerate is set to its default */
2570 [fVidRateField setStringValue: @"Framerate (FPS):"];
2574 if ([fPictureController deinterlace] == 0)
2576 [fPicSettingDeinterlace setStringValue: @"Off"];
2578 else if ([fPictureController deinterlace] == 1)
2580 [fPicSettingDeinterlace setStringValue: @"Fast"];
2582 else if ([fPictureController deinterlace] == 2)
2584 [fPicSettingDeinterlace setStringValue: @"Slow"];
2586 else if ([fPictureController deinterlace] == 3)
2588 [fPicSettingDeinterlace setStringValue: @"Slower"];
2590 else if ([fPictureController deinterlace] ==4)
2592 [fPicSettingDeinterlace setStringValue: @"Slowest"];
2595 if ([fPictureController denoise] == 0)
2597 [fPicSettingDenoise setStringValue: @"Off"];
2599 else if ([fPictureController denoise] == 1)
2601 [fPicSettingDenoise setStringValue: @"Weak"];
2603 else if ([fPictureController denoise] == 2)
2605 [fPicSettingDenoise setStringValue: @"Medium"];
2607 else if ([fPictureController denoise] == 3)
2609 [fPicSettingDenoise setStringValue: @"Strong"];
2613 if ([fPictureController deblock]) {
2614 [fPicSettingDeblock setStringValue: @"Yes"];
2617 [fPicSettingDeblock setStringValue: @"No"];
2620 if (fTitle->job->pixel_ratio > 0)
2622 [fPicSettingPAR setStringValue: @""];
2626 [fPicSettingPAR setStringValue: @"Off"];
2628 /* Set the display field for crop as per boolean */
2629 if (![fPictureController autoCrop])
2631 [fPicSettingAutoCrop setStringValue: @"Custom"];
2635 [fPicSettingAutoCrop setStringValue: @"Auto"];
2643 #pragma mark - Audio and Subtitles
2645 - (IBAction) setEnabledStateOfAudioMixdownControls: (id) sender
2648 /* enable/disable the mixdown text and popupbutton for audio track 1 */
2649 [fAudTrack1MixPopUp setEnabled: ([fAudLang1PopUp indexOfSelectedItem] == 0) ? NO : YES];
2650 [fAudTrack1MixLabel setTextColor: ([fAudLang1PopUp indexOfSelectedItem] == 0) ?
2651 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2653 /* enable/disable the mixdown text and popupbutton for audio track 2 */
2654 [fAudTrack2MixPopUp setEnabled: ([fAudLang2PopUp indexOfSelectedItem] == 0) ? NO : YES];
2655 [fAudTrack2MixLabel setTextColor: ([fAudLang2PopUp indexOfSelectedItem] == 0) ?
2656 [NSColor disabledControlTextColor] : [NSColor controlTextColor]];
2660 - (IBAction) addAllAudioTracksToPopUp: (id) sender
2663 hb_list_t * list = hb_get_titles( fHandle );
2664 hb_title_t * title = (hb_title_t*)
2665 hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
2669 [sender removeAllItems];
2670 [sender addItemWithTitle: _( @"None" )];
2671 for( int i = 0; i < hb_list_count( title->list_audio ); i++ )
2673 audio = (hb_audio_t *) hb_list_item( title->list_audio, i );
2674 [[sender menu] addItemWithTitle:
2675 [NSString stringWithCString: audio->lang]
2676 action: NULL keyEquivalent: @""];
2678 [sender selectItemAtIndex: 0];
2682 - (IBAction) selectAudioTrackInPopUp: (id) sender searchPrefixString: (NSString *) searchPrefixString selectIndexIfNotFound: (int) selectIndexIfNotFound
2685 /* this method can be used to find a language, or a language-and-source-format combination, by passing in the appropriate string */
2686 /* e.g. to find the first French track, pass in an NSString * of "Francais" */
2687 /* e.g. to find the first English 5.1 AC3 track, pass in an NSString * of "English (AC3) (5.1 ch)" */
2688 /* if no matching track is found, then selectIndexIfNotFound is used to choose which track to select instead */
2690 if (searchPrefixString != NULL)
2693 for( int i = 0; i < [sender numberOfItems]; i++ )
2695 /* Try to find the desired search string */
2696 if ([[[sender itemAtIndex: i] title] hasPrefix:searchPrefixString])
2698 [sender selectItemAtIndex: i];
2702 /* couldn't find the string, so select the requested "search string not found" item */
2703 /* index of 0 means select the "none" item */
2704 /* index of 1 means select the first audio track */
2705 [sender selectItemAtIndex: selectIndexIfNotFound];
2709 /* if no search string is provided, then select the selectIndexIfNotFound item */
2710 [sender selectItemAtIndex: selectIndexIfNotFound];
2715 - (IBAction) audioTrackPopUpChanged: (id) sender
2717 /* utility function to call audioTrackPopUpChanged without passing in a mixdown-to-use */
2718 [self audioTrackPopUpChanged: sender mixdownToUse: 0];
2721 - (IBAction) audioTrackPopUpChanged: (id) sender mixdownToUse: (int) mixdownToUse
2724 /* make sure we have a selected title before continuing */
2725 if (fTitle == NULL) return;
2727 /* find out if audio track 1 or 2 was changed - this is passed to us in the tag of the sender */
2728 /* the sender will have been either fAudLang1PopUp (tag = 0) or fAudLang2PopUp (tag = 1) */
2729 int thisAudio = [sender tag];
2731 /* get the index of the selected audio */
2732 int thisAudioIndex = [sender indexOfSelectedItem] - 1;
2734 /* Handbrake can't currently cope with ripping the same source track twice */
2735 /* So, if this audio is also selected in the other audio track popup, set that popup's selection to "none" */
2736 /* get a reference to the two audio track popups */
2737 NSPopUpButton * thisAudioPopUp = (thisAudio == 1 ? fAudLang2PopUp : fAudLang1PopUp);
2738 NSPopUpButton * otherAudioPopUp = (thisAudio == 1 ? fAudLang1PopUp : fAudLang2PopUp);
2739 /* if the same track is selected in the other audio popup, then select "none" in that popup */
2740 /* unless, of course, both are selected as "none!" */
2741 if ([thisAudioPopUp indexOfSelectedItem] != 0 && [thisAudioPopUp indexOfSelectedItem] == [otherAudioPopUp indexOfSelectedItem]) {
2742 [otherAudioPopUp selectItemAtIndex: 0];
2743 [self audioTrackPopUpChanged: otherAudioPopUp];
2746 /* pointer for the hb_audio_s struct we will use later on */
2749 /* find out what the currently-selected output audio codec is */
2750 int format = [fDstFormatPopUp indexOfSelectedItem];
2751 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2752 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2754 /* pointer to this track's mixdown NSPopUpButton */
2755 NSTextField * mixdownTextField;
2756 NSPopUpButton * mixdownPopUp;
2758 /* find our mixdown NSTextField and NSPopUpButton */
2761 mixdownTextField = fAudTrack1MixLabel;
2762 mixdownPopUp = fAudTrack1MixPopUp;
2766 mixdownTextField = fAudTrack2MixLabel;
2767 mixdownPopUp = fAudTrack2MixPopUp;
2770 /* delete the previous audio mixdown options */
2771 [mixdownPopUp removeAllItems];
2773 /* check if the audio mixdown controls need their enabled state changing */
2774 [self setEnabledStateOfAudioMixdownControls: NULL];
2776 if (thisAudioIndex != -1)
2780 audio = (hb_audio_t *) hb_list_item( fTitle->list_audio, thisAudioIndex );
2784 /* find out if our selected output audio codec supports mono and / or 6ch */
2785 /* we also check for an input codec of AC3 or DCA,
2786 as they are the only libraries able to do the mixdown to mono / conversion to 6-ch */
2787 /* audioCodecsSupportMono and audioCodecsSupport6Ch are the same for now,
2788 but this may change in the future, so they are separated for flexibility */
2789 int audioCodecsSupportMono = ((audio->codec == HB_ACODEC_AC3 ||
2790 audio->codec == HB_ACODEC_DCA) && acodec == HB_ACODEC_FAAC);
2791 int audioCodecsSupport6Ch = ((audio->codec == HB_ACODEC_AC3 ||
2792 audio->codec == HB_ACODEC_DCA) && (acodec == HB_ACODEC_FAAC ||
2793 acodec == HB_ACODEC_VORBIS));
2795 /* check for AC-3 passthru */
2796 if (audio->codec == HB_ACODEC_AC3 && acodec == HB_ACODEC_AC3)
2798 [[mixdownPopUp menu] addItemWithTitle:
2799 [NSString stringWithCString: "AC3 Passthru"]
2800 action: NULL keyEquivalent: @""];
2805 /* add the appropriate audio mixdown menuitems to the popupbutton */
2806 /* in each case, we set the new menuitem's tag to be the amixdown value for that mixdown,
2807 so that we can reference the mixdown later */
2809 /* keep a track of the min and max mixdowns we used, so we can select the best match later */
2810 int minMixdownUsed = 0;
2811 int maxMixdownUsed = 0;
2813 /* get the input channel layout without any lfe channels */
2814 int layout = audio->input_channel_layout & HB_INPUT_CH_LAYOUT_DISCRETE_NO_LFE_MASK;
2816 /* do we want to add a mono option? */
2817 if (audioCodecsSupportMono == 1) {
2818 NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
2819 [NSString stringWithCString: hb_audio_mixdowns[0].human_readable_name]
2820 action: NULL keyEquivalent: @""];
2821 [menuItem setTag: hb_audio_mixdowns[0].amixdown];
2822 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[0].amixdown;
2823 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[0].amixdown);
2826 /* do we want to add a stereo option? */
2827 /* offer stereo if we have a mono source and non-mono-supporting codecs, as otherwise we won't have a mixdown at all */
2828 /* also offer stereo if we have a stereo-or-better source */
2829 if ((layout == HB_INPUT_CH_LAYOUT_MONO && audioCodecsSupportMono == 0) || layout >= HB_INPUT_CH_LAYOUT_STEREO) {
2830 NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
2831 [NSString stringWithCString: hb_audio_mixdowns[1].human_readable_name]
2832 action: NULL keyEquivalent: @""];
2833 [menuItem setTag: hb_audio_mixdowns[1].amixdown];
2834 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[1].amixdown;
2835 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[1].amixdown);
2838 /* do we want to add a dolby surround (DPL1) option? */
2839 if (layout == HB_INPUT_CH_LAYOUT_3F1R || layout == HB_INPUT_CH_LAYOUT_3F2R || layout == HB_INPUT_CH_LAYOUT_DOLBY) {
2840 NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
2841 [NSString stringWithCString: hb_audio_mixdowns[2].human_readable_name]
2842 action: NULL keyEquivalent: @""];
2843 [menuItem setTag: hb_audio_mixdowns[2].amixdown];
2844 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[2].amixdown;
2845 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[2].amixdown);
2848 /* do we want to add a dolby pro logic 2 (DPL2) option? */
2849 if (layout == HB_INPUT_CH_LAYOUT_3F2R) {
2850 NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
2851 [NSString stringWithCString: hb_audio_mixdowns[3].human_readable_name]
2852 action: NULL keyEquivalent: @""];
2853 [menuItem setTag: hb_audio_mixdowns[3].amixdown];
2854 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[3].amixdown;
2855 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[3].amixdown);
2858 /* do we want to add a 6-channel discrete option? */
2859 if (audioCodecsSupport6Ch == 1 && layout == HB_INPUT_CH_LAYOUT_3F2R && (audio->input_channel_layout & HB_INPUT_CH_LAYOUT_HAS_LFE)) {
2860 NSMenuItem *menuItem = [[mixdownPopUp menu] addItemWithTitle:
2861 [NSString stringWithCString: hb_audio_mixdowns[4].human_readable_name]
2862 action: NULL keyEquivalent: @""];
2863 [menuItem setTag: hb_audio_mixdowns[4].amixdown];
2864 if (minMixdownUsed == 0) minMixdownUsed = hb_audio_mixdowns[4].amixdown;
2865 maxMixdownUsed = MAX(maxMixdownUsed, hb_audio_mixdowns[4].amixdown);
2868 /* auto-select the best mixdown based on our saved mixdown preference */
2870 /* for now, this is hard-coded to a "best" mixdown of HB_AMIXDOWN_DOLBYPLII */
2871 /* ultimately this should be a prefs option */
2874 /* if we passed in a mixdown to use - in order to load a preset - then try and use it */
2875 if (mixdownToUse > 0)
2877 useMixdown = mixdownToUse;
2881 useMixdown = HB_AMIXDOWN_DOLBYPLII;
2884 /* if useMixdown > maxMixdownUsed, then use maxMixdownUsed */
2885 if (useMixdown > maxMixdownUsed) useMixdown = maxMixdownUsed;
2887 /* if useMixdown < minMixdownUsed, then use minMixdownUsed */
2888 if (useMixdown < minMixdownUsed) useMixdown = minMixdownUsed;
2890 /* select the (possibly-amended) preferred mixdown */
2891 [mixdownPopUp selectItemWithTag: useMixdown];
2893 /* lets call the audioTrackMixdownChanged method here to determine appropriate bitrates, etc. */
2894 [self audioTrackMixdownChanged: NULL];
2901 /* see if the new audio track choice will change the bitrate we need */
2902 [self calculateBitrate: sender];
2905 - (IBAction) audioTrackMixdownChanged: (id) sender
2908 /* find out what the currently-selected output audio codec is */
2909 int format = [fDstFormatPopUp indexOfSelectedItem];
2910 int codecs = [fDstCodecsPopUp indexOfSelectedItem];
2911 int acodec = FormatSettings[format][codecs] & HB_ACODEC_MASK;
2913 /* storage variable for the min and max bitrate allowed for this codec */
2919 case HB_ACODEC_FAAC:
2920 /* check if we have a 6ch discrete conversion in either audio track */
2921 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2923 /* FAAC is happy using our min bitrate of 32 kbps, even for 6ch */
2925 /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
2931 /* FAAC is happy using our min bitrate of 32 kbps for stereo or mono */
2933 /* FAAC won't honour anything more than 160 for stereo, so let's not offer it */
2934 /* note: haven't dealt with mono separately here, FAAC will just use the max it can */
2939 case HB_ACODEC_LAME:
2940 /* Lame is happy using our min bitrate of 32 kbps */
2942 /* Lame won't encode if the bitrate is higher than 320 kbps */
2946 case HB_ACODEC_VORBIS:
2947 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2949 /* Vorbis causes a crash if we use a bitrate below 192 kbps with 6 channel */
2951 /* If either mixdown popup includes 6-channel discrete, then allow up to 384 kbps */
2957 /* Vorbis causes a crash if we use a bitrate below 48 kbps */
2959 /* Vorbis can cope with 384 kbps quite happily, even for stereo */
2965 /* AC3 passthru disables the bitrate dropdown anyway, so we might as well just use the min and max bitrate */
2971 [fAudBitratePopUp removeAllItems];
2973 for( int i = 0; i < hb_audio_bitrates_count; i++ )
2975 if (hb_audio_bitrates[i].rate >= minbitrate && hb_audio_bitrates[i].rate <= maxbitrate)
2977 /* add a new menuitem for this bitrate */
2978 NSMenuItem *menuItem = [[fAudBitratePopUp menu] addItemWithTitle:
2979 [NSString stringWithCString: hb_audio_bitrates[i].string]
2980 action: NULL keyEquivalent: @""];
2981 /* set its tag to be the actual bitrate as an integer, so we can retrieve it later */
2982 [menuItem setTag: hb_audio_bitrates[i].rate];
2986 /* select the default bitrate (but use 384 for 6-ch AAC) */
2987 if ([[fAudTrack1MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH || [[fAudTrack2MixPopUp selectedItem] tag] == HB_AMIXDOWN_6CH)
2989 [fAudBitratePopUp selectItemWithTag: 384];
2993 [fAudBitratePopUp selectItemWithTag: hb_audio_bitrates[hb_audio_bitrates_default].rate];
2998 - (IBAction) subtitleSelectionChanged: (id) sender
3000 if ([fSubPopUp indexOfSelectedItem] == 0)
3002 [fSubForcedCheck setState: NSOffState];
3003 [fSubForcedCheck setEnabled: NO];
3007 [fSubForcedCheck setEnabled: YES];
3016 #pragma mark Open New Windows
3018 - (IBAction) openHomepage: (id) sender
3020 [[NSWorkspace sharedWorkspace] openURL: [NSURL
3021 URLWithString:@"http://handbrake.m0k.org/"]];
3024 - (IBAction) openForums: (id) sender
3026 [[NSWorkspace sharedWorkspace] openURL: [NSURL
3027 URLWithString:@"http://handbrake.m0k.org/forum/"]];
3029 - (IBAction) openUserGuide: (id) sender
3031 [[NSWorkspace sharedWorkspace] openURL: [NSURL
3032 URLWithString:@"http://handbrake.m0k.org/trac/wiki/HandBrakeGuide"]];
3036 * Shows debug output window.
3038 - (IBAction)showDebugOutputPanel:(id)sender
3040 [outputPanel showOutputPanel:sender];
3044 * Shows preferences window.
3046 - (IBAction) showPreferencesWindow: (id) sender
3048 NSWindow * window = [fPreferencesController window];
3049 if (![window isVisible])
3052 [window makeKeyAndOrderFront: nil];
3056 * Shows queue window.
3058 - (IBAction) showQueueWindow:(id)sender
3060 [fQueueController showQueueWindow:sender];
3064 - (IBAction) toggleDrawer:(id)sender {
3065 [fPresetDrawer toggle:self];
3069 * Shows Picture Settings Window.
3072 - (IBAction) showPicturePanel: (id) sender
3074 hb_list_t * list = hb_get_titles( fHandle );
3075 hb_title_t * title = (hb_title_t *) hb_list_item( list,
3076 [fSrcTitlePopUp indexOfSelectedItem] );
3077 [fPictureController showPanelInWindow:fWindow forTitle:title];
3081 #pragma mark Preset Table View Methods
3083 - (IBAction)tableViewSelected:(id)sender
3085 /* Since we cannot disable the presets tableView in terms of clickability
3086 we will use the enabled state of the add presets button to determine whether
3087 or not clicking on a preset will do anything */
3088 if ([fPresetsAdd isEnabled])
3090 if ([tableView selectedRow] >= 0)
3092 /* we get the chosen preset from the UserPresets array */
3093 chosenPreset = [UserPresets objectAtIndex:[tableView selectedRow]];
3094 curUserPresetChosenNum = [sender selectedRow];
3095 /* we set the preset display field in main window here */
3096 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
3097 if ([[chosenPreset objectForKey:@"Default"] intValue] == 1)
3099 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@ (Default)",[chosenPreset valueForKey:@"PresetName"]]];
3103 [fPresetSelectedDisplay setStringValue: [NSString stringWithFormat: @"%@",[chosenPreset valueForKey:@"PresetName"]]];
3106 [fDstFormatPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileFormat"]]];
3107 [self formatPopUpChanged: NULL];
3109 /* Chapter Markers*/
3110 [fCreateChapterMarkers setState:[[chosenPreset objectForKey:@"ChapterMarkers"] intValue]];
3111 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
3112 [fDstMpgLargeFileCheck setState:[[chosenPreset objectForKey:@"Mp4LargeFile"] intValue]];
3114 [fDstCodecsPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"FileCodecs"]]];
3115 [self codecsPopUpChanged: NULL];
3117 [fVidEncoderPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoEncoder"]]];
3119 /* We can show the preset options here in the gui if we want to
3120 so we check to see it the user has specified it in the prefs */
3121 [fAdvancedOptions setOptions: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]];
3123 /* Lets run through the following functions to get variables set there */
3124 [self encoderPopUpChanged: NULL];
3126 [self calculateBitrate: NULL];
3129 [fVidQualityMatrix selectCellAtRow:[[chosenPreset objectForKey:@"VideoQualityType"] intValue] column:0];
3131 [fVidTargetSizeField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoTargetSize"]]];
3132 [fVidBitrateField setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoAvgBitrate"]]];
3134 [fVidQualitySlider setFloatValue: [[chosenPreset valueForKey:@"VideoQualitySlider"] floatValue]];
3135 [self videoMatrixChanged: NULL];
3137 /* Video framerate */
3138 /* For video preset video framerate, we want to make sure that Same as source does not conflict with the
3139 detected framerate in the fVidRatePopUp so we use index 0*/
3140 if ([[NSString stringWithFormat:[chosenPreset valueForKey:@"VideoFramerate"]] isEqualToString: @"Same as source"])
3142 [fVidRatePopUp selectItemAtIndex: 0];
3146 [fVidRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"VideoFramerate"]]];
3150 [fVidGrayscaleCheck setState:[[chosenPreset objectForKey:@"VideoGrayScale"] intValue]];
3152 /* 2 Pass Encoding */
3153 [fVidTwoPassCheck setState:[[chosenPreset objectForKey:@"VideoTwoPass"] intValue]];
3154 [self twoPassCheckboxChanged: NULL];
3155 /* Turbo 1st pass for 2 Pass Encoding */
3156 [fVidTurboPassCheck setState:[[chosenPreset objectForKey:@"VideoTurboTwoPass"] intValue]];
3160 /* Audio Sample Rate*/
3161 [fAudRatePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioSampleRate"]]];
3162 /* Audio Bitrate Rate*/
3163 [fAudBitratePopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"AudioBitRate"]]];
3165 [fSubPopUp selectItemWithTitle: [NSString stringWithFormat:[chosenPreset valueForKey:@"Subtitles"]]];
3167 /* Picture Settings */
3168 /* Note: objectForKey:@"UsesPictureSettings" now refers to picture size, this encompasses:
3169 * height, width, keep ar, anamorphic and crop settings.
3170 * picture filters are now handled separately.
3171 * We will be able to actually change the key names for legacy preset keys when preset file
3172 * update code is done. But for now, lets hang onto the old legacy key name for backwards compatibility.
3174 /* Check to see if the objectForKey:@"UsesPictureSettings is greater than 0, as 0 means use picture sizing "None"
3175 * and the preset completely ignores any picture sizing values in the preset.
3177 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] > 0)
3179 hb_job_t * job = fTitle->job;
3180 /* Check to see if the objectForKey:@"UsesPictureSettings is 2 which is "Use Max for the source */
3181 if ([[chosenPreset objectForKey:@"UsesPictureSettings"] intValue] == 2 || [[chosenPreset objectForKey:@"UsesMaxPictureSettings"] intValue] == 1)
3183 /* Use Max Picture settings for whatever the dvd is.*/
3184 [self revertPictureSizeToMax: NULL];
3185 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
3186 if (job->keep_ratio == 1)
3188 hb_fix_aspect( job, HB_KEEP_WIDTH );
3189 if( job->height > fTitle->height )
3191 job->height = fTitle->height;
3192 hb_fix_aspect( job, HB_KEEP_HEIGHT );
3195 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
3197 else // /* If not 0 or 2 we assume objectForKey:@"UsesPictureSettings is 1 which is "Use picture sizing from when the preset was set" */
3199 job->width = [[chosenPreset objectForKey:@"PictureWidth"] intValue];
3200 job->height = [[chosenPreset objectForKey:@"PictureHeight"] intValue];
3201 job->keep_ratio = [[chosenPreset objectForKey:@"PictureKeepRatio"] intValue];
3202 if (job->keep_ratio == 1)
3204 hb_fix_aspect( job, HB_KEEP_WIDTH );
3205 if( job->height > fTitle->height )
3207 job->height = fTitle->height;
3208 hb_fix_aspect( job, HB_KEEP_HEIGHT );
3211 job->pixel_ratio = [[chosenPreset objectForKey:@"PicturePAR"] intValue];
3214 /* If Cropping is set to custom, then recall all four crop values from
3215 when the preset was created and apply them */
3216 if ([[chosenPreset objectForKey:@"PictureAutoCrop"] intValue] == 0)
3218 [fPictureController setAutoCrop:NO];
3220 /* Here we use the custom crop values saved at the time the preset was saved */
3221 job->crop[0] = [[chosenPreset objectForKey:@"PictureTopCrop"] intValue];
3222 job->crop[1] = [[chosenPreset objectForKey:@"PictureBottomCrop"] intValue];
3223 job->crop[2] = [[chosenPreset objectForKey:@"PictureLeftCrop"] intValue];
3224 job->crop[3] = [[chosenPreset objectForKey:@"PictureRightCrop"] intValue];
3227 else /* if auto crop has been saved in preset, set to auto and use post scan auto crop */
3229 [fPictureController setAutoCrop:YES];
3230 /* Here we use the auto crop values determined right after scan */
3231 job->crop[0] = AutoCropTop;
3232 job->crop[1] = AutoCropBottom;
3233 job->crop[2] = AutoCropLeft;
3234 job->crop[3] = AutoCropRight;
3237 /* If the preset has no objectForKey:@"UsesPictureFilters", then we know it is a legacy preset
3238 * and handle the filters here as before.
3239 * NOTE: This should be removed when the update presets code is done as we can be assured that legacy
3240 * presets are updated to work properly with new keys.
3242 if (![chosenPreset objectForKey:@"UsesPictureFilters"])
3245 [fPictureController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
3247 if ([[chosenPreset objectForKey:@"VFR"] intValue] == 1)
3249 [fPictureController setVFR:[[chosenPreset objectForKey:@"VFR"] intValue]];
3253 [fPictureController setVFR:0];
3256 if ([chosenPreset objectForKey:@"PictureDetelecine"])
3258 [fPictureController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
3260 if ([chosenPreset objectForKey:@"PictureDenoise"])
3262 [fPictureController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
3264 if ([chosenPreset objectForKey:@"PictureDeblock"])
3266 [fPictureController setDeblock:[[chosenPreset objectForKey:@"PictureDeblock"] intValue]];
3268 [self calculatePictureSizing: NULL];
3275 /* If the preset has an objectForKey:@"UsesPictureFilters", then we know it is a newer style filters preset
3276 * and handle the filters here depending on whether or not the preset specifies applying the filter.
3278 if ([chosenPreset objectForKey:@"UsesPictureFilters"] && [[chosenPreset objectForKey:@"UsesPictureFilters"] intValue] > 0)
3281 [fPictureController setDeinterlace:[[chosenPreset objectForKey:@"PictureDeinterlace"] intValue]];
3282 if ([chosenPreset objectForKey:@"VFR"])
3284 [fPictureController setVFR:[[chosenPreset objectForKey:@"VFR"] intValue]];
3288 [fPictureController setVFR:0];
3290 if ([chosenPreset objectForKey:@"PictureDetelecine"])
3292 [fPictureController setDetelecine:[[chosenPreset objectForKey:@"PictureDetelecine"] intValue]];
3294 if ([chosenPreset objectForKey:@"PictureDenoise"])
3296 [fPictureController setDenoise:[[chosenPreset objectForKey:@"PictureDenoise"] intValue]];
3298 if ([chosenPreset objectForKey:@"PictureDeblock"])
3300 [fPictureController setDeblock:[[chosenPreset objectForKey:@"PictureDeblock"] intValue]];
3303 [self calculatePictureSizing: NULL];
3304 [[fPresetsActionMenu itemAtIndex:0] setEnabled: YES];
3311 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
3313 return [UserPresets count];
3316 /* we use this to determine display characteristics for
3317 each table cell based on content currently only used to
3318 show the built in presets in a blue font. */
3319 - (void)tableView:(NSTableView *)aTableView
3320 willDisplayCell:(id)aCell
3321 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
3323 NSDictionary *userPresetDict = [UserPresets objectAtIndex:rowIndex];
3326 NSColor *shadowColor;
3327 txtFont = [NSFont systemFontOfSize: [NSFont smallSystemFontSize]];
3328 /* First, we check to see if its a selected row, if so, we use white since its highlighted in blue */
3329 if ([[aTableView selectedRowIndexes] containsIndex:rowIndex] && ([tableView editedRow] != rowIndex))
3332 fontColor = [NSColor whiteColor];
3333 shadowColor = [NSColor colorWithDeviceRed:(127.0/255.0) green:(140.0/255.0) blue:(160.0/255.0) alpha:1.0];
3337 /* We set the properties of unselected rows */
3338 /* if built-in preset (defined by "type" == 0) we use a blue font */
3339 if ([[userPresetDict objectForKey:@"Type"] intValue] == 0)
3341 fontColor = [NSColor blueColor];
3343 else // User created preset, use a black font
3345 fontColor = [NSColor blackColor];
3349 /* We check to see if this is the HB default, if so, color it appropriately */
3350 if (!presetUserDefault && presetHbDefault && rowIndex == presetHbDefault)
3352 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
3354 /* We check to see if this is the User Specified default, if so, color it appropriately */
3355 if (presetUserDefault && rowIndex == presetUserDefault)
3357 txtFont = [NSFont boldSystemFontOfSize: [NSFont smallSystemFontSize]];
3360 [aCell setTextColor:fontColor];
3361 [aCell setFont:txtFont];
3362 /* this shadow stuff (like mail app) for some reason looks crappy, commented out
3363 temporarily in case we want to resurrect it */
3365 NSShadow *shadow = [[NSShadow alloc] init];
3366 NSSize shadowOffset = { width: 1.0, height: -1.5};
3367 [shadow setShadowOffset:shadowOffset];
3368 [shadow setShadowColor:shadowColor];
3373 /* Method to display tooltip with the description for each preset, if available */
3374 - (NSString *)tableView:(NSTableView *)aTableView toolTipForCell:(NSCell *)aCell
3375 rect:(NSRectPointer)aRect tableColumn:(NSTableColumn *)aTableColumn
3376 row:(int)rowIndex mouseLocation:(NSPoint)aPos
3378 /* initialize the tooltip contents variable */
3380 /* if there is a description for the preset, we show it in the tooltip */
3381 if ([[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"])
3383 loc_tip = [NSString stringWithFormat: @"%@",[[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"]];
3388 loc_tip = @"No description available";
3394 - (id)tableView:(NSTableView *)aTableView
3395 objectValueForTableColumn:(NSTableColumn *)aTableColumn
3398 id theRecord, theValue;
3400 theRecord = [UserPresets objectAtIndex:rowIndex];
3401 theValue = [theRecord objectForKey:[aTableColumn identifier]];
3405 // NSTableDataSource method that we implement to edit values directly in the table...
3406 - (void)tableView:(NSTableView *)aTableView
3407 setObjectValue:(id)anObject
3408 forTableColumn:(NSTableColumn *)aTableColumn
3413 theRecord = [UserPresets objectAtIndex:rowIndex];
3414 [theRecord setObject:anObject forKey:@"PresetName"];
3415 /* We Sort the Presets By Factory or Custom */
3416 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
3417 ascending:YES] autorelease];
3418 /* We Sort the Presets Alphabetically by name */
3419 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
3420 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
3421 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
3422 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
3423 [UserPresets setArray:sortedArray];
3424 /* We Reload the New Table data for presets */
3425 [tableView reloadData];
3426 /* We save all of the preset data here */
3434 #pragma mark Manage Presets
3436 - (void) loadPresets {
3437 /* We declare the default NSFileManager into fileManager */
3438 NSFileManager * fileManager = [NSFileManager defaultManager];
3439 /*We define the location of the user presets file */
3440 UserPresetsFile = @"~/Library/Application Support/HandBrake/UserPresets.plist";
3441 UserPresetsFile = [[UserPresetsFile stringByExpandingTildeInPath]retain];
3442 /* We check for the presets.plist */
3443 if ([fileManager fileExistsAtPath:UserPresetsFile] == 0)
3445 [fileManager createFileAtPath:UserPresetsFile contents:nil attributes:nil];
3448 UserPresets = [[NSMutableArray alloc] initWithContentsOfFile:UserPresetsFile];
3449 if (nil == UserPresets)
3451 UserPresets = [[NSMutableArray alloc] init];
3452 [self addFactoryPresets:NULL];
3458 - (IBAction) showAddPresetPanel: (id) sender
3460 /* Deselect the currently selected Preset if there is one*/
3461 [tableView deselectRow:[tableView selectedRow]];
3463 /* Populate the preset picture settings popup here */
3464 [fPresetNewPicSettingsPopUp removeAllItems];
3465 [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
3466 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
3467 [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
3468 [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];
3469 /* Uncheck the preset use filters checkbox */
3470 [fPresetNewPicFiltersCheck setState:NSOffState];
3471 /* Erase info from the input fields*/
3472 [fPresetNewName setStringValue: @""];
3473 [fPresetNewDesc setStringValue: @""];
3474 /* Show the panel */
3475 [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
3478 - (IBAction) closeAddPresetPanel: (id) sender
3480 [NSApp endSheet: fAddPresetPanel];
3481 [fAddPresetPanel orderOut: self];
3484 - (IBAction)addUserPreset:(id)sender
3486 if (![[fPresetNewName stringValue] length])
3487 NSRunAlertPanel(@"Warning!", @"You need to insert a name for the preset.", @"OK", nil , nil);
3490 /* Here we create a custom user preset */
3491 [UserPresets addObject:[self createPreset]];
3494 [self closeAddPresetPanel:NULL];
3501 /* We Sort the Presets By Factory or Custom */
3502 NSSortDescriptor * presetTypeDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"Type"
3503 ascending:YES] autorelease];
3504 /* We Sort the Presets Alphabetically by name */
3505 NSSortDescriptor * presetNameDescriptor=[[[NSSortDescriptor alloc] initWithKey:@"PresetName"
3506 ascending:YES selector:@selector(caseInsensitiveCompare:)] autorelease];
3507 NSArray *sortDescriptors=[NSArray arrayWithObjects:presetTypeDescriptor,presetNameDescriptor,nil];
3508 NSArray *sortedArray=[UserPresets sortedArrayUsingDescriptors:sortDescriptors];
3509 [UserPresets setArray:sortedArray];
3512 /* We Reload the New Table data for presets */
3513 [tableView reloadData];
3514 /* We save all of the preset data here */
3518 - (IBAction)insertPreset:(id)sender
3520 int index = [tableView selectedRow];
3521 [UserPresets insertObject:[self createPreset] atIndex:index];
3522 [tableView reloadData];
3526 - (NSDictionary *)createPreset
3528 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3529 /* Get the New Preset Name from the field in the AddPresetPanel */
3530 [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
3531 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3532 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
3533 /*Set whether or not this is default, at creation set to 0*/
3534 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3535 /*Get the whether or not to apply pic Size and Cropping (includes Anamorphic)*/
3536 [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
3537 /* Get whether or not to use the current Picture Filter settings for the preset */
3538 [preset setObject:[NSNumber numberWithInt:[fPresetNewPicFiltersCheck state]] forKey:@"UsesPictureFilters"];
3540 /* Get New Preset Description from the field in the AddPresetPanel*/
3541 [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
3543 [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
3544 /* Chapter Markers fCreateChapterMarkers*/
3545 [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
3546 /* Allow Mpeg4 64 bit formatting +4GB file sizes */
3547 [preset setObject:[NSNumber numberWithInt:[fDstMpgLargeFileCheck state]] forKey:@"Mp4LargeFile"];
3549 [preset setObject:[fDstCodecsPopUp titleOfSelectedItem] forKey:@"FileCodecs"];
3551 [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
3552 /* x264 Option String */
3553 [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
3555 [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
3556 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3557 [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
3558 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3560 /* Video framerate */
3561 if ([fVidRatePopUp indexOfSelectedItem] == 0) // Same as source is selected
3563 [preset setObject:[NSString stringWithFormat: @"Same as source"] forKey:@"VideoFramerate"];
3565 else // we can record the actual titleOfSelectedItem
3567 [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
3570 [preset setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
3571 /* 2 Pass Encoding */
3572 [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
3573 /* Turbo 2 pass Encoding fVidTurboPassCheck*/
3574 [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
3575 /*Picture Settings*/
3576 hb_job_t * job = fTitle->job;
3577 /* Picture Sizing */
3578 /* Use Max Picture settings for whatever the dvd is.*/
3579 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3580 [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
3581 [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
3582 [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
3583 [preset setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
3585 /* Set crop settings here */
3586 [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];
3587 [preset setObject:[NSNumber numberWithInt:job->crop[0]] forKey:@"PictureTopCrop"];
3588 [preset setObject:[NSNumber numberWithInt:job->crop[1]] forKey:@"PictureBottomCrop"];
3589 [preset setObject:[NSNumber numberWithInt:job->crop[2]] forKey:@"PictureLeftCrop"];
3590 [preset setObject:[NSNumber numberWithInt:job->crop[3]] forKey:@"PictureRightCrop"];
3592 /* Picture Filters */
3593 [preset setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
3594 [preset setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
3595 [preset setObject:[NSNumber numberWithInt:[fPictureController vfr]] forKey:@"VFR"];
3596 [preset setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
3597 [preset setObject:[NSNumber numberWithInt:[fPictureController deblock]] forKey:@"PictureDeblock"];
3602 /* Audio Sample Rate*/
3603 [preset setObject:[fAudRatePopUp titleOfSelectedItem] forKey:@"AudioSampleRate"];
3604 /* Audio Bitrate Rate*/
3605 [preset setObject:[fAudBitratePopUp titleOfSelectedItem] forKey:@"AudioBitRate"];
3607 [preset setObject:[fSubPopUp titleOfSelectedItem] forKey:@"Subtitles"];
3610 [preset autorelease];
3617 [UserPresets writeToFile:UserPresetsFile atomically:YES];
3618 /* We get the default preset in case it changed */
3619 [self getDefaultPresets: NULL];
3623 - (IBAction)deletePreset:(id)sender
3626 NSEnumerator *enumerator;
3628 NSMutableArray *tempArray;
3631 if ( [tableView numberOfSelectedRows] == 0 )
3633 /* Alert user before deleting preset */
3634 /* Comment out for now, tie to user pref eventually */
3637 status = NSRunAlertPanel(@"Warning!", @"Are you sure that you want to delete the selected preset?", @"OK", @"Cancel", nil);
3639 if ( status == NSAlertDefaultReturn ) {
3640 enumerator = [tableView selectedRowEnumerator];
3641 tempArray = [NSMutableArray array];
3643 while ( (index = [enumerator nextObject]) ) {
3644 tempObject = [UserPresets objectAtIndex:[index intValue]];
3645 [tempArray addObject:tempObject];
3648 [UserPresets removeObjectsInArray:tempArray];
3649 [tableView reloadData];
3655 #pragma mark Manage Default Preset
3657 - (IBAction)getDefaultPresets:(id)sender
3660 NSEnumerator *enumerator = [UserPresets objectEnumerator];
3662 while (tempObject = [enumerator nextObject])
3664 NSDictionary *thisPresetDict = tempObject;
3665 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 1) // 1 is HB default
3667 presetHbDefault = i;
3669 if ([[thisPresetDict objectForKey:@"Default"] intValue] == 2) // 2 is User specified default
3671 presetUserDefault = i;
3677 - (IBAction)setDefaultPreset:(id)sender
3680 NSEnumerator *enumerator = [UserPresets objectEnumerator];
3682 /* First make sure the old user specified default preset is removed */
3683 while (tempObject = [enumerator nextObject])
3685 /* make sure we are not removing the default HB preset */
3686 if ([[[UserPresets objectAtIndex:i] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
3688 [[UserPresets objectAtIndex:i] setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3692 /* Second, go ahead and set the appropriate user specfied preset */
3693 /* we get the chosen preset from the UserPresets array */
3694 if ([[[UserPresets objectAtIndex:[tableView selectedRow]] objectForKey:@"Default"] intValue] != 1) // 1 is HB default
3696 [[UserPresets objectAtIndex:[tableView selectedRow]] setObject:[NSNumber numberWithInt:2] forKey:@"Default"];
3698 presetUserDefault = [tableView selectedRow];
3700 /* We save all of the preset data here */
3702 /* We Reload the New Table data for presets */
3703 [tableView reloadData];
3706 - (IBAction)selectDefaultPreset:(id)sender
3708 /* if there is a user specified default, we use it */
3709 if (presetUserDefault)
3711 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetUserDefault] byExtendingSelection:NO];
3712 [self tableViewSelected:NULL];
3714 else if (presetHbDefault) //else we use the built in default presetHbDefault
3716 [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:presetHbDefault] byExtendingSelection:NO];
3717 [self tableViewSelected:NULL];
3723 #pragma mark Manage Built In Presets
3726 - (IBAction)deleteFactoryPresets:(id)sender
3729 NSEnumerator *enumerator = [UserPresets objectEnumerator];
3733 NSMutableArray *tempArray;
3736 tempArray = [NSMutableArray array];
3737 /* we look here to see if the preset is we move on to the next one */
3738 while ( tempObject = [enumerator nextObject] )
3740 /* if the preset is "Factory" then we put it in the array of
3741 presets to delete */
3742 if ([[tempObject objectForKey:@"Type"] intValue] == 0)
3744 [tempArray addObject:tempObject];
3748 [UserPresets removeObjectsInArray:tempArray];
3749 [tableView reloadData];
3754 /* We use this method to recreate new, updated factory
3756 - (IBAction)addFactoryPresets:(id)sender
3758 /* First, we delete any existing built in presets */
3759 [self deleteFactoryPresets: sender];
3760 /* Then, we re-create new built in presets programmatically CreateIpodOnlyPreset*/
3761 [UserPresets addObject:[self createNormalPreset]];
3762 [UserPresets addObject:[self createClassicPreset]];
3763 [UserPresets addObject:[self createQuickTimePreset]];
3764 [UserPresets addObject:[self createIpodLowPreset]];
3765 [UserPresets addObject:[self createIpodHighPreset]];
3766 [UserPresets addObject:[self createAppleTVPreset]];
3767 [UserPresets addObject:[self createiPhonePreset]];
3768 [UserPresets addObject:[self createPSThreePreset]];
3769 [UserPresets addObject:[self createPSPPreset]];
3770 [UserPresets addObject:[self createFilmPreset]];
3771 [UserPresets addObject:[self createTelevisionPreset]];
3772 [UserPresets addObject:[self createAnimationPreset]];
3773 [UserPresets addObject:[self createBedlamPreset]];
3774 [UserPresets addObject:[self createDeuxSixQuatrePreset]];
3775 [UserPresets addObject:[self createBrokePreset]];
3776 [UserPresets addObject:[self createBlindPreset]];
3777 [UserPresets addObject:[self createCRFPreset]];
3783 #pragma mark Built In Preset Definitions
3784 /* These NSDictionary Buit In Preset definitions contain all of the settings for one built in preset */
3785 - (NSDictionary *)createIpodLowPreset
3787 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3788 /* Get the New Preset Name from the field in the AddPresetPanel */
3789 [preset setObject:@"iPod Low-Rez" forKey:@"PresetName"];
3790 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3791 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3792 /*Set whether or not this is default, at creation set to 0*/
3793 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3794 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3795 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3796 /* Get the New Preset Description from the field in the AddPresetPanel */
3797 [preset setObject:@"HandBrake's low resolution settings for the iPod. Optimized for great playback on the iPod screen, with smaller file size." forKey:@"PresetDescription"];
3799 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3800 /* Chapter Markers*/
3801 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3803 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3805 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3806 /* x264 Option String */
3807 [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"];
3809 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3810 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3811 [preset setObject:@"700" forKey:@"VideoAvgBitrate"];
3812 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3814 /* Video framerate */
3815 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3817 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3818 /* 2 Pass Encoding */
3819 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3821 /*Picture Settings*/
3822 //hb_job_t * job = fTitle->job;
3823 /* Basic Picture Settings */
3824 /* Use Max Picture settings for whatever the dvd is.*/
3825 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3826 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3827 [preset setObject:[NSNumber numberWithInt:320] forKey:@"PictureWidth"];
3828 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3829 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3830 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3831 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3832 /* Set crop settings here */
3833 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3834 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3835 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3836 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3837 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3840 /* Audio Sample Rate*/
3841 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3842 /* Audio Bitrate Rate*/
3843 [preset setObject:@"160" forKey:@"AudioBitRate"];
3845 [preset setObject:@"None" forKey:@"Subtitles"];
3848 [preset autorelease];
3854 - (NSDictionary *)createIpodHighPreset
3856 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3857 /* Get the New Preset Name from the field in the AddPresetPanel */
3858 [preset setObject:@"iPod High-Rez" forKey:@"PresetName"];
3859 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
3860 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3861 /*Set whether or not this is default, at creation set to 0*/
3862 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3863 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3864 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
3865 /* Get the New Preset Description from the field in the AddPresetPanel */
3866 [preset setObject:@"HandBrake's high resolution settings for the iPod. Good video quality, great for viewing on a TV using your iPod" forKey:@"PresetDescription"];
3868 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3869 /* Chapter Markers*/
3870 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3872 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3874 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
3875 /* x264 Option String */
3876 [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"];
3878 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3879 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3880 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
3881 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3883 /* Video framerate */
3884 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3886 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3887 /* 2 Pass Encoding */
3888 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3890 /*Picture Settings*/
3891 //hb_job_t * job = fTitle->job;
3892 /* Basic Picture Settings */
3893 /* Use Max Picture settings for whatever the dvd is.*/
3894 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
3895 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
3896 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3897 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
3898 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3899 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
3900 /* Set crop settings here */
3901 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3902 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
3903 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3904 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3905 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3906 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3909 /* Audio Sample Rate*/
3910 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3911 /* Audio Bitrate Rate*/
3912 [preset setObject:@"160" forKey:@"AudioBitRate"];
3914 [preset setObject:@"None" forKey:@"Subtitles"];
3917 [preset autorelease];
3922 - (NSDictionary *)createAppleTVPreset
3924 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3925 /* Get the New Preset Name from the field in the AddPresetPanel */
3926 [preset setObject:@"AppleTV" forKey:@"PresetName"];
3927 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
3928 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
3929 /*Set whether or not this is default, at creation set to 0*/
3930 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
3931 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
3932 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
3933 /* Get the New Preset Description from the field in the AddPresetPanel */
3934 [preset setObject:@"HandBrake's settings for the AppleTV. Provides a good balance between quality and file size, and optimizes performance." forKey:@"PresetDescription"];
3936 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
3937 /* Chapter Markers*/
3938 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
3940 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
3942 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
3943 /* x264 Option String (We can use this to tweak the appleTV output)*/
3944 [preset setObject:@"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2:cabac=0" forKey:@"x264Option"];
3946 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
3947 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
3948 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
3949 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
3951 /* Video framerate */
3952 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
3954 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
3955 /* 2 Pass Encoding */
3956 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
3958 /*Picture Settings*/
3959 /* For AppleTV we only want to retain UsesMaxPictureSettings
3960 which depend on the source dvd picture settings, so we don't
3961 record the current dvd's picture info since it will vary from
3963 //hb_job_t * job = fTitle->job;
3964 //hb_job_t * job = title->job;
3965 /* Basic Picture Settings */
3966 /* Use Max Picture settings for whatever the dvd is.*/
3967 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
3968 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
3969 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
3970 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
3971 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
3972 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
3973 /* Set crop settings here */
3974 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
3975 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
3976 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
3977 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
3978 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
3981 /* Audio Sample Rate*/
3982 [preset setObject:@"48" forKey:@"AudioSampleRate"];
3983 /* Audio Bitrate Rate*/
3984 [preset setObject:@"160" forKey:@"AudioBitRate"];
3986 [preset setObject:@"None" forKey:@"Subtitles"];
3989 [preset autorelease];
3994 - (NSDictionary *)createPSThreePreset
3996 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
3997 /* Get the New Preset Name from the field in the AddPresetPanel */
3998 [preset setObject:@"PS3" forKey:@"PresetName"];
3999 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
4000 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4001 /*Set whether or not this is default, at creation set to 0*/
4002 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4003 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4004 [preset setObject:[NSNumber numberWithInt:2] forKey:@"UsesPictureSettings"];
4005 /* Get the New Preset Description from the field in the AddPresetPanel */
4006 [preset setObject:@"HandBrake's settings for the Sony PlayStation 3." forKey:@"PresetDescription"];
4008 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4009 /* Chapter Markers*/
4010 [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
4012 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4014 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4015 /* x264 Option String (We can use this to tweak the appleTV output)*/
4016 [preset setObject:@"level=41:subme=5:me=umh" forKey:@"x264Option"];
4018 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4019 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4020 [preset setObject:@"2500" forKey:@"VideoAvgBitrate"];
4021 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4023 /* Video framerate */
4024 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4026 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4027 /* 2 Pass Encoding */
4028 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4030 /*Picture Settings*/
4031 /* For PS3 we only want to retain UsesMaxPictureSettings
4032 which depend on the source dvd picture settings, so we don't
4033 record the current dvd's picture info since it will vary from
4035 /* Use Max Picture settings for whatever the dvd is.*/
4036 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4037 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4038 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4039 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4040 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4041 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4042 /* Set crop settings here */
4043 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4044 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4045 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4046 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4047 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4050 /* Audio Sample Rate*/
4051 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4052 /* Audio Bitrate Rate*/
4053 [preset setObject:@"160" forKey:@"AudioBitRate"];
4055 [preset setObject:@"None" forKey:@"Subtitles"];
4058 [preset autorelease];
4062 - (NSDictionary *)createPSPPreset
4064 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4065 /* Get the New Preset Name from the field in the AddPresetPanel */
4066 [preset setObject:@"PSP" forKey:@"PresetName"];
4067 /*Set whether or not this is a user preset where 0 is factory, 1 is user*/
4068 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4069 /*Set whether or not this is default, at creation set to 0*/
4070 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4071 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4072 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4073 /* Get the New Preset Description from the field in the AddPresetPanel */
4074 [preset setObject:@"HandBrake's settings for the Sony PlayStation Portable." forKey:@"PresetDescription"];
4076 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4077 /* Chapter Markers*/
4078 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4080 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4082 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4083 /* x264 Option String (We can use this to tweak the appleTV output)*/
4084 [preset setObject:@"" forKey:@"x264Option"];
4086 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4087 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4088 [preset setObject:@"1024" forKey:@"VideoAvgBitrate"];
4089 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4091 /* Video framerate */
4092 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4094 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4095 /* 2 Pass Encoding */
4096 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4098 /*Picture Settings*/
4099 /* For PS3 we only want to retain UsesMaxPictureSettings
4100 which depend on the source dvd picture settings, so we don't
4101 record the current dvd's picture info since it will vary from
4103 /* Use Max Picture settings for whatever the dvd is.*/
4104 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4105 [preset setObject:@"368" forKey:@"PictureWidth"];
4106 [preset setObject:@"208" forKey:@"PictureHeight"];
4107 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4108 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4109 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4110 /* Set crop settings here */
4111 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4112 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4113 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4114 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4115 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4116 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4119 /* Audio Sample Rate*/
4120 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4121 /* Audio Bitrate Rate*/
4122 [preset setObject:@"128" forKey:@"AudioBitRate"];
4124 [preset setObject:@"None" forKey:@"Subtitles"];
4127 [preset autorelease];
4132 - (NSDictionary *)createNormalPreset
4134 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4135 /* Get the New Preset Name from the field in the AddPresetPanel */
4136 [preset setObject:@"Normal" forKey:@"PresetName"];
4137 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4138 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4139 /*Set whether or not this is default, at creation set to 0*/
4140 [preset setObject:[NSNumber numberWithInt:1] forKey:@"Default"];
4141 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4142 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4143 /* Get the New Preset Description from the field in the AddPresetPanel */
4144 [preset setObject:@"HandBrake's normal, default settings." forKey:@"PresetDescription"];
4146 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4147 /* Chapter Markers*/
4148 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4150 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4152 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4153 /* x264 Option String */
4154 [preset setObject:@"ref=2:bframes=2:subme=5:me=umh" forKey:@"x264Option"];
4156 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4157 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4158 [preset setObject:@"1500" forKey:@"VideoAvgBitrate"];
4159 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4161 /* Video framerate */
4162 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4164 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4165 /* 2 Pass Encoding */
4166 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4167 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4169 /*Picture Settings*/
4170 //hb_job_t * job = fTitle->job;
4171 /* Basic Picture Settings */
4172 /* Use Max Picture settings for whatever the dvd is.*/
4173 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4174 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4175 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4176 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4177 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4178 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4179 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4180 /* Set crop settings here */
4181 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4182 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4183 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4184 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4185 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4188 /* Audio Sample Rate*/
4189 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4190 /* Audio Bitrate Rate*/
4191 [preset setObject:@"160" forKey:@"AudioBitRate"];
4193 [preset setObject:@"None" forKey:@"Subtitles"];
4196 [preset autorelease];
4201 - (NSDictionary *)createClassicPreset
4203 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4204 /* Get the New Preset Name from the field in the AddPresetPanel */
4205 [preset setObject:@"Classic" forKey:@"PresetName"];
4206 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4207 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4208 /*Set whether or not this is default, at creation set to 0*/
4209 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4210 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4211 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4212 /* Get the New Preset Description from the field in the AddPresetPanel */
4213 [preset setObject:@"HandBrake's traditional, faster, lower-quality settings." forKey:@"PresetDescription"];
4215 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4216 /* Chapter Markers*/
4217 [preset setObject:[NSNumber numberWithInt:0] forKey:@"ChapterMarkers"];
4219 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4221 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4222 /* x264 Option String */
4223 [preset setObject:@"" forKey:@"x264Option"];
4225 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4226 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4227 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
4228 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4230 /* Video framerate */
4231 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4233 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4234 /* 2 Pass Encoding */
4235 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4237 /*Picture Settings*/
4238 //hb_job_t * job = fTitle->job;
4239 /* Basic Picture Settings */
4240 /* Use Max Picture settings for whatever the dvd is.*/
4241 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4242 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4243 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4244 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4245 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4246 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4247 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4248 /* Set crop settings here */
4249 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4250 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4251 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4252 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4253 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4256 /* Audio Sample Rate*/
4257 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4258 /* Audio Bitrate Rate*/
4259 [preset setObject:@"160" forKey:@"AudioBitRate"];
4261 [preset setObject:@"None" forKey:@"Subtitles"];
4264 [preset autorelease];
4269 - (NSDictionary *)createFilmPreset
4271 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4272 /* Get the New Preset Name from the field in the AddPresetPanel */
4273 [preset setObject:@"Film" forKey:@"PresetName"];
4274 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4275 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4276 /*Set whether or not this is default, at creation set to 0*/
4277 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4278 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4279 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4280 /* Get the New Preset Description from the field in the AddPresetPanel */
4281 [preset setObject:@"HandBrake's preset for feature films." forKey:@"PresetDescription"];
4283 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4284 /* Chapter Markers*/
4285 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4287 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4289 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4290 /* x264 Option String */
4291 [preset setObject:@"ref=3:mixed-refs:bframes=16:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:no-fast-pskip" forKey:@"x264Option"];
4293 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4294 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4295 [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
4296 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4298 /* Video framerate */
4299 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4301 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4302 /* 2 Pass Encoding */
4303 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4304 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4306 /*Picture Settings*/
4307 //hb_job_t * job = fTitle->job;
4308 /* Basic Picture Settings */
4309 /* Use Max Picture settings for whatever the dvd is.*/
4310 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4311 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4312 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4313 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4314 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4315 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4316 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4317 /* Set crop settings here */
4318 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4319 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4320 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4321 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4322 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4325 /* Audio Sample Rate*/
4326 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4327 /* Audio Bitrate Rate*/
4328 [preset setObject:@"160" forKey:@"AudioBitRate"];
4330 [preset setObject:@"None" forKey:@"Subtitles"];
4333 [preset autorelease];
4338 - (NSDictionary *)createTelevisionPreset
4340 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4341 /* Get the New Preset Name from the field in the AddPresetPanel */
4342 [preset setObject:@"Television" forKey:@"PresetName"];
4343 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4344 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4345 /*Set whether or not this is default, at creation set to 0*/
4346 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4347 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4348 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4349 /* Get the New Preset Description from the field in the AddPresetPanel */
4350 [preset setObject:@"HandBrake's settings for video from television." forKey:@"PresetDescription"];
4352 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4353 /* Chapter Markers*/
4354 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4356 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4358 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4359 /* x264 Option String */
4360 [preset setObject:@"ref=3:mixed-refs:bframes=16:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip" forKey:@"x264Option"];
4362 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4363 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4364 [preset setObject:@"1300" forKey:@"VideoAvgBitrate"];
4365 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4367 /* Video framerate */
4368 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4370 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4371 /* 2 Pass Encoding */
4372 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4373 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4375 /*Picture Settings*/
4376 //hb_job_t * job = fTitle->job;
4377 /* Basic Picture Settings */
4378 /* Use Max Picture settings for whatever the dvd is.*/
4379 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4380 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4381 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4382 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4383 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4384 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
4385 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4386 /* Set crop settings here */
4387 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4388 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4389 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4390 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4391 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4394 /* Audio Sample Rate*/
4395 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4396 /* Audio Bitrate Rate*/
4397 [preset setObject:@"160" forKey:@"AudioBitRate"];
4399 [preset setObject:@"None" forKey:@"Subtitles"];
4402 [preset autorelease];
4407 - (NSDictionary *)createAnimationPreset
4409 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4410 /* Get the New Preset Name from the field in the AddPresetPanel */
4411 [preset setObject:@"Animation" forKey:@"PresetName"];
4412 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4413 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4414 /*Set whether or not this is default, at creation set to 0*/
4415 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4416 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4417 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4418 /* Get the New Preset Description from the field in the AddPresetPanel */
4419 [preset setObject:@"HandBrake's settings for cartoons, anime, and CGI." forKey:@"PresetDescription"];
4421 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4422 /* Chapter Markers*/
4423 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4425 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4427 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4428 /* x264 Option String */
4429 [preset setObject:@"ref=5:mixed-refs:bframes=16: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"];
4431 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4432 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4433 [preset setObject:@"1000" forKey:@"VideoAvgBitrate"];
4434 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4436 /* Video framerate */
4437 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4439 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4440 /* 2 Pass Encoding */
4441 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4442 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4444 /*Picture Settings*/
4445 //hb_job_t * job = fTitle->job;
4446 /* Basic Picture Settings */
4447 /* Use Max Picture settings for whatever the dvd is.*/
4448 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4449 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4450 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4451 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4452 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4453 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureDeinterlace"];
4454 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4455 /* Set crop settings here */
4456 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4457 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4458 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4459 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4460 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4463 /* Audio Sample Rate*/
4464 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4465 /* Audio Bitrate Rate*/
4466 [preset setObject:@"160" forKey:@"AudioBitRate"];
4468 [preset setObject:@"None" forKey:@"Subtitles"];
4471 [preset autorelease];
4476 - (NSDictionary *)createQuickTimePreset
4478 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4479 /* Get the New Preset Name from the field in the AddPresetPanel */
4480 [preset setObject:@"QuickTime" forKey:@"PresetName"];
4481 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4482 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4483 /*Set whether or not this is default, at creation set to 0*/
4484 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4485 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4486 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4487 /* Get the New Preset Description from the field in the AddPresetPanel */
4488 [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"];
4490 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4491 /* Chapter Markers*/
4492 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4494 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4496 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4497 /* x264 Option String */
4498 [preset setObject:@"ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:me=umh:subme=5:analyse=all:trellis=1:no-fast-pskip" forKey:@"x264Option"];
4500 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4501 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4502 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4503 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4505 /* Video framerate */
4506 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4508 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4509 /* 2 Pass Encoding */
4510 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4511 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4513 /*Picture Settings*/
4514 //hb_job_t * job = fTitle->job;
4515 /* Basic Picture Settings */
4516 /* Use Max Picture settings for whatever the dvd is.*/
4517 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4518 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4519 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4520 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4521 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4522 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4523 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4524 /* Set crop settings here */
4525 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4526 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4527 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4528 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4529 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4532 /* Audio Sample Rate*/
4533 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4534 /* Audio Bitrate Rate*/
4535 [preset setObject:@"160" forKey:@"AudioBitRate"];
4537 [preset setObject:@"None" forKey:@"Subtitles"];
4540 [preset autorelease];
4545 - (NSDictionary *)createBedlamPreset
4547 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4548 /* Get the New Preset Name from the field in the AddPresetPanel */
4549 [preset setObject:@"Bedlam" forKey:@"PresetName"];
4550 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4551 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4552 /*Set whether or not this is default, at creation set to 0*/
4553 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4554 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4555 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4556 /* Get the New Preset Description from the field in the AddPresetPanel */
4557 [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"];
4559 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4560 /* Chapter Markers*/
4561 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4563 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4565 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4566 /* x264 Option String */
4567 [preset setObject:@"ref=16:mixed-refs:bframes=16: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"];
4569 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4570 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4571 [preset setObject:@"1800" forKey:@"VideoAvgBitrate"];
4572 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4574 /* Video framerate */
4575 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4577 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4578 /* 2 Pass Encoding */
4579 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4580 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4582 /*Picture Settings*/
4583 //hb_job_t * job = fTitle->job;
4584 /* Basic Picture Settings */
4585 /* Use Max Picture settings for whatever the dvd is.*/
4586 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4587 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4588 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4589 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4590 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4591 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4592 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4593 /* Set crop settings here */
4594 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4595 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4596 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4597 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4598 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4601 /* Audio Sample Rate*/
4602 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4603 /* Audio Bitrate Rate*/
4604 [preset setObject:@"160" forKey:@"AudioBitRate"];
4606 [preset setObject:@"None" forKey:@"Subtitles"];
4609 [preset autorelease];
4614 - (NSDictionary *)createiPhonePreset
4616 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4617 /* Get the New Preset Name from the field in the AddPresetPanel */
4618 [preset setObject:@"iPhone / iPod Touch" forKey:@"PresetName"];
4619 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4620 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4621 /*Set whether or not this is default, at creation set to 0*/
4622 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4623 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4624 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4625 /* Get the New Preset Description from the field in the AddPresetPanel */
4626 [preset setObject:@"HandBrake's settings for the iPhone." forKey:@"PresetDescription"];
4628 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4629 /* Chapter Markers*/
4630 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4632 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4634 [preset setObject:@"x264 (h.264 iPod)" forKey:@"VideoEncoder"];
4635 /* x264 Option String */
4636 [preset setObject:@"cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1" forKey:@"x264Option"];
4638 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4639 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4640 [preset setObject:@"960" forKey:@"VideoAvgBitrate"];
4641 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4643 /* Video framerate */
4644 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4646 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4647 /* 2 Pass Encoding */
4648 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4650 /*Picture Settings*/
4651 //hb_job_t * job = fTitle->job;
4652 /* Basic Picture Settings */
4653 /* Use Max Picture settings for whatever the dvd is.*/
4654 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4655 [preset setObject:[NSNumber numberWithInt:480] forKey:@"PictureWidth"];
4656 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4657 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4658 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4659 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4660 /* Set crop settings here */
4661 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4662 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4663 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4664 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4665 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4666 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4669 /* Audio Sample Rate*/
4670 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4671 /* Audio Bitrate Rate*/
4672 [preset setObject:@"128" forKey:@"AudioBitRate"];
4674 [preset setObject:@"None" forKey:@"Subtitles"];
4677 [preset autorelease];
4682 - (NSDictionary *)createDeuxSixQuatrePreset
4684 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4685 /* Get the New Preset Name from the field in the AddPresetPanel */
4686 [preset setObject:@"Deux Six Quatre" forKey:@"PresetName"];
4687 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4688 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4689 /*Set whether or not this is default, at creation set to 0*/
4690 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4691 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4692 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4693 /* Get the New Preset Description from the field in the AddPresetPanel */
4694 [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"];
4696 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4697 /* Chapter Markers*/
4698 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4700 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4702 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4703 /* x264 Option String */
4704 [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"];
4706 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4707 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4708 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
4709 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4711 /* Video framerate */
4712 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4714 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4715 /* 2 Pass Encoding */
4716 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4717 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4719 /*Picture Settings*/
4720 //hb_job_t * job = fTitle->job;
4721 /* Basic Picture Settings */
4722 /* Use Max Picture settings for whatever the dvd is.*/
4723 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4724 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4725 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4726 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4727 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4728 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4729 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4730 /* Set crop settings here */
4731 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4732 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4733 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4734 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4735 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4738 /* Audio Sample Rate*/
4739 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4740 /* Audio Bitrate Rate*/
4741 [preset setObject:@"160" forKey:@"AudioBitRate"];
4743 [preset setObject:@"None" forKey:@"Subtitles"];
4746 [preset autorelease];
4751 - (NSDictionary *)createBrokePreset
4753 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4754 /* Get the New Preset Name from the field in the AddPresetPanel */
4755 [preset setObject:@"Broke" forKey:@"PresetName"];
4756 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4757 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4758 /*Set whether or not this is default, at creation set to 0*/
4759 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4760 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4761 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4762 /* Get the New Preset Description from the field in the AddPresetPanel */
4763 [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"];
4765 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4766 /* Chapter Markers*/
4767 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4769 [preset setObject:@"AVC/H.264 Video / AAC Audio" forKey:@"FileCodecs"];
4771 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4772 /* x264 Option String */
4773 [preset setObject:@"ref=3:mixed-refs:bframes=16:bime:weightb:b-rdo:b-pyramid:direct=auto:me=umh:subme=6:trellis=1:analyse=all:8x8dct:no-fast-pskip" forKey:@"x264Option"];
4775 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoQualityType"];
4776 [preset setObject:@"695" forKey:@"VideoTargetSize"];
4777 [preset setObject:@"1600" forKey:@"VideoAvgBitrate"];
4778 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4780 /* Video framerate */
4781 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4783 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4784 /* 2 Pass Encoding */
4785 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTwoPass"];
4786 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoTurboTwoPass"];
4788 /*Picture Settings*/
4789 //hb_job_t * job = fTitle->job;
4790 /* Basic Picture Settings */
4791 /* Use Max Picture settings for whatever the dvd is.*/
4792 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4793 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4794 [preset setObject:[NSNumber numberWithInt:640] forKey:@"PictureWidth"];
4795 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4796 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4797 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4798 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4799 /* Set crop settings here */
4800 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4801 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4802 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4803 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4804 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4807 /* Audio Sample Rate*/
4808 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4809 /* Audio Bitrate Rate*/
4810 [preset setObject:@"128" forKey:@"AudioBitRate"];
4812 [preset setObject:@"None" forKey:@"Subtitles"];
4815 [preset autorelease];
4820 - (NSDictionary *)createBlindPreset
4822 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4823 /* Get the New Preset Name from the field in the AddPresetPanel */
4824 [preset setObject:@"Blind" forKey:@"PresetName"];
4825 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4826 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4827 /*Set whether or not this is default, at creation set to 0*/
4828 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4829 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4830 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4831 /* Get the New Preset Description from the field in the AddPresetPanel */
4832 [preset setObject:@"HandBrake's preset for impatient people who don't care about picture quality." forKey:@"PresetDescription"];
4834 [preset setObject:@"MP4 file" forKey:@"FileFormat"];
4835 /* Chapter Markers*/
4836 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4838 [preset setObject:@"MPEG-4 Video / AAC Audio" forKey:@"FileCodecs"];
4840 [preset setObject:@"FFmpeg" forKey:@"VideoEncoder"];
4841 /* x264 Option String */
4842 [preset setObject:@"" forKey:@"x264Option"];
4844 [preset setObject:[NSNumber numberWithInt:1] forKey:@"VideoQualityType"];
4845 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4846 [preset setObject:@"512" forKey:@"VideoAvgBitrate"];
4847 [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
4849 /* Video framerate */
4850 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4852 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4853 /* 2 Pass Encoding */
4854 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4855 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4857 /*Picture Settings*/
4858 //hb_job_t * job = fTitle->job;
4859 /* Basic Picture Settings */
4860 /* Use Max Picture settings for whatever the dvd is.*/
4861 [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
4862 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4863 [preset setObject:[NSNumber numberWithInt:512] forKey:@"PictureWidth"];
4864 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4865 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureKeepRatio"];
4866 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4867 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PicturePAR"];
4868 /* Set crop settings here */
4869 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4870 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4871 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4872 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4873 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4876 /* Audio Sample Rate*/
4877 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4878 /* Audio Bitrate Rate*/
4879 [preset setObject:@"128" forKey:@"AudioBitRate"];
4881 [preset setObject:@"None" forKey:@"Subtitles"];
4884 [preset autorelease];
4889 - (NSDictionary *)createCRFPreset
4891 NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
4892 /* Get the New Preset Name from the field in the AddPresetPanel */
4893 [preset setObject:@"Constant Quality Rate" forKey:@"PresetName"];
4894 /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
4895 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Type"];
4896 /*Set whether or not this is default, at creation set to 0*/
4897 [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
4898 /*Get the whether or not to apply pic settings in the AddPresetPanel*/
4899 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesPictureSettings"];
4900 /* Get the New Preset Description from the field in the AddPresetPanel */
4901 [preset setObject:@"HandBrake's preset for consistently excellent quality in one pass, with the downside of entirely unpredictable file sizes and bitrates." forKey:@"PresetDescription"];
4903 [preset setObject:@"MKV file" forKey:@"FileFormat"];
4904 /* Chapter Markers*/
4905 [preset setObject:[NSNumber numberWithInt:1] forKey:@"ChapterMarkers"];
4907 [preset setObject:@"AVC/H.264 Video / AC-3 Audio" forKey:@"FileCodecs"];
4909 [preset setObject:@"x264 (h.264 Main)" forKey:@"VideoEncoder"];
4910 /* x264 Option String */
4911 [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"];
4913 [preset setObject:[NSNumber numberWithInt:2] forKey:@"VideoQualityType"];
4914 [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
4915 [preset setObject:@"2000" forKey:@"VideoAvgBitrate"];
4916 [preset setObject:[NSNumber numberWithFloat:0.6471] forKey:@"VideoQualitySlider"];
4918 /* Video framerate */
4919 [preset setObject:@"Same as source" forKey:@"VideoFramerate"];
4921 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoGrayScale"];
4922 /* 2 Pass Encoding */
4923 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTwoPass"];
4924 [preset setObject:[NSNumber numberWithInt:0] forKey:@"VideoTurboTwoPass"];
4926 /*Picture Settings*/
4927 //hb_job_t * job = fTitle->job;
4928 /* Basic Picture Settings */
4929 /* Use Max Picture settings for whatever the dvd is.*/
4930 [preset setObject:[NSNumber numberWithInt:1] forKey:@"UsesMaxPictureSettings"];
4931 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PictureAutoCrop"];
4932 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureWidth"];
4933 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureHeight"];
4934 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureKeepRatio"];
4935 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureDeinterlace"];
4936 [preset setObject:[NSNumber numberWithInt:1] forKey:@"PicturePAR"];
4937 /* Set crop settings here */
4938 /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
4939 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureTopCrop"];
4940 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureBottomCrop"];
4941 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureLeftCrop"];
4942 [preset setObject:[NSNumber numberWithInt:0] forKey:@"PictureRightCrop"];
4945 /* Audio Sample Rate*/
4946 [preset setObject:@"48" forKey:@"AudioSampleRate"];
4947 /* Audio Bitrate Rate*/
4948 [preset setObject:@"160" forKey:@"AudioBitRate"];
4950 [preset setObject:@"None" forKey:@"Subtitles"];
4953 [preset autorelease];