Author: dmeyer
Date: Mon Jan  1 11:41:18 2007
New Revision: 2318

Modified:
   trunk/popcorn/src/backends/base.py
   trunk/popcorn/src/backends/gstreamer/child.py
   trunk/popcorn/src/backends/gstreamer/player.py
   trunk/popcorn/src/backends/mplayer/player.py
   trunk/popcorn/src/backends/xine/child.py
   trunk/popcorn/src/backends/xine/player.py
   trunk/popcorn/src/config.cxml
   trunk/popcorn/src/generic.py

Log:
change aspect ration handling, needs much more work

Modified: trunk/popcorn/src/backends/base.py
==============================================================================
--- trunk/popcorn/src/backends/base.py  (original)
+++ trunk/popcorn/src/backends/base.py  Mon Jan  1 11:41:18 2007
@@ -61,7 +61,6 @@
         self._state_object = STATE_IDLE
         self._window = None
         self._size = None
-        self._aspect = None
         self._config = config
         self._properties = properties
         self._instance_id = "popcorn-%d-%d" % (os.getpid(), 
self._instance_count)
@@ -156,14 +155,11 @@
         return self.state == STATE_PLAYING
 
 
-    def set_size(self, size, aspect=None):
+    def set_size(self, size):
         """
         Set a new output size.
         """
         self._size = size
-        self._aspect = aspect
-        if not aspect and size and size[0] and size[1]:
-            self._aspect = float(size[0]) / size[1]
 
 
     def get_size(self):
@@ -173,18 +169,18 @@
         return self._size
 
 
-    def set_aspect(self, aspect=None):
+    def _get_aspect(self):
         """
-        Set special output aspect ratio.
+        Get aspect ration values. Returns a tuple monitoraspect and a
+        tuple with the fullscreen pixel size.
         """
-        self._aspect = aspect
-
-
-    def get_aspect(self):
-        """
-        Get output aspect ratio.
-        """
-        return self._aspect
+        if not self._window:
+            raise AttributeError("No window set")
+        size = self._window.get_size()
+        if hasattr(self._window, 'get_display'):
+            size = self._window.get_display().get_size()
+        aspect = [ int(x) for x in self._config.monitoraspect.split(':') ]
+        return aspect, size
 
 
     def get_capabilities(self):

Modified: trunk/popcorn/src/backends/gstreamer/child.py
==============================================================================
--- trunk/popcorn/src/backends/gstreamer/child.py       (original)
+++ trunk/popcorn/src/backends/gstreamer/child.py       Mon Jan  1 11:41:18 2007
@@ -131,18 +131,10 @@
             vo.set_xwindow_id(long(kwargs.get('window')))
             vo.set_property('force-aspect-ratio', True)
 
-            # Aspect test code. We can't deal with float here,
-            # it has to be integer values. As input we need the
-            # screen resolution (window doesn't count) and the
-            # aspect of the monitor/tv this fullscreen is visible.
-            # fullscreen = 800, 600
-            # display_aspect = 16, 9
-            # 
-            # # calculations
-            # xaspect = display_aspect[0] * fullscreen[1]
-            # yaspect = display_aspect[1] * fullscreen[0]
-            # vo.set_property('pixel-aspect-ratio', '%s/%s' % (xaspect, 
yaspect))
-
+            a1 = kwargs.get('aspect')[0] * kwargs.get('size')[1]
+            a2 = kwargs.get('aspect')[1] * kwargs.get('size')[0]
+            print a1, a2
+            vo.set_property('pixel-aspect-ratio', '%s/%s' % (a1, a2))
             goom = gst.element_factory_make("goom", "goom0")
             self._gst.set_property('vis-plugin', goom)
         elif driver == 'none':

Modified: trunk/popcorn/src/backends/gstreamer/player.py
==============================================================================
--- trunk/popcorn/src/backends/gstreamer/player.py      (original)
+++ trunk/popcorn/src/backends/gstreamer/player.py      Mon Jan  1 11:41:18 2007
@@ -69,7 +69,9 @@
         self._state = STATE_OPENING
         self._gst.open(self._mrl)
         if self._window:
-            self._gst.configure_video('xv', window=self._window.get_id())
+            aspect, size = self._get_aspect()
+            self._gst.configure_video('xv', window=self._window.get_id(),
+                                      aspect=aspect, size=size)
         else:
             self._gst.configure_video('none')
         self._gst.configure_audio(self._config.audio.driver)

Modified: trunk/popcorn/src/backends/mplayer/player.py
==============================================================================
--- trunk/popcorn/src/backends/mplayer/player.py        (original)
+++ trunk/popcorn/src/backends/mplayer/player.py        Mon Jan  1 11:41:18 2007
@@ -385,73 +385,6 @@
         self._state = STATE_OPEN
 
 
-    def _scale(self, video_width, video_height, video_aspect, mode):
-        """
-        Scale the video to fit the window and respect the given aspects.
-        """
-        if not video_width or not video_height:
-            # one or more of the values is 0
-            log.error('invalid movie size: %sx%s', video_width, video_height)
-            return self._size
-
-        if not self._size:
-            # no size set
-            log.error('no window size specified')
-            return 0,0
-
-        win_width, win_height = self._size
-        if not win_width or not win_height:
-            # one or more of the values is 0
-            log.error('invalid window size: %sx%s', win_width, win_height)
-            return self._size
-
-        # 'scale' mode, ignore aspect, always fill the window
-        if mode == 'scale':
-            return self._size
-
-        # get window aspect
-        win_aspect = self._aspect
-        if not win_aspect:
-            log.info('calculate window aspect')
-            win_aspect = float(win_width) / win_height
-
-        if video_aspect:
-            log.info('calculate width on video aspect')
-            video_width = float(video_aspect * video_height)
-
-        aspect = float(win_aspect * win_height) / float(win_width)
-
-        s1 = (float(win_width) / video_width)
-        s2 = (float(win_height) / video_height)
-
-        for scaling, aspect_w, aspect_h in (s1, aspect, 1), (s1, 1, aspect), \
-                (s2, aspect, 1), (s2, 1, aspect):
-            width = int((video_width * scaling) / aspect_w)
-            height = int(video_height * scaling * aspect_h)
-            # adjust width and height if off by one
-            if width + 1 == win_width or width - 1 == win_width:
-                width = win_width
-            if height + 1 == win_height or height -1 == win_height:
-                height = win_height
-
-            # 'bar' mode: both values need to fit and at least one should match
-            if mode == 'bars' and width <= win_width and \
-                   height <= win_height and \
-                   (width == win_width or height == win_height):
-                log.info('scale video to %sx%s for %sx%s window',
-                         width, height, *self._size)
-                return width, height
-
-            # 'zoom' mode: one values as to fit, the other one can be larger
-            if mode == 'zoom' and width >= win_width and \
-                   height >= win_height and \
-                   (width == win_width or height == win_height):
-                log.info('scale video to %sx%s for %sx%s window',
-                         width, height, *self._size)
-                return width, height
-        raise RuntimeError('unable to scale video')
-
-
     def play(self):
         """
         Start playback.
@@ -466,33 +399,16 @@
         if 'outbuf' in self._mp_info['video_filters']:
             filters += ["outbuf=%s:yv12" % self._frame_shmkey]
 
-        if 0:
-            # Some test code to keep aspect when not using a sws. Mplayer
-            # always uses the full window, so we need to expand the video
-            # to match the window size aspect
-            win_w, win_h = self._size
-            vid_w = self._streaminfo.get('width')
-            vid_h = self._streaminfo.get('height')
-
-            a = float(win_h * vid_w) / (vid_h * win_w)
-            filters += [ "expand=%d:%d" % (vid_w, int(win_h * a)) ]
-
 
         if self._window:
-            # FIXME: check these calculations. What happens when
-            # monitoraspect is added?
-            scale =  self._scale(self._streaminfo.get('width'),
-                                 self._streaminfo.get('height'),
-                                 self._streaminfo.get('aspect'),
-                                 self._config.widescreen)
-            filters += [ "scale=%d:%d" % scale ]
-            if self._config.widescreen == 'zoom':
-                filters += [ "crop=%d:%d:%d:%d" % \
-                             (self._size[0], self._size[1],
-                              (scale[0] - self._size[0]) / 2,
-                              (scale[1] - self._size[1]) / 2 )]
-            filters += [ "expand=%d:%d" % self._size,
-                         "dsize=%d:%d" % self._size ]
+            # FIXME: add software scaler
+            # FIXME: add support for self._config.widescreen
+            aspect, size = self._get_aspect()
+
+            # FIXME: this only works if the window has the the aspect
+            # as the full screen
+            filters.append('expand=:::::%s/%s' % tuple(aspect))
+            filters.append('dsize=%s/%s' % size)
 
         # FIXME: check freevo filter list and add stuff like pp
 

Modified: trunk/popcorn/src/backends/xine/child.py
==============================================================================
--- trunk/popcorn/src/backends/xine/child.py    (original)
+++ trunk/popcorn/src/backends/xine/child.py    Mon Jan  1 11:41:18 2007
@@ -267,7 +267,9 @@
 
         f = self._vfilter.get("expand")
         if aspect:
-            f.set_parameters(aspect=aspect)
+            aspect, fullscreen = aspect
+            # FIXME: is this correct? What about the fullscreen size?
+            f.set_parameters(aspect=float(aspect[0])/aspect[1])
         f.set_parameters(enable_automatic_shift = True)
 
         if self._driver_control:

Modified: trunk/popcorn/src/backends/xine/player.py
==============================================================================
--- trunk/popcorn/src/backends/xine/player.py   (original)
+++ trunk/popcorn/src/backends/xine/player.py   Mon Jan  1 11:41:18 2007
@@ -219,7 +219,7 @@
                     self._xine.window_changed(window.get_id(), None, None, 
None)
                 elif self._xine_configured:
                     # No previous window, must reconfigure vo.
-                    self._xine.configure_video(window.get_id(), 
self.get_aspect())
+                    self._xine.configure_video(window.get_id(), 
self._get_aspect())
 
         # Sends a window_changed command to slave.
         if window and self._xine:
@@ -233,7 +233,7 @@
         self._xine_configured = True
         self._xine.set_config(self._config)
         if self._window:
-            self._xine.configure_video(self._window.get_id(), 
self.get_aspect())
+            self._xine.configure_video(self._window.get_id(), 
self._get_aspect())
         else:
             self._xine.configure_video(None, None)
         self._xine.configure_audio(self._config.audio.driver)

Modified: trunk/popcorn/src/config.cxml
==============================================================================
--- trunk/popcorn/src/config.cxml       (original)
+++ trunk/popcorn/src/config.cxml       Mon Jan  1 11:41:18 2007
@@ -26,6 +26,10 @@
         </desc>
     </var>
 
+    <var name="monitoraspect" default="4:3">
+        <desc>Aspect ratio of the monitor or tv.</desc>
+    </var>
+
     <group name="audio">
         <desc lang="en">audio settings</desc>
         <var name="driver" default="alsa">

Modified: trunk/popcorn/src/generic.py
==============================================================================
--- trunk/popcorn/src/generic.py        (original)
+++ trunk/popcorn/src/generic.py        Mon Jan  1 11:41:18 2007
@@ -83,7 +83,6 @@
         self._player = None
         self._media = ( None, None )
         self._size = (0,0)
-        self._aspect = None
         self.set_window(window)
 
         self._config = config
@@ -101,34 +100,6 @@
             'postprocessing': False,
             'software-scaler': True,
 
-            # The pixel-aspect-ratio is set for the output. If both
-            # the screen resolution and the physical resolution of the
-            # monitor / tv are the same, this has to be set to 1:1.
-            # For all other cases this needs to be calculated. Because
-            # kaa.popcorn may not know the real fullscreen resolution
-            # for same displays, simple settings for an aspect like
-            # 4:3 or 16:9 are not possible (and a window may have a
-            # different aspect ratio than the screen itself). And
-            # since a config should work with different X-Server
-            # resolutions this has to be a player property.
-            #
-            # An easy way to calculate this is to use
-            # a1 = display_aspect[0] * fullscreen[1]
-            # a2 = display_aspect[1] * fullscreen[0]
-            # set_property('%s:%s' % (a1, a2)
-            # with display_aspect as physical monitor aspect and
-            # fullscreen the maximum pixels.
-            # So for a 16:9 TV and a 800x600 screen the
-            # pixel-aspect-ratio is 16 * 600 : 9 * 800.
-            #
-            # An application like Freevo who knows the fullscreen size
-            # can offer a simpler way for the user to only provide the
-            # monitor aspect (4:3, 16:9, 15:9 and 15:10)
-            #
-            # Note: the value has to be a string with int values or
-            # gstreamer won't work.
-            'pixel-aspect-ratio': '1:1',
-
             # settings usefull for changing after a stream is
             # loaded.
             'deinterlace': 'auto',
@@ -176,7 +147,7 @@
         self._window = window
         if self._player:
             self._player.set_window(self._window)
-            self._player.set_size(self._size, self._aspect)
+            self._player.set_size(self._size)
 
 
     def _get_player_class(self, player=None):
@@ -304,7 +275,7 @@
         The real open function called from 'open'.
         """
         self._player.set_window(self._window)
-        self._player.set_size(self._size, self._aspect)
+        self._player.set_size(self._size)
         # FIXME: maybe give the whole media object to the child
         self._player.open(self._media[0])
         self.signals['open'].emit()
@@ -515,23 +486,13 @@
         return self._size
 
 
-    def set_size(self, size, aspect=None):
+    def set_size(self, size):
         """
         Set output size.
         """
         self._size = size
-        self._aspect = aspect
-        if self._player:
-            return self._player.set_size(size, aspect)
-
-
-    def set_aspect(self, aspect):
-        """
-        Set output aspect.
-        """
-        self._aspect = aspect
         if self._player:
-            return self._player.set_aspect(aspect)
+            return self._player.set_size(size)
 
 
     def set_property(self, prop, value):

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to