diff options
author | sr55 <[email protected]> | 2009-06-08 16:18:38 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2009-06-08 16:18:38 +0000 |
commit | ba55f4a2f3c85a600231223d2912d9afcada00f8 (patch) | |
tree | f2f71219b0d7b8155ea29afb59c9976e97a7c041 | |
parent | 8c2ee7ae989974d9cd64d853e3c82acb55d4a4ab (diff) |
WinGui:
- Fixes some crashes in the new picture settings panel and hooks up the presetLoader and query parser so they work with the new options.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2502 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/C#/Controls/PictureSettings.Designer.cs | 22 | ||||
-rw-r--r-- | win/C#/Controls/PictureSettings.cs | 105 | ||||
-rw-r--r-- | win/C#/Functions/PresetLoader.cs | 19 | ||||
-rw-r--r-- | win/C#/Functions/QueryParser.cs | 55 | ||||
-rw-r--r-- | win/C#/frmTestWindow.cs | 5 |
5 files changed, 126 insertions, 80 deletions
diff --git a/win/C#/Controls/PictureSettings.Designer.cs b/win/C#/Controls/PictureSettings.Designer.cs index a5a79d85a..c033f7445 100644 --- a/win/C#/Controls/PictureSettings.Designer.cs +++ b/win/C#/Controls/PictureSettings.Designer.cs @@ -63,7 +63,7 @@ namespace Handbrake.Controls this.Label51 = new System.Windows.Forms.Label();
this.Label15 = new System.Windows.Forms.Label();
this.lbl_anamorphic = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
+ this.lbl_anamprohicLbl = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.text_height)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.text_width)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.crop_bottom)).BeginInit();
@@ -468,21 +468,21 @@ namespace Handbrake.Controls this.lbl_anamorphic.TabIndex = 74;
this.lbl_anamorphic.Text = "Select a Title";
//
- // label3
+ // lbl_anamprohicLbl
//
- this.label3.AutoSize = true;
- this.label3.BackColor = System.Drawing.Color.Transparent;
- this.label3.Location = new System.Drawing.Point(13, 221);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(66, 13);
- this.label3.TabIndex = 73;
- this.label3.Text = "Anamorphic:";
+ this.lbl_anamprohicLbl.AutoSize = true;
+ this.lbl_anamprohicLbl.BackColor = System.Drawing.Color.Transparent;
+ this.lbl_anamprohicLbl.Location = new System.Drawing.Point(13, 221);
+ this.lbl_anamprohicLbl.Name = "lbl_anamprohicLbl";
+ this.lbl_anamprohicLbl.Size = new System.Drawing.Size(66, 13);
+ this.lbl_anamprohicLbl.TabIndex = 73;
+ this.lbl_anamprohicLbl.Text = "Anamorphic:";
//
// PictureSettings
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.Controls.Add(this.lbl_anamorphic);
- this.Controls.Add(this.label3);
+ this.Controls.Add(this.lbl_anamprohicLbl);
this.Controls.Add(this.check_customCrop);
this.Controls.Add(this.check_autoCrop);
this.Controls.Add(this.crop_bottom);
@@ -563,7 +563,7 @@ namespace Handbrake.Controls internal System.Windows.Forms.TextBox txt_parHeight;
internal System.Windows.Forms.CheckBox check_KeepAR;
internal System.Windows.Forms.Label lbl_anamorphic;
- internal System.Windows.Forms.Label label3;
+ internal System.Windows.Forms.Label lbl_anamprohicLbl;
}
}
diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index 1563e8685..b9626f1d6 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -13,8 +13,6 @@ namespace Handbrake.Controls * - Code needs cleaned up and a ton of bugs probably need fixed.
*/
-
-
/*
* DISPLAY WIDTH STORAGE WIDTH PIXEL WIDTH
* HEIGHT KEEP ASPECT PIXEL HEIGHT
@@ -202,6 +200,7 @@ namespace Handbrake.Controls text_height.Text = heightVal.ToString();
check_KeepAR.Enabled = true;
lbl_anamorphic.Text = "";
+ lbl_anamprohicLbl.Visible = false;
break;
case 1: // Strict
text_height.BackColor = Color.LightGray;
@@ -214,17 +213,22 @@ namespace Handbrake.Controls check_KeepAR.Enabled = false;
disableCustomAnaControls();
lbl_anamorphic.Text = strictAnamorphic();
+ lbl_anamprohicLbl.Visible = true;
break;
case 2: // Loose
storageAspect = 0;
- text_width.Text = widthVal.ToString();
- text_height.Value = selectedTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value;
+ if (selectedTitle != null)
+ {
+ text_width.Value = selectedTitle.Resolution.Width - (int) crop_left.Value - (int) crop_right.Value;
+ text_height.Value = selectedTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value;
+ }
text_height.Enabled = false;
text_height.BackColor = Color.LightGray;
text_width.Enabled = true;
text_width.BackColor = Color.White;
disableCustomAnaControls();
lbl_anamorphic.Text = looseAnamorphic();
+ lbl_anamprohicLbl.Visible = true;
break;
case 3: // Custom
@@ -235,19 +239,22 @@ namespace Handbrake.Controls text_height.Enabled = true;
text_width.Enabled = true;
- // Actual Work
- text_width.Text = widthVal.ToString();
- text_height.Text = cacluateHeight(widthVal).ToString(); // Bug here
-
- txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
- txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
- txt_displayWidth.Text = displayWidth().ToString();
-
+ // Actual Work
+ if (selectedTitle != null)
+ {
+ widthVal = selectedTitle.Resolution.Width;
+ text_width.Text = widthVal.ToString();
+ text_height.Text = cacluateHeight(widthVal).ToString();
+ txt_parWidth.Text = selectedTitle.ParVal.Width.ToString();
+ txt_parHeight.Text = selectedTitle.ParVal.Height.ToString();
+ txt_displayWidth.Text = displayWidth().ToString();
+ }
+
darValue = calculateDar();
check_KeepAR.CheckState = CheckState.Checked;
check_KeepAR.Enabled = true;
-
+ lbl_anamprohicLbl.Visible = true;
break;
}
@@ -573,40 +580,45 @@ namespace Handbrake.Controls }
private int cacluateHeight(int width)
{
- int aw = 0;
- int ah = 0;
- if (selectedTitle.AspectRatio.ToString() == "1.78")
- {
- aw = 16;
- ah = 9;
- }
- else if (selectedTitle.AspectRatio.ToString() == "1.33")
- {
- aw = 4;
- ah = 3;
- }
-
- if (aw != 0)
+ if (selectedTitle != null)
{
- // Crop_Width = Title->Width - crop_Left - crop_right
- // Crop_Height = Title->Height - crop_top - crop_bottom
- double crop_width = selectedTitle.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value;
- double crop_height = selectedTitle.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value;
-
- double new_height = (width * selectedTitle.Resolution.Width * ah * crop_height) /
- (selectedTitle.Resolution.Height * aw * crop_width);
-
- if (drp_anamorphic.SelectedIndex == 3)
- new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);
- else
- new_height = getModulusAuto(16, new_height);
+ int aw = 0;
+ int ah = 0;
+ if (selectedTitle.AspectRatio.ToString() == "1.78")
+ {
+ aw = 16;
+ ah = 9;
+ }
+ else if (selectedTitle.AspectRatio.ToString() == "1.33")
+ {
+ aw = 4;
+ ah = 3;
+ }
- //16 * (421 / 16)
- //double z = ( 16 * (( y + 8 ) / 16 ) );
- int x = int.Parse(new_height.ToString());
- if (x < 64)
- x = 64;
- return x;
+ if (aw != 0)
+ {
+ // Crop_Width = Title->Width - crop_Left - crop_right
+ // Crop_Height = Title->Height - crop_top - crop_bottom
+ double crop_width = selectedTitle.Resolution.Width - (double) crop_left.Value -
+ (double) crop_right.Value;
+ double crop_height = selectedTitle.Resolution.Height - (double) crop_top.Value -
+ (double) crop_bottom.Value;
+
+ double new_height = (width*selectedTitle.Resolution.Width*ah*crop_height)/
+ (selectedTitle.Resolution.Height*aw*crop_width);
+
+ if (drp_anamorphic.SelectedIndex == 3)
+ new_height = getModulusAuto(int.Parse(drop_modulus.SelectedItem.ToString()), new_height);
+ else
+ new_height = getModulusAuto(16, new_height);
+
+ //16 * (421 / 16)
+ //double z = ( 16 * (( y + 8 ) / 16 ) );
+ int x = int.Parse(new_height.ToString());
+ if (x < 64)
+ x = 64;
+ return x;
+ }
}
return 0;
}
@@ -683,6 +695,9 @@ namespace Handbrake.Controls double hcalc = (actualWidth / storageAspect) + 0.5;
double newHeight = getModulusAuto(16, hcalc);
looseAnamorphicHeightGuard = true;
+
+ if (newHeight < 64)
+ newHeight = 64;
text_height.Value = (decimal)newHeight; // BUG Out of Range Exception with Width too low here.
// Calculate the anamorphic width
diff --git a/win/C#/Functions/PresetLoader.cs b/win/C#/Functions/PresetLoader.cs index 2434ad42a..dd5fa7c7d 100644 --- a/win/C#/Functions/PresetLoader.cs +++ b/win/C#/Functions/PresetLoader.cs @@ -99,16 +99,19 @@ namespace Handbrake.Functions mainWindow.pictureSettings.text_height.Text = presetQuery.Height.ToString();
}
- mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = presetQuery.Anamorphic ? 1 : 0;
+ // Set the anamorphic mode 0,1,2,3
+ mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = presetQuery.AnamorphicMode;
- if (presetQuery.LooseAnamorphic)
- mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = 2;
- else
- {
- if (presetQuery.Anamorphic != true)
- mainWindow.pictureSettings.drp_anamorphic.SelectedIndex = 0;
- }
+ // Custom Anamorphic Controls
+ mainWindow.pictureSettings.check_KeepAR.CheckState = presetQuery.keepDisplayAsect ? CheckState.Checked : CheckState.Unchecked;
+
+ mainWindow.pictureSettings.txt_displayWidth.Text = presetQuery.displayWidthValue.ToString();
+ mainWindow.pictureSettings.txt_parWidth.Text = presetQuery.pixelAspectWidth.ToString();
+ mainWindow.pictureSettings.txt_parHeight.Text = presetQuery.pixelAspectHeight.ToString();
+ mainWindow.pictureSettings.drop_modulus.SelectedItem = presetQuery.AnamorphicModulus;
+
+
// Set the public max width and max height varibles in frmMain
// These are used by the query generator to determine if it should use -X or -w / -Y or -h
if (presetQuery.MaxWidth != 0)
diff --git a/win/C#/Functions/QueryParser.cs b/win/C#/Functions/QueryParser.cs index ff621c625..659073adf 100644 --- a/win/C#/Functions/QueryParser.cs +++ b/win/C#/Functions/QueryParser.cs @@ -41,8 +41,12 @@ namespace Handbrake.Functions public string CropBottom { get; private set; }
public string CropLeft { get; private set; }
public string CropRight { get; private set; }
- public Boolean Anamorphic { get; private set; }
- public Boolean LooseAnamorphic { get; private set; }
+ public int AnamorphicMode { get; private set; }
+ public Boolean keepDisplayAsect { get; private set; }
+ public double displayWidthValue { get; private set; }
+ public int pixelAspectWidth { get; private set; }
+ public int pixelAspectHeight { get; private set; }
+ public int AnamorphicModulus { get; private set; }
#endregion
#region Video Filters
@@ -113,8 +117,15 @@ namespace Handbrake.Functions Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");
- Match lanamorphic = Regex.Match(input, @" -P");
- Match anamorphic = Regex.Match(input, @" -p ");
+
+ Match looseAnamorphic = Regex.Match(input, @"--loose-anamorphic");
+ Match strictAnamorphic = Regex.Match(input, @"--strict-anamorphic");
+ Match customAnamorphic = Regex.Match(input, @"--custom-anamorphic");
+
+ Match keepDisplayAsect = Regex.Match(input, @"--keep-display-aspect");
+ Match displayWidth = Regex.Match(input, @"--display-width ([0-9*])");
+ Match pixelAspect = Regex.Match(input, @"--pixel-aspect ([0-9]*):([0-9]*)");
+ Match modulus = Regex.Match(input, @"--modulus ([0-9*])");
// Picture Settings - Filters
Match decomb = Regex.Match(input, @" --decomb");
@@ -196,16 +207,16 @@ namespace Handbrake.Functions #region Picture Tab
if (width.Success)
- thisQuery.Width = int.Parse(width.ToString().Replace("-w ", ""));
-
+ thisQuery.Width = int.Parse(width.Groups[0].Value.Replace("-w ", ""));
+
if (height.Success)
- thisQuery.Height = int.Parse(height.ToString().Replace("-l ", ""));
+ thisQuery.Height = int.Parse(height.Groups[0].Value.Replace("-l ", ""));
if (maxWidth.Success)
- thisQuery.MaxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));
+ thisQuery.MaxWidth = int.Parse(maxWidth.Groups[0].Value.Replace("-X ", ""));
if (maxHeight.Success)
- thisQuery.MaxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));
+ thisQuery.MaxHeight = int.Parse(maxHeight.Groups[0].Value.Replace("-Y ", ""));
if (crop.Success)
{
@@ -217,8 +228,29 @@ namespace Handbrake.Functions thisQuery.CropRight = actCropValues[3];
}
- thisQuery.Anamorphic = anamorphic.Success;
- thisQuery.LooseAnamorphic = lanamorphic.Success;
+ if (strictAnamorphic.Success)
+ thisQuery.AnamorphicMode = 1;
+ else if (looseAnamorphic.Success)
+ thisQuery.AnamorphicMode = 2;
+ else if (customAnamorphic.Success)
+ thisQuery.AnamorphicMode = 3;
+ else
+ thisQuery.AnamorphicMode = 0;
+
+ thisQuery.keepDisplayAsect = keepDisplayAsect.Success;
+
+ if (displayWidth.Success)
+ thisQuery.displayWidthValue = double.Parse(displayWidth.Groups[0].Value.Replace("--display-width ", ""));
+
+ if (pixelAspect.Success)
+ thisQuery.pixelAspectWidth = int.Parse(pixelAspect.Groups[0].Value.Replace("--pixel-aspect ", ""));
+
+ if (pixelAspect.Success)
+ thisQuery.pixelAspectHeight = int.Parse(pixelAspect.Groups[1].Value.Replace("--pixel-aspect ", ""));
+
+ if (modulus.Success)
+ thisQuery.AnamorphicModulus = int.Parse(modulus.Groups[0].Value.Replace("--modulus ", ""));
+
#endregion
@@ -400,7 +432,6 @@ namespace Handbrake.Functions return thisQuery;
}
-
private static string getMixDown(string mixdown)
{
switch (mixdown.Trim())
diff --git a/win/C#/frmTestWindow.cs b/win/C#/frmTestWindow.cs index 1606a7724..a7dd567ba 100644 --- a/win/C#/frmTestWindow.cs +++ b/win/C#/frmTestWindow.cs @@ -49,10 +49,7 @@ namespace Handbrake.Functions rtf_testContent.Text += "Max Width: " + parsed.MaxWidth + Environment.NewLine;
if (parsed.MaxHeight != 0)
rtf_testContent.Text += "Max Height: " + parsed.MaxHeight + Environment.NewLine;
- if (parsed.Anamorphic)
- rtf_testContent.Text += "Anamorphic: " + parsed.Anamorphic + Environment.NewLine;
- if (parsed.LooseAnamorphic)
- rtf_testContent.Text += "Loose Anamorphic: " + parsed.LooseAnamorphic + Environment.NewLine;
+ rtf_testContent.Text += "Anamorphic Mode: " + parsed.AnamorphicMode + Environment.NewLine;
//Picture Settings - Filters
rtf_testContent.Text += Environment.NewLine + "## Filters " + Environment.NewLine;
|