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
240 drop_subpixelMotionEstimation.SelectedItem = optValue;
\r
246 drop_trellis.SelectedIndex = 1;
\r
249 drop_trellis.SelectedIndex = 2;
\r
252 drop_trellis.SelectedIndex = 3;
\r
257 if (optValue.Equals("dia"))
\r
258 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
259 else if (optValue.Equals("hex"))
\r
260 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
261 else if (optValue.Equals("umh"))
\r
262 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
263 else if (optValue.Equals("esa"))
\r
264 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
265 else if (optValue.Equals("tesa"))
\r
266 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
269 drop_MotionEstimationRange.SelectedItem = optValue;
\r
273 int.TryParse(optValue, out badapt);
\r
274 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
280 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
283 combo_pyrmidalBFrames.SelectedIndex = 2;
\r
286 combo_pyrmidalBFrames.SelectedIndex = 1;
\r
291 if (optValue == "auto")
\r
292 optValue = "Automatic";
\r
294 if (optValue != string.Empty)
\r
296 char[] letters = optValue.ToCharArray();
\r
297 letters[0] = Char.ToUpper(letters[0]);
\r
298 optValue = new string(letters);
\r
301 drop_directPrediction.SelectedItem = optValue;
\r
304 string[] splitDeblock = optValue.Split(',');
\r
305 string alphaDeblock = splitDeblock[0];
\r
306 string betaDeblock = splitDeblock[1];
\r
308 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", string.Empty).Equals("0"))
\r
310 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
311 drop_deblockBeta.SelectedItem = "Default (0)";
\r
315 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
317 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", string.Empty).Equals("0")
\r
318 ? betaDeblock.Replace("\n", string.Empty)
\r
323 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
324 drop_analysis.SelectedItem = "Default (most)";
\r
325 if (optValue.Equals("none"))
\r
326 drop_analysis.SelectedItem = "None";
\r
327 if (optValue.Equals("i4x4,i8x8"))
\r
328 drop_analysis.SelectedItem = "Some";
\r
329 if (optValue.Equals("all"))
\r
330 drop_analysis.SelectedItem = "All";
\r
333 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
335 case "aq-strength":
\r
337 float.TryParse(optValue, out value);
\r
339 int.TryParse((value * 10).ToString(), out sliderValue);
\r
340 slider_adaptiveQuantStrength.Value = sliderValue;
\r
343 check_Cabac.CheckState = CheckState.Unchecked;
\r
346 string[] x = optValue.Split(',');
\r
348 double psyrd, psytrellis;
\r
351 // default psy-rd = 1 (10 for the slider)
\r
352 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
353 // default psy-trellis = 0
\r
354 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 20 : 0.0;
\r
356 int.TryParse(psyrd.ToString(), out val);
\r
357 int.TryParse(psytrellis.ToString(), out val2);
\r
359 slider_psyrd.Value = val;
\r
360 slider_psytrellis.Value = val2;
\r
369 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
371 /// <param name="sender">
\r
374 private void OnX264WidgetChange(string sender)
\r
377 string optNameToChange = sender;
\r
378 string currentOptString = rtf_x264Query.Text;
\r
380 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
381 the first character of the opt string (hence the ":") */
\r
382 string checkOptNameToChange = ":" + optNameToChange + "=";
\r
383 string checkOptNameToChangeBegin = optNameToChange + "=";
\r
385 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
386 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
387 HasOptions(currentOptString, optNameToChange);
\r
388 else // IF there is no options in the rich text box!
\r
389 HasNoOptions(optNameToChange);
\r
393 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
394 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
396 /// <param name="currentOptString">The Current Option String</param>
\r
397 /// <param name="optNameToChange">Name of the option to change</param>
\r
398 private void HasOptions(string currentOptString, string optNameToChange)
\r
400 string thisOpt; // The separated option such as "bframes=3"
\r
401 string optName; // The option name such as "bframes"
\r
402 string[] currentOptsArray;
\r
404 /* Create new empty opt string*/
\r
405 string changedOptString = string.Empty;
\r
407 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
408 currentOptsArray = currentOptString.Split(':');
\r
410 /*iterate through the array and get <opts> and <values*/
\r
411 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
413 thisOpt = currentOptsArray[loopcounter];
\r
415 if (thisOpt.Contains("="))
\r
417 string[] splitOptRange = thisOpt.Split('=');
\r
419 optName = splitOptRange[0]; // e.g bframes
\r
422 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
423 * they need to be added here. This should be moved to its own method probably
\r
424 * If the optNameToChange is found, appropriately change the value or delete it if
\r
425 * "unspecified" is set.
\r
427 if (optName.Equals(optNameToChange))
\r
429 if (optNameToChange.Equals("deblock"))
\r
431 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
432 string db = drop_deblockBeta.SelectedItem.ToString();
\r
434 if (((da.Contains("Default")) && (db.Contains("Default"))) ||
\r
435 ((da.Contains("0")) && (db.Contains("0"))))
\r
437 drop_deblockBeta.SelectedItem = "Default (0)";
\r
438 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
439 thisOpt = string.Empty;
\r
441 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
443 drop_deblockBeta.SelectedItem = "0";
\r
444 thisOpt = "deblock=" + da + ",0";
\r
446 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
448 drop_deblockAlpha.SelectedItem = "0";
\r
449 thisOpt = "deblock=0," + db;
\r
451 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
452 thisOpt = "deblock=" + da + "," + db;
\r
454 else if (optNameToChange.Equals("aq-strength"))
\r
456 if (slider_adaptiveQuantStrength.Value == 10)
\r
457 thisOpt = string.Empty;
\r
460 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
461 string aqs = value.ToString("f1");
\r
462 thisOpt = "aq-strength=" + aqs;
\r
465 else if (optNameToChange.Equals("psy-rd"))
\r
467 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
468 thisOpt = string.Empty;
\r
471 double psyrd = slider_psyrd.Value * 0.1;
\r
472 double psytre = slider_psytrellis.Value * 0.05;
\r
474 string rd = psyrd.ToString("f2");
\r
475 string rt = psytre.ToString("f2");
\r
477 thisOpt = "psy-rd=" + rd + "," + rt;
\r
480 else if (optNameToChange.Equals("b-pyramid"))
\r
482 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
485 thisOpt = string.Empty;
\r
488 thisOpt = "b-pyramid=none";
\r
491 thisOpt = "b-pyramid=strict";
\r
495 else if (optNameToChange.Equals("no-dct-decimate"))
\r
496 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : string.Empty;
\r
497 else if (optNameToChange.Equals("8x8dct"))
\r
498 thisOpt = check_8x8DCT.CheckState == CheckState.Unchecked ? "8x8dct=0" : string.Empty;
\r
499 else if (optNameToChange.Equals("cabac"))
\r
500 thisOpt = check_Cabac.CheckState == CheckState.Checked ? string.Empty : "cabac=0";
\r
501 else if (optNameToChange.Equals("weightp"))
\r
502 thisOpt = check_weightp.CheckState == CheckState.Checked ? string.Empty : "weightp=0";
\r
503 else if (optNameToChange.Equals("me"))
\r
505 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
508 thisOpt = "me=dia";
\r
512 thisOpt = "me=hex";
\r
516 thisOpt = "me=umh";
\r
520 thisOpt = "me=esa";
\r
524 thisOpt = "me=tesa";
\r
528 thisOpt = string.Empty;
\r
532 else if (optNameToChange.Equals("direct"))
\r
534 switch (drop_directPrediction.SelectedIndex)
\r
537 thisOpt = "direct=none";
\r
541 thisOpt = "direct=spatial";
\r
545 thisOpt = "direct=temporal";
\r
549 thisOpt = "direct=auto";
\r
553 thisOpt = string.Empty;
\r
557 else if (optNameToChange.Equals("analyse"))
\r
559 switch (drop_analysis.SelectedIndex)
\r
562 thisOpt = "analyse=none";
\r
566 thisOpt = "analyse=some";
\r
570 thisOpt = "analyse=all";
\r
574 thisOpt = string.Empty;
\r
578 else if (optNameToChange.Equals("merange"))
\r
580 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
581 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
584 else if (optNameToChange.Equals("b-adapt"))
\r
586 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
587 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
590 else if (optNameToChange.Equals("ref"))
\r
592 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
593 ? "ref=" + drop_refFrames.SelectedItem
\r
596 else if (optNameToChange.Equals("bframes"))
\r
598 string value = drop_bFrames.SelectedItem.ToString();
\r
599 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
600 ? "bframes=" + value
\r
603 else if (optNameToChange.Equals("subq"))
\r
605 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
606 string[] val = value.Split(':');
\r
607 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
611 else if (optNameToChange.Equals("trellis"))
\r
613 switch (drop_trellis.SelectedIndex)
\r
616 thisOpt = "trellis=0";
\r
618 case 2: // Encode Only
\r
619 thisOpt = "trellis=1";
\r
622 thisOpt = "trellis=2";
\r
625 thisOpt = string.Empty;
\r
632 /* Construct New String for opts here */
\r
633 if (!thisOpt.Equals(string.Empty))
\r
634 changedOptString = changedOptString.Equals(string.Empty) ? thisOpt : changedOptString + ":" + thisOpt;
\r
637 /* Change the option string to reflect the new mod settings */
\r
638 rtf_x264Query.Text = changedOptString;
\r
642 /// Add's an option to the x264 query string.
\r
643 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
644 /// e.g no-fast-pskip
\r
646 /// <param name="optNameToChange">The Option Name to Change</param>
\r
647 private void HasNoOptions(IEquatable<string> optNameToChange)
\r
649 string colon = string.Empty;
\r
650 if (rtf_x264Query.Text != string.Empty)
\r
653 string query = rtf_x264Query.Text;
\r
654 if (optNameToChange.Equals("me"))
\r
656 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
659 query = query + colon + "me=dia";
\r
663 query = query + colon + "me=hex";
\r
667 query = query + colon + "me=umh";
\r
671 query = query + colon + "me=esa";
\r
675 query = query + colon + "me=tesa";
\r
682 else if (optNameToChange.Equals("direct"))
\r
684 switch (drop_directPrediction.SelectedIndex)
\r
687 query = query + colon + "direct=none";
\r
691 query = query + colon + "direct=spatial";
\r
695 query = query + colon + "direct=temporal";
\r
699 query = query + colon + "direct=auto";
\r
706 else if (optNameToChange.Equals("analyse"))
\r
708 switch (drop_analysis.SelectedIndex)
\r
711 query = query + colon + "analyse=none";
\r
715 query = query + colon + "analyse=some";
\r
719 query = query + colon + "analyse=all";
\r
726 else if (optNameToChange.Equals("merange"))
\r
728 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
729 query = query + colon + "merange=" + value;
\r
731 else if (optNameToChange.Equals("b-adapt"))
\r
733 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
734 query = query + colon + "b-adapt=" + value;
\r
736 else if (optNameToChange.Equals("deblock"))
\r
738 string da = drop_deblockAlpha.SelectedItem.ToString();
\r
739 string db = drop_deblockBeta.Text;
\r
741 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
743 drop_deblockBeta.SelectedItem = "Default (0)";
\r
744 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
748 if (db.Contains("Default"))
\r
751 if (da.Contains("Default"))
\r
754 query = query + colon + "deblock=" + da + "," + db;
\r
757 else if (optNameToChange.Equals("aq-strength"))
\r
759 if (slider_adaptiveQuantStrength.Value == 10)
\r
760 query = string.Empty;
\r
763 double value = slider_adaptiveQuantStrength.Value * 0.1;
\r
764 string aqs = value.ToString("f1");
\r
765 query += colon + "aq-strength=" + aqs;
\r
768 else if (optNameToChange.Equals("psy-rd"))
\r
770 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
771 query += string.Empty;
\r
774 double psyrd = slider_psyrd.Value * 0.1;
\r
775 double psytre = slider_psytrellis.Value * 0.05;
\r
777 string rd = psyrd.ToString("f1");
\r
778 string rt = psytre.ToString("f2");
\r
780 query += colon + "psy-rd=" + rd + "," + rt;
\r
783 else if (optNameToChange.Equals("b-pyramid"))
\r
785 switch (combo_pyrmidalBFrames.SelectedIndex)
\r
790 query = query + colon + "b-pyramid=none";
\r
793 query = query + colon + "b-pyramid=strict";
\r
797 else if (optNameToChange.Equals("no-dct-decimate"))
\r
799 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
800 query = query + colon + "no-dct-decimate=1";
\r
802 else if (optNameToChange.Equals("8x8dct"))
\r
804 if (check_8x8DCT.CheckState == CheckState.Unchecked)
\r
805 query = query + colon + "8x8dct=0";
\r
807 else if (optNameToChange.Equals("cabac"))
\r
809 if (check_Cabac.CheckState != CheckState.Checked)
\r
810 query = query + colon + "cabac=0";
\r
812 else if (optNameToChange.Equals("weightp"))
\r
814 if (check_weightp.CheckState == CheckState.Unchecked)
\r
815 query = query + colon + "weightp=0";
\r
817 else if (optNameToChange.Equals("ref"))
\r
819 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
820 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
822 else if (optNameToChange.Equals("bframes"))
\r
824 string value = drop_bFrames.SelectedItem.ToString();
\r
825 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
826 query = query + colon + "bframes=" + value;
\r
828 else if (optNameToChange.Equals("subq"))
\r
830 string value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
831 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
833 string[] val = value.Split(':');
\r
834 query = query + colon + "subq=" + val[0];
\r
837 else if (optNameToChange.Equals("trellis"))
\r
839 switch (drop_trellis.SelectedIndex)
\r
842 query = query + colon + "trellis=0";
\r
844 case 2: // Encode Only
\r
845 query = query + colon + "trellis=1";
\r
848 query = query + colon + "trellis=2";
\r
855 rtf_x264Query.Text = query;
\r
859 /// Shows and hides controls based on the values of other controls.
\r
861 /// <param name="sender">The Sender</param>
\r
862 private void Animate(string sender)
\r
864 /* Lots of situations to cover.
\r
865 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
866 - CABAC (when 0 turn off trellis and psy-trel
\r
867 - subme (if under 6, turn off psy-rd and psy-trel)
\r
868 - trellis (if 0, turn off psy-trel)
\r
874 if (drop_bFrames.SelectedIndex == 1)
\r
876 /* If the b-frame widget is at 1, the user has chosen
\r
877 not to use b-frames at all. So disable the options
\r
878 that can only be used when b-frames are enabled. */
\r
879 combo_pyrmidalBFrames.Visible = false;
\r
880 lbl_prymidalBframes.Visible = false;
\r
881 drop_directPrediction.Visible = false;
\r
882 lbl_direct_prediction.Visible = false;
\r
884 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
885 drop_directPrediction.SelectedIndex = 0;
\r
887 drop_adaptBFrames.Visible = false;
\r
888 lbl_adaptBFrames.Visible = false;
\r
889 drop_adaptBFrames.SelectedIndex = 0;
\r
891 else if (drop_bFrames.SelectedIndex == 2)
\r
893 /* Only 1 b-frame? Disable b-pyramid. */
\r
894 combo_pyrmidalBFrames.Visible = false;
\r
895 lbl_prymidalBframes.Visible = false;
\r
896 combo_pyrmidalBFrames.SelectedIndex = 0;
\r
898 drop_directPrediction.Visible = true;
\r
899 lbl_direct_prediction.Visible = true;
\r
901 drop_adaptBFrames.Visible = true;
\r
902 lbl_adaptBFrames.Visible = true;
\r
906 combo_pyrmidalBFrames.Visible = true;
\r
907 lbl_prymidalBframes.Visible = true;
\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 if (check_Cabac.Checked == false)
\r
918 /* Without CABAC entropy coding, trellis doesn't run. */
\r
919 drop_trellis.Visible = false;
\r
920 drop_trellis.SelectedIndex = 0;
\r
921 lbl_trellis.Visible = false;
\r
923 slider_psytrellis.Visible = false;
\r
924 lbl_psytrellis.Visible = false;
\r
925 slider_psytrellis.Value = 0;
\r
929 drop_trellis.Visible = true;
\r
930 lbl_trellis.Visible = true;
\r
932 slider_psytrellis.Visible = true;
\r
933 lbl_psytrellis.Visible = true;
\r
936 case "me": // Motion Estimation
\r
937 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
939 drop_MotionEstimationRange.Visible = false;
\r
940 lbl_merange.Visible = false;
\r
941 drop_MotionEstimationRange.SelectedIndex = 0;
\r
945 drop_MotionEstimationRange.Visible = true;
\r
946 lbl_merange.Visible = true;
\r
949 case "subq": // subme
\r
950 if (drop_subpixelMotionEstimation.SelectedIndex != 0 &&
\r
951 drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
953 slider_psyrd.Visible = false;
\r
954 slider_psyrd.Value = 10;
\r
955 lbl_psyrd.Visible = false;
\r
957 slider_psytrellis.Visible = false;
\r
958 slider_psytrellis.Value = 0;
\r
959 lbl_psytrellis.Visible = false;
\r
963 slider_psyrd.Visible = true;
\r
964 lbl_psyrd.Visible = true;
\r
966 if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
968 slider_psytrellis.Visible = true;
\r
969 lbl_psytrellis.Visible = true;
\r
973 case "trellis": // subme
\r
974 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2)
\r
976 slider_psytrellis.Visible = false;
\r
977 slider_psytrellis.Value = 0;
\r
978 lbl_psytrellis.Visible = false;
\r
982 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 ||
\r
983 drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked &&
\r
984 slider_psytrellis.Visible == false)
\r
986 slider_psytrellis.Visible = true;
\r
987 lbl_psytrellis.Visible = true;
\r
996 private void widgetControlChanged(object sender, EventArgs e)
\r
998 Control changedControlName = (Control) sender;
\r
999 string controlName = string.Empty;
\r
1001 switch (changedControlName.Name.Trim())
\r
1003 case "drop_refFrames":
\r
1004 controlName = "ref";
\r
1006 case "drop_bFrames":
\r
1007 controlName = "bframes";
\r
1009 case "drop_directPrediction":
\r
1010 controlName = "direct";
\r
1012 case "check_weightp":
\r
1013 controlName = "weightp";
\r
1015 case "combo_pyrmidalBFrames":
\r
1016 controlName = "b-pyramid";
\r
1018 case "drop_MotionEstimationMethod":
\r
1019 controlName = "me";
\r
1021 case "drop_MotionEstimationRange":
\r
1022 controlName = "merange";
\r
1024 case "drop_subpixelMotionEstimation":
\r
1025 controlName = "subq";
\r
1027 case "drop_analysis":
\r
1028 controlName = "analyse";
\r
1030 case "check_8x8DCT":
\r
1031 controlName = "8x8dct";
\r
1033 case "drop_deblockAlpha":
\r
1034 controlName = "deblock";
\r
1036 case "drop_deblockBeta":
\r
1037 controlName = "deblock";
\r
1039 case "drop_trellis":
\r
1040 controlName = "trellis";
\r
1042 case "check_noDCTDecimate":
\r
1043 controlName = "no-dct-decimate";
\r
1045 case "check_Cabac":
\r
1046 controlName = "cabac";
\r
1048 case "slider_psyrd":
\r
1049 controlName = "psy-rd";
\r
1051 case "slider_psytrellis":
\r
1052 controlName = "psy-rd";
\r
1054 case "slider_adaptiveQuantStrength":
\r
1055 controlName = "aq-strength";
\r
1057 case "drop_adaptBFrames":
\r
1058 controlName = "b-adapt";
\r
1061 OnX264WidgetChange(controlName);
\r
1064 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
1066 if (rtf_x264Query.Text.EndsWith("\n"))
\r
1068 string query = rtf_x264Query.Text.Replace("\n", string.Empty);
\r
1070 rtf_x264Query.Text = query;
\r
1071 this.StandardizeOptString();
\r
1072 this.SetCurrentSettingsInPanel();
\r
1074 if (rtf_x264Query.Text == string.Empty)
\r
1079 private void btn_reset_Click(object sender, EventArgs e)
\r
1081 rtf_x264Query.Text = string.Empty;
\r