From 31f7fbe8dd16aa524a8e3675060423127956a3e9 Mon Sep 17 00:00:00 2001 From: sr55 Date: Tue, 25 Aug 2009 16:16:00 +0000 Subject: WinGui: - Fix several issues with Picture Settings panel related to aspect ration and resolution calculation. - Fix issue where file extension could be mp4 when chapters is enabled. Problem in the autoname function. - Fix a regex error in the appcast reader and make it more robust to errors. - Clear up changelog git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2776 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Changelog.html | 35 +++++--- win/C#/Controls/PictureSettings.cs | 159 +++++++++++++++++++------------------ win/C#/Functions/AppcastReader.cs | 26 +++--- win/C#/Functions/Main.cs | 4 +- win/C#/HandBrakeCS.csproj | 2 - win/C#/Parsing/Title.cs | 2 - win/C#/frmMain.cs | 8 +- 7 files changed, 126 insertions(+), 110 deletions(-) (limited to 'win') diff --git a/win/C#/Changelog.html b/win/C#/Changelog.html index 4151f9719..ae6d6c3ef 100644 --- a/win/C#/Changelog.html +++ b/win/C#/Changelog.html @@ -8,28 +8,41 @@ Windows Platform Specific Changlog.
-

Changes since Snapshot 1 - SVN2592

+

Changes Since Snapshot 2 - SVN2773

-

Major Changes

+

New Features

+ +

Minor Improvements / Changes

+ +

Fixed

+ - Fix several issues with Picture Settings panel related to aspect ration and resolution calculation.
+ - Fix issue where file extension could be mp4 when chapters is enabled. Problem in the autoname function.
+ - Fix a regex error in the appcast reader and make it more robust to errors.

+ + +

Changes since Snapshot 1 - SVN2592

+ +

New Features

- Added support for Growl for Windows.
- Import MacGUI presets.
- External SRT supported added.
+ - Added new options: preferred language, "Dub Foreign language audio" and "Use Foreign language audio and Subtitles"
+ - Import Chapter Markers from csv file

Minor Improvements / Changes

- Some UI layout changes / improvements
- - Added new options: preferred language, "Dub Foreign language audio" and "Use Foreign language audio and Subtitles"
- Remove M4v from format dropdown and add new option "Use iPod/iTunes friendly (.m4v) file extension for MP4
- - Chapter Markers tab now resets far less often. It should retain chapter names after being disabled / re-enabled
- - Chapter Markers tab now as import functionality. It can now import a csv file

Fixed

- - Re-written the Picture Settings Panel code so it should now work a lot better.
- - Issue where the GUI would error if the encode was stopped too quickly.
- - Numerous other fixes including: Quality slider resetting to 0 and other settings lost when a title change occurs.
- - Fixes some scaling / quality issues with QuickTime preview. Also added a possible fix for QT not working on 64bit systems.
- - Chaning the x264 Quality granularity now longer requires an application restart to work correctly
+ - Picture Settings now works correctly (including Custom Anamorphic).
+ - Error message when cancelling an encode within 2 seconds of it starting.
+ - Quality slider resetting to 0 and other settings lost when a title change occurs.
+ - Fixes some scaling / quality issues with QuickTime preview. + - Possible fix for QT not working on 64bit systems.
+ - Chaning the x264 Quality granularity no longer requires a restart to work correctly
+ - Chapter Markers tab now resets far less often. It should retain chapter names after being disabled / re-enabled
-

Changes since 0.9.3

+

Changes since 0.9.3

Major Changes

diff --git a/win/C#/Controls/PictureSettings.cs b/win/C#/Controls/PictureSettings.cs index e31b6824d..f9d322ba9 100644 --- a/win/C#/Controls/PictureSettings.cs +++ b/win/C#/Controls/PictureSettings.cs @@ -12,10 +12,10 @@ namespace Handbrake.Controls private readonly CultureInfo Culture = new CultureInfo("en-US", false); public event EventHandler PictureSettingsChanged; - private Boolean preventChangingWidth, preventChangingHeight, preventChangingCustom, preventChangingDisplayWidth; - private int _PresetMaximumWidth, _PresetMaximumHeight; - private double cachedDar; - private Title _SourceTitle; + private Boolean _preventChangingWidth, _preventChangingHeight, _preventChangingCustom, _preventChangingDisplayWidth; + private int _presetMaximumWidth, _presetMaximumHeight; + private double _cachedDar; + private Title _sourceTitle; public PictureSettings() { @@ -32,45 +32,45 @@ namespace Handbrake.Controls [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Title Source { - get { return _SourceTitle; } + private get { return _sourceTitle; } set { - _SourceTitle = value; - Enabled = _SourceTitle != null; + _sourceTitle = value; + Enabled = _sourceTitle != null; // Set the Aspect Ratio - lbl_Aspect.Text = _SourceTitle.AspectRatio.ToString(Culture); - lbl_src_res.Text = _SourceTitle.Resolution.Width + " x " + _SourceTitle.Resolution.Height; + lbl_Aspect.Text = _sourceTitle.AspectRatio.ToString(Culture); + lbl_src_res.Text = _sourceTitle.Resolution.Width + " x " + _sourceTitle.Resolution.Height; // Set the Recommended Cropping values - crop_top.Value = GetCropMod2Clean(_SourceTitle.AutoCropDimensions[0]); - crop_bottom.Value = GetCropMod2Clean(_SourceTitle.AutoCropDimensions[1]); - crop_left.Value = GetCropMod2Clean(_SourceTitle.AutoCropDimensions[2]); - crop_right.Value = GetCropMod2Clean(_SourceTitle.AutoCropDimensions[3]); + crop_top.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[0]); + crop_bottom.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[1]); + crop_left.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[2]); + crop_right.Value = GetCropMod2Clean(_sourceTitle.AutoCropDimensions[3]); // Set the Resolution Boxes if (drp_anamorphic.SelectedIndex == 0) { if (text_width.Value == 0) // Only update the values if the fields don't already have values. - text_width.Value = _SourceTitle.Resolution.Width; + text_width.Value = _sourceTitle.Resolution.Width; check_KeepAR.Checked = true; // Forces Resolution to be correct. } else { - if (text_width.Value == 0 && text_height.Value ==0)// Only update the values if the fields don't already have values. - { - text_width.Value = _SourceTitle.Resolution.Width; - text_height.Value = _SourceTitle.Resolution.Height - (int) crop_top.Value - (int) crop_bottom.Value; + if (text_width.Value == 0 && text_height.Value == 0)// Only update the values if the fields don't already have values. + { + text_width.Value = _sourceTitle.Resolution.Width; + text_height.Value = _sourceTitle.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value; } - labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height; + labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height; } - updownDisplayWidth.Value = calculateAnamorphicSizes().Width; - updownParWidth.Value = _SourceTitle.ParVal.Width; - updownParHeight.Value = _SourceTitle.ParVal.Height; - cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value; + updownDisplayWidth.Value = CalculateAnamorphicSizes().Width; + updownParWidth.Value = _sourceTitle.ParVal.Width; + updownParHeight.Value = _sourceTitle.ParVal.Height; + _cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value; } } @@ -82,11 +82,11 @@ namespace Handbrake.Controls [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public Size PresetMaximumResolution { - get { return new Size(_PresetMaximumWidth, _PresetMaximumHeight); } + get { return new Size(_presetMaximumWidth, _presetMaximumHeight); } set { - _PresetMaximumWidth = value.Width; - _PresetMaximumHeight = value.Height; + _presetMaximumWidth = value.Width; + _presetMaximumHeight = value.Height; if (value.Width != 0 && value.Height != 0) lbl_max.Text = "Max Width / Height"; @@ -102,7 +102,7 @@ namespace Handbrake.Controls // Picture Controls private void text_width_ValueChanged(object sender, EventArgs e) { - if (preventChangingWidth) + if (_preventChangingWidth) return; // Make sure the new value doesn't exceed the maximum @@ -115,28 +115,32 @@ namespace Handbrake.Controls case 0: if (check_KeepAR.Checked && Source != null) { - preventChangingHeight = true; + _preventChangingHeight = true; int width = (int)text_width.Value; - double crop_width = Source.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value; - double crop_height = Source.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value; - double newHeight = (width * Source.Resolution.Width * sourceAspect.Height * crop_height) / - (Source.Resolution.Height * sourceAspect.Width * crop_width); + double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value; + double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value; + + if (SourceAspect.Width == 0 && SourceAspect.Height == 0) + break; + + double newHeight = ((double)width * Source.Resolution.Width * SourceAspect.Height * crop_height) / + (Source.Resolution.Height * SourceAspect.Width * crop_width); text_height.Value = (decimal)GetModulusValue(newHeight); - preventChangingHeight = false; + _preventChangingHeight = false; } break; case 3: if (check_KeepAR.CheckState == CheckState.Unchecked && Source != null) { - if (preventChangingCustom) + if (_preventChangingCustom) break; - preventChangingDisplayWidth = true; + _preventChangingDisplayWidth = true; updownDisplayWidth.Value = text_width.Value * updownParWidth.Value / updownParHeight.Value; - preventChangingDisplayWidth = false; + _preventChangingDisplayWidth = false; labelDisplaySize.Text = Math.Truncate(updownDisplayWidth.Value) + "x" + text_height.Value; } @@ -148,15 +152,15 @@ namespace Handbrake.Controls } break; default: - labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height; + labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height; break; } - preventChangingWidth = false; + _preventChangingWidth = false; } private void text_height_ValueChanged(object sender, EventArgs e) { - if (preventChangingHeight) + if (_preventChangingHeight) return; if (Source != null) @@ -168,17 +172,17 @@ namespace Handbrake.Controls case 0: if (check_KeepAR.Checked && Source != null) { - preventChangingWidth = true; + _preventChangingWidth = true; - double crop_width = Source.Resolution.Width - (double)crop_left.Value - (double)crop_right.Value; - double crop_height = Source.Resolution.Height - (double)crop_top.Value - (double)crop_bottom.Value; + double crop_width = Source.Resolution.Width - (int)crop_left.Value - (int)crop_right.Value; + double crop_height = Source.Resolution.Height - (int)crop_top.Value - (int)crop_bottom.Value; - double new_width = ((double)text_height.Value * Source.Resolution.Height * sourceAspect.Width * crop_width) / - (Source.Resolution.Width * sourceAspect.Height * crop_height); + double new_width = ((double)text_height.Value * Source.Resolution.Height * SourceAspect.Width * crop_width) / + (Source.Resolution.Width * SourceAspect.Height * crop_height); text_width.Value = (decimal)GetModulusValue(new_width); - preventChangingWidth = false; + _preventChangingWidth = false; } break; case 3: @@ -191,26 +195,26 @@ namespace Handbrake.Controls // - Changes PIXEL HEIGHT to STORAGE WIDTH // DAR = DISPLAY WIDTH / DISPLAY HEIGHT (cache after every modification) - double rawCalculatedDisplayWidth = (double)text_height.Value * cachedDar; + double rawCalculatedDisplayWidth = (double)text_height.Value * _cachedDar; - preventChangingDisplayWidth = true; // Start Guards - preventChangingWidth = true; + _preventChangingDisplayWidth = true; // Start Guards + _preventChangingWidth = true; updownDisplayWidth.Value = (decimal)rawCalculatedDisplayWidth; updownParWidth.Value = updownDisplayWidth.Value; updownParHeight.Value = text_width.Value; - preventChangingWidth = false; // Reset Guards - preventChangingDisplayWidth = false; + _preventChangingWidth = false; // Reset Guards + _preventChangingDisplayWidth = false; } break; default: - labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height; + labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height; break; } - preventChangingHeight = false; + _preventChangingHeight = false; } private void check_KeepAR_CheckedChanged(object sender, EventArgs e) { @@ -231,15 +235,15 @@ namespace Handbrake.Controls } private void updownDisplayWidth_ValueChanged(object sender, EventArgs e) { - if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked) + if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Unchecked) { - preventChangingCustom = true; + _preventChangingCustom = true; updownParWidth.Value = updownDisplayWidth.Value; updownParHeight.Value = text_width.Value; - preventChangingCustom = false; + _preventChangingCustom = false; } - if (preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked) + if (_preventChangingDisplayWidth == false && check_KeepAR.CheckState == CheckState.Checked) { // - Changes HEIGHT to keep DAR // - Changes PIXEL WIDTH to new DISPLAY WIDTH @@ -250,15 +254,15 @@ namespace Handbrake.Controls int modulus = 16; int.TryParse(drp_modulus.SelectedItem.ToString(), out modulus); - int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / cachedDar); + int rawCalculatedHeight = (int)((int)updownDisplayWidth.Value / _cachedDar); int modulusHeight = rawCalculatedHeight - (rawCalculatedHeight % modulus); // Update value - preventChangingHeight = true; + _preventChangingHeight = true; text_height.Value = (decimal)modulusHeight; updownParWidth.Value = updownDisplayWidth.Value; updownParHeight.Value = text_width.Value; - preventChangingHeight = false; + _preventChangingHeight = false; } } @@ -273,7 +277,7 @@ namespace Handbrake.Controls text_height.Enabled = true; check_KeepAR.Enabled = true; - setCustomAnamorphicOptionsVisible(false); + SetCustomAnamorphicOptionsVisible(false); labelStaticDisplaySize.Visible = false; labelDisplaySize.Visible = false; @@ -289,7 +293,7 @@ namespace Handbrake.Controls text_height.Enabled = false; check_KeepAR.Enabled = false; - setCustomAnamorphicOptionsVisible(false); + SetCustomAnamorphicOptionsVisible(false); labelStaticDisplaySize.Visible = true; labelDisplaySize.Visible = true; drp_modulus.SelectedIndex = 0; @@ -301,7 +305,7 @@ namespace Handbrake.Controls text_height.Enabled = false; check_KeepAR.Enabled = false; - setCustomAnamorphicOptionsVisible(false); + SetCustomAnamorphicOptionsVisible(false); labelStaticDisplaySize.Visible = true; labelDisplaySize.Visible = true; drp_modulus.SelectedIndex = 0; @@ -313,7 +317,7 @@ namespace Handbrake.Controls text_height.Enabled = true; check_KeepAR.Enabled = true; - setCustomAnamorphicOptionsVisible(true); + SetCustomAnamorphicOptionsVisible(true); labelStaticDisplaySize.Visible = true; labelDisplaySize.Visible = true; @@ -321,7 +325,7 @@ namespace Handbrake.Controls break; } - labelDisplaySize.Text = calculateAnamorphicSizes().Width + "x" + calculateAnamorphicSizes().Height; + labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height; if (check_KeepAR.Checked) text_width_ValueChanged(this, new EventArgs()); @@ -331,14 +335,14 @@ namespace Handbrake.Controls } private void drp_modulus_SelectedIndexChanged(object sender, EventArgs e) { - preventChangingWidth = true; - preventChangingHeight = true; + _preventChangingWidth = true; + _preventChangingHeight = true; text_width.Value = (decimal)GetModulusValue((double)text_width.Value); text_height.Value = (decimal)GetModulusValue((double)text_height.Value); - preventChangingWidth = false; - preventChangingHeight = false; + _preventChangingWidth = false; + _preventChangingHeight = false; text_width.Increment = int.Parse(drp_modulus.SelectedItem.ToString()); text_height.Increment = int.Parse(drp_modulus.SelectedItem.ToString()); @@ -361,7 +365,7 @@ namespace Handbrake.Controls } // GUI Functions - private void setCustomAnamorphicOptionsVisible(bool visible) + private void SetCustomAnamorphicOptionsVisible(bool visible) { lbl_modulus.Visible = visible; lbl_displayWidth.Visible = visible; @@ -375,21 +379,17 @@ namespace Handbrake.Controls } // Calculation Functions - private Size sourceAspect + private Size SourceAspect { get { - if (Source != null) - { - if (Source.AspectRatio == 1.78F) - return new Size(16, 9); - if (Source.AspectRatio == 1.33F) - return new Size(4, 3); - } - return new Size(0, 0); + if (Source != null) // display aspect = (width * par_width) / (height * par_height) + return new Size((Source.ParVal.Width * Source.Resolution.Width), (Source.ParVal.Height * Source.Resolution.Height)); + + return new Size(0, 0); // Fall over to 16:9 and hope for the best } } - private Size calculateAnamorphicSizes() + private Size CalculateAnamorphicSizes() { if (Source != null) { @@ -410,6 +410,7 @@ namespace Handbrake.Controls double width, height; switch (drp_anamorphic.SelectedIndex) { + default: case 1: /* Strict anamorphic */ double displayWidth = ((double)cropped_width * Source.ParVal.Width / Source.ParVal.Height); diff --git a/win/C#/Functions/AppcastReader.cs b/win/C#/Functions/AppcastReader.cs index 861bd0bae..7f1e90b88 100644 --- a/win/C#/Functions/AppcastReader.cs +++ b/win/C#/Functions/AppcastReader.cs @@ -18,18 +18,24 @@ namespace Handbrake.Functions /// public void getInfo(string input) { - // Get the correct Appcast and set input. - XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input))); - string result = nodeItem.InnerXml; + try + { + // Get the correct Appcast and set input. + XmlNode nodeItem = readRss(new XmlTextReader(new StringReader(input))); + string result = nodeItem.InnerXml; - // Regular Expressions - Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\"""); - Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""([0-9].[0-9].[0-9]*)\"""); + // Regular Expressions + Match ver = Regex.Match(result, @"sparkle:version=""([0-9]*)\"""); + Match verShort = Regex.Match(result, @"sparkle:shortVersionString=""(([svn]*)([0-9.\s]*))\"""); - build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""); - version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", ""); - downloadFile = nodeItem["windows"].InnerText; - descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText); + build = ver.ToString().Replace("sparkle:version=", "").Replace("\"", ""); + version = verShort.ToString().Replace("sparkle:shortVersionString=", "").Replace("\"", ""); + downloadFile = nodeItem["windows"].InnerText; + descriptionUrl = new Uri(nodeItem["sparkle:releaseNotesLink"].InnerText); + } catch( Exception) + { + // Ignore Error. + } } /// diff --git a/win/C#/Functions/Main.cs b/win/C#/Functions/Main.cs index db127b261..55b95c4a8 100644 --- a/win/C#/Functions/Main.cs +++ b/win/C#/Functions/Main.cs @@ -124,7 +124,7 @@ namespace Handbrake.Functions /// Function which generates the filename and path automatically based on /// the Source Name, DVD title and DVD Chapters /// - public static string autoName(ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format) + public static string autoName(ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters) { string AutoNamePath = string.Empty; if (drpDvdtitle.Text != "Automatic") @@ -156,7 +156,7 @@ namespace Handbrake.Functions // Add the appropriate file extension if (format == 0) { - if (Properties.Settings.Default.useM4v) + if (Properties.Settings.Default.useM4v || chapters) destinationFilename += ".m4v"; else destinationFilename += ".mp4"; diff --git a/win/C#/HandBrakeCS.csproj b/win/C#/HandBrakeCS.csproj index 9cd0c7430..4c3a4f8c1 100644 --- a/win/C#/HandBrakeCS.csproj +++ b/win/C#/HandBrakeCS.csproj @@ -103,8 +103,6 @@ libraries\Growl.CoreLibrary.dll True - - diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index deee24ad0..9c44330f1 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -175,8 +175,6 @@ namespace Handbrake.Parsing @"^ \+ size: ([0-9]*)x([0-9]*), pixel aspect: ([0-9]*)/([0-9]*), display aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps"); //size: 720x576, pixel aspect: 16/15, display aspect: 1.33, 25.000 fps - - if (m.Success) { thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value)); diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 224c077c5..fb63ed229 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -69,12 +69,12 @@ namespace Handbrake DateTime lastCheck = Properties.Settings.Default.lastUpdateCheckDate; TimeSpan elapsed = now.Subtract(lastCheck); if (elapsed.TotalDays > Properties.Settings.Default.daysBetweenUpdateCheck) - { + { lblStatus.Text = "Checking for updates ..."; Application.DoEvents(); Main.BeginCheckForUpdates(new AsyncCallback(UpdateCheckDone), false); - } + } } // Setup the GUI components @@ -939,7 +939,7 @@ namespace Handbrake // Run the autoName & chapterNaming functions if (Properties.Settings.Default.autoNaming) { - string autoPath = Main.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, sourcePath, text_destination.Text, drop_format.SelectedIndex); + string autoPath = Main.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, sourcePath, text_destination.Text, drop_format.SelectedIndex, Check_ChapterMarkers.Checked); if (autoPath != null) text_destination.Text = autoPath; else @@ -1014,7 +1014,7 @@ namespace Handbrake // Run the Autonaming function if (Properties.Settings.Default.autoNaming) - text_destination.Text = Main.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, sourcePath, text_destination.Text, drop_format.SelectedIndex); + text_destination.Text = Main.autoName(drp_dvdtitle, drop_chapterStart.Text, drop_chapterFinish.Text, sourcePath, text_destination.Text, drop_format.SelectedIndex, Check_ChapterMarkers.Checked); // Disable chapter markers if only 1 chapter is selected. if (chapterStart == chapterEnd) -- cgit v1.2.3