1 /* HBAdvancedController
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.m0k.org/>.
5 It may be used under the terms of the GNU General Public License. */
7 #import "HBAdvancedController.h"
9 @implementation HBAdvancedController
19 - (void) setView: (NSBox *) box {
21 [fOptionsBox setContentView:fX264optView];
24 - (BOOL) loadMyNibFile
26 if(![NSBundle loadNibNamed:@"AdvancedView" owner:self])
28 NSLog(@"Warning! Could not load myNib file.\n");
35 - (NSString *) optionsString {
36 return [fDisplayX264Options stringValue];
39 - (void) setOptions: (NSString *)string {
40 [fDisplayX264Options setStringValue:string];
41 [self X264AdvancedOptionsSet:NULL];
44 - (void) setHidden: (BOOL) hide {
47 [fOptionsBox setContentView:fEmptyView];
48 [fX264optViewTitleLabel setStringValue: @"Only Used With The x264 (H.264) Codec"];
52 [fOptionsBox setContentView:fX264optView];
53 [fX264optViewTitleLabel setStringValue: @""];
58 - (void) enableUI: (bool) b
61 NSControl * controls[] =
62 { fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel,
63 fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp,fX264optNfpskipLabel,fX264optNfpskipSwitch,
64 fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp,
65 fX264optTrellisLabel,fX264optTrellisPopUp,fX264optMixedRefsLabel,fX264optMixedRefsSwitch,
66 fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp,
67 fX264optWeightBLabel,fX264optWeightBSwitch,fX264optBRDOLabel,fX264optBRDOSwitch,
68 fX264optBPyramidLabel,fX264optBPyramidSwitch,fX264optBiMELabel,fX264optBiMESwitch,
69 fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel,
70 fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch,
71 fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp};
73 for( i = 0; i < sizeof( controls ) / sizeof( NSControl * ); i++ )
75 if( [[controls[i] className] isEqualToString: @"NSTextField"] )
77 NSTextField * tf = (NSTextField *) controls[i];
80 [tf setTextColor: b ? [NSColor controlTextColor] :
81 [NSColor disabledControlTextColor]];
85 [controls[i] setEnabled: b];
95 - (IBAction) X264AdvancedOptionsSet: (id) sender
97 /*Set opt widget values here*/
99 /*B-Frames fX264optBframesPopUp*/
101 [fX264optBframesPopUp removeAllItems];
102 [fX264optBframesPopUp addItemWithTitle:@"Default (0)"];
105 [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
108 /*Reference Frames fX264optRefPopUp*/
109 [fX264optRefPopUp removeAllItems];
110 [fX264optRefPopUp addItemWithTitle:@"Default (1)"];
113 [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
116 /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/
117 [fX264optNfpskipSwitch setState:0];
119 /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/
120 [fX264optNodctdcmtSwitch setState:0];
122 /*Sub Me fX264optSubmePopUp*/
123 [fX264optSubmePopUp removeAllItems];
124 [fX264optSubmePopUp addItemWithTitle:@"Default (4)"];
127 [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
130 /*Trellis fX264optTrellisPopUp*/
131 [fX264optTrellisPopUp removeAllItems];
132 [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"];
135 [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
138 /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/
139 [fX264optMixedRefsSwitch setState:0];
141 /*Motion Estimation fX264optMotionEstPopUp*/
142 [fX264optMotionEstPopUp removeAllItems];
143 [fX264optMotionEstPopUp addItemWithTitle:@"Default (Hexagon)"];
144 [fX264optMotionEstPopUp addItemWithTitle:@"Diamond"];
145 [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"];
146 [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"];
147 [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"];
149 /*Motion Estimation range fX264optMERangePopUp*/
150 [fX264optMERangePopUp removeAllItems];
151 [fX264optMERangePopUp addItemWithTitle:@"Default (16)"];
154 [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
157 /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/
158 [fX264optWeightBSwitch setState:0];
160 /*B-Frame Rate Distortion Optimization fX264optBRDOSwitch BOOLEAN*/
161 [fX264optBRDOSwitch setState:0];
163 /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/
164 [fX264optBPyramidSwitch setState:0];
166 /*Bidirectional Motion Estimation Refinement fX264optBiMESwitch BOOLEAN*/
167 [fX264optBiMESwitch setState:0];
169 /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/
170 [fX264optDirectPredPopUp removeAllItems];
171 [fX264optDirectPredPopUp addItemWithTitle:@"Default (Spatial)"];
172 [fX264optDirectPredPopUp addItemWithTitle:@"None"];
173 [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"];
174 [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"];
175 [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"];
178 [fX264optAlphaDeblockPopUp removeAllItems];
179 [fX264optAlphaDeblockPopUp addItemWithTitle:@"Default (0)"];
182 [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
186 [fX264optBetaDeblockPopUp removeAllItems];
187 [fX264optBetaDeblockPopUp addItemWithTitle:@"Default (0)"];
190 [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
193 /* Analysis fX264optAnalysePopUp */
194 [fX264optAnalysePopUp removeAllItems];
195 [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */
196 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */
197 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */
199 /* 8x8 DCT fX264op8x8dctSwitch */
200 [fX264opt8x8dctSwitch setState:0];
202 /* CABAC fX264opCabacSwitch */
203 [fX264optCabacSwitch setState:1];
205 /* Standardize the option string */
206 [self X264AdvancedOptionsStandardizeOptString: NULL];
207 /* Set Current GUI Settings based on newly standardized string */
208 [self X264AdvancedOptionsSetCurrentSettings: NULL];
211 - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender
213 /* Set widgets depending on the opt string in field */
214 NSString * thisOpt; // The separated option such as "bframes=3"
215 NSString * optName = @""; // The option name such as "bframes"
216 NSString * optValue = @"";// The option value such as "3"
217 NSString * changedOptString = @"";
218 NSArray *currentOptsArray;
220 /*First, we get an opt string to process */
221 NSString *currentOptString = [fDisplayX264Options stringValue];
223 /*verify there is an opt string to process */
224 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
225 if (currentOptRange.location != NSNotFound)
227 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
228 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
230 /*iterate through the array and get <opts> and <values*/
231 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
233 int currentOptsArrayCount = [currentOptsArray count];
234 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
236 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
238 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
239 if (splitOptRange.location != NSNotFound)
241 optName = [thisOpt substringToIndex:splitOptRange.location];
242 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
244 /* Standardize the names here depending on whats in the string */
245 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
246 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue];
248 else // No value given so we use a default of "1"
251 /* Standardize the names here depending on whats in the string */
252 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
253 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
256 /* Construct New String for opts here */
257 if ([thisOpt isEqualToString:@""])
259 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
263 if ([changedOptString isEqualToString:@""])
265 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
269 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
275 /* Change the option string to reflect the new standardized option string */
276 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
279 - (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString
281 if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"])
283 cleanOptNameString = @"ref";
286 /*No Fast PSkip nofast_pskip*/
287 if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"])
289 cleanOptNameString = @"no-fast-pskip";
293 if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"])
295 cleanOptNameString = @"no-dct-decimate";
299 if ([cleanOptNameString isEqualToString:@"subme"])
301 cleanOptNameString = @"subq";
305 if ([cleanOptNameString isEqualToString:@"me-range"] || [cleanOptNameString isEqualToString:@"me_range"])
306 cleanOptNameString = @"merange";
309 if ([cleanOptNameString isEqualToString:@"weight-b"] || [cleanOptNameString isEqualToString:@"weight_b"])
311 cleanOptNameString = @"weightb";
315 if ([cleanOptNameString isEqualToString:@"b-rdo"] || [cleanOptNameString isEqualToString:@"b_rdo"])
317 cleanOptNameString = @"brdo";
321 if ([cleanOptNameString isEqualToString:@"b_pyramid"])
323 cleanOptNameString = @"b-pyramid";
326 /*Direct Prediction*/
327 if ([cleanOptNameString isEqualToString:@"direct-pred"] || [cleanOptNameString isEqualToString:@"direct_pred"])
329 cleanOptNameString = @"direct";
333 if ([cleanOptNameString isEqualToString:@"filter"])
335 cleanOptNameString = @"deblock";
339 if ([cleanOptNameString isEqualToString:@"partitions"])
341 cleanOptNameString = @"analyse";
345 return cleanOptNameString;
348 - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender
350 /* Set widgets depending on the opt string in field */
351 NSString * thisOpt; // The separated option such as "bframes=3"
352 NSString * optName = @""; // The option name such as "bframes"
353 NSString * optValue = @"";// The option value such as "3"
354 NSArray *currentOptsArray;
356 /*First, we get an opt string to process */
357 //NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
358 NSString *currentOptString = [fDisplayX264Options stringValue];
360 /*verify there is an opt string to process */
361 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
362 if (currentOptRange.location != NSNotFound)
364 /* lets clean the opt string here to standardize any names*/
365 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
366 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
368 /*iterate through the array and get <opts> and <values*/
369 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
371 int currentOptsArrayCount = [currentOptsArray count];
373 /*iterate through the array and get <opts> and <values*/
374 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
376 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
377 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
379 if (splitOptRange.location != NSNotFound)
381 optName = [thisOpt substringToIndex:splitOptRange.location];
382 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
384 /*Run through the available widgets for x264 opts and set them, as you add widgets,
385 they need to be added here. This should be moved to its own method probably*/
387 /*bframes NSPopUpButton*/
388 if ([optName isEqualToString:@"bframes"])
390 [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1];
392 /*ref NSPopUpButton*/
393 if ([optName isEqualToString:@"ref"])
395 [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1];
397 /*No Fast PSkip NSPopUpButton*/
398 if ([optName isEqualToString:@"no-fast-pskip"])
400 [fX264optNfpskipSwitch setState:[optValue intValue]];
402 /*No Dict Decimate NSPopUpButton*/
403 if ([optName isEqualToString:@"no-dct-decimate"])
405 [fX264optNodctdcmtSwitch setState:[optValue intValue]];
407 /*Sub Me NSPopUpButton*/
408 if ([optName isEqualToString:@"subq"])
410 [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1];
412 /*Trellis NSPopUpButton*/
413 if ([optName isEqualToString:@"trellis"])
415 [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1];
417 /*Mixed Refs NSButton*/
418 if ([optName isEqualToString:@"mixed-refs"])
420 [fX264optMixedRefsSwitch setState:[optValue intValue]];
422 /*Motion Estimation NSPopUpButton*/
423 if ([optName isEqualToString:@"me"])
425 if ([optValue isEqualToString:@"dia"])
426 [fX264optMotionEstPopUp selectItemAtIndex:1];
427 else if ([optValue isEqualToString:@"hex"])
428 [fX264optMotionEstPopUp selectItemAtIndex:2];
429 else if ([optValue isEqualToString:@"umh"])
430 [fX264optMotionEstPopUp selectItemAtIndex:3];
431 else if ([optValue isEqualToString:@"esa"])
432 [fX264optMotionEstPopUp selectItemAtIndex:4];
434 /*ME Range NSPopUpButton*/
435 if ([optName isEqualToString:@"merange"])
437 [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3];
439 /*Weighted B-Frames NSPopUpButton*/
440 if ([optName isEqualToString:@"weightb"])
442 [fX264optWeightBSwitch setState:[optValue intValue]];
444 /*BRDO NSPopUpButton*/
445 if ([optName isEqualToString:@"brdo"])
447 [fX264optBRDOSwitch setState:[optValue intValue]];
449 /*B Pyramid NSPopUpButton*/
450 if ([optName isEqualToString:@"b-pyramid"])
452 [fX264optBPyramidSwitch setState:[optValue intValue]];
454 /*Bidirectional Motion Estimation Refinement NSPopUpButton*/
455 if ([optName isEqualToString:@"bime"])
457 [fX264optBiMESwitch setState:[optValue intValue]];
459 /*Direct B-frame Prediction NSPopUpButton*/
460 if ([optName isEqualToString:@"direct"])
462 if ([optValue isEqualToString:@"none"])
463 [fX264optDirectPredPopUp selectItemAtIndex:1];
464 else if ([optValue isEqualToString:@"spatial"])
465 [fX264optDirectPredPopUp selectItemAtIndex:2];
466 else if ([optValue isEqualToString:@"temporal"])
467 [fX264optDirectPredPopUp selectItemAtIndex:3];
468 else if ([optValue isEqualToString:@"auto"])
469 [fX264optDirectPredPopUp selectItemAtIndex:4];
471 /*Deblocking NSPopUpButtons*/
472 if ([optName isEqualToString:@"deblock"])
474 NSString * alphaDeblock = @"";
475 NSString * betaDeblock = @"";
477 NSRange splitDeblock = [optValue rangeOfString:@","];
478 alphaDeblock = [optValue substringToIndex:splitDeblock.location];
479 betaDeblock = [optValue substringFromIndex:splitDeblock.location + 1];
481 if ([alphaDeblock isEqualToString:@"0"] && [betaDeblock isEqualToString:@"0"])
483 [fX264optAlphaDeblockPopUp selectItemAtIndex:0];
484 [fX264optBetaDeblockPopUp selectItemAtIndex:0];
488 if (![alphaDeblock isEqualToString:@"0"])
490 [fX264optAlphaDeblockPopUp selectItemAtIndex:[alphaDeblock intValue]+7];
494 [fX264optAlphaDeblockPopUp selectItemAtIndex:7];
497 if (![betaDeblock isEqualToString:@"0"])
499 [fX264optBetaDeblockPopUp selectItemAtIndex:[betaDeblock intValue]+7];
503 [fX264optBetaDeblockPopUp selectItemAtIndex:7];
507 /* Analysis NSPopUpButton */
508 if ([optName isEqualToString:@"analyse"])
510 if ([optValue isEqualToString:@"p8x8,b8x8,i8x8,i4x4"])
512 [fX264optAnalysePopUp selectItemAtIndex:0];
514 if ([optValue isEqualToString:@"none"])
516 [fX264optAnalysePopUp selectItemAtIndex:1];
518 if ([optValue isEqualToString:@"all"])
520 [fX264optAnalysePopUp selectItemAtIndex:2];
523 /* 8x8 DCT NSButton */
524 if ([optName isEqualToString:@"8x8dct"])
526 [fX264opt8x8dctSwitch setState:[optValue intValue]];
529 if ([optName isEqualToString:@"cabac"])
531 [fX264optCabacSwitch setState:[optValue intValue]];
538 - (IBAction) X264AdvancedOptionsChanged: (id) sender
540 /*Determine which outlet is being used and set optName to process accordingly */
541 NSString * optNameToChange = @""; // The option name such as "bframes"
543 if (sender == fX264optBframesPopUp)
545 optNameToChange = @"bframes";
547 if (sender == fX264optRefPopUp)
549 optNameToChange = @"ref";
551 if (sender == fX264optNfpskipSwitch)
553 optNameToChange = @"no-fast-pskip";
555 if (sender == fX264optNodctdcmtSwitch)
557 optNameToChange = @"no-dct-decimate";
559 if (sender == fX264optSubmePopUp)
561 optNameToChange = @"subq";
563 if (sender == fX264optTrellisPopUp)
565 optNameToChange = @"trellis";
567 if (sender == fX264optMixedRefsSwitch)
569 optNameToChange = @"mixed-refs";
571 if (sender == fX264optMotionEstPopUp)
573 optNameToChange = @"me";
575 if (sender == fX264optMERangePopUp)
577 optNameToChange = @"merange";
579 if (sender == fX264optWeightBSwitch)
581 optNameToChange = @"weightb";
583 if (sender == fX264optBRDOSwitch)
585 optNameToChange = @"brdo";
587 if (sender == fX264optBPyramidSwitch)
589 optNameToChange = @"b-pyramid";
591 if (sender == fX264optBiMESwitch)
593 optNameToChange = @"bime";
595 if (sender == fX264optDirectPredPopUp)
597 optNameToChange = @"direct";
599 if (sender == fX264optAlphaDeblockPopUp)
601 optNameToChange = @"deblock";
603 if (sender == fX264optBetaDeblockPopUp)
605 optNameToChange = @"deblock";
607 if (sender == fX264optAnalysePopUp)
609 optNameToChange = @"analyse";
611 if (sender == fX264opt8x8dctSwitch)
613 optNameToChange = @"8x8dct";
615 if (sender == fX264optCabacSwitch)
617 optNameToChange = @"cabac";
620 /* Set widgets depending on the opt string in field */
621 NSString * thisOpt; // The separated option such as "bframes=3"
622 NSString * optName = @""; // The option name such as "bframes"
623 NSString * optValue = @"";// The option value such as "3"
624 NSArray *currentOptsArray;
626 /*First, we get an opt string to process */
627 //EXAMPLE: NSString *currentOptString = @"bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
628 NSString *currentOptString = [fDisplayX264Options stringValue];
630 /*verify there is an occurrence of the opt specified by the sender to change */
631 /*take care of any multi-value opt names here. This is extremely kludgy, but test for functionality
632 and worry about pretty later */
634 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
635 the first character of the opt string (hence the ":") */
636 NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange];
637 NSRange currentOptRange = [currentOptString rangeOfString:checkOptNameToChange];
638 /*Then we create a pattern to check for "<beginning of line>"optNameToChange"=" to modify the option to
639 see if the name falls at the beginning of the line, where we would not have the ":" as a pattern to test against*/
640 NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange];
641 NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning];
642 if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0)
644 /* Create new empty opt string*/
645 NSString *changedOptString = @"";
647 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
648 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
650 /*iterate through the array and get <opts> and <values*/
652 int currentOptsArrayCount = [currentOptsArray count];
653 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
655 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
656 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
658 if (splitOptRange.location != NSNotFound)
660 optName = [thisOpt substringToIndex:splitOptRange.location];
661 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
663 /*Run through the available widgets for x264 opts and set them, as you add widgets,
664 they need to be added here. This should be moved to its own method probably*/
666 /*If the optNameToChange is found, appropriately change the value or delete it if
667 "Unspecified" is set.*/
668 if ([optName isEqualToString:optNameToChange])
670 if ([optNameToChange isEqualToString:@"deblock"])
672 if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7)))
678 thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0];
681 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"] )
683 if ([sender state] == 0)
689 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
692 else if ([optNameToChange isEqualToString:@"cabac"])
694 if ([sender state] == 1)
700 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0];
703 else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string
707 else if ([optNameToChange isEqualToString:@"me"])
709 switch ([sender indexOfSelectedItem])
712 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"];
716 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"];
720 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"];
724 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"];
731 else if ([optNameToChange isEqualToString:@"direct"])
733 switch ([sender indexOfSelectedItem])
736 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
740 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"];
744 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"];
748 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"];
755 else if ([optNameToChange isEqualToString:@"analyse"])
757 switch ([sender indexOfSelectedItem])
760 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
764 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
771 else if ([optNameToChange isEqualToString:@"merange"])
773 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
775 else // we have a valid value to change, so change it
777 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
782 /* Construct New String for opts here */
783 if ([thisOpt isEqualToString:@""])
785 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
789 if ([changedOptString isEqualToString:@""])
791 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
795 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
800 /* Change the option string to reflect the new mod settings */
801 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
803 else // if none exists, add it to the string
805 if ([[fDisplayX264Options stringValue] isEqualToString: @""])
807 if ([optNameToChange isEqualToString:@"me"])
809 switch ([sender indexOfSelectedItem])
812 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
813 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
817 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
818 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
822 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
823 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
827 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
828 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
835 else if ([optNameToChange isEqualToString:@"direct"])
837 switch ([sender indexOfSelectedItem])
840 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
841 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
845 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
846 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
850 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
851 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
855 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
856 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
863 else if ([optNameToChange isEqualToString:@"analyse"])
865 switch ([sender indexOfSelectedItem])
868 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
869 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
873 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
874 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
882 else if ([optNameToChange isEqualToString:@"merange"])
884 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
885 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
887 else if ([optNameToChange isEqualToString:@"deblock"])
889 [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]]];
891 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"] ) {
892 if ([sender state] == 0)
894 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
898 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
899 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
902 else if ([optNameToChange isEqualToString:@"cabac"])
904 if ([sender state] == 1)
906 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
910 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
911 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
916 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
917 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
922 if ([optNameToChange isEqualToString:@"me"])
924 switch ([sender indexOfSelectedItem])
927 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
928 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
929 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
933 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
934 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
935 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
939 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
940 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
941 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
945 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
946 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
947 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
954 else if ([optNameToChange isEqualToString:@"direct"])
956 switch ([sender indexOfSelectedItem])
959 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
960 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
961 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
965 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
966 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
967 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
971 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
972 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
973 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
977 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
978 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
979 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
986 else if ([optNameToChange isEqualToString:@"analyse"])
988 switch ([sender indexOfSelectedItem])
991 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
992 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
993 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
997 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
998 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
999 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
1007 else if ([optNameToChange isEqualToString:@"merange"])
1009 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1010 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
1012 else if ([optNameToChange isEqualToString:@"deblock"])
1014 [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]]];
1016 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"] )
1018 if ([sender state] == 0)
1020 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
1024 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1025 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
1028 else if ([optNameToChange isEqualToString:@"cabac"])
1030 if ([sender state] == 1)
1032 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
1036 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1037 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
1042 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1043 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
1048 /* We now need to reset the opt widgets since we changed some stuff */
1049 [self X264AdvancedOptionsSet:NULL];