+using System;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Windows.Forms;\r
+\r
+namespace Handbrake.Functions\r
+{\r
+ class x264Panel\r
+ {\r
+ Boolean NoWidgetUpdate = false;\r
+\r
+ /// <summary>\r
+ /// Reset all components to defaults and clears the x264 rtf box\r
+ /// </summary>\r
+ public void reset2Defaults(frmMain mainWindow)\r
+ {\r
+ mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_bFrameDistortion.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_BidirectionalRefinement.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_Cabac.CheckState = CheckState.Checked;\r
+ mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_noDCTDecimate.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_noFastPSkip.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked;\r
+ mainWindow.check_weightedBFrames.CheckState = CheckState.Unchecked;\r
+ mainWindow.drop_analysis.SelectedIndex = 0;\r
+ mainWindow.drop_bFrames.SelectedIndex = 0;\r
+ mainWindow.drop_deblockAlpha.SelectedIndex = 0;\r
+ mainWindow.drop_deblockBeta.SelectedIndex = 0;\r
+ mainWindow.drop_directPrediction.SelectedIndex = 0;\r
+ mainWindow.drop_MotionEstimationMethod.SelectedIndex = 0;\r
+ mainWindow.drop_MotionEstimationRange.SelectedIndex = 0;\r
+ mainWindow.drop_refFrames.SelectedIndex = 0;\r
+ mainWindow.drop_subpixelMotionEstimation.SelectedIndex = 0;\r
+ mainWindow.drop_trellis.SelectedIndex = 0;\r
+\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+\r
+ /// <summary>\r
+ /// Update GUI componets from the current x264 rtf string\r
+ /// </summary>\r
+ public void X264_SetCurrentSettingsInPanel(frmMain mainWindow)\r
+ {\r
+ // When the widgets are changed, we don't want them to update the text box again. No Need.\r
+ // This boolean controls the Widget Change function\r
+\r
+\r
+ /* Set widgets depending on the opt string in field */\r
+ String thisOpt; // The separated option such as "bframes=3"\r
+ String optName = ""; // The option name such as "bframes"\r
+ String optValue = "";// The option value such as "3"\r
+ String[] currentOptsArray;\r
+\r
+ //Set currentOptString to the contents of the text box.\r
+ String currentOptString = mainWindow.rtf_x264Query.Text.Replace("\n", "");\r
+\r
+ /*verify there is an opt string to process */\r
+ if (currentOptString.Contains("="))\r
+ {\r
+ /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/\r
+ currentOptsArray = currentOptString.Split(':');\r
+\r
+ /*iterate through the array and get <opts> and <values*/\r
+ int loopcounter;\r
+ int currentOptsArrayCount = currentOptsArray.Length;\r
+ \r
+\r
+ /*iterate through the array and get <opts> and <values*/\r
+ for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)\r
+ {\r
+ \r
+ thisOpt = currentOptsArray[loopcounter];\r
+ String[] splitOptRange = thisOpt.Split('=');\r
+\r
+ if (thisOpt.Contains("="))\r
+ {\r
+ optName = splitOptRange[0];\r
+ optValue = splitOptRange[1];\r
+\r
+ /*Run through the available widgets for x264 opts and set them, as you add widgets, \r
+ they need to be added here. This should be moved to its own method probably*/\r
+\r
+ /*bframes NSPopUpButton*/\r
+ if (optName.Equals("bframes"))\r
+ mainWindow.drop_bFrames.SelectedItem = optValue;\r
+\r
+ /*ref NSPopUpButton*/\r
+ else if (optName.Equals("ref"))\r
+ mainWindow.drop_refFrames.SelectedItem = optValue;\r
+\r
+ /*No Fast PSkip NSPopUpButton*/\r
+ else if (optName.Equals("no-fast-pskip"))\r
+ mainWindow.check_noFastPSkip.CheckState = CheckState.Checked;\r
+\r
+ /*No Dict Decimate NSPopUpButton*/\r
+ else if (optName.Equals("no-dct-decimate"))\r
+ mainWindow.check_noDCTDecimate.CheckState = CheckState.Checked;\r
+\r
+ /*Sub Me NSPopUpButton*/\r
+ else if (optName.Equals("subq"))\r
+ mainWindow.drop_subpixelMotionEstimation.SelectedItem = optValue;\r
+\r
+ /*Trellis NSPopUpButton*/\r
+ else if (optName.Equals("trellis"))\r
+ mainWindow.drop_trellis.SelectedItem = optValue;\r
+\r
+ /*Mixed Refs NSButton*/\r
+ else if (optName.Equals("mixed-refs"))\r
+ mainWindow.check_mixedReferences.CheckState = CheckState.Checked;\r
+\r
+ /*Motion Estimation NSPopUpButton*/\r
+ else if (optName.Equals("me"))\r
+ {\r
+ if (optValue.Equals("dia"))\r
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Diamond";\r
+ else if (optValue.Equals("hex"))\r
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Hexagon";\r
+ else if (optValue.Equals("umh"))\r
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";\r
+ else if (optValue.Equals("esa"))\r
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Exhaustive";\r
+\r
+ }\r
+ /*ME Range NSPopUpButton*/\r
+ else if (optName.Equals("merange"))\r
+ mainWindow.drop_MotionEstimationRange.SelectedItem = optValue;\r
+\r
+ /*Weighted B-Frames NSPopUpButton*/\r
+ else if (optName.Equals("weightb"))\r
+ mainWindow.check_weightedBFrames.CheckState = CheckState.Checked;\r
+\r
+ /*BRDO NSPopUpButton*/\r
+ else if (optName.Equals("brdo"))\r
+ mainWindow.check_bFrameDistortion.CheckState = CheckState.Checked;\r
+\r
+ /*B Pyramid NSPopUpButton*/\r
+ else if (optName.Equals("b-pyramid"))\r
+ mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Checked;\r
+\r
+ /*Bidirectional Motion Estimation Refinement NSPopUpButton*/\r
+ else if (optName.Equals("bime"))\r
+ mainWindow.check_BidirectionalRefinement.CheckState = CheckState.Checked;\r
+\r
+ /*Direct B-frame Prediction NSPopUpButton*/\r
+ else if (optName.Equals("direct"))\r
+ {\r
+ if (optValue == "auto")\r
+ optValue = "Automatic";\r
+\r
+ if (optValue != "")\r
+ {\r
+ Char[] letters = optValue.ToCharArray();\r
+ letters[0] = Char.ToUpper(letters[0]);\r
+ optValue = new string(letters);\r
+ }\r
+\r
+ mainWindow.drop_directPrediction.SelectedItem = optValue;\r
+ }\r
+\r
+ /*Deblocking NSPopUpButtons*/\r
+ else if (optName.Equals("deblock"))\r
+ {\r
+ string alphaDeblock = "";\r
+ string betaDeblock = "";\r
+\r
+ string[] splitDeblock = optValue.Split(',');\r
+ alphaDeblock = splitDeblock[0];\r
+ betaDeblock = splitDeblock[1];\r
+\r
+ if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))\r
+ {\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";\r
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";\r
+ }\r
+ else\r
+ {\r
+ if (!alphaDeblock.Equals("0"))\r
+ mainWindow.drop_deblockAlpha.SelectedItem = alphaDeblock;\r
+ else\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "0";\r
+\r
+ if (!betaDeblock.Replace("\n", "").Equals("0"))\r
+ mainWindow.drop_deblockBeta.SelectedItem = betaDeblock.Replace("\n", "");\r
+ else\r
+ mainWindow.drop_deblockBeta.SelectedItem = "0";\r
+ }\r
+ }\r
+ /* Analysis NSPopUpButton */\r
+ else if (optName.Equals("analyse"))\r
+ {\r
+\r
+ if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))\r
+ mainWindow.drop_analysis.SelectedItem = "Default (some)";\r
+ if (optValue.Equals("none"))\r
+ mainWindow.drop_analysis.SelectedItem = "None";\r
+ if (optValue.Equals("all"))\r
+ mainWindow.drop_analysis.SelectedItem = "All";\r
+ }\r
+ /* 8x8 DCT NSButton */\r
+ else if (optName.Equals("8x8dct"))\r
+ mainWindow.check_8x8DCT.CheckState = CheckState.Checked;\r
+\r
+ /* CABAC NSButton */\r
+ else if (optName.Equals("cabac"))\r
+ mainWindow.check_Cabac.CheckState = CheckState.Unchecked;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box\r
+ /// </summary>\r
+ public void X264_StandardizeOptString(frmMain mainWindow)\r
+ {\r
+ /* Set widgets depending on the opt string in field */\r
+ String thisOpt; // The separated option such as "bframes=3"\r
+ String optName = ""; // The option name such as "bframes"\r
+ String optValue = "";// The option value such as "3"\r
+ String changedOptString = "";\r
+ String[] currentOptsArray;\r
+\r
+ /*First, we get an opt string to process */\r
+ String currentOptString = mainWindow.rtf_x264Query.Text;\r
+\r
+ /*verify there is an opt string to process */\r
+ if (currentOptString.Contains("="))\r
+ {\r
+ /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/\r
+ currentOptsArray = currentOptString.Split(':');\r
+\r
+ /*iterate through the array and get <opts> and <values*/\r
+ //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];\r
+ int loopcounter;\r
+ int currentOptsArrayCount = currentOptsArray.Length;\r
+ for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)\r
+ {\r
+ thisOpt = currentOptsArray[loopcounter];\r
+ if (currentOptsArray[currentOptsArrayCount - 1] == "")\r
+ break;\r
+\r
+ String[] splitOptRange = thisOpt.Split('=');\r
+ if (thisOpt != "")\r
+ {\r
+ if (thisOpt.Contains("="))\r
+ {\r
+ optName = splitOptRange[0];\r
+ optValue = splitOptRange[1];\r
+\r
+ /* Standardize the names here depending on whats in the string */\r
+ optName = X264_StandardizeOptNames(optName);\r
+ thisOpt = optName + "=" + optValue;\r
+ }\r
+ else // No value given so we use a default of "1"\r
+ {\r
+ optName = thisOpt;\r
+ /* Standardize the names here depending on whats in the string */\r
+ optName = X264_StandardizeOptNames(optName);\r
+ thisOpt = optName + "=1";\r
+ }\r
+ }\r
+\r
+ /* Construct New String for opts here */\r
+ if (thisOpt == "")\r
+ changedOptString = changedOptString + thisOpt;\r
+ else\r
+ {\r
+ if (changedOptString == "")\r
+ changedOptString = thisOpt;\r
+ else\r
+ changedOptString = changedOptString + ":" + thisOpt;\r
+ }\r
+ }\r
+ }\r
+\r
+ /* Change the option string to reflect the new standardized option string */\r
+ if (changedOptString != "")\r
+ mainWindow.rtf_x264Query.Text = changedOptString;\r
+ }\r
+\r
+ /// <summary>\r
+ /// This function will update the X264 Query when one of the GUI widgets changes.\r
+ /// </summary>\r
+ public void on_x264_WidgetChange(string sender, frmMain mainWindow)\r
+ {\r
+ if (NoWidgetUpdate == false)\r
+ {\r
+ String optNameToChange = sender;\r
+ String currentOptString = mainWindow.rtf_x264Query.Text;\r
+\r
+ /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after\r
+ the first character of the opt string (hence the ":") */\r
+ String checkOptNameToChange = ":" + optNameToChange + "=";\r
+ String checkOptNameToChangeBegin = optNameToChange + "=";\r
+\r
+ // IF the current H264 Option String Contains Multiple Items or Just 1 Item\r
+ if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))\r
+ hasFullOption(currentOptString, optNameToChange, mainWindow);\r
+ else // IF there is no options in the rich text box!\r
+ hasNoOptions(optNameToChange, mainWindow);\r
+ }\r
+ else\r
+ {\r
+ NoWidgetUpdate = false;\r
+ }\r
+ }\r
+ \r
+\r
+ #region Some Private Functions used by the above Public Functions\r
+ /*\r
+ * Used by on_x264_WidgetChange()\r
+ * Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :\r
+ * Basically, it updates the current option that the widget corrosponds to, if it is already in thes string\r
+ * otherwise, it adds it to the string.\r
+ */\r
+ private void hasFullOption(string currentOptString, string optNameToChange, frmMain mainWindow)\r
+ {\r
+ String thisOpt; // The separated option such as "bframes=3"\r
+ String optName = ""; // The option name such as "bframes"\r
+ String optValue = ""; // The option value such as "3"\r
+ String[] currentOptsArray;\r
+\r
+ /* Create new empty opt string*/\r
+ String changedOptString = "";\r
+\r
+ /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/\r
+ currentOptsArray = currentOptString.Split(':');\r
+\r
+ /*iterate through the array and get <opts> and <values*/\r
+ for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)\r
+ {\r
+ thisOpt = currentOptsArray[loopcounter];\r
+\r
+ if (thisOpt.Contains("="))\r
+ {\r
+ string[] splitOptRange = thisOpt.Split('=');\r
+\r
+ optName = splitOptRange[0]; // e.g bframes\r
+ optValue = splitOptRange[1]; // e.g 2\r
+\r
+ /* \r
+ * Run through the available widgets for x264 opts and set them, as you add widgets,\r
+ * they need to be added here. This should be moved to its own method probably\r
+ * If the optNameToChange is found, appropriately change the value or delete it if\r
+ * "unspecified" is set.\r
+ */\r
+ if (optName.Equals(optNameToChange))\r
+ {\r
+ if (optNameToChange.Equals("deblock"))\r
+ {\r
+ String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();\r
+ String db = mainWindow.drop_deblockBeta.SelectedItem.ToString();\r
+\r
+ if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))\r
+ {\r
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";\r
+ thisOpt = "";\r
+ }\r
+ else if ((!da.Contains("Default")) && (db.Contains("Default")))\r
+ {\r
+ mainWindow.drop_deblockBeta.SelectedItem = "0";\r
+ thisOpt = "deblock=" + da + ",0";\r
+ }\r
+ else if ((da.Contains("Default")) && (!db.Contains("Default")))\r
+ {\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "0";\r
+ thisOpt = "deblock=0," + db;\r
+ }\r
+ else if ((!da.Contains("Default")) && (!db.Contains("Default")))\r
+ thisOpt = "deblock=" + da + "," + db;\r
+ }\r
+\r
+ else if (optNameToChange.Equals("mixed-refs"))\r
+ {\r
+ if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)\r
+ thisOpt = "mixed-refs=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("weightb"))\r
+ {\r
+ if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)\r
+ thisOpt = "weightb=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("brdo"))\r
+ {\r
+ if (mainWindow.check_bFrameDistortion.CheckState == CheckState.Checked)\r
+ thisOpt = "brdo=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("bime"))\r
+ {\r
+ if (mainWindow.check_BidirectionalRefinement.CheckState == CheckState.Checked)\r
+ thisOpt = "bime=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("b-pyramid"))\r
+ {\r
+ if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)\r
+ thisOpt = "b-pyramid=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("no-fast-pskip"))\r
+ {\r
+ if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)\r
+ thisOpt = "no-fast-pskip=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("no-dct-decimate"))\r
+ {\r
+ if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)\r
+ thisOpt = "no-dct-decimate=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("8x8dct"))\r
+ {\r
+ if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)\r
+ thisOpt = "8x8dct=1";\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("cabac"))\r
+ {\r
+ if (mainWindow.check_Cabac.CheckState == CheckState.Checked)\r
+ thisOpt = "";\r
+ else\r
+ thisOpt = "cabac=0";\r
+ }\r
+ else if (optNameToChange.Equals("me"))\r
+ {\r
+ switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)\r
+ {\r
+ case 1:\r
+ thisOpt = "me=dia";\r
+ break;\r
+\r
+ case 2:\r
+ thisOpt = "me=hex";\r
+ break;\r
+\r
+ case 3:\r
+ thisOpt = "me=umh";\r
+ break;\r
+\r
+ case 4:\r
+ thisOpt = "me=esa";\r
+ break;\r
+\r
+ default:\r
+ thisOpt = "";\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("direct"))\r
+ {\r
+ switch (mainWindow.drop_directPrediction.SelectedIndex)\r
+ {\r
+ case 1:\r
+ thisOpt = "direct=none";\r
+ break;\r
+\r
+ case 2:\r
+ thisOpt = "direct=spatial";\r
+ break;\r
+\r
+ case 3:\r
+ thisOpt = "direct=temporal";\r
+ break;\r
+\r
+ case 4:\r
+ thisOpt = "direct=auto";\r
+ break;\r
+\r
+ default:\r
+ thisOpt = "";\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("analyse"))\r
+ {\r
+ switch (mainWindow.drop_analysis.SelectedIndex)\r
+ {\r
+ case 1:\r
+ thisOpt = "analyse=none";\r
+ break;\r
+\r
+ case 2:\r
+ thisOpt = "analyse=all";\r
+ break;\r
+\r
+ default:\r
+ thisOpt = "";\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("merange"))\r
+ {\r
+ if (!mainWindow.drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default"))\r
+ thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem.ToString();\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("ref"))\r
+ {\r
+ if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))\r
+ thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("bframes"))\r
+ {\r
+ String value = mainWindow.drop_bFrames.SelectedItem.ToString();\r
+ if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))\r
+ thisOpt = "bframes=" + value;\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("subq"))\r
+ {\r
+ String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();\r
+ if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))\r
+ thisOpt = "subq=" + value;\r
+ else\r
+ thisOpt = "";\r
+ }\r
+ else if (optNameToChange.Equals("trellis"))\r
+ {\r
+ String value = mainWindow.drop_trellis.SelectedItem.ToString();\r
+ if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))\r
+ thisOpt = "trellis=" + value;\r
+ else\r
+ thisOpt = "";\r
+ }\r
+\r
+ }\r
+ }\r
+\r
+ /* Construct New String for opts here */\r
+ if (!thisOpt.Equals(""))\r
+ {\r
+ if (changedOptString.Equals(""))\r
+ changedOptString = thisOpt;\r
+ else\r
+ changedOptString = changedOptString + ":" + thisOpt;\r
+ }\r
+ }\r
+\r
+ /* Change the option string to reflect the new mod settings */\r
+ mainWindow.rtf_x264Query.Text = changedOptString;\r
+ }\r
+ /*\r
+ * Used by on_x264_WidgetChange()\r
+ * Called when the current x264 option string contains no options.\r
+ * This simply adds the option to the x264 query in the gui.\r
+ */\r
+ private void hasNoOptions(string optNameToChange, frmMain mainWindow)\r
+ {\r
+ // If the text box is blank\r
+ if (mainWindow.rtf_x264Query.Text == "")\r
+ {\r
+ if (optNameToChange.Equals("me"))\r
+ {\r
+ switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)\r
+ {\r
+ case 1:\r
+ mainWindow.rtf_x264Query.Text = "me=dia";\r
+ break;\r
+\r
+ case 2:\r
+ mainWindow.rtf_x264Query.Text = "me=hex";\r
+\r
+ break;\r
+\r
+ case 3:\r
+ mainWindow.rtf_x264Query.Text = "me=umh";\r
+ break;\r
+\r
+ case 4:\r
+ mainWindow.rtf_x264Query.Text = "me=esa";\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("direct"))\r
+ {\r
+ switch (mainWindow.drop_directPrediction.SelectedIndex)\r
+ {\r
+ case 1:\r
+ mainWindow.rtf_x264Query.Text = "direct=none";\r
+ break;\r
+\r
+ case 2:\r
+ mainWindow.rtf_x264Query.Text = "direct=spatial";\r
+ break;\r
+\r
+ case 3:\r
+ mainWindow.rtf_x264Query.Text = "direct=temporal";\r
+ break;\r
+\r
+ case 4:\r
+ mainWindow.rtf_x264Query.Text = "direct=auto";\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("analyse"))\r
+ {\r
+ switch (mainWindow.drop_analysis.SelectedIndex)\r
+ {\r
+ case 1:\r
+ mainWindow.rtf_x264Query.Text = "analyse=none";\r
+ break;\r
+\r
+ case 2:\r
+ mainWindow.rtf_x264Query.Text = "analyse=all";\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+ else if (optNameToChange.Equals("merange"))\r
+ {\r
+ int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;\r
+ mainWindow.rtf_x264Query.Text = "merange=" + value.ToString();\r
+ }\r
+ else if (optNameToChange.Equals("deblock"))\r
+ {\r
+ String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();\r
+ String db = mainWindow.drop_deblockBeta.SelectedItem.ToString();\r
+\r
+ if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))\r
+ {\r
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if ((!da.Contains("Default")) && (db.Contains("Default")))\r
+ {\r
+ mainWindow.drop_deblockBeta.SelectedItem = "0";\r
+ mainWindow.rtf_x264Query.Text = "deblock=" + da + ",0";\r
+ }\r
+ else if ((da.Contains("Default")) && (!db.Contains("Default")))\r
+ {\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "0";\r
+ mainWindow.rtf_x264Query.Text = "deblock=0," + db;\r
+ }\r
+ else if ((!da.Contains("Default")) && (!db.Contains("Default")))\r
+ {\r
+ mainWindow.rtf_x264Query.Text = "deblock=" + da + "," + db;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("mixed-refs"))\r
+ {\r
+ if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "mixed-refs=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("weightb"))\r
+ {\r
+ if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "weightb=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("brdo"))\r
+ {\r
+ if (mainWindow.check_bFrameDistortion.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "brdo=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("bime"))\r
+ {\r
+ if (mainWindow.check_BidirectionalRefinement.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "bime=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("b-pyramid"))\r
+ {\r
+ if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "b-pyramid=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("no-fast-pskip"))\r
+ {\r
+ if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "no-fast-pskip=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("no-dct-decimate"))\r
+ {\r
+ if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "no-dct-decimate=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("8x8dct"))\r
+ {\r
+ if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "8x8dct=1";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ }\r
+ else if (optNameToChange.Equals("cabac"))\r
+ {\r
+ if (mainWindow.check_Cabac.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = "";\r
+ else\r
+ mainWindow.rtf_x264Query.Text = "cabac=0";\r
+ }\r
+ else if (optNameToChange.Equals("ref"))\r
+ {\r
+ string refItem = mainWindow.drop_refFrames.SelectedItem.ToString();\r
+ if (!refItem.Contains("default"))\r
+ mainWindow.rtf_x264Query.Text = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();\r
+ }\r
+ else if (optNameToChange.Equals("bframes"))\r
+ {\r
+ String value = mainWindow.drop_bFrames.SelectedItem.ToString();\r
+ if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = "bframes=" + value;\r
+ }\r
+ else if (optNameToChange.Equals("subq"))\r
+ {\r
+ String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();\r
+ if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = "subq=" + value;\r
+ }\r
+ else if (optNameToChange.Equals("trellis"))\r
+ {\r
+ String value = mainWindow.drop_trellis.SelectedItem.ToString();\r
+ if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = "trellis=" + value;\r
+ }\r
+\r
+ //*******************************************************\r
+ }\r
+ else // There was some text in the box. This deals with options with no value. e.g "no-fast-pskip"\r
+ {\r
+ //*******************************************************\r
+ if (optNameToChange.Equals("me"))\r
+ {\r
+ switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)\r
+ {\r
+ case 1:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=dia";\r
+ break;\r
+\r
+ case 2:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=hex";\r
+ break;\r
+\r
+ case 3:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=umh";\r
+ break;\r
+\r
+ case 4:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":me=esa";\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("direct"))\r
+ {\r
+ switch (mainWindow.drop_directPrediction.SelectedIndex)\r
+ {\r
+ case 1:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=none";\r
+ break;\r
+\r
+ case 2:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=spatial";\r
+ break;\r
+\r
+ case 3:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=temporal";\r
+ break;\r
+\r
+ case 4:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":direct=auto";\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("analyse"))\r
+ {\r
+ switch (mainWindow.drop_analysis.SelectedIndex)\r
+ {\r
+ case 1:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":analyse=none";\r
+ break;\r
+\r
+ case 2:\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":analyse=all";\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ }\r
+\r
+ else if (optNameToChange.Equals("merange"))\r
+ {\r
+ int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":merange=" + value.ToString();\r
+ }\r
+ else if (optNameToChange.Equals("deblock"))\r
+ {\r
+ String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();\r
+ String db = mainWindow.drop_deblockBeta.Text.ToString();\r
+\r
+ if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))\r
+ {\r
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";\r
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";\r
+ }\r
+ else\r
+ {\r
+ if (db.Contains("Default"))\r
+ db = "0";\r
+\r
+ if (da.Contains("Default"))\r
+ da = "0";\r
+\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":deblock=" + da + "," + db;\r
+ }\r
+ }\r
+ else if (optNameToChange.Equals("mixed-refs"))\r
+ {\r
+ if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":mixed-refs=1";\r
+ }\r
+ else if (optNameToChange.Equals("weightb"))\r
+ {\r
+ if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":weightb=1";\r
+ }\r
+ else if (optNameToChange.Equals("brdo"))\r
+ {\r
+ if (mainWindow.check_bFrameDistortion.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":brdo=1";\r
+ }\r
+ else if (optNameToChange.Equals("bime"))\r
+ {\r
+ if (mainWindow.check_BidirectionalRefinement.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":bime=1";\r
+ }\r
+ else if (optNameToChange.Equals("b-pyramid"))\r
+ {\r
+ if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":b-pyramid=1";\r
+ }\r
+ else if (optNameToChange.Equals("no-fast-pskip"))\r
+ {\r
+ if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":no-fast-pskip=1";\r
+ }\r
+ else if (optNameToChange.Equals("no-dct-decimate"))\r
+ {\r
+ if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":no-dct-decimate=1";\r
+ }\r
+ else if (optNameToChange.Equals("8x8dct"))\r
+ {\r
+ if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":8x8dct=1";\r
+ }\r
+ else if (optNameToChange.Equals("cabac"))\r
+ {\r
+ if (mainWindow.check_Cabac.CheckState == CheckState.Checked)\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text;\r
+ else\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":cabac=0";\r
+ }\r
+ else if (optNameToChange.Equals("ref"))\r
+ {\r
+ if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();\r
+ }\r
+ else if (optNameToChange.Equals("bframes"))\r
+ {\r
+ int value = mainWindow.drop_bFrames.SelectedIndex;\r
+ value = value - 1;\r
+ if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":bframes=" + value.ToString();\r
+ }\r
+ else if (optNameToChange.Equals("subq"))\r
+ {\r
+ String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();\r
+ if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":subq=" + value;\r
+ }\r
+ else if (optNameToChange.Equals("trellis"))\r
+ {\r
+ if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))\r
+ mainWindow.rtf_x264Query.Text = mainWindow.rtf_x264Query.Text + ":trellis=" + mainWindow.drop_trellis.SelectedItem.ToString();\r
+ }\r
+ }\r
+ }\r
+\r
+ /*\r
+ * Take a single option and standardize it. Returns as a String\r
+ * Input: String. - Single X264 Option. Name only\r
+ * Output: String - Single X264 Option. Name only. Changed to standard format\r
+ */\r
+ private string X264_StandardizeOptNames(String cleanOptNameString)\r
+ {\r
+ String input = cleanOptNameString;\r
+ if (input.Equals("ref") || input.Equals("frameref"))\r
+ {\r
+ cleanOptNameString = "ref";\r
+ }\r
+\r
+ /*No Fast PSkip nofast_pskip*/\r
+ if (input.Equals("no-fast-pskip") || input.Equals("no_fast_pskip") || input.Equals("nofast_pskip"))\r
+ {\r
+ cleanOptNameString = "no-fast-pskip";\r
+ }\r
+\r
+ /*No Dict Decimate*/\r
+ if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))\r
+ {\r
+ cleanOptNameString = "no-dct-decimate";\r
+ }\r
+\r
+ /*Subme*/\r
+ if (input.Equals("subme"))\r
+ {\r
+ cleanOptNameString = "subq";\r
+ }\r
+\r
+ /*ME Range*/\r
+ if (input.Equals("me-range") || input.Equals("me_range"))\r
+ {\r
+ cleanOptNameString = "merange";\r
+ }\r
+\r
+ /*WeightB*/\r
+ if (input.Equals("weight-b") || input.Equals("weight_b"))\r
+ {\r
+ cleanOptNameString = "weightb";\r
+ }\r
+\r
+ /*BRDO*/\r
+ if (input.Equals("b-rdo") || input.Equals("b_rdo"))\r
+ {\r
+ cleanOptNameString = "brdo";\r
+ }\r
+\r
+ /*B Pyramid*/\r
+ if (input.Equals("b_pyramid"))\r
+ {\r
+ cleanOptNameString = "b-pyramid";\r
+ }\r
+\r
+ /*Direct Prediction*/\r
+ if (input.Equals("direct-pred") || input.Equals("direct_pred"))\r
+ {\r
+ cleanOptNameString = "direct";\r
+ }\r
+\r
+ /*Deblocking*/\r
+ if (input.Equals("filter"))\r
+ {\r
+ cleanOptNameString = "deblock";\r
+ }\r
+\r
+ /*Analysis*/\r
+ if (input.Equals("partitions"))\r
+ {\r
+ cleanOptNameString = "analyse";\r
+ }\r
+\r
+ return cleanOptNameString;\r
+ }\r
+\r
+ #endregion\r
+ }\r
+}\r