From 8019891f41076f6eb1f2ed6ae535103b392662e2 Mon Sep 17 00:00:00 2001 From: sr55 Date: Sun, 10 Oct 2010 14:12:22 +0000 Subject: WinGui: - Add support for the new AC3 Encoder. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3595 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Controls/AudioPanel.Designer.cs | 106 +++++++++++++++++---------------- win/C#/Controls/AudioPanel.cs | 96 +++++++++++++++-------------- win/C#/Functions/QueryGenerator.cs | 6 +- win/C#/Functions/QueryParser.cs | 6 +- win/C#/Presets/PlistPresetHandler.cs | 12 +--- win/C#/frmMain.Designer.cs | 14 +++-- 6 files changed, 124 insertions(+), 116 deletions(-) diff --git a/win/C#/Controls/AudioPanel.Designer.cs b/win/C#/Controls/AudioPanel.Designer.cs index 0931d2a3f..3349ab488 100644 --- a/win/C#/Controls/AudioPanel.Designer.cs +++ b/win/C#/Controls/AudioPanel.Designer.cs @@ -59,13 +59,13 @@ namespace Handbrake.Controls this.AudioTrackGroup = new System.Windows.Forms.GroupBox(); this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components); this.audioList = new System.Windows.Forms.DataGridView(); - this.DRC = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Bitrate = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Samplerate = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Mixdown = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.AudioCodec = new System.Windows.Forms.DataGridViewTextBoxColumn(); - this.Source = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.Track = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Source = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.AudioCodec = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Mixdown = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Samplerate = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Bitrate = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DRC = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.audioMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.tb_drc)).BeginInit(); this.AudioTrackGroup.SuspendLayout(); @@ -166,7 +166,7 @@ namespace Handbrake.Controls this.tb_drc.Size = new System.Drawing.Size(57, 45); this.tb_drc.TabIndex = 60; this.tb_drc.TickFrequency = 10; - this.tb_drc.Scroll += new System.EventHandler(this.controlChanged); + this.tb_drc.Scroll += new System.EventHandler(this.ControlChanged); // // label68 // @@ -227,12 +227,14 @@ namespace Handbrake.Controls "AAC (faac)", "MP3 (lame)", "Vorbis (vorbis)", - "AC3 Passthru"}); + "AC3 Passthru", + "AC3 (ffmpeg)", + "DTS Passthru"}); this.drp_audioEncoder.Location = new System.Drawing.Point(215, 34); this.drp_audioEncoder.Name = "drp_audioEncoder"; this.drp_audioEncoder.Size = new System.Drawing.Size(111, 21); this.drp_audioEncoder.TabIndex = 52; - this.drp_audioEncoder.SelectedIndexChanged += new System.EventHandler(this.controlChanged); + this.drp_audioEncoder.SelectedIndexChanged += new System.EventHandler(this.ControlChanged); // // label27 // @@ -259,7 +261,7 @@ namespace Handbrake.Controls this.drp_audioMix.Name = "drp_audioMix"; this.drp_audioMix.Size = new System.Drawing.Size(129, 21); this.drp_audioMix.TabIndex = 54; - this.drp_audioMix.SelectedIndexChanged += new System.EventHandler(this.controlChanged); + this.drp_audioMix.SelectedIndexChanged += new System.EventHandler(this.ControlChanged); // // drp_audioTrack // @@ -271,7 +273,7 @@ namespace Handbrake.Controls this.drp_audioTrack.Name = "drp_audioTrack"; this.drp_audioTrack.Size = new System.Drawing.Size(194, 21); this.drp_audioTrack.TabIndex = 50; - this.drp_audioTrack.SelectedIndexChanged += new System.EventHandler(this.controlChanged); + this.drp_audioTrack.SelectedIndexChanged += new System.EventHandler(this.ControlChanged); // // drp_audioBitrate // @@ -292,7 +294,7 @@ namespace Handbrake.Controls this.drp_audioBitrate.Name = "drp_audioBitrate"; this.drp_audioBitrate.Size = new System.Drawing.Size(70, 21); this.drp_audioBitrate.TabIndex = 58; - this.drp_audioBitrate.SelectedIndexChanged += new System.EventHandler(this.controlChanged); + this.drp_audioBitrate.SelectedIndexChanged += new System.EventHandler(this.ControlChanged); // // drp_audioSample // @@ -309,7 +311,7 @@ namespace Handbrake.Controls this.drp_audioSample.Name = "drp_audioSample"; this.drp_audioSample.Size = new System.Drawing.Size(55, 21); this.drp_audioSample.TabIndex = 56; - this.drp_audioSample.SelectedIndexChanged += new System.EventHandler(this.controlChanged); + this.drp_audioSample.SelectedIndexChanged += new System.EventHandler(this.ControlChanged); // // AudioTrackGroup // @@ -371,32 +373,29 @@ namespace Handbrake.Controls this.audioList.TabIndex = 67; this.audioList.SelectionChanged += new System.EventHandler(this.audioList_SelectionChanged); // - // DRC + // Track // - this.DRC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; - this.DRC.FillWeight = 96.36334F; - this.DRC.HeaderText = "DRC"; - this.DRC.Name = "DRC"; - this.DRC.ReadOnly = true; - this.DRC.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Track.FillWeight = 304.2808F; + this.Track.HeaderText = "Track"; + this.Track.Name = "Track"; + this.Track.ReadOnly = true; + this.Track.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Track.Width = 50; // - // Bitrate + // Source // - this.Bitrate.FillWeight = 49.69727F; - this.Bitrate.HeaderText = "Bitrate"; - this.Bitrate.Name = "Bitrate"; - this.Bitrate.ReadOnly = true; - this.Bitrate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.Bitrate.Width = 75; + this.Source.FillWeight = 49.69727F; + this.Source.HeaderText = "Source"; + this.Source.Name = "Source"; + this.Source.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Source.Width = 150; // - // Samplerate + // AudioCodec // - this.Samplerate.FillWeight = 49.69727F; - this.Samplerate.HeaderText = "Samplerate"; - this.Samplerate.Name = "Samplerate"; - this.Samplerate.ReadOnly = true; - this.Samplerate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.Samplerate.Width = 75; + this.AudioCodec.HeaderText = "Audio Codec"; + this.AudioCodec.Name = "AudioCodec"; + this.AudioCodec.ReadOnly = true; + this.AudioCodec.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // Mixdown // @@ -407,29 +406,32 @@ namespace Handbrake.Controls this.Mixdown.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; this.Mixdown.Width = 150; // - // AudioCodec + // Samplerate // - this.AudioCodec.HeaderText = "Audio Codec"; - this.AudioCodec.Name = "AudioCodec"; - this.AudioCodec.ReadOnly = true; - this.AudioCodec.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Samplerate.FillWeight = 49.69727F; + this.Samplerate.HeaderText = "Samplerate"; + this.Samplerate.Name = "Samplerate"; + this.Samplerate.ReadOnly = true; + this.Samplerate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Samplerate.Width = 75; // - // Source + // Bitrate // - this.Source.FillWeight = 49.69727F; - this.Source.HeaderText = "Source"; - this.Source.Name = "Source"; - this.Source.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.Source.Width = 150; + this.Bitrate.FillWeight = 49.69727F; + this.Bitrate.HeaderText = "Bitrate"; + this.Bitrate.Name = "Bitrate"; + this.Bitrate.ReadOnly = true; + this.Bitrate.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; + this.Bitrate.Width = 75; // - // Track + // DRC // - this.Track.FillWeight = 304.2808F; - this.Track.HeaderText = "Track"; - this.Track.Name = "Track"; - this.Track.ReadOnly = true; - this.Track.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; - this.Track.Width = 50; + this.DRC.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.DRC.FillWeight = 96.36334F; + this.DRC.HeaderText = "DRC"; + this.DRC.Name = "DRC"; + this.DRC.ReadOnly = true; + this.DRC.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; // // AudioPanel // diff --git a/win/C#/Controls/AudioPanel.cs b/win/C#/Controls/AudioPanel.cs index 3555dcd28..888c91c9f 100644 --- a/win/C#/Controls/AudioPanel.cs +++ b/win/C#/Controls/AudioPanel.cs @@ -21,6 +21,11 @@ namespace Handbrake.Controls /// public partial class AudioPanel : UserControl { + + private const string AC3Passthru = "AC3 Passthru"; + + private const string DTSPassthru = "DTS Passthru"; + /// /// Initializes a new instance of the class. /// Create a new instance of the Audio Panel @@ -55,32 +60,26 @@ namespace Handbrake.Controls public void SetContainer(string path) { string oldval = drp_audioEncoder.Text; - if ((path.Contains("MP4")) || (path.Contains("M4V"))) - { - drp_audioEncoder.Items.Clear(); - drp_audioEncoder.Items.Add("AAC (faac)"); - drp_audioEncoder.Items.Add("MP3 (lame)"); - drp_audioEncoder.Items.Add("AC3 Passthru"); - if ((oldval != "AAC (faac)") && (oldval != "AC3 Passthru")) - drp_audioEncoder.SelectedIndex = 0; - else - drp_audioEncoder.SelectedItem = oldval; - } - else if (path.Contains("MKV")) + + drp_audioEncoder.Items.Clear(); + drp_audioEncoder.Items.Add("AAC (faac)"); + drp_audioEncoder.Items.Add("MP3 (lame)"); + drp_audioEncoder.Items.Add(AC3Passthru); + drp_audioEncoder.Items.Add("AC3 (ffmpeg)"); + + if (path.Contains("MKV")) { - drp_audioEncoder.Items.Clear(); - drp_audioEncoder.Items.Add("AAC (faac)"); - drp_audioEncoder.Items.Add("MP3 (lame)"); - drp_audioEncoder.Items.Add("AC3 Passthru"); - drp_audioEncoder.Items.Add("DTS Passthru"); + drp_audioEncoder.Items.Add(DTSPassthru); drp_audioEncoder.Items.Add("Vorbis (vorbis)"); - drp_audioEncoder.SelectedItem = oldval; - - if (drp_audioEncoder.Text == string.Empty) - drp_audioEncoder.SelectedIndex = 0; } + if (!drp_audioEncoder.Text.Contains(oldval)) + drp_audioEncoder.SelectedIndex = 0; + else + drp_audioEncoder.SelectedItem = oldval; + // Make sure the table is updated with new audio codecs + // Defaults to AAC encoding. foreach (DataGridViewRow row in audioList.Rows) { if (!drp_audioEncoder.Items.Contains(row.Cells[2].Value)) @@ -117,7 +116,7 @@ namespace Handbrake.Controls newTrack.Cells[2].Value = track.Encoder; newTrack.Cells[3].Value = track.MixDown; newTrack.Cells[4].Value = track.SampleRate; - newTrack.Cells[5].Value = track.Encoder.Contains("AC3") || track.Encoder.Contains("DTS") ? "Auto" : track.Bitrate; + newTrack.Cells[5].Value = track.Encoder.Contains(AC3Passthru) || track.Encoder.Contains(DTSPassthru) ? "Auto" : track.Bitrate; newTrack.Cells[6].Value = track.DRC; AddTrackForPreset(newTrack); } @@ -145,12 +144,6 @@ namespace Handbrake.Controls drp_audioTrack.Items.Clear(); drp_audioTrack.Items.AddRange(selectedTitle.AudioTracks.ToArray()); - // Reset the Audio Track Selection to the first audio track of the source, or Audiomatic if that fails - foreach (DataGridViewRow row in this.audioList.Rows) - { - row.Cells[1].Value = "Automatic"; - } - // Add any tracks the preset has, if there is a preset and no audio tracks in the list currently if (audioList.Rows.Count == 0 && preset != null) { @@ -244,7 +237,7 @@ namespace Handbrake.Controls /// /// The e. /// - private void controlChanged(object sender, EventArgs e) + private void ControlChanged(object sender, EventArgs e) { Control ctl = (Control)sender; @@ -256,14 +249,14 @@ namespace Handbrake.Controls audioList.SelectedRows[0].Cells[1].Value = drp_audioTrack.Text; // If the track isn't AC3, and the encoder is, change it. - if (audioList.SelectedRows[0].Cells[2].Value.ToString().Contains("AC3") && !audioList.SelectedRows[0].Cells[1].Value.ToString().Contains("AC3")) + if (audioList.SelectedRows[0].Cells[2].Value.ToString().Contains(AC3Passthru) && !audioList.SelectedRows[0].Cells[1].Value.ToString().Contains("(AC3)")) { // Switch to AAC drp_audioEncoder.SelectedIndex = 0; } // If the track isn't DTS, and the encoder is, change it. - if (audioList.SelectedRows[0].Cells[2].Value.ToString().Contains("DTS") && !audioList.SelectedRows[0].Cells[1].Value.ToString().Contains("DTS")) + if (audioList.SelectedRows[0].Cells[2].Value.ToString().Contains(DTSPassthru) && !audioList.SelectedRows[0].Cells[1].Value.ToString().Contains("DTS")) { // Switch to AAC drp_audioEncoder.SelectedIndex = 0; @@ -275,7 +268,7 @@ namespace Handbrake.Controls SetBitrate(); // Configure the widgets with values - if (drp_audioEncoder.Text.Contains("AC3") || drp_audioEncoder.Text.Contains("DTS")) + if (drp_audioEncoder.Text.Contains(AC3Passthru) || drp_audioEncoder.Text.Contains(DTSPassthru)) { drp_audioMix.Enabled = drp_audioBitrate.Enabled = drp_audioSample.Enabled = tb_drc.Enabled = false; @@ -592,6 +585,7 @@ namespace Handbrake.Controls drp_audioBitrate.Items.Remove("320"); drp_audioBitrate.Items.Remove("384"); drp_audioBitrate.Items.Remove("448"); + drp_audioBitrate.Items.Remove("640"); drp_audioBitrate.Items.Remove("768"); switch (drp_audioEncoder.Text) @@ -605,12 +599,15 @@ namespace Handbrake.Controls case "Vorbis (vorbis)": max = 384; break; - case "AC3 Passthru": + case "AC3 (ffmpeg)": + max = 640; + break; + case AC3Passthru: drp_audioBitrate.Items.Add("Auto"); drp_audioBitrate.SelectedItem = "Auto"; drp_audioSample.SelectedItem = "Auto"; break; - case "DTS Passthru": + case DTSPassthru: drp_audioBitrate.Items.Add("Auto"); drp_audioBitrate.SelectedItem = "Auto"; drp_audioSample.SelectedItem = "Auto"; @@ -630,9 +627,14 @@ namespace Handbrake.Controls drp_audioBitrate.Items.Add("384"); } - if (max == 768) + if (max >= 640) { drp_audioBitrate.Items.Add("448"); + drp_audioBitrate.Items.Add("640"); + } + + if (max == 768) + { drp_audioBitrate.Items.Add("768"); } @@ -651,31 +653,35 @@ namespace Handbrake.Controls drp_audioMix.Items.Add("Dolby Surround"); drp_audioMix.Items.Add("Dolby Pro Logic II"); drp_audioMix.Items.Add("6 Channel Discrete"); - drp_audioMix.Items.Add("AC3 Passthru"); - drp_audioMix.Items.Add("DTS Passthru"); + drp_audioMix.Items.Add(AC3Passthru); + drp_audioMix.Items.Add(DTSPassthru); drp_audioMix.SelectedItem = "Dolby Pro Logic II"; switch (drp_audioEncoder.Text) { case "AAC (faac)": - drp_audioMix.Items.Remove("AC3 Passthru"); - drp_audioMix.Items.Remove("DTS Passthru"); + drp_audioMix.Items.Remove(AC3Passthru); + drp_audioMix.Items.Remove(DTSPassthru); break; case "MP3 (lame)": drp_audioMix.Items.Remove("6 Channel Discrete"); - drp_audioMix.Items.Remove("AC3 Passthru"); - drp_audioMix.Items.Remove("DTS Passthru"); + drp_audioMix.Items.Remove(AC3Passthru); + drp_audioMix.Items.Remove(DTSPassthru); break; case "Vorbis (vorbis)": - drp_audioMix.Items.Remove("AC3 Passthru"); - drp_audioMix.Items.Remove("DTS Passthru"); + drp_audioMix.Items.Remove(AC3Passthru); + drp_audioMix.Items.Remove(DTSPassthru); + break; + case "AC3 (ffmpeg)": + drp_audioMix.Items.Remove(AC3Passthru); + drp_audioMix.Items.Remove(DTSPassthru); break; case "AC3 Passthru": - drp_audioMix.SelectedItem = "AC3 Passthru"; + drp_audioMix.SelectedItem = AC3Passthru; break; case "DTS Passthru": - drp_audioMix.SelectedItem = "DTS Passthru"; + drp_audioMix.SelectedItem = DTSPassthru; break; } } diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index 2c4706f71..0703b65ba 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -597,9 +597,11 @@ namespace Handbrake.Functions case "Vorbis (vorbis)": return "vorbis"; case "AC3 Passthru": - return "ac3"; + return "copy:ac3"; case "DTS Passthru": - return "dts"; + return "copy:dts"; + case "AC3 (ffmpeg)": + return "ac3"; default: return string.Empty; } diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index c4ea1e5c9..01344c83c 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -353,7 +353,7 @@ namespace Handbrake.Functions Match noAudio = Regex.Match(input, @"-a none"); Match audioTracks = Regex.Match(input, @"-a ([0-9,]*)"); Match audioTrackMixes = Regex.Match(input, @"-6 ([0-9a-zA-Z,]*)"); - Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,]*)"); + Match audioEncoders = Regex.Match(input, @"-E ([a-zA-Z0-9+,:]*)"); Match audioBitrates = Regex.Match(input, @"-B ([0-9a-zA-Z,]*)"); // Auto = a-z Match audioSampleRates = Regex.Match(input, @"-R ([0-9a-zA-Z.,]*)"); // Auto = a-z Match drcValues = Regex.Match(input, @"-D ([0-9.,]*)"); @@ -688,8 +688,10 @@ namespace Handbrake.Functions case "vorbis": return "Vorbis (vorbis)"; case "ac3": + return "AC3 (ffmpeg)"; + case "copy:ac3": return "AC3 Passthru"; - case "dts": + case "copy:dts": return "DTS Passthru"; default: return "AAC (faac)"; diff --git a/win/C#/Presets/PlistPresetHandler.cs b/win/C#/Presets/PlistPresetHandler.cs index d05cb52af..87a29cc84 100644 --- a/win/C#/Presets/PlistPresetHandler.cs +++ b/win/C#/Presets/PlistPresetHandler.cs @@ -549,16 +549,8 @@ namespace Handbrake.Presets xmlWriter.WriteStartElement("key"); xmlWriter.WriteString(keyName); xmlWriter.WriteEndElement(); - if (value) - { - xmlWriter.WriteStartElement("true"); - xmlWriter.WriteEndElement(); - } - else - { - xmlWriter.WriteStartElement("false"); - xmlWriter.WriteEndElement(); - } + xmlWriter.WriteStartElement(value ? "true" : "false"); + xmlWriter.WriteEndElement(); } /// diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index b42649b43..a307147ce 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -39,7 +39,7 @@ namespace Handbrake this.components = new System.ComponentModel.Container(); System.Windows.Forms.ContextMenuStrip notifyIconMenu; System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.btn_restore = new System.Windows.Forms.ToolStripMenuItem(); this.DVD_Save = new System.Windows.Forms.SaveFileDialog(); this.ToolTip = new System.Windows.Forms.ToolTip(this.components); @@ -407,9 +407,9 @@ namespace Handbrake // // number // - dataGridViewCellStyle1.Format = "N0"; - dataGridViewCellStyle1.NullValue = null; - this.number.DefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle2.Format = "N0"; + dataGridViewCellStyle2.NullValue = null; + this.number.DefaultCellStyle = dataGridViewCellStyle2; this.number.Frozen = true; this.number.HeaderText = "Chapter Number"; this.number.MaxInputLength = 3; @@ -717,13 +717,17 @@ namespace Handbrake this.mnu_importMacPreset.Name = "mnu_importMacPreset"; this.mnu_importMacPreset.Size = new System.Drawing.Size(194, 22); this.mnu_importMacPreset.Text = "Import"; + this.mnu_importMacPreset.ToolTipText = "Import a (plist - mac format) preset.\r\nYou can import plist presets from the Mac," + + " Linux and Windows GUI\'s"; this.mnu_importMacPreset.Click += new System.EventHandler(this.mnu_importMacPreset_Click); // // mnu_exportMacPreset // this.mnu_exportMacPreset.Name = "mnu_exportMacPreset"; this.mnu_exportMacPreset.Size = new System.Drawing.Size(194, 22); - this.mnu_exportMacPreset.Text = "Export"; + this.mnu_exportMacPreset.Text = "Export (Experimental)"; + this.mnu_exportMacPreset.ToolTipText = "Export a (plist - mac format) preset.\r\nThis can be imported by Mac, Linux or Wind" + + "ows GUI\'s"; this.mnu_exportMacPreset.Click += new System.EventHandler(this.mnu_exportMacPreset_Click); // // mnu_SelectDefault -- cgit v1.2.3