1 /* HBAdvancedController
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.fr/>.
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
22 [fOptionsBox setContentView:fX264optView];
25 - (BOOL) loadMyNibFile
27 if(![NSBundle loadNibNamed:@"AdvancedView" owner:self])
29 NSLog(@"Warning! Could not load myNib file.\n");
36 - (NSString *) optionsString
38 return [fDisplayX264Options stringValue];
41 - (void) setOptions: (NSString *)string
43 [fDisplayX264Options setStringValue:string];
44 [self X264AdvancedOptionsSet:nil];
47 - (void) setHidden: (BOOL) hide
51 [fOptionsBox setContentView:fEmptyView];
52 [fX264optViewTitleLabel setStringValue: @"Only Used With The x264 (H.264) Codec"];
56 [fOptionsBox setContentView:fX264optView];
57 [fX264optViewTitleLabel setStringValue: @""];
62 - (void) enableUI: (bool) b
65 NSControl * controls[] =
66 { fX264optViewTitleLabel,fDisplayX264Options,fDisplayX264OptionsLabel,fX264optBframesLabel,
67 fX264optBframesPopUp,fX264optRefLabel,fX264optRefPopUp,fX264optNfpskipLabel,fX264optNfpskipSwitch,
68 fX264optNodctdcmtLabel,fX264optNodctdcmtSwitch,fX264optSubmeLabel,fX264optSubmePopUp,
69 fX264optTrellisLabel,fX264optTrellisPopUp,fX264optMixedRefsLabel,fX264optMixedRefsSwitch,
70 fX264optMotionEstLabel,fX264optMotionEstPopUp,fX264optMERangeLabel,fX264optMERangePopUp,
71 fX264optWeightBLabel,fX264optWeightBSwitch, fX264optBPyramidLabel,fX264optBPyramidSwitch,
72 fX264optDirectPredLabel,fX264optDirectPredPopUp,fX264optDeblockLabel,fX264optAnalyseLabel,
73 fX264optAnalysePopUp,fX264opt8x8dctLabel,fX264opt8x8dctSwitch,fX264optCabacLabel,fX264optCabacSwitch,
74 fX264optAlphaDeblockPopUp,fX264optBetaDeblockPopUp};
76 for( i = 0; i < sizeof( controls ) / sizeof( NSControl * ); i++ )
78 if( [[controls[i] className] isEqualToString: @"NSTextField"] )
80 NSTextField * tf = (NSTextField *) controls[i];
83 [tf setTextColor: b ? [NSColor controlTextColor] :
84 [NSColor disabledControlTextColor]];
88 [controls[i] setEnabled: b];
92 [fX264optView setWantsLayer:YES];
101 * Populates the option widgets
103 - (IBAction) X264AdvancedOptionsSet: (id) sender
105 /*Set opt widget values here*/
107 /*B-Frames fX264optBframesPopUp*/
109 [fX264optBframesPopUp removeAllItems];
110 [fX264optBframesPopUp addItemWithTitle:@"Default (0)"];
113 [fX264optBframesPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
116 /*Reference Frames fX264optRefPopUp*/
117 [fX264optRefPopUp removeAllItems];
118 [fX264optRefPopUp addItemWithTitle:@"Default (1)"];
121 [fX264optRefPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
124 /*No Fast P-Skip fX264optNfpskipSwitch BOOLEAN*/
125 [fX264optNfpskipSwitch setState:0];
127 /*No Dict Decimate fX264optNodctdcmtSwitch BOOLEAN*/
128 [fX264optNodctdcmtSwitch setState:0];
130 /*Sub Me fX264optSubmePopUp*/
131 [fX264optSubmePopUp removeAllItems];
132 [fX264optSubmePopUp addItemWithTitle:@"Default (6)"];
135 [fX264optSubmePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
138 /*Trellis fX264optTrellisPopUp*/
139 [fX264optTrellisPopUp removeAllItems];
140 [fX264optTrellisPopUp addItemWithTitle:@"Default (0)"];
143 [fX264optTrellisPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
145 [fX264optTrellisPopUp setWantsLayer:YES];
147 /*Mixed-references fX264optMixedRefsSwitch BOOLEAN*/
148 [fX264optMixedRefsSwitch setState:0];
149 [fX264optMixedRefsSwitch setWantsLayer:YES];
151 /*Motion Estimation fX264optMotionEstPopUp*/
152 [fX264optMotionEstPopUp removeAllItems];
153 [fX264optMotionEstPopUp addItemWithTitle:@"Default (Hexagon)"];
154 [fX264optMotionEstPopUp addItemWithTitle:@"Diamond"];
155 [fX264optMotionEstPopUp addItemWithTitle:@"Hexagon"];
156 [fX264optMotionEstPopUp addItemWithTitle:@"Uneven Multi-Hexagon"];
157 [fX264optMotionEstPopUp addItemWithTitle:@"Exhaustive"];
158 [fX264optMotionEstPopUp addItemWithTitle:@"Transformed Exhaustive"];
160 /*Motion Estimation range fX264optMERangePopUp*/
161 [fX264optMERangePopUp removeAllItems];
162 [fX264optMERangePopUp addItemWithTitle:@"Default (16)"];
165 [fX264optMERangePopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
168 /*Weighted B-Frame Prediction fX264optWeightBSwitch BOOLEAN*/
169 [fX264optWeightBSwitch setState:0];
170 [fX264optWeightBSwitch setWantsLayer:YES];
172 /*B-frame Pyramids fX264optBPyramidSwitch BOOLEAN*/
173 [fX264optBPyramidSwitch setState:0];
174 [fX264optBPyramidSwitch setWantsLayer:YES];
176 /*Direct B-Frame Prediction Mode fX264optDirectPredPopUp*/
177 [fX264optDirectPredPopUp removeAllItems];
178 [fX264optDirectPredPopUp addItemWithTitle:@"Default (Spatial)"];
179 [fX264optDirectPredPopUp addItemWithTitle:@"None"];
180 [fX264optDirectPredPopUp addItemWithTitle:@"Spatial"];
181 [fX264optDirectPredPopUp addItemWithTitle:@"Temporal"];
182 [fX264optDirectPredPopUp addItemWithTitle:@"Automatic"];
183 [fX264optDirectPredPopUp setWantsLayer:YES];
186 [fX264optAlphaDeblockPopUp removeAllItems];
187 [fX264optAlphaDeblockPopUp addItemWithTitle:@"Default (0)"];
190 [fX264optAlphaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
194 [fX264optBetaDeblockPopUp removeAllItems];
195 [fX264optBetaDeblockPopUp addItemWithTitle:@"Default (0)"];
198 [fX264optBetaDeblockPopUp addItemWithTitle:[NSString stringWithFormat:@"%d",i]];
201 /* Analysis fX264optAnalysePopUp */
202 [fX264optAnalysePopUp removeAllItems];
203 [fX264optAnalysePopUp addItemWithTitle:@"Default (some)"]; /* 0=default */
204 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"None"]]; /* 1=none */
205 [fX264optAnalysePopUp addItemWithTitle:[NSString stringWithFormat:@"All"]]; /* 2=all */
207 /* 8x8 DCT fX264op8x8dctSwitch */
208 [fX264opt8x8dctSwitch setState:0];
209 [fX264opt8x8dctSwitch setWantsLayer:YES];
211 /* CABAC fX264opCabacSwitch */
212 [fX264optCabacSwitch setState:1];
214 /* Standardize the option string */
215 [self X264AdvancedOptionsStandardizeOptString:nil];
217 /* Set Current GUI Settings based on newly standardized string */
218 [self X264AdvancedOptionsSetCurrentSettings:nil];
220 /* Fade out options that don't apply */
221 [self X264AdvancedOptionsAnimate: sender];
225 * Cleans the option string to use a standard format of option=value
227 - (IBAction) X264AdvancedOptionsStandardizeOptString: (id) sender
229 /* Set widgets depending on the opt string in field */
230 NSString * thisOpt; // The separated option such as "bframes=3"
231 NSString * optName = @""; // The option name such as "bframes"
232 NSString * optValue = @"";// The option value such as "3"
233 NSString * changedOptString = @"";
234 NSArray *currentOptsArray;
236 /*First, we get an opt string to process */
237 NSString *currentOptString = [fDisplayX264Options stringValue];
239 /* Verify there is an opt string to process by making sure an
240 option is getting its value set. If so, start to process it. */
241 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
242 if (currentOptRange.location != NSNotFound)
244 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
245 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
247 /*iterate through the array and get <opts> and <values*/
249 int currentOptsArrayCount = [currentOptsArray count];
250 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
252 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
254 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
255 if (splitOptRange.location != NSNotFound)
257 optName = [thisOpt substringToIndex:splitOptRange.location];
258 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
260 /* Standardize the names here depending on whats in the string */
261 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
262 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,optValue];
264 else // No value given so we use a default of "1"
268 /* Standardize the names here depending on whats in the string */
269 optName = [self X264AdvancedOptionsStandardizeOptNames:optName];
270 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
273 /* Construct New String for opts here.*/
274 if ([thisOpt isEqualToString:@""])
276 /* Blank option, just add it to the string. (Why?) */
277 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
281 if ([changedOptString isEqualToString:@""])
283 /* Blank string, output the current option. */
284 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
288 /* Option exists and string exists, so append the option
289 to the string with a semi-colon inbetween them. */
290 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
296 /* Change the option string to reflect the new standardized option string */
297 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
301 * Cleans the option string to use a standard set of option names, by conflating synonyms.
303 - (NSString *) X264AdvancedOptionsStandardizeOptNames:(NSString *) cleanOptNameString
305 /* Reference Frames */
306 if ([cleanOptNameString isEqualToString:@"ref"] || [cleanOptNameString isEqualToString:@"frameref"])
308 cleanOptNameString = @"ref";
311 /*No Fast PSkip nofast_pskip*/
312 if ([cleanOptNameString isEqualToString:@"no-fast-pskip"] || [cleanOptNameString isEqualToString:@"no_fast_pskip"] || [cleanOptNameString isEqualToString:@"nofast_pskip"])
314 cleanOptNameString = @"no-fast-pskip";
318 if ([cleanOptNameString isEqualToString:@"no-dct-decimate"] || [cleanOptNameString isEqualToString:@"no_dct_decimate"] || [cleanOptNameString isEqualToString:@"nodct_decimate"])
320 cleanOptNameString = @"no-dct-decimate";
324 if ([cleanOptNameString isEqualToString:@"subme"])
326 cleanOptNameString = @"subq";
330 if ([cleanOptNameString isEqualToString:@"me-range"] || [cleanOptNameString isEqualToString:@"me_range"])
331 cleanOptNameString = @"merange";
334 if ([cleanOptNameString isEqualToString:@"weight-b"] || [cleanOptNameString isEqualToString:@"weight_b"])
336 cleanOptNameString = @"weightb";
340 if ([cleanOptNameString isEqualToString:@"b_pyramid"])
342 cleanOptNameString = @"b-pyramid";
345 /*Direct Prediction*/
346 if ([cleanOptNameString isEqualToString:@"direct-pred"] || [cleanOptNameString isEqualToString:@"direct_pred"])
348 cleanOptNameString = @"direct";
352 if ([cleanOptNameString isEqualToString:@"filter"])
354 cleanOptNameString = @"deblock";
358 if ([cleanOptNameString isEqualToString:@"partitions"])
360 cleanOptNameString = @"analyse";
363 return cleanOptNameString;
367 * Fades options in and out depending on whether they're available..
369 - (IBAction) X264AdvancedOptionsAnimate: (id) sender
371 /* Lots of situations to cover.
372 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
373 - CABAC (when 0 turn off trellis)
374 - analysis (if none, turn off 8x8dct)
375 - refs (under 2, disable mixed-refs)
378 if ( [fX264optBframesPopUp indexOfSelectedItem ] < 2)
380 /* If the b-frame widget is at 0 or 1, the user has chosen
381 not to use b-frames at all. So disable the options
382 that can only be used when b-frames are enabled. */
383 [[fX264optWeightBSwitch animator] setHidden:YES];
384 [[fX264optWeightBLabel animator] setHidden:YES];
385 if ( [fX264optWeightBSwitch state] == 1 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp)
386 [fX264optWeightBSwitch performClick:self];
388 [[fX264optBPyramidSwitch animator] setHidden:YES];
389 [[fX264optBPyramidLabel animator] setHidden:YES];
390 if ( [fX264optBPyramidSwitch state] == 1 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp)
391 [fX264optBPyramidSwitch performClick:self];
393 [[fX264optDirectPredPopUp animator] setHidden:YES];
394 [[fX264optDirectPredLabel animator] setHidden:YES];
395 if ( [fX264optDirectPredPopUp indexOfSelectedItem] > 0 && sender != fX264optWeightBSwitch && sender != fX264optBPyramidSwitch && sender != fX264optDirectPredPopUp)
397 [fX264optDirectPredPopUp selectItemAtIndex: 0];
398 [[fX264optDirectPredPopUp cell] performClick:self];
402 else if ( [fX264optBframesPopUp indexOfSelectedItem ] == 2)
404 /* Only 1 b-frame? Disable b-pyramid. */
405 [[fX264optBPyramidSwitch animator] setHidden:YES];
406 [[fX264optBPyramidLabel animator] setHidden:YES];
407 if ( [fX264optBPyramidSwitch state] == 1 && sender != fX264optBPyramidSwitch)
408 [fX264optBPyramidSwitch performClick:self];
410 [[fX264optWeightBSwitch animator] setHidden:NO];
411 [[fX264optWeightBLabel animator] setHidden:NO];
413 [[fX264optDirectPredPopUp animator] setHidden:NO];
414 [[fX264optDirectPredLabel animator] setHidden:NO];
418 [[fX264optWeightBSwitch animator] setHidden:NO];
419 [[fX264optWeightBLabel animator] setHidden:NO];
421 [[fX264optBPyramidSwitch animator] setHidden:NO];
422 [[fX264optBPyramidLabel animator] setHidden:NO];
424 [[fX264optDirectPredPopUp animator] setHidden:NO];
425 [[fX264optDirectPredLabel animator] setHidden:NO];
428 if ( [fX264optCabacSwitch state] == false)
430 /* Without CABAC entropy coding, trellis doesn't run. */
432 [[fX264optTrellisPopUp animator] setHidden:YES];
433 [[fX264optTrellisLabel animator] setHidden:YES];
434 [fX264optTrellisPopUp selectItemAtIndex:0];
435 if (sender != fX264optTrellisPopUp)
436 [[fX264optTrellisPopUp cell] performClick:self];
440 [[fX264optTrellisPopUp animator] setHidden:NO];
441 [[fX264optTrellisLabel animator] setHidden:NO];
444 if ( [fX264optAnalysePopUp indexOfSelectedItem] == 1)
446 /* No analysis? Disable 8x8dct */
447 [[fX264opt8x8dctSwitch animator] setHidden:YES];
448 [[fX264opt8x8dctLabel animator] setHidden:YES];
449 if ( [fX264opt8x8dctSwitch state] == 1 && sender != fX264opt8x8dctSwitch )
450 [fX264opt8x8dctSwitch performClick:self];
454 [[fX264opt8x8dctSwitch animator] setHidden:NO];
455 [[fX264opt8x8dctLabel animator] setHidden:NO];
458 if ( [fX264optRefPopUp indexOfSelectedItem] < 3)
460 /* Only do mixed-refs when there are at least 2 refs to mix. */
461 [[fX264optMixedRefsSwitch animator] setHidden:YES];
462 [[fX264optMixedRefsLabel animator] setHidden:YES];
463 if ( [fX264optMixedRefsSwitch state] == 1 && sender != fX264optMixedRefsSwitch )
464 [fX264optMixedRefsSwitch performClick:self];
468 [[fX264optMixedRefsSwitch animator] setHidden:NO];
469 [[fX264optMixedRefsLabel animator] setHidden:NO];
474 * Resets the GUI widgets to the contents of the option string.
476 - (IBAction) X264AdvancedOptionsSetCurrentSettings: (id) sender
478 /* Set widgets depending on the opt string in field */
479 NSString * thisOpt; // The separated option such as "bframes=3"
480 NSString * optName = @""; // The option name such as "bframes"
481 NSString * optValue = @"";// The option value such as "3"
482 NSArray *currentOptsArray;
484 /*First, we get an opt string to process */
485 NSString *currentOptString = [fDisplayX264Options stringValue];
487 /* Verify there is an opt string to process by making sure an
488 option is getting its value set. If so, start to process it. */
489 NSRange currentOptRange = [currentOptString rangeOfString:@"="];
490 if (currentOptRange.location != NSNotFound)
492 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
493 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
495 /*iterate through the array and get <opts> and <values*/
497 int currentOptsArrayCount = [currentOptsArray count];
498 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
500 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
502 /* Verify the option sets a value */
503 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
504 if (splitOptRange.location != NSNotFound)
506 /* Split thisOpt into an optName setting an optValue. */
507 optName = [thisOpt substringToIndex:splitOptRange.location];
508 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
510 /*Run through the available widgets for x264 opts and set them, as you add widgets,
511 they need to be added here. This should be moved to its own method probably*/
513 /*bframes NSPopUpButton*/
514 if ([optName isEqualToString:@"bframes"])
516 [fX264optBframesPopUp selectItemAtIndex:[optValue intValue]+1];
518 /*ref NSPopUpButton*/
519 if ([optName isEqualToString:@"ref"])
521 [fX264optRefPopUp selectItemAtIndex:[optValue intValue]+1];
523 /*No Fast PSkip NSButton*/
524 if ([optName isEqualToString:@"no-fast-pskip"])
526 [fX264optNfpskipSwitch setState:[optValue intValue]];
528 /*No Dict Decimate NSButton*/
529 if ([optName isEqualToString:@"no-dct-decimate"])
531 [fX264optNodctdcmtSwitch setState:[optValue intValue]];
533 /*Sub Me NSPopUpButton*/
534 if ([optName isEqualToString:@"subq"])
536 [fX264optSubmePopUp selectItemAtIndex:[optValue intValue]+1];
538 /*Trellis NSPopUpButton*/
539 if ([optName isEqualToString:@"trellis"])
541 [fX264optTrellisPopUp selectItemAtIndex:[optValue intValue]+1];
543 /*Mixed Refs NSButton*/
544 if ([optName isEqualToString:@"mixed-refs"])
546 [fX264optMixedRefsSwitch setState:[optValue intValue]];
548 /*Motion Estimation NSPopUpButton*/
549 if ([optName isEqualToString:@"me"])
551 if ([optValue isEqualToString:@"dia"])
552 [fX264optMotionEstPopUp selectItemAtIndex:1];
553 else if ([optValue isEqualToString:@"hex"])
554 [fX264optMotionEstPopUp selectItemAtIndex:2];
555 else if ([optValue isEqualToString:@"umh"])
556 [fX264optMotionEstPopUp selectItemAtIndex:3];
557 else if ([optValue isEqualToString:@"esa"])
558 [fX264optMotionEstPopUp selectItemAtIndex:4];
559 else if ([optValue isEqualToString:@"tesa"])
560 [fX264optMotionEstPopUp selectItemAtIndex:5];
562 /*ME Range NSPopUpButton*/
563 if ([optName isEqualToString:@"merange"])
565 [fX264optMERangePopUp selectItemAtIndex:[optValue intValue]-3];
567 /*Weighted B-Frames NSButton*/
568 if ([optName isEqualToString:@"weightb"])
570 [fX264optWeightBSwitch setState:[optValue intValue]];
572 /*B Pyramid NSPButton*/
573 if ([optName isEqualToString:@"b-pyramid"])
575 [fX264optBPyramidSwitch setState:[optValue intValue]];
577 /*Direct B-frame Prediction NSPopUpButton*/
578 if ([optName isEqualToString:@"direct"])
580 if ([optValue isEqualToString:@"none"])
581 [fX264optDirectPredPopUp selectItemAtIndex:1];
582 else if ([optValue isEqualToString:@"spatial"])
583 [fX264optDirectPredPopUp selectItemAtIndex:2];
584 else if ([optValue isEqualToString:@"temporal"])
585 [fX264optDirectPredPopUp selectItemAtIndex:3];
586 else if ([optValue isEqualToString:@"auto"])
587 [fX264optDirectPredPopUp selectItemAtIndex:4];
589 /*Deblocking NSPopUpButtons*/
590 if ([optName isEqualToString:@"deblock"])
592 NSString * alphaDeblock = @"";
593 NSString * betaDeblock = @"";
595 NSRange splitDeblock = [optValue rangeOfString:@","];
596 alphaDeblock = [optValue substringToIndex:splitDeblock.location];
597 betaDeblock = [optValue substringFromIndex:splitDeblock.location + 1];
599 if ([alphaDeblock isEqualToString:@"0"] && [betaDeblock isEqualToString:@"0"])
601 /* When both filters are at 0, default */
602 [fX264optAlphaDeblockPopUp selectItemAtIndex:0];
603 [fX264optBetaDeblockPopUp selectItemAtIndex:0];
607 if (![alphaDeblock isEqualToString:@"0"])
609 /* Alpha isn't 0, so set it. The offset of 7 is
610 because filters start at -6 instead of at 0. */
611 [fX264optAlphaDeblockPopUp selectItemAtIndex:[alphaDeblock intValue]+7];
615 /* Set alpha filter to 0, which is 7 up
616 because filters start at -6, not 0. */
617 [fX264optAlphaDeblockPopUp selectItemAtIndex:7];
620 if (![betaDeblock isEqualToString:@"0"])
622 /* Beta isn't 0, so set it. */
623 [fX264optBetaDeblockPopUp selectItemAtIndex:[betaDeblock intValue]+7];
627 /* Set beta filter to 0. */
628 [fX264optBetaDeblockPopUp selectItemAtIndex:7];
632 /* Analysis NSPopUpButton */
633 if ([optName isEqualToString:@"analyse"])
635 if ([optValue isEqualToString:@"p8x8,b8x8,i8x8,i4x4"])
637 /* Default ("some") */
638 [fX264optAnalysePopUp selectItemAtIndex:0];
640 if ([optValue isEqualToString:@"none"])
642 [fX264optAnalysePopUp selectItemAtIndex:1];
644 if ([optValue isEqualToString:@"all"])
646 [fX264optAnalysePopUp selectItemAtIndex:2];
649 /* 8x8 DCT NSButton */
650 if ([optName isEqualToString:@"8x8dct"])
652 [fX264opt8x8dctSwitch setState:[optValue intValue]];
655 if ([optName isEqualToString:@"cabac"])
657 [fX264optCabacSwitch setState:[optValue intValue]];
665 * Resets the option string to mirror the GUI widgets.
667 - (IBAction) X264AdvancedOptionsChanged: (id) sender
669 /*Determine which outlet is being used and set optName to process accordingly */
670 NSString * optNameToChange = @""; // The option name such as "bframes"
672 if (sender == fX264optBframesPopUp)
674 optNameToChange = @"bframes";
676 if (sender == fX264optRefPopUp)
678 optNameToChange = @"ref";
680 if (sender == fX264optNfpskipSwitch)
682 optNameToChange = @"no-fast-pskip";
684 if (sender == fX264optNodctdcmtSwitch)
686 optNameToChange = @"no-dct-decimate";
688 if (sender == fX264optSubmePopUp)
690 optNameToChange = @"subq";
692 if (sender == fX264optTrellisPopUp)
694 optNameToChange = @"trellis";
696 if (sender == fX264optMixedRefsSwitch)
698 optNameToChange = @"mixed-refs";
700 if (sender == fX264optMotionEstPopUp)
702 optNameToChange = @"me";
704 if (sender == fX264optMERangePopUp)
706 optNameToChange = @"merange";
708 if (sender == fX264optWeightBSwitch)
710 optNameToChange = @"weightb";
712 if (sender == fX264optBPyramidSwitch)
714 optNameToChange = @"b-pyramid";
716 if (sender == fX264optDirectPredPopUp)
718 optNameToChange = @"direct";
720 if (sender == fX264optAlphaDeblockPopUp)
722 optNameToChange = @"deblock";
724 if (sender == fX264optBetaDeblockPopUp)
726 optNameToChange = @"deblock";
728 if (sender == fX264optAnalysePopUp)
730 optNameToChange = @"analyse";
732 if (sender == fX264opt8x8dctSwitch)
734 optNameToChange = @"8x8dct";
736 if (sender == fX264optCabacSwitch)
738 optNameToChange = @"cabac";
741 /* Set widgets depending on the opt string in field */
742 NSString * thisOpt; // The separated option such as "bframes=3"
743 NSString * optName = @""; // The option name such as "bframes"
744 NSString * optValue = @"";// The option value such as "3"
745 NSArray *currentOptsArray;
747 /*First, we get an opt string to process */
748 NSString *currentOptString = [fDisplayX264Options stringValue];
750 /* There are going to be a few possibilities.
751 - The option might start off the string.
752 - The option might be in the middle of the string.
753 - The option might not be in the string at all yet.
754 - The string itself might not yet exist.
756 Because each of these possibilities means constructing a different kind of string,
757 they're all handled separately in a sea of messy, somewhat redundant code. =( */
759 /* If the option is in the string but not the beginning of it, it will be in the form of ":optName=value"
760 so we really want to be looking for ":optNameToChange=" rather than "optNameToChange". */
761 NSString *checkOptNameToChange = [NSString stringWithFormat:@":%@=",optNameToChange];
763 /* Now we store the part of the string up through the option name in currentOptRange. */
764 NSRange currentOptRange = [currentOptString rangeOfString:checkOptNameToChange];
766 /* We need to know if the option is at the beginning of the string.
767 If it is at the start, it won't be preceded by a colon.
768 To figure this out, we'll use the rangeOfString method. First,
769 store what the option name would be if if it was at the beginning,
770 in checkOptNameToChangeBeginning. Then, find its range in the string.
771 If the range is 0, it's the first option listed in the string. */
772 NSString *checkOptNameToChangeBeginning = [NSString stringWithFormat:@"%@=",optNameToChange];
773 NSRange currentOptRangeBeginning = [currentOptString rangeOfString:checkOptNameToChangeBeginning];
775 if (currentOptRange.location != NSNotFound || currentOptRangeBeginning.location == 0)
777 /* If the option is in the string wth a semicolon, or starts the string, it's time to edit.
778 This means parsing the whole string into an array of options and values. From there,
779 iterate through the options, and when you reach the one that's been changed, edit it. */
781 /* Create new empty opt string*/
782 NSString *changedOptString = @"";
784 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
785 currentOptsArray = [currentOptString componentsSeparatedByString:@":"];
787 /*iterate through the array and get <opts> and <values*/
789 int currentOptsArrayCount = [currentOptsArray count];
790 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
792 thisOpt = [currentOptsArray objectAtIndex:loopcounter];
793 NSRange splitOptRange = [thisOpt rangeOfString:@"="];
795 if (splitOptRange.location != NSNotFound)
797 /* First off, it's time to handle option strings that
798 already have at least one option=value pair in them. */
800 optName = [thisOpt substringToIndex:splitOptRange.location];
801 optValue = [thisOpt substringFromIndex:splitOptRange.location + 1];
803 /*Run through the available widgets for x264 opts and set them, as you add widgets,
804 they need to be added here. This should be moved to its own method probably*/
806 /*If the optNameToChange is found, appropriately change the value or delete it if
807 "Unspecified" is set.*/
808 if ([optName isEqualToString:optNameToChange])
810 if ([optNameToChange isEqualToString:@"deblock"])
812 if ((([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optAlphaDeblockPopUp indexOfSelectedItem] == 7)) && (([fX264optBetaDeblockPopUp indexOfSelectedItem] == 0) || ([fX264optBetaDeblockPopUp indexOfSelectedItem] == 7)))
814 /* When both deblock widgets are 0 or default or a mix of the two,
815 use a blank string, since deblocking defaults to 0,0. */
820 /* Otherwise the format is deblock=a,b, where a and b both have an array
821 offset of 7 because deblocking values start at -6 instead of at zero. */
822 thisOpt = [NSString stringWithFormat:@"%@=%d,%d",optName, ([fX264optAlphaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optAlphaDeblockPopUp indexOfSelectedItem]-7 : 0,([fX264optBetaDeblockPopUp indexOfSelectedItem] != 0) ? [fX264optBetaDeblockPopUp indexOfSelectedItem]-7 : 0];
825 else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
827 /* Here is where we take care of the boolean options that work overtly:
828 no-dct-decimate being on means no-dct-decimate=1, etc. Some options
829 require the inverse, but those will be handled a couple lines down. */
830 if ([sender state] == 0)
832 /* When these options are false, don't include them. They all default
833 to being set off, so they don't need to be mentioned at all. */
838 /* Otherwise, include them as optioname=1 */
839 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,1];
842 else if ([optNameToChange isEqualToString:@"cabac"])
844 /* CABAC is odd, in that it defaults to being on. That means
845 it only needs to be included in the string when turned off. */
846 if ([sender state] == 1)
848 /* It's true so don't include it. */
853 /* Otherwise, include cabac=0 in the string to enable CAVLC. */
854 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,0];
857 else if (([sender indexOfSelectedItem] == 0) && (sender != fX264optAlphaDeblockPopUp) && (sender != fX264optBetaDeblockPopUp) ) // means that "unspecified" is chosen, lets then remove it from the string
859 /* When a widget is at index 0, it's default. Default means don't add to the string.
860 The exception for deblocking is because for those, *both* need to at index 0
861 for it to default, so it's handled separately, above this section. */
864 else if ([optNameToChange isEqualToString:@"me"])
866 /* Motion estimation uses string values, so this switch
867 pairs the widget index with the right value string. */
868 switch ([sender indexOfSelectedItem])
871 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"dia"];
875 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"hex"];
879 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"umh"];
883 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"esa"];
887 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"tesa"];
893 else if ([optNameToChange isEqualToString:@"direct"])
895 /* Direct prediction uses string values, so this switch
896 pairs the right string value with the right widget index. */
897 switch ([sender indexOfSelectedItem])
900 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
904 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"spatial"];
908 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"temporal"];
912 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"auto"];
919 else if ([optNameToChange isEqualToString:@"analyse"])
921 /* Analysis uses string values as well. */
922 switch ([sender indexOfSelectedItem])
925 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"none"];
929 thisOpt = [NSString stringWithFormat:@"%@=%@",optName,@"all"];
936 else if ([optNameToChange isEqualToString:@"merange"])
938 /* Motion estimation range uses an odd array offset because in addition
939 to starting with index 0 as default, index 1 starts at 4 instead of 1,
940 because merange can't go below 4. So it has to be handled separately. */
941 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]+3];
943 else // we have a valid value to change, so change it
945 if ( [sender indexOfSelectedItem] != 0 )
946 /* Here's our general case, that catches things like ref frames and b-frames.
947 Basically, any options that are PopUp menus with index 0 as default and
948 index 1 as 1, with numerical values, are all handled right here. All of
949 the above stuff is for the exceptions to the general case. */
950 thisOpt = [NSString stringWithFormat:@"%@=%d",optName,[sender indexOfSelectedItem]-1];
955 /* Construct New String for opts here */
956 if ([thisOpt isEqualToString:@""])
958 /* Blank option, so just add it to the string. (Why?) */
959 changedOptString = [NSString stringWithFormat:@"%@%@",changedOptString,thisOpt];
963 if ([changedOptString isEqualToString:@""])
965 /* No existing string, make the string this option. */
966 changedOptString = [NSString stringWithFormat:@"%@",thisOpt];
970 /* Existing string, existing option. Append the
971 option to the string, preceding it with a colon. */
972 changedOptString = [NSString stringWithFormat:@"%@:%@",changedOptString,thisOpt];
977 /* Change the dislayed option string to reflect the new modified settings */
978 [fDisplayX264Options setStringValue:[NSString stringWithFormat:changedOptString]];
980 else // if none exists, add it to the string
982 /* This is where options that aren't already in the string are handled. */
983 if ([[fDisplayX264Options stringValue] isEqualToString: @""])
985 /* The option might not be in the string because the
986 string is empty. Handle this possibility first. */
987 if ([optNameToChange isEqualToString:@"me"])
989 /* Special case for motion estimation, which uses string values
990 that need to be paired up with the equivalent widget index. */
991 switch ([sender indexOfSelectedItem])
994 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
995 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
999 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1000 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
1004 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1005 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
1009 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1010 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
1014 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1015 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"tesa"]]];
1022 else if ([optNameToChange isEqualToString:@"direct"])
1024 /* Special case for direct prediction, which uses string values
1025 that need to be paired up with the equivalent widget index. */
1026 switch ([sender indexOfSelectedItem])
1029 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1030 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
1034 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1035 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
1039 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1040 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
1044 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1045 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
1052 else if ([optNameToChange isEqualToString:@"analyse"])
1054 /* Special case for partition analysis, which uses string values
1055 that need to be paired up with the equivalent widget index. */
1056 switch ([sender indexOfSelectedItem])
1059 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1060 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
1064 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1065 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
1073 else if ([optNameToChange isEqualToString:@"merange"])
1075 /* Special case for motion estimation range, which uses
1076 a widget index offset of 3. This is because the
1077 first valid value after default is four, not zero. */
1078 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1079 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
1081 else if ([optNameToChange isEqualToString:@"deblock"])
1083 /* Very special case for deblock. Uses a weird widget index offset
1084 of 7, because the first value after default is -6, rather than 0.
1085 As well, deblock only goes to default when *both* alpha and beta
1086 are zero. If only one is zero, you can't mark it down as default.
1087 Instead, mark that one down as literally 0. This is because when
1088 widgets are at default values, they aren't included in the string.
1089 If only one filter is at 0, both need to be overtly specified. */
1090 [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]]];
1092 else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
1094 /* This covers all the boolean options that need to be specified only when true. */
1095 if ([sender state] == 0)
1097 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
1101 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1102 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
1105 else if ([optNameToChange isEqualToString:@"cabac"])
1107 /* CABAC is weird in that you need the inverse. Only include in the string
1108 when cabac=0, because cabac=1 is the default. Turning it off means CAVLC. */
1109 if ([sender state] == 1)
1111 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@""]];
1115 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1116 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
1121 if ( [sender indexOfSelectedItem] != 0 )
1122 /* General case to cover all the normal PopUp widgets, like ref and b-frames. */
1123 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@=%@",
1124 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
1129 /* The string isn't empty, and the option isn't already in it,
1130 so it will need to be appended to the string with a colon. */
1131 if ([optNameToChange isEqualToString:@"me"])
1133 /* Special case for motion estimation, which uses string values
1134 that need to be paired up with the equivalent widget index. */
1135 switch ([sender indexOfSelectedItem])
1138 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1139 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1140 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"dia"]]];
1144 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1145 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1146 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"hex"]]];
1150 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1151 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1152 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"umh"]]];
1156 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1157 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1158 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"esa"]]];
1162 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1163 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1164 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"tesa"]]];
1171 else if ([optNameToChange isEqualToString:@"direct"])
1173 /* Special case for direct prediction, which uses string values
1174 that need to be paired up with the equivalent widget index. */
1175 switch ([sender indexOfSelectedItem])
1178 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1179 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1180 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
1184 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1185 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1186 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"spatial"]]];
1190 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1191 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1192 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"temporal"]]];
1196 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1197 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1198 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"auto"]]];
1205 else if ([optNameToChange isEqualToString:@"analyse"])
1207 /* Special case for partition analysis, which uses string values
1208 that need to be paired up with the equivalent widget index. */
1209 switch ([sender indexOfSelectedItem])
1212 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1213 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1214 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"none"]]];
1218 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",
1219 [NSString stringWithFormat:[fDisplayX264Options stringValue]],
1220 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"all"]]];
1228 else if ([optNameToChange isEqualToString:@"merange"])
1230 /* Motion estimation range uses a weird offset since its index goes
1231 0: default, 1: 4, because the first valid value is 4, not 1. */
1232 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1233 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]+3]]];
1235 else if ([optNameToChange isEqualToString:@"deblock"])
1237 /* Deblock is really weird because it has two values, and if only one is default, both
1238 still need to be specified directly. with the default one at zero. To make deblock
1239 just a little more fun, values start at -6 instead of at zero. */
1240 [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]]];
1242 else if /*Boolean Switches*/ ([optNameToChange isEqualToString:@"mixed-refs"] || [optNameToChange isEqualToString:@"weightb"] || [optNameToChange isEqualToString:@"b-pyramid"] || [optNameToChange isEqualToString:@"no-fast-pskip"] || [optNameToChange isEqualToString:@"no-dct-decimate"] || [optNameToChange isEqualToString:@"8x8dct"] )
1244 /* Covers all the normal booleans, that only need to be included in the string when they're true. */
1245 if ([sender state] == 0)
1247 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
1251 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1252 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
1255 else if ([optNameToChange isEqualToString:@"cabac"])
1257 /* CABAC is weird, in that it's an inverse. Only include it in the string when it's false. */
1258 if ([sender state] == 1)
1260 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]]]];
1264 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1265 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender state]]]];
1270 /* General case to handle the normal PopUp widgets like ref and b-frames. */
1271 if ( [sender indexOfSelectedItem] != 0 )
1272 [fDisplayX264Options setStringValue:[NSString stringWithFormat:@"%@:%@=%@",[NSString stringWithFormat:[fDisplayX264Options stringValue]],
1273 [NSString stringWithFormat:optNameToChange],[NSString stringWithFormat:@"%d",[sender indexOfSelectedItem]-1]]];
1278 /* We now need to reset the opt widgets since we changed some stuff */
1279 [self X264AdvancedOptionsSet:sender];