[pitivi] check: Change get_square_width to return an int value
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] check: Change get_square_width to return an int value
- Date: Tue, 10 Apr 2018 20:48:29 +0000 (UTC)
commit 766193642f927917df3dd738525b17848e5e5f14
Author: Alexandru Băluț <alexandru balut gmail com>
Date: Fri Apr 6 06:56:31 2018 +0200
check: Change get_square_width to return an int value
pitivi/check.py | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/pitivi/check.py b/pitivi/check.py
index 600472d4..845ef803 100644
--- a/pitivi/check.py
+++ b/pitivi/check.py
@@ -324,6 +324,22 @@ def require_version(modulename, version):
exit(1)
+def get_square_width(video_info):
+ """Applies the pixel aspect ratio to the width of the video info.
+
+ Args:
+ video_info (GstPbutils.DiscovererVideoInfo): The video info.
+
+ Returns:
+ int: The width calculated exactly as GStreamer does.
+ """
+ width = video_info.get_width()
+ par_num = video_info.get_par_num()
+ par_denom = video_info.get_par_denom()
+ # We observed GStreamer does a simple int(), so we leave it like this.
+ return int(width * par_num / par_denom)
+
+
def initialize_modules():
"""Initializes the modules.
@@ -361,10 +377,9 @@ def initialize_modules():
require_version("GstPbutils", GST_API_VERSION)
from gi.repository import GstPbutils
- # Monky patch an helper method to retrieve the size of a video
+ # Monky patch a helper method for retrieving the size of a video
# when using square pixels.
- GstPbutils.DiscovererVideoInfo.get_square_width = \
- lambda i: i.get_width() * i.get_par_num() / i.get_par_denom()
+ GstPbutils.DiscovererVideoInfo.get_square_width = get_square_width
if not os.environ.get("GES_DISCOVERY_TIMEOUT"):
os.environ["GES_DISCOVERY_TIMEOUT"] = "5"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]