From: sr55 Date: Wed, 11 Feb 2009 23:33:19 +0000 (+0000) Subject: WinGui: X-Git-Tag: 0.9.4~811 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7556f1aa51659a9d5aa96e6f7b8e0e9dcf165248;p=handbrake WinGui: - Constant Quality Slider now QP/RF based. - Nearest percentage is also shown for reference. - Preset system also updated to handle new CP/RF values git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2146 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index 68bcac00f..b297ed68e 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -256,7 +256,7 @@ namespace Handbrake.Functions private Boolean q_twoPass; private string q_videoFramerate; - private int q_videoQuality; + private float q_videoQuality; private string q_videoTargetSize; /// @@ -334,7 +334,7 @@ namespace Handbrake.Functions /// /// Returns a int with the video quality value /// - public int VideoQuality + public float VideoQuality { get { return q_videoQuality; } } @@ -848,12 +848,11 @@ namespace Handbrake.Functions if (videoFilesize.Success) thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", ""); - double qConvert; if (videoQuality.Success) { - qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Culture)*100; - qConvert = Math.Ceiling(qConvert); - thisQuery.q_videoQuality = int.Parse(qConvert.ToString()); + float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture); + //qConvert = Math.Ceiling(qConvert); + thisQuery.q_videoQuality = qConvert; } #endregion diff --git a/win/C#/Properties/Settings.Designer.cs b/win/C#/Properties/Settings.Designer.cs index a8c3c0f2f..aa02382f5 100644 --- a/win/C#/Properties/Settings.Designer.cs +++ b/win/C#/Properties/Settings.Designer.cs @@ -334,5 +334,17 @@ namespace Handbrake.Properties { this["QueryEditorTab"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0.25")] + public string x264cqstep { + get { + return ((string)(this["x264cqstep"])); + } + set { + this["x264cqstep"] = value; + } + } } } diff --git a/win/C#/Properties/Settings.settings b/win/C#/Properties/Settings.settings index ce7993310..9cf3031ef 100644 --- a/win/C#/Properties/Settings.settings +++ b/win/C#/Properties/Settings.settings @@ -80,5 +80,8 @@ + + 0.25 + \ No newline at end of file diff --git a/win/C#/app.config b/win/C#/app.config index 4ac6ad7ba..694345cf7 100644 --- a/win/C#/app.config +++ b/win/C#/app.config @@ -85,6 +85,9 @@ + + 0.25 + diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 89647c884..526f9c4fc 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -35,7 +35,6 @@ namespace Handbrake private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.Label Label38; 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(); @@ -164,14 +163,14 @@ namespace Handbrake this.Label20 = new System.Windows.Forms.Label(); this.drp_track1Audio = new System.Windows.Forms.ComboBox(); this.TabPage3 = new System.Windows.Forms.TabPage(); + this.radio_cq = new System.Windows.Forms.RadioButton(); + this.radio_avgBitrate = new System.Windows.Forms.RadioButton(); + this.radio_targetFilesize = new System.Windows.Forms.RadioButton(); this.label25 = new System.Windows.Forms.Label(); - this.Label22 = new System.Windows.Forms.Label(); this.check_2PassEncode = new System.Windows.Forms.CheckBox(); this.Label2 = new System.Windows.Forms.Label(); - this.Label42 = new System.Windows.Forms.Label(); this.SliderValue = new System.Windows.Forms.Label(); this.Label46 = new System.Windows.Forms.Label(); - this.Label40 = new System.Windows.Forms.Label(); this.check_grayscale = new System.Windows.Forms.CheckBox(); this.TabPage1 = new System.Windows.Forms.TabPage(); this.label6 = new System.Windows.Forms.Label(); @@ -197,10 +196,6 @@ namespace Handbrake this.Check_ChapterMarkers = new System.Windows.Forms.CheckBox(); this.tabs_panel = new System.Windows.Forms.TabControl(); this.tab_Filters = new System.Windows.Forms.TabPage(); - this.ctl_deinterlace = new Handbrake.Deinterlace(); - this.ctl_denoise = new Handbrake.Denoise(); - this.ctl_decomb = new Handbrake.Decomb(); - this.ctl_detelecine = new Handbrake.Detelecine(); this.tab_chapters = new System.Windows.Forms.TabPage(); this.label31 = new System.Windows.Forms.Label(); this.h264Tab = new System.Windows.Forms.TabPage(); @@ -254,7 +249,10 @@ namespace Handbrake this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.StatusStrip = new System.Windows.Forms.StatusStrip(); this.lbl_encode = new System.Windows.Forms.ToolStripStatusLabel(); - Label38 = new System.Windows.Forms.Label(); + this.ctl_deinterlace = new Handbrake.Deinterlace(); + this.ctl_denoise = new Handbrake.Denoise(); + this.ctl_decomb = new Handbrake.Decomb(); + this.ctl_detelecine = new Handbrake.Detelecine(); notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components); notifyIconMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).BeginInit(); @@ -287,17 +285,6 @@ namespace Handbrake this.StatusStrip.SuspendLayout(); this.SuspendLayout(); // - // Label38 - // - Label38.AutoSize = true; - Label38.BackColor = System.Drawing.Color.Transparent; - Label38.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - Label38.Location = new System.Drawing.Point(334, 38); - Label38.Name = "Label38"; - Label38.Size = new System.Drawing.Size(108, 13); - Label38.TabIndex = 11; - Label38.Text = "Target Size (MB):"; - // // notifyIconMenu // notifyIconMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -470,7 +457,7 @@ namespace Handbrake this.check_turbo.BackColor = System.Drawing.Color.Transparent; this.check_turbo.Enabled = false; this.check_turbo.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.check_turbo.Location = new System.Drawing.Point(37, 168); + this.check_turbo.Location = new System.Drawing.Point(146, 123); this.check_turbo.Name = "check_turbo"; this.check_turbo.Size = new System.Drawing.Size(115, 17); this.check_turbo.TabIndex = 7; @@ -501,34 +488,34 @@ namespace Handbrake // // slider_videoQuality // - this.slider_videoQuality.Location = new System.Drawing.Point(468, 91); + this.slider_videoQuality.Enabled = false; + this.slider_videoQuality.Location = new System.Drawing.Point(337, 120); this.slider_videoQuality.Maximum = 100; this.slider_videoQuality.Name = "slider_videoQuality"; - this.slider_videoQuality.Size = new System.Drawing.Size(167, 42); + this.slider_videoQuality.Size = new System.Drawing.Size(322, 42); this.slider_videoQuality.TabIndex = 14; this.slider_videoQuality.TickFrequency = 17; this.ToolTip.SetToolTip(this.slider_videoQuality, "Set the quality level of the video. (Around 70% is fine for most)"); - this.slider_videoQuality.Scroll += new System.EventHandler(this.slider_videoQuality_Scroll); + this.slider_videoQuality.ValueChanged += new System.EventHandler(this.slider_videoQuality_Scroll); // // text_filesize // + this.text_filesize.Enabled = false; this.text_filesize.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.text_filesize.Location = new System.Drawing.Point(476, 36); + this.text_filesize.Location = new System.Drawing.Point(482, 36); this.text_filesize.Name = "text_filesize"; this.text_filesize.Size = new System.Drawing.Size(81, 21); this.text_filesize.TabIndex = 12; this.ToolTip.SetToolTip(this.text_filesize, "Set the file size you wish the encoded file to be."); - this.text_filesize.TextChanged += new System.EventHandler(this.text_filesize_TextChanged); // // text_bitrate // this.text_bitrate.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.text_bitrate.Location = new System.Drawing.Point(476, 63); + this.text_bitrate.Location = new System.Drawing.Point(482, 63); this.text_bitrate.Name = "text_bitrate"; this.text_bitrate.Size = new System.Drawing.Size(81, 21); this.text_bitrate.TabIndex = 10; this.ToolTip.SetToolTip(this.text_bitrate, "Set the bitrate of the video"); - this.text_bitrate.TextChanged += new System.EventHandler(this.text_bitrate_TextChanged); // // drp_subtitle // @@ -1866,21 +1853,20 @@ namespace Handbrake // TabPage3 // this.TabPage3.BackColor = System.Drawing.Color.Transparent; + this.TabPage3.Controls.Add(this.radio_cq); + this.TabPage3.Controls.Add(this.radio_avgBitrate); + this.TabPage3.Controls.Add(this.radio_targetFilesize); this.TabPage3.Controls.Add(this.drp_videoEncoder); this.TabPage3.Controls.Add(this.Label47); this.TabPage3.Controls.Add(this.label25); this.TabPage3.Controls.Add(this.check_turbo); - this.TabPage3.Controls.Add(this.Label22); this.TabPage3.Controls.Add(this.check_2PassEncode); this.TabPage3.Controls.Add(this.Label2); this.TabPage3.Controls.Add(this.text_filesize); - this.TabPage3.Controls.Add(this.Label42); this.TabPage3.Controls.Add(this.slider_videoQuality); this.TabPage3.Controls.Add(this.text_bitrate); - this.TabPage3.Controls.Add(Label38); this.TabPage3.Controls.Add(this.SliderValue); this.TabPage3.Controls.Add(this.Label46); - this.TabPage3.Controls.Add(this.Label40); this.TabPage3.Controls.Add(this.drp_videoFramerate); this.TabPage3.Location = new System.Drawing.Point(4, 22); this.TabPage3.Name = "TabPage3"; @@ -1890,6 +1876,41 @@ namespace Handbrake this.TabPage3.Text = "Video"; this.TabPage3.UseVisualStyleBackColor = true; // + // radio_cq + // + this.radio_cq.AutoSize = true; + this.radio_cq.Location = new System.Drawing.Point(336, 97); + this.radio_cq.Name = "radio_cq"; + this.radio_cq.Size = new System.Drawing.Size(125, 17); + this.radio_cq.TabIndex = 18; + this.radio_cq.Text = "Constant Quality:"; + this.radio_cq.UseVisualStyleBackColor = true; + this.radio_cq.CheckedChanged += new System.EventHandler(this.radio_cq_CheckedChanged); + // + // radio_avgBitrate + // + this.radio_avgBitrate.AutoSize = true; + this.radio_avgBitrate.Checked = true; + this.radio_avgBitrate.Location = new System.Drawing.Point(336, 64); + this.radio_avgBitrate.Name = "radio_avgBitrate"; + this.radio_avgBitrate.Size = new System.Drawing.Size(135, 17); + this.radio_avgBitrate.TabIndex = 17; + this.radio_avgBitrate.TabStop = true; + this.radio_avgBitrate.Text = "Avg Bitrate (kbps):"; + this.radio_avgBitrate.UseVisualStyleBackColor = true; + this.radio_avgBitrate.CheckedChanged += new System.EventHandler(this.radio_avgBitrate_CheckedChanged); + // + // radio_targetFilesize + // + this.radio_targetFilesize.AutoSize = true; + this.radio_targetFilesize.Location = new System.Drawing.Point(336, 37); + this.radio_targetFilesize.Name = "radio_targetFilesize"; + this.radio_targetFilesize.Size = new System.Drawing.Size(126, 17); + this.radio_targetFilesize.TabIndex = 16; + this.radio_targetFilesize.Text = "Target Size (MB):"; + this.radio_targetFilesize.UseVisualStyleBackColor = true; + this.radio_targetFilesize.CheckedChanged += new System.EventHandler(this.radio_targetFilesize_CheckedChanged); + // // label25 // this.label25.AutoSize = true; @@ -1901,23 +1922,12 @@ namespace Handbrake this.label25.TabIndex = 0; this.label25.Text = "Video"; // - // Label22 - // - this.Label22.AutoSize = true; - this.Label22.BackColor = System.Drawing.Color.Transparent; - this.Label22.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label22.Location = new System.Drawing.Point(13, 118); - this.Label22.Name = "Label22"; - this.Label22.Size = new System.Drawing.Size(191, 13); - this.Label22.TabIndex = 4; - this.Label22.Text = "Advanced Encoding Settings"; - // // check_2PassEncode // this.check_2PassEncode.AutoSize = true; this.check_2PassEncode.BackColor = System.Drawing.Color.Transparent; this.check_2PassEncode.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.check_2PassEncode.Location = new System.Drawing.Point(16, 145); + this.check_2PassEncode.Location = new System.Drawing.Point(125, 100); this.check_2PassEncode.Name = "check_2PassEncode"; this.check_2PassEncode.Size = new System.Drawing.Size(119, 17); this.check_2PassEncode.TabIndex = 6; @@ -1936,23 +1946,12 @@ namespace Handbrake this.Label2.TabIndex = 8; this.Label2.Text = "Quality"; // - // Label42 - // - this.Label42.AutoSize = true; - this.Label42.BackColor = System.Drawing.Color.Transparent; - this.Label42.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label42.Location = new System.Drawing.Point(334, 65); - this.Label42.Name = "Label42"; - this.Label42.Size = new System.Drawing.Size(117, 13); - this.Label42.TabIndex = 9; - this.Label42.Text = "Avg Bitrate (kbps):"; - // // SliderValue // this.SliderValue.AutoSize = true; this.SliderValue.BackColor = System.Drawing.Color.Transparent; this.SliderValue.Font = new System.Drawing.Font("Verdana", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.SliderValue.Location = new System.Drawing.Point(641, 100); + this.SliderValue.Location = new System.Drawing.Point(480, 100); this.SliderValue.Name = "SliderValue"; this.SliderValue.Size = new System.Drawing.Size(23, 12); this.SliderValue.TabIndex = 15; @@ -1969,17 +1968,6 @@ namespace Handbrake this.Label46.TabIndex = 1; this.Label46.Text = "Framerate (FPS):"; // - // Label40 - // - this.Label40.AutoSize = true; - this.Label40.BackColor = System.Drawing.Color.Transparent; - this.Label40.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Label40.Location = new System.Drawing.Point(334, 99); - this.Label40.Name = "Label40"; - this.Label40.Size = new System.Drawing.Size(107, 13); - this.Label40.TabIndex = 13; - this.Label40.Text = "Constant Quality:"; - // // check_grayscale // this.check_grayscale.AutoSize = true; @@ -2307,48 +2295,6 @@ namespace Handbrake this.tab_Filters.Text = "Video Filters"; this.tab_Filters.UseVisualStyleBackColor = true; // - // ctl_deinterlace - // - this.ctl_deinterlace.AutoSize = true; - this.ctl_deinterlace.Location = new System.Drawing.Point(19, 95); - this.ctl_deinterlace.Margin = new System.Windows.Forms.Padding(0); - this.ctl_deinterlace.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_deinterlace.Name = "ctl_deinterlace"; - this.ctl_deinterlace.Size = new System.Drawing.Size(275, 28); - this.ctl_deinterlace.TabIndex = 41; - this.ctl_deinterlace.onChange += new System.EventHandler(this.ctl_deinterlace_changed); - // - // ctl_denoise - // - this.ctl_denoise.AutoSize = true; - this.ctl_denoise.Location = new System.Drawing.Point(19, 123); - this.ctl_denoise.Margin = new System.Windows.Forms.Padding(0); - this.ctl_denoise.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_denoise.Name = "ctl_denoise"; - this.ctl_denoise.Size = new System.Drawing.Size(275, 28); - this.ctl_denoise.TabIndex = 40; - // - // ctl_decomb - // - this.ctl_decomb.AutoSize = true; - this.ctl_decomb.Location = new System.Drawing.Point(19, 66); - this.ctl_decomb.Margin = new System.Windows.Forms.Padding(0); - this.ctl_decomb.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_decomb.Name = "ctl_decomb"; - this.ctl_decomb.Size = new System.Drawing.Size(275, 28); - this.ctl_decomb.TabIndex = 39; - this.ctl_decomb.onChange += new System.EventHandler(this.ctl_decomb_changed); - // - // ctl_detelecine - // - this.ctl_detelecine.AutoSize = true; - this.ctl_detelecine.Location = new System.Drawing.Point(19, 38); - this.ctl_detelecine.Margin = new System.Windows.Forms.Padding(0); - this.ctl_detelecine.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_detelecine.Name = "ctl_detelecine"; - this.ctl_detelecine.Size = new System.Drawing.Size(275, 28); - this.ctl_detelecine.TabIndex = 38; - // // tab_chapters // this.tab_chapters.BackColor = System.Drawing.Color.Transparent; @@ -2930,6 +2876,48 @@ namespace Handbrake this.lbl_encode.Size = new System.Drawing.Size(31, 17); this.lbl_encode.Text = "{0}"; // + // ctl_deinterlace + // + this.ctl_deinterlace.AutoSize = true; + this.ctl_deinterlace.Location = new System.Drawing.Point(19, 95); + this.ctl_deinterlace.Margin = new System.Windows.Forms.Padding(0); + this.ctl_deinterlace.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_deinterlace.Name = "ctl_deinterlace"; + this.ctl_deinterlace.Size = new System.Drawing.Size(275, 28); + this.ctl_deinterlace.TabIndex = 41; + this.ctl_deinterlace.onChange += new System.EventHandler(this.ctl_deinterlace_changed); + // + // ctl_denoise + // + this.ctl_denoise.AutoSize = true; + this.ctl_denoise.Location = new System.Drawing.Point(19, 123); + this.ctl_denoise.Margin = new System.Windows.Forms.Padding(0); + this.ctl_denoise.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_denoise.Name = "ctl_denoise"; + this.ctl_denoise.Size = new System.Drawing.Size(275, 28); + this.ctl_denoise.TabIndex = 40; + // + // ctl_decomb + // + this.ctl_decomb.AutoSize = true; + this.ctl_decomb.Location = new System.Drawing.Point(19, 66); + this.ctl_decomb.Margin = new System.Windows.Forms.Padding(0); + this.ctl_decomb.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_decomb.Name = "ctl_decomb"; + this.ctl_decomb.Size = new System.Drawing.Size(275, 28); + this.ctl_decomb.TabIndex = 39; + this.ctl_decomb.onChange += new System.EventHandler(this.ctl_decomb_changed); + // + // ctl_detelecine + // + this.ctl_detelecine.AutoSize = true; + this.ctl_detelecine.Location = new System.Drawing.Point(19, 38); + this.ctl_detelecine.Margin = new System.Windows.Forms.Padding(0); + this.ctl_detelecine.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_detelecine.Name = "ctl_detelecine"; + this.ctl_detelecine.Size = new System.Drawing.Size(275, 28); + this.ctl_detelecine.TabIndex = 38; + // // frmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -3035,16 +3023,13 @@ namespace Handbrake internal System.Windows.Forms.TabPage TabPage3; internal System.Windows.Forms.CheckBox check_largeFile; internal System.Windows.Forms.CheckBox check_turbo; - internal System.Windows.Forms.Label Label22; internal System.Windows.Forms.Label Label2; internal System.Windows.Forms.Label SliderValue; internal System.Windows.Forms.ComboBox drp_videoFramerate; internal System.Windows.Forms.CheckBox check_2PassEncode; internal System.Windows.Forms.TrackBar slider_videoQuality; internal System.Windows.Forms.TextBox text_filesize; - internal System.Windows.Forms.Label Label40; internal System.Windows.Forms.TextBox text_bitrate; - internal System.Windows.Forms.Label Label42; internal System.Windows.Forms.TabPage TabPage1; internal System.Windows.Forms.CheckBox Check_ChapterMarkers; internal System.Windows.Forms.Label Label1; @@ -3213,6 +3198,9 @@ namespace Handbrake internal Denoise ctl_denoise; internal Decomb ctl_decomb; internal Detelecine ctl_detelecine; + internal System.Windows.Forms.RadioButton radio_cq; + internal System.Windows.Forms.RadioButton radio_avgBitrate; + internal System.Windows.Forms.RadioButton radio_targetFilesize; } } \ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 98d99f4a0..c9224407d 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -966,8 +966,6 @@ namespace Handbrake } private void text_destination_TextChanged(object sender, EventArgs e) { - setAudioByContainer(text_destination.Text); - setVideoByContainer(text_destination.Text); string path = text_destination.Text; if (path.EndsWith(".mp4")) drop_format.SelectedIndex = 0; @@ -995,6 +993,9 @@ namespace Handbrake setExtension(".avi"); else if (drop_format.SelectedIndex == 4) setExtension(".ogm"); + + setAudioByContainer(drop_format.Text); + setVideoByContainer(drop_format.Text); } private void setExtension(string newExtension) { @@ -1045,27 +1046,99 @@ namespace Handbrake check_iPodAtom.Enabled = false; check_iPodAtom.Checked = false; } - + + // Setup the CQ Slider + switch (drp_videoEncoder.Text) + { + case "MPEG-4 (FFmpeg)": + slider_videoQuality.Minimum = 1; + slider_videoQuality.Maximum = 31; + slider_videoQuality.Value = 1; + SliderValue.Text = "0% QP: 31.00"; + break; + case "MPEG-4 (XviD)": + slider_videoQuality.Minimum = 1; + slider_videoQuality.Maximum = 31; + slider_videoQuality.Value = 1; + SliderValue.Text = "0% QP: 31.00"; + break; + case "H.264 (x264)": + slider_videoQuality.Minimum = 0; + double tickFreq; + double.TryParse(Properties.Settings.Default.x264cqstep, out tickFreq); + tickFreq = 1/tickFreq; + int freq; + int.TryParse(Math.Round(tickFreq).ToString(), out freq); + slider_videoQuality.Maximum = (51 * freq); + slider_videoQuality.TickFrequency = 1; + slider_videoQuality.Value = 0; + SliderValue.Text = "0% RF: 51.00"; + break; + case "VP3 (Theora)": + slider_videoQuality.Minimum = 0; + slider_videoQuality.Maximum = 63; + slider_videoQuality.Value = 0; + SliderValue.Text = "0% QP: 0.00"; + break; + } } - private void text_bitrate_TextChanged(object sender, EventArgs e) + + private void slider_videoQuality_Scroll(object sender, EventArgs e) { - text_filesize.Text = ""; - slider_videoQuality.Value = 0; - SliderValue.Text = "0%"; + switch (drp_videoEncoder.Text) + { + case "MPEG-4 (FFmpeg)": + float rfValue = 31 - (slider_videoQuality.Value -1); + float max = slider_videoQuality.Maximum; + float min = slider_videoQuality.Minimum; + float val = ((max - min) - (rfValue - min)) / (max - min); + SliderValue.Text = Math.Round((val * 100), 2) + "% QP:" + (32 - slider_videoQuality.Value); + break; + case "MPEG-4 (XviD)": + rfValue = 31 - (slider_videoQuality.Value - 1); + max = slider_videoQuality.Maximum; + min = slider_videoQuality.Minimum; + val = ((max - min) - (rfValue - min)) / (max - min); + SliderValue.Text = Math.Round((val * 100), 2) + "% QP:" + (32 - slider_videoQuality.Value); + break; + case "H.264 (x264)": + float divided; + float.TryParse(Properties.Settings.Default.x264cqstep, out divided); + rfValue = 51 - slider_videoQuality.Value*divided; + max = slider_videoQuality.Maximum * divided; + min = slider_videoQuality.Minimum; + val = ((max - min) - (rfValue - min)) / (max - min); + SliderValue.Text = Math.Round((val * 100), 2) + "% RF:" + (51 - slider_videoQuality.Value * divided); + break; + case "VP3 (Theora)": + rfValue = slider_videoQuality.Value; + float value = rfValue/63; + SliderValue.Text = Math.Round((value * 100), 2) + "% QP:" + slider_videoQuality.Value; + break; + } + } + private void radio_targetFilesize_CheckedChanged(object sender, EventArgs e) + { + text_bitrate.Enabled = false; + text_filesize.Enabled = true; + slider_videoQuality.Enabled = false; + check_2PassEncode.Enabled = true; } - private void text_filesize_TextChanged(object sender, EventArgs e) + private void radio_avgBitrate_CheckedChanged(object sender, EventArgs e) { - text_bitrate.Text = ""; - slider_videoQuality.Value = 0; - SliderValue.Text = "0%"; + text_bitrate.Enabled = true; + text_filesize.Enabled = false; + slider_videoQuality.Enabled = false; + check_2PassEncode.Enabled = true; } - private void slider_videoQuality_Scroll(object sender, EventArgs e) + private void radio_cq_CheckedChanged(object sender, EventArgs e) { - SliderValue.Text = slider_videoQuality.Value + "%"; - text_bitrate.Text = ""; - text_filesize.Text = ""; + text_bitrate.Enabled = false; + text_filesize.Enabled = false; + slider_videoQuality.Enabled = true; + check_2PassEncode.Enabled = false; check_2PassEncode.CheckState = CheckState.Unchecked; } @@ -1756,7 +1829,7 @@ namespace Handbrake { string oldval; - if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v"))) + if ((path.Contains("MP4")) || (path.Contains("M4V"))) { oldval = drp_audenc_1.Text; drp_audenc_1.Items.Clear(); @@ -1766,7 +1839,7 @@ namespace Handbrake drp_audenc_1.SelectedIndex = 0; } - else if (path.EndsWith(".avi")) + else if (path.Contains("AVI")) { oldval = drp_audenc_1.Text; drp_audenc_1.Items.Clear(); @@ -1776,14 +1849,14 @@ namespace Handbrake drp_audenc_1.SelectedIndex = 0; } - else if (path.EndsWith(".ogm")) + else if (path.Contains("OGM")) { drp_audenc_1.Items.Clear(); drp_audenc_1.Items.Add("Vorbis"); drp_audenc_1.SelectedIndex = 0; } - else if (path.EndsWith(".mkv")) + else if (path.Contains("MKV")) { drp_audenc_1.Items.Clear(); drp_audenc_1.Items.Add("AAC"); @@ -1805,7 +1878,7 @@ namespace Handbrake { string oldval; - if ((path.EndsWith(".mp4")) || (path.EndsWith(".m4v"))) + if ((path.Contains("MP3")) || (path.Contains("M4V"))) { oldval = drp_videoEncoder.Text; drp_videoEncoder.Items.Clear(); @@ -1818,7 +1891,7 @@ namespace Handbrake drp_videoEncoder.Text = oldval; } - else if (path.EndsWith(".avi")) + else if (path.Contains("AVI")) { oldval = drp_videoEncoder.Text; drp_videoEncoder.Items.Clear(); @@ -1830,7 +1903,7 @@ namespace Handbrake else drp_videoEncoder.Text = oldval; } - else if (path.EndsWith(".ogm")) + else if (path.Contains("OGM")) { oldval = drp_videoEncoder.Text; drp_videoEncoder.Items.Clear(); @@ -1842,7 +1915,7 @@ namespace Handbrake else drp_videoEncoder.Text = oldval; } - else if (path.EndsWith(".mkv")) + else if (path.Contains("MKV")) { oldval = drp_videoEncoder.Text; drp_videoEncoder.Items.Clear(); @@ -2097,6 +2170,7 @@ namespace Handbrake #endregion + // This is the END of the road ------------------------------------------------------------------------------ } diff --git a/win/C#/frmMain.resx b/win/C#/frmMain.resx index dddbeb31b..00fd53019 100644 --- a/win/C#/frmMain.resx +++ b/win/C#/frmMain.resx @@ -117,9 +117,6 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - False - 977, 15 diff --git a/win/C#/frmMain/PresetLoader.cs b/win/C#/frmMain/PresetLoader.cs index 1d7472358..c7b50366e 100644 --- a/win/C#/frmMain/PresetLoader.cs +++ b/win/C#/frmMain/PresetLoader.cs @@ -144,12 +144,12 @@ namespace Handbrake if (mainWindow.ctl_decomb.getDropValue == "Off") mainWindow.ctl_deinterlace.setOption(presetQuery.DeInterlace); - else + else mainWindow.ctl_deinterlace.setOption("None"); // Don't want decomb and deinterlace on at the same time mainWindow.ctl_denoise.setOption(presetQuery.DeNoise); mainWindow.ctl_detelecine.setOption(presetQuery.DeTelecine); - + if (presetQuery.DeBlock != 0) { mainWindow.slider_deblock.Value = presetQuery.DeBlock; @@ -164,13 +164,45 @@ namespace Handbrake // 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) + if (presetQuery.AverageVideoBitrate != null) + { + mainWindow.radio_avgBitrate.Checked = true; + mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate; + } + if (presetQuery.VideoTargetSize != null) { - int ql = presetQuery.VideoQuality; - mainWindow.SliderValue.Text = ql + "%"; + mainWindow.radio_targetFilesize.Checked = true; + mainWindow.text_filesize.Text = presetQuery.VideoTargetSize; + } + + // Quality + if (presetQuery.VideoQuality != 0) + { + mainWindow.radio_cq.Checked = true; + if (presetQuery.VideoEncoder == "H.264 (x264)") + { + int value; + float presetValue, calculated, x264step; + float.TryParse(presetQuery.VideoQuality.ToString(), out presetValue); + float.TryParse(Properties.Settings.Default.x264cqstep, out x264step); + + float x = 51 / x264step; + + calculated = presetValue / x264step; + calculated = x - calculated; + + //TODO: Handle cases where it can't parse a value due to the float being too lage. + // when used with .33 and .2 and 1.0 for example. + int.TryParse(calculated.ToString(), out value); + + mainWindow.slider_videoQuality.Value = value; + } + else + { + int presetVal; + int.TryParse(presetQuery.VideoQuality.ToString(), out presetVal); + mainWindow.slider_videoQuality.Value = presetVal; + } } if (presetQuery.TwoPass) diff --git a/win/C#/frmMain/QueryGenerator.cs b/win/C#/frmMain/QueryGenerator.cs index 738bb2503..4dabd2433 100644 --- a/win/C#/frmMain/QueryGenerator.cs +++ b/win/C#/frmMain/QueryGenerator.cs @@ -197,19 +197,38 @@ namespace Handbrake query += " -g "; // Video Settings - if (mainWindow.text_bitrate.Text != "") + if (mainWindow.radio_avgBitrate.Checked) query += " -b " + mainWindow.text_bitrate.Text; - if (mainWindow.text_filesize.Text != "") + if (mainWindow.radio_targetFilesize.Checked) query += " -S " + mainWindow.text_filesize.Text; // Video Quality Setting - double videoQuality = mainWindow.slider_videoQuality.Value; - if (videoQuality != 0) + if (mainWindow.radio_cq.Checked) { - videoQuality = videoQuality / 100; - query += " -q " + videoQuality.ToString(new CultureInfo("en-US")); - } + float value; + switch (mainWindow.drp_videoEncoder.Text) + { + case "MPEG-4 (FFmpeg)": + value = 31 - (mainWindow.slider_videoQuality.Value -1); + query += " -q " + value.ToString(new CultureInfo("en-US")); + break; + case "MPEG-4 (XviD)": + value = 31 - (mainWindow.slider_videoQuality.Value - 1); + query += " -q " + value.ToString(new CultureInfo("en-US")); + break; + case "H.264 (x264)": + float divided; + float.TryParse(Properties.Settings.Default.x264cqstep, out divided); + value = 51 - mainWindow.slider_videoQuality.Value * divided; + query += " -q " + value.ToString(new CultureInfo("en-US")); + break; + case "VP3 (Theora)": + value = mainWindow.slider_videoQuality.Value; + query += " -q " + value.ToString(new CultureInfo("en-US")); + break; + } + } if (mainWindow.check_2PassEncode.Checked) query += " -2 "; diff --git a/win/C#/frmOptions.Designer.cs b/win/C#/frmOptions.Designer.cs index 5dd7247d8..7c13e91c6 100644 --- a/win/C#/frmOptions.Designer.cs +++ b/win/C#/frmOptions.Designer.cs @@ -113,6 +113,9 @@ namespace Handbrake this.label26 = new System.Windows.Forms.Label(); this.label27 = new System.Windows.Forms.Label(); this.openFile_vlc = new System.Windows.Forms.OpenFileDialog(); + this.label28 = new System.Windows.Forms.Label(); + this.drop_x264step = new System.Windows.Forms.ComboBox(); + this.label30 = new System.Windows.Forms.Label(); this.tab_options.SuspendLayout(); this.tab_general.SuspendLayout(); this.tab_picture.SuspendLayout(); @@ -595,6 +598,9 @@ namespace Handbrake // // tab_advanced // + this.tab_advanced.Controls.Add(this.label30); + this.tab_advanced.Controls.Add(this.drop_x264step); + this.tab_advanced.Controls.Add(this.label28); this.tab_advanced.Controls.Add(this.check_queryEditorTab); this.tab_advanced.Controls.Add(this.lbl_appcastUnstable); this.tab_advanced.Controls.Add(this.check_mainMinimize); @@ -1044,6 +1050,44 @@ namespace Handbrake this.openFile_vlc.DefaultExt = "exe"; this.openFile_vlc.Filter = "exe|*.exe"; // + // label28 + // + this.label28.AutoSize = true; + this.label28.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label28.Location = new System.Drawing.Point(27, 142); + this.label28.Name = "label28"; + this.label28.Size = new System.Drawing.Size(43, 13); + this.label28.TabIndex = 85; + this.label28.Text = "x264:"; + // + // drop_x264step + // + this.drop_x264step.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.drop_x264step.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.drop_x264step.FormattingEnabled = true; + this.drop_x264step.Items.AddRange(new object[] { + "1.0", + "0.50", + "0.33", + "0.25", + "0.20"}); + this.drop_x264step.Location = new System.Drawing.Point(312, 139); + this.drop_x264step.Name = "drop_x264step"; + this.drop_x264step.Size = new System.Drawing.Size(111, 21); + this.drop_x264step.TabIndex = 86; + this.ToolTip.SetToolTip(this.drop_x264step, "The number of processor\'s / processor cores. Unless your having problems, leave o" + + "n Automatic."); + this.drop_x264step.SelectedIndexChanged += new System.EventHandler(this.x264step_SelectedIndexChanged); + // + // label30 + // + this.label30.AutoSize = true; + this.label30.Location = new System.Drawing.Point(76, 142); + this.label30.Name = "label30"; + this.label30.Size = new System.Drawing.Size(230, 13); + this.label30.TabIndex = 87; + this.label30.Text = "Constant Quality fractional granularity:\r\n"; + // // frmOptions // this.ClientSize = new System.Drawing.Size(514, 375); @@ -1153,5 +1197,8 @@ namespace Handbrake private System.Windows.Forms.Label lbl_appcastUnstable; internal System.Windows.Forms.CheckBox check_mainMinimize; internal System.Windows.Forms.CheckBox check_queryEditorTab; + private System.Windows.Forms.Label label30; + internal System.Windows.Forms.ComboBox drop_x264step; + private System.Windows.Forms.Label label28; } } \ No newline at end of file diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs index e56dbe79e..d6ee3a3ef 100644 --- a/win/C#/frmOptions.cs +++ b/win/C#/frmOptions.cs @@ -113,6 +113,8 @@ namespace Handbrake // Enable snapshot updating if (Properties.Settings.Default.MainWindowMinimize == "Checked") check_mainMinimize.CheckState = CheckState.Checked; + + drop_x264step.SelectedItem = Properties.Settings.Default.x264cqstep; } #region General @@ -246,6 +248,12 @@ namespace Handbrake { Properties.Settings.Default.checkSnapshot = check_snapshot.CheckState.ToString(); } + + private void x264step_SelectedIndexChanged(object sender, EventArgs e) + { + Properties.Settings.Default.x264cqstep = drop_x264step.Text; + } + #endregion private void btn_close_Click(object sender, EventArgs e) @@ -253,5 +261,7 @@ namespace Handbrake Properties.Settings.Default.Save(); // Small hack for Vista. Seems to work fine on XP without this this.Close(); } + + } } \ No newline at end of file