3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.fr>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
8 using System.Windows.Forms;
\r
10 namespace Handbrake.Controls
\r
12 public partial class x264Panel : UserControl
\r
15 * TODO This code was ported from the obj-c MacGUI code. It's really messy and could really do with being cleaned up
\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
37 get { return " -x " + rtf_x264Query.Text; }
\r
38 set { rtf_x264Query.Text = value; }
\r
42 /// Reset all components to defaults and clears the x264 rtf box
\r
44 public void Reset2Defaults()
\r
46 check_8x8DCT.CheckState = CheckState.Checked;
\r
47 check_Cabac.CheckState = CheckState.Checked;
\r
48 check_mixedReferences.CheckState = CheckState.Checked;
\r
49 check_noDCTDecimate.CheckState = CheckState.Unchecked;
\r
50 check_noFastPSkip.CheckState = CheckState.Unchecked;
\r
51 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
52 check_weightedBFrames.CheckState = CheckState.Checked;
\r
53 drop_analysis.SelectedIndex = 0;
\r
54 drop_bFrames.SelectedIndex = 0;
\r
55 drop_deblockAlpha.SelectedIndex = 0;
\r
56 drop_deblockBeta.SelectedIndex = 0;
\r
57 drop_directPrediction.SelectedIndex = 0;
\r
58 drop_MotionEstimationMethod.SelectedIndex = 0;
\r
59 drop_MotionEstimationRange.SelectedIndex = 0;
\r
60 drop_refFrames.SelectedIndex = 0;
\r
61 drop_subpixelMotionEstimation.SelectedIndex = 0;
\r
62 drop_trellis.SelectedIndex = 0;
\r
63 slider_psyrd.Value = 10;
\r
64 slider_psytrellis.Value = 0;
\r
65 drop_adaptBFrames.SelectedIndex = 0;
\r
67 rtf_x264Query.Text = "";
\r
71 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
73 public void X264_StandardizeOptString()
\r
75 /* Set widgets depending on the opt string in field */
\r
76 String thisOpt; // The separated option such as "bframes=3"
\r
77 String optName; // The option name such as "bframes"
\r
78 String optValue;// The option value such as "3"
\r
79 String changedOptString = "";
\r
80 String[] currentOptsArray;
\r
82 /*First, we get an opt string to process */
\r
83 String currentOptString = rtf_x264Query.Text;
\r
85 /*verify there is an opt string to process */
\r
86 if (currentOptString.Contains("="))
\r
88 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
89 currentOptsArray = currentOptString.Split(':');
\r
91 /*iterate through the array and get <opts> and <values*/
\r
93 int currentOptsArrayCount = currentOptsArray.Length;
\r
94 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
96 thisOpt = currentOptsArray[loopcounter];
\r
97 if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
\r
100 String[] splitOptRange = thisOpt.Split('=');
\r
103 if (thisOpt.Contains("="))
\r
105 optName = splitOptRange[0];
\r
106 optValue = splitOptRange[1];
\r
108 /* Standardize the names here depending on whats in the string */
\r
109 optName = X264_StandardizeOptNames(optName);
\r
110 thisOpt = optName + "=" + optValue;
\r
112 else // No value given so we use a default of "1"
\r
115 /* Standardize the names here depending on whats in the string */
\r
116 optName = X264_StandardizeOptNames(optName);
\r
117 thisOpt = optName + "=1";
\r
121 /* Construct New String for opts here */
\r
122 if (thisOpt == string.Empty)
\r
123 changedOptString = changedOptString + thisOpt;
\r
126 if (changedOptString == string.Empty)
\r
127 changedOptString = thisOpt;
\r
129 changedOptString = changedOptString + ":" + thisOpt;
\r
134 /* Change the option string to reflect the new standardized option string */
\r
135 if (changedOptString != "")
\r
136 rtf_x264Query.Text = changedOptString;
\r
140 /// Take a single option and standardize it. Returns as a String
\r
141 /// Input: String. - Single X264 Option. Name only
\r
142 /// Output: String - Single X264 Option. Name only. Changed to standard format
\r
144 /// <param name="cleanOptNameString"></param>
\r
145 /// <returns></returns>
\r
146 private static string X264_StandardizeOptNames(String cleanOptNameString)
\r
148 String input = cleanOptNameString;
\r
150 if (input.Equals("ref") || input.Equals("frameref"))
\r
151 cleanOptNameString = "ref";
\r
153 /*No Fast PSkip nofast_pskip*/
\r
154 if (input.Equals("no-fast-pskip") || input.Equals("no_fast_pskip") || input.Equals("nofast_pskip"))
\r
155 cleanOptNameString = "no-fast-pskip";
\r
157 /*No Dict Decimate*/
\r
158 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
159 cleanOptNameString = "no-dct-decimate";
\r
162 if (input.Equals("subme"))
\r
163 cleanOptNameString = "subq";
\r
166 if (input.Equals("me-range") || input.Equals("me_range"))
\r
167 cleanOptNameString = "merange";
\r
170 if (input.Equals("weight-b") || input.Equals("weight_b"))
\r
171 cleanOptNameString = "weightb";
\r
174 if (input.Equals("b_pyramid"))
\r
175 cleanOptNameString = "b-pyramid";
\r
177 /*Direct Prediction*/
\r
178 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
179 cleanOptNameString = "direct";
\r
182 if (input.Equals("filter"))
\r
183 cleanOptNameString = "deblock";
\r
186 if (input.Equals("partitions"))
\r
187 cleanOptNameString = "analyse";
\r
189 return cleanOptNameString;
\r
193 /// Resets the GUI widgets to the contents of the option string.
\r
195 public void X264_SetCurrentSettingsInPanel()
\r
197 /* Set widgets depending on the opt string in field */
\r
198 String thisOpt; // The separated option such as "bframes=3"
\r
199 String optName; // The option name such as "bframes"
\r
200 String optValue;// The option value such as "3"
\r
201 String[] currentOptsArray;
\r
203 //Set currentOptString to the contents of the text box.
\r
204 String currentOptString = rtf_x264Query.Text.Replace("\n", "");
\r
206 /*verify there is an opt string to process */
\r
207 if (currentOptString.Contains("="))
\r
209 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
210 currentOptsArray = currentOptString.Split(':');
\r
212 /*iterate through the array and get <opts> and <values*/
\r
214 int currentOptsArrayCount = currentOptsArray.Length;
\r
216 /*iterate through the array and get <opts> and <values*/
\r
217 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
219 thisOpt = currentOptsArray[loopcounter];
\r
220 String[] splitOptRange = thisOpt.Split('=');
\r
222 if (thisOpt.Contains("="))
\r
224 optName = splitOptRange[0];
\r
225 optValue = splitOptRange[1];
\r
227 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
228 they need to be added here. This should be moved to its own method probably*/
\r
232 drop_bFrames.SelectedItem = optValue;
\r
235 drop_refFrames.SelectedItem = optValue;
\r
237 case "no-fast-pskip":
\r
238 check_noFastPSkip.CheckState = CheckState.Checked;
\r
240 case "no-dct-decimate":
\r
241 check_noDCTDecimate.CheckState = CheckState.Checked;
\r
244 drop_subpixelMotionEstimation.SelectedItem = optValue;
\r
247 drop_trellis.SelectedItem = optValue;
\r
250 check_mixedReferences.CheckState = CheckState.Checked;
\r
253 if (optValue.Equals("dia"))
\r
254 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
255 else if (optValue.Equals("hex"))
\r
256 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
257 else if (optValue.Equals("umh"))
\r
258 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
259 else if (optValue.Equals("esa"))
\r
260 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
261 else if (optValue.Equals("tesa"))
\r
262 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
265 drop_MotionEstimationRange.SelectedItem = optValue;
\r
269 int.TryParse(optValue, out badapt);
\r
270 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
273 if (optValue != "0")
\r
274 check_weightedBFrames.CheckState = CheckState.Checked;
\r
276 check_weightedBFrames.CheckState = CheckState.Unchecked;
\r
279 check_pyrmidalBFrames.CheckState = CheckState.Checked;
\r
282 if (optValue == "auto")
\r
283 optValue = "Automatic";
\r
285 if (optValue != "")
\r
287 Char[] letters = optValue.ToCharArray();
\r
288 letters[0] = Char.ToUpper(letters[0]);
\r
289 optValue = new string(letters);
\r
292 drop_directPrediction.SelectedItem = optValue;
\r
295 string[] splitDeblock = optValue.Split(',');
\r
296 string alphaDeblock = splitDeblock[0];
\r
297 string betaDeblock = splitDeblock[1];
\r
299 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
\r
301 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
302 drop_deblockBeta.SelectedItem = "Default (0)";
\r
306 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
308 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", "").Equals("0") ? betaDeblock.Replace("\n", "") : "0";
\r
312 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
313 drop_analysis.SelectedItem = "Default (some)";
\r
314 if (optValue.Equals("none"))
\r
315 drop_analysis.SelectedItem = "None";
\r
316 if (optValue.Equals("all"))
\r
317 drop_analysis.SelectedItem = "All";
\r
320 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
323 check_Cabac.CheckState = CheckState.Unchecked;
\r
326 string[] x = optValue.Split(',');
\r
328 double psyrd, psytrellis;
\r
331 // default psy-rd = 1 (10 for the slider)
\r
332 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
333 // default psy-trellis = 0
\r
334 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 10 : 0.0;
\r
336 int.TryParse(psyrd.ToString(), out val);
\r
337 int.TryParse(psytrellis.ToString(), out val2);
\r
339 slider_psyrd.Value = val;
\r
340 slider_psytrellis.Value = val2;
\r
349 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
351 private void OnX264WidgetChange(string sender)
\r
354 String optNameToChange = sender;
\r
355 String currentOptString = rtf_x264Query.Text;
\r
357 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
358 the first character of the opt string (hence the ":") */
\r
359 String checkOptNameToChange = ":" + optNameToChange + "=";
\r
360 String checkOptNameToChangeBegin = optNameToChange + "=";
\r
362 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
363 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
364 HasOptions(currentOptString, optNameToChange);
\r
365 else // IF there is no options in the rich text box!
\r
366 HasNoOptions(optNameToChange);
\r
370 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
371 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
373 /// <param name="currentOptString"></param>
\r
374 /// <param name="optNameToChange"></param>
\r
375 private void HasOptions(string currentOptString, string optNameToChange)
\r
377 String thisOpt; // The separated option such as "bframes=3"
\r
378 String optName; // The option name such as "bframes"
\r
379 String[] currentOptsArray;
\r
381 /* Create new empty opt string*/
\r
382 String changedOptString = "";
\r
384 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
385 currentOptsArray = currentOptString.Split(':');
\r
387 /*iterate through the array and get <opts> and <values*/
\r
388 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
390 thisOpt = currentOptsArray[loopcounter];
\r
392 if (thisOpt.Contains("="))
\r
394 string[] splitOptRange = thisOpt.Split('=');
\r
396 optName = splitOptRange[0]; // e.g bframes
\r
399 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
400 * they need to be added here. This should be moved to its own method probably
\r
401 * If the optNameToChange is found, appropriately change the value or delete it if
\r
402 * "unspecified" is set.
\r
404 if (optName.Equals(optNameToChange))
\r
406 if (optNameToChange.Equals("deblock"))
\r
408 String da = drop_deblockAlpha.SelectedItem.ToString();
\r
409 String db = drop_deblockBeta.SelectedItem.ToString();
\r
411 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
413 drop_deblockBeta.SelectedItem = "Default (0)";
\r
414 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
417 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
419 drop_deblockBeta.SelectedItem = "0";
\r
420 thisOpt = "deblock=" + da + ",0";
\r
422 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
424 drop_deblockAlpha.SelectedItem = "0";
\r
425 thisOpt = "deblock=0," + db;
\r
427 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
428 thisOpt = "deblock=" + da + "," + db;
\r
430 else if (optNameToChange.Equals("psy-rd"))
\r
432 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
436 double psyrd = slider_psyrd.Value * 0.1;
\r
437 double psytre = slider_psytrellis.Value * 0.1;
\r
439 string rd = psyrd.ToString("f1");
\r
440 string rt = psytre.ToString("f1");
\r
442 thisOpt = "psy-rd=" + rd + "," + rt;
\r
445 else if (optNameToChange.Equals("mixed-refs"))
\r
446 thisOpt = check_mixedReferences.CheckState == CheckState.Checked ? "mixed-refs=1" : "mixed-refs=0";
\r
447 else if (optNameToChange.Equals("weightb"))
\r
448 thisOpt = check_weightedBFrames.CheckState == CheckState.Checked ? "" : "weightb=0";
\r
449 else if (optNameToChange.Equals("b-pyramid"))
\r
450 thisOpt = check_pyrmidalBFrames.CheckState == CheckState.Checked ? "b-pyramid=1" : "";
\r
451 else if (optNameToChange.Equals("no-fast-pskip"))
\r
452 thisOpt = check_noFastPSkip.CheckState == CheckState.Checked ? "no-fast-pskip=1" : "";
\r
453 else if (optNameToChange.Equals("no-dct-decimate"))
\r
454 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : "";
\r
455 else if (optNameToChange.Equals("8x8dct"))
\r
456 thisOpt = check_8x8DCT.CheckState == CheckState.Checked ? "8x8dct=1" : "8x8dct=0";
\r
457 else if (optNameToChange.Equals("cabac"))
\r
458 thisOpt = check_Cabac.CheckState == CheckState.Checked ? "" : "cabac=0";
\r
459 else if (optNameToChange.Equals("me"))
\r
461 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
464 thisOpt = "me=dia";
\r
468 thisOpt = "me=hex";
\r
472 thisOpt = "me=umh";
\r
476 thisOpt = "me=esa";
\r
480 thisOpt = "me=tesa";
\r
488 else if (optNameToChange.Equals("direct"))
\r
490 switch (drop_directPrediction.SelectedIndex)
\r
493 thisOpt = "direct=none";
\r
497 thisOpt = "direct=spatial";
\r
501 thisOpt = "direct=temporal";
\r
505 thisOpt = "direct=auto";
\r
513 else if (optNameToChange.Equals("analyse"))
\r
515 switch (drop_analysis.SelectedIndex)
\r
518 thisOpt = "analyse=none";
\r
522 thisOpt = "analyse=all";
\r
530 else if (optNameToChange.Equals("merange"))
\r
532 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
533 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
536 else if (optNameToChange.Equals("b-adapt"))
\r
538 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
539 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
542 else if (optNameToChange.Equals("ref"))
\r
544 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
545 ? "ref=" + drop_refFrames.SelectedItem
\r
548 else if (optNameToChange.Equals("bframes"))
\r
550 String value = drop_bFrames.SelectedItem.ToString();
\r
551 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
552 ? "bframes=" + value
\r
555 else if (optNameToChange.Equals("subq"))
\r
557 String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
558 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
562 else if (optNameToChange.Equals("trellis"))
\r
564 String value = drop_trellis.SelectedItem.ToString();
\r
565 thisOpt = !drop_trellis.SelectedItem.ToString().Contains("Default")
\r
566 ? "trellis=" + value
\r
572 /* Construct New String for opts here */
\r
573 if (!thisOpt.Equals(""))
\r
574 changedOptString = changedOptString.Equals("") ? thisOpt : changedOptString + ":" + thisOpt;
\r
577 /* Change the option string to reflect the new mod settings */
\r
578 rtf_x264Query.Text = changedOptString;
\r
582 /// Add's an option to the x264 query string.
\r
583 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
584 /// e.g no-fast-pskip
\r
586 /// <param name="optNameToChange"></param>
\r
587 private void HasNoOptions(IEquatable<string> optNameToChange)
\r
590 if (rtf_x264Query.Text != "")
\r
593 string query = rtf_x264Query.Text;
\r
594 if (optNameToChange.Equals("me"))
\r
596 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
599 query = query + colon + "me=dia";
\r
603 query = query + colon + "me=hex";
\r
607 query = query + colon + "me=umh";
\r
611 query = query + colon + "me=esa";
\r
615 query = query + colon + "me=tesa";
\r
622 else if (optNameToChange.Equals("direct"))
\r
624 switch (drop_directPrediction.SelectedIndex)
\r
627 query = query + colon + "direct=none";
\r
631 query = query + colon + "direct=spatial";
\r
635 query = query + colon + "direct=temporal";
\r
639 query = query + colon + "direct=auto";
\r
646 else if (optNameToChange.Equals("analyse"))
\r
648 switch (drop_analysis.SelectedIndex)
\r
651 query = query + colon + "analyse=none";
\r
655 query = query + colon + "analyse=all";
\r
662 else if (optNameToChange.Equals("merange"))
\r
664 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
665 query = query + colon + "merange=" + value;
\r
667 else if (optNameToChange.Equals("b-adapt"))
\r
669 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
670 query = query + colon + "b-adapt=" + value;
\r
673 else if (optNameToChange.Equals("deblock"))
\r
675 String da = drop_deblockAlpha.SelectedItem.ToString();
\r
676 String db = drop_deblockBeta.Text;
\r
678 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
680 drop_deblockBeta.SelectedItem = "Default (0)";
\r
681 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
685 if (db.Contains("Default"))
\r
688 if (da.Contains("Default"))
\r
691 query = query + colon + "deblock=" + da + "," + db;
\r
694 else if (optNameToChange.Equals("psy-rd"))
\r
696 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
700 double psyrd = slider_psyrd.Value * 0.1;
\r
701 double psytre = slider_psytrellis.Value * 0.1;
\r
703 string rd = psyrd.ToString("f1");
\r
704 string rt = psytre.ToString("f1");
\r
706 query += colon + "psy-rd=" + rd + "," + rt;
\r
709 else if (optNameToChange.Equals("mixed-refs"))
\r
711 if (check_mixedReferences.CheckState == CheckState.Checked)
\r
712 query = query + colon + "mixed-refs=1";
\r
714 query = query + colon + "mixed-refs=0";
\r
716 else if (optNameToChange.Equals("weightb"))
\r
718 if (check_weightedBFrames.CheckState != CheckState.Checked)
\r
719 query = query + colon + "weightb=0";
\r
721 else if (optNameToChange.Equals("b-pyramid"))
\r
723 if (check_pyrmidalBFrames.CheckState == CheckState.Checked)
\r
724 query = query + colon + "b-pyramid=1";
\r
726 else if (optNameToChange.Equals("no-fast-pskip"))
\r
728 if (check_noFastPSkip.CheckState == CheckState.Checked)
\r
729 query = query + colon + "no-fast-pskip=1";
\r
731 else if (optNameToChange.Equals("no-dct-decimate"))
\r
733 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
734 query = query + colon + "no-dct-decimate=1";
\r
736 else if (optNameToChange.Equals("8x8dct"))
\r
738 if (check_8x8DCT.CheckState == CheckState.Checked)
\r
739 query = query + colon + "8x8dct=1";
\r
741 else if (optNameToChange.Equals("cabac"))
\r
743 if (check_Cabac.CheckState != CheckState.Checked)
\r
744 query = query + colon + "cabac=0";
\r
746 else if (optNameToChange.Equals("ref"))
\r
748 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
749 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
751 else if (optNameToChange.Equals("bframes"))
\r
753 String value = drop_bFrames.SelectedItem.ToString();
\r
754 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
755 query = query + colon + "bframes=" + value;
\r
757 else if (optNameToChange.Equals("subq"))
\r
759 String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
760 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
761 query = query + colon + "subq=" + value;
\r
763 else if (optNameToChange.Equals("trellis"))
\r
765 if (!drop_trellis.SelectedItem.ToString().Contains("Default"))
\r
766 query = query + colon + "trellis=" + drop_trellis.SelectedItem;
\r
769 rtf_x264Query.Text = query;
\r
773 /// Shows and hides controls based on the values of other controls.
\r
775 /// <param name="sender"></param>
\r
776 private void Animate(string sender)
\r
778 /* Lots of situations to cover.
\r
779 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
780 - CABAC (when 0 turn off trellis)
\r
781 - analysis (if none, turn off 8x8dct)
\r
782 - refs (under 2, disable mixed-refs)
\r
783 - subme (if under 6, turn off psy-rd and psy-trel)
\r
784 - trellis (if 0, turn off psy-trel)
\r
790 if (drop_bFrames.SelectedIndex >0 && drop_bFrames.SelectedIndex < 2 )
\r
792 /* If the b-frame widget is at 0 or 1, the user has chosen
\r
793 not to use b-frames at all. So disable the options
\r
794 that can only be used when b-frames are enabled. */
\r
795 check_weightedBFrames.Visible = false;
\r
796 check_pyrmidalBFrames.Visible = false;
\r
797 drop_directPrediction.Visible = false;
\r
798 lbl_direct_prediction.Visible = false;
\r
800 check_weightedBFrames.CheckState = CheckState.Unchecked;
\r
801 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
802 drop_directPrediction.SelectedIndex = 0;
\r
804 drop_adaptBFrames.Visible = false;
\r
805 lbl_adaptBFrames.Visible = false;
\r
806 drop_adaptBFrames.SelectedIndex = 0;
\r
808 else if (drop_bFrames.SelectedIndex == 2)
\r
810 /* Only 1 b-frame? Disable b-pyramid. */
\r
811 check_pyrmidalBFrames.Visible = false;
\r
812 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
814 check_weightedBFrames.Visible = true;
\r
815 drop_directPrediction.Visible = true;
\r
816 lbl_direct_prediction.Visible = true;
\r
818 drop_adaptBFrames.Visible = true;
\r
819 lbl_adaptBFrames.Visible = true;
\r
823 check_weightedBFrames.Visible = true;
\r
824 check_pyrmidalBFrames.Visible = true;
\r
825 drop_directPrediction.Visible = true;
\r
826 lbl_direct_prediction.Visible = true;
\r
828 drop_adaptBFrames.Visible = true;
\r
829 lbl_adaptBFrames.Visible = true;
\r
833 if (check_Cabac.Checked == false)
\r
835 /* Without CABAC entropy coding, trellis doesn't run. */
\r
836 drop_trellis.Visible = false;
\r
837 drop_trellis.SelectedIndex = 0;
\r
838 lbl_trellis.Visible = false;
\r
842 drop_trellis.Visible = true;
\r
843 lbl_trellis.Visible = true;
\r
847 if (drop_analysis.SelectedIndex == 1)
\r
849 /* No analysis? Disable 8x8dct */
\r
850 check_8x8DCT.Visible = false;
\r
851 if (sender != "8x8dct")
\r
852 check_8x8DCT.CheckState = CheckState.Unchecked;
\r
855 check_8x8DCT.Visible = true;
\r
858 if (drop_refFrames.SelectedIndex > 0 && drop_refFrames.SelectedIndex < 3)
\r
860 check_mixedReferences.Visible = false;
\r
861 if (sender != "mixed-refs")
\r
862 check_mixedReferences.CheckState = CheckState.Unchecked;
\r
865 check_mixedReferences.Visible = true;
\r
867 case "me": // Motion Estimation
\r
868 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
870 drop_MotionEstimationRange.Visible = false;
\r
871 lbl_merange.Visible = false;
\r
872 drop_MotionEstimationRange.SelectedIndex = 0;
\r
876 drop_MotionEstimationRange.Visible = true;
\r
877 lbl_merange.Visible = true;
\r
880 case "subq": // subme
\r
881 if (drop_subpixelMotionEstimation.SelectedIndex != 0 && drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
883 slider_psyrd.Visible = false;
\r
884 slider_psyrd.Value = 10;
\r
885 lbl_psyrd.Visible = false;
\r
888 slider_psytrellis.Visible = false;
\r
889 slider_psytrellis.Value = 0;
\r
890 lbl_psytrellis.Visible = false;
\r
894 slider_psyrd.Visible = true;
\r
895 lbl_psyrd.Visible = true;
\r
897 if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
899 slider_psytrellis.Visible = true;
\r
900 lbl_psytrellis.Visible = true;
\r
904 case "trellis": // subme
\r
905 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2 )
\r
907 slider_psytrellis.Visible = false;
\r
908 slider_psytrellis.Value = 0;
\r
909 lbl_psytrellis.Visible = false;
\r
913 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
915 slider_psytrellis.Visible = true;
\r
916 lbl_psytrellis.Visible = true;
\r
924 private void widgetControlChanged(object sender, EventArgs e)
\r
926 Control changedControlName = (Control)sender;
\r
927 string controlName = "";
\r
929 switch (changedControlName.Name.Trim())
\r
931 case "drop_refFrames":
\r
932 controlName = "ref";
\r
934 case "check_mixedReferences":
\r
935 controlName = "mixed-refs";
\r
937 case "drop_bFrames":
\r
938 controlName = "bframes";
\r
940 case "drop_directPrediction":
\r
941 controlName = "direct";
\r
943 case "check_weightedBFrames":
\r
944 controlName = "weightb";
\r
946 case "check_pyrmidalBFrames":
\r
947 controlName = "b-pyramid";
\r
949 case "drop_MotionEstimationMethod":
\r
950 controlName = "me";
\r
952 case "drop_MotionEstimationRange":
\r
953 controlName = "merange";
\r
955 case "drop_subpixelMotionEstimation":
\r
956 controlName = "subq";
\r
958 case "drop_analysis":
\r
959 controlName = "analyse";
\r
961 case "check_8x8DCT":
\r
962 controlName = "8x8dct";
\r
964 case "drop_deblockAlpha":
\r
965 controlName = "deblock";
\r
967 case "drop_deblockBeta":
\r
968 controlName = "deblock";
\r
970 case "drop_trellis":
\r
971 controlName = "trellis";
\r
973 case "check_noFastPSkip":
\r
974 controlName = "no-fast-pskip";
\r
976 case "check_noDCTDecimate":
\r
977 controlName = "no-dct-decimate";
\r
979 case "check_Cabac":
\r
980 controlName = "cabac";
\r
982 case "slider_psyrd":
\r
983 controlName = "psy-rd";
\r
985 case "slider_psytrellis":
\r
986 controlName = "psy-rd";
\r
988 case "drop_adaptBFrames":
\r
989 controlName = "b-adapt";
\r
992 OnX264WidgetChange(controlName);
\r
994 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
996 if (rtf_x264Query.Text.EndsWith("\n"))
\r
998 string query = rtf_x264Query.Text.Replace("\n", "");
\r
1000 rtf_x264Query.Text = query;
\r
1001 X264_StandardizeOptString();
\r
1002 X264_SetCurrentSettingsInPanel();
\r
1004 if (rtf_x264Query.Text == string.Empty)
\r
1008 private void btn_reset_Click(object sender, EventArgs e)
\r
1010 rtf_x264Query.Text = "";
\r