2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
6 namespace Handbrake.Controls
\r
9 using System.Globalization;
\r
10 using System.Windows.Forms;
\r
15 public partial class x264Panel : UserControl
\r
18 * TODO This code was ported from the obj-c MacGUI code. It's really messy and could really do with being cleaned up
\r
22 private CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
\r
25 /// Initializes a new instance of the <see cref="x264Panel"/> class.
\r
26 /// Initializes a new instance of the x264 panel user control
\r
30 InitializeComponent();
\r
32 if (Properties.Settings.Default.tooltipEnable)
\r
33 ToolTip.Active = true;
\r
39 /// Gets or sets the X264 query string
\r
41 public string X264Query
\r
45 return rtf_x264Query.Text;
\r
49 rtf_x264Query.Text = value;
\r
54 /// Reset all components to defaults and clears the x264 rtf box
\r
56 public void Reset2Defaults()
\r
58 check_8x8DCT.CheckState = CheckState.Checked;
\r
59 check_Cabac.CheckState = CheckState.Checked;
\r
60 check_weightp.CheckState = CheckState.Checked;
\r
61 check_noDCTDecimate.CheckState = CheckState.Unchecked;
\r
62 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
63 drop_analysis.SelectedIndex = 0;
\r
64 drop_bFrames.SelectedIndex = 0;
\r
65 drop_deblockAlpha.SelectedIndex = 0;
\r
66 drop_deblockBeta.SelectedIndex = 0;
\r
67 drop_directPrediction.SelectedIndex = 0;
\r
68 drop_MotionEstimationMethod.SelectedIndex = 0;
\r
69 drop_MotionEstimationRange.SelectedIndex = 0;
\r
70 drop_refFrames.SelectedIndex = 0;
\r
71 drop_subpixelMotionEstimation.SelectedIndex = 0;
\r
72 drop_trellis.SelectedIndex = 0;
\r
73 slider_psyrd.Value = 10;
\r
74 slider_psytrellis.Value = 0;
\r
75 drop_adaptBFrames.SelectedIndex = 0;
\r
76 slider_adaptiveQuantStrength.Value = slider_adaptiveQuantStrength.Maximum / 2;
\r
78 rtf_x264Query.Text = string.Empty;
\r
81 #region Standardize Option String
\r
83 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
85 public void StandardizeOptString()
\r
87 /* Set widgets depending on the opt string in field */
\r
88 string thisOpt; // The separated option such as "bframes=3"
\r
89 string optName; // The option name such as "bframes"
\r
90 string optValue; // The option value such as "3"
\r
91 string changedOptString = string.Empty;
\r
92 string[] currentOptsArray;
\r
94 /*First, we get an opt string to process */
\r
95 string currentOptString = rtf_x264Query.Text;
\r
97 /*verify there is an opt string to process */
\r
98 if (currentOptString.Contains("="))
\r
100 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
101 currentOptsArray = currentOptString.Split(':');
\r
103 /*iterate through the array and get <opts> and <values*/
\r
105 int currentOptsArrayCount = currentOptsArray.Length;
\r
106 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
108 thisOpt = currentOptsArray[loopcounter];
\r
109 if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
\r
112 string[] splitOptRange = thisOpt.Split('=');
\r
113 if (thisOpt != string.Empty)
\r
115 if (thisOpt.Contains("="))
\r
117 optName = splitOptRange[0];
\r
118 optValue = splitOptRange[1];
\r
120 /* Standardize the names here depending on whats in the string */
\r
121 optName = StandardizeOptName(optName);
\r
122 thisOpt = optName + "=" + optValue;
\r
124 else // No value given so we use a default of "1"
\r
127 /* Standardize the names here depending on whats in the string */
\r
128 optName = StandardizeOptName(optName);
\r
129 thisOpt = optName + "=1";
\r
133 /* Construct New String for opts here */
\r
134 if (thisOpt == string.Empty)
\r
135 changedOptString = changedOptString + thisOpt;
\r
138 if (changedOptString == string.Empty)
\r
139 changedOptString = thisOpt;
\r
141 changedOptString = changedOptString + ":" + thisOpt;
\r
146 /* Change the option string to reflect the new standardized option string */
\r
147 if (changedOptString != string.Empty)
\r
148 rtf_x264Query.Text = changedOptString;
\r
152 /// Take a single option and standardize it. Returns as a String
\r
153 /// Input: String. - Single X264 Option. Name only
\r
154 /// Output: String - Single X264 Option. Name only. Changed to standard format
\r
156 /// <param name="cleanOptNameString">a string of x264 options to clean</param>
\r
157 /// <returns>A string containing standardized x264 option names</returns>
\r
158 private static string StandardizeOptName(string cleanOptNameString)
\r
160 string input = cleanOptNameString;
\r
162 /* Reference Frames */
\r
163 if (input.Equals("ref") || input.Equals("frameref"))
\r
164 cleanOptNameString = "ref";
\r
166 /*No Dict Decimate*/
\r
167 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
168 cleanOptNameString = "no-dct-decimate";
\r
171 if (input.Equals("subme"))
\r
172 cleanOptNameString = "subq";
\r
175 if (input.Equals("me-range") || input.Equals("me_range"))
\r
176 cleanOptNameString = "merange";
\r
179 if (input.Equals("b_pyramid"))
\r
180 cleanOptNameString = "b-pyramid";
\r
182 /*Direct Prediction*/
\r
183 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
184 cleanOptNameString = "direct";
\r
187 if (input.Equals("filter"))
\r
188 cleanOptNameString = "deblock";
\r
191 if (input.Equals("partitions"))
\r
192 cleanOptNameString = "analyse";
\r
194 return cleanOptNameString;
\r
199 /// Resets the GUI widgets to the contents of the option string.
\r
201 public void SetCurrentSettingsInPanel()
\r
203 /* Set widgets depending on the opt string in field */
\r
204 string thisOpt; // The separated option such as "bframes=3"
\r
205 string optName; // The option name such as "bframes"
\r
206 string optValue; // The option value such as "3"
\r
207 string[] currentOptsArray;
\r
209 // Set currentOptString to the contents of the text box.
\r
210 string currentOptString = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
212 /*verify there is an opt string to process */
\r
213 if (currentOptString.Contains("="))
\r
215 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
216 currentOptsArray = currentOptString.Split(':');
\r
218 /*iterate through the array and get <opts> and <values*/
\r
220 int currentOptsArrayCount = currentOptsArray.Length;
\r
222 /*iterate through the array and get <opts> and <values*/
\r
223 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
225 thisOpt = currentOptsArray[loopcounter];
\r
226 string[] splitOptRange = thisOpt.Split('=');
\r
228 if (thisOpt.Contains("="))
\r
230 optName = splitOptRange[0];
\r
231 optValue = splitOptRange[1];
\r
233 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
234 they need to be added here. This should be moved to its own method probably*/
\r
238 drop_bFrames.SelectedItem = optValue;
\r
241 drop_refFrames.SelectedItem = optValue;
\r
244 this.check_weightp.CheckState = optValue == "0" ? CheckState.Unchecked : CheckState.Checked;
\r
246 case "no-dct-decimate":
\r
247 check_noDCTDecimate.CheckState = CheckState.Checked;
\r
251 if (int.TryParse(optValue, out subqValue))
\r
253 drop_subpixelMotionEstimation.SelectedIndex = subqValue + 1;
\r
260 drop_trellis.SelectedIndex = 1;
\r
263 drop_trellis.SelectedIndex = 2;
\r
266 drop_trellis.SelectedIndex = 3;
\r
271 if (optValue.Equals("dia"))
\r
272 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
273 else if (optValue.Equals("hex"))
\r
274 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
275 else if (optValue.Equals("umh"))
\r
276 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
277 else if (optValue.Equals("esa"))
\r
278 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
279 else if (optValue.Equals("tesa"))
\r
280 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
283 drop_MotionEstimationRange.SelectedItem = optValue;
\r
287 int.TryParse(optValue, out badapt);
\r
288 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
294 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
297 combo_pyrmidalBFrames.SelectedIndex = 2;
\r
300 combo_pyrmidalBFrames.SelectedIndex = 1;
\r
305 if (optValue == "auto")
\r
306 optValue = "Automatic";
\r
308 if (optValue != string.Empty)
\r
310 char[] letters = optValue.ToCharArray();
\r
311 letters[0] = Char.ToUpper(letters[0]);
\r
312 optValue = new string(letters);
\r
315 drop_directPrediction.SelectedItem = optValue;
\r
318 string[] splitDeblock = optValue.Split(',');
\r
319 string alphaDeblock = splitDeblock[0];
\r
320 string betaDeblock = splitDeblock[1];
\r
322 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", string.Empty).Equals("0"))
\r
324 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
325 drop_deblockBeta.SelectedItem = "Default (0)";
\r
329 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
331 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", string.Empty).Equals("0")
\r
332 ? betaDeblock.Replace("\n", string.Empty)
\r
337 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
338 drop_analysis.SelectedItem = "Default (most)";
\r
339 if (optValue.Equals("none"))
\r
340 drop_analysis.SelectedItem = "None";
\r
341 if (optValue.Equals("i4x4,i8x8"))
\r
342 drop_analysis.SelectedItem = "Some";
\r
343 if (optValue.Equals("all"))
\r
344 drop_analysis.SelectedItem = "All";
\r
347 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
349 case "aq-strength":
\r
351 float.TryParse(optValue, NumberStyles.Float, CultureInfo.InvariantCulture, out value);
\r
353 int.TryParse((value * 10).ToString(), out sliderValue);
\r
354 slider_adaptiveQuantStrength.Value = sliderValue;
\r
357 check_Cabac.CheckState = CheckState.Unchecked;
\r
360 string[] x = optValue.Split(',');
\r
362 double psyrd, psytrellis;
\r
365 // default psy-rd = 1 (10 for the slider)
\r
366 psyrd = double.TryParse(x[0], NumberStyles.Float, CultureInfo.InvariantCulture, out psyrd) ? psyrd * 10 : 10.0;
\r
367 // default psy-trellis = 0
\r
368 psytrellis = double.TryParse(x[1], NumberStyles.Float, CultureInfo.InvariantCulture, out psytrellis) ? psytrellis * 20 : 0.0;
\r
370 int.TryParse(psyrd.ToString(), out val);
\r
371 int.TryParse(psytrellis.ToString(), out val2);
\r
373 slider_psyrd.Value = val;
\r
374 slider_psytrellis.Value = val2;
\r
383 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
385 /// <param name="sender">
\r
388 private void OnX264WidgetChange(string sender)
\r
391 string optNameToChange = sender;
\r
392 string currentOptString = rtf_x264Query.Text;
\r
394 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
395 the first character of the opt string (hence the ":") */
\r
396 string checkOptNameToChange = ":" + optNameToChange + "=";
\r
397 string checkOptNameToChangeBegin = optNameToChange + "=";
\r
399 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
400 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
401 HasOptions(currentOptString, optNameToChange);
\r
402 else // IF there is no options in the rich text box!
\r
403 HasNoOptions(optNameToChange);
\r
407 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
408 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
410 /// <param name="currentOptString">The Current Option String</param>
\r
411 /// <param name="optNameToChange">Name of the option to change</param>
\r
412 private void HasOptions(string currentOptString, string optNameToChange)
\r
414 string thisOpt; // The separated option such as "bframes=3"
\r
415 string optName; // The option name such as "bframes"
\r
416 string[] currentOptsArray;
\r
418 /* Create new empty opt string*/
\r
419 string changedOptString = string.Empty;
\r
421 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
422 currentOptsArray = currentOptString.Split(':');
\r
424 /*iterate through the array and get <opts> and <values*/
\r
425 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
427 thisOpt = currentOptsArray[loopcounter];
\r
429 if (thisOpt.Contains("="))
\r
431 string[] splitOptRange = thisOpt.Split('=');
\r
433 optName = splitOptRange[0]; // e.g bframes
\r
436 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
437 * they need to be added here. This should be moved to its own method probably
\r
438 * If the optNameToChange is found, appropriately change the value or delete it if
\r
439 * "unspecified" is set.
\r
441 if (optName.Equals(optNameToChange))
\r
443 if (optNameToChange.Equals("deblock"))
\r
445 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
446 string db = drop_deblockBeta.SelectedItem.ToString();
\r
448 if (((da.Contains("Default")) && (db.Contains("Default"))) ||
\r
449 ((da.Contains("0")) && (db.Contains("0"))))
\r
451 drop_deblockBeta.SelectedItem = "Default (0)";
\r
452 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
453 thisOpt = string.Empty;
\r
455 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
457 drop_deblockBeta.SelectedItem = "0";
\r
458 thisOpt = "deblock=" + da + ",0";
\r
460 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
462 drop_deblockAlpha.SelectedItem = "0";
\r
463 thisOpt = "deblock=0," + db;
\r
465 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
466 thisOpt = "deblock=" + da + "," + db;
\r
468 else if (optNameToChange.Equals("aq-strength"))
\r
470 if (slider_adaptiveQuantStrength.Value == 10)
\r
471 thisOpt = string.Empty;
\r
474 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
475 string aqs = value.ToString("f1", culture);
\r
476 thisOpt = "aq-strength=" + aqs;
\r
479 else if (optNameToChange.Equals("psy-rd"))
\r
481 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
482 thisOpt = string.Empty;
\r
485 double psyrd = slider_psyrd.Value * 0.1;
\r
486 double psytre = slider_psytrellis.Value * 0.05;
\r
488 string rd = psyrd.ToString("f2", culture);
\r
489 string rt = psytre.ToString("f2", culture);
\r
491 thisOpt = "psy-rd=" + rd + "," + rt;
\r
494 else if (optNameToChange.Equals("b-pyramid"))
\r
496 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
499 thisOpt = string.Empty;
\r
502 thisOpt = "b-pyramid=none";
\r
505 thisOpt = "b-pyramid=strict";
\r
509 else if (optNameToChange.Equals("no-dct-decimate"))
\r
510 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : string.Empty;
\r
511 else if (optNameToChange.Equals("8x8dct"))
\r
512 thisOpt = check_8x8DCT.CheckState == CheckState.Unchecked ? "8x8dct=0" : string.Empty;
\r
513 else if (optNameToChange.Equals("cabac"))
\r
514 thisOpt = check_Cabac.CheckState == CheckState.Checked ? string.Empty : "cabac=0";
\r
515 else if (optNameToChange.Equals("weightp"))
\r
516 thisOpt = check_weightp.CheckState == CheckState.Checked ? string.Empty : "weightp=0";
\r
517 else if (optNameToChange.Equals("me"))
\r
519 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
522 thisOpt = "me=dia";
\r
526 thisOpt = "me=hex";
\r
530 thisOpt = "me=umh";
\r
534 thisOpt = "me=esa";
\r
538 thisOpt = "me=tesa";
\r
542 thisOpt = string.Empty;
\r
546 else if (optNameToChange.Equals("direct"))
\r
548 switch (drop_directPrediction.SelectedIndex)
\r
551 thisOpt = "direct=none";
\r
555 thisOpt = "direct=spatial";
\r
559 thisOpt = "direct=temporal";
\r
563 thisOpt = "direct=auto";
\r
567 thisOpt = string.Empty;
\r
571 else if (optNameToChange.Equals("analyse"))
\r
573 switch (drop_analysis.SelectedIndex)
\r
576 thisOpt = "analyse=none";
\r
580 thisOpt = "analyse=some";
\r
584 thisOpt = "analyse=all";
\r
588 thisOpt = string.Empty;
\r
592 else if (optNameToChange.Equals("merange"))
\r
594 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
595 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
598 else if (optNameToChange.Equals("b-adapt"))
\r
600 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
601 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
604 else if (optNameToChange.Equals("ref"))
\r
606 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
607 ? "ref=" + drop_refFrames.SelectedItem
\r
610 else if (optNameToChange.Equals("bframes"))
\r
612 string value = drop_bFrames.SelectedItem.ToString();
\r
613 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
614 ? "bframes=" + value
\r
617 else if (optNameToChange.Equals("subq"))
\r
619 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
620 string[] val = value.Split(':');
\r
621 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
625 else if (optNameToChange.Equals("trellis"))
\r
627 switch (drop_trellis.SelectedIndex)
\r
630 thisOpt = "trellis=0";
\r
632 case 2: // Encode Only
\r
633 thisOpt = "trellis=1";
\r
636 thisOpt = "trellis=2";
\r
639 thisOpt = string.Empty;
\r
646 /* Construct New String for opts here */
\r
647 if (!thisOpt.Equals(string.Empty))
\r
648 changedOptString = changedOptString.Equals(string.Empty) ? thisOpt : changedOptString + ":" + thisOpt;
\r
651 /* Change the option string to reflect the new mod settings */
\r
652 rtf_x264Query.Text = changedOptString;
\r
656 /// Add's an option to the x264 query string.
\r
657 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
658 /// e.g no-fast-pskip
\r
660 /// <param name="optNameToChange">The Option Name to Change</param>
\r
661 private void HasNoOptions(IEquatable<string> optNameToChange)
\r
663 string colon = string.Empty;
\r
664 if (rtf_x264Query.Text != string.Empty)
\r
667 string query = rtf_x264Query.Text;
\r
668 if (optNameToChange.Equals("me"))
\r
670 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
673 query = query + colon + "me=dia";
\r
677 query = query + colon + "me=hex";
\r
681 query = query + colon + "me=umh";
\r
685 query = query + colon + "me=esa";
\r
689 query = query + colon + "me=tesa";
\r
696 else if (optNameToChange.Equals("direct"))
\r
698 switch (drop_directPrediction.SelectedIndex)
\r
701 query = query + colon + "direct=none";
\r
705 query = query + colon + "direct=spatial";
\r
709 query = query + colon + "direct=temporal";
\r
713 query = query + colon + "direct=auto";
\r
720 else if (optNameToChange.Equals("analyse"))
\r
722 switch (drop_analysis.SelectedIndex)
\r
725 query = query + colon + "analyse=none";
\r
729 query = query + colon + "analyse=some";
\r
733 query = query + colon + "analyse=all";
\r
740 else if (optNameToChange.Equals("merange"))
\r
742 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
743 query = query + colon + "merange=" + value;
\r
745 else if (optNameToChange.Equals("b-adapt"))
\r
747 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
748 query = query + colon + "b-adapt=" + value;
\r
750 else if (optNameToChange.Equals("deblock"))
\r
752 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
753 string db = drop_deblockBeta.Text;
\r
755 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
757 drop_deblockBeta.SelectedItem = "Default (0)";
\r
758 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
762 if (db.Contains("Default"))
\r
765 if (da.Contains("Default"))
\r
768 query = query + colon + "deblock=" + da + "," + db;
\r
771 else if (optNameToChange.Equals("aq-strength"))
\r
773 if (slider_adaptiveQuantStrength.Value == 10)
\r
774 query = string.Empty;
\r
777 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
778 string aqs = value.ToString("f1", culture);
\r
779 query += colon + "aq-strength=" + aqs;
\r
782 else if (optNameToChange.Equals("psy-rd"))
\r
784 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
785 query += string.Empty;
\r
788 double psyrd = slider_psyrd.Value * 0.1;
\r
789 double psytre = slider_psytrellis.Value * 0.05;
\r
791 string rd = psyrd.ToString("f1", culture);
\r
792 string rt = psytre.ToString("f2", culture);
\r
794 query += colon + "psy-rd=" + rd + "," + rt;
\r
797 else if (optNameToChange.Equals("b-pyramid"))
\r
799 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
804 query = query + colon + "b-pyramid=none";
\r
807 query = query + colon + "b-pyramid=strict";
\r
811 else if (optNameToChange.Equals("no-dct-decimate"))
\r
813 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
814 query = query + colon + "no-dct-decimate=1";
\r
816 else if (optNameToChange.Equals("8x8dct"))
\r
818 if (check_8x8DCT.CheckState == CheckState.Unchecked)
\r
819 query = query + colon + "8x8dct=0";
\r
821 else if (optNameToChange.Equals("cabac"))
\r
823 if (check_Cabac.CheckState != CheckState.Checked)
\r
824 query = query + colon + "cabac=0";
\r
826 else if (optNameToChange.Equals("weightp"))
\r
828 if (check_weightp.CheckState == CheckState.Unchecked)
\r
829 query = query + colon + "weightp=0";
\r
831 else if (optNameToChange.Equals("ref"))
\r
833 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
834 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
836 else if (optNameToChange.Equals("bframes"))
\r
838 string value = drop_bFrames.SelectedItem.ToString();
\r
839 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
840 query = query + colon + "bframes=" + value;
\r
842 else if (optNameToChange.Equals("subq"))
\r
844 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
845 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
847 string[] val = value.Split(':');
\r
848 query = query + colon + "subq=" + val[0];
\r
851 else if (optNameToChange.Equals("trellis"))
\r
853 switch (drop_trellis.SelectedIndex)
\r
856 query = query + colon + "trellis=0";
\r
858 case 2: // Encode Only
\r
859 query = query + colon + "trellis=1";
\r
862 query = query + colon + "trellis=2";
\r
869 rtf_x264Query.Text = query;
\r
873 /// Shows and hides controls based on the values of other controls.
\r
875 /// <param name="sender">The Sender</param>
\r
876 private void Animate(string sender)
\r
878 /* Lots of situations to cover.
\r
879 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
880 - CABAC (when 0 turn off trellis and psy-trel
\r
881 - subme (if under 6, turn off psy-rd and psy-trel)
\r
882 - trellis (if 0, turn off psy-trel)
\r
888 if (drop_bFrames.SelectedIndex == 1)
\r
890 /* If the b-frame widget is at 1, the user has chosen
\r
891 not to use b-frames at all. So disable the options
\r
892 that can only be used when b-frames are enabled. */
\r
893 combo_pyrmidalBFrames.Visible = false;
\r
894 lbl_prymidalBframes.Visible = false;
\r
895 drop_directPrediction.Visible = false;
\r
896 lbl_direct_prediction.Visible = false;
\r
898 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
899 drop_directPrediction.SelectedIndex = 0;
\r
901 drop_adaptBFrames.Visible = false;
\r
902 lbl_adaptBFrames.Visible = false;
\r
903 drop_adaptBFrames.SelectedIndex = 0;
\r
905 else if (drop_bFrames.SelectedIndex == 2)
\r
907 /* Only 1 b-frame? Disable b-pyramid. */
\r
908 combo_pyrmidalBFrames.Visible = false;
\r
909 lbl_prymidalBframes.Visible = false;
\r
910 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
912 drop_directPrediction.Visible = true;
\r
913 lbl_direct_prediction.Visible = true;
\r
915 drop_adaptBFrames.Visible = true;
\r
916 lbl_adaptBFrames.Visible = true;
\r
920 combo_pyrmidalBFrames.Visible = true;
\r
921 lbl_prymidalBframes.Visible = true;
\r
922 drop_directPrediction.Visible = true;
\r
923 lbl_direct_prediction.Visible = true;
\r
925 drop_adaptBFrames.Visible = true;
\r
926 lbl_adaptBFrames.Visible = true;
\r
929 case "me": // Motion Estimation
\r
930 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
932 drop_MotionEstimationRange.Visible = false;
\r
933 lbl_merange.Visible = false;
\r
934 drop_MotionEstimationRange.SelectedIndex = 0;
\r
938 drop_MotionEstimationRange.Visible = true;
\r
939 lbl_merange.Visible = true;
\r
942 case "subq": // subme
\r
943 if (drop_subpixelMotionEstimation.SelectedIndex != 0 &&
\r
944 drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
946 slider_psyrd.Visible = false;
\r
947 slider_psyrd.Value = 10;
\r
948 lbl_psyrd.Visible = false;
\r
950 slider_psytrellis.Visible = false;
\r
951 slider_psytrellis.Value = 0;
\r
952 lbl_psytrellis.Visible = false;
\r
956 slider_psyrd.Visible = true;
\r
957 lbl_psyrd.Visible = true;
\r
959 if (drop_trellis.SelectedIndex >= 2 && slider_psytrellis.Visible == false)
\r
961 slider_psytrellis.Visible = true;
\r
962 lbl_psytrellis.Visible = true;
\r
966 case "trellis": // subme
\r
967 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2)
\r
969 slider_psytrellis.Visible = false;
\r
970 slider_psytrellis.Value = 0;
\r
971 lbl_psytrellis.Visible = false;
\r
975 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && slider_psytrellis.Visible == false)
\r
977 slider_psytrellis.Visible = true;
\r
978 lbl_psytrellis.Visible = true;
\r
987 private void widgetControlChanged(object sender, EventArgs e)
\r
989 Control changedControlName = (Control) sender;
\r
990 string controlName = string.Empty;
\r
992 switch (changedControlName.Name.Trim())
\r
994 case "drop_refFrames":
\r
995 controlName = "ref";
\r
997 case "drop_bFrames":
\r
998 controlName = "bframes";
\r
1000 case "drop_directPrediction":
\r
1001 controlName = "direct";
\r
1003 case "check_weightp":
\r
1004 controlName = "weightp";
\r
1006 case "combo_pyrmidalBFrames":
\r
1007 controlName = "b-pyramid";
\r
1009 case "drop_MotionEstimationMethod":
\r
1010 controlName = "me";
\r
1012 case "drop_MotionEstimationRange":
\r
1013 controlName = "merange";
\r
1015 case "drop_subpixelMotionEstimation":
\r
1016 controlName = "subq";
\r
1018 case "drop_analysis":
\r
1019 controlName = "analyse";
\r
1021 case "check_8x8DCT":
\r
1022 controlName = "8x8dct";
\r
1024 case "drop_deblockAlpha":
\r
1025 controlName = "deblock";
\r
1027 case "drop_deblockBeta":
\r
1028 controlName = "deblock";
\r
1030 case "drop_trellis":
\r
1031 controlName = "trellis";
\r
1033 case "check_noDCTDecimate":
\r
1034 controlName = "no-dct-decimate";
\r
1036 case "check_Cabac":
\r
1037 controlName = "cabac";
\r
1039 case "slider_psyrd":
\r
1040 controlName = "psy-rd";
\r
1042 case "slider_psytrellis":
\r
1043 controlName = "psy-rd";
\r
1045 case "slider_adaptiveQuantStrength":
\r
1046 controlName = "aq-strength";
\r
1048 case "drop_adaptBFrames":
\r
1049 controlName = "b-adapt";
\r
1052 OnX264WidgetChange(controlName);
\r
1055 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
1057 if (rtf_x264Query.Text.EndsWith("\n"))
\r
1059 string query = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
1061 rtf_x264Query.Text = query;
\r
1062 this.StandardizeOptString();
\r
1063 this.SetCurrentSettingsInPanel();
\r
1065 if (rtf_x264Query.Text == string.Empty)
\r
1070 private void btn_reset_Click(object sender, EventArgs e)
\r
1072 rtf_x264Query.Text = string.Empty;
\r