[pitivi] base: operation: Swap SmartVideoScale for videoscale and fix framerate of output



commit fff4c2e9fb4256db2157202f73f57dda28d5867c
Author: Robert Swain <robert swain collabora co uk>
Date:   Mon Jul 26 19:17:00 2010 +0200

    base: operation: Swap SmartVideoScale for videoscale and fix framerate of output
    
    The videoscale GStreamer element now has black border padding capability that
    is enabled through the add-borders property so the smartvideoscale calculations
    are no longer needed.
    
    Also, the framerate was not being affected to the videorate filter in the
    rendering branch of the pipeline.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=613416

 pitivi/elements/Makefile.am   |    1 -
 pitivi/elements/smartscale.py |  200 -----------------------------------------
 pitivi/factories/base.py      |   36 +++++---
 pitivi/factories/operation.py |    8 +-
 4 files changed, 27 insertions(+), 218 deletions(-)
---
diff --git a/pitivi/elements/Makefile.am b/pitivi/elements/Makefile.am
index 3192f40..225dab2 100644
--- a/pitivi/elements/Makefile.am
+++ b/pitivi/elements/Makefile.am
@@ -5,7 +5,6 @@ elements_PYTHON = 		\
 	arraysink.py 		\
 	mixer.py		\
 	singledecodebin.py 	\
-	smartscale.py		\
 	thumbnailsink.py 	\
 	videofade.py
 
diff --git a/pitivi/factories/base.py b/pitivi/factories/base.py
index 7a024ad..a6b003b 100644
--- a/pitivi/factories/base.py
+++ b/pitivi/factories/base.py
@@ -27,7 +27,6 @@ import gst
 
 from pitivi.log.loggable import Loggable
 from pitivi.elements.singledecodebin import SingleDecodeBin
-from pitivi.elements.smartscale import SmartVideoScale
 from pitivi.signalinterface import Signallable
 from pitivi.stream import match_stream_groups_map, AudioStream, VideoStream
 from pitivi.utils import formatPercent
@@ -347,12 +346,14 @@ class SourceFactory(ObjectFactory):
             del bin.ares
             del bin.arate
         elif hasattr(bin, "alpha"):
-            for elt in [bin.csp, bin.queue, bin.alpha]:
+            for elt in [bin.csp, bin.queue, bin.alpha, bin.capsfilter, bin.scale]:
                 elt.set_state(gst.STATE_NULL)
                 bin.remove(elt)
             del bin.queue
             del bin.csp
             del bin.alpha
+            del bin.capsfilter
+            del bin.scale
 
         if hasattr(bin, "ghostpad"):
             # singledecodebin found something on this pad
@@ -415,17 +416,19 @@ class SourceFactory(ObjectFactory):
                 b.csp = gst.element_factory_make("identity")
 
             b.alpha = gst.element_factory_make("alpha", "internal-alpha")
-            b.scale = SmartVideoScale()
-            b.scale.set_caps(self._filtercaps)
-            b.scale._computeAndSetValues()
+            b.scale = gst.element_factory_make("videoscale")
+            b.scale.props.add_borders = True
+            b.capsfilter = gst.element_factory_make("capsfilter")
+            self.setFilterCaps(self._filtercaps)
 
-            b.add(b.queue, b.scale, b.csp, b.alpha)
+            b.add(b.queue, b.scale, b.csp, b.alpha, b.capsfilter)
             gst.element_link_many(b.queue, b.csp, b.scale)
             if child_bin:
-                gst.element_link_many(b.scale, b.child, b.alpha)
+                gst.element_link_many(b.scale, b.child, b.alpha, b.capsfilter)
                 b.child.sync_state_with_parent()
             else:
-                gst.element_link_many(b.scale, b.alpha)
+                gst.element_link_many(b.scale, b.alpha, b.capsfilter)
+            b.capsfilter.sync_state_with_parent()
             b.scale.sync_state_with_parent()
             b.queue.sync_state_with_parent()
             b.csp.sync_state_with_parent()
@@ -449,11 +452,11 @@ class SourceFactory(ObjectFactory):
             pad.link(topbin.aconv.get_pad("sink"))
             topbin.ghostpad = gst.GhostPad("src", topbin.volume.get_pad("src"))
         elif hasattr(topbin, "alpha"):
-            for element in [topbin.queue, topbin.scale, topbin.csp, topbin.alpha]:
+            for element in [topbin.queue, topbin.scale, topbin.csp, topbin.alpha, topbin.capsfilter]:
                 element.sync_state_with_parent()
 
             pad.link(topbin.queue.get_pad("sink"))
-            topbin.ghostpad = gst.GhostPad("src", topbin.alpha.get_pad("src"))
+            topbin.ghostpad = gst.GhostPad("src", topbin.capsfilter.get_pad("src"))
         else:
             topbin.ghostpad = gst.GhostPad("src", pad)
 
@@ -482,11 +485,18 @@ class SourceFactory(ObjectFactory):
         raise AssertionError("source factories can't have input streams")
 
     def setFilterCaps(self, caps):
-        self._filtercaps = caps
+        caps_copy = gst.Caps(caps)
+        for structure in caps_copy:
+            # remove framerate as we don't adjust framerate here
+            if structure.has_key("framerate"):
+                del structure["framerate"]
+            # remove format as we will have converted to AYUV/ARGB
+            if structure.has_key("format"):
+                del structure["format"]
         for b in self.bins:
             if hasattr(b, "scale"):
-                b.scale.set_caps(caps)
-                b.scale._computeAndSetValues()
+                b.capsfilter.props.caps = caps_copy
+        self._filtercaps = caps_copy
 
 class SinkFactory(ObjectFactory):
     """
diff --git a/pitivi/factories/operation.py b/pitivi/factories/operation.py
index 6e37206..ee47117 100644
--- a/pitivi/factories/operation.py
+++ b/pitivi/factories/operation.py
@@ -22,7 +22,6 @@
 
 import gst
 from pitivi.factories.base import OperationFactory
-from pitivi.elements.smartscale import SmartVideoScale
 from pitivi.stream import AudioStream, VideoStream
 
 # FIXME: define a proper hierarchy
@@ -111,12 +110,13 @@ class VideoModifierFactory(StreamModifierFactory):
         b.add_pad(gsink)
 
         # if we have an output stream specified, we add a capsfilter
-        vscale = SmartVideoScale()
-        vscale.set_caps(self.output_streams[0].caps)
+        vscale = gst.element_factory_make("videoscale")
+        vscale.props.add_borders = True
         b.add(vscale)
         vrate.link(vscale)
         self.debug("output_streams:%d", len(self.output_streams))
-        if len(self.output_streams) and self.output_streams[0].caps.is_fixed():
+
+        if len(self.output_streams):
             idt = gst.element_factory_make("capsfilter")
             idt.props.caps = self.output_streams[0].caps
             b.add(idt)



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