[pitivi: 1/10] really take into account the thumbnail aspect ratio



commit 099aebde243d3c5dbb9b73351a8919a277b48c8f
Author: Brandon Lewis <brandon_lewis berkeley edu>
Date:   Sat Mar 28 09:41:15 2009 -0700

    really take into account the thumbnail aspect ratio
---
 pitivi/ui/previewer.py |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/pitivi/ui/previewer.py b/pitivi/ui/previewer.py
index 2e75ab3..f2319f8 100644
--- a/pitivi/ui/previewer.py
+++ b/pitivi/ui/previewer.py
@@ -77,7 +77,12 @@ previewers = {}
 
 def get_preview_for_object(trackobject):
     factory = trackobject.factory
-    stream_ = trackobject.track.stream
+    for stream_ in factory.getOutputStreams():
+        if stream_.isCompatible(trackobject.track.stream):
+            break
+        stream_ = None
+    if not stream_:
+        raise NotImplementedError
     stream_type = type(stream_)
     key = factory, stream_
     if not key in previewers:
@@ -108,6 +113,8 @@ class Previewer(object, Signallable, Loggable):
 
     __DEFAULT_THUMB__ = "processing-clip.png"
 
+    aspect = 4.0 / 3.0
+
     def __init__(self, factory, stream_):
         Loggable.__init__(self)
         # create default thumbnail
@@ -152,9 +159,8 @@ class RandomAccessPreviewer(Previewer):
         caps = stream_.caps
         bin = SingleDecodeBin(uri=uri, caps=caps)
 
-        # assume 4:3 default aspect ratio, 50 pixel height
+        # assume 50 pixel height
         self.theight = 50
-        self.aspect = 4.0 / 3.0
         self.twidth = int(self.aspect * self.theight)
         self.spacing = instance.PiTiVi.settings.thumbnailSpacingHint
         self.waiting_timestamp = None
@@ -286,12 +292,11 @@ class RandomAccessPreviewer(Previewer):
 class RandomAccessVideoPreviewer(RandomAccessPreviewer):
 
     def __init__(self, factory, stream_):
+        if stream_.dar and stream_.par:
+            self.aspect = float(stream_.dar)
         RandomAccessPreviewer.__init__(self, factory, stream_)
-        if stream_.width and stream_.height:
-            self.aspect = stream_.width / stream_.height
 
     def _pipelineInit(self, factory, sbin):
-
         csp = gst.element_factory_make("ffmpegcolorspace")
         sink = CairoSurfaceThumbnailSink()
         scale = gst.element_factory_make("videoscale")



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]