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
16 InitializeComponent();
\r
18 if (Properties.Settings.Default.tooltipEnable)
\r
19 ToolTip.Active = true;
\r
24 public string x264Query
\r
26 get { return rtf_x264Query.Text; }
\r
27 set { rtf_x264Query.Text = value; }
\r
30 private void widgetControlChanged(object sender, EventArgs e)
\r
32 Control changedControlName = (Control) sender;
\r
33 string controlName = "";
\r
35 switch (changedControlName.Name.Trim())
\r
37 case "drop_refFrames":
\r
38 controlName = "ref";
\r
40 case "check_mixedReferences":
\r
41 controlName = "mixed-refs";
\r
43 case "drop_bFrames":
\r
44 controlName = "bframes";
\r
46 case "drop_directPrediction":
\r
47 controlName = "direct";
\r
49 case "check_weightedBFrames":
\r
50 controlName = "weightb";
\r
52 case "check_pyrmidalBFrames":
\r
53 controlName = "b-pyramid";
\r
55 case "drop_MotionEstimationMethod":
\r
58 case "drop_MotionEstimationRange":
\r
59 controlName = "merange";
\r
61 case "drop_subpixelMotionEstimation":
\r
62 controlName = "subq";
\r
64 case "drop_analysis":
\r
65 controlName = "analyse";
\r
67 case "check_8x8DCT":
\r
68 controlName = "8x8dct";
\r
70 case "drop_deblockAlpha":
\r
71 controlName = "deblock";
\r
73 case "drop_deblockBeta":
\r
74 controlName = "deblock";
\r
76 case "drop_trellis":
\r
77 controlName = "trellis";
\r
79 case "check_noFastPSkip":
\r
80 controlName = "no-fast-pskip";
\r
82 case "check_noDCTDecimate":
\r
83 controlName = "no-dct-decimate";
\r
86 controlName = "cabac";
\r
88 case "slider_psyrd":
\r
89 controlName = "psy-rd";
\r
91 case "slider_psytrellis":
\r
92 controlName = "psy-rd";
\r
94 case "drop_adaptBFrames":
\r
95 controlName = "b-adapt";
\r
98 on_x264_WidgetChange(controlName);
\r
100 private void rtf_x264Query_TextChanged(object sender, EventArgs e)
\r
102 if (rtf_x264Query.Text.EndsWith("\n"))
\r
104 string query = rtf_x264Query.Text.Replace("\n", "");
\r
106 rtf_x264Query.Text = query;
\r
107 X264_StandardizeOptString();
\r
108 X264_SetCurrentSettingsInPanel();
\r
110 if (rtf_x264Query.Text == string.Empty)
\r
114 private void btn_reset_Click(object sender, EventArgs e)
\r
116 rtf_x264Query.Text = "";
\r
121 /// Reset all components to defaults and clears the x264 rtf box
\r
123 public void reset2Defaults()
\r
125 check_8x8DCT.CheckState = CheckState.Checked;
\r
126 check_Cabac.CheckState = CheckState.Checked;
\r
127 check_mixedReferences.CheckState = CheckState.Checked;
\r
128 check_noDCTDecimate.CheckState = CheckState.Unchecked;
\r
129 check_noFastPSkip.CheckState = CheckState.Unchecked;
\r
130 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
131 check_weightedBFrames.CheckState = CheckState.Checked;
\r
132 drop_analysis.SelectedIndex = 0;
\r
133 drop_bFrames.SelectedIndex = 0;
\r
134 drop_deblockAlpha.SelectedIndex = 0;
\r
135 drop_deblockBeta.SelectedIndex = 0;
\r
136 drop_directPrediction.SelectedIndex = 0;
\r
137 drop_MotionEstimationMethod.SelectedIndex = 0;
\r
138 drop_MotionEstimationRange.SelectedIndex = 0;
\r
139 drop_refFrames.SelectedIndex = 0;
\r
140 drop_subpixelMotionEstimation.SelectedIndex = 0;
\r
141 drop_trellis.SelectedIndex = 0;
\r
142 slider_psyrd.Value = 10;
\r
143 slider_psytrellis.Value = 0;
\r
144 drop_adaptBFrames.SelectedIndex = 0;
\r
146 rtf_x264Query.Text = "";
\r
150 /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
\r
152 public void X264_StandardizeOptString()
\r
154 /* Set widgets depending on the opt string in field */
\r
155 String thisOpt; // The separated option such as "bframes=3"
\r
156 String optName; // The option name such as "bframes"
\r
157 String optValue;// The option value such as "3"
\r
158 String changedOptString = "";
\r
159 String[] currentOptsArray;
\r
161 /*First, we get an opt string to process */
\r
162 String currentOptString = rtf_x264Query.Text;
\r
164 /*verify there is an opt string to process */
\r
165 if (currentOptString.Contains("="))
\r
167 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
168 currentOptsArray = currentOptString.Split(':');
\r
170 /*iterate through the array and get <opts> and <values*/
\r
172 int currentOptsArrayCount = currentOptsArray.Length;
\r
173 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
175 thisOpt = currentOptsArray[loopcounter];
\r
176 if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
\r
179 String[] splitOptRange = thisOpt.Split('=');
\r
182 if (thisOpt.Contains("="))
\r
184 optName = splitOptRange[0];
\r
185 optValue = splitOptRange[1];
\r
187 /* Standardize the names here depending on whats in the string */
\r
188 optName = X264_StandardizeOptNames(optName);
\r
189 thisOpt = optName + "=" + optValue;
\r
191 else // No value given so we use a default of "1"
\r
194 /* Standardize the names here depending on whats in the string */
\r
195 optName = X264_StandardizeOptNames(optName);
\r
196 thisOpt = optName + "=1";
\r
200 /* Construct New String for opts here */
\r
201 if (thisOpt == string.Empty)
\r
202 changedOptString = changedOptString + thisOpt;
\r
205 if (changedOptString == string.Empty)
\r
206 changedOptString = thisOpt;
\r
208 changedOptString = changedOptString + ":" + thisOpt;
\r
213 /* Change the option string to reflect the new standardized option string */
\r
214 if (changedOptString != "")
\r
215 rtf_x264Query.Text = changedOptString;
\r
219 /// Take a single option and standardize it. Returns as a String
\r
220 /// Input: String. - Single X264 Option. Name only
\r
221 /// Output: String - Single X264 Option. Name only. Changed to standard format
\r
223 /// <param name="cleanOptNameString"></param>
\r
224 /// <returns></returns>
\r
225 private static string X264_StandardizeOptNames(String cleanOptNameString)
\r
227 String input = cleanOptNameString;
\r
229 if (input.Equals("ref") || input.Equals("frameref"))
\r
230 cleanOptNameString = "ref";
\r
232 /*No Fast PSkip nofast_pskip*/
\r
233 if (input.Equals("no-fast-pskip") || input.Equals("no_fast_pskip") || input.Equals("nofast_pskip"))
\r
234 cleanOptNameString = "no-fast-pskip";
\r
236 /*No Dict Decimate*/
\r
237 if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
\r
238 cleanOptNameString = "no-dct-decimate";
\r
241 if (input.Equals("subme"))
\r
242 cleanOptNameString = "subq";
\r
245 if (input.Equals("me-range") || input.Equals("me_range"))
\r
246 cleanOptNameString = "merange";
\r
249 if (input.Equals("weight-b") || input.Equals("weight_b"))
\r
250 cleanOptNameString = "weightb";
\r
253 if (input.Equals("b_pyramid"))
\r
254 cleanOptNameString = "b-pyramid";
\r
256 /*Direct Prediction*/
\r
257 if (input.Equals("direct-pred") || input.Equals("direct_pred"))
\r
258 cleanOptNameString = "direct";
\r
261 if (input.Equals("filter"))
\r
262 cleanOptNameString = "deblock";
\r
265 if (input.Equals("partitions"))
\r
266 cleanOptNameString = "analyse";
\r
268 return cleanOptNameString;
\r
272 /// Resets the GUI widgets to the contents of the option string.
\r
274 public void X264_SetCurrentSettingsInPanel()
\r
276 /* Set widgets depending on the opt string in field */
\r
277 String thisOpt; // The separated option such as "bframes=3"
\r
278 String optName; // The option name such as "bframes"
\r
279 String optValue;// The option value such as "3"
\r
280 String[] currentOptsArray;
\r
282 //Set currentOptString to the contents of the text box.
\r
283 String currentOptString = rtf_x264Query.Text.Replace("\n", "");
\r
285 /*verify there is an opt string to process */
\r
286 if (currentOptString.Contains("="))
\r
288 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
289 currentOptsArray = currentOptString.Split(':');
\r
291 /*iterate through the array and get <opts> and <values*/
\r
293 int currentOptsArrayCount = currentOptsArray.Length;
\r
295 /*iterate through the array and get <opts> and <values*/
\r
296 for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
\r
298 thisOpt = currentOptsArray[loopcounter];
\r
299 String[] splitOptRange = thisOpt.Split('=');
\r
301 if (thisOpt.Contains("="))
\r
303 optName = splitOptRange[0];
\r
304 optValue = splitOptRange[1];
\r
306 /*Run through the available widgets for x264 opts and set them, as you add widgets,
\r
307 they need to be added here. This should be moved to its own method probably*/
\r
311 drop_bFrames.SelectedItem = optValue;
\r
314 drop_refFrames.SelectedItem = optValue;
\r
316 case "no-fast-pskip":
\r
317 check_noFastPSkip.CheckState = CheckState.Checked;
\r
319 case "no-dct-decimate":
\r
320 check_noDCTDecimate.CheckState = CheckState.Checked;
\r
323 drop_subpixelMotionEstimation.SelectedItem = optValue;
\r
326 drop_trellis.SelectedItem = optValue;
\r
329 check_mixedReferences.CheckState = CheckState.Checked;
\r
332 if (optValue.Equals("dia"))
\r
333 drop_MotionEstimationMethod.SelectedItem = "Diamond";
\r
334 else if (optValue.Equals("hex"))
\r
335 drop_MotionEstimationMethod.SelectedItem = "Hexagon";
\r
336 else if (optValue.Equals("umh"))
\r
337 drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
\r
338 else if (optValue.Equals("esa"))
\r
339 drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
\r
340 else if (optValue.Equals("tesa"))
\r
341 drop_MotionEstimationMethod.SelectedItem = "Transformed Exhaustive";
\r
344 drop_MotionEstimationRange.SelectedItem = optValue;
\r
348 int.TryParse(optValue, out badapt);
\r
349 drop_adaptBFrames.SelectedIndex = (badapt + 1);
\r
352 if (optValue != "0")
\r
353 check_weightedBFrames.CheckState = CheckState.Checked;
\r
355 check_weightedBFrames.CheckState = CheckState.Unchecked;
\r
358 check_pyrmidalBFrames.CheckState = CheckState.Checked;
\r
361 if (optValue == "auto")
\r
362 optValue = "Automatic";
\r
364 if (optValue != "")
\r
366 Char[] letters = optValue.ToCharArray();
\r
367 letters[0] = Char.ToUpper(letters[0]);
\r
368 optValue = new string(letters);
\r
371 drop_directPrediction.SelectedItem = optValue;
\r
374 string[] splitDeblock = optValue.Split(',');
\r
375 string alphaDeblock = splitDeblock[0];
\r
376 string betaDeblock = splitDeblock[1];
\r
378 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
\r
380 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
381 drop_deblockBeta.SelectedItem = "Default (0)";
\r
385 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
387 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", "").Equals("0") ? betaDeblock.Replace("\n", "") : "0";
\r
391 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
392 drop_analysis.SelectedItem = "Default (some)";
\r
393 if (optValue.Equals("none"))
\r
394 drop_analysis.SelectedItem = "None";
\r
395 if (optValue.Equals("all"))
\r
396 drop_analysis.SelectedItem = "All";
\r
399 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
402 check_Cabac.CheckState = CheckState.Unchecked;
\r
405 string[] x = optValue.Split(',');
\r
407 double psyrd, psytrellis;
\r
410 // default psy-rd = 1 (10 for the slider)
\r
411 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
412 // default psy-trellis = 0
\r
413 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 10 : 0.0;
\r
415 int.TryParse(psyrd.ToString(), out val);
\r
416 int.TryParse(psytrellis.ToString(), out val2);
\r
418 slider_psyrd.Value = val;
\r
419 slider_psytrellis.Value = val2;
\r
428 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
430 private void on_x264_WidgetChange(string sender)
\r
433 String optNameToChange = sender;
\r
434 String currentOptString = rtf_x264Query.Text;
\r
436 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
437 the first character of the opt string (hence the ":") */
\r
438 String checkOptNameToChange = ":" + optNameToChange + "=";
\r
439 String checkOptNameToChangeBegin = optNameToChange + "=";
\r
441 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
442 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
443 hasOptions(currentOptString, optNameToChange);
\r
444 else // IF there is no options in the rich text box!
\r
445 hasNoOptions(optNameToChange);
\r
449 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
450 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
452 /// <param name="currentOptString"></param>
\r
453 /// <param name="optNameToChange"></param>
\r
454 private void hasOptions(string currentOptString, string optNameToChange)
\r
456 String thisOpt; // The separated option such as "bframes=3"
\r
457 String optName; // The option name such as "bframes"
\r
458 String[] currentOptsArray;
\r
460 /* Create new empty opt string*/
\r
461 String changedOptString = "";
\r
463 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
464 currentOptsArray = currentOptString.Split(':');
\r
466 /*iterate through the array and get <opts> and <values*/
\r
467 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
469 thisOpt = currentOptsArray[loopcounter];
\r
471 if (thisOpt.Contains("="))
\r
473 string[] splitOptRange = thisOpt.Split('=');
\r
475 optName = splitOptRange[0]; // e.g bframes
\r
478 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
479 * they need to be added here. This should be moved to its own method probably
\r
480 * If the optNameToChange is found, appropriately change the value or delete it if
\r
481 * "unspecified" is set.
\r
483 if (optName.Equals(optNameToChange))
\r
485 if (optNameToChange.Equals("deblock"))
\r
487 String da = drop_deblockAlpha.SelectedItem.ToString();
\r
488 String db = drop_deblockBeta.SelectedItem.ToString();
\r
490 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
492 drop_deblockBeta.SelectedItem = "Default (0)";
\r
493 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
496 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
498 drop_deblockBeta.SelectedItem = "0";
\r
499 thisOpt = "deblock=" + da + ",0";
\r
501 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
503 drop_deblockAlpha.SelectedItem = "0";
\r
504 thisOpt = "deblock=0," + db;
\r
506 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
507 thisOpt = "deblock=" + da + "," + db;
\r
509 else if (optNameToChange.Equals("psy-rd"))
\r
511 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
515 double psyrd = slider_psyrd.Value * 0.1;
\r
516 double psytre = slider_psytrellis.Value * 0.1;
\r
518 string rd = psyrd.ToString("f1");
\r
519 string rt = psytre.ToString("f1");
\r
521 thisOpt = "psy-rd=" + rd + "," + rt;
\r
524 else if (optNameToChange.Equals("mixed-refs"))
\r
525 thisOpt = check_mixedReferences.CheckState == CheckState.Checked ? "mixed-refs=1" : "mixed-refs=0";
\r
526 else if (optNameToChange.Equals("weightb"))
\r
527 thisOpt = check_weightedBFrames.CheckState == CheckState.Checked ? "" : "weightb=0";
\r
528 else if (optNameToChange.Equals("b-pyramid"))
\r
529 thisOpt = check_pyrmidalBFrames.CheckState == CheckState.Checked ? "b-pyramid=1" : "";
\r
530 else if (optNameToChange.Equals("no-fast-pskip"))
\r
531 thisOpt = check_noFastPSkip.CheckState == CheckState.Checked ? "no-fast-pskip=1" : "";
\r
532 else if (optNameToChange.Equals("no-dct-decimate"))
\r
533 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : "";
\r
534 else if (optNameToChange.Equals("8x8dct"))
\r
535 thisOpt = check_8x8DCT.CheckState == CheckState.Checked ? "8x8dct=1" : "8x8dct=0";
\r
536 else if (optNameToChange.Equals("cabac"))
\r
537 thisOpt = check_Cabac.CheckState == CheckState.Checked ? "" : "cabac=0";
\r
538 else if (optNameToChange.Equals("me"))
\r
540 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
543 thisOpt = "me=dia";
\r
547 thisOpt = "me=hex";
\r
551 thisOpt = "me=umh";
\r
555 thisOpt = "me=esa";
\r
559 thisOpt = "me=tesa";
\r
567 else if (optNameToChange.Equals("direct"))
\r
569 switch (drop_directPrediction.SelectedIndex)
\r
572 thisOpt = "direct=none";
\r
576 thisOpt = "direct=spatial";
\r
580 thisOpt = "direct=temporal";
\r
584 thisOpt = "direct=auto";
\r
592 else if (optNameToChange.Equals("analyse"))
\r
594 switch (drop_analysis.SelectedIndex)
\r
597 thisOpt = "analyse=none";
\r
601 thisOpt = "analyse=all";
\r
609 else if (optNameToChange.Equals("merange"))
\r
611 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
612 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
615 else if (optNameToChange.Equals("b-adapt"))
\r
617 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
618 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
621 else if (optNameToChange.Equals("ref"))
\r
623 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
624 ? "ref=" + drop_refFrames.SelectedItem
\r
627 else if (optNameToChange.Equals("bframes"))
\r
629 String value = drop_bFrames.SelectedItem.ToString();
\r
630 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
631 ? "bframes=" + value
\r
634 else if (optNameToChange.Equals("subq"))
\r
636 String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
637 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
641 else if (optNameToChange.Equals("trellis"))
\r
643 String value = drop_trellis.SelectedItem.ToString();
\r
644 thisOpt = !drop_trellis.SelectedItem.ToString().Contains("Default")
\r
645 ? "trellis=" + value
\r
651 /* Construct New String for opts here */
\r
652 if (!thisOpt.Equals(""))
\r
653 changedOptString = changedOptString.Equals("") ? thisOpt : changedOptString + ":" + thisOpt;
\r
656 /* Change the option string to reflect the new mod settings */
\r
657 rtf_x264Query.Text = changedOptString;
\r
661 /// Add's an option to the x264 query string.
\r
662 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
663 /// e.g no-fast-pskip
\r
665 /// <param name="optNameToChange"></param>
\r
666 private void hasNoOptions(string optNameToChange)
\r
669 if (rtf_x264Query.Text != "")
\r
672 string query = rtf_x264Query.Text;
\r
673 if (optNameToChange.Equals("me"))
\r
675 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
678 query = query + colon + "me=dia";
\r
682 query = query + colon + "me=hex";
\r
686 query = query + colon + "me=umh";
\r
690 query = query + colon + "me=esa";
\r
694 query = query + colon + "me=tesa";
\r
701 else if (optNameToChange.Equals("direct"))
\r
703 switch (drop_directPrediction.SelectedIndex)
\r
706 query = query + colon + "direct=none";
\r
710 query = query + colon + "direct=spatial";
\r
714 query = query + colon + "direct=temporal";
\r
718 query = query + colon + "direct=auto";
\r
725 else if (optNameToChange.Equals("analyse"))
\r
727 switch (drop_analysis.SelectedIndex)
\r
730 query = query + colon + "analyse=none";
\r
734 query = query + colon + "analyse=all";
\r
741 else if (optNameToChange.Equals("merange"))
\r
743 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
744 query = query + colon + "merange=" + value;
\r
746 else if (optNameToChange.Equals("b-adapt"))
\r
748 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
749 query = query + colon + "b-adapt=" + value;
\r
752 else if (optNameToChange.Equals("deblock"))
\r
754 String da = drop_deblockAlpha.SelectedItem.ToString();
\r
755 String db = drop_deblockBeta.Text;
\r
757 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
759 drop_deblockBeta.SelectedItem = "Default (0)";
\r
760 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
764 if (db.Contains("Default"))
\r
767 if (da.Contains("Default"))
\r
770 query = query + colon + "deblock=" + da + "," + db;
\r
773 else if (optNameToChange.Equals("psy-rd"))
\r
775 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
779 double psyrd = slider_psyrd.Value * 0.1;
\r
780 double psytre = slider_psytrellis.Value * 0.1;
\r
782 string rd = psyrd.ToString("f1");
\r
783 string rt = psytre.ToString("f1");
\r
785 query += colon + "psy-rd=" + rd + "," + rt;
\r
788 else if (optNameToChange.Equals("mixed-refs"))
\r
790 if (check_mixedReferences.CheckState == CheckState.Checked)
\r
791 query = query + colon + "mixed-refs=1";
\r
793 query = query + colon + "mixed-refs=0";
\r
795 else if (optNameToChange.Equals("weightb"))
\r
797 if (check_weightedBFrames.CheckState != CheckState.Checked)
\r
798 query = query + colon + "weightb=0";
\r
800 else if (optNameToChange.Equals("b-pyramid"))
\r
802 if (check_pyrmidalBFrames.CheckState == CheckState.Checked)
\r
803 query = query + colon + "b-pyramid=1";
\r
805 else if (optNameToChange.Equals("no-fast-pskip"))
\r
807 if (check_noFastPSkip.CheckState == CheckState.Checked)
\r
808 query = query + colon + "no-fast-pskip=1";
\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.Checked)
\r
818 query = query + colon + "8x8dct=1";
\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("ref"))
\r
827 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
828 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
830 else if (optNameToChange.Equals("bframes"))
\r
832 String value = drop_bFrames.SelectedItem.ToString();
\r
833 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
834 query = query + colon + "bframes=" + value;
\r
836 else if (optNameToChange.Equals("subq"))
\r
838 String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
839 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
840 query = query + colon + "subq=" + value;
\r
842 else if (optNameToChange.Equals("trellis"))
\r
844 if (!drop_trellis.SelectedItem.ToString().Contains("Default"))
\r
845 query = query + colon + "trellis=" + drop_trellis.SelectedItem;
\r
848 rtf_x264Query.Text = query;
\r
852 /// Shows and hides controls based on the values of other controls.
\r
854 /// <param name="sender"></param>
\r
855 private void animate(string sender)
\r
857 /* Lots of situations to cover.
\r
858 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
859 - CABAC (when 0 turn off trellis)
\r
860 - analysis (if none, turn off 8x8dct)
\r
861 - refs (under 2, disable mixed-refs)
\r
862 - subme (if under 6, turn off psy-rd and psy-trel)
\r
863 - trellis (if 0, turn off psy-trel)
\r
869 if (drop_bFrames.SelectedIndex >0 && drop_bFrames.SelectedIndex < 2 )
\r
871 /* If the b-frame widget is at 0 or 1, the user has chosen
\r
872 not to use b-frames at all. So disable the options
\r
873 that can only be used when b-frames are enabled. */
\r
874 check_weightedBFrames.Visible = false;
\r
875 check_pyrmidalBFrames.Visible = false;
\r
876 drop_directPrediction.Visible = false;
\r
877 lbl_direct_prediction.Visible = false;
\r
879 check_weightedBFrames.CheckState = CheckState.Unchecked;
\r
880 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
881 drop_directPrediction.SelectedIndex = 0;
\r
883 drop_adaptBFrames.Visible = false;
\r
884 lbl_adaptBFrames.Visible = false;
\r
885 drop_adaptBFrames.SelectedIndex = 0;
\r
887 else if (drop_bFrames.SelectedIndex == 2)
\r
889 /* Only 1 b-frame? Disable b-pyramid. */
\r
890 check_pyrmidalBFrames.Visible = false;
\r
891 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
893 check_weightedBFrames.Visible = true;
\r
894 drop_directPrediction.Visible = true;
\r
895 lbl_direct_prediction.Visible = true;
\r
897 drop_adaptBFrames.Visible = true;
\r
898 lbl_adaptBFrames.Visible = true;
\r
902 check_weightedBFrames.Visible = true;
\r
903 check_pyrmidalBFrames.Visible = true;
\r
904 drop_directPrediction.Visible = true;
\r
905 lbl_direct_prediction.Visible = true;
\r
907 drop_adaptBFrames.Visible = true;
\r
908 lbl_adaptBFrames.Visible = true;
\r
912 if (check_Cabac.Checked == false)
\r
914 /* Without CABAC entropy coding, trellis doesn't run. */
\r
915 drop_trellis.Visible = false;
\r
916 drop_trellis.SelectedIndex = 0;
\r
917 lbl_trellis.Visible = false;
\r
921 drop_trellis.Visible = true;
\r
922 lbl_trellis.Visible = true;
\r
926 if (drop_analysis.SelectedIndex == 1)
\r
928 /* No analysis? Disable 8x8dct */
\r
929 check_8x8DCT.Visible = false;
\r
930 if (sender != "8x8dct")
\r
931 check_8x8DCT.CheckState = CheckState.Unchecked;
\r
934 check_8x8DCT.Visible = true;
\r
937 if (drop_refFrames.SelectedIndex > 0 && drop_refFrames.SelectedIndex < 3)
\r
939 check_mixedReferences.Visible = false;
\r
940 if (sender != "mixed-refs")
\r
941 check_mixedReferences.CheckState = CheckState.Unchecked;
\r
944 check_mixedReferences.Visible = true;
\r
946 case "me": // Motion Estimation
\r
947 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
949 drop_MotionEstimationRange.Visible = false;
\r
950 lbl_merange.Visible = false;
\r
951 drop_MotionEstimationRange.SelectedIndex = 0;
\r
955 drop_MotionEstimationRange.Visible = true;
\r
956 lbl_merange.Visible = true;
\r
959 case "subq": // subme
\r
960 if (drop_subpixelMotionEstimation.SelectedIndex != 0 && drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
962 slider_psyrd.Visible = false;
\r
963 slider_psyrd.Value = 10;
\r
964 lbl_psyrd.Visible = false;
\r
967 slider_psytrellis.Visible = false;
\r
968 slider_psytrellis.Value = 0;
\r
969 lbl_psytrellis.Visible = false;
\r
973 slider_psyrd.Visible = true;
\r
974 lbl_psyrd.Visible = true;
\r
976 if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
978 slider_psytrellis.Visible = true;
\r
979 lbl_psytrellis.Visible = true;
\r
983 case "trellis": // subme
\r
984 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2 )
\r
986 slider_psytrellis.Visible = false;
\r
987 slider_psytrellis.Value = 0;
\r
988 lbl_psytrellis.Visible = false;
\r
992 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
994 slider_psytrellis.Visible = true;
\r
995 lbl_psytrellis.Visible = true;
\r