[PATCH] Fixed width calculation after scan when KeepAR is on

Archive of historical development discussions
Discussions / Development has moved to GitHub
Forum rules
*******************************
Please be aware we are now using GitHub for issue tracking and feature requests.
- This section of the forum is now closed to new topics.

*******************************
Post Reply
patches11
Posts: 1
Joined: Wed Sep 02, 2009 4:02 am

[PATCH] Fixed width calculation after scan when KeepAR is on

Post by patches11 » Wed Sep 02, 2009 5:16 am

This fixes a crash I was having in one of my presets.

Code: Select all

Index: PictureSettings.cs
===================================================================
--- PictureSettings.cs	(revision 2798)
+++ PictureSettings.cs	(working copy)
@@ -67,10 +67,11 @@
                     labelDisplaySize.Text = CalculateAnamorphicSizes().Width + "x" + CalculateAnamorphicSizes().Height;
                 }
 
-                updownDisplayWidth.Value = CalculateAnamorphicSizes().Width;
+                var width = CalculateAnamorphicSizes().Width;
+                _cachedDar = (double)width / (double)text_height.Value;
+                updownDisplayWidth.Value = width;
                 updownParWidth.Value = _sourceTitle.ParVal.Width;
                 updownParHeight.Value = _sourceTitle.ParVal.Height;
-                _cachedDar = (double)updownDisplayWidth.Value / (double)text_height.Value;
             }
         }
When Keep Aspect Ratio is turned on and you load a video file, _cachedDar would be 0 when updownDisplayWidth.Value gets set, which fires an event that depends on the value of _cachedDar. The fix just sets _cachedDar before the property gets set.

ExDeus
Posts: 43
Joined: Mon Mar 02, 2009 7:13 am

Re: [PATCH] Fixed width calculation after scan when KeepAR is on

Post by ExDeus » Wed Sep 02, 2009 7:18 am

I was working on a fix for this, as well as a number of others (see http://forum.handbrake.fr/viewtopic.php?f=4&t=12119), as you posted this. Missed it.

I see you calculate the width with CalculateAnamorphicSizes(), then the DAR from that width and the source height, whereas I originally used the source DAR from the HB CLI.

I think we were both wrong. I think the DAR should, by definition, be based on the display width / display height, which is what is returned by CalculateAnamorphicSizes().

So really, _cachedDar should only be set once (no need to set it twice in that short span of time), and it should be set to CalculateAnamorphicSizes().Width / CalculateAnamorphicSizes().Height.

What do you think?

Patch at Pastebin: http://handbrake.fr/pastebin/pastebin.php?show=836

Post Reply