-using System;\r
+/* PresetLoader.cs $\r
+ \r
+ This file is part of the HandBrake source code.\r
+ Homepage: <http://handbrake.fr>.\r
+ It may be used under the terms of the GNU General Public License. */\r
+\r
+using System;\r
using System.Windows.Forms;\r
-using System.Drawing;\r
\r
namespace Handbrake.Functions\r
{\r
/// <param name="presetQuery">The Parsed CLI Query</param>\r
/// <param name="name">Name of the preset</param>\r
/// <param name="pictureSettings">Save picture settings in the preset</param>\r
- public static void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name, Boolean pictureSettings)\r
+ public static void presetLoader(frmMain mainWindow, QueryParser presetQuery, string name, Boolean pictureSettings)\r
{\r
// ---------------------------\r
// Setup the GUI\r
// ---------------------------\r
\r
- // Source tab\r
- #region source\r
+ #region Source\r
// Reset some vaules to stock first to prevent errors.\r
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;\r
\r
\r
#endregion\r
\r
- // Destination tab\r
- #region destination\r
-\r
- mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;\r
+ #region Destination and Output Settings\r
\r
if (presetQuery.Format != null)\r
{\r
- if (presetQuery.Format == "mp4")\r
+ if (presetQuery.Format == "mp4" || presetQuery.Format == "m4v")\r
mainWindow.drop_format.SelectedIndex = 0;\r
- else if (presetQuery.Format == "m4v")\r
- mainWindow.drop_format.SelectedIndex = 1;\r
else if (presetQuery.Format == "mkv")\r
- mainWindow.drop_format.SelectedIndex = 2;\r
-\r
- if (presetQuery.ChapterMarkers && presetQuery.Format == "mp4")\r
mainWindow.drop_format.SelectedIndex = 1;\r
}\r
\r
\r
mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4 ? CheckState.Checked : CheckState.Unchecked;\r
\r
- #endregion\r
+ mainWindow.check_largeFile.CheckState = presetQuery.LargeMP4 ? CheckState.Checked : CheckState.Unchecked;\r
\r
- // Picture Settings Tab\r
- #region Picture\r
- mainWindow.check_autoCrop.Checked = true;\r
- if (presetQuery.CropBottom == "0" && presetQuery.CropTop == "0")\r
- if (presetQuery.CropLeft == "0" && presetQuery.CropRight == "0")\r
- mainWindow.check_customCrop.Checked = true;\r
+ mainWindow.setContainerOpts(); // select the container options according to the selected format\r
\r
- mainWindow.text_width.Text = "";\r
- mainWindow.text_height.Text = "";\r
+ #endregion\r
\r
- if (pictureSettings)\r
+ #region Picture\r
+ \r
+ if (pictureSettings) // only Load picture settings if the perset requires it\r
{\r
- if (presetQuery.CropTop != null)\r
+ mainWindow.PictureSettings.check_autoCrop.Checked = true;\r
+ \r
+ if (presetQuery.CropValues != null)\r
{\r
int top, bottom, left, right;\r
int.TryParse(presetQuery.CropTop, out top);\r
int.TryParse(presetQuery.CropLeft, out left);\r
int.TryParse(presetQuery.CropRight, out right);\r
\r
- mainWindow.check_customCrop.Checked = true;\r
- mainWindow.text_top.Value = top;\r
- mainWindow.text_bottom.Value = bottom;\r
- mainWindow.text_left.Value = left;\r
- mainWindow.text_right.Value = right;\r
+ mainWindow.PictureSettings.check_customCrop.Checked = true;\r
+ mainWindow.PictureSettings.crop_top.Value = top;\r
+ mainWindow.PictureSettings.crop_bottom.Value = bottom;\r
+ mainWindow.PictureSettings.crop_left.Value = left;\r
+ mainWindow.PictureSettings.crop_right.Value = right;\r
}\r
-\r
- if (presetQuery.Width != 0)\r
- mainWindow.text_width.Text = presetQuery.Width.ToString();\r
-\r
- if (presetQuery.Height != 0)\r
- mainWindow.text_height.Text = presetQuery.Height.ToString();\r
}\r
\r
- mainWindow.drp_anamorphic.SelectedIndex = presetQuery.Anamorphic ? 1 : 0;\r
+ // Reset maxWidth and MaxHeight to 0\r
+ mainWindow.PictureSettings.maxWidth = 0;\r
+ mainWindow.PictureSettings.maxHeight = 0;\r
\r
- if (presetQuery.LooseAnamorphic)\r
- mainWindow.drp_anamorphic.SelectedIndex = 2;\r
- else\r
+ // Set the width and height\r
+ if (presetQuery.Width != 0)\r
+ mainWindow.PictureSettings.text_width.Value = presetQuery.Width;\r
+ else if (presetQuery.MaxWidth == 0)\r
{\r
- if (presetQuery.Anamorphic != true)\r
- mainWindow.drp_anamorphic.SelectedIndex = 0;\r
+ if (mainWindow.selectedTitle != null)\r
+ if (mainWindow.selectedTitle.Resolution.Width != 0)\r
+ {\r
+ mainWindow.PictureSettings.text_width.Value = mainWindow.selectedTitle.Resolution.Width;\r
+ if (presetQuery.Height == 0 && presetQuery.MaxHeight == 0)\r
+ mainWindow.PictureSettings.check_KeepAR.Checked = true;\r
+ }\r
+ else\r
+ mainWindow.PictureSettings.text_width.Value = 0;\r
}\r
\r
- // Set the public max width and max height varibles in frmMain\r
- // These are used by the query generator to determine if it should use -X or -w / -Y or -h\r
+ if (presetQuery.Height != 0)\r
+ mainWindow.PictureSettings.text_height.Value = presetQuery.Height;\r
+\r
+ // Max Width/Height override Width/Height\r
if (presetQuery.MaxWidth != 0)\r
{\r
- mainWindow.text_width.Text = presetQuery.MaxWidth.ToString();\r
- mainWindow.maxWidth = presetQuery.MaxWidth;\r
+ mainWindow.PictureSettings.text_width.Value = presetQuery.MaxWidth;\r
+ mainWindow.PictureSettings.maxWidth = presetQuery.MaxWidth;\r
}\r
\r
if (presetQuery.MaxHeight != 0)\r
{\r
- mainWindow.text_height.Text = presetQuery.MaxHeight.ToString();\r
- mainWindow.maxHeight = presetQuery.MaxHeight;\r
+ mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight;\r
+ mainWindow.PictureSettings.maxHeight = presetQuery.MaxHeight;\r
}\r
+ mainWindow.PictureSettings.setMax();\r
\r
+ // Set the anamorphic mode 0,1,2,3\r
+ mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;\r
\r
- #endregion\r
-\r
- // Filters Tab\r
- #region Filters\r
+ // Custom Anamorphic Controls\r
+ mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked;\r
+ mainWindow.PictureSettings.txt_displayWidth.Text = presetQuery.displayWidthValue.ToString();\r
+ mainWindow.PictureSettings.txt_parWidth.Text = presetQuery.pixelAspectWidth.ToString();\r
+ mainWindow.PictureSettings.txt_parHeight.Text = presetQuery.pixelAspectHeight.ToString();\r
+ mainWindow.PictureSettings.drop_modulus.SelectedItem = presetQuery.AnamorphicModulus;\r
\r
- mainWindow.ctl_decomb.setOption(presetQuery.Decomb);\r
\r
- if (mainWindow.ctl_decomb.getDropValue == "Off")\r
- mainWindow.ctl_deinterlace.setOption(presetQuery.DeInterlace);\r
- else\r
- mainWindow.ctl_deinterlace.setOption("None"); // Don't want decomb and deinterlace on at the same time\r
-\r
- mainWindow.ctl_denoise.setOption(presetQuery.DeNoise);\r
- mainWindow.ctl_detelecine.setOption(presetQuery.DeTelecine);\r
+ #endregion\r
\r
- if (presetQuery.DeBlock != 0)\r
- {\r
- mainWindow.slider_deblock.Value = presetQuery.DeBlock;\r
- mainWindow.lbl_deblockVal.Text = presetQuery.DeBlock.ToString();\r
- }\r
- else\r
- {\r
- mainWindow.slider_deblock.Value = 4;\r
- mainWindow.lbl_deblockVal.Text = "Off";\r
- }\r
+ #region Filters\r
+ mainWindow.Filters.setDecomb(presetQuery.Decomb);\r
+ mainWindow.Filters.setDeInterlace(presetQuery.DeInterlace);\r
+ mainWindow.Filters.setDeNoise(presetQuery.DeNoise);\r
+ mainWindow.Filters.setDeTelecine(presetQuery.DeTelecine);\r
+ mainWindow.Filters.setDeBlock(presetQuery.DeBlock);\r
+ mainWindow.Filters.setGrayScale(presetQuery.Grayscale);\r
#endregion\r
\r
- // Video Settings Tab\r
- #region video\r
+ #region Video\r
+ mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;\r
+\r
if (presetQuery.AverageVideoBitrate != null)\r
{\r
mainWindow.radio_avgBitrate.Checked = true;\r
if (presetQuery.VideoEncoder == "H.264 (x264)")\r
{\r
int value;\r
- System.Globalization.CultureInfo culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-US");\r
-\r
- double x264step;\r
+ double x264step = Properties.Settings.Default.x264cqstep;\r
double presetValue = presetQuery.VideoQuality;\r
- double.TryParse(Properties.Settings.Default.x264cqstep,\r
- System.Globalization.NumberStyles.Number,\r
- culture,\r
- out x264step);\r
\r
double x = 51 / x264step;\r
\r
// with a different granularity, so, round and try again.\r
if (value == 0)\r
{\r
- double val = Math.Round(calculated, 0);\r
+ double val = Math.Round(calculated, 0);\r
int.TryParse(val.ToString(), out value);\r
}\r
-\r
mainWindow.slider_videoQuality.Value = value;\r
}\r
else\r
\r
mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
\r
- mainWindow.check_grayscale.CheckState = presetQuery.Grayscale ? CheckState.Checked : CheckState.Unchecked;\r
\r
mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
\r
mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;\r
\r
- if (presetQuery.LargeMP4)\r
- mainWindow.check_largeFile.CheckState = CheckState.Checked;\r
- else\r
- {\r
- mainWindow.check_largeFile.CheckState = CheckState.Unchecked;\r
- mainWindow.check_largeFile.BackColor = Color.Transparent;\r
- }\r
#endregion\r
\r
- // Chapter Markers Tab\r
#region Chapter Markers\r
\r
if (presetQuery.ChapterMarkers)\r
\r
#endregion\r
\r
- // Audio Settings Tab\r
#region Audio\r
// Clear the audio listing\r
- mainWindow.lv_audioList.Items.Clear();\r
-\r
- // Create a new row for the Audio list based on the currently selected items in the dropdown.\r
- ListViewItem newTrack;\r
- if (presetQuery.AudioTrack1 != "None")\r
- {\r
- newTrack = new ListViewItem("Automatic");\r
- newTrack.SubItems.Add(presetQuery.AudioEncoder1);\r
- newTrack.SubItems.Add(presetQuery.AudioTrackMix1);\r
- newTrack.SubItems.Add(presetQuery.AudioSamplerate1);\r
- newTrack.SubItems.Add(presetQuery.AudioBitrate1);\r
- newTrack.SubItems.Add(presetQuery.DRC1.ToString());\r
- mainWindow.lv_audioList.Items.Add(newTrack);\r
- }\r
-\r
- if (presetQuery.AudioTrack2 != "None")\r
- {\r
- newTrack = new ListViewItem("Automatic");\r
- newTrack.SubItems.Add(presetQuery.AudioEncoder2);\r
- newTrack.SubItems.Add(presetQuery.AudioTrackMix2);\r
- newTrack.SubItems.Add(presetQuery.AudioSamplerate2);\r
- newTrack.SubItems.Add(presetQuery.AudioBitrate2);\r
- newTrack.SubItems.Add(presetQuery.DRC2.ToString());\r
- mainWindow.lv_audioList.Items.Add(newTrack);\r
- }\r
-\r
- if (presetQuery.AudioTrack3 != "None")\r
- {\r
- newTrack = new ListViewItem("Automatic");\r
- newTrack.SubItems.Add(presetQuery.AudioEncoder3);\r
- newTrack.SubItems.Add(presetQuery.AudioTrackMix3);\r
- newTrack.SubItems.Add(presetQuery.AudioSamplerate3);\r
- newTrack.SubItems.Add(presetQuery.AudioBitrate3);\r
- newTrack.SubItems.Add(presetQuery.DRC3.ToString());\r
- mainWindow.lv_audioList.Items.Add(newTrack);\r
- }\r
-\r
- if (presetQuery.AudioTrack4 != "None")\r
- {\r
- newTrack = new ListViewItem("Automatic");\r
- newTrack.SubItems.Add(presetQuery.AudioEncoder4);\r
- newTrack.SubItems.Add(presetQuery.AudioTrackMix4);\r
- newTrack.SubItems.Add(presetQuery.AudioSamplerate4);\r
- newTrack.SubItems.Add(presetQuery.AudioBitrate4);\r
- newTrack.SubItems.Add(presetQuery.DRC4.ToString());\r
- mainWindow.lv_audioList.Items.Add(newTrack);\r
- }\r
-\r
- // Subtitle Stuff\r
- mainWindow.drp_subtitle.Text = presetQuery.Subtitles;\r
-\r
- if (presetQuery.ForcedSubtitles)\r
- {\r
- mainWindow.check_forced.CheckState = CheckState.Checked;\r
- mainWindow.check_forced.Enabled = true;\r
- }\r
- else\r
- mainWindow.check_forced.CheckState = CheckState.Unchecked;\r
+ mainWindow.AudioSettings.clearAudioList();\r
\r
+ if (presetQuery.AudioInformation != null)\r
+ foreach (AudioTrack track in presetQuery.AudioInformation)\r
+ {\r
+ ListViewItem newTrack = new ListViewItem(mainWindow.AudioSettings.getNewID().ToString());\r
+\r
+ newTrack.SubItems.Add("Automatic");\r
+ newTrack.SubItems.Add(track.Encoder);\r
+ newTrack.SubItems.Add(track.MixDown);\r
+ newTrack.SubItems.Add(track.SampleRate);\r
+ if (track.Encoder.Contains("AC3"))\r
+ newTrack.SubItems.Add("Auto");\r
+ else\r
+ newTrack.SubItems.Add(track.Bitrate);\r
+ newTrack.SubItems.Add(track.DRC);\r
+ mainWindow.AudioSettings.addTrackForPreset(newTrack);\r
+ }\r
#endregion\r
\r
- // H264 Tab & Preset Name\r
- #region other\r
+ #region Other\r
mainWindow.x264Panel.x264Query = presetQuery.H264Query;\r
\r
// Set the preset name\r