diff options
Diffstat (limited to 'macosx/Controller.mm')
-rw-r--r-- | macosx/Controller.mm | 351 |
1 files changed, 344 insertions, 7 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 871dfae31..d17bcfbbc 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -1863,16 +1863,354 @@ the user is using "Custom" settings by determining the sender*/ /* Lets check to see there is a specified string in the prefs, and use that if need be */ if ([[NSUserDefaults standardUserDefaults] stringForKey:@"DefAdvancedx264Flags"] != @"") { - [fDisplayX264Options setStringValue: [NSString stringWithFormat:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefAdvancedx264Flags"]]]; + [fDisplayX264Options setStringValue: [NSString stringWithFormat:[[NSUserDefaults standardUserDefaults] stringForKey:@"DefAdvancedx264Flags"]]]; } } else { - /* Empty the field to display custom x264 preset options*/ - [fDisplayX264Options setStringValue: @""]; + /* Empty the field to display custom x264 preset options*/ + [fDisplayX264Options setStringValue: @""]; } } + [self X264AdvancedOptionsSet:NULL]; +} + +- (IBAction) X264AdvancedOptionsSet: (id) sender +{ + /*Set opt widget values here*/ + + /*B-Frames fX264optBframesPopUp*/ + int i; + [fX264optBframesPopUp removeAllItems]; + [fX264optBframesPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<17;i++) + { + [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Reference Frames fX264optRefPopUp*/ + [fX264optRefPopUp removeAllItems]; + [fX264optRefPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<17;i++) + { + [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*No Fast P-Skip fX264optNfpskipPopUp BOOLEAN*/ + [fX264optNfpskipPopUp removeAllItems]; + [fX264optNfpskipPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<2;i++) + { + if (i==0) + { + [fX264optNfpskipPopUp addItemWithTitle:[NSString stringWithFormat:@"No"]]; + } + else + { + [fX264optNfpskipPopUp addItemWithTitle:[NSString stringWithFormat:@"Yes"]]; + } + } + + /*No Dict Decimate fX264optNodctdcmtPopUp BOOLEAN*/ + [fX264optNodctdcmtPopUp removeAllItems]; + [fX264optNodctdcmtPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<2;i++) + { + if (i==0) + { + [fX264optNodctdcmtPopUp addItemWithTitle:[NSString stringWithFormat:@"No"]]; + } + else + { + [fX264optNodctdcmtPopUp addItemWithTitle:[NSString stringWithFormat:@"Yes"]]; + } + } + + /*Sub Me fX264optSubmePopUp*/ + [fX264optSubmePopUp removeAllItems]; + [fX264optSubmePopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<8;i++) + { + [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + + /*Trellis fX264optTrellisPopUp*/ + [fX264optTrellisPopUp removeAllItems]; + [fX264optTrellisPopUp addItemWithTitle:@"Unspecified"]; + for (i=0; i<3;i++) + { + [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]]; + } + /* 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"; + } + 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"]) + { + [fX264optNfpskipPopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*No Dict Decimate NSPopUpButton*/ + if ([optName isEqualToString:@"no-dct-decimate"]) + { + [fX264optNodctdcmtPopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*Sub Me NSPopUpButton*/ + if ([optName isEqualToString:@"subme"]) + { + [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1]; + } + /*Trellis NSPopUpButton*/ + if ([optName isEqualToString:@"trellis"]) + { + [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1]; + } + + } + } + } + +} + +- (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 == fX264optNfpskipPopUp) + { + optNameToChange = @"no-fast-pskip"; + } + if (sender == fX264optNodctdcmtPopUp) + { + optNameToChange = @"no-dct-decimate"; + } + if (sender == fX264optSubmePopUp) + { + optNameToChange = @"subme"; + } + if (sender == fX264optTrellisPopUp) + { + optNameToChange = @"trellis"; + } + /* 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 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 */ + + NSRange currentOptRange = [currentOptString rangeOfString:optNameToChange]; + if (currentOptRange.location != NSNotFound) + { + /* 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 ([sender indexOfSelectedItem] == 0) // means that "unspecified" is chosen, lets then remove it from the string + { + thisOpt = @""; + } + 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 + { + [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]; } @@ -2378,10 +2716,9 @@ 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 */ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefAdvancedx264FlagsShow"] > 0) - { - [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]]; - } + [fDisplayX264Options setStringValue: [NSString stringWithFormat:[chosenPreset valueForKey:@"x264Option"]]]; + + [self X264AdvancedOptionsSet:NULL]; /* Lets run through the following functions to get variables set there */ [self EncoderPopUpChanged: NULL]; |