2 using System.Collections.Generic;
\r
4 using System.Windows.Forms;
\r
6 namespace Handbrake.Functions
\r
10 Boolean NoWidgetUpdate = false;
\r
13 /// Reset all components to defaults and clears the x264 rtf box
\r
15 public void reset2Defaults(frmMain mainWindow)
\r
17 mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked;
\r
18 mainWindow.check_bFrameDistortion.CheckState = CheckState.Unchecked;
\r
19 mainWindow.check_BidirectionalRefinement.CheckState = CheckState.Unchecked;
\r
20 mainWindow.check_Cabac.CheckState = CheckState.Checked;
\r
21 mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked;
\r
22 mainWindow.check_noDCTDecimate.CheckState = CheckState.Unchecked;
\r
23 mainWindow.check_noFastPSkip.CheckState = CheckState.Unchecked;
\r
24 mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
25 mainWindow.check_weightedBFrames.CheckState = CheckState.Unchecked;
\r
26 mainWindow.drop_analysis.SelectedIndex = 0;
\r
27 mainWindow.drop_bFrames.SelectedIndex = 0;
\r
28 mainWindow.drop_deblockAlpha.SelectedIndex = 0;
\r
29 mainWindow.drop_deblockBeta.SelectedIndex = 0;
\r
30 mainWindow.drop_directPrediction.SelectedIndex = 0;
\r
31 mainWindow.drop_MotionEstimationMethod.SelectedIndex = 0;
\r
32 mainWindow.drop_MotionEstimationRange.SelectedIndex = 0;
\r
33 mainWindow.drop_refFrames.SelectedIndex = 0;
\r
34 mainWindow.drop_subpixelMotionEstimation.SelectedIndex = 0;
\r
35 mainWindow.drop_trellis.SelectedIndex = 0;
\r
37 mainWindow.rtf_x264Query.Text = "";
\r
41 /// Update GUI componets from the current x264 rtf string
\r
43 public void X264_SetCurrentSettingsInPanel(frmMain mainWindow)
\r
45 // When the widgets are changed, we don't want them to update the text box again. No Need.
\r
46 // This boolean controls the Widget Change function
\r
49 /* Set widgets depending on the opt string in field */
\r
50 String thisOpt; // The separated option such as "bframes=3"
\r
51 String optName = ""; // The option name such as "bframes"
\r
52 String optValue = "";// The option value such as "3"
\r
53 String[] currentOptsArray;
\r
55 //Set currentOptString to the contents of the text box.
\r
56 String currentOptString = mainWindow.rtf_x264Query.Text.Replace("\n", "");
\r
58 /*verify there is an opt string to process */
\r
59 if (currentOptString.Contains("="))
\r
61 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
62 currentOptsArray = currentOptString.Split(':');
\r
64 /*iterate through the array and get <opts> and <values*/
\r
66 int currentOptsArrayCount = currentOptsArray.Length;
\r
69 /*iterate through the array and get <opts> and <values*/
\r
70 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
73 thisOpt = currentOptsArray[loopcounter];
\r
74 String[] splitOptRange = thisOpt.Split('=');
\r
76 if (thisOpt.Contains("="))
\r
78 optName = splitOptRange[0];
\r
79 optValue = splitOptRange[1];
\r
81 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
82 they need to be added here. This should be moved to its own method probably*/
\r
84 /*bframes NSPopUpButton*/
\r
85 if (optName.Equals("bframes"))
\r
86 mainWindow.drop_bFrames.SelectedItem = optValue;
\r
88 /*ref NSPopUpButton*/
\r
89 else if (optName.Equals("ref"))
\r
90 mainWindow.drop_refFrames.SelectedItem = optValue;
\r
92 /*No Fast PSkip NSPopUpButton*/
\r
93 else if (optName.Equals("no-fast-pskip"))
\r
94 mainWindow.check_noFastPSkip.CheckState = CheckState.Checked;
\r
96 /*No Dict Decimate NSPopUpButton*/
\r
97 else if (optName.Equals("no-dct-decimate"))
\r
98 mainWindow.check_noDCTDecimate.CheckState = CheckState.Checked;
\r
100 /*Sub Me NSPopUpButton*/
\r
101 else if (optName.Equals("subq"))
\r
102 mainWindow.drop_subpixelMotionEstimation.SelectedItem = optValue;
\r
104 /*Trellis NSPopUpButton*/
\r
105 else if (optName.Equals("trellis"))
\r
106 mainWindow.drop_trellis.SelectedItem = optValue;
\r
108 /*Mixed Refs NSButton*/
\r
109 else if (optName.Equals("mixed-refs"))
\r
110 mainWindow.check_mixedReferences.CheckState = CheckState.Checked;
\r
112 /*Motion Estimation NSPopUpButton*/
\r
113 else if (optName.Equals("me"))
\r
115 if (optValue.Equals("dia"))
\r
116 mainWindow.drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
117 else if (optValue.Equals("hex"))
\r
118 mainWindow.drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
119 else if (optValue.Equals("umh"))
\r
120 mainWindow.drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
121 else if (optValue.Equals("esa"))
\r
122 mainWindow.drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
125 /*ME Range NSPopUpButton*/
\r
126 else if (optName.Equals("merange"))
\r
127 mainWindow.drop_MotionEstimationRange.SelectedItem = optValue;
\r
129 /*Weighted B-Frames NSPopUpButton*/
\r
130 else if (optName.Equals("weightb"))
\r
131 mainWindow.check_weightedBFrames.CheckState = CheckState.Checked;
\r
133 /*BRDO NSPopUpButton*/
\r
134 else if (optName.Equals("brdo"))
\r
135 mainWindow.check_bFrameDistortion.CheckState = CheckState.Checked;
\r
137 /*B Pyramid NSPopUpButton*/
\r
138 else if (optName.Equals("b-pyramid"))
\r
139 mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Checked;
\r
141 /*Bidirectional Motion Estimation Refinement NSPopUpButton*/
\r
142 else if (optName.Equals("bime"))
\r
143 mainWindow.check_BidirectionalRefinement.CheckState = CheckState.Checked;
\r
145 /*Direct B-frame Prediction NSPopUpButton*/
\r
146 else if (optName.Equals("direct"))
\r
148 if (optValue == "auto")
\r
149 optValue = "Automatic";
\r
151 if (optValue != "")
\r
153 Char[] letters = optValue.ToCharArray();
\r
154 letters[0] = Char.ToUpper(letters[0]);
\r
155 optValue = new string(letters);
\r
158 mainWindow.drop_directPrediction.SelectedItem = optValue;
\r
161 /*Deblocking NSPopUpButtons*/
\r
162 else if (optName.Equals("deblock"))
\r
164 string alphaDeblock = "";
\r
165 string betaDeblock = "";
\r
167 string[] splitDeblock = optValue.Split(',');
\r
168 alphaDeblock = splitDeblock[0];
\r
169 betaDeblock = splitDeblock[1];
\r
171 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
\r
173 mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
\r
174 mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
\r
178 if (!alphaDeblock.Equals("0"))
\r
179 mainWindow.drop_deblockAlpha.SelectedItem = alphaDeblock;
\r
181 mainWindow.drop_deblockAlpha.SelectedItem = "0";
\r
183 if (!betaDeblock.Replace("\n", "").Equals("0"))
\r
184 mainWindow.drop_deblockBeta.SelectedItem = betaDeblock.Replace("\n", "");
\r
186 mainWindow.drop_deblockBeta.SelectedItem = "0";
\r
189 /* Analysis NSPopUpButton */
\r
190 else if (optName.Equals("analyse"))
\r
193 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
194 mainWindow.drop_analysis.SelectedItem = "Default (some)";
\r
195 if (optValue.Equals("none"))
\r
196 mainWindow.drop_analysis.SelectedItem = "None";
\r
197 if (optValue.Equals("all"))
\r
198 mainWindow.drop_analysis.SelectedItem = "All";
\r
200 /* 8x8 DCT NSButton */
\r
201 else if (optName.Equals("8x8dct"))
\r
202 mainWindow.check_8x8DCT.CheckState = CheckState.Checked;
\r
204 /* CABAC NSButton */
\r
205 else if (optName.Equals("cabac"))
\r
206 mainWindow.check_Cabac.CheckState = CheckState.Unchecked;
\r
213 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
215 public void X264_StandardizeOptString(frmMain mainWindow)
\r
217 /* Set widgets depending on the opt string in field */
\r
218 String thisOpt; // The separated option such as "bframes=3"
\r
219 String optName = ""; // The option name such as "bframes"
\r
220 String optValue = "";// The option value such as "3"
\r
221 String changedOptString = "";
\r
222 String[] currentOptsArray;
\r
224 /*First, we get an opt string to process */
\r
225 String currentOptString = mainWindow.rtf_x264Query.Text;
\r
227 /*verify there is an opt string to process */
\r
228 if (currentOptString.Contains("="))
\r
230 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
231 currentOptsArray = currentOptString.Split(':');
\r
233 /*iterate through the array and get <opts> and <values*/
\r
234 //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
\r
236 int currentOptsArrayCount = currentOptsArray.Length;
\r
237 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
239 thisOpt = currentOptsArray[loopcounter];
\r
240 if (currentOptsArray[currentOptsArrayCount - 1] == "")
\r
243 String[] splitOptRange = thisOpt.Split('=');
\r
246 if (thisOpt.Contains("="))
\r
248 optName = splitOptRange[0];
\r
249 optValue = splitOptRange[1];
\r
251 /* Standardize the names here depending on whats in the string */
\r
252 optName = X264_StandardizeOptNames(optName);
\r
253 thisOpt = optName + "=" + optValue;
\r
255 else // No value given so we use a default of "1"
\r
258 /* Standardize the names here depending on whats in the string */
\r
259 optName = X264_StandardizeOptNames(optName);
\r
260 thisOpt = optName + "=1";
\r
264 /* Construct New String for opts here */
\r
266 changedOptString = changedOptString + thisOpt;
\r
269 if (changedOptString == "")
\r
270 changedOptString = thisOpt;
\r
272 changedOptString = changedOptString + ":" + thisOpt;
\r
277 /* Change the option string to reflect the new standardized option string */
\r
278 if (changedOptString != "")
\r
279 mainWindow.rtf_x264Query.Text = changedOptString;
\r
283 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
285 public void on_x264_WidgetChange(string sender, frmMain mainWindow)
\r
287 if (NoWidgetUpdate == false)
\r
289 String optNameToChange = sender;
\r
290 String currentOptString = mainWindow.rtf_x264Query.Text;
\r
292 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
293 the first character of the opt string (hence the ":") */
\r
294 String checkOptNameToChange = ":" + optNameToChange + "=";
\r
295 String checkOptNameToChangeBegin = optNameToChange + "=";
\r
297 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
298 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
299 hasFullOption(currentOptString, optNameToChange, mainWindow);
\r
300 else // IF there is no options in the rich text box!
\r
301 hasNoOptions(optNameToChange, mainWindow);
\r
305 NoWidgetUpdate = false;
\r
310 // Some Private Functions used by the above Public Functions
\r
312 * Used by on_x264_WidgetChange()
\r
313 * Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
314 * Basically, it updates the current option that the widget corrosponds to, if it is already in thes string
\r
315 * otherwise, it adds it to the string.
\r
317 private void hasFullOption(string currentOptString, string optNameToChange, frmMain mainWindow)
\r
319 String thisOpt; // The separated option such as "bframes=3"
\r
320 String optName = ""; // The option name such as "bframes"
\r
321 String optValue = ""; // The option value such as "3"
\r
322 String[] currentOptsArray;
\r
324 /* Create new empty opt string*/
\r
325 String changedOptString = "";
\r
327 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
328 currentOptsArray = currentOptString.Split(':');
\r
330 /*iterate through the array and get <opts> and <values*/
\r
331 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
333 thisOpt = currentOptsArray[loopcounter];
\r
335 if (thisOpt.Contains("="))
\r
337 string[] splitOptRange = thisOpt.Split('=');
\r
339 optName = splitOptRange[0]; // e.g bframes
\r
340 optValue = splitOptRange[1]; // e.g 2
\r
343 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
344 * they need to be added here. This should be moved to its own method probably
\r
345 * If the optNameToChange is found, appropriately change the value or delete it if
\r
346 * "unspecified" is set.
\r
348 if (optName.Equals(optNameToChange))
\r
350 if (optNameToChange.Equals("deblock"))
\r
352 String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();
\r
353 String db = mainWindow.drop_deblockBeta.SelectedItem.ToString();
\r
355 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
357 mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
\r
358 mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
\r
361 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
363 mainWindow.drop_deblockBeta.SelectedItem = "0";
\r
364 thisOpt = "deblock=" + da + ",0";
\r
366 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
368 mainWindow.drop_deblockAlpha.SelectedItem = "0";
\r
369 thisOpt = "deblock=0," + db;
\r
371 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
372 thisOpt = "deblock=" + da + "," + db;
\r
375 else if (optNameToChange.Equals("mixed-refs"))
\r
377 if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)
\r
378 thisOpt = "mixed-refs=1";
\r
382 else if (optNameToChange.Equals("weightb"))
\r
384 if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)
\r
385 thisOpt = "weightb=1";
\r
389 else if (optNameToChange.Equals("brdo"))
\r
391 if (mainWindow.check_bFrameDistortion.CheckState == CheckState.Checked)
\r
392 thisOpt = "brdo=1";
\r
396 else if (optNameToChange.Equals("bime"))
\r
398 if (mainWindow.check_BidirectionalRefinement.CheckState == CheckState.Checked)
\r
399 thisOpt = "bime=1";
\r
403 else if (optNameToChange.Equals("b-pyramid"))
\r
405 if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)
\r
406 thisOpt = "b-pyramid=1";
\r
410 else if (optNameToChange.Equals("no-fast-pskip"))
\r
412 if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)
\r
413 thisOpt = "no-fast-pskip=1";
\r
417 else if (optNameToChange.Equals("no-dct-decimate"))
\r
419 if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)
\r
420 thisOpt = "no-dct-decimate=1";
\r
424 else if (optNameToChange.Equals("8x8dct"))
\r
426 if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)
\r
427 thisOpt = "8x8dct=1";
\r
431 else if (optNameToChange.Equals("cabac"))
\r
433 if (mainWindow.check_Cabac.CheckState == CheckState.Checked)
\r
436 thisOpt = "cabac=0";
\r
438 else if (optNameToChange.Equals("me"))
\r
440 switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)
\r
443 thisOpt = "me=dia";
\r
447 thisOpt = "me=hex";
\r
451 thisOpt = "me=umh";
\r
455 thisOpt = "me=esa";
\r
463 else if (optNameToChange.Equals("direct"))
\r
465 switch (mainWindow.drop_directPrediction.SelectedIndex)
\r
468 thisOpt = "direct=none";
\r
472 thisOpt = "direct=spatial";
\r
476 thisOpt = "direct=temporal";
\r
480 thisOpt = "direct=auto";
\r
488 else if (optNameToChange.Equals("analyse"))
\r
490 switch (mainWindow.drop_analysis.SelectedIndex)
\r
493 thisOpt = "analyse=none";
\r
497 thisOpt = "analyse=all";
\r
505 else if (optNameToChange.Equals("merange"))
\r
507 if (!mainWindow.drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default"))
\r
508 thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem.ToString();
\r
512 else if (optNameToChange.Equals("ref"))
\r
514 if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
515 thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
\r
519 else if (optNameToChange.Equals("bframes"))
\r
521 String value = mainWindow.drop_bFrames.SelectedItem.ToString();
\r
522 if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
523 thisOpt = "bframes=" + value;
\r
527 else if (optNameToChange.Equals("subq"))
\r
529 String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
530 if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
531 thisOpt = "subq=" + value;
\r
535 else if (optNameToChange.Equals("trellis"))
\r
537 String value = mainWindow.drop_trellis.SelectedItem.ToString();
\r
538 if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))
\r
539 thisOpt = "trellis=" + value;
\r
547 /* Construct New String for opts here */
\r
548 if (!thisOpt.Equals(""))
\r
550 if (changedOptString.Equals(""))
\r
551 changedOptString = thisOpt;
\r
553 changedOptString = changedOptString + ":" + thisOpt;
\r
557 /* Change the option string to reflect the new mod settings */
\r
558 mainWindow.rtf_x264Query.Text = changedOptString;
\r
562 * Used by on_x264_WidgetChange()
\r
563 * Called when the current x264 option string contains no options.
\r
564 * This simply adds the option to the x264 query in the gui.
\r
566 private void hasNoOptions(string optNameToChange, frmMain mainWindow)
\r
568 // If the text box is blank
\r
569 if (mainWindow.rtf_x264Query.Text == "")
\r
571 if (optNameToChange.Equals("me"))
\r
573 switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)
\r
576 mainWindow.rtf_x264Query.Text = "me=dia";
\r
580 mainWindow.rtf_x264Query.Text = "me=hex";
\r
585 mainWindow.rtf_x264Query.Text = "me=umh";
\r
589 mainWindow.rtf_x264Query.Text = "me=esa";
\r
596 else if (optNameToChange.Equals("direct"))
\r
598 switch (mainWindow.drop_directPrediction.SelectedIndex)
\r
601 mainWindow.rtf_x264Query.Text = "direct=none";
\r
605 mainWindow.rtf_x264Query.Text = "direct=spatial";
\r
609 mainWindow.rtf_x264Query.Text = "direct=temporal";
\r
613 mainWindow.rtf_x264Query.Text = "direct=auto";
\r
620 else if (optNameToChange.Equals("analyse"))
\r
622 switch (mainWindow.drop_analysis.SelectedIndex)
\r
625 mainWindow.rtf_x264Query.Text = "analyse=none";
\r
629 mainWindow.rtf_x264Query.Text = "analyse=all";
\r
637 else if (optNameToChange.Equals("merange"))
\r
639 int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;
\r
640 mainWindow.rtf_x264Query.Text = "merange=" + value.ToString();
\r
642 else if (optNameToChange.Equals("deblock"))
\r
644 String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();
\r
645 String db = mainWindow.drop_deblockBeta.SelectedItem.ToString();
\r
647 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
649 mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
\r
650 mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
\r
651 mainWindow.rtf_x264Query.Text = "";
\r
653 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
655 mainWindow.drop_deblockBeta.SelectedItem = "0";
\r
656 mainWindow.rtf_x264Query.Text = "deblock=" + da + ",0";
\r
658 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
660 mainWindow.drop_deblockAlpha.SelectedItem = "0";
\r
661 mainWindow.rtf_x264Query.Text = "deblock=0," + db;
\r
663 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
665 mainWindow.rtf_x264Query.Text = "deblock=" + da + "," + db;
\r
668 else if (optNameToChange.Equals("mixed-refs"))
\r
670 if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)
\r
671 mainWindow.rtf_x264Query.Text = "mixed-refs=1";
\r
673 mainWindow.rtf_x264Query.Text = "";
\r
675 else if (optNameToChange.Equals("weightb"))
\r
677 if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)
\r
678 mainWindow.rtf_x264Query.Text = "weightb=1";
\r
680 mainWindow.rtf_x264Query.Text = "";
\r
682 else if (optNameToChange.Equals("brdo"))
\r
684 if (mainWindow.check_bFrameDistortion.CheckState == CheckState.Checked)
\r
685 mainWindow.rtf_x264Query.Text = "brdo=1";
\r
687 mainWindow.rtf_x264Query.Text = "";
\r
689 else if (optNameToChange.Equals("bime"))
\r
691 if (mainWindow.check_BidirectionalRefinement.CheckState == CheckState.Checked)
\r
692 mainWindow.rtf_x264Query.Text = "bime=1";
\r
694 mainWindow.rtf_x264Query.Text = "";
\r
696 else if (optNameToChange.Equals("b-pyramid"))
\r
698 if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)
\r
699 mainWindow.rtf_x264Query.Text = "b-pyramid=1";
\r
701 mainWindow.rtf_x264Query.Text = "";
\r
703 else if (optNameToChange.Equals("no-fast-pskip"))
\r
705 if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)
\r
706 mainWindow.rtf_x264Query.Text = "no-fast-pskip=1";
\r
708 mainWindow.rtf_x264Query.Text = "";
\r
710 else if (optNameToChange.Equals("no-dct-decimate"))
\r
712 if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)
\r
713 mainWindow.rtf_x264Query.Text = "no-dct-decimate=1";
\r
715 mainWindow.rtf_x264Query.Text = "";
\r
717 else if (optNameToChange.Equals("8x8dct"))
\r
719 if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)
\r
720 mainWindow.rtf_x264Query.Text = "8x8dct=1";
\r
722 mainWindow.rtf_x264Query.Text = "";
\r
724 else if (optNameToChange.Equals("cabac"))
\r
726 if (mainWindow.check_Cabac.CheckState == CheckState.Checked)
\r
727 mainWindow.rtf_x264Query.Text = "";
\r
729 mainWindow.rtf_x264Query.Text = "cabac=0";
\r
731 else if (optNameToChange.Equals("ref"))
\r
733 string refItem = mainWindow.drop_refFrames.SelectedItem.ToString();
\r
734 if (!refItem.Contains("default"))
\r
735 mainWindow.rtf_x264Query.Text = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
\r
737 else if (optNameToChange.Equals("bframes"))
\r
739 String value = mainWindow.drop_bFrames.SelectedItem.ToString();
\r
740 if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
741 mainWindow.rtf_x264Query.Text = "bframes=" + value;
\r
743 else if (optNameToChange.Equals("subq"))
\r
745 String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
746 if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
747 mainWindow.rtf_x264Query.Text = "subq=" + value;
\r
749 else if (optNameToChange.Equals("trellis"))
\r
751 String value = mainWindow.drop_trellis.SelectedItem.ToString();
\r
752 if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))
\r
753 mainWindow.rtf_x264Query.Text = "trellis=" + value;
\r
756 //*******************************************************
\r
758 else // There was some text in the box. This deals with options with no value. e.g "no-fast-pskip"
\r
760 //*******************************************************
\r
761 if (optNameToChange.Equals("me"))
\r
763 switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)
\r
766 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=dia";
\r
770 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=hex";
\r
774 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=umh";
\r
778 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=esa";
\r
785 else if (optNameToChange.Equals("direct"))
\r
787 switch (mainWindow.drop_directPrediction.SelectedIndex)
\r
790 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=none";
\r
794 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=spatial";
\r
798 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=temporal";
\r
802 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=auto";
\r
809 else if (optNameToChange.Equals("analyse"))
\r
811 switch (mainWindow.drop_analysis.SelectedIndex)
\r
814 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":analyse=none";
\r
818 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":analyse=all";
\r
826 else if (optNameToChange.Equals("merange"))
\r
828 int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;
\r
829 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":merange=" + value.ToString();
\r
831 else if (optNameToChange.Equals("deblock"))
\r
833 String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();
\r
834 String db = mainWindow.drop_deblockBeta.Text.ToString();
\r
836 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
838 mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
\r
839 mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
\r
843 if (db.Contains("Default"))
\r
846 if (da.Contains("Default"))
\r
849 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":deblock=" + da + "," + db;
\r
852 else if (optNameToChange.Equals("mixed-refs"))
\r
854 if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)
\r
855 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":mixed-refs=1";
\r
857 else if (optNameToChange.Equals("weightb"))
\r
859 if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)
\r
860 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":weightb=1";
\r
862 else if (optNameToChange.Equals("brdo"))
\r
864 if (mainWindow.check_bFrameDistortion.CheckState == CheckState.Checked)
\r
865 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":brdo=1";
\r
867 else if (optNameToChange.Equals("bime"))
\r
869 if (mainWindow.check_BidirectionalRefinement.CheckState == CheckState.Checked)
\r
870 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":bime=1";
\r
872 else if (optNameToChange.Equals("b-pyramid"))
\r
874 if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)
\r
875 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":b-pyramid=1";
\r
877 else if (optNameToChange.Equals("no-fast-pskip"))
\r
879 if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)
\r
880 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":no-fast-pskip=1";
\r
882 else if (optNameToChange.Equals("no-dct-decimate"))
\r
884 if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)
\r
885 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":no-dct-decimate=1";
\r
887 else if (optNameToChange.Equals("8x8dct"))
\r
889 if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)
\r
890 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":8x8dct=1";
\r
892 else if (optNameToChange.Equals("cabac"))
\r
894 if (mainWindow.check_Cabac.CheckState == CheckState.Checked)
\r
895 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text;
\r
897 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":cabac=0";
\r
899 else if (optNameToChange.Equals("ref"))
\r
901 if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
902 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
\r
904 else if (optNameToChange.Equals("bframes"))
\r
906 int value = mainWindow.drop_bFrames.SelectedIndex;
\r
908 if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
909 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":bframes=" + value.ToString();
\r
911 else if (optNameToChange.Equals("subq"))
\r
913 String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
914 if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
915 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":subq=" + value;
\r
917 else if (optNameToChange.Equals("trellis"))
\r
919 if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))
\r
920 mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":trellis=" + mainWindow.drop_trellis.SelectedItem.ToString();
\r
926 * Take a single option and standardize it. Returns as a String
\r
927 * Input: String. - Single X264 Option. Name only
\r
928 * Output: String - Single X264 Option. Name only. Changed to standard format
\r
930 private string X264_StandardizeOptNames(String cleanOptNameString)
\r
932 String input = cleanOptNameString;
\r
933 if (input.Equals("ref") || input.Equals("frameref"))
\r
935 cleanOptNameString = "ref";
\r
938 /*No Fast PSkip nofast_pskip*/
\r
939 if (input.Equals("no-fast-pskip") || input.Equals("no_fast_pskip") || input.Equals("nofast_pskip"))
\r
941 cleanOptNameString = "no-fast-pskip";
\r
944 /*No Dict Decimate*/
\r
945 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
947 cleanOptNameString = "no-dct-decimate";
\r
951 if (input.Equals("subme"))
\r
953 cleanOptNameString = "subq";
\r
957 if (input.Equals("me-range") || input.Equals("me_range"))
\r
959 cleanOptNameString = "merange";
\r
963 if (input.Equals("weight-b") || input.Equals("weight_b"))
\r
965 cleanOptNameString = "weightb";
\r
969 if (input.Equals("b-rdo") || input.Equals("b_rdo"))
\r
971 cleanOptNameString = "brdo";
\r
975 if (input.Equals("b_pyramid"))
\r
977 cleanOptNameString = "b-pyramid";
\r
980 /*Direct Prediction*/
\r
981 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
983 cleanOptNameString = "direct";
\r
987 if (input.Equals("filter"))
\r
989 cleanOptNameString = "deblock";
\r
993 if (input.Equals("partitions"))
\r
995 cleanOptNameString = "analyse";
\r
998 return cleanOptNameString;
\r