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
11 public partial class x264Panel : UserControl
\r
14 * TODO This code was ported from the obj-c MacGUI code. It's really messy and could really do with being cleaned up
\r
19 /// Initializes a new instance of the <see cref="x264Panel"/> class.
\r
20 /// Initializes a new instance of the x264 panel user control
\r
24 InitializeComponent();
\r
26 if (Properties.Settings.Default.tooltipEnable)
\r
27 ToolTip.Active = true;
\r
33 /// Gets or sets the X264 query string
\r
35 public string X264Query
\r
39 return rtf_x264Query.Text;
\r
41 set { rtf_x264Query.Text = value; }
\r
45 /// Reset all components to defaults and clears the x264 rtf box
\r
47 public void Reset2Defaults()
\r
49 check_8x8DCT.CheckState = CheckState.Checked;
\r
50 check_Cabac.CheckState = CheckState.Checked;
\r
51 check_weightp.CheckState = CheckState.Checked;
\r
52 check_noDCTDecimate.CheckState = CheckState.Unchecked;
\r
53 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
54 drop_analysis.SelectedIndex = 0;
\r
55 drop_bFrames.SelectedIndex = 0;
\r
56 drop_deblockAlpha.SelectedIndex = 0;
\r
57 drop_deblockBeta.SelectedIndex = 0;
\r
58 drop_directPrediction.SelectedIndex = 0;
\r
59 drop_MotionEstimationMethod.SelectedIndex = 0;
\r
60 drop_MotionEstimationRange.SelectedIndex = 0;
\r
61 drop_refFrames.SelectedIndex = 0;
\r
62 drop_subpixelMotionEstimation.SelectedIndex = 0;
\r
63 drop_trellis.SelectedIndex = 0;
\r
64 slider_psyrd.Value = 10;
\r
65 slider_psytrellis.Value = 0;
\r
66 drop_adaptBFrames.SelectedIndex = 0;
\r
68 rtf_x264Query.Text = string.Empty;
\r
71 #region Standardize Option String
\r
73 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
75 public void StandardizeOptString()
\r
77 /* Set widgets depending on the opt string in field */
\r
78 string thisOpt; // The separated option such as "bframes=3"
\r
79 string optName; // The option name such as "bframes"
\r
80 string optValue; // The option value such as "3"
\r
81 string changedOptString = string.Empty;
\r
82 string[] currentOptsArray;
\r
84 /*First, we get an opt string to process */
\r
85 string currentOptString = rtf_x264Query.Text;
\r
87 /*verify there is an opt string to process */
\r
88 if (currentOptString.Contains("="))
\r
90 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
91 currentOptsArray = currentOptString.Split(':');
\r
93 /*iterate through the array and get <opts> and <values*/
\r
95 int currentOptsArrayCount = currentOptsArray.Length;
\r
96 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
98 thisOpt = currentOptsArray[loopcounter];
\r
99 if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
\r
102 string[] splitOptRange = thisOpt.Split('=');
\r
103 if (thisOpt != string.Empty)
\r
105 if (thisOpt.Contains("="))
\r
107 optName = splitOptRange[0];
\r
108 optValue = splitOptRange[1];
\r
110 /* Standardize the names here depending on whats in the string */
\r
111 optName = StandardizeOptName(optName);
\r
112 thisOpt = optName + "=" + optValue;
\r
114 else // No value given so we use a default of "1"
\r
117 /* Standardize the names here depending on whats in the string */
\r
118 optName = StandardizeOptName(optName);
\r
119 thisOpt = optName + "=1";
\r
123 /* Construct New String for opts here */
\r
124 if (thisOpt == string.Empty)
\r
125 changedOptString = changedOptString + thisOpt;
\r
128 if (changedOptString == string.Empty)
\r
129 changedOptString = thisOpt;
\r
131 changedOptString = changedOptString + ":" + thisOpt;
\r
136 /* Change the option string to reflect the new standardized option string */
\r
137 if (changedOptString != string.Empty)
\r
138 rtf_x264Query.Text = changedOptString;
\r
142 /// Take a single option and standardize it. Returns as a String
\r
143 /// Input: String. - Single X264 Option. Name only
\r
144 /// Output: String - Single X264 Option. Name only. Changed to standard format
\r
146 /// <param name="cleanOptNameString">a string of x264 options to clean</param>
\r
147 /// <returns>A string containing standardized x264 option names</returns>
\r
148 private static string StandardizeOptName(string cleanOptNameString)
\r
150 string input = cleanOptNameString;
\r
152 /* Reference Frames */
\r
153 if (input.Equals("ref") || input.Equals("frameref"))
\r
154 cleanOptNameString = "ref";
\r
156 /*No Dict Decimate*/
\r
157 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
158 cleanOptNameString = "no-dct-decimate";
\r
161 if (input.Equals("subme"))
\r
162 cleanOptNameString = "subq";
\r
165 if (input.Equals("me-range") || input.Equals("me_range"))
\r
166 cleanOptNameString = "merange";
\r
169 if (input.Equals("b_pyramid"))
\r
170 cleanOptNameString = "b-pyramid";
\r
172 /*Direct Prediction*/
\r
173 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
174 cleanOptNameString = "direct";
\r
177 if (input.Equals("filter"))
\r
178 cleanOptNameString = "deblock";
\r
181 if (input.Equals("partitions"))
\r
182 cleanOptNameString = "analyse";
\r
184 return cleanOptNameString;
\r
189 /// Resets the GUI widgets to the contents of the option string.
\r
191 public void SetCurrentSettingsInPanel()
\r
193 /* Set widgets depending on the opt string in field */
\r
194 string thisOpt; // The separated option such as "bframes=3"
\r
195 string optName; // The option name such as "bframes"
\r
196 string optValue; // The option value such as "3"
\r
197 string[] currentOptsArray;
\r
199 // Set currentOptString to the contents of the text box.
\r
200 string currentOptString = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
202 /*verify there is an opt string to process */
\r
203 if (currentOptString.Contains("="))
\r
205 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
206 currentOptsArray = currentOptString.Split(':');
\r
208 /*iterate through the array and get <opts> and <values*/
\r
210 int currentOptsArrayCount = currentOptsArray.Length;
\r
212 /*iterate through the array and get <opts> and <values*/
\r
213 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
215 thisOpt = currentOptsArray[loopcounter];
\r
216 string[] splitOptRange = thisOpt.Split('=');
\r
218 if (thisOpt.Contains("="))
\r
220 optName = splitOptRange[0];
\r
221 optValue = splitOptRange[1];
\r
223 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
224 they need to be added here. This should be moved to its own method probably*/
\r
228 drop_bFrames.SelectedItem = optValue;
\r
231 drop_refFrames.SelectedItem = optValue;
\r
234 this.check_weightp.CheckState = optValue == "0" ? CheckState.Unchecked : CheckState.Checked;
\r
236 case "no-dct-decimate":
\r
237 check_noDCTDecimate.CheckState = CheckState.Checked;
\r
241 if (int.TryParse(optValue, out subqValue))
\r
243 drop_subpixelMotionEstimation.SelectedIndex = subqValue + 1;
\r
250 drop_trellis.SelectedIndex = 1;
\r
253 drop_trellis.SelectedIndex = 2;
\r
256 drop_trellis.SelectedIndex = 3;
\r
261 if (optValue.Equals("dia"))
\r
262 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
263 else if (optValue.Equals("hex"))
\r
264 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
265 else if (optValue.Equals("umh"))
\r
266 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
267 else if (optValue.Equals("esa"))
\r
268 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
269 else if (optValue.Equals("tesa"))
\r
270 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
273 drop_MotionEstimationRange.SelectedItem = optValue;
\r
277 int.TryParse(optValue, out badapt);
\r
278 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
284 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
287 combo_pyrmidalBFrames.SelectedIndex = 2;
\r
290 combo_pyrmidalBFrames.SelectedIndex = 1;
\r
295 if (optValue == "auto")
\r
296 optValue = "Automatic";
\r
298 if (optValue != string.Empty)
\r
300 char[] letters = optValue.ToCharArray();
\r
301 letters[0] = Char.ToUpper(letters[0]);
\r
302 optValue = new string(letters);
\r
305 drop_directPrediction.SelectedItem = optValue;
\r
308 string[] splitDeblock = optValue.Split(',');
\r
309 string alphaDeblock = splitDeblock[0];
\r
310 string betaDeblock = splitDeblock[1];
\r
312 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", string.Empty).Equals("0"))
\r
314 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
315 drop_deblockBeta.SelectedItem = "Default (0)";
\r
319 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
321 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", string.Empty).Equals("0")
\r
322 ? betaDeblock.Replace("\n", string.Empty)
\r
327 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
328 drop_analysis.SelectedItem = "Default (most)";
\r
329 if (optValue.Equals("none"))
\r
330 drop_analysis.SelectedItem = "None";
\r
331 if (optValue.Equals("i4x4,i8x8"))
\r
332 drop_analysis.SelectedItem = "Some";
\r
333 if (optValue.Equals("all"))
\r
334 drop_analysis.SelectedItem = "All";
\r
337 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
339 case "aq-strength":
\r
341 float.TryParse(optValue, out value);
\r
343 int.TryParse((value * 10).ToString(), out sliderValue);
\r
344 slider_adaptiveQuantStrength.Value = sliderValue;
\r
347 check_Cabac.CheckState = CheckState.Unchecked;
\r
350 string[] x = optValue.Split(',');
\r
352 double psyrd, psytrellis;
\r
355 // default psy-rd = 1 (10 for the slider)
\r
356 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
357 // default psy-trellis = 0
\r
358 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 20 : 0.0;
\r
360 int.TryParse(psyrd.ToString(), out val);
\r
361 int.TryParse(psytrellis.ToString(), out val2);
\r
363 slider_psyrd.Value = val;
\r
364 slider_psytrellis.Value = val2;
\r
373 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
375 /// <param name="sender">
\r
378 private void OnX264WidgetChange(string sender)
\r
381 string optNameToChange = sender;
\r
382 string currentOptString = rtf_x264Query.Text;
\r
384 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
385 the first character of the opt string (hence the ":") */
\r
386 string checkOptNameToChange = ":" + optNameToChange + "=";
\r
387 string checkOptNameToChangeBegin = optNameToChange + "=";
\r
389 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
390 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
391 HasOptions(currentOptString, optNameToChange);
\r
392 else // IF there is no options in the rich text box!
\r
393 HasNoOptions(optNameToChange);
\r
397 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
398 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
400 /// <param name="currentOptString">The Current Option String</param>
\r
401 /// <param name="optNameToChange">Name of the option to change</param>
\r
402 private void HasOptions(string currentOptString, string optNameToChange)
\r
404 string thisOpt; // The separated option such as "bframes=3"
\r
405 string optName; // The option name such as "bframes"
\r
406 string[] currentOptsArray;
\r
408 /* Create new empty opt string*/
\r
409 string changedOptString = string.Empty;
\r
411 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
412 currentOptsArray = currentOptString.Split(':');
\r
414 /*iterate through the array and get <opts> and <values*/
\r
415 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
417 thisOpt = currentOptsArray[loopcounter];
\r
419 if (thisOpt.Contains("="))
\r
421 string[] splitOptRange = thisOpt.Split('=');
\r
423 optName = splitOptRange[0]; // e.g bframes
\r
426 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
427 * they need to be added here. This should be moved to its own method probably
\r
428 * If the optNameToChange is found, appropriately change the value or delete it if
\r
429 * "unspecified" is set.
\r
431 if (optName.Equals(optNameToChange))
\r
433 if (optNameToChange.Equals("deblock"))
\r
435 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
436 string db = drop_deblockBeta.SelectedItem.ToString();
\r
438 if (((da.Contains("Default")) && (db.Contains("Default"))) ||
\r
439 ((da.Contains("0")) && (db.Contains("0"))))
\r
441 drop_deblockBeta.SelectedItem = "Default (0)";
\r
442 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
443 thisOpt = string.Empty;
\r
445 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
447 drop_deblockBeta.SelectedItem = "0";
\r
448 thisOpt = "deblock=" + da + ",0";
\r
450 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
452 drop_deblockAlpha.SelectedItem = "0";
\r
453 thisOpt = "deblock=0," + db;
\r
455 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
456 thisOpt = "deblock=" + da + "," + db;
\r
458 else if (optNameToChange.Equals("aq-strength"))
\r
460 if (slider_adaptiveQuantStrength.Value == 10)
\r
461 thisOpt = string.Empty;
\r
464 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
465 string aqs = value.ToString("f1");
\r
466 thisOpt = "aq-strength=" + aqs;
\r
469 else if (optNameToChange.Equals("psy-rd"))
\r
471 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
472 thisOpt = string.Empty;
\r
475 double psyrd = slider_psyrd.Value * 0.1;
\r
476 double psytre = slider_psytrellis.Value * 0.05;
\r
478 string rd = psyrd.ToString("f2");
\r
479 string rt = psytre.ToString("f2");
\r
481 thisOpt = "psy-rd=" + rd + "," + rt;
\r
484 else if (optNameToChange.Equals("b-pyramid"))
\r
486 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
489 thisOpt = string.Empty;
\r
492 thisOpt = "b-pyramid=none";
\r
495 thisOpt = "b-pyramid=strict";
\r
499 else if (optNameToChange.Equals("no-dct-decimate"))
\r
500 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : string.Empty;
\r
501 else if (optNameToChange.Equals("8x8dct"))
\r
502 thisOpt = check_8x8DCT.CheckState == CheckState.Unchecked ? "8x8dct=0" : string.Empty;
\r
503 else if (optNameToChange.Equals("cabac"))
\r
504 thisOpt = check_Cabac.CheckState == CheckState.Checked ? string.Empty : "cabac=0";
\r
505 else if (optNameToChange.Equals("weightp"))
\r
506 thisOpt = check_weightp.CheckState == CheckState.Checked ? string.Empty : "weightp=0";
\r
507 else if (optNameToChange.Equals("me"))
\r
509 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
512 thisOpt = "me=dia";
\r
516 thisOpt = "me=hex";
\r
520 thisOpt = "me=umh";
\r
524 thisOpt = "me=esa";
\r
528 thisOpt = "me=tesa";
\r
532 thisOpt = string.Empty;
\r
536 else if (optNameToChange.Equals("direct"))
\r
538 switch (drop_directPrediction.SelectedIndex)
\r
541 thisOpt = "direct=none";
\r
545 thisOpt = "direct=spatial";
\r
549 thisOpt = "direct=temporal";
\r
553 thisOpt = "direct=auto";
\r
557 thisOpt = string.Empty;
\r
561 else if (optNameToChange.Equals("analyse"))
\r
563 switch (drop_analysis.SelectedIndex)
\r
566 thisOpt = "analyse=none";
\r
570 thisOpt = "analyse=some";
\r
574 thisOpt = "analyse=all";
\r
578 thisOpt = string.Empty;
\r
582 else if (optNameToChange.Equals("merange"))
\r
584 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
585 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
588 else if (optNameToChange.Equals("b-adapt"))
\r
590 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
591 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
594 else if (optNameToChange.Equals("ref"))
\r
596 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
597 ? "ref=" + drop_refFrames.SelectedItem
\r
600 else if (optNameToChange.Equals("bframes"))
\r
602 string value = drop_bFrames.SelectedItem.ToString();
\r
603 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
604 ? "bframes=" + value
\r
607 else if (optNameToChange.Equals("subq"))
\r
609 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
610 string[] val = value.Split(':');
\r
611 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
615 else if (optNameToChange.Equals("trellis"))
\r
617 switch (drop_trellis.SelectedIndex)
\r
620 thisOpt = "trellis=0";
\r
622 case 2: // Encode Only
\r
623 thisOpt = "trellis=1";
\r
626 thisOpt = "trellis=2";
\r
629 thisOpt = string.Empty;
\r
636 /* Construct New String for opts here */
\r
637 if (!thisOpt.Equals(string.Empty))
\r
638 changedOptString = changedOptString.Equals(string.Empty) ? thisOpt : changedOptString + ":" + thisOpt;
\r
641 /* Change the option string to reflect the new mod settings */
\r
642 rtf_x264Query.Text = changedOptString;
\r
646 /// Add's an option to the x264 query string.
\r
647 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
648 /// e.g no-fast-pskip
\r
650 /// <param name="optNameToChange">The Option Name to Change</param>
\r
651 private void HasNoOptions(IEquatable<string> optNameToChange)
\r
653 string colon = string.Empty;
\r
654 if (rtf_x264Query.Text != string.Empty)
\r
657 string query = rtf_x264Query.Text;
\r
658 if (optNameToChange.Equals("me"))
\r
660 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
663 query = query + colon + "me=dia";
\r
667 query = query + colon + "me=hex";
\r
671 query = query + colon + "me=umh";
\r
675 query = query + colon + "me=esa";
\r
679 query = query + colon + "me=tesa";
\r
686 else if (optNameToChange.Equals("direct"))
\r
688 switch (drop_directPrediction.SelectedIndex)
\r
691 query = query + colon + "direct=none";
\r
695 query = query + colon + "direct=spatial";
\r
699 query = query + colon + "direct=temporal";
\r
703 query = query + colon + "direct=auto";
\r
710 else if (optNameToChange.Equals("analyse"))
\r
712 switch (drop_analysis.SelectedIndex)
\r
715 query = query + colon + "analyse=none";
\r
719 query = query + colon + "analyse=some";
\r
723 query = query + colon + "analyse=all";
\r
730 else if (optNameToChange.Equals("merange"))
\r
732 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
733 query = query + colon + "merange=" + value;
\r
735 else if (optNameToChange.Equals("b-adapt"))
\r
737 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
738 query = query + colon + "b-adapt=" + value;
\r
740 else if (optNameToChange.Equals("deblock"))
\r
742 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
743 string db = drop_deblockBeta.Text;
\r
745 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
747 drop_deblockBeta.SelectedItem = "Default (0)";
\r
748 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
752 if (db.Contains("Default"))
\r
755 if (da.Contains("Default"))
\r
758 query = query + colon + "deblock=" + da + "," + db;
\r
761 else if (optNameToChange.Equals("aq-strength"))
\r
763 if (slider_adaptiveQuantStrength.Value == 10)
\r
764 query = string.Empty;
\r
767 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
768 string aqs = value.ToString("f1");
\r
769 query += colon + "aq-strength=" + aqs;
\r
772 else if (optNameToChange.Equals("psy-rd"))
\r
774 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
775 query += string.Empty;
\r
778 double psyrd = slider_psyrd.Value * 0.1;
\r
779 double psytre = slider_psytrellis.Value * 0.05;
\r
781 string rd = psyrd.ToString("f1");
\r
782 string rt = psytre.ToString("f2");
\r
784 query += colon + "psy-rd=" + rd + "," + rt;
\r
787 else if (optNameToChange.Equals("b-pyramid"))
\r
789 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
794 query = query + colon + "b-pyramid=none";
\r
797 query = query + colon + "b-pyramid=strict";
\r
801 else if (optNameToChange.Equals("no-dct-decimate"))
\r
803 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
804 query = query + colon + "no-dct-decimate=1";
\r
806 else if (optNameToChange.Equals("8x8dct"))
\r
808 if (check_8x8DCT.CheckState == CheckState.Unchecked)
\r
809 query = query + colon + "8x8dct=0";
\r
811 else if (optNameToChange.Equals("cabac"))
\r
813 if (check_Cabac.CheckState != CheckState.Checked)
\r
814 query = query + colon + "cabac=0";
\r
816 else if (optNameToChange.Equals("weightp"))
\r
818 if (check_weightp.CheckState == CheckState.Unchecked)
\r
819 query = query + colon + "weightp=0";
\r
821 else if (optNameToChange.Equals("ref"))
\r
823 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
824 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
826 else if (optNameToChange.Equals("bframes"))
\r
828 string value = drop_bFrames.SelectedItem.ToString();
\r
829 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
830 query = query + colon + "bframes=" + value;
\r
832 else if (optNameToChange.Equals("subq"))
\r
834 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
835 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
837 string[] val = value.Split(':');
\r
838 query = query + colon + "subq=" + val[0];
\r
841 else if (optNameToChange.Equals("trellis"))
\r
843 switch (drop_trellis.SelectedIndex)
\r
846 query = query + colon + "trellis=0";
\r
848 case 2: // Encode Only
\r
849 query = query + colon + "trellis=1";
\r
852 query = query + colon + "trellis=2";
\r
859 rtf_x264Query.Text = query;
\r
863 /// Shows and hides controls based on the values of other controls.
\r
865 /// <param name="sender">The Sender</param>
\r
866 private void Animate(string sender)
\r
868 /* Lots of situations to cover.
\r
869 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
870 - CABAC (when 0 turn off trellis and psy-trel
\r
871 - subme (if under 6, turn off psy-rd and psy-trel)
\r
872 - trellis (if 0, turn off psy-trel)
\r
878 if (drop_bFrames.SelectedIndex == 1)
\r
880 /* If the b-frame widget is at 1, the user has chosen
\r
881 not to use b-frames at all. So disable the options
\r
882 that can only be used when b-frames are enabled. */
\r
883 combo_pyrmidalBFrames.Visible = false;
\r
884 lbl_prymidalBframes.Visible = false;
\r
885 drop_directPrediction.Visible = false;
\r
886 lbl_direct_prediction.Visible = false;
\r
888 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
889 drop_directPrediction.SelectedIndex = 0;
\r
891 drop_adaptBFrames.Visible = false;
\r
892 lbl_adaptBFrames.Visible = false;
\r
893 drop_adaptBFrames.SelectedIndex = 0;
\r
895 else if (drop_bFrames.SelectedIndex == 2)
\r
897 /* Only 1 b-frame? Disable b-pyramid. */
\r
898 combo_pyrmidalBFrames.Visible = false;
\r
899 lbl_prymidalBframes.Visible = false;
\r
900 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
902 drop_directPrediction.Visible = true;
\r
903 lbl_direct_prediction.Visible = true;
\r
905 drop_adaptBFrames.Visible = true;
\r
906 lbl_adaptBFrames.Visible = true;
\r
910 combo_pyrmidalBFrames.Visible = true;
\r
911 lbl_prymidalBframes.Visible = true;
\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 if (check_Cabac.Checked == false)
\r
922 /* Without CABAC entropy coding, trellis doesn't run. */
\r
923 drop_trellis.Visible = false;
\r
924 drop_trellis.SelectedIndex = 0;
\r
925 lbl_trellis.Visible = false;
\r
927 slider_psytrellis.Visible = false;
\r
928 lbl_psytrellis.Visible = false;
\r
929 slider_psytrellis.Value = 0;
\r
933 drop_trellis.Visible = true;
\r
934 lbl_trellis.Visible = true;
\r
936 slider_psytrellis.Visible = true;
\r
937 lbl_psytrellis.Visible = true;
\r
940 case "me": // Motion Estimation
\r
941 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
943 drop_MotionEstimationRange.Visible = false;
\r
944 lbl_merange.Visible = false;
\r
945 drop_MotionEstimationRange.SelectedIndex = 0;
\r
949 drop_MotionEstimationRange.Visible = true;
\r
950 lbl_merange.Visible = true;
\r
953 case "subq": // subme
\r
954 if (drop_subpixelMotionEstimation.SelectedIndex != 0 &&
\r
955 drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
957 slider_psyrd.Visible = false;
\r
958 slider_psyrd.Value = 10;
\r
959 lbl_psyrd.Visible = false;
\r
961 slider_psytrellis.Visible = false;
\r
962 slider_psytrellis.Value = 0;
\r
963 lbl_psytrellis.Visible = false;
\r
967 slider_psyrd.Visible = true;
\r
968 lbl_psyrd.Visible = true;
\r
970 if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
972 slider_psytrellis.Visible = true;
\r
973 lbl_psytrellis.Visible = true;
\r
977 case "trellis": // subme
\r
978 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2)
\r
980 slider_psytrellis.Visible = false;
\r
981 slider_psytrellis.Value = 0;
\r
982 lbl_psytrellis.Visible = false;
\r
986 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 ||
\r
987 drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked &&
\r
988 slider_psytrellis.Visible == false)
\r
990 slider_psytrellis.Visible = true;
\r
991 lbl_psytrellis.Visible = true;
\r
1000 private void widgetControlChanged(object sender, EventArgs e)
\r
1002 Control changedControlName = (Control) sender;
\r
1003 string controlName = string.Empty;
\r
1005 switch (changedControlName.Name.Trim())
\r
1007 case "drop_refFrames":
\r
1008 controlName = "ref";
\r
1010 case "drop_bFrames":
\r
1011 controlName = "bframes";
\r
1013 case "drop_directPrediction":
\r
1014 controlName = "direct";
\r
1016 case "check_weightp":
\r
1017 controlName = "weightp";
\r
1019 case "combo_pyrmidalBFrames":
\r
1020 controlName = "b-pyramid";
\r
1022 case "drop_MotionEstimationMethod":
\r
1023 controlName = "me";
\r
1025 case "drop_MotionEstimationRange":
\r
1026 controlName = "merange";
\r
1028 case "drop_subpixelMotionEstimation":
\r
1029 controlName = "subq";
\r
1031 case "drop_analysis":
\r
1032 controlName = "analyse";
\r
1034 case "check_8x8DCT":
\r
1035 controlName = "8x8dct";
\r
1037 case "drop_deblockAlpha":
\r
1038 controlName = "deblock";
\r
1040 case "drop_deblockBeta":
\r
1041 controlName = "deblock";
\r
1043 case "drop_trellis":
\r
1044 controlName = "trellis";
\r
1046 case "check_noDCTDecimate":
\r
1047 controlName = "no-dct-decimate";
\r
1049 case "check_Cabac":
\r
1050 controlName = "cabac";
\r
1052 case "slider_psyrd":
\r
1053 controlName = "psy-rd";
\r
1055 case "slider_psytrellis":
\r
1056 controlName = "psy-rd";
\r
1058 case "slider_adaptiveQuantStrength":
\r
1059 controlName = "aq-strength";
\r
1061 case "drop_adaptBFrames":
\r
1062 controlName = "b-adapt";
\r
1065 OnX264WidgetChange(controlName);
\r
1068 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
1070 if (rtf_x264Query.Text.EndsWith("\n"))
\r
1072 string query = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
1074 rtf_x264Query.Text = query;
\r
1075 this.StandardizeOptString();
\r
1076 this.SetCurrentSettingsInPanel();
\r
1078 if (rtf_x264Query.Text == string.Empty)
\r
1083 private void btn_reset_Click(object sender, EventArgs e)
\r
1085 rtf_x264Query.Text = string.Empty;
\r