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 check_weightedBFrames.CheckState = CheckState.Checked;
\r
355 check_pyrmidalBFrames.CheckState = CheckState.Checked;
\r
358 if (optValue == "auto")
\r
359 optValue = "Automatic";
\r
361 if (optValue != "")
\r
363 Char[] letters = optValue.ToCharArray();
\r
364 letters[0] = Char.ToUpper(letters[0]);
\r
365 optValue = new string(letters);
\r
368 drop_directPrediction.SelectedItem = optValue;
\r
371 string[] splitDeblock = optValue.Split(',');
\r
372 string alphaDeblock = splitDeblock[0];
\r
373 string betaDeblock = splitDeblock[1];
\r
375 if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
\r
377 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
378 drop_deblockBeta.SelectedItem = "Default (0)";
\r
382 drop_deblockAlpha.SelectedItem = !alphaDeblock.Equals("0") ? alphaDeblock : "0";
\r
384 drop_deblockBeta.SelectedItem = !betaDeblock.Replace("\n", "").Equals("0") ? betaDeblock.Replace("\n", "") : "0";
\r
388 if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
\r
389 drop_analysis.SelectedItem = "Default (some)";
\r
390 if (optValue.Equals("none"))
\r
391 drop_analysis.SelectedItem = "None";
\r
392 if (optValue.Equals("all"))
\r
393 drop_analysis.SelectedItem = "All";
\r
396 check_8x8DCT.CheckState = optValue == "1" ? CheckState.Checked : CheckState.Unchecked;
\r
399 check_Cabac.CheckState = CheckState.Unchecked;
\r
402 string[] x = optValue.Split(',');
\r
404 double psyrd, psytrellis;
\r
407 // default psy-rd = 1 (10 for the slider)
\r
408 psyrd = double.TryParse(x[0], out psyrd) ? psyrd * 10 : 10.0;
\r
409 // default psy-trellis = 0
\r
410 psytrellis = double.TryParse(x[1], out psytrellis) ? psytrellis * 10 : 0.0;
\r
412 int.TryParse(psyrd.ToString(), out val);
\r
413 int.TryParse(psytrellis.ToString(), out val2);
\r
415 slider_psyrd.Value = val;
\r
416 slider_psytrellis.Value = val2;
\r
425 /// This function will update the X264 Query when one of the GUI widgets changes.
\r
427 private void on_x264_WidgetChange(string sender)
\r
430 String optNameToChange = sender;
\r
431 String currentOptString = rtf_x264Query.Text;
\r
433 /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
\r
434 the first character of the opt string (hence the ":") */
\r
435 String checkOptNameToChange = ":" + optNameToChange + "=";
\r
436 String checkOptNameToChangeBegin = optNameToChange + "=";
\r
438 // IF the current H264 Option String Contains Multiple Items or Just 1 Item
\r
439 if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
\r
440 hasOptions(currentOptString, optNameToChange);
\r
441 else // IF there is no options in the rich text box!
\r
442 hasNoOptions(optNameToChange);
\r
446 /// Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
\r
447 /// it updates the current option that the widget corrosponds to, if it is already in thes string.
\r
449 /// <param name="currentOptString"></param>
\r
450 /// <param name="optNameToChange"></param>
\r
451 private void hasOptions(string currentOptString, string optNameToChange)
\r
453 String thisOpt; // The separated option such as "bframes=3"
\r
454 String optName; // The option name such as "bframes"
\r
455 String[] currentOptsArray;
\r
457 /* Create new empty opt string*/
\r
458 String changedOptString = "";
\r
460 /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
\r
461 currentOptsArray = currentOptString.Split(':');
\r
463 /*iterate through the array and get <opts> and <values*/
\r
464 for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
\r
466 thisOpt = currentOptsArray[loopcounter];
\r
468 if (thisOpt.Contains("="))
\r
470 string[] splitOptRange = thisOpt.Split('=');
\r
472 optName = splitOptRange[0]; // e.g bframes
\r
475 * Run through the available widgets for x264 opts and set them, as you add widgets,
\r
476 * they need to be added here. This should be moved to its own method probably
\r
477 * If the optNameToChange is found, appropriately change the value or delete it if
\r
478 * "unspecified" is set.
\r
480 if (optName.Equals(optNameToChange))
\r
482 if (optNameToChange.Equals("deblock"))
\r
484 String da = drop_deblockAlpha.SelectedItem.ToString();
\r
485 String db = drop_deblockBeta.SelectedItem.ToString();
\r
487 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
489 drop_deblockBeta.SelectedItem = "Default (0)";
\r
490 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
493 else if ((!da.Contains("Default")) && (db.Contains("Default")))
\r
495 drop_deblockBeta.SelectedItem = "0";
\r
496 thisOpt = "deblock=" + da + ",0";
\r
498 else if ((da.Contains("Default")) && (!db.Contains("Default")))
\r
500 drop_deblockAlpha.SelectedItem = "0";
\r
501 thisOpt = "deblock=0," + db;
\r
503 else if ((!da.Contains("Default")) && (!db.Contains("Default")))
\r
504 thisOpt = "deblock=" + da + "," + db;
\r
506 else if (optNameToChange.Equals("psy-rd"))
\r
508 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
512 double psyrd = slider_psyrd.Value * 0.1;
\r
513 double psytre = slider_psytrellis.Value * 0.1;
\r
515 string rd = psyrd.ToString("f1");
\r
516 string rt = psytre.ToString("f1");
\r
518 thisOpt = "psy-rd=" + rd + "," + rt;
\r
521 else if (optNameToChange.Equals("mixed-refs"))
\r
522 thisOpt = check_mixedReferences.CheckState == CheckState.Checked ? "mixed-refs=1" : "mixed-refs=0";
\r
523 else if (optNameToChange.Equals("weightb"))
\r
524 thisOpt = check_weightedBFrames.CheckState == CheckState.Checked ? "weightb=1" : "";
\r
525 else if (optNameToChange.Equals("b-pyramid"))
\r
526 thisOpt = check_pyrmidalBFrames.CheckState == CheckState.Checked ? "b-pyramid=1" : "";
\r
527 else if (optNameToChange.Equals("no-fast-pskip"))
\r
528 thisOpt = check_noFastPSkip.CheckState == CheckState.Checked ? "no-fast-pskip=1" : "";
\r
529 else if (optNameToChange.Equals("no-dct-decimate"))
\r
530 thisOpt = check_noDCTDecimate.CheckState == CheckState.Checked ? "no-dct-decimate=1" : "";
\r
531 else if (optNameToChange.Equals("8x8dct"))
\r
532 thisOpt = check_8x8DCT.CheckState == CheckState.Checked ? "8x8dct=1" : "8x8dct=0";
\r
533 else if (optNameToChange.Equals("cabac"))
\r
534 thisOpt = check_Cabac.CheckState == CheckState.Checked ? "" : "cabac=0";
\r
535 else if (optNameToChange.Equals("me"))
\r
537 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
540 thisOpt = "me=dia";
\r
544 thisOpt = "me=hex";
\r
548 thisOpt = "me=umh";
\r
552 thisOpt = "me=esa";
\r
556 thisOpt = "me=tesa";
\r
564 else if (optNameToChange.Equals("direct"))
\r
566 switch (drop_directPrediction.SelectedIndex)
\r
569 thisOpt = "direct=none";
\r
573 thisOpt = "direct=spatial";
\r
577 thisOpt = "direct=temporal";
\r
581 thisOpt = "direct=auto";
\r
589 else if (optNameToChange.Equals("analyse"))
\r
591 switch (drop_analysis.SelectedIndex)
\r
594 thisOpt = "analyse=none";
\r
598 thisOpt = "analyse=all";
\r
606 else if (optNameToChange.Equals("merange"))
\r
608 thisOpt = !drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default")
\r
609 ? "merange=" + drop_MotionEstimationRange.SelectedItem
\r
612 else if (optNameToChange.Equals("b-adapt"))
\r
614 thisOpt = !drop_adaptBFrames.SelectedItem.ToString().Contains("Default")
\r
615 ? "b-adapt=" + (drop_adaptBFrames.SelectedIndex - 1)
\r
618 else if (optNameToChange.Equals("ref"))
\r
620 thisOpt = !drop_refFrames.SelectedItem.ToString().Contains("Default")
\r
621 ? "ref=" + drop_refFrames.SelectedItem
\r
624 else if (optNameToChange.Equals("bframes"))
\r
626 String value = drop_bFrames.SelectedItem.ToString();
\r
627 thisOpt = !drop_bFrames.SelectedItem.ToString().Contains("Default")
\r
628 ? "bframes=" + value
\r
631 else if (optNameToChange.Equals("subq"))
\r
633 String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
634 thisOpt = !drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default")
\r
638 else if (optNameToChange.Equals("trellis"))
\r
640 String value = drop_trellis.SelectedItem.ToString();
\r
641 thisOpt = !drop_trellis.SelectedItem.ToString().Contains("Default")
\r
642 ? "trellis=" + value
\r
648 /* Construct New String for opts here */
\r
649 if (!thisOpt.Equals(""))
\r
650 changedOptString = changedOptString.Equals("") ? thisOpt : changedOptString + ":" + thisOpt;
\r
653 /* Change the option string to reflect the new mod settings */
\r
654 rtf_x264Query.Text = changedOptString;
\r
658 /// Add's an option to the x264 query string.
\r
659 /// Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
\r
660 /// e.g no-fast-pskip
\r
662 /// <param name="optNameToChange"></param>
\r
663 private void hasNoOptions(string optNameToChange)
\r
666 if (rtf_x264Query.Text != "")
\r
669 string query = rtf_x264Query.Text;
\r
670 if (optNameToChange.Equals("me"))
\r
672 switch (drop_MotionEstimationMethod.SelectedIndex)
\r
675 query = query + colon + "me=dia";
\r
679 query = query + colon + "me=hex";
\r
683 query = query + colon + "me=umh";
\r
687 query = query + colon + "me=esa";
\r
691 query = query + colon + "me=tesa";
\r
698 else if (optNameToChange.Equals("direct"))
\r
700 switch (drop_directPrediction.SelectedIndex)
\r
703 query = query + colon + "direct=none";
\r
707 query = query + colon + "direct=spatial";
\r
711 query = query + colon + "direct=temporal";
\r
715 query = query + colon + "direct=auto";
\r
722 else if (optNameToChange.Equals("analyse"))
\r
724 switch (drop_analysis.SelectedIndex)
\r
727 query = query + colon + "analyse=none";
\r
731 query = query + colon + "analyse=all";
\r
738 else if (optNameToChange.Equals("merange"))
\r
740 int value = drop_MotionEstimationRange.SelectedIndex + 3;
\r
741 query = query + colon + "merange=" + value;
\r
743 else if (optNameToChange.Equals("b-adapt"))
\r
745 int value = drop_adaptBFrames.SelectedIndex - 1;
\r
746 query = query + colon + "b-adapt=" + value;
\r
749 else if (optNameToChange.Equals("deblock"))
\r
751 String da = drop_deblockAlpha.SelectedItem.ToString();
\r
752 String db = drop_deblockBeta.Text;
\r
754 if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
\r
756 drop_deblockBeta.SelectedItem = "Default (0)";
\r
757 drop_deblockAlpha.SelectedItem = "Default (0)";
\r
761 if (db.Contains("Default"))
\r
764 if (da.Contains("Default"))
\r
767 query = query + colon + "deblock=" + da + "," + db;
\r
770 else if (optNameToChange.Equals("psy-rd"))
\r
772 if (slider_psyrd.Value == 10 && slider_psytrellis.Value == 0)
\r
776 double psyrd = slider_psyrd.Value * 0.1;
\r
777 double psytre = slider_psytrellis.Value * 0.1;
\r
779 string rd = psyrd.ToString("f1");
\r
780 string rt = psytre.ToString("f1");
\r
782 query += colon + "psy-rd=" + rd + "," + rt;
\r
785 else if (optNameToChange.Equals("mixed-refs"))
\r
787 if (check_mixedReferences.CheckState == CheckState.Checked)
\r
788 query = query + colon + "mixed-refs=1";
\r
790 query = query + colon + "mixed-refs=0";
\r
792 else if (optNameToChange.Equals("weightb"))
\r
794 if (check_weightedBFrames.CheckState == CheckState.Checked)
\r
795 query = query + colon + "weightb=1";
\r
797 else if (optNameToChange.Equals("b-pyramid"))
\r
799 if (check_pyrmidalBFrames.CheckState == CheckState.Checked)
\r
800 query = query + colon + "b-pyramid=1";
\r
802 else if (optNameToChange.Equals("no-fast-pskip"))
\r
804 if (check_noFastPSkip.CheckState == CheckState.Checked)
\r
805 query = query + colon + "no-fast-pskip=1";
\r
807 else if (optNameToChange.Equals("no-dct-decimate"))
\r
809 if (check_noDCTDecimate.CheckState == CheckState.Checked)
\r
810 query = query + colon + "no-dct-decimate=1";
\r
812 else if (optNameToChange.Equals("8x8dct"))
\r
814 if (check_8x8DCT.CheckState == CheckState.Checked)
\r
815 query = query + colon + "8x8dct=1";
\r
817 else if (optNameToChange.Equals("cabac"))
\r
819 if (check_Cabac.CheckState != CheckState.Checked)
\r
820 query = query + colon + "cabac=0";
\r
822 else if (optNameToChange.Equals("ref"))
\r
824 if (!drop_refFrames.SelectedItem.ToString().Contains("Default"))
\r
825 query = query + colon + "ref=" + drop_refFrames.SelectedItem;
\r
827 else if (optNameToChange.Equals("bframes"))
\r
829 String value = drop_bFrames.SelectedItem.ToString();
\r
830 if (!drop_bFrames.SelectedItem.ToString().Contains("Default"))
\r
831 query = query + colon + "bframes=" + value;
\r
833 else if (optNameToChange.Equals("subq"))
\r
835 String value = drop_subpixelMotionEstimation.SelectedItem.ToString();
\r
836 if (!drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
\r
837 query = query + colon + "subq=" + value;
\r
839 else if (optNameToChange.Equals("trellis"))
\r
841 if (!drop_trellis.SelectedItem.ToString().Contains("Default"))
\r
842 query = query + colon + "trellis=" + drop_trellis.SelectedItem;
\r
845 rtf_x264Query.Text = query;
\r
849 /// Shows and hides controls based on the values of other controls.
\r
851 /// <param name="sender"></param>
\r
852 private void animate(string sender)
\r
854 /* Lots of situations to cover.
\r
855 - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
\r
856 - CABAC (when 0 turn off trellis)
\r
857 - analysis (if none, turn off 8x8dct)
\r
858 - refs (under 2, disable mixed-refs)
\r
859 - subme (if under 6, turn off psy-rd and psy-trel)
\r
860 - trellis (if 0, turn off psy-trel)
\r
866 if (drop_bFrames.SelectedIndex >0 && drop_bFrames.SelectedIndex < 2 )
\r
868 /* If the b-frame widget is at 0 or 1, the user has chosen
\r
869 not to use b-frames at all. So disable the options
\r
870 that can only be used when b-frames are enabled. */
\r
871 check_weightedBFrames.Visible = false;
\r
872 check_pyrmidalBFrames.Visible = false;
\r
873 drop_directPrediction.Visible = false;
\r
874 lbl_direct_prediction.Visible = false;
\r
876 check_weightedBFrames.CheckState = CheckState.Unchecked;
\r
877 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
878 drop_directPrediction.SelectedIndex = 0;
\r
880 drop_adaptBFrames.Visible = false;
\r
881 lbl_adaptBFrames.Visible = false;
\r
882 drop_adaptBFrames.SelectedIndex = 0;
\r
884 else if (drop_bFrames.SelectedIndex == 2)
\r
886 /* Only 1 b-frame? Disable b-pyramid. */
\r
887 check_pyrmidalBFrames.Visible = false;
\r
888 check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
\r
890 check_weightedBFrames.Visible = true;
\r
891 drop_directPrediction.Visible = true;
\r
892 lbl_direct_prediction.Visible = true;
\r
894 drop_adaptBFrames.Visible = true;
\r
895 lbl_adaptBFrames.Visible = true;
\r
899 check_weightedBFrames.Visible = true;
\r
900 check_pyrmidalBFrames.Visible = true;
\r
901 drop_directPrediction.Visible = true;
\r
902 lbl_direct_prediction.Visible = true;
\r
904 drop_adaptBFrames.Visible = true;
\r
905 lbl_adaptBFrames.Visible = true;
\r
909 if (check_Cabac.Checked == false)
\r
911 /* Without CABAC entropy coding, trellis doesn't run. */
\r
912 drop_trellis.Visible = false;
\r
913 drop_trellis.SelectedIndex = 0;
\r
914 lbl_trellis.Visible = false;
\r
918 drop_trellis.Visible = true;
\r
919 lbl_trellis.Visible = true;
\r
923 if (drop_analysis.SelectedIndex == 1)
\r
925 /* No analysis? Disable 8x8dct */
\r
926 check_8x8DCT.Visible = false;
\r
927 if (sender != "8x8dct")
\r
928 check_8x8DCT.CheckState = CheckState.Unchecked;
\r
931 check_8x8DCT.Visible = true;
\r
934 if (drop_refFrames.SelectedIndex > 0 && drop_refFrames.SelectedIndex < 3)
\r
936 check_mixedReferences.Visible = false;
\r
937 if (sender != "mixed-refs")
\r
938 check_mixedReferences.CheckState = CheckState.Unchecked;
\r
941 check_mixedReferences.Visible = true;
\r
943 case "me": // Motion Estimation
\r
944 if (drop_MotionEstimationMethod.SelectedIndex < 3)
\r
946 drop_MotionEstimationRange.Visible = false;
\r
947 lbl_merange.Visible = false;
\r
948 drop_MotionEstimationRange.SelectedIndex = 0;
\r
952 drop_MotionEstimationRange.Visible = true;
\r
953 lbl_merange.Visible = true;
\r
956 case "subq": // subme
\r
957 if (drop_subpixelMotionEstimation.SelectedIndex != 0 && drop_subpixelMotionEstimation.SelectedIndex < 7)
\r
959 slider_psyrd.Visible = false;
\r
960 slider_psyrd.Value = 10;
\r
961 lbl_psyrd.Visible = false;
\r
964 slider_psytrellis.Visible = false;
\r
965 slider_psytrellis.Value = 0;
\r
966 lbl_psytrellis.Visible = false;
\r
970 slider_psyrd.Visible = true;
\r
971 lbl_psyrd.Visible = true;
\r
973 if (drop_trellis.SelectedIndex >= 2 && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
975 slider_psytrellis.Visible = true;
\r
976 lbl_psytrellis.Visible = true;
\r
980 case "trellis": // subme
\r
981 if (drop_trellis.SelectedIndex > 0 && drop_trellis.SelectedIndex < 2 )
\r
983 slider_psytrellis.Visible = false;
\r
984 slider_psytrellis.Value = 0;
\r
985 lbl_psytrellis.Visible = false;
\r
989 if ((drop_subpixelMotionEstimation.SelectedIndex == 0 || drop_subpixelMotionEstimation.SelectedIndex >= 7) && check_Cabac.Checked && slider_psytrellis.Visible == false)
\r
991 slider_psytrellis.Visible = true;
\r
992 lbl_psytrellis.Visible = true;
\r