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
77 rtf_x264Query.Text = string.Empty;
\r
80 #region Standardize Option String
\r
82 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
84 public void StandardizeOptString()
\r
86 /* Set widgets depending on the opt string in field */
\r
87 string thisOpt; // The separated option such as "bframes=3"
\r
88 string optName; // The option name such as "bframes"
\r
89 string optValue; // The option value such as "3"
\r
90 string changedOptString = string.Empty;
\r
91 string[] currentOptsArray;
\r
93 /*First, we get an opt string to process */
\r
94 string currentOptString = rtf_x264Query.Text;
\r
96 /*verify there is an opt string to process */
\r
97 if (currentOptString.Contains("="))
\r
99 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
100 currentOptsArray = currentOptString.Split(':');
\r
102 /*iterate through the array and get <opts> and <values*/
\r
104 int currentOptsArrayCount = currentOptsArray.Length;
\r
105 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
107 thisOpt = currentOptsArray[loopcounter];
\r
108 if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
\r
111 string[] splitOptRange = thisOpt.Split('=');
\r
112 if (thisOpt != string.Empty)
\r
114 if (thisOpt.Contains("="))
\r
116 optName = splitOptRange[0];
\r
117 optValue = splitOptRange[1];
\r
119 /* Standardize the names here depending on whats in the string */
\r
120 optName = StandardizeOptName(optName);
\r
121 thisOpt = optName + "=" + optValue;
\r
123 else // No value given so we use a default of "1"
\r
126 /* Standardize the names here depending on whats in the string */
\r
127 optName = StandardizeOptName(optName);
\r
128 thisOpt = optName + "=1";
\r
132 /* Construct New String for opts here */
\r
133 if (thisOpt == string.Empty)
\r
134 changedOptString = changedOptString + thisOpt;
\r
137 if (changedOptString == string.Empty)
\r
138 changedOptString = thisOpt;
\r
140 changedOptString = changedOptString + ":" + thisOpt;
\r
145 /* Change the option string to reflect the new standardized option string */
\r
146 if (changedOptString != string.Empty)
\r
147 rtf_x264Query.Text = changedOptString;
\r
151 /// Take a single option and standardize it. Returns as a String
\r
152 /// Input: String. - Single X264 Option. Name only
\r
153 /// Output: String - Single X264 Option. Name only. Changed to standard format
\r
155 /// <param name="cleanOptNameString">a string of x264 options to clean</param>
\r
156 /// <returns>A string containing standardized x264 option names</returns>
\r
157 private static string StandardizeOptName(string cleanOptNameString)
\r
159 string input = cleanOptNameString;
\r
161 /* Reference Frames */
\r
162 if (input.Equals("ref") || input.Equals("frameref"))
\r
163 cleanOptNameString = "ref";
\r
165 /*No Dict Decimate*/
\r
166 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
167 cleanOptNameString = "no-dct-decimate";
\r
170 if (input.Equals("subme"))
\r
171 cleanOptNameString = "subq";
\r
174 if (input.Equals("me-range") || input.Equals("me_range"))
\r
175 cleanOptNameString = "merange";
\r
178 if (input.Equals("b_pyramid"))
\r
179 cleanOptNameString = "b-pyramid";
\r
181 /*Direct Prediction*/
\r
182 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
183 cleanOptNameString = "direct";
\r
186 if (input.Equals("filter"))
\r
187 cleanOptNameString = "deblock";
\r
190 if (input.Equals("partitions"))
\r
191 cleanOptNameString = "analyse";
\r
193 return cleanOptNameString;
\r
198 /// Resets the GUI widgets to the contents of the option string.
\r
200 public void SetCurrentSettingsInPanel()
\r
202 /* Set widgets depending on the opt string in field */
\r
203 string thisOpt; // The separated option such as "bframes=3"
\r
204 string optName; // The option name such as "bframes"
\r
205 string optValue; // The option value such as "3"
\r
206 string[] currentOptsArray;
\r
208 // Set currentOptString to the contents of the text box.
\r
209 string currentOptString = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
211 /*verify there is an opt string to process */
\r
212 if (currentOptString.Contains("="))
\r
214 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
215 currentOptsArray = currentOptString.Split(':');
\r
217 /*iterate through the array and get <opts> and <values*/
\r
219 int currentOptsArrayCount = currentOptsArray.Length;
\r
221 /*iterate through the array and get <opts> and <values*/
\r
222 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
224 thisOpt = currentOptsArray[loopcounter];
\r
225 string[] splitOptRange = thisOpt.Split('=');
\r
227 if (thisOpt.Contains("="))
\r
229 optName = splitOptRange[0];
\r
230 optValue = splitOptRange[1];
\r
232 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
233 they need to be added here. This should be moved to its own method probably*/
\r
237 drop_bFrames.SelectedItem = optValue;
\r
240 drop_refFrames.SelectedItem = optValue;
\r
243 this.check_weightp.CheckState = optValue == "0" ? CheckState.Unchecked : CheckState.Checked;
\r
245 case "no-dct-decimate":
\r
246 check_noDCTDecimate.CheckState = CheckState.Checked;
\r
250 if (int.TryParse(optValue, out subqValue))
\r
252 drop_subpixelMotionEstimation.SelectedIndex = subqValue + 1;
\r
259 drop_trellis.SelectedIndex = 1;
\r
262 drop_trellis.SelectedIndex = 2;
\r
265 drop_trellis.SelectedIndex = 3;
\r
270 if (optValue.Equals("dia"))
\r
271 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
272 else if (optValue.Equals("hex"))
\r
273 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
274 else if (optValue.Equals("umh"))
\r
275 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
276 else if (optValue.Equals("esa"))
\r
277 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
278 else if (optValue.Equals("tesa"))
\r
279 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
282 drop_MotionEstimationRange.SelectedItem = optValue;
\r
286 int.TryParse(optValue, out badapt);
\r
287 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
293 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
296 combo_pyrmidalBFrames.SelectedIndex = 2;
\r
299 combo_pyrmidalBFrames.SelectedIndex = 1;
\r
304 if (optValue == "auto")
\r
305 optValue = "Automatic";
\r
307 if (optValue != string.Empty)
\r
309 char[] letters = optValue.ToCharArray();
\r
310 letters[0] = Char.ToUpper(letters[0]);
\r
311 optValue = new string(letters);
\r
314 drop_directPrediction.SelectedItem = optValue;
\r
317 string[] splitDeblock = optValue.Split(',');
\r
318 string alphaDeblock = splitDeblock[0];
\r
319 string betaDeblock = splitDeblock[1];
\r
321 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", string.Empty).Equals("0"))
\r
323 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
324 drop_deblockBeta.SelectedItem = "Default (0)";
\r
328 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
330 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", string.Empty).Equals("0")
\r
331 ? betaDeblock.Replace("\n", string.Empty)
\r
336 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
337 drop_analysis.SelectedItem = "Default (most)";
\r
338 if (optValue.Equals("none"))
\r
339 drop_analysis.SelectedItem = "None";
\r
340 if (optValue.Equals("i4x4,i8x8"))
\r
341 drop_analysis.SelectedItem = "Some";
\r
342 if (optValue.Equals("all"))
\r
343 drop_analysis.SelectedItem = "All";
\r
346 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
348 case "aq-strength":
\r
350 float.TryParse(optValue, out value);
\r
352 int.TryParse((value * 10).ToString(), out sliderValue);
\r
353 slider_adaptiveQuantStrength.Value = sliderValue;
\r
356 check_Cabac.CheckState = CheckState.Unchecked;
\r
359 string[] x = optValue.Split(',');
\r
361 double psyrd, psytrellis;
\r
364 // default psy-rd = 1 (10 for the slider)
\r
365 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
366 // default psy-trellis = 0
\r
367 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 20 : 0.0;
\r
369 int.TryParse(psyrd.ToString(), out val);
\r
370 int.TryParse(psytrellis.ToString(), out val2);
\r
372 slider_psyrd.Value = val;
\r
373 slider_psytrellis.Value = val2;
\r
382 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
384 /// <param name="sender">
\r
387 private void OnX264WidgetChange(string sender)
\r
390 string optNameToChange = sender;
\r
391 string currentOptString = rtf_x264Query.Text;
\r
393 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
394 the first character of the opt string (hence the ":") */
\r
395 string checkOptNameToChange = ":" + optNameToChange + "=";
\r
396 string checkOptNameToChangeBegin = optNameToChange + "=";
\r
398 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
399 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
400 HasOptions(currentOptString, optNameToChange);
\r
401 else // IF there is no options in the rich text box!
\r
402 HasNoOptions(optNameToChange);
\r
406 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
407 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
409 /// <param name="currentOptString">The Current Option String</param>
\r
410 /// <param name="optNameToChange">Name of the option to change</param>
\r
411 private void HasOptions(string currentOptString, string optNameToChange)
\r
413 string thisOpt; // The separated option such as "bframes=3"
\r
414 string optName; // The option name such as "bframes"
\r
415 string[] currentOptsArray;
\r
417 /* Create new empty opt string*/
\r
418 string changedOptString = string.Empty;
\r
420 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
421 currentOptsArray = currentOptString.Split(':');
\r
423 /*iterate through the array and get <opts> and <values*/
\r
424 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
426 thisOpt = currentOptsArray[loopcounter];
\r
428 if (thisOpt.Contains("="))
\r
430 string[] splitOptRange = thisOpt.Split('=');
\r
432 optName = splitOptRange[0]; // e.g bframes
\r
435 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
436 * they need to be added here. This should be moved to its own method probably
\r
437 * If the optNameToChange is found, appropriately change the value or delete it if
\r
438 * "unspecified" is set.
\r
440 if (optName.Equals(optNameToChange))
\r
442 if (optNameToChange.Equals("deblock"))
\r
444 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
445 string db = drop_deblockBeta.SelectedItem.ToString();
\r
447 if (((da.Contains("Default")) && (db.Contains("Default"))) ||
\r
448 ((da.Contains("0")) && (db.Contains("0"))))
\r
450 drop_deblockBeta.SelectedItem = "Default (0)";
\r
451 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
452 thisOpt = string.Empty;
\r
454 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
456 drop_deblockBeta.SelectedItem = "0";
\r
457 thisOpt = "deblock=" + da + ",0";
\r
459 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
461 drop_deblockAlpha.SelectedItem = "0";
\r
462 thisOpt = "deblock=0," + db;
\r
464 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
465 thisOpt = "deblock=" + da + "," + db;
\r
467 else if (optNameToChange.Equals("aq-strength"))
\r
469 if (slider_adaptiveQuantStrength.Value == 10)
\r
470 thisOpt = string.Empty;
\r
473 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
474 string aqs = value.ToString("f1", culture);
\r
475 thisOpt = "aq-strength=" + aqs;
\r
478 else if (optNameToChange.Equals("psy-rd"))
\r
480 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
481 thisOpt = string.Empty;
\r
484 double psyrd = slider_psyrd.Value * 0.1;
\r
485 double psytre = slider_psytrellis.Value * 0.05;
\r
487 string rd = psyrd.ToString("f2", culture);
\r
488 string rt = psytre.ToString("f2", culture);
\r
490 thisOpt = "psy-rd=" + rd + "," + rt;
\r
493 else if (optNameToChange.Equals("b-pyramid"))
\r
495 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
498 thisOpt = string.Empty;
\r
501 thisOpt = "b-pyramid=none";
\r
504 thisOpt = "b-pyramid=strict";
\r
508 else if (optNameToChange.Equals("no-dct-decimate"))
\r
509 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : string.Empty;
\r
510 else if (optNameToChange.Equals("8x8dct"))
\r
511 thisOpt = check_8x8DCT.CheckState == CheckState.Unchecked ? "8x8dct=0" : string.Empty;
\r
512 else if (optNameToChange.Equals("cabac"))
\r
513 thisOpt = check_Cabac.CheckState == CheckState.Checked ? string.Empty : "cabac=0";
\r
514 else if (optNameToChange.Equals("weightp"))
\r
515 thisOpt = check_weightp.CheckState == CheckState.Checked ? string.Empty : "weightp=0";
\r
516 else if (optNameToChange.Equals("me"))
\r
518 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
521 thisOpt = "me=dia";
\r
525 thisOpt = "me=hex";
\r
529 thisOpt = "me=umh";
\r
533 thisOpt = "me=esa";
\r
537 thisOpt = "me=tesa";
\r
541 thisOpt = string.Empty;
\r
545 else if (optNameToChange.Equals("direct"))
\r
547 switch (drop_directPrediction.SelectedIndex)
\r
550 thisOpt = "direct=none";
\r
554 thisOpt = "direct=spatial";
\r
558 thisOpt = "direct=temporal";
\r
562 thisOpt = "direct=auto";
\r
566 thisOpt = string.Empty;
\r
570 else if (optNameToChange.Equals("analyse"))
\r
572 switch (drop_analysis.SelectedIndex)
\r
575 thisOpt = "analyse=none";
\r
579 thisOpt = "analyse=some";
\r
583 thisOpt = "analyse=all";
\r
587 thisOpt = string.Empty;
\r
591 else if (optNameToChange.Equals("merange"))
\r
593 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
594 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
597 else if (optNameToChange.Equals("b-adapt"))
\r
599 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
600 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
603 else if (optNameToChange.Equals("ref"))
\r
605 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
606 ? "ref=" + drop_refFrames.SelectedItem
\r
609 else if (optNameToChange.Equals("bframes"))
\r
611 string value = drop_bFrames.SelectedItem.ToString();
\r
612 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
613 ? "bframes=" + value
\r
616 else if (optNameToChange.Equals("subq"))
\r
618 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
619 string[] val = value.Split(':');
\r
620 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
624 else if (optNameToChange.Equals("trellis"))
\r
626 switch (drop_trellis.SelectedIndex)
\r
629 thisOpt = "trellis=0";
\r
631 case 2: // Encode Only
\r
632 thisOpt = "trellis=1";
\r
635 thisOpt = "trellis=2";
\r
638 thisOpt = string.Empty;
\r
645 /* Construct New String for opts here */
\r
646 if (!thisOpt.Equals(string.Empty))
\r
647 changedOptString = changedOptString.Equals(string.Empty) ? thisOpt : changedOptString + ":" + thisOpt;
\r
650 /* Change the option string to reflect the new mod settings */
\r
651 rtf_x264Query.Text = changedOptString;
\r
655 /// Add's an option to the x264 query string.
\r
656 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
657 /// e.g no-fast-pskip
\r
659 /// <param name="optNameToChange">The Option Name to Change</param>
\r
660 private void HasNoOptions(IEquatable<string> optNameToChange)
\r
662 string colon = string.Empty;
\r
663 if (rtf_x264Query.Text != string.Empty)
\r
666 string query = rtf_x264Query.Text;
\r
667 if (optNameToChange.Equals("me"))
\r
669 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
672 query = query + colon + "me=dia";
\r
676 query = query + colon + "me=hex";
\r
680 query = query + colon + "me=umh";
\r
684 query = query + colon + "me=esa";
\r
688 query = query + colon + "me=tesa";
\r
695 else if (optNameToChange.Equals("direct"))
\r
697 switch (drop_directPrediction.SelectedIndex)
\r
700 query = query + colon + "direct=none";
\r
704 query = query + colon + "direct=spatial";
\r
708 query = query + colon + "direct=temporal";
\r
712 query = query + colon + "direct=auto";
\r
719 else if (optNameToChange.Equals("analyse"))
\r
721 switch (drop_analysis.SelectedIndex)
\r
724 query = query + colon + "analyse=none";
\r
728 query = query + colon + "analyse=some";
\r
732 query = query + colon + "analyse=all";
\r
739 else if (optNameToChange.Equals("merange"))
\r
741 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
742 query = query + colon + "merange=" + value;
\r
744 else if (optNameToChange.Equals("b-adapt"))
\r
746 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
747 query = query + colon + "b-adapt=" + value;
\r
749 else if (optNameToChange.Equals("deblock"))
\r
751 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
752 string db = drop_deblockBeta.Text;
\r
754 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
756 drop_deblockBeta.SelectedItem = "Default (0)";
\r
757 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
761 if (db.Contains("Default"))
\r
764 if (da.Contains("Default"))
\r
767 query = query + colon + "deblock=" + da + "," + db;
\r
770 else if (optNameToChange.Equals("aq-strength"))
\r
772 if (slider_adaptiveQuantStrength.Value == 10)
\r
773 query = string.Empty;
\r
776 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
777 string aqs = value.ToString("f1", culture);
\r
778 query += colon + "aq-strength=" + aqs;
\r
781 else if (optNameToChange.Equals("psy-rd"))
\r
783 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
784 query += string.Empty;
\r
787 double psyrd = slider_psyrd.Value * 0.1;
\r
788 double psytre = slider_psytrellis.Value * 0.05;
\r
790 string rd = psyrd.ToString("f1", culture);
\r
791 string rt = psytre.ToString("f2", culture);
\r
793 query += colon + "psy-rd=" + rd + "," + rt;
\r
796 else if (optNameToChange.Equals("b-pyramid"))
\r
798 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
803 query = query + colon + "b-pyramid=none";
\r
806 query = query + colon + "b-pyramid=strict";
\r
810 else if (optNameToChange.Equals("no-dct-decimate"))
\r
812 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
813 query = query + colon + "no-dct-decimate=1";
\r
815 else if (optNameToChange.Equals("8x8dct"))
\r
817 if (check_8x8DCT.CheckState == CheckState.Unchecked)
\r
818 query = query + colon + "8x8dct=0";
\r
820 else if (optNameToChange.Equals("cabac"))
\r
822 if (check_Cabac.CheckState != CheckState.Checked)
\r
823 query = query + colon + "cabac=0";
\r
825 else if (optNameToChange.Equals("weightp"))
\r
827 if (check_weightp.CheckState == CheckState.Unchecked)
\r
828 query = query + colon + "weightp=0";
\r
830 else if (optNameToChange.Equals("ref"))
\r
832 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
833 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
835 else if (optNameToChange.Equals("bframes"))
\r
837 string value = drop_bFrames.SelectedItem.ToString();
\r
838 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
839 query = query + colon + "bframes=" + value;
\r
841 else if (optNameToChange.Equals("subq"))
\r
843 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
844 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
846 string[] val = value.Split(':');
\r
847 query = query + colon + "subq=" + val[0];
\r
850 else if (optNameToChange.Equals("trellis"))
\r
852 switch (drop_trellis.SelectedIndex)
\r
855 query = query + colon + "trellis=0";
\r
857 case 2: // Encode Only
\r
858 query = query + colon + "trellis=1";
\r
861 query = query + colon + "trellis=2";
\r
868 rtf_x264Query.Text = query;
\r
872 /// Shows and hides controls based on the values of other controls.
\r
874 /// <param name="sender">The Sender</param>
\r
875 private void Animate(string sender)
\r
877 /* Lots of situations to cover.
\r
878 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
879 - CABAC (when 0 turn off trellis and psy-trel
\r
880 - subme (if under 6, turn off psy-rd and psy-trel)
\r
881 - trellis (if 0, turn off psy-trel)
\r
887 if (drop_bFrames.SelectedIndex == 1)
\r
889 /* If the b-frame widget is at 1, the user has chosen
\r
890 not to use b-frames at all. So disable the options
\r
891 that can only be used when b-frames are enabled. */
\r
892 combo_pyrmidalBFrames.Visible = false;
\r
893 lbl_prymidalBframes.Visible = false;
\r
894 drop_directPrediction.Visible = false;
\r
895 lbl_direct_prediction.Visible = false;
\r
897 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
898 drop_directPrediction.SelectedIndex = 0;
\r
900 drop_adaptBFrames.Visible = false;
\r
901 lbl_adaptBFrames.Visible = false;
\r
902 drop_adaptBFrames.SelectedIndex = 0;
\r
904 else if (drop_bFrames.SelectedIndex == 2)
\r
906 /* Only 1 b-frame? Disable b-pyramid. */
\r
907 combo_pyrmidalBFrames.Visible = false;
\r
908 lbl_prymidalBframes.Visible = false;
\r
909 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
911 drop_directPrediction.Visible = true;
\r
912 lbl_direct_prediction.Visible = true;
\r
914 drop_adaptBFrames.Visible = true;
\r
915 lbl_adaptBFrames.Visible = true;
\r
919 combo_pyrmidalBFrames.Visible = true;
\r
920 lbl_prymidalBframes.Visible = true;
\r
921 drop_directPrediction.Visible = true;
\r
922 lbl_direct_prediction.Visible = true;
\r
924 drop_adaptBFrames.Visible = true;
\r
925 lbl_adaptBFrames.Visible = true;
\r
928 case "me": // Motion Estimation
\r
929 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
931 drop_MotionEstimationRange.Visible = false;
\r
932 lbl_merange.Visible = false;
\r
933 drop_MotionEstimationRange.SelectedIndex = 0;
\r
937 drop_MotionEstimationRange.Visible = true;
\r
938 lbl_merange.Visible = true;
\r
941 case "subq": // subme
\r
942 if (drop_subpixelMotionEstimation.SelectedIndex != 0 &&
\r
943 drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
945 slider_psyrd.Visible = false;
\r
946 slider_psyrd.Value = 10;
\r
947 lbl_psyrd.Visible = false;
\r
949 slider_psytrellis.Visible = false;
\r
950 slider_psytrellis.Value = 0;
\r
951 lbl_psytrellis.Visible = false;
\r
955 slider_psyrd.Visible = true;
\r
956 lbl_psyrd.Visible = true;
\r
958 if (drop_trellis.SelectedIndex >= 2 && slider_psytrellis.Visible == false)
\r
960 slider_psytrellis.Visible = true;
\r
961 lbl_psytrellis.Visible = true;
\r
965 case "trellis": // subme
\r
966 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2)
\r
968 slider_psytrellis.Visible = false;
\r
969 slider_psytrellis.Value = 0;
\r
970 lbl_psytrellis.Visible = false;
\r
974 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && slider_psytrellis.Visible == false)
\r
976 slider_psytrellis.Visible = true;
\r
977 lbl_psytrellis.Visible = true;
\r
986 private void widgetControlChanged(object sender, EventArgs e)
\r
988 Control changedControlName = (Control) sender;
\r
989 string controlName = string.Empty;
\r
991 switch (changedControlName.Name.Trim())
\r
993 case "drop_refFrames":
\r
994 controlName = "ref";
\r
996 case "drop_bFrames":
\r
997 controlName = "bframes";
\r
999 case "drop_directPrediction":
\r
1000 controlName = "direct";
\r
1002 case "check_weightp":
\r
1003 controlName = "weightp";
\r
1005 case "combo_pyrmidalBFrames":
\r
1006 controlName = "b-pyramid";
\r
1008 case "drop_MotionEstimationMethod":
\r
1009 controlName = "me";
\r
1011 case "drop_MotionEstimationRange":
\r
1012 controlName = "merange";
\r
1014 case "drop_subpixelMotionEstimation":
\r
1015 controlName = "subq";
\r
1017 case "drop_analysis":
\r
1018 controlName = "analyse";
\r
1020 case "check_8x8DCT":
\r
1021 controlName = "8x8dct";
\r
1023 case "drop_deblockAlpha":
\r
1024 controlName = "deblock";
\r
1026 case "drop_deblockBeta":
\r
1027 controlName = "deblock";
\r
1029 case "drop_trellis":
\r
1030 controlName = "trellis";
\r
1032 case "check_noDCTDecimate":
\r
1033 controlName = "no-dct-decimate";
\r
1035 case "check_Cabac":
\r
1036 controlName = "cabac";
\r
1038 case "slider_psyrd":
\r
1039 controlName = "psy-rd";
\r
1041 case "slider_psytrellis":
\r
1042 controlName = "psy-rd";
\r
1044 case "slider_adaptiveQuantStrength":
\r
1045 controlName = "aq-strength";
\r
1047 case "drop_adaptBFrames":
\r
1048 controlName = "b-adapt";
\r
1051 OnX264WidgetChange(controlName);
\r
1054 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
1056 if (rtf_x264Query.Text.EndsWith("\n"))
\r
1058 string query = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
1060 rtf_x264Query.Text = query;
\r
1061 this.StandardizeOptString();
\r
1062 this.SetCurrentSettingsInPanel();
\r
1064 if (rtf_x264Query.Text == string.Empty)
\r
1069 private void btn_reset_Click(object sender, EventArgs e)
\r
1071 rtf_x264Query.Text = string.Empty;
\r