diff options
author | ritsuka <[email protected]> | 2007-09-07 15:45:19 +0000 |
---|---|---|
committer | ritsuka <[email protected]> | 2007-09-07 15:45:19 +0000 |
commit | d42a0a339f8dc328a6fafbfdb9d04a2add90b0cd (patch) | |
tree | 2ae549be80e80bc02220e088544f5003bf38c935 | |
parent | 0d64d01626d4198ac9809a60a5fb673724b153d7 (diff) |
MacGui: Move x264 advanced options code to a new class (HBAdvancedController) and add a new nib to simplify future gui changes
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@934 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | macosx/Controller.h | 63 | ||||
-rw-r--r-- | macosx/Controller.mm | 1003 | ||||
-rw-r--r-- | macosx/English.lproj/AdvancedView.nib/classes.nib | 61 | ||||
-rw-r--r-- | macosx/English.lproj/AdvancedView.nib/info.nib | 28 | ||||
-rw-r--r-- | macosx/English.lproj/AdvancedView.nib/keyedobjects.nib | bin | 0 -> 36239 bytes | |||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 104 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/info.nib | 12 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/keyedobjects.nib | bin | 132148 -> 97622 bytes | |||
-rw-r--r-- | macosx/HBAdvancedController.h | 71 | ||||
-rw-r--r-- | macosx/HBAdvancedController.m | 1052 | ||||
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 34 |
11 files changed, 1332 insertions, 1096 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index dc797c35f..232551b8c 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -14,6 +14,8 @@ #include "PictureController.h" #include "HBQueueController.h" #import "MVMenuButton.h" +#import "HBAdvancedController.h" + @class HBOutputPanelController; @interface HBController : NSObject <GrowlApplicationBridgeDelegate> @@ -24,7 +26,7 @@ /* Picture panel */ IBOutlet PictureController * fPictureController; IBOutlet NSPanel * fPicturePanel; - + IBOutlet NSBox * fAdvancedView; /* Queue panel */ HBQueueController * fQueueController; IBOutlet NSTextField * fQueueStatus; @@ -46,8 +48,6 @@ /* Source box */ IBOutlet NSProgressIndicator * fScanIndicator; NSString * sourceDisplayName; - IBOutlet NSTextField * fScanStatus; - IBOutlet NSTextField * fSrcDVD1Field; IBOutlet NSTextField * fSrcDVD2Field; IBOutlet NSTextField * fSrcTitleField; IBOutlet NSPopUpButton * fSrcTitlePopUp; @@ -155,54 +155,7 @@ IBOutlet NSButton * fPictureButton; IBOutlet NSTextField * fStatusField; IBOutlet NSProgressIndicator * fRipIndicator; - IBOutlet NSButton * fShowQuButton; - IBOutlet NSButton * fAddToQuButton; - IBOutlet NSButton * fPauseButton; - IBOutlet NSButton * fRipButton; BOOL fRipIndicatorShown; - - /* Advanced Tab for opts fX264optView*/ - IBOutlet NSView * fX264optView; - IBOutlet NSTextField * fX264optViewTitleLabel; - IBOutlet NSTextField * fDisplayX264OptionsLabel; - IBOutlet NSTextField * fDisplayX264Options; - IBOutlet NSTextField * fX264optBframesLabel; - IBOutlet NSPopUpButton * fX264optBframesPopUp; - IBOutlet NSTextField * fX264optRefLabel; - IBOutlet NSPopUpButton * fX264optRefPopUp; - IBOutlet NSTextField * fX264optNfpskipLabel; - IBOutlet NSButton * fX264optNfpskipSwitch; - IBOutlet NSTextField * fX264optNodctdcmtLabel; - IBOutlet NSButton * fX264optNodctdcmtSwitch; - IBOutlet NSTextField * fX264optSubmeLabel; - IBOutlet NSPopUpButton * fX264optSubmePopUp; - IBOutlet NSTextField * fX264optTrellisLabel; - IBOutlet NSPopUpButton * fX264optTrellisPopUp; - IBOutlet NSTextField * fX264optMixedRefsLabel; - IBOutlet NSButton * fX264optMixedRefsSwitch; - IBOutlet NSTextField * fX264optMotionEstLabel; - IBOutlet NSPopUpButton * fX264optMotionEstPopUp; - IBOutlet NSTextField * fX264optMERangeLabel; - IBOutlet NSPopUpButton * fX264optMERangePopUp; - IBOutlet NSTextField * fX264optWeightBLabel; - IBOutlet NSButton * fX264optWeightBSwitch; - IBOutlet NSTextField * fX264optBRDOLabel; - IBOutlet NSButton * fX264optBRDOSwitch; - IBOutlet NSTextField * fX264optBPyramidLabel; - IBOutlet NSButton * fX264optBPyramidSwitch; - IBOutlet NSTextField * fX264optBiMELabel; - IBOutlet NSButton * fX264optBiMESwitch; - IBOutlet NSTextField * fX264optDirectPredLabel; - IBOutlet NSPopUpButton * fX264optDirectPredPopUp; - IBOutlet NSTextField * fX264optDeblockLabel; - IBOutlet NSPopUpButton * fX264optAlphaDeblockPopUp; - IBOutlet NSPopUpButton * fX264optBetaDeblockPopUp; - IBOutlet NSTextField * fX264optAnalyseLabel; - IBOutlet NSPopUpButton * fX264optAnalysePopUp; - IBOutlet NSTextField * fX264opt8x8dctLabel; - IBOutlet NSButton * fX264opt8x8dctSwitch; - IBOutlet NSTextField * fX264optCabacLabel; - IBOutlet NSButton * fX264optCabacSwitch; /* User Preset variables here */ @@ -238,6 +191,7 @@ int SuccessfulScan; NSString * currentSource; HBOutputPanelController *outputPanel; + HBAdvancedController *fAdvancedOptions; hb_job_t * fLastKnownCurrentJob; @@ -284,6 +238,8 @@ - (IBAction) addToQueue: (id) sender; - (IBAction) showQueueWindow:(id)sender; +- (IBAction)showPreferencesWindow:(id)sender; + - (IBAction) Rip: (id) sender; - (void) overWriteAlertDone: (NSWindow *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo; @@ -304,13 +260,6 @@ - (IBAction) openForums: (id) sender; - (IBAction) openUserGuide: (id) sender; -// x264 Advanced Panel Methods -- (IBAction) X264AdvancedOptionsSet: (id) sender; -- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender; -- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender; -- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString; -- (IBAction) X264AdvancedOptionsChanged: (id) sender; - // Preset Methods Here - (void) loadPresets; - (IBAction) customSettingUsed: (id) sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index a73b60719..dbfbf1c8a 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -81,6 +81,7 @@ static int hb_group_count(hb_handle_t * h) fHandle = NULL; outputPanel = [[HBOutputPanelController alloc] init]; fQueueController = [[HBQueueController alloc] init]; + fAdvancedOptions = [[HBAdvancedController alloc] init]; return self; } @@ -135,6 +136,7 @@ static int hb_group_count(hb_handle_t * h) /* Show scan panel ASAP */ [self performSelectorOnMainThread: @selector(showScanPanel:) withObject: NULL waitUntilDone: NO]; + } - (NSApplicationTerminateReply) applicationShouldTerminate: @@ -162,7 +164,7 @@ static int hb_group_count(hb_handle_t * h) { [fWindow center]; [fWindow setExcludedFromWindowsMenu:YES]; - + [fAdvancedOptions setView:fAdvancedView]; /* set the main menu bar so it doesnt auto enable the menu items so we can manually do it with setEnabled: This should be changed to use validateUserInterfaceItem: along with setAutoEnablesItems: YES @@ -311,7 +313,7 @@ static int hb_group_count(hb_handle_t * h) [self getDefaultPresets: NULL]; /* lets initialize the current successful scancount here to 0 */ currentSuccessfulScanCount = 0; - + } - (void) loadPresets { @@ -545,7 +547,6 @@ return registrationDictionary; } - (void) TranslateStrings { - [fSrcDVD1Field setStringValue: _( @"DVD:" )]; [fSrcTitleField setStringValue: _( @"Title:" )]; [fSrcChapterField setStringValue: _( @"Chapters:" )]; [fSrcChapterToField setStringValue: _( @"to" )]; @@ -1085,7 +1086,7 @@ list = hb_get_titles( fHandle ); - (void) enableUI: (bool) b { NSControl * controls[] = - { fSrcDVD1Field, fSrcTitleField, fSrcTitlePopUp, + { fSrcTitleField, fSrcTitlePopUp, fSrcChapterField, fSrcChapterStartPopUp, fSrcChapterToField, fSrcChapterEndPopUp, fSrcDuration1Field, fSrcDuration2Field, fDstFormatField, fDstFormatPopUp, fDstCodecsField, @@ -1103,16 +1104,7 @@ list = hb_get_titles( fHandle ); fPicLabelAr,fPicLabelDeinter,fPicLabelSrcX,fPicLabelOutputX, fPicLabelPAROutp,fPicLabelPAROutputX,fPicSettingPARWidth,fPicSettingPARHeight, fPicSettingPARDsply,fPicLabelAnamorphic,tableView,fPresetsAdd,fPresetsDelete, - fCreateChapterMarkers,fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel, - fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp,fX264optNfpskipLabel,fX264optNfpskipSwitch, - fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp, - fX264optTrellisLabel,fX264optTrellisPopUp,fX264optMixedRefsLabel,fX264optMixedRefsSwitch, - fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp, - fX264optWeightBLabel,fX264optWeightBSwitch,fX264optBRDOLabel,fX264optBRDOSwitch, - fX264optBPyramidLabel,fX264optBPyramidSwitch,fX264optBiMELabel,fX264optBiMESwitch, - fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel, - fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch, - fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp,fVidTurboPassCheck,fDstMpgLargeFileCheck,fPicSettingAutoCropLabel, + fCreateChapterMarkers,fVidTurboPassCheck,fDstMpgLargeFileCheck,fPicSettingAutoCropLabel, fPicSettingAutoCropDsply,fPicSettingDetelecine,fPicSettingDetelecineLabel,fPicSettingDenoiseLabel,fPicSettingDenoiseDsply,fSubForcedCheck,}; for( unsigned i = 0; @@ -1145,6 +1137,7 @@ list = hb_get_titles( fHandle ); } [self videoMatrixChanged: NULL]; + [fAdvancedOptions enableUI:b]; } - (IBAction) showScanPanel: (id) sender @@ -1426,12 +1419,12 @@ list = hb_get_titles( fHandle ); NSString *firstPassOptStringTurbo = @":ref=1:subme=1:me=dia:analyse=none:trellis=0:no-fast-pskip=0:8x8dct=0"; /* append the "Turbo" string variable to the existing opts string. Note: the "Turbo" string must be appended, not prepended to work properly*/ - NSString *firstPassOptStringCombined = [[fDisplayX264Options stringValue] stringByAppendingString:firstPassOptStringTurbo]; + NSString *firstPassOptStringCombined = [[fAdvancedOptions optionsString] stringByAppendingString:firstPassOptStringTurbo]; strcpy(job->x264opts, [firstPassOptStringCombined UTF8String]); } else { - strcpy(job->x264opts, [[fDisplayX264Options stringValue] UTF8String]); + strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]); } job->h264_13 = [fVidEncoderPopUp indexOfSelectedItem]; @@ -1650,7 +1643,7 @@ list = hb_get_titles( fHandle ); job->sequence_id++; // for job grouping job->x264opts = (char *)calloc(1024, 1); /* Fixme, this just leaks */ - strcpy(job->x264opts, [[fDisplayX264Options stringValue] UTF8String]); + strcpy(job->x264opts, [[fAdvancedOptions optionsString] UTF8String]); job->select_subtitle = subtitle_tmp; @@ -2065,9 +2058,8 @@ list = hb_get_titles( fHandle ); { int format = [fDstFormatPopUp indexOfSelectedItem]; int codecs = [fDstCodecsPopUp indexOfSelectedItem]; - [fX264optView setHidden: YES]; - [fX264optViewTitleLabel setStringValue: @"Only Used With The x264 (H.264) Codec"]; - + + [fAdvancedOptions setHidden:YES]; /* Update the encoder popup*/ if( ( FormatSettings[format][codecs] & HB_VCODEC_X264 ) ) @@ -2077,12 +2069,9 @@ list = hb_get_titles( fHandle ); [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 Main)"]; [fVidEncoderPopUp addItemWithTitle: @"x264 (h.264 iPod)"]; [fVidEncoderPopUp selectItemAtIndex: 0]; - [fX264optView setHidden: NO]; - [fX264optViewTitleLabel setStringValue: @""]; - - - + [fAdvancedOptions setHidden:NO]; } + else if( ( FormatSettings[format][codecs] & HB_VCODEC_FFMPEG ) ) { /* H.264 -> MPEG-4 */ @@ -2737,964 +2726,6 @@ the user is using "Custom" settings by determining the sender*/ } -- (IBAction) X264AdvancedOptionsSet: (id) sender -{ - /*Set opt widget values here*/ - - /*B-Frames fX264optBframesPopUp*/ - int i; - [fX264optBframesPopUp removeAllItems]; - [fX264optBframesPopUp addItemWithTitle:@"Default (0)"]; - for (i=0; i<17;i++) - { - [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /*Reference Frames fX264optRefPopUp*/ - [fX264optRefPopUp removeAllItems]; - [fX264optRefPopUp addItemWithTitle:@"Default (1)"]; - for (i=0; i<17;i++) - { - [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/ - [fX264optNfpskipSwitch setState:0]; - - /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/ - [fX264optNodctdcmtSwitch setState:0]; - - /*Sub Me fX264optSubmePopUp*/ - [fX264optSubmePopUp removeAllItems]; - [fX264optSubmePopUp addItemWithTitle:@"Default (4)"]; - for (i=0; i<8;i++) - { - [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /*Trellis fX264optTrellisPopUp*/ - [fX264optTrellisPopUp removeAllItems]; - [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"]; - for (i=0; i<3;i++) - { - [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/ - [fX264optMixedRefsSwitch setState:0]; - - /*Motion Estimation fX264optMotionEstPopUp*/ - [fX264optMotionEstPopUp removeAllItems]; - [fX264optMotionEstPopUp addItemWithTitle:@"Default (Hexagon)"]; - [fX264optMotionEstPopUp addItemWithTitle:@"Diamond"]; - [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"]; - [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"]; - [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"]; - - /*Motion Estimation range fX264optMERangePopUp*/ - [fX264optMERangePopUp removeAllItems]; - [fX264optMERangePopUp addItemWithTitle:@"Default (16)"]; - for (i=4; i<65;i++) - { - [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/ - [fX264optWeightBSwitch setState:0]; - - /*B-Frame Rate Distortion Optimization fX264optBRDOSwitch BOOLEAN*/ - [fX264optBRDOSwitch setState:0]; - - /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/ - [fX264optBPyramidSwitch setState:0]; - - /*Bidirectional Motion Estimation Refinement fX264optBiMESwitch BOOLEAN*/ - [fX264optBiMESwitch setState:0]; - - /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/ - [fX264optDirectPredPopUp removeAllItems]; - [fX264optDirectPredPopUp addItemWithTitle:@"Default (Spatial)"]; - [fX264optDirectPredPopUp addItemWithTitle:@"None"]; - [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"]; - [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"]; - [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"]; - - /*Alpha Deblock*/ - [fX264optAlphaDeblockPopUp removeAllItems]; - [fX264optAlphaDeblockPopUp addItemWithTitle:@"Default (0)"]; - for (i=-6; i<7;i++) - { - [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /*Beta Deblock*/ - [fX264optBetaDeblockPopUp removeAllItems]; - [fX264optBetaDeblockPopUp addItemWithTitle:@"Default (0)"]; - for (i=-6; i<7;i++) - { - [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; - } - - /* Analysis fX264optAnalysePopUp */ - [fX264optAnalysePopUp removeAllItems]; - [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */ - [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */ - [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */ - - /* 8x8 DCT fX264op8x8dctSwitch */ - [fX264opt8x8dctSwitch setState:0]; - - /* CABAC fX264opCabacSwitch */ - [fX264optCabacSwitch setState:1]; - - /* Standardize the option string */ - [self X264AdvancedOptionsStandardizeOptString: NULL]; - /* Set Current GUI Settings based on newly standardized string */ - [self X264AdvancedOptionsSetCurrentSettings: NULL]; -} - -- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender -{ - /* Set widgets depending on the opt string in field */ - NSString * thisOpt; // The separated option such as "bframes=3" - NSString * optName = @""; // The option name such as "bframes" - NSString * optValue = @"";// The option value such as "3" - NSString * changedOptString = @""; - NSArray *currentOptsArray; - - /*First, we get an opt string to process */ - NSString *currentOptString = [fDisplayX264Options stringValue]; - - /*verify there is an opt string to process */ - NSRange currentOptRange = [currentOptString rangeOfString:@"="]; - if (currentOptRange.location != NSNotFound) - { - /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/ - currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; - - /*iterate through the array and get <opts> and <values*/ - //NSEnumerator * enumerator = [currentOptsArray objectEnumerator]; - int loopcounter; - int currentOptsArrayCount = [currentOptsArray count]; - for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++) - { - thisOpt = [currentOptsArray objectAtIndex:loopcounter]; - - NSRange splitOptRange = [thisOpt rangeOfString:@"="]; - if (splitOptRange.location != NSNotFound) - { - optName = [thisOpt substringToIndex:splitOptRange.location]; - optValue = [thisOpt substringFromIndex:splitOptRange.location + 1]; - - /* Standardize the names here depending on whats in the string */ - optName = [self X264AdvancedOptionsStandardizeOptNames:optName]; - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue]; - } - else // No value given so we use a default of "1" - { - optName = thisOpt; - /* Standardize the names here depending on whats in the string */ - optName = [self X264AdvancedOptionsStandardizeOptNames:optName]; - thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1]; - } - - /* Construct New String for opts here */ - if ([thisOpt isEqualToString:@""]) - { - changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt]; - } - else - { - if ([changedOptString isEqualToString:@""]) - { - changedOptString = [NSString stringWithFormat:@"%@",thisOpt]; - } - else - { - changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt]; - } - } - } - } - - /* Change the option string to reflect the new standardized option string */ - [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]]; -} - -- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString -{ - if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"]) - { - cleanOptNameString = @"ref"; - } - - /*No Fast PSkip nofast_pskip*/ - if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"]) - { - cleanOptNameString = @"no-fast-pskip"; - } - - /*No Dict Decimate*/ - if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"]) - { - cleanOptNameString = @"no-dct-decimate"; - } - - /*Subme*/ - if ([cleanOptNameString isEqualToString:@"subme"]) - { - cleanOptNameString = @"subq"; - } - - /*ME Range*/ - if ([cleanOptNameString isEqualToString:@"me-range"] || [cleanOptNameString isEqualToString:@"me_range"]) - cleanOptNameString = @"merange"; - - /*WeightB*/ - if ([cleanOptNameString isEqualToString:@"weight-b"] || [cleanOptNameString isEqualToString:@"weight_b"]) - { - cleanOptNameString = @"weightb"; - } - - /*BRDO*/ - if ([cleanOptNameString isEqualToString:@"b-rdo"] || [cleanOptNameString isEqualToString:@"b_rdo"]) - { - cleanOptNameString = @"brdo"; - } - - /*B Pyramid*/ - if ([cleanOptNameString isEqualToString:@"b_pyramid"]) - { - cleanOptNameString = @"b-pyramid"; - } - - /*Direct Prediction*/ - if ([cleanOptNameString isEqualToString:@"direct-pred"] || [cleanOptNameString isEqualToString:@"direct_pred"]) - { - cleanOptNameString = @"direct"; - } - - /*Deblocking*/ - if ([cleanOptNameString isEqualToString:@"filter"]) - { - cleanOptNameString = @"deblock"; - } - - /*Analysis*/ - if ([cleanOptNameString isEqualToString:@"partitions"]) - { - cleanOptNameString = @"analyse"; - } - - - return cleanOptNameString; -} - -- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender -{ - /* Set widgets depending on the opt string in field */ - NSString * thisOpt; // The separated option such as "bframes=3" - NSString * optName = @""; // The option name such as "bframes" - NSString * optValue = @"";// The option value such as "3" - NSArray *currentOptsArray; - - /*First, we get an opt string to process */ - //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2"; - NSString *currentOptString = [fDisplayX264Options stringValue]; - - /*verify there is an opt string to process */ - NSRange currentOptRange = [currentOptString rangeOfString:@"="]; - if (currentOptRange.location != NSNotFound) - { - /* lets clean the opt string here to standardize any names*/ - /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/ - currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; - - /*iterate through the array and get <opts> and <values*/ - //NSEnumerator * enumerator = [currentOptsArray objectEnumerator]; - int loopcounter; - int currentOptsArrayCount = [currentOptsArray count]; - - /*iterate through the array and get <opts> and <values*/ - for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++) - { - thisOpt = [currentOptsArray objectAtIndex:loopcounter]; - NSRange splitOptRange = [thisOpt rangeOfString:@"="]; - - if (splitOptRange.location != NSNotFound) - { - optName = [thisOpt substringToIndex:splitOptRange.location]; - optValue = [thisOpt substringFromIndex:splitOptRange.location + 1]; - - /*Run through the available widgets for x264 opts and set them, as you add widgets, - they need to be added here. This should be moved to its own method probably*/ - - /*bframes NSPopUpButton*/ - if ([optName isEqualToString:@"bframes"]) - { - [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1]; - } - /*ref NSPopUpButton*/ - if ([optName isEqualToString:@"ref"]) - { - [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1]; - } - /*No Fast PSkip NSPopUpButton*/ - if ([optName isEqualToString:@"no-fast-pskip"]) - { - [fX264optNfpskipSwitch setState:[optValue intValue]]; - } - /*No Dict Decimate NSPopUpButton*/ - if ([optName isEqualToString:@"no-dct-decimate"]) - { - [fX264optNodctdcmtSwitch setState:[optValue intValue]]; - } - /*Sub Me NSPopUpButton*/ - if ([optName isEqualToString:@"subq"]) - { - [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1]; - } - /*Trellis NSPopUpButton*/ - if ([optName isEqualToString:@"trellis"]) - { - [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1]; - } - /*Mixed Refs NSButton*/ - if ([optName isEqualToString:@"mixed-refs"]) - { - [fX264optMixedRefsSwitch setState:[optValue intValue]]; - } - /*Motion Estimation NSPopUpButton*/ - if ([optName isEqualToString:@"me"]) - { - if ([optValue isEqualToString:@"dia"]) - [fX264optMotionEstPopUp selectItemAtIndex:1]; - else if ([optValue isEqualToString:@"hex"]) - [fX264optMotionEstPopUp selectItemAtIndex:2]; - else if ([optValue isEqualToString:@"umh"]) - [fX264optMotionEstPopUp selectItemAtIndex:3]; - else if ([optValue isEqualToString:@"esa"]) - [fX264optMotionEstPopUp selectItemAtIndex:4]; - } - /*ME Range NSPopUpButton*/ - if ([optName isEqualToString:@"merange"]) - { - [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3]; - } - /*Weighted B-Frames NSPopUpButton*/ - if ([optName isEqualToString:@"weightb"]) - { - [fX264optWeightBSwitch setState:[optValue intValue]]; - } - /*BRDO NSPopUpButton*/ - if ([optName isEqualToString:@"brdo"]) - { - [fX264optBRDOSwitch setState:[optValue intValue]]; - } - /*B Pyramid NSPopUpButton*/ - if ([optName isEqualToString:@"b-pyramid"]) - { - [fX264optBPyramidSwitch setState:[optValue intValue]]; - } - /*Bidirectional Motion Estimation Refinement NSPopUpButton*/ - if ([optName isEqualToString:@"bime"]) - { - [fX264optBiMESwitch setState:[optValue intValue]]; - } - /*Direct B-frame Prediction NSPopUpButton*/ - if ([optName isEqualToString:@"direct"]) - { - if ([optValue isEqualToString:@"none"]) - [fX264optDirectPredPopUp selectItemAtIndex:1]; - else if ([optValue isEqualToString:@"spatial"]) - [fX264optDirectPredPopUp selectItemAtIndex:2]; - else if ([optValue isEqualToString:@"temporal"]) - [fX264optDirectPredPopUp selectItemAtIndex:3]; - else if ([optValue isEqualToString:@"auto"]) - [fX264optDirectPredPopUp selectItemAtIndex:4]; - } - /*Deblocking NSPopUpButtons*/ - if ([optName isEqualToString:@"deblock"]) - { - NSString * alphaDeblock = @""; - NSString * betaDeblock = @""; - - NSRange splitDeblock = [optValue rangeOfString:@","]; - alphaDeblock = [optValue substringToIndex:splitDeblock.location]; - betaDeblock = [optValue substringFromIndex:splitDeblock.location + 1]; - - if ([alphaDeblock isEqualToString:@"0"] && [betaDeblock isEqualToString:@"0"]) - { - [fX264optAlphaDeblockPopUp selectItemAtIndex:0]; - [fX264optBetaDeblockPopUp selectItemAtIndex:0]; - } - else - { - if (![alphaDeblock isEqualToString:@"0"]) - { - [fX264optAlphaDeblockPopUp selectItemAtIndex:[alphaDeblock intValue]+7]; - } - else - { - [fX264optAlphaDeblockPopUp selectItemAtIndex:7]; - } - - if (![betaDeblock isEqualToString:@"0"]) - { - [fX264optBetaDeblockPopUp selectItemAtIndex:[betaDeblock intValue]+7]; - } - else - { - [fX264optBetaDeblockPopUp selectItemAtIndex:7]; - } - } - } - /* Analysis NSPopUpButton */ - if ([optName isEqualToString:@"analyse"]) - { - if ([optValue isEqualToString:@"p8x8,b8x8,i8x8,i4x4"]) - { - [fX264optAnalysePopUp selectItemAtIndex:0]; - } - if ([optValue isEqualToString:@"none"]) - { - [fX264optAnalysePopUp selectItemAtIndex:1]; - } - if ([optValue isEqualToString:@"all"]) - { - [fX264optAnalysePopUp selectItemAtIndex:2]; - } - } - /* 8x8 DCT NSButton */ - if ([optName isEqualToString:@"8x8dct"]) - { - [fX264opt8x8dctSwitch setState:[optValue intValue]]; - } - /* CABAC NSButton */ - if ([optName isEqualToString:@"cabac"]) - { - [fX264optCabacSwitch setState:[optValue intValue]]; - } - } - } - } -} - -- (IBAction) X264AdvancedOptionsChanged: (id) sender -{ - /*Determine which outlet is being used and set optName to process accordingly */ - NSString * optNameToChange = @""; // The option name such as "bframes" - - if (sender == fX264optBframesPopUp) - { - optNameToChange = @"bframes"; - } - if (sender == fX264optRefPopUp) - { - optNameToChange = @"ref"; - } - if (sender == fX264optNfpskipSwitch) - { - optNameToChange = @"no-fast-pskip"; - } - if (sender == fX264optNodctdcmtSwitch) - { - optNameToChange = @"no-dct-decimate"; - } - if (sender == fX264optSubmePopUp) - { - optNameToChange = @"subq"; - } - if (sender == fX264optTrellisPopUp) - { - optNameToChange = @"trellis"; - } - if (sender == fX264optMixedRefsSwitch) - { - optNameToChange = @"mixed-refs"; - } - if (sender == fX264optMotionEstPopUp) - { - optNameToChange = @"me"; - } - if (sender == fX264optMERangePopUp) - { - optNameToChange = @"merange"; - } - if (sender == fX264optWeightBSwitch) - { - optNameToChange = @"weightb"; - } - if (sender == fX264optBRDOSwitch) - { - optNameToChange = @"brdo"; - } - if (sender == fX264optBPyramidSwitch) - { - optNameToChange = @"b-pyramid"; - } - if (sender == fX264optBiMESwitch) - { - optNameToChange = @"bime"; - } - if (sender == fX264optDirectPredPopUp) - { - optNameToChange = @"direct"; - } - if (sender == fX264optAlphaDeblockPopUp) - { - optNameToChange = @"deblock"; - } - if (sender == fX264optBetaDeblockPopUp) - { - optNameToChange = @"deblock"; - } - if (sender == fX264optAnalysePopUp) - { - optNameToChange = @"analyse"; - } - if (sender == fX264opt8x8dctSwitch) - { - optNameToChange = @"8x8dct"; - } - if (sender == fX264optCabacSwitch) - { - optNameToChange = @"cabac"; - } - - /* Set widgets depending on the opt string in field */ - NSString * thisOpt; // The separated option such as "bframes=3" - NSString * optName = @""; // The option name such as "bframes" - NSString * optValue = @"";// The option value such as "3" - NSArray *currentOptsArray; - - /*First, we get an opt string to process */ - //EXAMPLE: NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2"; - NSString *currentOptString = [fDisplayX264Options stringValue]; - - /*verify there is an occurrence of the opt specified by the sender to change */ - /*take care of any multi-value opt names here. This is extremely kludgy, but test for functionality - and worry about pretty later */ - - /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after - the first character of the opt string (hence the ":") */ - NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange]; - NSRange currentOptRange = [currentOptString rangeOfString:checkOptNameToChange]; - /*Then we create a pattern to check for "<beginning of line>"optNameToChange"=" to modify the option to - see if the name falls at the beginning of the line, where we would not have the ":" as a pattern to test against*/ - NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange]; - NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning]; - if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0) - { - /* Create new empty opt string*/ - NSString *changedOptString = @""; - - /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/ - currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; - - /*iterate through the array and get <opts> and <values*/ - int loopcounter; - int currentOptsArrayCount = [currentOptsArray count]; - for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++) - { - thisOpt = [currentOptsArray objectAtIndex:loopcounter]; - NSRange splitOptRange = [thisOpt rangeOfString:@"="]; - - if (splitOptRange.location != NSNotFound) - { - optName = [thisOpt substringToIndex:splitOptRange.location]; - optValue = [thisOpt substringFromIndex:splitOptRange.location + 1]; - - /*Run through the available widgets for x264 opts and set them, as you add widgets, - they need to be added here. This should be moved to its own method probably*/ - - /*If the optNameToChange is found, appropriately change the value or delete it if - "Unspecified" is set.*/ - if ([optName isEqualToString:optNameToChange]) - { - if ([optNameToChange isEqualToString:@"deblock"]) - { - if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7))) - { - thisOpt = @""; - } - else - { - thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]; - } - } - else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) - { - if ([sender state] == 0) - { - thisOpt = @""; - } - else - { - thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1]; - } - } - else if ([optNameToChange isEqualToString:@"cabac"]) - { - if ([sender state] == 1) - { - thisOpt = @""; - } - else - { - thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0]; - } - } - else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string - { - thisOpt = @""; - } - else if ([optNameToChange isEqualToString:@"me"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"]; - break; - - case 2: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"]; - break; - - case 3: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"]; - break; - - case 4: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"direct"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"]; - break; - - case 2: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"]; - break; - - case 3: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"]; - break; - - case 4: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"analyse"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"]; - break; - - case 2: - thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"merange"]) - { - thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3]; - } - else // we have a valid value to change, so change it - { - thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1]; - } - } - } - - /* Construct New String for opts here */ - if ([thisOpt isEqualToString:@""]) - { - changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt]; - } - else - { - if ([changedOptString isEqualToString:@""]) - { - changedOptString = [NSString stringWithFormat:@"%@",thisOpt]; - } - else - { - changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt]; - } - } - } - - /* Change the option string to reflect the new mod settings */ - [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]]; - } - else // if none exists, add it to the string - { - if ([[fDisplayX264Options stringValue] isEqualToString: @""]) - { - if ([optNameToChange isEqualToString:@"me"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]]; - break; - - case 2: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]]; - break; - - case 3: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]]; - break; - - case 4: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"direct"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; - break; - - case 2: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]]; - break; - - case 3: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]]; - break; - - case 4: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"analyse"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; - break; - - case 2: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]]; - break; - - default: - break; - } - } - - else if ([optNameToChange isEqualToString:@"merange"]) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]]; - } - else if ([optNameToChange isEqualToString:@"deblock"]) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]]; - } - else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) { - if ([sender state] == 0) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]]; - } - else - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; - } - } - else if ([optNameToChange isEqualToString:@"cabac"]) - { - if ([sender state] == 1) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]]; - } - else - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; - } - } - else - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]]; - } - } - else - { - if ([optNameToChange isEqualToString:@"me"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]]; - break; - - case 2: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]]; - break; - - case 3: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]]; - break; - - case 4: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"direct"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; - break; - - case 2: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]]; - break; - - case 3: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]]; - break; - - case 4: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]]; - break; - - default: - break; - } - } - else if ([optNameToChange isEqualToString:@"analyse"]) - { - switch ([sender indexOfSelectedItem]) - { - case 1: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; - break; - - case 2: - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", - [NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]]; - break; - - default: - break; - } - } - - else if ([optNameToChange isEqualToString:@"merange"]) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]]; - } - else if ([optNameToChange isEqualToString:@"deblock"]) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", [NSString stringWithFormat:[fDisplayX264Options stringValue]], [NSString stringWithFormat:optNameToChange], [NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]]; - } - else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) - { - if ([sender state] == 0) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]]; - } - else - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; - } - } - else if ([optNameToChange isEqualToString:@"cabac"]) - { - if ([sender state] == 1) - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]]; - } - else - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; - } - } - else - { - [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], - [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]]; - } - } - } - - /* We now need to reset the opt widgets since we changed some stuff */ - [self X264AdvancedOptionsSet:NULL]; -} - - /* We use this method to recreate new, updated factory presets */ - (IBAction)addFactoryPresets:(id)sender @@ -3847,7 +2878,7 @@ the user is using "Custom" settings by determining the sender*/ /* Video encoder */ [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"]; /* x264 Option String */ - [preset setObject:[fDisplayX264Options stringValue] forKey:@"x264Option"]; + [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"]; [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"]; [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"]; @@ -5204,9 +4235,7 @@ the user is using "Custom" settings by determining the sender*/ /* We can show the preset options here in the gui if we want to so we check to see it the user has specified it in the prefs */ - [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]]; - - [self X264AdvancedOptionsSet:NULL]; + [fAdvancedOptions setOptions: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]]; /* Lets run through the following functions to get variables set there */ [self encoderPopUpChanged: NULL]; diff --git a/macosx/English.lproj/AdvancedView.nib/classes.nib b/macosx/English.lproj/AdvancedView.nib/classes.nib new file mode 100644 index 000000000..9ced59c01 --- /dev/null +++ b/macosx/English.lproj/AdvancedView.nib/classes.nib @@ -0,0 +1,61 @@ +{ + IBClasses = ( + {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, + { + ACTIONS = { + X264AdvancedOptionsChanged = id; + X264AdvancedOptionsSet = id; + X264AdvancedOptionsSetCurrentSettings = id; + X264AdvancedOptionsStandardizeOptString = id; + }; + CLASS = HBAdvancedController; + LANGUAGE = ObjC; + OUTLETS = { + fDisplayX264Options = NSTextField; + fDisplayX264OptionsLabel = NSTextField; + fEmptyView = NSView; + fX264opt8x8dctLabel = NSTextField; + fX264opt8x8dctSwitch = NSButton; + fX264optAlphaDeblockPopUp = NSPopUpButton; + fX264optAnalyseLabel = NSTextField; + fX264optAnalysePopUp = NSPopUpButton; + fX264optBPyramidLabel = NSTextField; + fX264optBPyramidSwitch = NSButton; + fX264optBRDOLabel = NSTextField; + fX264optBRDOSwitch = NSButton; + fX264optBetaDeblockPopUp = NSPopUpButton; + fX264optBframesLabel = NSTextField; + fX264optBframesPopUp = NSPopUpButton; + fX264optBiMELabel = NSTextField; + fX264optBiMESwitch = NSButton; + fX264optCabacLabel = NSTextField; + fX264optCabacSwitch = NSButton; + fX264optDeblockLabel = NSTextField; + fX264optDirectPredLabel = NSTextField; + fX264optDirectPredPopUp = NSPopUpButton; + fX264optMERangeLabel = NSTextField; + fX264optMERangePopUp = NSPopUpButton; + fX264optMixedRefsLabel = NSTextField; + fX264optMixedRefsSwitch = NSButton; + fX264optMotionEstLabel = NSTextField; + fX264optMotionEstPopUp = NSPopUpButton; + fX264optNfpskipLabel = NSTextField; + fX264optNfpskipSwitch = NSButton; + fX264optNodctdcmtLabel = NSTextField; + fX264optNodctdcmtSwitch = NSButton; + fX264optRefLabel = NSTextField; + fX264optRefPopUp = NSPopUpButton; + fX264optSubmeLabel = NSTextField; + fX264optSubmePopUp = NSPopUpButton; + fX264optTrellisLabel = NSTextField; + fX264optTrellisPopUp = NSPopUpButton; + fX264optView = NSView; + fX264optViewTitleLabel = NSTextField; + fX264optWeightBLabel = NSTextField; + fX264optWeightBSwitch = NSButton; + }; + SUPERCLASS = NSObject; + } + ); + IBVersion = 1; +}
\ No newline at end of file diff --git a/macosx/English.lproj/AdvancedView.nib/info.nib b/macosx/English.lproj/AdvancedView.nib/info.nib new file mode 100644 index 000000000..c21a0c3e6 --- /dev/null +++ b/macosx/English.lproj/AdvancedView.nib/info.nib @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>IBDocumentLocation</key> + <string>216 196 356 240 0 0 1440 878 </string> + <key>IBEditorPositions</key> + <dict> + <key>254</key> + <string>465 444 550 282 0 0 1440 878 </string> + <key>5</key> + <string>289 494 550 282 0 0 1440 878 </string> + </dict> + <key>IBFramework Version</key> + <string>446.1</string> + <key>IBLockedObjects</key> + <array> + <integer>5</integer> + <integer>254</integer> + </array> + <key>IBOpenObjects</key> + <array> + <integer>5</integer> + </array> + <key>IBSystem Version</key> + <string>8R2218</string> +</dict> +</plist> diff --git a/macosx/English.lproj/AdvancedView.nib/keyedobjects.nib b/macosx/English.lproj/AdvancedView.nib/keyedobjects.nib Binary files differnew file mode 100644 index 000000000..5fb13e9ae --- /dev/null +++ b/macosx/English.lproj/AdvancedView.nib/keyedobjects.nib diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib index c813db235..40dbb00e4 100644 --- a/macosx/English.lproj/MainMenu.nib/classes.nib +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -2,13 +2,63 @@ IBClasses = ( { ACTIONS = { - Cancel = id; - Pause = id; - Rip = id; X264AdvancedOptionsChanged = id; X264AdvancedOptionsSet = id; X264AdvancedOptionsSetCurrentSettings = id; X264AdvancedOptionsStandardizeOptString = id; + }; + CLASS = HBAdvancedController; + LANGUAGE = ObjC; + OUTLETS = { + fDisplayX264Options = NSTextField; + fDisplayX264OptionsLabel = NSTextField; + fX264opt8x8dctLabel = NSTextField; + fX264opt8x8dctSwitch = NSButton; + fX264optAlphaDeblockPopUp = NSPopUpButton; + fX264optAnalyseLabel = NSTextField; + fX264optAnalysePopUp = NSPopUpButton; + fX264optBPyramidLabel = NSTextField; + fX264optBPyramidSwitch = NSButton; + fX264optBRDOLabel = NSTextField; + fX264optBRDOSwitch = NSButton; + fX264optBetaDeblockPopUp = NSPopUpButton; + fX264optBframesLabel = NSTextField; + fX264optBframesPopUp = NSPopUpButton; + fX264optBiMELabel = NSTextField; + fX264optBiMESwitch = NSButton; + fX264optCabacLabel = NSTextField; + fX264optCabacSwitch = NSButton; + fX264optDeblockLabel = NSTextField; + fX264optDirectPredLabel = NSTextField; + fX264optDirectPredPopUp = NSPopUpButton; + fX264optMERangeLabel = NSTextField; + fX264optMERangePopUp = NSPopUpButton; + fX264optMixedRefsLabel = NSTextField; + fX264optMixedRefsSwitch = NSButton; + fX264optMotionEstLabel = NSTextField; + fX264optMotionEstPopUp = NSPopUpButton; + fX264optNfpskipLabel = NSTextField; + fX264optNfpskipSwitch = NSButton; + fX264optNodctdcmtLabel = NSTextField; + fX264optNodctdcmtSwitch = NSButton; + fX264optRefLabel = NSTextField; + fX264optRefPopUp = NSPopUpButton; + fX264optSubmeLabel = NSTextField; + fX264optSubmePopUp = NSPopUpButton; + fX264optTrellisLabel = NSTextField; + fX264optTrellisPopUp = NSPopUpButton; + fX264optView = NSView; + fX264optViewTitleLabel = NSTextField; + fX264optWeightBLabel = NSTextField; + fX264optWeightBSwitch = NSButton; + }; + SUPERCLASS = NSView; + }, + { + ACTIONS = { + Cancel = id; + Pause = id; + Rip = id; addAllAudioTracksToPopUp = id; addFactoryPresets = id; addToQueue = id; @@ -16,6 +66,7 @@ audioTrackMixdownChanged = id; audioTrackPopUpChanged = id; browseFile = id; + browseSources = id; calculateBitrate = id; calculatePictureSizing = id; chapterPopUpChanged = id; @@ -26,6 +77,7 @@ deletePreset = id; encoderPopUpChanged = id; formatPopUpChanged = id; + getDefaultPresets = id; insertPreset = id; openForums = id; openHomepage = id; @@ -55,6 +107,7 @@ LANGUAGE = ObjC; OUTLETS = { fAddPresetPanel = NSPanel; + fAdvancedView = NSBox; fAudBitrateField = NSTextField; fAudBitratePopUp = NSPopUpButton; fAudLang1Field = NSTextField; @@ -69,8 +122,6 @@ fAudTrack2MixPopUp = NSPopUpButton; fChapterTable = NSTableView; fCreateChapterMarkers = NSButton; - fDisplayX264Options = NSTextField; - fDisplayX264OptionsLabel = NSTextField; fDstBrowseButton = NSButton; fDstCodecsField = NSTextField; fDstCodecsPopUp = NSPopUpButton; @@ -133,15 +184,11 @@ fPresetsDelete = NSButton; fQueueStatus = NSTextField; fRipIndicator = NSProgressIndicator; - fScanController = ScanController; fScanIndicator = NSProgressIndicator; - fScanPanel = NSPanel; - fScanStatus = NSTextField; fSrcChapterEndPopUp = NSPopUpButton; fSrcChapterField = NSTextField; fSrcChapterStartPopUp = NSPopUpButton; fSrcChapterToField = NSTextField; - fSrcDVD1Field = NSTextField; fSrcDVD2Field = NSTextField; fSrcDuration1Field = NSTextField; fSrcDuration2Field = NSTextField; @@ -167,45 +214,6 @@ fVidTurboPassCheck = NSButton; fVidTwoPassCheck = NSButton; fWindow = NSWindow; - fX264opt8x8dctLabel = NSTextField; - fX264opt8x8dctSwitch = NSButton; - fX264optAlphaDeblockPopUp = NSPopUpButton; - fX264optAnalyseLabel = NSTextField; - fX264optAnalysePopUp = NSPopUpButton; - fX264optBPyramidLabel = NSTextField; - fX264optBPyramidSwitch = NSButton; - fX264optBRDOLabel = NSTextField; - fX264optBRDOSwitch = NSButton; - fX264optBetaDeblockPopUp = NSPopUpButton; - fX264optBframesLabel = NSTextField; - fX264optBframesPopUp = NSPopUpButton; - fX264optBiMELabel = NSTextField; - fX264optBiMESwitch = NSButton; - fX264optCabacLabel = NSTextField; - fX264optCabacSwitch = NSButton; - fX264optDeblockLabel = NSTextField; - fX264optDirectPredLabel = NSTextField; - fX264optDirectPredPopUp = NSPopUpButton; - fX264optMERangeLabel = NSTextField; - fX264optMERangePopUp = NSPopUpButton; - fX264optMixedRefsLabel = NSTextField; - fX264optMixedRefsSwitch = NSButton; - fX264optMotionEstLabel = NSTextField; - fX264optMotionEstPopUp = NSPopUpButton; - fX264optNfpskipLabel = NSTextField; - fX264optNfpskipSwitch = NSButton; - fX264optNodctdcmtLabel = NSTextField; - fX264optNodctdcmtSwitch = NSButton; - fX264optRefLabel = NSTextField; - fX264optRefPopUp = NSPopUpButton; - fX264optSubmeLabel = NSTextField; - fX264optSubmePopUp = NSPopUpButton; - fX264optTrellisLabel = NSTextField; - fX264optTrellisPopUp = NSPopUpButton; - fX264optView = NSView; - fX264optViewTitleLabel = NSTextField; - fX264optWeightBLabel = NSTextField; - fX264optWeightBSwitch = NSButton; tableView = NSTableView; }; SUPERCLASS = NSObject; diff --git a/macosx/English.lproj/MainMenu.nib/info.nib b/macosx/English.lproj/MainMenu.nib/info.nib index d9eb9f92d..532b25d26 100644 --- a/macosx/English.lproj/MainMenu.nib/info.nib +++ b/macosx/English.lproj/MainMenu.nib/info.nib @@ -3,15 +3,15 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>5 70 451 803 0 0 1440 878 </string> + <string>144 230 417 350 0 0 1440 878 </string> <key>IBEditorPositions</key> <dict> <key>1843</key> - <string>540 238 200 530 0 0 1280 778 </string> + <string>720 93 200 530 0 0 1440 878 </string> <key>2436</key> <string>307 361 192 68 0 0 1440 878 </string> <key>29</key> - <string>772 342 368 44 0 0 1680 1028 </string> + <string>790 391 368 44 0 0 1440 878 </string> </dict> <key>IBFramework Version</key> <string>446.1</string> @@ -25,6 +25,12 @@ </array> <key>IBOldestOS</key> <integer>4</integer> + <key>IBOpenObjects</key> + <array> + <integer>365</integer> + <integer>29</integer> + <integer>21</integer> + </array> <key>IBSystem Version</key> <string>8R2218</string> <key>IBUserGuides</key> diff --git a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib Binary files differindex acacaf066..5389ac3de 100644 --- a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib +++ b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib diff --git a/macosx/HBAdvancedController.h b/macosx/HBAdvancedController.h new file mode 100644 index 000000000..42fe5194a --- /dev/null +++ b/macosx/HBAdvancedController.h @@ -0,0 +1,71 @@ +/* HBAdvancedController + + This file is part of the HandBrake source code. + Homepage: <http://handbrake.m0k.org/>. + It may be used under the terms of the GNU General Public License. */ + +#import <Cocoa/Cocoa.h> + +@interface HBAdvancedController : NSObject +{ + /* Advanced Tab for opts fX264optView*/ + NSBox * fOptionsBox; + + IBOutlet NSView * fX264optView; + IBOutlet NSView * fEmptyView; + IBOutlet NSTextField * fX264optViewTitleLabel; + IBOutlet NSTextField * fDisplayX264OptionsLabel; + IBOutlet NSTextField * fDisplayX264Options; + IBOutlet NSTextField * fX264optBframesLabel; + IBOutlet NSPopUpButton * fX264optBframesPopUp; + IBOutlet NSTextField * fX264optRefLabel; + IBOutlet NSPopUpButton * fX264optRefPopUp; + IBOutlet NSTextField * fX264optNfpskipLabel; + IBOutlet NSButton * fX264optNfpskipSwitch; + IBOutlet NSTextField * fX264optNodctdcmtLabel; + IBOutlet NSButton * fX264optNodctdcmtSwitch; + IBOutlet NSTextField * fX264optSubmeLabel; + IBOutlet NSPopUpButton * fX264optSubmePopUp; + IBOutlet NSTextField * fX264optTrellisLabel; + IBOutlet NSPopUpButton * fX264optTrellisPopUp; + IBOutlet NSTextField * fX264optMixedRefsLabel; + IBOutlet NSButton * fX264optMixedRefsSwitch; + IBOutlet NSTextField * fX264optMotionEstLabel; + IBOutlet NSPopUpButton * fX264optMotionEstPopUp; + IBOutlet NSTextField * fX264optMERangeLabel; + IBOutlet NSPopUpButton * fX264optMERangePopUp; + IBOutlet NSTextField * fX264optWeightBLabel; + IBOutlet NSButton * fX264optWeightBSwitch; + IBOutlet NSTextField * fX264optBRDOLabel; + IBOutlet NSButton * fX264optBRDOSwitch; + IBOutlet NSTextField * fX264optBPyramidLabel; + IBOutlet NSButton * fX264optBPyramidSwitch; + IBOutlet NSTextField * fX264optBiMELabel; + IBOutlet NSButton * fX264optBiMESwitch; + IBOutlet NSTextField * fX264optDirectPredLabel; + IBOutlet NSPopUpButton * fX264optDirectPredPopUp; + IBOutlet NSTextField * fX264optDeblockLabel; + IBOutlet NSPopUpButton * fX264optAlphaDeblockPopUp; + IBOutlet NSPopUpButton * fX264optBetaDeblockPopUp; + IBOutlet NSTextField * fX264optAnalyseLabel; + IBOutlet NSPopUpButton * fX264optAnalysePopUp; + IBOutlet NSTextField * fX264opt8x8dctLabel; + IBOutlet NSButton * fX264opt8x8dctSwitch; + IBOutlet NSTextField * fX264optCabacLabel; + IBOutlet NSButton * fX264optCabacSwitch; +} + +// x264 Advanced Panel Methods +- (void) setView: (NSBox *) box; +- (BOOL) loadMyNibFile; +- (NSString *) optionsString; +- (void) setOptions: (NSString *)string; +- (void) enableUI: (bool) b; +- (void) setHidden: (BOOL) hide; +- (IBAction) X264AdvancedOptionsSet: (id) sender; +- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender; +- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender; +- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString; +- (IBAction) X264AdvancedOptionsChanged: (id) sender; + +@end diff --git a/macosx/HBAdvancedController.m b/macosx/HBAdvancedController.m new file mode 100644 index 000000000..dc92f957b --- /dev/null +++ b/macosx/HBAdvancedController.m @@ -0,0 +1,1052 @@ +/* HBAdvancedController + + This file is part of the HandBrake source code. + Homepage: <http://handbrake.m0k.org/>. + It may be used under the terms of the GNU General Public License. */ + +#import "HBAdvancedController.h" + +@implementation HBAdvancedController + +- (id)init +{ + [super init]; + [self loadMyNibFile]; + + return self; +} + +- (void) setView: (NSBox *) box { + fOptionsBox = box; + [fOptionsBox setContentView:fX264optView]; +} + +- (BOOL) loadMyNibFile +{ + if(![NSBundle loadNibNamed:@"AdvancedView" owner:self]) + { + NSLog(@"Warning! Could not load myNib file.\n"); + return NO; + } + + return YES; +} + +- (NSString *) optionsString { + return [fDisplayX264Options stringValue]; +} + +- (void) setOptions: (NSString *)string { + [fDisplayX264Options setStringValue:string]; + [self X264AdvancedOptionsSet:NULL]; +} + +- (void) setHidden: (BOOL) hide { + if(hide) + { + [fOptionsBox setContentView:fEmptyView]; + [fX264optViewTitleLabel setStringValue: @"Only Used With The x264 (H.264) Codec"]; + } + else + { + [fOptionsBox setContentView:fX264optView]; + [fX264optViewTitleLabel setStringValue: @""]; + } + return; +} + + - (void) enableUI: (bool) b +{ + unsigned i; + NSControl * controls[] = + { fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel, + fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp,fX264optNfpskipLabel,fX264optNfpskipSwitch, + fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp, + fX264optTrellisLabel,fX264optTrellisPopUp,fX264optMixedRefsLabel,fX264optMixedRefsSwitch, + fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp, + fX264optWeightBLabel,fX264optWeightBSwitch,fX264optBRDOLabel,fX264optBRDOSwitch, + fX264optBPyramidLabel,fX264optBPyramidSwitch,fX264optBiMELabel,fX264optBiMESwitch, + fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel, + fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch, + fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp}; + + for( i = 0; i < sizeof( controls ) / sizeof( NSControl * ); i++ ) + { + if( [[controls[i] className] isEqualToString: @"NSTextField"] ) + { + NSTextField * tf = (NSTextField *) controls[i]; + if( ![tf isBezeled] ) + { + [tf setTextColor: b ? [NSColor controlTextColor] : + [NSColor disabledControlTextColor]]; + continue; + } + } + [controls[i] setEnabled: b]; + + } +} + +- (void)dealloc +{ + [super dealloc]; +} + +- (IBAction) X264AdvancedOptionsSet: (id) sender +{ + /*Set opt widget values here*/ + + /*B-Frames fX264optBframesPopUp*/ + int i; + [fX264optBframesPopUp removeAllItems]; + [fX264optBframesPopUp addItemWithTitle:@"Default (0)"]; + for (i=0; i<17;i++) + { + [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Reference Frames fX264optRefPopUp*/ + [fX264optRefPopUp removeAllItems]; + [fX264optRefPopUp addItemWithTitle:@"Default (1)"]; + for (i=0; i<17;i++) + { + [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/ + [fX264optNfpskipSwitch setState:0]; + + /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/ + [fX264optNodctdcmtSwitch setState:0]; + + /*Sub Me fX264optSubmePopUp*/ + [fX264optSubmePopUp removeAllItems]; + [fX264optSubmePopUp addItemWithTitle:@"Default (4)"]; + for (i=0; i<8;i++) + { + [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Trellis fX264optTrellisPopUp*/ + [fX264optTrellisPopUp removeAllItems]; + [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"]; + for (i=0; i<3;i++) + { + [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/ + [fX264optMixedRefsSwitch setState:0]; + + /*Motion Estimation fX264optMotionEstPopUp*/ + [fX264optMotionEstPopUp removeAllItems]; + [fX264optMotionEstPopUp addItemWithTitle:@"Default (Hexagon)"]; + [fX264optMotionEstPopUp addItemWithTitle:@"Diamond"]; + [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"]; + [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"]; + [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"]; + + /*Motion Estimation range fX264optMERangePopUp*/ + [fX264optMERangePopUp removeAllItems]; + [fX264optMERangePopUp addItemWithTitle:@"Default (16)"]; + for (i=4; i<65;i++) + { + [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/ + [fX264optWeightBSwitch setState:0]; + + /*B-Frame Rate Distortion Optimization fX264optBRDOSwitch BOOLEAN*/ + [fX264optBRDOSwitch setState:0]; + + /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/ + [fX264optBPyramidSwitch setState:0]; + + /*Bidirectional Motion Estimation Refinement fX264optBiMESwitch BOOLEAN*/ + [fX264optBiMESwitch setState:0]; + + /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/ + [fX264optDirectPredPopUp removeAllItems]; + [fX264optDirectPredPopUp addItemWithTitle:@"Default (Spatial)"]; + [fX264optDirectPredPopUp addItemWithTitle:@"None"]; + [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"]; + [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"]; + [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"]; + + /*Alpha Deblock*/ + [fX264optAlphaDeblockPopUp removeAllItems]; + [fX264optAlphaDeblockPopUp addItemWithTitle:@"Default (0)"]; + for (i=-6; i<7;i++) + { + [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Beta Deblock*/ + [fX264optBetaDeblockPopUp removeAllItems]; + [fX264optBetaDeblockPopUp addItemWithTitle:@"Default (0)"]; + for (i=-6; i<7;i++) + { + [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /* Analysis fX264optAnalysePopUp */ + [fX264optAnalysePopUp removeAllItems]; + [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */ + [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */ + [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */ + + /* 8x8 DCT fX264op8x8dctSwitch */ + [fX264opt8x8dctSwitch setState:0]; + + /* CABAC fX264opCabacSwitch */ + [fX264optCabacSwitch setState:1]; + + /* Standardize the option string */ + [self X264AdvancedOptionsStandardizeOptString: NULL]; + /* Set Current GUI Settings based on newly standardized string */ + [self X264AdvancedOptionsSetCurrentSettings: NULL]; +} + +- (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender +{ + /* Set widgets depending on the opt string in field */ + NSString * thisOpt; // The separated option such as "bframes=3" + NSString * optName = @""; // The option name such as "bframes" + NSString * optValue = @"";// The option value such as "3" + NSString * changedOptString = @""; + NSArray *currentOptsArray; + + /*First, we get an opt string to process */ + NSString *currentOptString = [fDisplayX264Options stringValue]; + + /*verify there is an opt string to process */ + NSRange currentOptRange = [currentOptString rangeOfString:@"="]; + if (currentOptRange.location != NSNotFound) + { + /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/ + currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; + + /*iterate through the array and get <opts> and <values*/ + //NSEnumerator * enumerator = [currentOptsArray objectEnumerator]; + int loopcounter; + int currentOptsArrayCount = [currentOptsArray count]; + for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++) + { + thisOpt = [currentOptsArray objectAtIndex:loopcounter]; + + NSRange splitOptRange = [thisOpt rangeOfString:@"="]; + if (splitOptRange.location != NSNotFound) + { + optName = [thisOpt substringToIndex:splitOptRange.location]; + optValue = [thisOpt substringFromIndex:splitOptRange.location + 1]; + + /* Standardize the names here depending on whats in the string */ + optName = [self X264AdvancedOptionsStandardizeOptNames:optName]; + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue]; + } + else // No value given so we use a default of "1" + { + optName = thisOpt; + /* Standardize the names here depending on whats in the string */ + optName = [self X264AdvancedOptionsStandardizeOptNames:optName]; + thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1]; + } + + /* Construct New String for opts here */ + if ([thisOpt isEqualToString:@""]) + { + changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt]; + } + else + { + if ([changedOptString isEqualToString:@""]) + { + changedOptString = [NSString stringWithFormat:@"%@",thisOpt]; + } + else + { + changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt]; + } + } + } + } + + /* Change the option string to reflect the new standardized option string */ + [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]]; +} + +- (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString +{ + if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"]) + { + cleanOptNameString = @"ref"; + } + + /*No Fast PSkip nofast_pskip*/ + if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"]) + { + cleanOptNameString = @"no-fast-pskip"; + } + + /*No Dict Decimate*/ + if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"]) + { + cleanOptNameString = @"no-dct-decimate"; + } + + /*Subme*/ + if ([cleanOptNameString isEqualToString:@"subme"]) + { + cleanOptNameString = @"subq"; + } + + /*ME Range*/ + if ([cleanOptNameString isEqualToString:@"me-range"] || [cleanOptNameString isEqualToString:@"me_range"]) + cleanOptNameString = @"merange"; + + /*WeightB*/ + if ([cleanOptNameString isEqualToString:@"weight-b"] || [cleanOptNameString isEqualToString:@"weight_b"]) + { + cleanOptNameString = @"weightb"; + } + + /*BRDO*/ + if ([cleanOptNameString isEqualToString:@"b-rdo"] || [cleanOptNameString isEqualToString:@"b_rdo"]) + { + cleanOptNameString = @"brdo"; + } + + /*B Pyramid*/ + if ([cleanOptNameString isEqualToString:@"b_pyramid"]) + { + cleanOptNameString = @"b-pyramid"; + } + + /*Direct Prediction*/ + if ([cleanOptNameString isEqualToString:@"direct-pred"] || [cleanOptNameString isEqualToString:@"direct_pred"]) + { + cleanOptNameString = @"direct"; + } + + /*Deblocking*/ + if ([cleanOptNameString isEqualToString:@"filter"]) + { + cleanOptNameString = @"deblock"; + } + + /*Analysis*/ + if ([cleanOptNameString isEqualToString:@"partitions"]) + { + cleanOptNameString = @"analyse"; + } + + + return cleanOptNameString; +} + +- (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender +{ + /* Set widgets depending on the opt string in field */ + NSString * thisOpt; // The separated option such as "bframes=3" + NSString * optName = @""; // The option name such as "bframes" + NSString * optValue = @"";// The option value such as "3" + NSArray *currentOptsArray; + + /*First, we get an opt string to process */ + //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2"; + NSString *currentOptString = [fDisplayX264Options stringValue]; + + /*verify there is an opt string to process */ + NSRange currentOptRange = [currentOptString rangeOfString:@"="]; + if (currentOptRange.location != NSNotFound) + { + /* lets clean the opt string here to standardize any names*/ + /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/ + currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; + + /*iterate through the array and get <opts> and <values*/ + //NSEnumerator * enumerator = [currentOptsArray objectEnumerator]; + int loopcounter; + int currentOptsArrayCount = [currentOptsArray count]; + + /*iterate through the array and get <opts> and <values*/ + for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++) + { + thisOpt = [currentOptsArray objectAtIndex:loopcounter]; + NSRange splitOptRange = [thisOpt rangeOfString:@"="]; + + if (splitOptRange.location != NSNotFound) + { + optName = [thisOpt substringToIndex:splitOptRange.location]; + optValue = [thisOpt substringFromIndex:splitOptRange.location + 1]; + + /*Run through the available widgets for x264 opts and set them, as you add widgets, + they need to be added here. This should be moved to its own method probably*/ + + /*bframes NSPopUpButton*/ + if ([optName isEqualToString:@"bframes"]) + { + [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*ref NSPopUpButton*/ + if ([optName isEqualToString:@"ref"]) + { + [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*No Fast PSkip NSPopUpButton*/ + if ([optName isEqualToString:@"no-fast-pskip"]) + { + [fX264optNfpskipSwitch setState:[optValue intValue]]; + } + /*No Dict Decimate NSPopUpButton*/ + if ([optName isEqualToString:@"no-dct-decimate"]) + { + [fX264optNodctdcmtSwitch setState:[optValue intValue]]; + } + /*Sub Me NSPopUpButton*/ + if ([optName isEqualToString:@"subq"]) + { + [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*Trellis NSPopUpButton*/ + if ([optName isEqualToString:@"trellis"]) + { + [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*Mixed Refs NSButton*/ + if ([optName isEqualToString:@"mixed-refs"]) + { + [fX264optMixedRefsSwitch setState:[optValue intValue]]; + } + /*Motion Estimation NSPopUpButton*/ + if ([optName isEqualToString:@"me"]) + { + if ([optValue isEqualToString:@"dia"]) + [fX264optMotionEstPopUp selectItemAtIndex:1]; + else if ([optValue isEqualToString:@"hex"]) + [fX264optMotionEstPopUp selectItemAtIndex:2]; + else if ([optValue isEqualToString:@"umh"]) + [fX264optMotionEstPopUp selectItemAtIndex:3]; + else if ([optValue isEqualToString:@"esa"]) + [fX264optMotionEstPopUp selectItemAtIndex:4]; + } + /*ME Range NSPopUpButton*/ + if ([optName isEqualToString:@"merange"]) + { + [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3]; + } + /*Weighted B-Frames NSPopUpButton*/ + if ([optName isEqualToString:@"weightb"]) + { + [fX264optWeightBSwitch setState:[optValue intValue]]; + } + /*BRDO NSPopUpButton*/ + if ([optName isEqualToString:@"brdo"]) + { + [fX264optBRDOSwitch setState:[optValue intValue]]; + } + /*B Pyramid NSPopUpButton*/ + if ([optName isEqualToString:@"b-pyramid"]) + { + [fX264optBPyramidSwitch setState:[optValue intValue]]; + } + /*Bidirectional Motion Estimation Refinement NSPopUpButton*/ + if ([optName isEqualToString:@"bime"]) + { + [fX264optBiMESwitch setState:[optValue intValue]]; + } + /*Direct B-frame Prediction NSPopUpButton*/ + if ([optName isEqualToString:@"direct"]) + { + if ([optValue isEqualToString:@"none"]) + [fX264optDirectPredPopUp selectItemAtIndex:1]; + else if ([optValue isEqualToString:@"spatial"]) + [fX264optDirectPredPopUp selectItemAtIndex:2]; + else if ([optValue isEqualToString:@"temporal"]) + [fX264optDirectPredPopUp selectItemAtIndex:3]; + else if ([optValue isEqualToString:@"auto"]) + [fX264optDirectPredPopUp selectItemAtIndex:4]; + } + /*Deblocking NSPopUpButtons*/ + if ([optName isEqualToString:@"deblock"]) + { + NSString * alphaDeblock = @""; + NSString * betaDeblock = @""; + + NSRange splitDeblock = [optValue rangeOfString:@","]; + alphaDeblock = [optValue substringToIndex:splitDeblock.location]; + betaDeblock = [optValue substringFromIndex:splitDeblock.location + 1]; + + if ([alphaDeblock isEqualToString:@"0"] && [betaDeblock isEqualToString:@"0"]) + { + [fX264optAlphaDeblockPopUp selectItemAtIndex:0]; + [fX264optBetaDeblockPopUp selectItemAtIndex:0]; + } + else + { + if (![alphaDeblock isEqualToString:@"0"]) + { + [fX264optAlphaDeblockPopUp selectItemAtIndex:[alphaDeblock intValue]+7]; + } + else + { + [fX264optAlphaDeblockPopUp selectItemAtIndex:7]; + } + + if (![betaDeblock isEqualToString:@"0"]) + { + [fX264optBetaDeblockPopUp selectItemAtIndex:[betaDeblock intValue]+7]; + } + else + { + [fX264optBetaDeblockPopUp selectItemAtIndex:7]; + } + } + } + /* Analysis NSPopUpButton */ + if ([optName isEqualToString:@"analyse"]) + { + if ([optValue isEqualToString:@"p8x8,b8x8,i8x8,i4x4"]) + { + [fX264optAnalysePopUp selectItemAtIndex:0]; + } + if ([optValue isEqualToString:@"none"]) + { + [fX264optAnalysePopUp selectItemAtIndex:1]; + } + if ([optValue isEqualToString:@"all"]) + { + [fX264optAnalysePopUp selectItemAtIndex:2]; + } + } + /* 8x8 DCT NSButton */ + if ([optName isEqualToString:@"8x8dct"]) + { + [fX264opt8x8dctSwitch setState:[optValue intValue]]; + } + /* CABAC NSButton */ + if ([optName isEqualToString:@"cabac"]) + { + [fX264optCabacSwitch setState:[optValue intValue]]; + } + } + } + } +} + +- (IBAction) X264AdvancedOptionsChanged: (id) sender +{ + /*Determine which outlet is being used and set optName to process accordingly */ + NSString * optNameToChange = @""; // The option name such as "bframes" + + if (sender == fX264optBframesPopUp) + { + optNameToChange = @"bframes"; + } + if (sender == fX264optRefPopUp) + { + optNameToChange = @"ref"; + } + if (sender == fX264optNfpskipSwitch) + { + optNameToChange = @"no-fast-pskip"; + } + if (sender == fX264optNodctdcmtSwitch) + { + optNameToChange = @"no-dct-decimate"; + } + if (sender == fX264optSubmePopUp) + { + optNameToChange = @"subq"; + } + if (sender == fX264optTrellisPopUp) + { + optNameToChange = @"trellis"; + } + if (sender == fX264optMixedRefsSwitch) + { + optNameToChange = @"mixed-refs"; + } + if (sender == fX264optMotionEstPopUp) + { + optNameToChange = @"me"; + } + if (sender == fX264optMERangePopUp) + { + optNameToChange = @"merange"; + } + if (sender == fX264optWeightBSwitch) + { + optNameToChange = @"weightb"; + } + if (sender == fX264optBRDOSwitch) + { + optNameToChange = @"brdo"; + } + if (sender == fX264optBPyramidSwitch) + { + optNameToChange = @"b-pyramid"; + } + if (sender == fX264optBiMESwitch) + { + optNameToChange = @"bime"; + } + if (sender == fX264optDirectPredPopUp) + { + optNameToChange = @"direct"; + } + if (sender == fX264optAlphaDeblockPopUp) + { + optNameToChange = @"deblock"; + } + if (sender == fX264optBetaDeblockPopUp) + { + optNameToChange = @"deblock"; + } + if (sender == fX264optAnalysePopUp) + { + optNameToChange = @"analyse"; + } + if (sender == fX264opt8x8dctSwitch) + { + optNameToChange = @"8x8dct"; + } + if (sender == fX264optCabacSwitch) + { + optNameToChange = @"cabac"; + } + + /* Set widgets depending on the opt string in field */ + NSString * thisOpt; // The separated option such as "bframes=3" + NSString * optName = @""; // The option name such as "bframes" + NSString * optValue = @"";// The option value such as "3" + NSArray *currentOptsArray; + + /*First, we get an opt string to process */ + //EXAMPLE: NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2"; + NSString *currentOptString = [fDisplayX264Options stringValue]; + + /*verify there is an occurrence of the opt specified by the sender to change */ + /*take care of any multi-value opt names here. This is extremely kludgy, but test for functionality + and worry about pretty later */ + + /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after + the first character of the opt string (hence the ":") */ + NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange]; + NSRange currentOptRange = [currentOptString rangeOfString:checkOptNameToChange]; + /*Then we create a pattern to check for "<beginning of line>"optNameToChange"=" to modify the option to + see if the name falls at the beginning of the line, where we would not have the ":" as a pattern to test against*/ + NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange]; + NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning]; + if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0) + { + /* Create new empty opt string*/ + NSString *changedOptString = @""; + + /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/ + currentOptsArray = [currentOptString componentsSeparatedByString:@":"]; + + /*iterate through the array and get <opts> and <values*/ + int loopcounter; + int currentOptsArrayCount = [currentOptsArray count]; + for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++) + { + thisOpt = [currentOptsArray objectAtIndex:loopcounter]; + NSRange splitOptRange = [thisOpt rangeOfString:@"="]; + + if (splitOptRange.location != NSNotFound) + { + optName = [thisOpt substringToIndex:splitOptRange.location]; + optValue = [thisOpt substringFromIndex:splitOptRange.location + 1]; + + /*Run through the available widgets for x264 opts and set them, as you add widgets, + they need to be added here. This should be moved to its own method probably*/ + + /*If the optNameToChange is found, appropriately change the value or delete it if + "Unspecified" is set.*/ + if ([optName isEqualToString:optNameToChange]) + { + if ([optNameToChange isEqualToString:@"deblock"]) + { + if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7))) + { + thisOpt = @""; + } + else + { + thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]; + } + } + else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) + { + if ([sender state] == 0) + { + thisOpt = @""; + } + else + { + thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1]; + } + } + else if ([optNameToChange isEqualToString:@"cabac"]) + { + if ([sender state] == 1) + { + thisOpt = @""; + } + else + { + thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0]; + } + } + else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string + { + thisOpt = @""; + } + else if ([optNameToChange isEqualToString:@"me"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"]; + break; + + case 2: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"]; + break; + + case 3: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"]; + break; + + case 4: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"direct"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"]; + break; + + case 2: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"]; + break; + + case 3: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"]; + break; + + case 4: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"analyse"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"]; + break; + + case 2: + thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"merange"]) + { + thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3]; + } + else // we have a valid value to change, so change it + { + thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1]; + } + } + } + + /* Construct New String for opts here */ + if ([thisOpt isEqualToString:@""]) + { + changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt]; + } + else + { + if ([changedOptString isEqualToString:@""]) + { + changedOptString = [NSString stringWithFormat:@"%@",thisOpt]; + } + else + { + changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt]; + } + } + } + + /* Change the option string to reflect the new mod settings */ + [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]]; + } + else // if none exists, add it to the string + { + if ([[fDisplayX264Options stringValue] isEqualToString: @""]) + { + if ([optNameToChange isEqualToString:@"me"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]]; + break; + + case 2: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]]; + break; + + case 3: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]]; + break; + + case 4: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"direct"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; + break; + + case 2: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]]; + break; + + case 3: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]]; + break; + + case 4: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"analyse"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; + break; + + case 2: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]]; + break; + + default: + break; + } + } + + else if ([optNameToChange isEqualToString:@"merange"]) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]]; + } + else if ([optNameToChange isEqualToString:@"deblock"]) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]]; + } + else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) { + if ([sender state] == 0) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]]; + } + else + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; + } + } + else if ([optNameToChange isEqualToString:@"cabac"]) + { + if ([sender state] == 1) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]]; + } + else + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; + } + } + else + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@", + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]]; + } + } + else + { + if ([optNameToChange isEqualToString:@"me"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]]; + break; + + case 2: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]]; + break; + + case 3: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]]; + break; + + case 4: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"direct"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; + break; + + case 2: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]]; + break; + + case 3: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]]; + break; + + case 4: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]]; + break; + + default: + break; + } + } + else if ([optNameToChange isEqualToString:@"analyse"]) + { + switch ([sender indexOfSelectedItem]) + { + case 1: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]]; + break; + + case 2: + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", + [NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]]; + break; + + default: + break; + } + } + + else if ([optNameToChange isEqualToString:@"merange"]) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]]; + } + else if ([optNameToChange isEqualToString:@"deblock"]) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@", [NSString stringWithFormat:[fDisplayX264Options stringValue]], [NSString stringWithFormat:optNameToChange], [NSString stringWithFormat:@"%d,%d", ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0, ([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0]]]; + } + else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"brdo"] || [optNameToChange isEqualToString:@"bime"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] ) + { + if ([sender state] == 0) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]]; + } + else + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; + } + } + else if ([optNameToChange isEqualToString:@"cabac"]) + { + if ([sender state] == 1) + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]]; + } + else + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]]; + } + } + else + { + [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]], + [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]]; + } + } + } + + /* We now need to reset the opt widgets since we changed some stuff */ + [self X264AdvancedOptionsSet:NULL]; +} + +@end diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index 01e8ddaee..0ce0e89db 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -124,6 +124,10 @@ A2DFC66F0C6196D900E66E89 /* actionWidgetPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2DFC66D0C6196D900E66E89 /* actionWidgetPressed.png */; }; A2DFC6750C6197C600E66E89 /* MVMenuButton.h in Headers */ = {isa = PBXBuildFile; fileRef = A2DFC6740C6197C600E66E89 /* MVMenuButton.h */; }; A2DFC6770C61980700E66E89 /* MVMenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = A2DFC6760C61980700E66E89 /* MVMenuButton.m */; }; + A97A1DB40C91A6800015BC08 /* Express.nib in Resources */ = {isa = PBXBuildFile; fileRef = A97A1DB20C91A6800015BC08 /* Express.nib */; }; + A9AC41DF0C918DB500DDF9B8 /* HBAdvancedController.m in Sources */ = {isa = PBXBuildFile; fileRef = A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */; }; + A9AC41E00C918DB500DDF9B8 /* HBAdvancedController.h in Headers */ = {isa = PBXBuildFile; fileRef = A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */; }; + A9AC41E70C918DC000DDF9B8 /* AdvancedView.nib in Resources */ = {isa = PBXBuildFile; fileRef = A9AC41E50C918DC000DDF9B8 /* AdvancedView.nib */; }; B48359A80C82960500E04440 /* lang.c in Sources */ = {isa = PBXBuildFile; fileRef = B48359A70C82960500E04440 /* lang.c */; }; D4D49FED0C83355600F01215 /* lang.c in Sources */ = {isa = PBXBuildFile; fileRef = B48359A70C82960500E04440 /* lang.c */; }; E3003C7F0C88505D0072F2A8 /* DeleteHighlightPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = E3003C7E0C88505D0072F2A8 /* DeleteHighlightPressed.png */; }; @@ -194,7 +198,7 @@ /* Begin PBXFileReference section */ 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 0D096DFF0B707D1200A845D4 /* libhb.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libhb.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; - 0D6E35760B6BD4F0005AABB3 /* HandBrake.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HandBrake.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 0D6E35760B6BD4F0005AABB3 /* HandBrake.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = HandBrake.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0DF377970B7BF99A00115CB0 /* fakexcode.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = fakexcode.cpp; path = ../test/fakexcode.cpp; sourceTree = SOURCE_ROOT; }; 0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = HandBrake.icns; sourceTree = "<group>"; }; 0DFA5C7E0B8DD3B60020BC09 /* declpcm.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = declpcm.c; path = ../libhb/declpcm.c; sourceTree = SOURCE_ROOT; }; @@ -280,6 +284,10 @@ A2DFC66D0C6196D900E66E89 /* actionWidgetPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = actionWidgetPressed.png; sourceTree = "<group>"; }; A2DFC6740C6197C600E66E89 /* MVMenuButton.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = MVMenuButton.h; sourceTree = "<group>"; }; A2DFC6760C61980700E66E89 /* MVMenuButton.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = MVMenuButton.m; sourceTree = "<group>"; }; + A97A1DB30C91A6800015BC08 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/Express.nib; sourceTree = "<group>"; }; + A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = HBAdvancedController.m; sourceTree = "<group>"; }; + A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HBAdvancedController.h; sourceTree = "<group>"; }; + A9AC41E60C918DC000DDF9B8 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = English.lproj/AdvancedView.nib; sourceTree = "<group>"; }; B48359A70C82960500E04440 /* lang.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = lang.c; path = ../libhb/lang.c; sourceTree = SOURCE_ROOT; }; E3003C7E0C88505D0072F2A8 /* DeleteHighlightPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DeleteHighlightPressed.png; sourceTree = "<group>"; }; E3003CB40C8852B70072F2A8 /* DeletePressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DeletePressed.png; sourceTree = "<group>"; }; @@ -394,6 +402,8 @@ children = ( 0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */, 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, + A97A1DB20C91A6800015BC08 /* Express.nib */, + A9AC41E50C918DC000DDF9B8 /* AdvancedView.nib */, 2538860A0BFE0B730064E995 /* OutputPanel.nib */, 25DE1FAB0C1699E500F01FC8 /* Preferences.nib */, 4D1EA3000993B13700FDC1A2 /* Express.nib */, @@ -495,6 +505,8 @@ 25DE1FB50C169A0C00F01FC8 /* HBPreferencesController.m */, E37C89460C83989F00C1B919 /* HBQueueController.h */, E37C89450C83989F00C1B919 /* HBQueueController.mm */, + A9AC41DD0C918DB500DDF9B8 /* HBAdvancedController.m */, + A9AC41DE0C918DB500DDF9B8 /* HBAdvancedController.h */, ); name = "HandBrake Sources"; sourceTree = "<group>"; @@ -572,6 +584,7 @@ 253886170BFE0C160064E995 /* HBOutputPanelController.h in Headers */, 25DE1FB60C169A0C00F01FC8 /* HBPreferencesController.h in Headers */, E37C89480C83989F00C1B919 /* HBQueueController.h in Headers */, + A9AC41E00C918DB500DDF9B8 /* HBAdvancedController.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -732,6 +745,8 @@ E318F0470C90D6D3003EFB59 /* JobPassLarge.png in Resources */, E318F0580C90D88C003EFB59 /* JobPassSmall.png in Resources */, E318F0830C90DC4A003EFB59 /* Info.png in Resources */, + A9AC41E70C918DC000DDF9B8 /* AdvancedView.nib in Resources */, + A97A1DB40C91A6800015BC08 /* Express.nib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -861,6 +876,7 @@ 25DE1FB70C169A0C00F01FC8 /* HBPreferencesController.m in Sources */, A2DFC6770C61980700E66E89 /* MVMenuButton.m in Sources */, E37C89470C83989F00C1B919 /* HBQueueController.mm in Sources */, + A9AC41DF0C918DB500DDF9B8 /* HBAdvancedController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -917,6 +933,22 @@ name = MainMenu.nib; sourceTree = "<group>"; }; + A97A1DB20C91A6800015BC08 /* Express.nib */ = { + isa = PBXVariantGroup; + children = ( + A97A1DB30C91A6800015BC08 /* English */, + ); + name = Express.nib; + sourceTree = "<group>"; + }; + A9AC41E50C918DC000DDF9B8 /* AdvancedView.nib */ = { + isa = PBXVariantGroup; + children = ( + A9AC41E60C918DC000DDF9B8 /* English */, + ); + name = AdvancedView.nib; + sourceTree = "<group>"; + }; E37C894D0C8398CF00C1B919 /* Queue.nib */ = { isa = PBXVariantGroup; children = ( |