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.Windows.Forms;
\r
12 /// The Advanced Panel
\r
14 public partial class x264Panel : UserControl
\r
17 * 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 /// Initializes a new instance of the <see cref="x264Panel"/> class.
\r
23 /// Initializes a new instance of the x264 panel user control
\r
27 InitializeComponent();
\r
29 if (Properties.Settings.Default.tooltipEnable)
\r
30 ToolTip.Active = true;
\r
36 /// Gets or sets the X264 query string
\r
38 public string X264Query
\r
42 return rtf_x264Query.Text;
\r
46 rtf_x264Query.Text = value;
\r
51 /// Reset all components to defaults and clears the x264 rtf box
\r
53 public void Reset2Defaults()
\r
55 check_8x8DCT.CheckState = CheckState.Checked;
\r
56 check_Cabac.CheckState = CheckState.Checked;
\r
57 check_weightp.CheckState = CheckState.Checked;
\r
58 check_noDCTDecimate.CheckState = CheckState.Unchecked;
\r
59 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
60 drop_analysis.SelectedIndex = 0;
\r
61 drop_bFrames.SelectedIndex = 0;
\r
62 drop_deblockAlpha.SelectedIndex = 0;
\r
63 drop_deblockBeta.SelectedIndex = 0;
\r
64 drop_directPrediction.SelectedIndex = 0;
\r
65 drop_MotionEstimationMethod.SelectedIndex = 0;
\r
66 drop_MotionEstimationRange.SelectedIndex = 0;
\r
67 drop_refFrames.SelectedIndex = 0;
\r
68 drop_subpixelMotionEstimation.SelectedIndex = 0;
\r
69 drop_trellis.SelectedIndex = 0;
\r
70 slider_psyrd.Value = 10;
\r
71 slider_psytrellis.Value = 0;
\r
72 drop_adaptBFrames.SelectedIndex = 0;
\r
74 rtf_x264Query.Text = string.Empty;
\r
77 #region Standardize Option String
\r
79 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
81 public void StandardizeOptString()
\r
83 /* Set widgets depending on the opt string in field */
\r
84 string thisOpt; // The separated option such as "bframes=3"
\r
85 string optName; // The option name such as "bframes"
\r
86 string optValue; // The option value such as "3"
\r
87 string changedOptString = string.Empty;
\r
88 string[] currentOptsArray;
\r
90 /*First, we get an opt string to process */
\r
91 string currentOptString = rtf_x264Query.Text;
\r
93 /*verify there is an opt string to process */
\r
94 if (currentOptString.Contains("="))
\r
96 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
97 currentOptsArray = currentOptString.Split(':');
\r
99 /*iterate through the array and get <opts> and <values*/
\r
101 int currentOptsArrayCount = currentOptsArray.Length;
\r
102 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
104 thisOpt = currentOptsArray[loopcounter];
\r
105 if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
\r
108 string[] splitOptRange = thisOpt.Split('=');
\r
109 if (thisOpt != string.Empty)
\r
111 if (thisOpt.Contains("="))
\r
113 optName = splitOptRange[0];
\r
114 optValue = splitOptRange[1];
\r
116 /* Standardize the names here depending on whats in the string */
\r
117 optName = StandardizeOptName(optName);
\r
118 thisOpt = optName + "=" + optValue;
\r
120 else // No value given so we use a default of "1"
\r
123 /* Standardize the names here depending on whats in the string */
\r
124 optName = StandardizeOptName(optName);
\r
125 thisOpt = optName + "=1";
\r
129 /* Construct New String for opts here */
\r
130 if (thisOpt == string.Empty)
\r
131 changedOptString = changedOptString + thisOpt;
\r
134 if (changedOptString == string.Empty)
\r
135 changedOptString = thisOpt;
\r
137 changedOptString = changedOptString + ":" + thisOpt;
\r
142 /* Change the option string to reflect the new standardized option string */
\r
143 if (changedOptString != string.Empty)
\r
144 rtf_x264Query.Text = changedOptString;
\r
148 /// Take a single option and standardize it. Returns as a String
\r
149 /// Input: String. - Single X264 Option. Name only
\r
150 /// Output: String - Single X264 Option. Name only. Changed to standard format
\r
152 /// <param name="cleanOptNameString">a string of x264 options to clean</param>
\r
153 /// <returns>A string containing standardized x264 option names</returns>
\r
154 private static string StandardizeOptName(string cleanOptNameString)
\r
156 string input = cleanOptNameString;
\r
158 /* Reference Frames */
\r
159 if (input.Equals("ref") || input.Equals("frameref"))
\r
160 cleanOptNameString = "ref";
\r
162 /*No Dict Decimate*/
\r
163 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
164 cleanOptNameString = "no-dct-decimate";
\r
167 if (input.Equals("subme"))
\r
168 cleanOptNameString = "subq";
\r
171 if (input.Equals("me-range") || input.Equals("me_range"))
\r
172 cleanOptNameString = "merange";
\r
175 if (input.Equals("b_pyramid"))
\r
176 cleanOptNameString = "b-pyramid";
\r
178 /*Direct Prediction*/
\r
179 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
180 cleanOptNameString = "direct";
\r
183 if (input.Equals("filter"))
\r
184 cleanOptNameString = "deblock";
\r
187 if (input.Equals("partitions"))
\r
188 cleanOptNameString = "analyse";
\r
190 return cleanOptNameString;
\r
195 /// Resets the GUI widgets to the contents of the option string.
\r
197 public void SetCurrentSettingsInPanel()
\r
199 /* Set widgets depending on the opt string in field */
\r
200 string thisOpt; // The separated option such as "bframes=3"
\r
201 string optName; // The option name such as "bframes"
\r
202 string optValue; // The option value such as "3"
\r
203 string[] currentOptsArray;
\r
205 // Set currentOptString to the contents of the text box.
\r
206 string currentOptString = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
208 /*verify there is an opt string to process */
\r
209 if (currentOptString.Contains("="))
\r
211 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
212 currentOptsArray = currentOptString.Split(':');
\r
214 /*iterate through the array and get <opts> and <values*/
\r
216 int currentOptsArrayCount = currentOptsArray.Length;
\r
218 /*iterate through the array and get <opts> and <values*/
\r
219 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
221 thisOpt = currentOptsArray[loopcounter];
\r
222 string[] splitOptRange = thisOpt.Split('=');
\r
224 if (thisOpt.Contains("="))
\r
226 optName = splitOptRange[0];
\r
227 optValue = splitOptRange[1];
\r
229 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
230 they need to be added here. This should be moved to its own method probably*/
\r
234 drop_bFrames.SelectedItem = optValue;
\r
237 drop_refFrames.SelectedItem = optValue;
\r
240 this.check_weightp.CheckState = optValue == "0" ? CheckState.Unchecked : CheckState.Checked;
\r
242 case "no-dct-decimate":
\r
243 check_noDCTDecimate.CheckState = CheckState.Checked;
\r
247 if (int.TryParse(optValue, out subqValue))
\r
249 drop_subpixelMotionEstimation.SelectedIndex = subqValue + 1;
\r
256 drop_trellis.SelectedIndex = 1;
\r
259 drop_trellis.SelectedIndex = 2;
\r
262 drop_trellis.SelectedIndex = 3;
\r
267 if (optValue.Equals("dia"))
\r
268 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
269 else if (optValue.Equals("hex"))
\r
270 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
271 else if (optValue.Equals("umh"))
\r
272 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
273 else if (optValue.Equals("esa"))
\r
274 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
275 else if (optValue.Equals("tesa"))
\r
276 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
279 drop_MotionEstimationRange.SelectedItem = optValue;
\r
283 int.TryParse(optValue, out badapt);
\r
284 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
290 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
293 combo_pyrmidalBFrames.SelectedIndex = 2;
\r
296 combo_pyrmidalBFrames.SelectedIndex = 1;
\r
301 if (optValue == "auto")
\r
302 optValue = "Automatic";
\r
304 if (optValue != string.Empty)
\r
306 char[] letters = optValue.ToCharArray();
\r
307 letters[0] = Char.ToUpper(letters[0]);
\r
308 optValue = new string(letters);
\r
311 drop_directPrediction.SelectedItem = optValue;
\r
314 string[] splitDeblock = optValue.Split(',');
\r
315 string alphaDeblock = splitDeblock[0];
\r
316 string betaDeblock = splitDeblock[1];
\r
318 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", string.Empty).Equals("0"))
\r
320 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
321 drop_deblockBeta.SelectedItem = "Default (0)";
\r
325 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
327 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", string.Empty).Equals("0")
\r
328 ? betaDeblock.Replace("\n", string.Empty)
\r
333 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
334 drop_analysis.SelectedItem = "Default (most)";
\r
335 if (optValue.Equals("none"))
\r
336 drop_analysis.SelectedItem = "None";
\r
337 if (optValue.Equals("i4x4,i8x8"))
\r
338 drop_analysis.SelectedItem = "Some";
\r
339 if (optValue.Equals("all"))
\r
340 drop_analysis.SelectedItem = "All";
\r
343 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
345 case "aq-strength":
\r
347 float.TryParse(optValue, out value);
\r
349 int.TryParse((value * 10).ToString(), out sliderValue);
\r
350 slider_adaptiveQuantStrength.Value = sliderValue;
\r
353 check_Cabac.CheckState = CheckState.Unchecked;
\r
356 string[] x = optValue.Split(',');
\r
358 double psyrd, psytrellis;
\r
361 // default psy-rd = 1 (10 for the slider)
\r
362 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
363 // default psy-trellis = 0
\r
364 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 20 : 0.0;
\r
366 int.TryParse(psyrd.ToString(), out val);
\r
367 int.TryParse(psytrellis.ToString(), out val2);
\r
369 slider_psyrd.Value = val;
\r
370 slider_psytrellis.Value = val2;
\r
379 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
381 /// <param name="sender">
\r
384 private void OnX264WidgetChange(string sender)
\r
387 string optNameToChange = sender;
\r
388 string currentOptString = rtf_x264Query.Text;
\r
390 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
391 the first character of the opt string (hence the ":") */
\r
392 string checkOptNameToChange = ":" + optNameToChange + "=";
\r
393 string checkOptNameToChangeBegin = optNameToChange + "=";
\r
395 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
396 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
397 HasOptions(currentOptString, optNameToChange);
\r
398 else // IF there is no options in the rich text box!
\r
399 HasNoOptions(optNameToChange);
\r
403 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
404 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
406 /// <param name="currentOptString">The Current Option String</param>
\r
407 /// <param name="optNameToChange">Name of the option to change</param>
\r
408 private void HasOptions(string currentOptString, string optNameToChange)
\r
410 string thisOpt; // The separated option such as "bframes=3"
\r
411 string optName; // The option name such as "bframes"
\r
412 string[] currentOptsArray;
\r
414 /* Create new empty opt string*/
\r
415 string changedOptString = string.Empty;
\r
417 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
418 currentOptsArray = currentOptString.Split(':');
\r
420 /*iterate through the array and get <opts> and <values*/
\r
421 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
423 thisOpt = currentOptsArray[loopcounter];
\r
425 if (thisOpt.Contains("="))
\r
427 string[] splitOptRange = thisOpt.Split('=');
\r
429 optName = splitOptRange[0]; // e.g bframes
\r
432 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
433 * they need to be added here. This should be moved to its own method probably
\r
434 * If the optNameToChange is found, appropriately change the value or delete it if
\r
435 * "unspecified" is set.
\r
437 if (optName.Equals(optNameToChange))
\r
439 if (optNameToChange.Equals("deblock"))
\r
441 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
442 string db = drop_deblockBeta.SelectedItem.ToString();
\r
444 if (((da.Contains("Default")) && (db.Contains("Default"))) ||
\r
445 ((da.Contains("0")) && (db.Contains("0"))))
\r
447 drop_deblockBeta.SelectedItem = "Default (0)";
\r
448 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
449 thisOpt = string.Empty;
\r
451 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
453 drop_deblockBeta.SelectedItem = "0";
\r
454 thisOpt = "deblock=" + da + ",0";
\r
456 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
458 drop_deblockAlpha.SelectedItem = "0";
\r
459 thisOpt = "deblock=0," + db;
\r
461 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
462 thisOpt = "deblock=" + da + "," + db;
\r
464 else if (optNameToChange.Equals("aq-strength"))
\r
466 if (slider_adaptiveQuantStrength.Value == 10)
\r
467 thisOpt = string.Empty;
\r
470 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
471 string aqs = value.ToString("f1");
\r
472 thisOpt = "aq-strength=" + aqs;
\r
475 else if (optNameToChange.Equals("psy-rd"))
\r
477 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
478 thisOpt = string.Empty;
\r
481 double psyrd = slider_psyrd.Value * 0.1;
\r
482 double psytre = slider_psytrellis.Value * 0.05;
\r
484 string rd = psyrd.ToString("f2");
\r
485 string rt = psytre.ToString("f2");
\r
487 thisOpt = "psy-rd=" + rd + "," + rt;
\r
490 else if (optNameToChange.Equals("b-pyramid"))
\r
492 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
495 thisOpt = string.Empty;
\r
498 thisOpt = "b-pyramid=none";
\r
501 thisOpt = "b-pyramid=strict";
\r
505 else if (optNameToChange.Equals("no-dct-decimate"))
\r
506 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : string.Empty;
\r
507 else if (optNameToChange.Equals("8x8dct"))
\r
508 thisOpt = check_8x8DCT.CheckState == CheckState.Unchecked ? "8x8dct=0" : string.Empty;
\r
509 else if (optNameToChange.Equals("cabac"))
\r
510 thisOpt = check_Cabac.CheckState == CheckState.Checked ? string.Empty : "cabac=0";
\r
511 else if (optNameToChange.Equals("weightp"))
\r
512 thisOpt = check_weightp.CheckState == CheckState.Checked ? string.Empty : "weightp=0";
\r
513 else if (optNameToChange.Equals("me"))
\r
515 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
518 thisOpt = "me=dia";
\r
522 thisOpt = "me=hex";
\r
526 thisOpt = "me=umh";
\r
530 thisOpt = "me=esa";
\r
534 thisOpt = "me=tesa";
\r
538 thisOpt = string.Empty;
\r
542 else if (optNameToChange.Equals("direct"))
\r
544 switch (drop_directPrediction.SelectedIndex)
\r
547 thisOpt = "direct=none";
\r
551 thisOpt = "direct=spatial";
\r
555 thisOpt = "direct=temporal";
\r
559 thisOpt = "direct=auto";
\r
563 thisOpt = string.Empty;
\r
567 else if (optNameToChange.Equals("analyse"))
\r
569 switch (drop_analysis.SelectedIndex)
\r
572 thisOpt = "analyse=none";
\r
576 thisOpt = "analyse=some";
\r
580 thisOpt = "analyse=all";
\r
584 thisOpt = string.Empty;
\r
588 else if (optNameToChange.Equals("merange"))
\r
590 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
591 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
594 else if (optNameToChange.Equals("b-adapt"))
\r
596 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
597 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
600 else if (optNameToChange.Equals("ref"))
\r
602 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
603 ? "ref=" + drop_refFrames.SelectedItem
\r
606 else if (optNameToChange.Equals("bframes"))
\r
608 string value = drop_bFrames.SelectedItem.ToString();
\r
609 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
610 ? "bframes=" + value
\r
613 else if (optNameToChange.Equals("subq"))
\r
615 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
616 string[] val = value.Split(':');
\r
617 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
621 else if (optNameToChange.Equals("trellis"))
\r
623 switch (drop_trellis.SelectedIndex)
\r
626 thisOpt = "trellis=0";
\r
628 case 2: // Encode Only
\r
629 thisOpt = "trellis=1";
\r
632 thisOpt = "trellis=2";
\r
635 thisOpt = string.Empty;
\r
642 /* Construct New String for opts here */
\r
643 if (!thisOpt.Equals(string.Empty))
\r
644 changedOptString = changedOptString.Equals(string.Empty) ? thisOpt : changedOptString + ":" + thisOpt;
\r
647 /* Change the option string to reflect the new mod settings */
\r
648 rtf_x264Query.Text = changedOptString;
\r
652 /// Add's an option to the x264 query string.
\r
653 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
654 /// e.g no-fast-pskip
\r
656 /// <param name="optNameToChange">The Option Name to Change</param>
\r
657 private void HasNoOptions(IEquatable<string> optNameToChange)
\r
659 string colon = string.Empty;
\r
660 if (rtf_x264Query.Text != string.Empty)
\r
663 string query = rtf_x264Query.Text;
\r
664 if (optNameToChange.Equals("me"))
\r
666 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
669 query = query + colon + "me=dia";
\r
673 query = query + colon + "me=hex";
\r
677 query = query + colon + "me=umh";
\r
681 query = query + colon + "me=esa";
\r
685 query = query + colon + "me=tesa";
\r
692 else if (optNameToChange.Equals("direct"))
\r
694 switch (drop_directPrediction.SelectedIndex)
\r
697 query = query + colon + "direct=none";
\r
701 query = query + colon + "direct=spatial";
\r
705 query = query + colon + "direct=temporal";
\r
709 query = query + colon + "direct=auto";
\r
716 else if (optNameToChange.Equals("analyse"))
\r
718 switch (drop_analysis.SelectedIndex)
\r
721 query = query + colon + "analyse=none";
\r
725 query = query + colon + "analyse=some";
\r
729 query = query + colon + "analyse=all";
\r
736 else if (optNameToChange.Equals("merange"))
\r
738 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
739 query = query + colon + "merange=" + value;
\r
741 else if (optNameToChange.Equals("b-adapt"))
\r
743 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
744 query = query + colon + "b-adapt=" + value;
\r
746 else if (optNameToChange.Equals("deblock"))
\r
748 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
749 string db = drop_deblockBeta.Text;
\r
751 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
753 drop_deblockBeta.SelectedItem = "Default (0)";
\r
754 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
758 if (db.Contains("Default"))
\r
761 if (da.Contains("Default"))
\r
764 query = query + colon + "deblock=" + da + "," + db;
\r
767 else if (optNameToChange.Equals("aq-strength"))
\r
769 if (slider_adaptiveQuantStrength.Value == 10)
\r
770 query = string.Empty;
\r
773 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
774 string aqs = value.ToString("f1");
\r
775 query += colon + "aq-strength=" + aqs;
\r
778 else if (optNameToChange.Equals("psy-rd"))
\r
780 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
781 query += string.Empty;
\r
784 double psyrd = slider_psyrd.Value * 0.1;
\r
785 double psytre = slider_psytrellis.Value * 0.05;
\r
787 string rd = psyrd.ToString("f1");
\r
788 string rt = psytre.ToString("f2");
\r
790 query += colon + "psy-rd=" + rd + "," + rt;
\r
793 else if (optNameToChange.Equals("b-pyramid"))
\r
795 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
800 query = query + colon + "b-pyramid=none";
\r
803 query = query + colon + "b-pyramid=strict";
\r
807 else if (optNameToChange.Equals("no-dct-decimate"))
\r
809 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
810 query = query + colon + "no-dct-decimate=1";
\r
812 else if (optNameToChange.Equals("8x8dct"))
\r
814 if (check_8x8DCT.CheckState == CheckState.Unchecked)
\r
815 query = query + colon + "8x8dct=0";
\r
817 else if (optNameToChange.Equals("cabac"))
\r
819 if (check_Cabac.CheckState != CheckState.Checked)
\r
820 query = query + colon + "cabac=0";
\r
822 else if (optNameToChange.Equals("weightp"))
\r
824 if (check_weightp.CheckState == CheckState.Unchecked)
\r
825 query = query + colon + "weightp=0";
\r
827 else if (optNameToChange.Equals("ref"))
\r
829 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
830 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
832 else if (optNameToChange.Equals("bframes"))
\r
834 string value = drop_bFrames.SelectedItem.ToString();
\r
835 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
836 query = query + colon + "bframes=" + value;
\r
838 else if (optNameToChange.Equals("subq"))
\r
840 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
841 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
843 string[] val = value.Split(':');
\r
844 query = query + colon + "subq=" + val[0];
\r
847 else if (optNameToChange.Equals("trellis"))
\r
849 switch (drop_trellis.SelectedIndex)
\r
852 query = query + colon + "trellis=0";
\r
854 case 2: // Encode Only
\r
855 query = query + colon + "trellis=1";
\r
858 query = query + colon + "trellis=2";
\r
865 rtf_x264Query.Text = query;
\r
869 /// Shows and hides controls based on the values of other controls.
\r
871 /// <param name="sender">The Sender</param>
\r
872 private void Animate(string sender)
\r
874 /* Lots of situations to cover.
\r
875 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
876 - CABAC (when 0 turn off trellis and psy-trel
\r
877 - subme (if under 6, turn off psy-rd and psy-trel)
\r
878 - trellis (if 0, turn off psy-trel)
\r
884 if (drop_bFrames.SelectedIndex == 1)
\r
886 /* If the b-frame widget is at 1, the user has chosen
\r
887 not to use b-frames at all. So disable the options
\r
888 that can only be used when b-frames are enabled. */
\r
889 combo_pyrmidalBFrames.Visible = false;
\r
890 lbl_prymidalBframes.Visible = false;
\r
891 drop_directPrediction.Visible = false;
\r
892 lbl_direct_prediction.Visible = false;
\r
894 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
895 drop_directPrediction.SelectedIndex = 0;
\r
897 drop_adaptBFrames.Visible = false;
\r
898 lbl_adaptBFrames.Visible = false;
\r
899 drop_adaptBFrames.SelectedIndex = 0;
\r
901 else if (drop_bFrames.SelectedIndex == 2)
\r
903 /* Only 1 b-frame? Disable b-pyramid. */
\r
904 combo_pyrmidalBFrames.Visible = false;
\r
905 lbl_prymidalBframes.Visible = false;
\r
906 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
908 drop_directPrediction.Visible = true;
\r
909 lbl_direct_prediction.Visible = true;
\r
911 drop_adaptBFrames.Visible = true;
\r
912 lbl_adaptBFrames.Visible = true;
\r
916 combo_pyrmidalBFrames.Visible = true;
\r
917 lbl_prymidalBframes.Visible = true;
\r
918 drop_directPrediction.Visible = true;
\r
919 lbl_direct_prediction.Visible = true;
\r
921 drop_adaptBFrames.Visible = true;
\r
922 lbl_adaptBFrames.Visible = true;
\r
926 if (check_Cabac.Checked == false)
\r
928 /* Without CABAC entropy coding, trellis doesn't run. */
\r
929 drop_trellis.Visible = false;
\r
930 drop_trellis.SelectedIndex = 0;
\r
931 lbl_trellis.Visible = false;
\r
933 slider_psytrellis.Visible = false;
\r
934 lbl_psytrellis.Visible = false;
\r
935 slider_psytrellis.Value = 0;
\r
939 drop_trellis.Visible = true;
\r
940 lbl_trellis.Visible = true;
\r
942 slider_psytrellis.Visible = true;
\r
943 lbl_psytrellis.Visible = true;
\r
946 case "me": // Motion Estimation
\r
947 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
949 drop_MotionEstimationRange.Visible = false;
\r
950 lbl_merange.Visible = false;
\r
951 drop_MotionEstimationRange.SelectedIndex = 0;
\r
955 drop_MotionEstimationRange.Visible = true;
\r
956 lbl_merange.Visible = true;
\r
959 case "subq": // subme
\r
960 if (drop_subpixelMotionEstimation.SelectedIndex != 0 &&
\r
961 drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
963 slider_psyrd.Visible = false;
\r
964 slider_psyrd.Value = 10;
\r
965 lbl_psyrd.Visible = false;
\r
967 slider_psytrellis.Visible = false;
\r
968 slider_psytrellis.Value = 0;
\r
969 lbl_psytrellis.Visible = false;
\r
973 slider_psyrd.Visible = true;
\r
974 lbl_psyrd.Visible = true;
\r
976 if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
978 slider_psytrellis.Visible = true;
\r
979 lbl_psytrellis.Visible = true;
\r
983 case "trellis": // subme
\r
984 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2)
\r
986 slider_psytrellis.Visible = false;
\r
987 slider_psytrellis.Value = 0;
\r
988 lbl_psytrellis.Visible = false;
\r
992 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 ||
\r
993 drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked &&
\r
994 slider_psytrellis.Visible == false)
\r
996 slider_psytrellis.Visible = true;
\r
997 lbl_psytrellis.Visible = true;
\r
1006 private void widgetControlChanged(object sender, EventArgs e)
\r
1008 Control changedControlName = (Control)sender;
\r
1009 string controlName = string.Empty;
\r
1011 switch (changedControlName.Name.Trim())
\r
1013 case "drop_refFrames":
\r
1014 controlName = "ref";
\r
1016 case "drop_bFrames":
\r
1017 controlName = "bframes";
\r
1019 case "drop_directPrediction":
\r
1020 controlName = "direct";
\r
1022 case "check_weightp":
\r
1023 controlName = "weightp";
\r
1025 case "combo_pyrmidalBFrames":
\r
1026 controlName = "b-pyramid";
\r
1028 case "drop_MotionEstimationMethod":
\r
1029 controlName = "me";
\r
1031 case "drop_MotionEstimationRange":
\r
1032 controlName = "merange";
\r
1034 case "drop_subpixelMotionEstimation":
\r
1035 controlName = "subq";
\r
1037 case "drop_analysis":
\r
1038 controlName = "analyse";
\r
1040 case "check_8x8DCT":
\r
1041 controlName = "8x8dct";
\r
1043 case "drop_deblockAlpha":
\r
1044 controlName = "deblock";
\r
1046 case "drop_deblockBeta":
\r
1047 controlName = "deblock";
\r
1049 case "drop_trellis":
\r
1050 controlName = "trellis";
\r
1052 case "check_noDCTDecimate":
\r
1053 controlName = "no-dct-decimate";
\r
1055 case "check_Cabac":
\r
1056 controlName = "cabac";
\r
1058 case "slider_psyrd":
\r
1059 controlName = "psy-rd";
\r
1061 case "slider_psytrellis":
\r
1062 controlName = "psy-rd";
\r
1064 case "slider_adaptiveQuantStrength":
\r
1065 controlName = "aq-strength";
\r
1067 case "drop_adaptBFrames":
\r
1068 controlName = "b-adapt";
\r
1071 OnX264WidgetChange(controlName);
\r
1074 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
1076 if (rtf_x264Query.Text.EndsWith("\n"))
\r
1078 string query = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
1080 rtf_x264Query.Text = query;
\r
1081 this.StandardizeOptString();
\r
1082 this.SetCurrentSettingsInPanel();
\r
1084 if (rtf_x264Query.Text == string.Empty)
\r
1089 private void btn_reset_Click(object sender, EventArgs e)
\r
1091 rtf_x264Query.Text = string.Empty;
\r