using System;\r
using System.Windows.Forms;\r
\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
+\r
/// <summary>\r
/// The Filters Panel\r
/// </summary>\r
/// <summary>\r
/// Set the Detelecine control\r
/// </summary>\r
- /// <param name="value">The value part of the CLI string</param>\r
- public void SetDeTelecine(string value)\r
+ /// <param name="value">\r
+ /// The value part of the CLI string\r
+ /// </param>\r
+ /// <param name="custom">\r
+ /// The Custom Detelecine setting\r
+ /// </param>\r
+ public void SetDeTelecine(Detelecine value, string custom)\r
{\r
text_customDT.Text = string.Empty;\r
text_customDT.Visible = false;\r
switch (value)\r
{\r
- case "Off":\r
+ case Detelecine.Off:\r
drop_detelecine.SelectedIndex = 0;\r
break;\r
- case "Default":\r
+ case Detelecine.Default:\r
drop_detelecine.SelectedIndex = 2;\r
break;\r
default:\r
drop_detelecine.SelectedIndex = 1;\r
- text_customDT.Text = value;\r
+ text_customDT.Text = custom;\r
text_customDT.Visible = true;\r
break;\r
}\r
/// <summary>\r
/// Set the Denoise control\r
/// </summary>\r
- /// <param name="value">The value part of the CLI string</param>\r
- public void SetDeNoise(string value)\r
+ /// <param name="value">\r
+ /// The value part of the CLI string\r
+ /// </param>\r
+ /// <param name="custom">\r
+ /// The custom denoise setting.\r
+ /// </param>\r
+ public void SetDeNoise(Denoise value, string custom)\r
{\r
text_customDN.Text = string.Empty;\r
text_customDN.Visible = false;\r
switch (value)\r
{\r
- case "Off":\r
+ case Denoise.Off:\r
drop_denoise.SelectedIndex = 0;\r
break;\r
- case "Weak":\r
+ case Denoise.Weak:\r
drop_denoise.SelectedIndex = 2;\r
break;\r
- case "Medium":\r
+ case Denoise.Medium:\r
drop_denoise.SelectedIndex = 3;\r
break;\r
- case "Strong":\r
+ case Denoise.Strong:\r
drop_denoise.SelectedIndex = 4;\r
break;\r
default:\r
drop_denoise.SelectedIndex = 1;\r
- text_customDN.Text = value;\r
+ text_customDN.Text = custom;\r
text_customDN.Visible = true;\r
break;\r
}\r
/// <summary>\r
/// Set the Deinterlace Control\r
/// </summary>\r
- /// <param name="value">The value part of the CLI string</param>\r
- public void SetDeInterlace(string value)\r
+ /// <param name="value">\r
+ /// The value part of the CLI string\r
+ /// </param>\r
+ /// <param name="custom">\r
+ /// The Custom Detinerlace Settings\r
+ /// </param>\r
+ public void SetDeInterlace(Deinterlace value, string custom)\r
{\r
text_customDI.Text = string.Empty;\r
text_customDI.Visible = false;\r
switch (value)\r
{\r
- case "Off":\r
+ case Deinterlace.Off:\r
drop_deinterlace.SelectedIndex = 0;\r
break;\r
- case "Fast":\r
+ case Deinterlace.Fast:\r
drop_deinterlace.SelectedIndex = 2;\r
break;\r
- case "Slow":\r
+ case Deinterlace.Slow:\r
drop_deinterlace.SelectedIndex = 3;\r
break;\r
- case "Slower":\r
+ case Deinterlace.Slower:\r
drop_deinterlace.SelectedIndex = 4;\r
\r
break;\r
default:\r
drop_deinterlace.SelectedIndex = 1;\r
- text_customDI.Text = value;\r
+ text_customDI.Text = custom;\r
text_customDI.Visible = true;\r
break;\r
}\r
/// <summary>\r
/// Set the Decomb Control\r
/// </summary>\r
- /// <param name="value">The value part of the CLI string</param>\r
- public void SetDecomb(string value)\r
+ /// <param name="value">\r
+ /// The value part of the CLI string\r
+ /// </param>\r
+ /// <param name="custom">\r
+ /// The custom option string\r
+ /// </param>\r
+ public void SetDecomb(Decomb value, string custom)\r
{\r
text_customDC.Text = string.Empty;\r
text_customDC.Visible = false;\r
switch (value)\r
{\r
- case "Off":\r
+ case Decomb.Off:\r
drop_decomb.SelectedIndex = 0;\r
break;\r
- case "Default":\r
+ case Decomb.Default:\r
drop_decomb.SelectedIndex = 2;\r
break;\r
default:\r
drop_decomb.SelectedIndex = 1;\r
- text_customDC.Text = value;\r
+ text_customDC.Text = custom;\r
text_customDC.Visible = true;\r
break;\r
}\r
using System.Drawing;\r
using System.Windows.Forms;\r
\r
- using HandBrake.ApplicationServices.Utilities;\r
+ using HandBrake.ApplicationServices.Model;\r
+ using HandBrake.ApplicationServices.Model.Encoding;\r
\r
/// <summary>\r
/// Load a preset into the main Window\r
/// <param name="name">\r
/// Name of the preset\r
/// </param>\r
- public static void LoadPreset(frmMain mainWindow, QueryParserUtility presetQuery, string name)\r
+ public static void LoadPreset(frmMain mainWindow, EncodeTask presetQuery, string name)\r
{\r
#region Source\r
\r
mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;\r
\r
// Now load all the new settings onto the main window\r
- if (presetQuery.Format != null)\r
- {\r
- string destination = mainWindow.text_destination.Text;\r
- destination = destination.Replace(".mp4", "." + presetQuery.Format);\r
- destination = destination.Replace(".m4v", "." + presetQuery.Format);\r
- destination = destination.Replace(".mkv", "." + presetQuery.Format);\r
- mainWindow.text_destination.Text = destination;\r
- }\r
+ string destination = mainWindow.text_destination.Text;\r
+ destination = destination.Replace(".mp4", "." + presetQuery.OutputFormat);\r
+ destination = destination.Replace(".m4v", "." + presetQuery.OutputFormat);\r
+ destination = destination.Replace(".mkv", "." + presetQuery.OutputFormat);\r
+ mainWindow.text_destination.Text = destination;\r
\r
#endregion\r
\r
#region Destination and Output Settings\r
\r
- if (presetQuery.Format != null)\r
+ if (presetQuery.OutputFormat == OutputFormat.Mp4 || presetQuery.OutputFormat == OutputFormat.M4V)\r
{\r
- if (presetQuery.Format == "mp4" || presetQuery.Format == "m4v")\r
+ if (mainWindow.drop_format.SelectedIndex == 0)\r
{\r
- if (mainWindow.drop_format.SelectedIndex == 0)\r
- mainWindow.SetExtension(".mp4");\r
- else\r
- mainWindow.drop_format.SelectedIndex = 0;\r
+ mainWindow.SetExtension(".mp4");\r
}\r
- else if (presetQuery.Format == "mkv")\r
+ else\r
{\r
- if (mainWindow.drop_format.SelectedIndex == 1)\r
- mainWindow.SetExtension(".mkv");\r
- else\r
- mainWindow.drop_format.SelectedIndex = 1;\r
+ mainWindow.drop_format.SelectedIndex = 0;\r
+ }\r
+ }\r
+ else if (presetQuery.OutputFormat == OutputFormat.Mkv)\r
+ {\r
+ if (mainWindow.drop_format.SelectedIndex == 1)\r
+ {\r
+ mainWindow.SetExtension(".mkv");\r
+ }\r
+ else\r
+ {\r
+ mainWindow.drop_format.SelectedIndex = 1;\r
}\r
}\r
\r
- mainWindow.check_iPodAtom.CheckState = presetQuery.IpodAtom ? CheckState.Checked : CheckState.Unchecked;\r
+ mainWindow.check_iPodAtom.CheckState = presetQuery.IPod5GSupport ? CheckState.Checked : CheckState.Unchecked;\r
\r
mainWindow.check_optimiseMP4.CheckState = presetQuery.OptimizeMP4\r
? CheckState.Checked\r
: CheckState.Unchecked;\r
\r
- mainWindow.check_largeFile.CheckState = presetQuery.LargeMP4 ? CheckState.Checked : CheckState.Unchecked;\r
+ mainWindow.check_largeFile.CheckState = presetQuery.LargeFile ? CheckState.Checked : CheckState.Unchecked;\r
\r
mainWindow.setContainerOpts(); // select the container options according to the selected format\r
\r
#region Picture\r
\r
mainWindow.PictureSettings.check_autoCrop.Checked = true;\r
- if (presetQuery.CropValues != null)\r
+ if (presetQuery.IsCustomCropping)\r
{\r
- int top, bottom, left, right;\r
- int.TryParse(presetQuery.CropTop, out top);\r
- int.TryParse(presetQuery.CropBottom, out bottom);\r
- int.TryParse(presetQuery.CropLeft, out left);\r
- int.TryParse(presetQuery.CropRight, out right);\r
-\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
+ mainWindow.PictureSettings.crop_top.Value = presetQuery.Cropping.Top;\r
+ mainWindow.PictureSettings.crop_bottom.Value = presetQuery.Cropping.Bottom;\r
+ mainWindow.PictureSettings.crop_left.Value = presetQuery.Cropping.Left;\r
+ mainWindow.PictureSettings.crop_right.Value = presetQuery.Cropping.Right;\r
}\r
\r
// Set the anamorphic mode 0,1,2,3\r
- mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;\r
+\r
+ switch (presetQuery.Anamorphic)\r
+ {\r
+ case Anamorphic.None:\r
+ mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 0;\r
+ break;\r
+ case Anamorphic.Strict:\r
+ mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 1;\r
+ break;\r
+ case Anamorphic.Loose:\r
+ mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 2;\r
+ break;\r
+ case Anamorphic.Custom:\r
+ mainWindow.PictureSettings.drp_anamorphic.SelectedIndex = 3;\r
+ break;\r
+ }\r
\r
// Keep Aspect Ration Anamorphic Setting.\r
- mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.KeepDisplayAsect\r
+ mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.KeepDisplayAspect\r
? CheckState.Checked\r
: CheckState.Unchecked;\r
\r
// Set the Width and height as Required.\r
if (presetQuery.Width != 0)\r
+ {\r
mainWindow.PictureSettings.text_width.Value = presetQuery.Width;\r
+ }\r
\r
if (presetQuery.Height != 0)\r
+ {\r
mainWindow.PictureSettings.text_height.Value = presetQuery.Height;\r
+ }\r
\r
// Max Width/Height override Width/Height\r
if (presetQuery.MaxWidth != 0)\r
+ {\r
mainWindow.PictureSettings.text_width.Value = presetQuery.MaxWidth;\r
+ }\r
\r
if (presetQuery.MaxHeight != 0)\r
+ {\r
mainWindow.PictureSettings.text_height.Value = presetQuery.MaxHeight;\r
+ }\r
\r
mainWindow.PictureSettings.PresetMaximumResolution = new Size(presetQuery.MaxWidth, presetQuery.MaxHeight);\r
\r
// Case where both height and max height are 0 - For built-in presets\r
if (presetQuery.MaxHeight == 0 && presetQuery.Height == 0)\r
+ {\r
mainWindow.PictureSettings.text_height.Value = 0;\r
+ }\r
\r
if (presetQuery.MaxWidth == 0 && presetQuery.Width == 0)\r
+ {\r
if (mainWindow.selectedTitle != null && mainWindow.selectedTitle.Resolution.Width != 0)\r
+ {\r
mainWindow.PictureSettings.text_width.Value = mainWindow.selectedTitle.Resolution.Width;\r
+ }\r
+ }\r
\r
// Aspect Ratio for non anamorphic sources\r
- if (presetQuery.AnamorphicMode == 0)\r
+ if (presetQuery.Anamorphic == Anamorphic.None)\r
+ {\r
mainWindow.PictureSettings.check_KeepAR.CheckState = presetQuery.Height == 0\r
? CheckState.Checked\r
: CheckState.Unchecked;\r
+ }\r
\r
// Custom Anamorphic Controls\r
- mainWindow.PictureSettings.updownDisplayWidth.Text = presetQuery.DisplayWidthValue.ToString();\r
- mainWindow.PictureSettings.updownParHeight.Text = presetQuery.PixelAspectHeight.ToString();\r
- mainWindow.PictureSettings.updownParWidth.Text = presetQuery.PixelAspectWidth.ToString();\r
- mainWindow.PictureSettings.drp_modulus.SelectedItem = presetQuery.AnamorphicModulus.ToString();\r
+ mainWindow.PictureSettings.updownDisplayWidth.Text = presetQuery.DisplayWidth.ToString();\r
+ mainWindow.PictureSettings.updownParHeight.Text = presetQuery.PixelAspectY.ToString();\r
+ mainWindow.PictureSettings.updownParWidth.Text = presetQuery.PixelAspectX.ToString();\r
+ mainWindow.PictureSettings.drp_modulus.SelectedItem = presetQuery.Modulus.ToString();\r
\r
#endregion\r
\r
#region Filters\r
\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.SetDecomb(presetQuery.Decomb, presetQuery.CustomDecomb);\r
+ mainWindow.Filters.SetDeInterlace(presetQuery.Deinterlace, presetQuery.CustomDeinterlace);\r
+ mainWindow.Filters.SetDeNoise(presetQuery.Denoise, presetQuery.CustomDenoise);\r
+ mainWindow.Filters.SetDeTelecine(presetQuery.Detelecine, presetQuery.CustomDetelecine);\r
+ mainWindow.Filters.SetDeBlock(presetQuery.Deblock);\r
mainWindow.Filters.SetGrayScale(presetQuery.Grayscale);\r
\r
#endregion\r
\r
#region Video\r
\r
- mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;\r
+ switch (presetQuery.VideoEncoder)\r
+ {\r
+ case VideoEncoder.X264:\r
+ mainWindow.drp_videoEncoder.SelectedIndex = 1;\r
+ break;\r
+ case VideoEncoder.FFMpeg:\r
+ mainWindow.drp_videoEncoder.SelectedIndex = 0;\r
+ break;\r
+ case VideoEncoder.Theora:\r
+ mainWindow.drp_videoEncoder.SelectedIndex = 2;\r
+ break;\r
+ }\r
\r
- if (presetQuery.AverageVideoBitrate != null)\r
+ if (presetQuery.VideoBitrate != null)\r
{\r
mainWindow.radio_avgBitrate.Checked = true;\r
- mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate;\r
+ mainWindow.text_bitrate.Text = presetQuery.VideoBitrate.ToString();\r
}\r
- if (presetQuery.VideoTargetSize != null)\r
+\r
+ if (presetQuery.TargetSize != null)\r
{\r
mainWindow.radio_targetFilesize.Checked = true;\r
- mainWindow.text_filesize.Text = presetQuery.VideoTargetSize;\r
+ mainWindow.text_filesize.Text = presetQuery.TargetSize.ToString();\r
}\r
\r
// Quality\r
- if (presetQuery.VideoQuality != -1)\r
+ if (presetQuery.Quality != null)\r
{\r
mainWindow.radio_cq.Checked = true;\r
- mainWindow.slider_videoQuality.Value = QualityToSliderValue(presetQuery.VideoEncoder, presetQuery.VideoQuality);\r
+ mainWindow.slider_videoQuality.Value = QualityToSliderValue(\r
+ presetQuery.VideoEncoder, presetQuery.Quality);\r
}\r
\r
mainWindow.check_2PassEncode.CheckState = presetQuery.TwoPass ? CheckState.Checked : CheckState.Unchecked;\r
\r
- mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;\r
- mainWindow.checkMaximumFramerate.Checked = presetQuery.Pfr;\r
+ if (presetQuery.Framerate != null)\r
+ {\r
+ mainWindow.drp_videoFramerate.Text = presetQuery.Framerate.ToString();\r
+ }\r
+ else\r
+ {\r
+ mainWindow.drp_videoFramerate.SelectedIndex = 0;\r
+ }\r
+\r
+ mainWindow.checkMaximumFramerate.Checked = presetQuery.FramerateMode == FramerateMode.PFR;\r
\r
mainWindow.check_turbo.CheckState = presetQuery.TurboFirstPass ? CheckState.Checked : CheckState.Unchecked;\r
\r
\r
#region Chapter Markers\r
\r
- if (presetQuery.ChapterMarkers)\r
+ if (presetQuery.IncludeChapterMarkers)\r
{\r
mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;\r
mainWindow.Check_ChapterMarkers.Enabled = true;\r
}\r
else\r
+ {\r
mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked;\r
+ }\r
\r
#endregion\r
\r
#region Audio\r
\r
- mainWindow.AudioSettings.LoadTracks(presetQuery.AudioInformation);\r
+ mainWindow.AudioSettings.LoadTracks(presetQuery.AudioTracks);\r
\r
#endregion\r
\r
#region Other\r
\r
- mainWindow.x264Panel.X264Query = presetQuery.H264Query;\r
+ mainWindow.x264Panel.X264Query = presetQuery.X264Options;\r
\r
// Set the preset name\r
mainWindow.labelPreset.Text = "Output Settings (Preset: " + name + ")";\r
/// <param name="videoEncoder">The selected video encoder</param>\r
/// <param name="value">The Quality value</param>\r
/// <returns>The position on the video quality slider</returns>\r
- private static int QualityToSliderValue(string videoEncoder, float value)\r
+ private static int QualityToSliderValue(VideoEncoder videoEncoder, double? value)\r
{\r
+ if (!value.HasValue)\r
+ {\r
+ // Default to a sensible level.\r
+ return 20;\r
+ }\r
+\r
int sliderValue = 0;\r
switch (videoEncoder)\r
{\r
- case "MPEG-4 (FFmpeg)":\r
+ case VideoEncoder.FFMpeg:\r
sliderValue = 32 - (int)value;\r
break;\r
- case "H.264 (x264)":\r
+ case VideoEncoder.X264:\r
double cqStep = Properties.Settings.Default.x264cqstep;\r
sliderValue = (int)((51.0 / cqStep) - (value / cqStep));\r
break;\r
- case "VP3 (Theora)":\r
+ case VideoEncoder.Theora:\r
sliderValue = (int)value;\r
break;\r
}\r
foreach (QueueTask queueItem in theQueue)\r
{\r
string qItem = queueItem.Query;\r
- QueryParserUtility parsed = QueryParserUtility.Parse(qItem);\r
+ EncodeTask parsed = QueryParserUtility.Parse(qItem);\r
\r
// Get the DVD Title\r
string title = parsed.Title == 0 ? "Auto" : parsed.Title.ToString();\r
\r
// Get the DVD Chapters\r
string chapters;\r
- if (parsed.ChapterStart == 0)\r
+ if (parsed.StartPoint == 0)\r
chapters = "Auto";\r
else\r
{\r
- chapters = parsed.ChapterStart.ToString();\r
- if (parsed.ChapterFinish != 0)\r
- chapters = chapters + " - " + parsed.ChapterFinish;\r
+ chapters = parsed.StartPoint.ToString();\r
+ if (parsed.EndPoint != 0)\r
+ chapters = chapters + " - " + parsed.EndPoint;\r
}\r
\r
ListViewItem item = new ListViewItem { Tag = queueItem, Text = title };\r
item.SubItems.Add(chapters); // Chapters\r
item.SubItems.Add(queueItem.Source); // Source\r
item.SubItems.Add(queueItem.Destination); // Destination\r
- item.SubItems.Add(parsed.VideoEncoder); // Video\r
+\r
+ switch (parsed.VideoEncoder)\r
+ {\r
+ case VideoEncoder.FFMpeg:\r
+ item.SubItems.Add("MPEG-4 (FFmpeg)");\r
+ break;\r
+ default:\r
+ case VideoEncoder.X264:\r
+ item.SubItems.Add("H.264 (x264)");\r
+ break;\r
+ case VideoEncoder.Theora:\r
+ item.SubItems.Add("VP3 (Theroa)");\r
+ break;\r
+ }\r
+\r
+ // Video\r
\r
// Display The Audio Track Information\r
string audio = string.Empty;\r
- foreach (AudioTrack track in parsed.AudioInformation)\r
+ foreach (AudioTrack track in parsed.AudioTracks)\r
{\r
if (audio != string.Empty)\r
audio += ", " + track.Encoder;\r
BeginInvoke(new UpdateHandler(SetCurrentEncodeInformation));\r
}\r
\r
- QueryParserUtility parsed = QueryParserUtility.Parse(queue.QueueManager.LastProcessedJob.Query);\r
+ EncodeTask parsed = QueryParserUtility.Parse(queue.QueueManager.LastProcessedJob.Query);\r
\r
// Get title and chapters\r
string title = parsed.Title == 0 ? "Auto" : parsed.Title.ToString();\r
string chapterlbl;\r
- if (Equals(parsed.ChapterStart, 0))\r
+ if (Equals(parsed.StartPoint, 0))\r
chapterlbl = "Auto";\r
else\r
{\r
- string chapters = parsed.ChapterStart.ToString();\r
- if (parsed.ChapterFinish != 0)\r
- chapters = chapters + " - " + parsed.ChapterFinish;\r
+ string chapters = parsed.StartPoint.ToString();\r
+ if (parsed.EndPoint != 0)\r
+ chapters = chapters + " - " + parsed.EndPoint;\r
chapterlbl = chapters;\r
}\r
\r
// Get audio information\r
string audio = string.Empty;\r
- foreach (AudioTrack track in parsed.AudioInformation)\r
+ foreach (AudioTrack track in parsed.AudioTracks)\r
{\r
if (audio != string.Empty) \r
audio += ", " + track.Encoder;\r
lbl_source.Text = queue.QueueManager.LastProcessedJob.Source + "(Title: " + title + " Chapters: " + chapterlbl + ")";\r
lbl_dest.Text = queue.QueueManager.LastProcessedJob.Destination;\r
lbl_encodeOptions.Text = "Video: " + parsed.VideoEncoder + " Audio: " + audio + Environment.NewLine +\r
- "x264 Options: " + parsed.H264Query;\r
+ "x264 Options: " + parsed.X264Options;\r
}\r
catch (Exception)\r
{\r