From 9748a13268d66a5949aebc970637b5903756d018 Mon Sep 17 00:00:00 2001 From: Jonathan Thomas Date: Thu, 7 Oct 2021 13:53:09 -0500 Subject: [PATCH] Support for previewing anamorphic video profiles, including a few code clean-ups. --- src/windows/video_widget.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/windows/video_widget.py b/src/windows/video_widget.py index 7326598d34..842deb3ba0 100644 --- a/src/windows/video_widget.py +++ b/src/windows/video_widget.py @@ -77,28 +77,20 @@ def changed(self, action): if action.type == "load" and action.values.get("pixel_ratio"): pixel_ratio_changed = True self.pixel_ratio = openshot.Fraction( - action.values.get("pixel_ratio").get("num", 16), - action.values.get("pixel_ratio").get("den", 9)) + action.values.get("pixel_ratio").get("num", 1), + action.values.get("pixel_ratio").get("den", 1)) log.info( "Set video widget pixel aspect ratio to: %s", self.pixel_ratio.ToFloat()) elif action.key and action.key[0] == "pixel_ratio": pixel_ratio_changed = True self.pixel_ratio = openshot.Fraction( - action.values.get("num", 16), - action.values.get("den", 9)) + action.values.get("num", 1), + action.values.get("den", 1)) log.info( "Update: Set video widget pixel aspect ratio to: %s", self.pixel_ratio.ToFloat()) - # Update max size (to size of video preview viewport) - if display_ratio_changed or pixel_ratio_changed: - timeline = get_app().window.timeline_sync.timeline - timeline.SetMaxSize( - round(self.width() * self.pixel_ratio.ToFloat()), - round(self.height() * self.pixel_ratio.ToFloat()) - ) - def drawTransformHandler(self, painter, sx, sy, source_width, source_height, origin_x, origin_y, x1=None, y1=None, x2=None, y2=None, rotation = None): @@ -236,7 +228,7 @@ def paintEvent(self, event, *args): # Determine original size of clip's reader source_width = self.transforming_clip.data['reader']['width'] source_height = self.transforming_clip.data['reader']['height'] - source_size = QSize(source_width, source_height) + source_size = QSize(source_width, source_height * self.pixel_ratio.Reciprocal().ToDouble()) # Determine scale of clip scale = self.transforming_clip.data['scale'] @@ -405,7 +397,7 @@ def paintEvent(self, event, *args): self.mutex.unlock() def centeredViewport(self, width, height): - """ Calculate size of viewport to maintain apsect ratio """ + """ Calculate size of viewport to maintain aspect ratio """ # Calculate padding top_padding = (height - (height * self.zoom)) / 2.0 @@ -416,7 +408,7 @@ def centeredViewport(self, width, height): height = height * self.zoom # Calculate which direction to scale (for perfect centering) - aspectRatio = self.aspect_ratio.ToFloat() * self.pixel_ratio.ToFloat() + aspectRatio = self.aspect_ratio.ToFloat() heightFromWidth = width / aspectRatio widthFromHeight = height * aspectRatio