+ else if ([optName isEqualToString:@"aq-strength"])
+ {
+ if( [fX264optAqSlider floatValue] == 1.0 )
+ {
+ /* When Aq is 1 it's the default value and can be ignored. */
+ thisOpt = @"";
+ }
+ else
+ {
+ thisOpt = [NSString stringWithFormat:@"%@=%0.1f", optName, [fX264optAqSlider floatValue] ];
+ }
+ }
+
+ else if ([optName isEqualToString:@"psy-rd"])
+ {
+ if( [fX264optPsyRDSlider floatValue] == 1.0 && [fX264optPsyTrellisSlider floatValue] == 0.0 )
+ {
+ /* When PsyRD is 1 and PsyTrel is 0 they're default values and can be ignored. */
+ thisOpt = @"";
+ }
+ else
+ {
+ /* Otherwise the format is psy-rd=a,b */
+ thisOpt = [NSString stringWithFormat:@"%@=%0.1f,%0.2f", optName, [fX264optPsyRDSlider floatValue], [fX264optPsyTrellisSlider floatValue] ];
+ }
+ }
+
+ else if /*Boolean Switches*/ ( [optName isEqualToString:@"no-dct-decimate"] )
+ {
+ /* Here is where we take care of the boolean options that work overtly:
+ no-dct-decimate being on means no-dct-decimate=1, etc. Some options
+ require the inverse, but those will be handled a couple lines down. */
+ if ([sender state] == 0)
+ {
+ /* When these options are false, don't include them. They all default
+ to being set off, so they don't need to be mentioned at all. */
+ thisOpt = @"";
+ }
+ else
+ {
+ /* Otherwise, include them as optioname=1 */
+ thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
+ }
+ }
+
+ else if ( [optName isEqualToString:@"8x8dct"] || [optName isEqualToString:@"cabac"] || [optName isEqualToString:@"weightp"] )
+ {
+ /* These options default to being on. That means they
+ only need to be included in the string when turned off. */
+ if ([sender state] == 1)
+ {
+ /* It's true so don't include it. */
+ thisOpt = @"";
+ }
+ else
+ {
+ /* Otherwise, include cabac=0, etc, in the string. */
+ 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
+ {
+ /* When a widget is at index 0, it's default. Default means don't add to the string.
+ The exception for deblocking is because for those, *both* need to at index 0
+ for it to default, so it's handled separately, above this section. */
+ thisOpt = @"";
+ }
+
+ else if ([optName isEqualToString:@"me"])
+ {
+ /* Motion estimation uses string values, so this switch
+ pairs the widget index with the right value string. */
+ 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;
+
+ case 5:
+ thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"tesa"];
+
+ default:
+ break;
+ }
+ }
+
+ else if ([optName isEqualToString:@"direct"])
+ {
+ /* Direct prediction uses string values, so this switch
+ pairs the right string value with the right widget index. */
+ 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 ([optName isEqualToString:@"analyse"])
+ {
+ /* Analysis uses string values as well. */
+ switch ([sender indexOfSelectedItem])
+ {
+ case 1:
+ thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
+ break;
+ case 2:
+ thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"i4x4,i8x8"];
+ break;
+ case 3:
+ thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ else if ([optName isEqualToString:@"b-pyramid"])
+ {
+ /* B-pyramid uses string values too. */
+ switch ([sender indexOfSelectedItem])
+ {
+ case 1:
+ thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
+ break;
+ case 2:
+ thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"strict"];
+ break;
+ case 0:
+ thisOpt = @"";
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ else if ([optName isEqualToString:@"merange"])
+ {
+ /* Motion estimation range uses an odd array offset because in addition
+ to starting with index 0 as default, index 1 starts at 4 instead of 1,
+ because merange can't go below 4. So it has to be handled separately. */
+ thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
+ }
+
+ else if ([optName isEqualToString:@"b-adapt"])
+ {
+ /* B-adapt starts at index 0 with default then goes 0, 1, 2)*/
+ thisOpt = [NSString stringWithFormat:@"%@=%d", optName, [sender indexOfSelectedItem]-1];
+ }
+
+ else if ([optName isEqualToString:@"ref"])
+ {
+ /* Refs use actual index numbers */
+ thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]];
+ }
+
+ else // we have a valid value to change, so change it
+ {
+ if ( [sender indexOfSelectedItem] != 0 )
+ /* Here's our general case, that catches things like b-frames.
+ Basically, any options that are PopUp menus with index 0 as default and
+ index 1 as 0, with numerical values, are all handled right here. All of
+ the above stuff is for the exceptions to the general case. */
+ thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
+ }
+
+ return thisOpt;
+}
+
+- (BOOL) X264AdvancedOptionsIsOpt: (NSString *) optNameToChange inString: (NSString *) currentOptString
+{
+ /* If the option is in the string but not the beginning of it,
+ it will be in the form of ":optName=value" so we really want
+ to be looking for ":optNameToChange=" rather than "optNameToChange". */