summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorsr55 <[email protected]>2009-08-10 19:59:27 +0000
committersr55 <[email protected]>2009-08-10 19:59:27 +0000
commitfd88b574a2d980491a693e6d8747669a8507a031 (patch)
treef7b40af800e0a046bcfaea195ae1da9117068b50 /win
parent79e381141a579d027f8f37aa992b9c2a710dd20c (diff)
WinGui:
- Changing the CQ step for the quality slider when using x264 no longer requires a program restart. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2760 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win')
-rw-r--r--win/C#/Functions/PresetLoader.cs7
-rw-r--r--win/C#/Functions/QueryGenerator.cs5
-rw-r--r--win/C#/Properties/Settings.Designer.cs4
-rw-r--r--win/C#/Properties/Settings.settings2
-rw-r--r--win/C#/frmMain.cs62
-rw-r--r--win/C#/frmOptions.Designer.cs6
-rw-r--r--win/C#/frmOptions.cs18
7 files changed, 84 insertions, 20 deletions
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs
index 136641474..4345f6f9a 100644
--- a/win/C#/Functions/PresetLoader.cs
+++ b/win/C#/Functions/PresetLoader.cs
@@ -151,8 +151,10 @@ namespace Handbrake.Functions
mainWindow.radio_cq.Checked = true;
if (presetQuery.VideoEncoder == "H.264 (x264)")
{
+ double cqStep;
+ double.TryParse(Properties.Settings.Default.x264cqstep, out cqStep);
int value;
- double x264step = Properties.Settings.Default.x264cqstep;
+ double x264step = cqStep;
double presetValue = presetQuery.VideoQuality;
double x = 51 / x264step;
@@ -169,7 +171,8 @@ namespace Handbrake.Functions
double val = Math.Round(calculated, 0);
int.TryParse(val.ToString(), out value);
}
- mainWindow.slider_videoQuality.Value = value;
+ if (value < mainWindow.slider_videoQuality.Maximum)
+ mainWindow.slider_videoQuality.Value = value;
}
else
{
diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs
index 42b962541..b67dfa918 100644
--- a/win/C#/Functions/QueryGenerator.cs
+++ b/win/C#/Functions/QueryGenerator.cs
@@ -192,6 +192,9 @@ namespace Handbrake.Functions
// Video Quality Setting
if (mainWindow.radio_cq.Checked)
{
+ double cqStep;
+ double.TryParse(Properties.Settings.Default.x264cqstep, out cqStep);
+
double value;
switch (mainWindow.drp_videoEncoder.Text)
{
@@ -201,7 +204,7 @@ namespace Handbrake.Functions
break;
case "H.264 (x264)":
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
- value = 51 - mainWindow.slider_videoQuality.Value * Properties.Settings.Default.x264cqstep;
+ value = 51 - mainWindow.slider_videoQuality.Value * cqStep;
value = Math.Round(value, 2);
query += " -q " + value.ToString(culture);
break;
diff --git a/win/C#/Properties/Settings.Designer.cs b/win/C#/Properties/Settings.Designer.cs
index 4cf46354c..b20cb37a9 100644
--- a/win/C#/Properties/Settings.Designer.cs
+++ b/win/C#/Properties/Settings.Designer.cs
@@ -302,9 +302,9 @@ namespace Handbrake.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0.25")]
- public double x264cqstep {
+ public string x264cqstep {
get {
- return ((double)(this["x264cqstep"]));
+ return ((string)(this["x264cqstep"]));
}
set {
this["x264cqstep"] = value;
diff --git a/win/C#/Properties/Settings.settings b/win/C#/Properties/Settings.settings
index 0f9c5ffb0..7bb901bc9 100644
--- a/win/C#/Properties/Settings.settings
+++ b/win/C#/Properties/Settings.settings
@@ -71,7 +71,7 @@
<Setting Name="QueryEditorTab" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
- <Setting Name="x264cqstep" Type="System.Double" Scope="User">
+ <Setting Name="x264cqstep" Type="System.String" Scope="User">
<Value Profile="(Default)">0.25</Value>
</Setting>
<Setting Name="verboseLevel" Type="System.Int32" Scope="User">
diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs
index 584764f88..91fb789c8 100644
--- a/win/C#/frmMain.cs
+++ b/win/C#/frmMain.cs
@@ -343,7 +343,7 @@ namespace Handbrake
}
private void mnu_options_Click(object sender, EventArgs e)
{
- Form options = new frmOptions();
+ Form options = new frmOptions(this);
options.ShowDialog();
}
#endregion
@@ -1153,7 +1153,9 @@ namespace Handbrake
slider_videoQuality.TickFrequency = 1;
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
- double multiplier = 1.0 / Properties.Settings.Default.x264cqstep;
+ double cqStep;
+ double.TryParse(Properties.Settings.Default.x264cqstep, out cqStep);
+ double multiplier = 1.0 / cqStep;
double value = slider_videoQuality.Value * multiplier;
switch (Properties.Settings.Default.x264cqstep.ToString(culture))
@@ -1165,7 +1167,7 @@ namespace Handbrake
slider_videoQuality.Maximum = 204;
break;
case "0.50":
- slider_videoQuality.Maximum = 40;
+ slider_videoQuality.Maximum = 102;
break;
case "1.0":
slider_videoQuality.Maximum = 51;
@@ -1207,8 +1209,58 @@ namespace Handbrake
check_iPodAtom.Checked = false;
}
}
+ private string _cachedCqStep = Properties.Settings.Default.x264cqstep;
+ /// <summary>
+ /// Update the CQ slider for x264 for a new CQ step. This is set from option
+ /// </summary>
+ public void setQualityFromSlider()
+ {
+ // Work out the current RF value.
+ double cqStep;
+ double.TryParse(_cachedCqStep, out cqStep);
+ double rfValue = 51.0 - slider_videoQuality.Value * cqStep;
+
+ // Change the maximum value for the slider
+ CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
+ switch (Properties.Settings.Default.x264cqstep.ToString(culture))
+ {
+ case "0.20":
+ slider_videoQuality.Maximum = 255;
+ break;
+ case "0.25":
+ slider_videoQuality.Maximum = 204;
+ break;
+ case "0.50":
+ slider_videoQuality.Maximum = 102;
+ break;
+ case "1.0":
+ slider_videoQuality.Maximum = 51;
+ break;
+ default:
+ slider_videoQuality.Maximum = 51;
+ break;
+ }
+
+ // Reset the CQ slider to RF0
+ slider_videoQuality.Value = slider_videoQuality.Maximum;
+
+ // Reset the CQ slider back to the previous value as close as possible
+ double cqStepNew;
+ double.TryParse(Properties.Settings.Default.x264cqstep, out cqStepNew);
+ double rfValueCurrent = 51.0 - slider_videoQuality.Value * cqStepNew;
+ while (rfValueCurrent < rfValue)
+ {
+ slider_videoQuality.Value--;
+ rfValueCurrent = 51.0 - slider_videoQuality.Value * cqStepNew;
+ }
+
+ // Cache the CQ step for the next calculation
+ _cachedCqStep = Properties.Settings.Default.x264cqstep;
+ }
private void slider_videoQuality_Scroll(object sender, EventArgs e)
{
+ double cqStep;
+ double.TryParse(Properties.Settings.Default.x264cqstep, out cqStep);
switch (drp_videoEncoder.Text)
{
case "MPEG-4 (FFmpeg)":
@@ -1219,8 +1271,8 @@ namespace Handbrake
SliderValue.Text = Math.Round((val * 100), 2) + "% QP:" + (32 - slider_videoQuality.Value);
break;
case "H.264 (x264)":
- rfValue = 51.0 - slider_videoQuality.Value * Properties.Settings.Default.x264cqstep;
- max = slider_videoQuality.Maximum * Properties.Settings.Default.x264cqstep;
+ rfValue = 51.0 - slider_videoQuality.Value * cqStep;
+ max = slider_videoQuality.Maximum * cqStep;
min = slider_videoQuality.Minimum;
val = ((max - min) - (rfValue - min)) / (max - min);
rfValue = Math.Round(rfValue, 2);
diff --git a/win/C#/frmOptions.Designer.cs b/win/C#/frmOptions.Designer.cs
index ec7065e5f..92c9cff63 100644
--- a/win/C#/frmOptions.Designer.cs
+++ b/win/C#/frmOptions.Designer.cs
@@ -1019,7 +1019,7 @@ namespace Handbrake
"0.50",
"0.25",
"0.20"});
- this.drop_x264step.Location = new System.Drawing.Point(358, 184);
+ this.drop_x264step.Location = new System.Drawing.Point(262, 184);
this.drop_x264step.Name = "drop_x264step";
this.drop_x264step.Size = new System.Drawing.Size(85, 21);
this.drop_x264step.TabIndex = 86;
@@ -1034,9 +1034,9 @@ namespace Handbrake
this.tableLayoutPanel4.SetColumnSpan(this.label30, 2);
this.label30.Location = new System.Drawing.Point(67, 188);
this.label30.Name = "label30";
- this.label30.Size = new System.Drawing.Size(285, 13);
+ this.label30.Size = new System.Drawing.Size(189, 13);
this.label30.TabIndex = 87;
- this.label30.Text = "Constant quality fractional granularity (Requires Restart):\r\n";
+ this.label30.Text = "Constant quality fractional granularity";
//
// btn_drive_detect
//
diff --git a/win/C#/frmOptions.cs b/win/C#/frmOptions.cs
index 66adf04e4..0206d1ca3 100644
--- a/win/C#/frmOptions.cs
+++ b/win/C#/frmOptions.cs
@@ -14,9 +14,13 @@ namespace Handbrake
{
public partial class frmOptions : Form
{
- public frmOptions()
+ private frmMain mainWindow;
+
+ public frmOptions(frmMain mw)
{
InitializeComponent();
+ mainWindow = mw;
+
IDictionary<string, string> langList = Main.mapLanguages();
foreach (string item in langList.Keys)
drop_preferredLang.Items.Add(item);
@@ -155,7 +159,8 @@ namespace Handbrake
// x264 step
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
- drop_x264step.SelectedItem = Properties.Settings.Default.x264cqstep.ToString(culture);
+ string test = Properties.Settings.Default.x264cqstep.ToString(culture);
+ drop_x264step.SelectedItem = test;
// Use Experimental dvdnav
if (Properties.Settings.Default.dvdnav)
@@ -370,18 +375,19 @@ namespace Handbrake
switch (drop_x264step.SelectedIndex)
{
case 0:
- Properties.Settings.Default.x264cqstep = 1.0;
+ Properties.Settings.Default.x264cqstep = "1.0";
break;
case 1:
- Properties.Settings.Default.x264cqstep = 0.50;
+ Properties.Settings.Default.x264cqstep = "0.50";
break;
case 2:
- Properties.Settings.Default.x264cqstep = 0.25;
+ Properties.Settings.Default.x264cqstep = "0.25";
break;
case 3:
- Properties.Settings.Default.x264cqstep = 0.20;
+ Properties.Settings.Default.x264cqstep = "0.20";
break;
}
+ mainWindow.setQualityFromSlider();
}
private void check_dvdnav_CheckedChanged(object sender, EventArgs e)