diff options
Diffstat (limited to 'win/C#/frmMain')
-rw-r--r-- | win/C#/frmMain/PresetLoader.cs | 351 | ||||
-rw-r--r-- | win/C#/frmMain/QueryGenerator.cs | 590 | ||||
-rw-r--r-- | win/C#/frmMain/x264Panel.cs | 808 |
3 files changed, 1749 insertions, 0 deletions
diff --git a/win/C#/frmMain/PresetLoader.cs b/win/C#/frmMain/PresetLoader.cs new file mode 100644 index 000000000..c42f8202e --- /dev/null +++ b/win/C#/frmMain/PresetLoader.cs @@ -0,0 +1,351 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace Handbrake
+{
+ class PresetLoader
+ {
+ /// <summary>
+ /// This function takes in a Query which has been parsed by QueryParser and
+ /// set's all the GUI widgets correctly.
+ /// </summary>
+ /// <param name="mainWindow"></param>
+ /// <param name="presetQuery">The Parsed CLI Query</param>
+ /// <param name="name">Name of the preset</param>
+ public void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name)
+ {
+ // ---------------------------
+ // Setup the GUI
+ // ---------------------------
+
+ // Source tab
+ #region source
+ // Reset some vaules to stock first to prevent errors.
+ mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
+
+ // Now load all the new settings onto the main window
+ mainWindow.drp_dvdtitle.Text = "Automatic";
+ mainWindow.drop_chapterStart.Text = "Auto";
+ mainWindow.drop_chapterFinish.Text = "Auto";
+
+ if (presetQuery.Format != null)
+ {
+ string destination = mainWindow.text_destination.Text;
+ destination = destination.Replace(".mp4", "." + presetQuery.Format);
+ destination = destination.Replace(".m4v", "." + presetQuery.Format);
+ destination = destination.Replace(".avi", "." + presetQuery.Format);
+ destination = destination.Replace(".mkv", "." + presetQuery.Format);
+ destination = destination.Replace(".ogm", "." + presetQuery.Format);
+ mainWindow.text_destination.Text = destination;
+ }
+
+ #endregion
+
+ // Destination tab
+ #region destination
+
+ mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
+
+ if (presetQuery.Format != null)
+ {
+ if (presetQuery.Format == "mp4")
+ mainWindow.drop_format.SelectedIndex = 0;
+ else if (presetQuery.Format == "m4v")
+ mainWindow.drop_format.SelectedIndex = 1;
+ else if (presetQuery.Format == "mkv")
+ mainWindow.drop_format.SelectedIndex = 2;
+ else if (presetQuery.Format == "avi")
+ mainWindow.drop_format.SelectedIndex = 3;
+ else if (presetQuery.Format == "ogm")
+ mainWindow.drop_format.SelectedIndex = 4;
+ }
+
+ if (presetQuery.IpodAtom == true)
+ mainWindow.check_iPodAtom.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
+
+ if (presetQuery.OptimizeMP4 == true)
+ mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;
+
+ #endregion
+
+ // Picture Settings Tab
+ #region Picture
+ mainWindow.check_autoCrop.Checked = true;
+ mainWindow.drp_deInterlace_option.Text = presetQuery.DeInterlace;
+ mainWindow.drp_deNoise.Text = presetQuery.DeNoise;
+
+ if (presetQuery.Decomb == true)
+ mainWindow.check_decomb.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_decomb.CheckState = CheckState.Unchecked;
+
+ if (presetQuery.DeTelecine == true)
+ mainWindow.check_detelecine.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_detelecine.CheckState = CheckState.Unchecked;
+
+ if (presetQuery.DeBlock != 0)
+ {
+ mainWindow.slider_deblock.Value = presetQuery.DeBlock;
+ mainWindow.lbl_deblockVal.Text = presetQuery.DeBlock.ToString();
+ }
+ else
+ {
+ mainWindow.slider_deblock.Value = 4;
+ mainWindow.lbl_deblockVal.Text = "Off";
+ }
+
+ if (presetQuery.Anamorphic == true)
+ mainWindow.drp_anamorphic.SelectedIndex = 1;
+ else
+ mainWindow.drp_anamorphic.SelectedIndex = 0;
+
+ if (presetQuery.LooseAnamorphic == true)
+ mainWindow.drp_anamorphic.SelectedIndex = 2;
+ else
+ {
+ if (presetQuery.Anamorphic != true)
+ mainWindow.drp_anamorphic.SelectedIndex = 0;
+ }
+
+ if (presetQuery.Width != 0)
+ mainWindow.text_width.Text = presetQuery.Width.ToString();
+ else
+ {
+ mainWindow.text_width.Text = "";
+ }
+
+ if (presetQuery.Height != 0)
+ mainWindow.text_height.Text = presetQuery.Height.ToString();
+ else
+ {
+ mainWindow.text_height.Text = "";
+ }
+
+ #endregion
+
+ // Video Settings Tab
+ #region video
+ mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate;
+ mainWindow.text_filesize.Text = presetQuery.VideoTargetSize;
+ mainWindow.slider_videoQuality.Value = presetQuery.VideoQuality;
+ if (mainWindow.slider_videoQuality.Value != 0)
+ {
+ int ql = presetQuery.VideoQuality;
+ mainWindow.SliderValue.Text = ql.ToString() + "%";
+ }
+
+ if (presetQuery.TwoPass == true)
+ mainWindow.check_2PassEncode.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;
+
+ if (presetQuery.Grayscale == true)
+ mainWindow.check_grayscale.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_grayscale.CheckState = CheckState.Unchecked;
+
+ mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;
+
+ if (presetQuery.TurboFirstPass == true)
+ mainWindow.check_turbo.CheckState = CheckState.Checked;
+ else
+ mainWindow.check_turbo.CheckState = CheckState.Unchecked;
+
+ if (presetQuery.LargeMP4 == true)
+ mainWindow.check_largeFile.CheckState = CheckState.Checked;
+ else
+ {
+ mainWindow.check_largeFile.CheckState = CheckState.Unchecked;
+ mainWindow.check_largeFile.BackColor = Color.Transparent;
+ }
+ #endregion
+
+ // Chapter Markers Tab
+ #region Chapter Markers
+
+ if (presetQuery.ChapterMarkers == true)
+ mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;
+ else
+ mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked;
+
+ #endregion
+
+ // Audio Settings Tab
+ #region Audio
+
+ // Handle Track 1
+ mainWindow.drp_track1Audio.Text = "Automatic";
+
+ // Handle Track 2
+ if (presetQuery.AudioEncoder2 != null) // Fix for loading in built in presets. Where 2 encoders but no tracks in the preset.
+ {
+ mainWindow.drp_track2Audio.Enabled = true;
+ mainWindow.drp_audsr_2.Enabled = true;
+ mainWindow.drp_audmix_2.Enabled = true;
+ mainWindow.drp_audenc_2.Enabled = true;
+ mainWindow.drp_audbit_2.Enabled = true;
+ mainWindow.drp_audsr_2.Text = "48";
+ mainWindow.drp_track2Audio.Text = "Automatic";
+ }
+ else if (presetQuery.AudioTrack2 == "None")
+ {
+ mainWindow.drp_track2Audio.Text = "None";
+ mainWindow.drp_track2Audio.SelectedIndex = 0;
+ mainWindow.drp_audsr_2.Enabled = false;
+ mainWindow.drp_audmix_2.Enabled = false;
+ mainWindow.drp_audenc_2.Enabled = false;
+ mainWindow.drp_audbit_2.Enabled = false;
+ }
+ else
+ {
+ mainWindow.drp_track2Audio.Text = presetQuery.AudioTrack2;
+ mainWindow.drp_audsr_2.Enabled = true;
+ mainWindow.drp_audmix_2.Enabled = true;
+ mainWindow.drp_audenc_2.Enabled = true;
+ mainWindow.drp_audbit_2.Enabled = true;
+ }
+
+ // Handle Track 3
+ if (presetQuery.AudioTrack3 == "None")
+ {
+ mainWindow.drp_track3Audio.SelectedIndex = 0;
+ mainWindow.drp_audsr_3.Enabled = false;
+ mainWindow.drp_audmix_3.Enabled = false;
+ mainWindow.drp_audenc_3.Enabled = false;
+ mainWindow.drp_audbit_3.Enabled = false;
+ mainWindow.trackBar3.Enabled = false;
+
+ mainWindow.drp_track3Audio.Text = "None";
+ mainWindow.drp_audsr_3.Text = "";
+ mainWindow.drp_audmix_3.Text = "Automatic";
+ mainWindow.drp_audenc_3.Text = "";
+ mainWindow.drp_audbit_3.Text = "";
+ mainWindow.trackBar3.Value = 0;
+
+ }
+ else
+ {
+ mainWindow.drp_track3Audio.Text = presetQuery.AudioTrack3;
+ mainWindow.drp_audsr_3.Enabled = true;
+ mainWindow.drp_audmix_3.Enabled = true;
+ mainWindow.drp_audenc_3.Enabled = true;
+ mainWindow.drp_audbit_3.Enabled = true;
+ mainWindow.trackBar3.Enabled = true;
+ }
+
+ // Handle Track 4
+ if (presetQuery.AudioTrack4 == "None")
+ {
+ mainWindow.drp_track4Audio.SelectedIndex = 0;
+ mainWindow.drp_audsr_4.Enabled = false;
+ mainWindow.drp_audmix_4.Enabled = false;
+ mainWindow.drp_audenc_4.Enabled = false;
+ mainWindow.drp_audbit_4.Enabled = false;
+ mainWindow.trackBar4.Enabled = false;
+
+ mainWindow.drp_track4Audio.Text = "None";
+ mainWindow.drp_audsr_4.Text = "";
+ mainWindow.drp_audmix_4.Text = "Automatic";
+ mainWindow.drp_audenc_4.Text = "";
+ mainWindow.drp_audbit_4.Text = "";
+ mainWindow.trackBar4.Value = 0;
+ }
+ else
+ {
+ mainWindow.drp_track4Audio.Text = presetQuery.AudioTrack4;
+ mainWindow.drp_audsr_4.Enabled = true;
+ mainWindow.drp_audmix_4.Enabled = true;
+ mainWindow.drp_audenc_4.Enabled = true;
+ mainWindow.drp_audbit_4.Enabled = true;
+ mainWindow.trackBar4.Enabled = true;
+ }
+
+ // Now lets start setting stuff
+ if (presetQuery.AudioEncoder1 != null)
+ mainWindow.drp_audenc_1.Text = presetQuery.AudioEncoder1;
+ mainWindow.drp_audenc_2.Text = presetQuery.AudioEncoder2;
+ mainWindow.drp_audenc_3.Text = presetQuery.AudioEncoder3;
+ mainWindow.drp_audenc_4.Text = presetQuery.AudioEncoder4;
+
+ mainWindow.drp_audmix_1.Text = presetQuery.AudioTrackMix1;
+ mainWindow.drp_audmix_2.Text = presetQuery.AudioTrackMix2;
+ mainWindow.drp_audmix_3.Text = presetQuery.AudioTrackMix3;
+ mainWindow.drp_audmix_4.Text = presetQuery.AudioTrackMix4;
+
+ if (presetQuery.AudioBitrate1 != null)
+ mainWindow.drp_audbit_1.Text = presetQuery.AudioBitrate1;
+ mainWindow.drp_audbit_2.Text = presetQuery.AudioBitrate2;
+ mainWindow.drp_audbit_3.Text = presetQuery.AudioBitrate4;
+ mainWindow.drp_audbit_3.Text = presetQuery.AudioBitrate4;
+
+ if (presetQuery.AudioSamplerate1 != null)
+ mainWindow.drp_audsr_1.Text = presetQuery.AudioSamplerate1;
+ mainWindow.drp_audsr_2.Text = presetQuery.AudioSamplerate2;
+ mainWindow.drp_audsr_3.Text = presetQuery.AudioSamplerate3;
+ mainWindow.drp_audsr_4.Text = presetQuery.AudioSamplerate4;
+
+ // Dynamic Range Compression (Should be a float but we use double for ease)
+ double value = 0;
+ double actualValue = 0;
+
+ value = presetQuery.DRC1;
+ if (value > 0)
+ value = value - 10;
+ mainWindow.trackBar1.Value = int.Parse(value.ToString());
+ actualValue = presetQuery.DRC1 / 10;
+ mainWindow.lbl_drc1.Text = actualValue.ToString();
+
+ value = presetQuery.DRC2;
+ if (value > 0)
+ value = value - 10;
+ mainWindow.trackBar2.Value = int.Parse(value.ToString());
+ actualValue = presetQuery.DRC2 / 10;
+ mainWindow.lbl_drc2.Text = actualValue.ToString();
+
+ value = presetQuery.DRC3;
+ if (value > 0)
+ value = value - 10;
+ mainWindow.trackBar3.Value = int.Parse(value.ToString());
+ actualValue = presetQuery.DRC3 / 10;
+ mainWindow.lbl_drc3.Text = actualValue.ToString();
+
+ value = presetQuery.DRC4;
+ if (value > 0)
+ value = value - 10;
+ mainWindow.trackBar4.Value = int.Parse(value.ToString());
+ actualValue = presetQuery.DRC4 / 10;
+ mainWindow.lbl_drc4.Text = actualValue.ToString();
+
+
+ // Subtitle Stuff
+ mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
+
+ if (presetQuery.ForcedSubtitles == true)
+ {
+ mainWindow.check_forced.CheckState = CheckState.Checked;
+ mainWindow.check_forced.Enabled = true;
+ }
+ else
+ mainWindow.check_forced.CheckState = CheckState.Unchecked;
+
+
+ #endregion
+
+ // H264 Tab & Preset Name
+ #region other
+ mainWindow.rtf_x264Query.Text = presetQuery.H264Query;
+
+ // Set the preset name
+ mainWindow.groupBox_output.Text = "Output Settings (Preset: " + name + ")";
+ #endregion
+ }
+ }
+}
diff --git a/win/C#/frmMain/QueryGenerator.cs b/win/C#/frmMain/QueryGenerator.cs new file mode 100644 index 000000000..b66e3f041 --- /dev/null +++ b/win/C#/frmMain/QueryGenerator.cs @@ -0,0 +1,590 @@ +using System;
+using System.Collections;
+using System.Text;
+using System.Windows.Forms;
+using System.Globalization;
+using System.IO;
+
+namespace Handbrake
+{
+ class QueryGenerator
+ {
+ /// <summary>
+ /// Generates a CLI query based on the GUI widgets.
+ /// </summary>
+ /// <param name="mainWindow"></param>
+ /// <returns>The CLI String</returns>
+ public string GenerateTheQuery(frmMain mainWindow)
+ {
+ // Source tab
+ string query = "";
+
+ if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue"))
+ query = " -i " + '"' + mainWindow.text_source.Text + '"';
+
+ if (mainWindow.drp_dvdtitle.Text != "Automatic")
+ {
+ string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');
+ query += " -t " + titleInfo[0];
+ }
+
+ if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "Auto")
+ query += " -c " + mainWindow.drop_chapterStart.Text;
+ else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
+ query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text;
+ else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto")
+ query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text;
+
+ // Destination tab
+ if (mainWindow.text_destination.Text != "")
+ query += " -o " + '"' + mainWindow.text_destination.Text + '"';
+
+ query += generateTabbedComponentsQuery(mainWindow);
+ return query;
+ }
+
+ /// <summary>
+ /// Generates a CLI query for the preview function.
+ /// This basically forces a shortened version of the encdode.
+ /// </summary>
+ /// <param name="mainWindow"></param>
+ /// <returns>Returns a CLI query String.</returns>
+ public string GeneratePreviewQuery(frmMain mainWindow)
+ {
+ // Source tab
+ string query = "";
+
+ if ((mainWindow.text_source.Text != "") && (mainWindow.text_source.Text.Trim() != "Click 'Source' to continue"))
+ query = " -i " + '"' + mainWindow.text_source.Text + '"';
+
+ if (mainWindow.drp_dvdtitle.Text != "Automatic")
+ {
+ string[] titleInfo = mainWindow.drp_dvdtitle.Text.Split(' ');
+ query += " -t " + titleInfo[0];
+ }
+
+ query += " -c 2";
+
+ // Destination tab
+ if (mainWindow.text_destination.Text != "")
+ query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm") + '"';
+
+ query += generateTabbedComponentsQuery(mainWindow);
+ return query;
+ }
+
+ /// <summary>
+ /// Generates part of the CLI query, for the tabbed components only.
+ /// </summary>
+ /// <param name="mainWindow"></param>
+ /// <param name="source"></param>
+ /// <returns></returns>
+ public string generateTabbedComponentsQuery(frmMain mainWindow)
+ {
+ string query = "";
+
+ // The Output Settings box above the tabbed section.
+ #region Output Settings Box
+ query += " -f " + mainWindow.drop_format.Text.ToLower().Replace(" file", "");
+
+ // These are output settings features
+ if (mainWindow.check_largeFile.Checked)
+ query += " -4 ";
+
+ if (mainWindow.check_iPodAtom.Checked)
+ query += " -I ";
+
+ if (mainWindow.check_optimiseMP4.Checked)
+ query += " -O ";
+ #endregion
+
+ // Picture Settings Tab
+ #region Picture Settings Tab
+
+ if (mainWindow.text_width.Text != "")
+ query += " -w " + mainWindow.text_width.Text;
+
+ if (mainWindow.text_height.Text != "")
+ query += " -l " + mainWindow.text_height.Text;
+
+ string cropTop = mainWindow.text_top.Text;
+ string cropBottom = mainWindow.text_bottom.Text;
+ string cropLeft = mainWindow.text_left.Text;
+ string cropRight = mainWindow.text_right.Text;
+
+ if (mainWindow.check_customCrop.Checked)
+ {
+ if (mainWindow.text_top.Text == string.Empty)
+ cropTop = "0";
+ if (mainWindow.text_bottom.Text == string.Empty)
+ cropBottom = "0";
+ if (mainWindow.text_left.Text == string.Empty)
+ cropLeft = "0";
+ if (mainWindow.text_right.Text == string.Empty)
+ cropRight = "0";
+
+ query += " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
+ }
+
+ switch (mainWindow.drp_deInterlace_option.Text)
+ {
+ case "None":
+ query += "";
+ break;
+ case "Fast":
+ query += " --deinterlace=\"fast\"";
+ break;
+ case "Slow":
+ query += " --deinterlace=\"slow\"";
+ break;
+ case "Slower":
+ query += " --deinterlace=\"slower\"";
+ break;
+ case "Slowest":
+ query += " --deinterlace=\"slowest\"";
+ break;
+ default:
+ query += "";
+ break;
+ }
+
+ if (mainWindow.check_decomb.Checked)
+ {
+ string decombValue = Properties.Settings.Default.decomb;
+ if (decombValue != "" && decombValue != Properties.Settings.Default.default_decomb)
+ query += " --decomb=\"" + decombValue + "\"";
+ else
+ query += " --decomb ";
+ }
+
+ if (mainWindow.drp_anamorphic.SelectedIndex == 1)
+ query += " -p ";
+ else if (mainWindow.drp_anamorphic.SelectedIndex == 2)
+ query += " -P ";
+
+ if (mainWindow.slider_deblock.Value != 4)
+ query += " --deblock=" + mainWindow.slider_deblock.Value;
+
+ if (mainWindow.check_detelecine.Checked)
+ query += " --detelecine";
+ #endregion
+
+ // Video Settings Tab
+ #region Video Settings Tab
+
+ switch (mainWindow.drp_videoEncoder.Text)
+ {
+ case "MPEG-4 (FFmpeg)":
+ query += " -e ffmpeg";
+ break;
+ case "MPEG-4 (XviD)":
+ query += " -e xvid";
+ break;
+ case "H.264 (x264)":
+ query += " -e x264";
+ break;
+ case "VP3 (Theora)":
+ query += " -e theora";
+ break;
+ default:
+ query += " -e x264";
+ break;
+ }
+
+ if (mainWindow.check_grayscale.Checked)
+ query += " -g ";
+
+ // Video Settings
+ if (mainWindow.text_bitrate.Text != "")
+ query += " -b " + mainWindow.text_bitrate.Text;
+
+ if (mainWindow.text_filesize.Text != "")
+ query += " -S " + mainWindow.text_filesize.Text;
+
+ // Video Quality Setting
+ double videoQuality = mainWindow.slider_videoQuality.Value;
+ if (videoQuality != 0)
+ {
+ videoQuality = videoQuality / 100;
+ query += " -q " + videoQuality.ToString(new CultureInfo("en-US"));
+ }
+
+ if (mainWindow.check_2PassEncode.Checked)
+ query += " -2 ";
+
+ if (mainWindow.check_turbo.Checked)
+ query += " -T ";
+
+ if (mainWindow.drp_videoFramerate.Text != "Same as source")
+ query += " -r " + mainWindow.drp_videoFramerate.Text;
+
+ switch (mainWindow.drp_deNoise.Text)
+ {
+ case "None":
+ query += "";
+ break;
+ case "Weak":
+ query += " --denoise=\"weak\"";
+ break;
+ case "Medium":
+ query += " --denoise=\"medium\"";
+ break;
+ case "Strong":
+ query += " --denoise=\"strong\"";
+ break;
+ default:
+ query += "";
+ break;
+ }
+ #endregion
+
+ // Audio Settings Tab
+ #region Audio Settings Tab
+ // Track 1
+ string track1 = mainWindow.drp_track1Audio.Text;
+ string aencoder1 = mainWindow.drp_audenc_1.Text;
+ string audioBitrate1 = mainWindow.drp_audbit_1.Text;
+ string audioSampleRate1 = mainWindow.drp_audsr_1.Text;
+ string Mixdown1 = mainWindow.drp_audmix_1.Text;
+ string drc1 = mainWindow.trackBar1.Value.ToString();
+
+ // Track 2
+ string track2 = mainWindow.drp_track2Audio.Text;
+ string aencoder2 = mainWindow.drp_audenc_2.Text;
+ string audioBitrate2 = mainWindow.drp_audbit_2.Text;
+ string audioSampleRate2 = mainWindow.drp_audsr_2.Text;
+ string Mixdown2 = mainWindow.drp_audmix_2.Text;
+ string drc2 = mainWindow.trackBar2.Value.ToString();
+
+ // Track 3
+ string track3 = mainWindow.drp_track3Audio.Text;
+ string aencoder3 = mainWindow.drp_audenc_3.Text;
+ string audioBitrate3 = mainWindow.drp_audbit_3.Text;
+ string audioSampleRate3 = mainWindow.drp_audsr_3.Text;
+ string Mixdown3 = mainWindow.drp_audmix_3.Text;
+ string drc3 = mainWindow.trackBar3.Value.ToString();
+
+ // Track 4
+ string track4 = mainWindow.drp_track4Audio.Text;
+ string aencoder4 = mainWindow.drp_audenc_4.Text;
+ string audioBitrate4 = mainWindow.drp_audbit_4.Text;
+ string audioSampleRate4 = mainWindow.drp_audsr_4.Text;
+ string Mixdown4 = mainWindow.drp_audmix_4.Text;
+ string drc4 = mainWindow.trackBar4.Value.ToString();
+
+ //
+ // Audio Track Selections
+ //
+ if (track1 == "Automatic")
+ query += " -a 1";
+ else if (track1 != "None")
+ {
+ string[] tempSub = track1.Split(' ');
+ query += " -a " + tempSub[0];
+ }
+
+ if (track2 == "Automatic")
+ query += ",1";
+ else if (track2 != "None")
+ {
+ string[] tempSub;
+ tempSub = track2.Split(' ');
+
+ if (track1 == "None")
+ query += " -a none," + tempSub[0];
+ else
+ query += "," + tempSub[0];
+ }
+
+ if (track3 != "None")
+ {
+ string[] tempSub;
+ tempSub = track3.Split(' ');
+ query += "," + tempSub[0];
+ }
+
+ if (track4 != "None")
+ {
+ string[] tempSub;
+ tempSub = track4.Split(' ');
+ query += "," + tempSub[0];
+ }
+
+ //
+ // Audio Encoder
+ //
+ if (aencoder1 != "")
+ query += " -E " + getAudioEncoder(aencoder1);
+
+ if (aencoder2 != "")
+ {
+ if (aencoder1 == string.Empty)
+ query += " -E faac," + getAudioEncoder(aencoder2);
+ else
+ query += "," + getAudioEncoder(aencoder2);
+ }
+
+ if (aencoder3 != "")
+ query += "," + getAudioEncoder(aencoder3);
+
+ if (aencoder4 != "")
+ query += "," + getAudioEncoder(aencoder4);
+
+ //
+ // Audio Bitrate Selections
+ //
+ if (audioBitrate1 != "")
+ query += " -B " + audioBitrate1;
+
+ if (audioBitrate2 != "")
+ {
+ if (audioBitrate1 == string.Empty)
+ query += " -B 160," + audioBitrate2;
+ else
+ query += "," + audioBitrate2;
+ }
+
+ if (audioBitrate3 != "")
+ query += "," + audioBitrate3;
+
+ if (audioBitrate4 != "")
+ query += "," + audioBitrate4;
+
+
+ //Audio Sample Rate - audioSampleRate
+ if (audioSampleRate1 != "")
+ query += " -R " + audioSampleRate1.Replace("Auto", "0");
+
+ if (audioSampleRate2 != "")
+ {
+ if (audioSampleRate1 == string.Empty)
+ query += " -R 0," + audioSampleRate2.Replace("Auto", "0");
+ else
+ query += "," + audioSampleRate2.Replace("Auto", "0");
+ }
+ else
+ {
+ // All this is a hack, because when AppleTV is selected, there is no sample rate selected. so just add a 48
+ // It should probably be setup later so the GUI widget has the value 48 in it.
+
+ if ((track2 != "") && (track2 != "None"))
+ {
+ if (audioSampleRate1 == string.Empty)
+ query += " -R 0,0";
+ else
+ query += ",0";
+ }
+ }
+
+ if (audioSampleRate3 != "")
+ query += "," + audioSampleRate3.Replace("Auto", "0");
+
+ if (audioSampleRate4 != "")
+ query += "," + audioSampleRate4.Replace("Auto", "0");
+
+ //
+ // Audio Mixdown Selections
+ //
+
+ if (Mixdown1 != "")
+ query += " -6 " + getMixDown(Mixdown1);
+ else
+ query += " -6 dpl2";
+
+ if (Mixdown2 != "" && track2 != "None")
+ query += "," + getMixDown(Mixdown2);
+
+ if (Mixdown3 != "" && track3 != "None" && track2 != "None")
+ query += "," + getMixDown(Mixdown3);
+
+ if (Mixdown4 != "" && track4 != "None" && track3 != "None")
+ query += "," + getMixDown(Mixdown4);
+
+
+ //
+ // DRC
+ //
+ double value = 0;
+
+ value = mainWindow.trackBar1.Value / 10.0;
+ value++;
+
+ if (value > 1.0)
+ query += " -D " + value;
+ else
+ query += " -D 1";
+
+ value = mainWindow.trackBar2.Value / 10.0;
+ value++;
+ if (track2 != "None" && drc2 != "0")
+ query += "," + value;
+ else if (track2 != "None" && drc2 == "0")
+ query += ",1";
+
+ value = mainWindow.trackBar3.Value / 10.0;
+ value++;
+ if (track3 != "None" && drc3 != "0")
+ query += "," + value;
+ else if (track3 != "None" && drc3 == "0")
+ query += ",1";
+
+ value = mainWindow.trackBar4.Value / 10.0;
+ value++;
+ if (track4 != "None" && drc4 != "0")
+ query += "," + value;
+ else if (track4 != "None" && drc4 == "0")
+ query += ",1";
+
+ // Subtitles
+ string subtitles = mainWindow.drp_subtitle.Text;
+ if (subtitles == "Autoselect")
+ query += " -U ";
+ else if (subtitles != "" && subtitles != "None")
+ {
+ string[] tempSub;
+ tempSub = subtitles.Split(' ');
+ query += " -s " + tempSub[0];
+ }
+
+ if (mainWindow.check_forced.Checked)
+ query += " -F ";
+
+ #endregion
+
+ // Chapter Markers Tab
+ #region Chapter Markers
+
+ // Attach Source name and dvd title to the start of the chapters.csv filename.
+ // This is for the queue. It allows different chapter name files for each title.
+ string source_name = mainWindow.text_source.Text;
+ string[] sourceName = source_name.Split('\\');
+ source_name = sourceName[sourceName.Length - 1];
+ source_name = source_name.Replace("\"", "");
+
+ string source_title = mainWindow.drp_dvdtitle.Text;
+ string[] titlesplit = source_title.Split(' ');
+ source_title = titlesplit[0];
+
+ if (mainWindow.Check_ChapterMarkers.Checked)
+ {
+ if ((source_name.Trim() != "Click 'Source' to continue") && (source_name.Trim() != ""))
+ {
+ string path = "";
+ if (source_title != "Automatic")
+ path = Path.Combine(Path.GetTempPath(), source_name + "-" + source_title + "-chapters.csv");
+ else
+ path = Path.Combine(Path.GetTempPath(), source_name + "-chapters.csv");
+
+ if (chapterCSVSave(mainWindow, path) == false)
+ query += " -m ";
+ else
+ query += " --markers=" + "\"" + path + "\"";
+ }
+ else
+ query += " -m";
+ }
+ #endregion
+
+ // H264 Tab
+ #region H264 Tab
+ if (mainWindow.rtf_x264Query.Text != "")
+ query += " -x " + mainWindow.rtf_x264Query.Text;
+ #endregion
+
+ // Other
+ #region Processors / Other
+ string processors = Properties.Settings.Default.Processors;
+ if (processors != "Automatic")
+ query += " -C " + processors + " ";
+
+ query += " -v ";
+ #endregion
+
+ return query;
+ }
+
+ /// <summary>
+ /// Get the CLI equive of the audio mixdown from the widget name.
+ /// </summary>
+ /// <param name="selectedAudio"></param>
+ /// <returns></returns>
+ ///
+ private string getMixDown(string selectedAudio)
+ {
+ switch (selectedAudio)
+ {
+ case "Automatic":
+ return "dpl2";
+ case "Mono":
+ return "mono";
+ case "Stereo":
+ return "stereo";
+ case "Dolby Surround":
+ return "dpl1";
+ case "Dolby Pro Logic II":
+ return "dpl2";
+ case "6 Channel Discrete":
+ return "6ch";
+ default:
+ return "dpl2";
+ }
+ }
+
+ /// <summary>
+ /// Get the CLI equiv of the audio encoder from the widget name.
+ /// </summary>
+ /// <param name="selectedEncoder"></param>
+ /// <returns></returns>
+ ///
+ private string getAudioEncoder(string selectedEncoder)
+ {
+ switch (selectedEncoder)
+ {
+ case "AAC":
+ return "faac";
+ case "MP3":
+ return "lame";
+ case "Vorbis":
+ return "vorbis";
+ case "AC3":
+ return "ac3";
+ default:
+ return "";
+ }
+ }
+
+ /// <summary>
+ /// This function saves the data in the chapters tab, dataGridView into a CSV file called chapters.csv
+ /// in a directory specified by file_path_name
+ /// </summary>
+ /// <param name="mainWindow"></param>
+ /// <param name="file_path_name"></param>
+ /// <returns></returns>
+ private Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)
+ {
+ try
+ {
+ StringBuilder csv = new StringBuilder();
+
+ foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)
+ {
+ csv.Append(row.Cells[0].Value.ToString());
+ csv.Append(",");
+ csv.Append(row.Cells[1].Value.ToString());
+ csv.Append(Environment.NewLine);
+ }
+ StreamWriter file = new StreamWriter(file_path_name);
+ file.Write(csv.ToString());
+ file.Close();
+ file.Dispose();
+ return true;
+
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return false;
+ }
+ }
+ }
+}
diff --git a/win/C#/frmMain/x264Panel.cs b/win/C#/frmMain/x264Panel.cs new file mode 100644 index 000000000..13580665c --- /dev/null +++ b/win/C#/frmMain/x264Panel.cs @@ -0,0 +1,808 @@ +using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Handbrake
+{
+ class x264Panel
+ {
+ /// <summary>
+ /// Reset all components to defaults and clears the x264 rtf box
+ /// </summary>
+ public void reset2Defaults(frmMain mainWindow)
+ {
+ mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked;
+ mainWindow.check_Cabac.CheckState = CheckState.Checked;
+ mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked;
+ mainWindow.check_noDCTDecimate.CheckState = CheckState.Unchecked;
+ mainWindow.check_noFastPSkip.CheckState = CheckState.Unchecked;
+ mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
+ mainWindow.check_weightedBFrames.CheckState = CheckState.Unchecked;
+ mainWindow.drop_analysis.SelectedIndex = 0;
+ mainWindow.drop_bFrames.SelectedIndex = 0;
+ mainWindow.drop_deblockAlpha.SelectedIndex = 0;
+ mainWindow.drop_deblockBeta.SelectedIndex = 0;
+ mainWindow.drop_directPrediction.SelectedIndex = 0;
+ mainWindow.drop_MotionEstimationMethod.SelectedIndex = 0;
+ mainWindow.drop_MotionEstimationRange.SelectedIndex = 0;
+ mainWindow.drop_refFrames.SelectedIndex = 0;
+ mainWindow.drop_subpixelMotionEstimation.SelectedIndex = 0;
+ mainWindow.drop_trellis.SelectedIndex = 0;
+
+ mainWindow.rtf_x264Query.Text = "";
+ }
+
+ /// <summary>
+ /// Update GUI componets from the current x264 rtf string
+ /// </summary>
+ public void X264_SetCurrentSettingsInPanel(frmMain mainWindow)
+ {
+ /* Set widgets depending on the opt string in field */
+ String thisOpt; // The separated option such as "bframes=3"
+ String optName = ""; // The option name such as "bframes"
+ String optValue = "";// The option value such as "3"
+ String[] currentOptsArray;
+
+ //Set currentOptString to the contents of the text box.
+ String currentOptString = mainWindow.rtf_x264Query.Text.Replace("\n", "");
+
+ /*verify there is an opt string to process */
+ if (currentOptString.Contains("="))
+ {
+ /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
+ currentOptsArray = currentOptString.Split(':');
+
+ /*iterate through the array and get <opts> and <values*/
+ int loopcounter;
+ int currentOptsArrayCount = currentOptsArray.Length;
+
+
+ /*iterate through the array and get <opts> and <values*/
+ for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
+ {
+
+ thisOpt = currentOptsArray[loopcounter];
+ String[] splitOptRange = thisOpt.Split('=');
+
+ if (thisOpt.Contains("="))
+ {
+ optName = splitOptRange[0];
+ optValue = splitOptRange[1];
+
+ /*Run through the available widgets for x264 opts and set them, as you add widgets,
+ they need to be added here. This should be moved to its own method probably*/
+
+ /*bframes NSPopUpButton*/
+ if (optName.Equals("bframes"))
+ mainWindow.drop_bFrames.SelectedItem = optValue;
+
+ /*ref NSPopUpButton*/
+ else if (optName.Equals("ref"))
+ mainWindow.drop_refFrames.SelectedItem = optValue;
+
+ /*No Fast PSkip NSPopUpButton*/
+ else if (optName.Equals("no-fast-pskip"))
+ mainWindow.check_noFastPSkip.CheckState = CheckState.Checked;
+
+ /*No Dict Decimate NSPopUpButton*/
+ else if (optName.Equals("no-dct-decimate"))
+ mainWindow.check_noDCTDecimate.CheckState = CheckState.Checked;
+
+ /*Sub Me NSPopUpButton*/
+ else if (optName.Equals("subq"))
+ mainWindow.drop_subpixelMotionEstimation.SelectedItem = optValue;
+
+ /*Trellis NSPopUpButton*/
+ else if (optName.Equals("trellis"))
+ mainWindow.drop_trellis.SelectedItem = optValue;
+
+ /*Mixed Refs NSButton*/
+ else if (optName.Equals("mixed-refs"))
+ mainWindow.check_mixedReferences.CheckState = CheckState.Checked;
+
+ /*Motion Estimation NSPopUpButton*/
+ else if (optName.Equals("me"))
+ {
+ if (optValue.Equals("dia"))
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Diamond";
+ else if (optValue.Equals("hex"))
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Hexagon";
+ else if (optValue.Equals("umh"))
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Uneven Multi-Hexagon";
+ else if (optValue.Equals("esa"))
+ mainWindow.drop_MotionEstimationMethod.SelectedItem = "Exhaustive";
+
+ }
+ /*ME Range NSPopUpButton*/
+ else if (optName.Equals("merange"))
+ mainWindow.drop_MotionEstimationRange.SelectedItem = optValue;
+
+ /*Weighted B-Frames NSPopUpButton*/
+ else if (optName.Equals("weightb"))
+ mainWindow.check_weightedBFrames.CheckState = CheckState.Checked;
+
+ /*B Pyramid NSPopUpButton*/
+ else if (optName.Equals("b-pyramid"))
+ mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Checked;
+
+ /*Direct B-frame Prediction NSPopUpButton*/
+ else if (optName.Equals("direct"))
+ {
+ if (optValue == "auto")
+ optValue = "Automatic";
+
+ if (optValue != "")
+ {
+ Char[] letters = optValue.ToCharArray();
+ letters[0] = Char.ToUpper(letters[0]);
+ optValue = new string(letters);
+ }
+
+ mainWindow.drop_directPrediction.SelectedItem = optValue;
+ }
+
+ /*Deblocking NSPopUpButtons*/
+ else if (optName.Equals("deblock"))
+ {
+ string alphaDeblock = "";
+ string betaDeblock = "";
+
+ string[] splitDeblock = optValue.Split(',');
+ alphaDeblock = splitDeblock[0];
+ betaDeblock = splitDeblock[1];
+
+ if (alphaDeblock.Equals("0") && betaDeblock.Replace("\n", "").Equals("0"))
+ {
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
+ }
+ else
+ {
+ if (!alphaDeblock.Equals("0"))
+ mainWindow.drop_deblockAlpha.SelectedItem = alphaDeblock;
+ else
+ mainWindow.drop_deblockAlpha.SelectedItem = "0";
+
+ if (!betaDeblock.Replace("\n", "").Equals("0"))
+ mainWindow.drop_deblockBeta.SelectedItem = betaDeblock.Replace("\n", "");
+ else
+ mainWindow.drop_deblockBeta.SelectedItem = "0";
+ }
+ }
+ /* Analysis NSPopUpButton */
+ else if (optName.Equals("analyse"))
+ {
+
+ if (optValue.Equals("p8x8,b8x8,i8x8,i4x4"))
+ mainWindow.drop_analysis.SelectedItem = "Default (some)";
+ if (optValue.Equals("none"))
+ mainWindow.drop_analysis.SelectedItem = "None";
+ if (optValue.Equals("all"))
+ mainWindow.drop_analysis.SelectedItem = "All";
+ }
+ /* 8x8 DCT NSButton */
+ else if (optName.Equals("8x8dct"))
+ mainWindow.check_8x8DCT.CheckState = CheckState.Checked;
+
+ /* CABAC NSButton */
+ else if (optName.Equals("cabac"))
+ mainWindow.check_Cabac.CheckState = CheckState.Unchecked;
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Iterate over every x264 option, standardize it, write the full string to the x264 rtf box
+ /// </summary>
+ public void X264_StandardizeOptString(frmMain mainWindow)
+ {
+ /* Set widgets depending on the opt string in field */
+ String thisOpt; // The separated option such as "bframes=3"
+ String optName = ""; // The option name such as "bframes"
+ String optValue = "";// The option value such as "3"
+ String changedOptString = "";
+ String[] currentOptsArray;
+
+ /*First, we get an opt string to process */
+ String currentOptString = mainWindow.rtf_x264Query.Text;
+
+ /*verify there is an opt string to process */
+ if (currentOptString.Contains("="))
+ {
+ /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
+ currentOptsArray = currentOptString.Split(':');
+
+ /*iterate through the array and get <opts> and <values*/
+ //NSEnumerator * enumerator = [currentOptsArray objectEnumerator];
+ int loopcounter;
+ int currentOptsArrayCount = currentOptsArray.Length;
+ for (loopcounter = 0; loopcounter < currentOptsArrayCount; loopcounter++)
+ {
+ thisOpt = currentOptsArray[loopcounter];
+ if (currentOptsArray[currentOptsArrayCount - 1] == string.Empty)
+ break;
+
+ String[] splitOptRange = thisOpt.Split('=');
+ if (thisOpt != "")
+ {
+ if (thisOpt.Contains("="))
+ {
+ optName = splitOptRange[0];
+ optValue = splitOptRange[1];
+
+ /* Standardize the names here depending on whats in the string */
+ optName = X264_StandardizeOptNames(optName);
+ thisOpt = optName + "=" + optValue;
+ }
+ else // No value given so we use a default of "1"
+ {
+ optName = thisOpt;
+ /* Standardize the names here depending on whats in the string */
+ optName = X264_StandardizeOptNames(optName);
+ thisOpt = optName + "=1";
+ }
+ }
+
+ /* Construct New String for opts here */
+ if (thisOpt == string.Empty)
+ changedOptString = changedOptString + thisOpt;
+ else
+ {
+ if (changedOptString == string.Empty)
+ changedOptString = thisOpt;
+ else
+ changedOptString = changedOptString + ":" + thisOpt;
+ }
+ }
+ }
+
+ /* Change the option string to reflect the new standardized option string */
+ if (changedOptString != "")
+ mainWindow.rtf_x264Query.Text = changedOptString;
+ }
+ /*
+ * Take a single option and standardize it. Returns as a String
+ * Input: String. - Single X264 Option. Name only
+ * Output: String - Single X264 Option. Name only. Changed to standard format
+ */
+ private string X264_StandardizeOptNames(String cleanOptNameString)
+ {
+ String input = cleanOptNameString;
+
+ if (input.Equals("ref") || input.Equals("frameref"))
+ cleanOptNameString = "ref";
+
+ /*No Fast PSkip nofast_pskip*/
+ if (input.Equals("no-fast-pskip") || input.Equals("no_fast_pskip") || input.Equals("nofast_pskip"))
+ cleanOptNameString = "no-fast-pskip";
+
+ /*No Dict Decimate*/
+ if (input.Equals("no-dct-decimate") || input.Equals("no_dct_decimate") || input.Equals("nodct_decimate"))
+ cleanOptNameString = "no-dct-decimate";
+
+ /*Subme*/
+ if (input.Equals("subme"))
+ cleanOptNameString = "subq";
+
+ /*ME Range*/
+ if (input.Equals("me-range") || input.Equals("me_range"))
+ cleanOptNameString = "merange";
+
+ /*WeightB*/
+ if (input.Equals("weight-b") || input.Equals("weight_b"))
+ cleanOptNameString = "weightb";
+
+ /*B Pyramid*/
+ if (input.Equals("b_pyramid"))
+ cleanOptNameString = "b-pyramid";
+
+ /*Direct Prediction*/
+ if (input.Equals("direct-pred") || input.Equals("direct_pred"))
+ cleanOptNameString = "direct";
+
+ /*Deblocking*/
+ if (input.Equals("filter"))
+ cleanOptNameString = "deblock";
+
+ /*Analysis*/
+ if (input.Equals("partitions"))
+ cleanOptNameString = "analyse";
+
+ return cleanOptNameString;
+ }
+
+ /// <summary>
+ /// This function will update the X264 Query when one of the GUI widgets changes.
+ /// </summary>
+ public void on_x264_WidgetChange(string sender, frmMain mainWindow)
+ {
+ animate(mainWindow, sender);
+ String optNameToChange = sender;
+ String currentOptString = mainWindow.rtf_x264Query.Text;
+
+ /*First, we create a pattern to check for ":"optNameToChange"=" to modify the option if the name falls after
+ the first character of the opt string (hence the ":") */
+ String checkOptNameToChange = ":" + optNameToChange + "=";
+ String checkOptNameToChangeBegin = optNameToChange + "=";
+
+ // IF the current H264 Option String Contains Multiple Items or Just 1 Item
+ if ((currentOptString.Contains(checkOptNameToChange)) || (currentOptString.StartsWith(checkOptNameToChangeBegin)))
+ hasOptions(currentOptString, optNameToChange, mainWindow);
+ else // IF there is no options in the rich text box!
+ hasNoOptions(optNameToChange, mainWindow);
+ }
+ /*
+ * Used by on_x264_WidgetChange()
+ ** hasOptions - Called when the current x264 option string contains multiple (or a single) item(s) in it seperated by :
+ * it updates the current option that the widget corrosponds to, if it is already in thes string.
+ ** hasNoOptions - Add's an option to the x264 query string.
+ * Handles 2 cases. 1 Where rtf_x264Query.Text is empty, and one where there is an option with no value,
+ * e.g no-fast-pskip
+ */
+ private void hasOptions(string currentOptString, string optNameToChange, frmMain mainWindow)
+ {
+ String thisOpt; // The separated option such as "bframes=3"
+ String optName = ""; // The option name such as "bframes"
+ String optValue = ""; // The option value such as "3"
+ String[] currentOptsArray;
+
+ /* Create new empty opt string*/
+ String changedOptString = "";
+
+ /*Put individual options into an array based on the ":" separator for processing, result is "<opt>=<value>"*/
+ currentOptsArray = currentOptString.Split(':');
+
+ /*iterate through the array and get <opts> and <values*/
+ for (int loopcounter = 0; loopcounter < currentOptsArray.Length; loopcounter++)
+ {
+ thisOpt = currentOptsArray[loopcounter];
+
+ if (thisOpt.Contains("="))
+ {
+ string[] splitOptRange = thisOpt.Split('=');
+
+ optName = splitOptRange[0]; // e.g bframes
+ optValue = splitOptRange[1]; // e.g 2
+
+ /*
+ * Run through the available widgets for x264 opts and set them, as you add widgets,
+ * they need to be added here. This should be moved to its own method probably
+ * If the optNameToChange is found, appropriately change the value or delete it if
+ * "unspecified" is set.
+ */
+ if (optName.Equals(optNameToChange))
+ {
+ if (optNameToChange.Equals("deblock"))
+ {
+ String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();
+ String db = mainWindow.drop_deblockBeta.SelectedItem.ToString();
+
+ if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
+ {
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
+ thisOpt = "";
+ }
+ else if ((!da.Contains("Default")) && (db.Contains("Default")))
+ {
+ mainWindow.drop_deblockBeta.SelectedItem = "0";
+ thisOpt = "deblock=" + da + ",0";
+ }
+ else if ((da.Contains("Default")) && (!db.Contains("Default")))
+ {
+ mainWindow.drop_deblockAlpha.SelectedItem = "0";
+ thisOpt = "deblock=0," + db;
+ }
+ else if ((!da.Contains("Default")) && (!db.Contains("Default")))
+ thisOpt = "deblock=" + da + "," + db;
+ }
+
+ else if (optNameToChange.Equals("mixed-refs"))
+ {
+ if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)
+ thisOpt = "mixed-refs=1";
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("weightb"))
+ {
+ if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)
+ thisOpt = "weightb=1";
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("b-pyramid"))
+ {
+ if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)
+ thisOpt = "b-pyramid=1";
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("no-fast-pskip"))
+ {
+ if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)
+ thisOpt = "no-fast-pskip=1";
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("no-dct-decimate"))
+ {
+ if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)
+ thisOpt = "no-dct-decimate=1";
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("8x8dct"))
+ {
+ if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)
+ thisOpt = "8x8dct=1";
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("cabac"))
+ {
+ if (mainWindow.check_Cabac.CheckState == CheckState.Checked)
+ thisOpt = "";
+ else
+ thisOpt = "cabac=0";
+ }
+ else if (optNameToChange.Equals("me"))
+ {
+ switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)
+ {
+ case 1:
+ thisOpt = "me=dia";
+ break;
+
+ case 2:
+ thisOpt = "me=hex";
+ break;
+
+ case 3:
+ thisOpt = "me=umh";
+ break;
+
+ case 4:
+ thisOpt = "me=esa";
+ break;
+
+ default:
+ thisOpt = "";
+ break;
+ }
+ }
+ else if (optNameToChange.Equals("direct"))
+ {
+ switch (mainWindow.drop_directPrediction.SelectedIndex)
+ {
+ case 1:
+ thisOpt = "direct=none";
+ break;
+
+ case 2:
+ thisOpt = "direct=spatial";
+ break;
+
+ case 3:
+ thisOpt = "direct=temporal";
+ break;
+
+ case 4:
+ thisOpt = "direct=auto";
+ break;
+
+ default:
+ thisOpt = "";
+ break;
+ }
+ }
+ else if (optNameToChange.Equals("analyse"))
+ {
+ switch (mainWindow.drop_analysis.SelectedIndex)
+ {
+ case 1:
+ thisOpt = "analyse=none";
+ break;
+
+ case 2:
+ thisOpt = "analyse=all";
+ break;
+
+ default:
+ thisOpt = "";
+ break;
+ }
+ }
+ else if (optNameToChange.Equals("merange"))
+ {
+ if (!mainWindow.drop_MotionEstimationRange.SelectedItem.ToString().Contains("Default"))
+ thisOpt = "merange=" + mainWindow.drop_MotionEstimationRange.SelectedItem.ToString();
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("ref"))
+ {
+ if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))
+ thisOpt = "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("bframes"))
+ {
+ String value = mainWindow.drop_bFrames.SelectedItem.ToString();
+ if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))
+ thisOpt = "bframes=" + value;
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("subq"))
+ {
+ String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();
+ if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
+ thisOpt = "subq=" + value;
+ else
+ thisOpt = "";
+ }
+ else if (optNameToChange.Equals("trellis"))
+ {
+ String value = mainWindow.drop_trellis.SelectedItem.ToString();
+ if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))
+ thisOpt = "trellis=" + value;
+ else
+ thisOpt = "";
+ }
+
+ }
+ }
+
+ /* Construct New String for opts here */
+ if (!thisOpt.Equals(""))
+ {
+ if (changedOptString.Equals(""))
+ changedOptString = thisOpt;
+ else
+ changedOptString = changedOptString + ":" + thisOpt;
+ }
+ }
+
+ /* Change the option string to reflect the new mod settings */
+ mainWindow.rtf_x264Query.Text = changedOptString;
+ }
+ private void hasNoOptions(string optNameToChange, frmMain mainWindow)
+ {
+ string query = "";
+ string colon = "";
+ if (mainWindow.rtf_x264Query.Text != "")
+ colon = ":";
+
+ query = mainWindow.rtf_x264Query.Text;
+ if (optNameToChange.Equals("me"))
+ {
+ switch (mainWindow.drop_MotionEstimationMethod.SelectedIndex)
+ {
+ case 1:
+ query = query + colon + "me=dia";
+ break;
+
+ case 2:
+ query = query + colon + "me=hex";
+ break;
+
+ case 3:
+ query = query + colon + "me=umh";
+ break;
+
+ case 4:
+ query = query + colon + "me=esa";
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (optNameToChange.Equals("direct"))
+ {
+ switch (mainWindow.drop_directPrediction.SelectedIndex)
+ {
+ case 1:
+ query = query + colon + "direct=none";
+ break;
+
+ case 2:
+ query = query + colon + "direct=spatial";
+ break;
+
+ case 3:
+ query = query + colon + "direct=temporal";
+ break;
+
+ case 4:
+ query = query + colon + "direct=auto";
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (optNameToChange.Equals("analyse"))
+ {
+ switch (mainWindow.drop_analysis.SelectedIndex)
+ {
+ case 1:
+ query = query + colon + "analyse=none";
+ break;
+
+ case 2:
+ query = query + colon + "analyse=all";
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (optNameToChange.Equals("merange"))
+ {
+ int value = mainWindow.drop_MotionEstimationRange.SelectedIndex + 3;
+ query = query + colon + "merange=" + value.ToString();
+ }
+ else if (optNameToChange.Equals("deblock"))
+ {
+ String da = mainWindow.drop_deblockAlpha.SelectedItem.ToString();
+ String db = mainWindow.drop_deblockBeta.Text.ToString();
+
+ if (((da.Contains("Default")) && (db.Contains("Default"))) || ((da.Contains("0")) && (db.Contains("0"))))
+ {
+ mainWindow.drop_deblockBeta.SelectedItem = "Default (0)";
+ mainWindow.drop_deblockAlpha.SelectedItem = "Default (0)";
+ }
+ else
+ {
+ if (db.Contains("Default"))
+ db = "0";
+
+ if (da.Contains("Default"))
+ da = "0";
+
+ query = query + colon + "deblock=" + da + "," + db;
+ }
+ }
+ else if (optNameToChange.Equals("mixed-refs"))
+ {
+ if (mainWindow.check_mixedReferences.CheckState == CheckState.Checked)
+ query = query + colon + "mixed-refs=1";
+ }
+ else if (optNameToChange.Equals("weightb"))
+ {
+ if (mainWindow.check_weightedBFrames.CheckState == CheckState.Checked)
+ query = query + colon + "weightb=1";
+ }
+ else if (optNameToChange.Equals("b-pyramid"))
+ {
+ if (mainWindow.check_pyrmidalBFrames.CheckState == CheckState.Checked)
+ query = query + colon + "b-pyramid=1";
+ }
+ else if (optNameToChange.Equals("no-fast-pskip"))
+ {
+ if (mainWindow.check_noFastPSkip.CheckState == CheckState.Checked)
+ query = query + colon + "no-fast-pskip=1";
+ }
+ else if (optNameToChange.Equals("no-dct-decimate"))
+ {
+ if (mainWindow.check_noDCTDecimate.CheckState == CheckState.Checked)
+ query = query + colon + "no-dct-decimate=1";
+ }
+ else if (optNameToChange.Equals("8x8dct"))
+ {
+ if (mainWindow.check_8x8DCT.CheckState == CheckState.Checked)
+ query = query + colon + "8x8dct=1";
+ }
+ else if (optNameToChange.Equals("cabac"))
+ {
+ if (mainWindow.check_Cabac.CheckState != CheckState.Checked)
+ query = query + colon + "cabac=0";
+ }
+ else if (optNameToChange.Equals("ref"))
+ {
+ if (!mainWindow.drop_refFrames.SelectedItem.ToString().Contains("Default"))
+ query = query + colon + "ref=" + mainWindow.drop_refFrames.SelectedItem.ToString();
+ }
+ else if (optNameToChange.Equals("bframes"))
+ {
+ String value = mainWindow.drop_bFrames.SelectedItem.ToString();
+ if (!mainWindow.drop_bFrames.SelectedItem.ToString().Contains("Default"))
+ query = query + colon + "bframes=" + value;
+ }
+ else if (optNameToChange.Equals("subq"))
+ {
+ String value = mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString();
+ if (!mainWindow.drop_subpixelMotionEstimation.SelectedItem.ToString().Contains("Default"))
+ query = query + colon + "subq=" + value;
+ }
+ else if (optNameToChange.Equals("trellis"))
+ {
+ if (!mainWindow.drop_trellis.SelectedItem.ToString().Contains("Default"))
+ query = query + colon + "trellis=" + mainWindow.drop_trellis.SelectedItem.ToString();
+ }
+
+ mainWindow.rtf_x264Query.Text = query;
+ }
+ private void animate(frmMain mainWindow, string sender)
+ {
+ /* Lots of situations to cover.
+ - B-frames (when 0 turn of b-frame specific stuff, when < 2 disable b-pyramid)
+ - CABAC (when 0 turn off trellis)
+ - analysis (if none, turn off 8x8dct)
+ - refs (under 2, disable mixed-refs)
+ */
+ if (mainWindow.drop_bFrames.SelectedIndex < 2)
+ {
+ /* If the b-frame widget is at 0 or 1, the user has chosen
+ not to use b-frames at all. So disable the options
+ that can only be used when b-frames are enabled. */
+ mainWindow.check_weightedBFrames.Visible = false;
+ mainWindow.check_pyrmidalBFrames.Visible = false;
+ mainWindow.drop_directPrediction.Visible = false;
+ mainWindow.lbl_direct_prediction.Visible = false;
+
+ mainWindow.check_weightedBFrames.CheckState = CheckState.Unchecked;
+ mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
+ mainWindow.drop_directPrediction.SelectedIndex = 0;
+ }
+ else if (mainWindow.drop_bFrames.SelectedIndex == 2)
+ {
+ /* Only 1 b-frame? Disable b-pyramid. */
+ mainWindow.check_pyrmidalBFrames.Visible = false;
+ mainWindow.check_pyrmidalBFrames.CheckState = CheckState.Unchecked;
+
+ mainWindow.check_weightedBFrames.Visible = true;
+ mainWindow.drop_directPrediction.Visible = true;
+ mainWindow.lbl_direct_prediction.Visible = true;
+
+ }
+ else
+ {
+ mainWindow.check_weightedBFrames.Visible = true;
+ mainWindow.check_pyrmidalBFrames.Visible = true;
+ mainWindow.drop_directPrediction.Visible = true;
+ mainWindow.lbl_direct_prediction.Visible = true;
+ }
+
+ if (mainWindow.check_Cabac.Checked == false)
+ {
+ /* Without CABAC entropy coding, trellis doesn't run. */
+ mainWindow.drop_trellis.Visible = false;
+ mainWindow.drop_trellis.SelectedIndex = 0;
+ mainWindow.lbl_trellis.Visible = false;
+ }
+ else
+ {
+ mainWindow.drop_trellis.Visible = true;
+ mainWindow.lbl_trellis.Visible = true;
+ }
+
+ if (mainWindow.drop_analysis.SelectedIndex == 1)
+ {
+ /* No analysis? Disable 8x8dct */
+ mainWindow.check_8x8DCT.Visible = false;
+ if (sender != "8x8dct")
+ mainWindow.check_8x8DCT.CheckState = CheckState.Unchecked;
+ }
+ else
+ mainWindow.check_8x8DCT.Visible = true;
+
+ if (mainWindow.drop_refFrames.SelectedIndex < 3)
+ {
+ mainWindow.check_mixedReferences.Visible = false;
+ if (sender != "mixed-refs")
+ mainWindow.check_mixedReferences.CheckState = CheckState.Unchecked;
+ }
+ else
+ {
+ mainWindow.check_mixedReferences.Visible = true;
+ }
+ }
+
+ }
+}
\ No newline at end of file |