diff options
-rw-r--r-- | win/C#/Controls/AudioPanel.cs | 58 | ||||
-rw-r--r-- | win/C#/Presets/PlistPresetHandler.cs | 51 | ||||
-rw-r--r-- | win/C#/frmMain.cs | 14 |
3 files changed, 87 insertions, 36 deletions
diff --git a/win/C#/Controls/AudioPanel.cs b/win/C#/Controls/AudioPanel.cs index b43e6d028..1ed84273c 100644 --- a/win/C#/Controls/AudioPanel.cs +++ b/win/C#/Controls/AudioPanel.cs @@ -9,7 +9,9 @@ namespace Handbrake.Controls using System.Collections;
using System.Linq;
using System.Windows.Forms;
+ using Functions;
using Parsing;
+ using Presets;
using AudioTrack = Model.AudioTrack;
public partial class AudioPanel : UserControl
@@ -116,16 +118,43 @@ namespace Handbrake.Controls /// Set the Track list dropdown from the parsed title captured during the scan
/// </summary>
/// <param name="selectedTitle"></param>
- public void SetTrackList(Title selectedTitle)
+ public void SetTrackList(Title selectedTitle, Preset preset)
{
- drp_audioTrack.Items.Clear();
- drp_audioTrack.Items.Add("Automatic");
- drp_audioTrack.Items.Add("None");
- drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray());
+ if (selectedTitle.AudioTracks.Count == 0)
+ {
+ lv_audioList.Items.Clear();
+ drp_audioTrack.Items.Clear();
+ drp_audioTrack.Items.Add("None Found");
+ drp_audioTrack.SelectedIndex = 0;
+ return;
+ }
+ else
+ {
+ drp_audioTrack.Items.Clear();
+ drp_audioTrack.Items.Add("Automatic");
+ drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray());
+
+ if (lv_audioList.Items.Count == 0 && preset != null)
+ {
+ QueryParser parsed = QueryParser.Parse(preset.Query);
+ foreach (AudioTrack audioTrack in parsed.AudioInformation)
+ {
+ ListViewItem newTrack = new ListViewItem(GetNewID().ToString());
+ newTrack.SubItems.Add(audioTrack.Track);
+ newTrack.SubItems.Add(audioTrack.Encoder);
+ newTrack.SubItems.Add(audioTrack.MixDown);
+ newTrack.SubItems.Add(audioTrack.SampleRate);
+ newTrack.SubItems.Add(audioTrack.Bitrate);
+ newTrack.SubItems.Add(audioTrack.DRC.ToString());
+ lv_audioList.Items.Add(newTrack);
+ }
+ }
+
+ }
// Handle Native Language and "Dub Foreign language audio" and "Use Foreign language audio and Subtitles" Options
if (Properties.Settings.Default.NativeLanguage == "Any")
- drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 3 ? 2 : 0;
+ drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 2 ? 1 : 0;
else
{
if (Properties.Settings.Default.DubAudio) // "Dub Foreign language audio"
@@ -155,14 +184,14 @@ namespace Handbrake.Controls }
else
drp_audioTrack.SelectedIndex = drp_audioTrack.Items.Count >= 3 ? 2 : 0;
- // "Use Foreign language audio and Subtitles"
+ // "Use Foreign language audio and Subtitles"
}
}
// Control and ListView
private void controlChanged(object sender, EventArgs e)
{
- Control ctl = (Control) sender;
+ Control ctl = (Control)sender;
switch (ctl.Name)
{
@@ -215,7 +244,7 @@ namespace Handbrake.Controls double value;
if (tb_drc.Value == 0) value = 0;
else
- value = ((tb_drc.Value - 1)/10.0) + 1;
+ value = ((tb_drc.Value - 1) / 10.0) + 1;
lbl_drc.Text = value.ToString();
@@ -245,7 +274,7 @@ namespace Handbrake.Controls int drcCalculated;
double.TryParse(lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text, out drcValue);
if (drcValue != 0)
- drcValue = ((drcValue*10) + 1) - 10;
+ drcValue = ((drcValue * 10) + 1) - 10;
int.TryParse(drcValue.ToString(), out drcCalculated);
tb_drc.Value = drcCalculated;
lbl_drc.Text = lv_audioList.Items[lv_audioList.SelectedIndices[0]].SubItems[6].Text;
@@ -260,9 +289,16 @@ namespace Handbrake.Controls // Track Controls
private void btn_addAudioTrack_Click(object sender, EventArgs e)
{
+ if (drp_audioTrack.Text == "None Found")
+ {
+ MessageBox.Show("Your source appears to have no audio tracks that HandBrake supports.", "Warning",
+ MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ return;
+ }
+
double value = 0;
if (tb_drc.Value != 0)
- value = ((tb_drc.Value - 1)/10.0) + 1;
+ value = ((tb_drc.Value - 1) / 10.0) + 1;
// Create a new row for the Audio list based on the currently selected items in the dropdown.
ListViewItem newTrack = new ListViewItem(GetNewID().ToString());
diff --git a/win/C#/Presets/PlistPresetHandler.cs b/win/C#/Presets/PlistPresetHandler.cs index 4fd085184..142662fd8 100644 --- a/win/C#/Presets/PlistPresetHandler.cs +++ b/win/C#/Presets/PlistPresetHandler.cs @@ -53,8 +53,8 @@ namespace Handbrake.Presets if (!root.HasChildNodes)
{
MessageBox.Show(
- "The Preset file you selected appears to be invlaid or from an older version of HandBrake",
- "Error",
+ "The Preset file you selected appears to be invlaid or from an older version of HandBrake",
+ "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
@@ -62,15 +62,15 @@ namespace Handbrake.Presets catch (Exception)
{
MessageBox.Show(
- "The Preset file you selected appears to be invlaid or from an older version of HandBrake.\n\n Please note, if you are exporting from the MacGui you may need to rebuild your preset so that it uses the current preset plist format.\n The MacGui does not currently update user presets automatically.",
- "Error",
+ "The Preset file you selected appears to be invlaid or from an older version of HandBrake.\n\n Please note, if you are exporting from the MacGui you may need to rebuild your preset so that it uses the current preset plist format.\n The MacGui does not currently update user presets automatically.",
+ "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// We'll query a query parser object and use it's public var structures to store all the data.
// This will allow the preset loader logic to be used instead of writing custom logic just for this file.
QueryParser queryParsed = new QueryParser();
-
+ string QualityMode = string.Empty;
/***** Get the Audio Tracks *****/
XmlNode audioListDict = root.ChildNodes[2].ChildNodes[0].FirstChild.ChildNodes[1];
ArrayList AudioInfo = new ArrayList();
@@ -113,14 +113,14 @@ namespace Handbrake.Presets /***** Get the rest of the settings. *****/
XmlNode presetSettings = root.ChildNodes[2].ChildNodes[0].FirstChild;
for (int i = 2; i < presetSettings.ChildNodes.Count; i += 2)
- // Start from 2 to avoid the audio settings which we don't need.
+ // Start from 2 to avoid the audio settings which we don't need.
{
string key = presetSettings.ChildNodes[i].InnerText;
string value = presetSettings.ChildNodes[i + 1].InnerText;
switch (key)
{
- // Output Settings
+ // Output Settings
case "FileFormat":
queryParsed.Format = value;
break;
@@ -134,7 +134,7 @@ namespace Handbrake.Presets queryParsed.IpodAtom = value == "1";
break;
- // Picture Settings
+ // Picture Settings
case "PictureAutoCrop":
break;
case "PictureTopCrop":
@@ -163,7 +163,7 @@ namespace Handbrake.Presets break;
- // Filters
+ // Filters
case "PictureDeblock":
queryParsed.DeBlock = int.Parse(value);
break;
@@ -230,9 +230,9 @@ namespace Handbrake.Presets queryParsed.DeTelecine = value;
break;
- // Video Tab
+ // Video Tab
case "VideoAvgBitrate":
- queryParsed.Width = int.Parse(value);
+ queryParsed.AverageVideoBitrate = value;
break;
case "VideoEncoder":
queryParsed.VideoEncoder = value;
@@ -246,7 +246,8 @@ namespace Handbrake.Presets case "VideoQualitySlider":
queryParsed.VideoQuality = float.Parse(value);
break;
- case "VideoQualityType":
+ case "VideoQualityType": // The Type of Quality Mode used
+ QualityMode = value;
break;
case "VideoTargetSize":
queryParsed.VideoTargetSize = value;
@@ -258,17 +259,17 @@ namespace Handbrake.Presets queryParsed.TwoPass = value == "1";
break;
- // Chapter Markers Tab
+ // Chapter Markers Tab
case "ChapterMarkers":
queryParsed.ChapterMarkers = value == "1";
break;
- // Advanced x264 tab
+ // Advanced x264 tab
case "x264Option":
queryParsed.H264Query = value;
break;
- // Preset Information
+ // Preset Information
case "PresetBuildNumber":
queryParsed.PresetBuildNumber = int.Parse(value);
break;
@@ -292,6 +293,24 @@ namespace Handbrake.Presets break;
}
}
+
+ // Kill any Quality values we don't need.
+ switch (QualityMode)
+ {
+ case "0": // FileSize
+ queryParsed.VideoQuality = -1;
+ queryParsed.AverageVideoBitrate = null;
+ break;
+ case "1": // Avg Bitrate
+ queryParsed.VideoQuality = -1;
+ queryParsed.VideoTargetSize = null;
+ break;
+ case "2": // CQ
+ queryParsed.AverageVideoBitrate = null;
+ queryParsed.VideoTargetSize = null;
+ break;
+ }
+
return queryParsed;
}
@@ -305,7 +324,7 @@ namespace Handbrake.Presets // Header
Writer.WriteStartDocument();
- Writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN",
+ Writer.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN",
@"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null);
Writer.WriteStartElement("plist");
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 2e9541a02..1fb52db5c 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -429,7 +429,7 @@ namespace Handbrake private void mnu_importMacPreset_Click(object sender, EventArgs e)
{
- importPreset();
+ ImportPreset();
}
private void btn_new_preset_Click(object sender, EventArgs e)
@@ -518,7 +518,7 @@ namespace Handbrake private void pmnu_import_Click(object sender, EventArgs e)
{
- importPreset();
+ ImportPreset();
}
private void pmnu_saveChanges_Click(object sender, EventArgs e)
@@ -698,7 +698,7 @@ namespace Handbrake }
}
- private void importPreset()
+ private void ImportPreset()
{
if (openPreset.ShowDialog() == DialogResult.OK)
{
@@ -720,10 +720,6 @@ namespace Handbrake else
{
PresetLoader.LoadPreset(this, parsed, parsed.PresetName, parsed.UsesPictureSettings);
- presetHandler.Add(parsed.PresetName,
- QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),
- parsed.UsesPictureSettings);
-
if (presetHandler.Add(parsed.PresetName + " (Imported)",
QueryGenerator.GenerateCliQuery(this, drop_mode.SelectedIndex, 0, null),
parsed.UsesPictureSettings))
@@ -1073,7 +1069,7 @@ namespace Handbrake drop_chapterFinish.Items.Clear();
// If the dropdown is set to automatic nothing else needs to be done.
- // Otheriwse if its not, title data has to be loased from parsing.
+ // Otheriwse if its not, title data has to be loaded from parsing.
if (drp_dvdtitle.Text != "Automatic")
{
selectedTitle = drp_dvdtitle.SelectedItem as Title;
@@ -1110,7 +1106,7 @@ namespace Handbrake drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
// Populate the Audio Channels Dropdown
- AudioSettings.SetTrackList(selectedTitle);
+ AudioSettings.SetTrackList(selectedTitle, CurrentlySelectedPreset);
// Populate the Subtitles dropdown
Subtitles.SetSubtitleTrackAuto(selectedTitle.Subtitles.ToArray());
|