- /*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;
- }
- }
+ NSMutableDictionary *preset = [[NSMutableDictionary alloc] init];
+ /* Get the New Preset Name from the field in the AddPresetPanel */
+ [preset setObject:[fPresetNewName stringValue] forKey:@"PresetName"];
+ /*Set whether or not this is a user preset or factory 0 is factory, 1 is user*/
+ [preset setObject:[NSNumber numberWithInt:1] forKey:@"Type"];
+ /*Set whether or not this is default, at creation set to 0*/
+ [preset setObject:[NSNumber numberWithInt:0] forKey:@"Default"];
+ /*Get the whether or not to apply pic settings in the AddPresetPanel*/
+ [preset setObject:[NSNumber numberWithInt:[fPresetNewPicSettingsPopUp indexOfSelectedItem]] forKey:@"UsesPictureSettings"];
+ /* Get New Preset Description from the field in the AddPresetPanel*/
+ [preset setObject:[fPresetNewDesc stringValue] forKey:@"PresetDescription"];
+ /* File Format */
+ [preset setObject:[fDstFormatPopUp titleOfSelectedItem] forKey:@"FileFormat"];
+ /* Chapter Markers fCreateChapterMarkers*/
+ [preset setObject:[NSNumber numberWithInt:[fCreateChapterMarkers state]] forKey:@"ChapterMarkers"];
+ /* Allow Mpeg4 64 bit formatting +4GB file sizes */
+ [preset setObject:[NSNumber numberWithInt:[fDstMpgLargeFileCheck state]] forKey:@"Mp4LargeFile"];
+ /* Codecs */
+ [preset setObject:[fDstCodecsPopUp titleOfSelectedItem] forKey:@"FileCodecs"];
+ /* Video encoder */
+ [preset setObject:[fVidEncoderPopUp titleOfSelectedItem] forKey:@"VideoEncoder"];
+ /* x264 Option String */
+ [preset setObject:[fAdvancedOptions optionsString] forKey:@"x264Option"];
+
+ [preset setObject:[NSNumber numberWithInt:[fVidQualityMatrix selectedRow]] forKey:@"VideoQualityType"];
+ [preset setObject:[fVidTargetSizeField stringValue] forKey:@"VideoTargetSize"];
+ [preset setObject:[fVidBitrateField stringValue] forKey:@"VideoAvgBitrate"];
+ [preset setObject:[NSNumber numberWithFloat:[fVidQualitySlider floatValue]] forKey:@"VideoQualitySlider"];
+
+ /* Video framerate */
+ [preset setObject:[fVidRatePopUp titleOfSelectedItem] forKey:@"VideoFramerate"];
+ /* GrayScale */
+ [preset setObject:[NSNumber numberWithInt:[fVidGrayscaleCheck state]] forKey:@"VideoGrayScale"];
+ /* 2 Pass Encoding */
+ [preset setObject:[NSNumber numberWithInt:[fVidTwoPassCheck state]] forKey:@"VideoTwoPass"];
+ /* Turbo 2 pass Encoding fVidTurboPassCheck*/
+ [preset setObject:[NSNumber numberWithInt:[fVidTurboPassCheck state]] forKey:@"VideoTurboTwoPass"];
+ /*Picture Settings*/
+ hb_job_t * job = fTitle->job;
+ /* Basic Picture Settings */
+ /* Use Max Picture settings for whatever the dvd is.*/
+ [preset setObject:[NSNumber numberWithInt:0] forKey:@"UsesMaxPictureSettings"];
+ [preset setObject:[NSNumber numberWithInt:fTitle->job->width] forKey:@"PictureWidth"];
+ [preset setObject:[NSNumber numberWithInt:fTitle->job->height] forKey:@"PictureHeight"];
+ [preset setObject:[NSNumber numberWithInt:fTitle->job->keep_ratio] forKey:@"PictureKeepRatio"];
+ [preset setObject:[NSNumber numberWithInt:[fPictureController deinterlace]] forKey:@"PictureDeinterlace"];
+ [preset setObject:[NSNumber numberWithInt:fTitle->job->pixel_ratio] forKey:@"PicturePAR"];
+ [preset setObject:[NSNumber numberWithInt:[fPictureController detelecine]] forKey:@"PictureDetelecine"];
+ [preset setObject:[NSNumber numberWithInt:[fPictureController denoise]] forKey:@"PictureDenoise"];
+ /* Set crop settings here */
+ /* The Auto Crop Matrix in the Picture Window autodetects differences in crop settings */
+ [preset setObject:[NSNumber numberWithInt:[fPictureController autoCrop]] forKey:@"PictureAutoCrop"];