Author: ArcRiley
Date: 2007-07-07 06:33:20 -0400 (Sat, 07 Jul 2007)
New Revision: 400

Removed:
   trunk/pysoy/src/_internals/IndexTab.pxi
Modified:
   trunk/pysoy/src/_internals/Loadable.pxi
   trunk/pysoy/src/_internals/soy._internals.pxd
   trunk/pysoy/src/_internals/soy._internals.pyx
   trunk/pysoy/src/textures/Video.pxi
   trunk/pysoy/src/textures/soy.textures.pxd
   trunk/pysoy/src/transports/Transport.pxi
Log:
Video now runs at realtime (fix for #274)


Deleted: trunk/pysoy/src/_internals/IndexTab.pxi
===================================================================
--- trunk/pysoy/src/_internals/IndexTab.pxi     2007-07-07 09:58:16 UTC (rev 
399)
+++ trunk/pysoy/src/_internals/IndexTab.pxi     2007-07-07 10:33:20 UTC (rev 
400)
@@ -1,91 +0,0 @@
-# PySoy _internals.IndexTab class
-#
-# Copyright (C) 2007 Team PySoy
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-
-cdef class IndexTab :
-  '''PySoy Indexed Lookup Table
-
-     This is an extremely fast lookup table object.  It's really only useful
-     for C-level code.
-  '''
-  def __new__(self) :
-    self.size = 1
-    self.current = 0
-    self.list = <void **>py.PyMem_Malloc(sizeof(void *))
-
-  cdef void append(self, void *child) :
-    if self.size == self.current :
-      self.size = self.size * 2
-      self.list = <void **>py.PyMem_Realloc(self.list,
-                                                sizeof(void *)*(self.size))
-    self.list[self.current] = <void *>child
-    self.current = self.current + 1
-
-  cdef int index(self, void *child) :
-    cdef int i
-    for i from 0 <= i < self.current :
-      if self.list[i] == child :
-        return i
-    return -1
-
-  cdef void swap(self, int first, int second) :
-    cdef void *sibling
-    sibling = self.list[first]
-    self.list[first] = self.list[second]
-    self.list[second] = sibling
-
-  cdef void down(self, void *child) :
-    cdef int index
-    index = self.index(child)
-    if index > 0 :
-      self.swap(index, index-1)
-
-  cdef void up(self, void *child) :
-    cdef int index
-    index = self.index(child)
-    if index == -1 :
-      return  
-    if index < self.current-1 :
-      self.swap(index, index+1)
-
-  cdef void top(self, void *child) :
-    cdef int index
-    index = self.index(child)
-    if index == -1 :
-      return  
-    if index < self.current-1 :
-      self.swap(index, self.current-1)
-
-  cdef void bottom(self, void *child) :
-    cdef int index
-    index = self.index(child)
-    if index > 0 :
-      self.swap(index, 0)
-
-  cdef void remove(self, void *child) :
-    cdef int i
-    cdef int index
-    index = self.index(child)
-    if index == -1 :
-      return
-    for i from index <= i < (self.current-1) :
-      self.list[i] = self.list[i+1]
-    self.current = self.current - 1
-
-  def __dealloc__(self) :
-    py.PyMem_Free(self.list)

Modified: trunk/pysoy/src/_internals/Loadable.pxi
===================================================================
--- trunk/pysoy/src/_internals/Loadable.pxi     2007-07-07 09:58:16 UTC (rev 
399)
+++ trunk/pysoy/src/_internals/Loadable.pxi     2007-07-07 10:33:20 UTC (rev 
400)
@@ -27,3 +27,6 @@
 
   cdef int _save(self, void *data) :
     return 0
+
+  cdef int _ready(self) :
+    return 0

Modified: trunk/pysoy/src/_internals/soy._internals.pxd
===================================================================
--- trunk/pysoy/src/_internals/soy._internals.pxd       2007-07-07 09:58:16 UTC 
(rev 399)
+++ trunk/pysoy/src/_internals/soy._internals.pxd       2007-07-07 10:33:20 UTC 
(rev 400)
@@ -34,19 +34,7 @@
   cdef void   bottom  ( self, void* )
   cdef void   remove  ( self, void* )
 
-cdef class IndexTab :
-  cdef int    size
-  cdef int    current
-  cdef void **list
-  cdef void   append  ( self, void* )
-  cdef int    index   ( self, void* )
-  cdef void   swap    ( self, int, int )
-  cdef void   up      ( self, void* )
-  cdef void   down    ( self, void* )
-  cdef void   top     ( self, void* )
-  cdef void   bottom  ( self, void* )
-  cdef void   remove  ( self, void* )
-
 cdef class Loadable :
-  cdef int _load(self, void *data)
-  cdef int _save(self, void *data)
+  cdef int _load(self, void*)
+  cdef int _save(self, void*)
+  cdef int _ready(self)

Modified: trunk/pysoy/src/_internals/soy._internals.pyx
===================================================================
--- trunk/pysoy/src/_internals/soy._internals.pyx       2007-07-07 09:58:16 UTC 
(rev 399)
+++ trunk/pysoy/src/_internals/soy._internals.pyx       2007-07-07 10:33:20 UTC 
(rev 400)
@@ -27,5 +27,4 @@
 __version__ = 'Trunk (r'+'$Rev$'[6:-2]+')'
 
 include "Children.pxi"
-include "IndexTab.pxi"
 include "Loadable.pxi"

Modified: trunk/pysoy/src/textures/Video.pxi
===================================================================
--- trunk/pysoy/src/textures/Video.pxi  2007-07-07 09:58:16 UTC (rev 399)
+++ trunk/pysoy/src/textures/Video.pxi  2007-07-07 10:33:20 UTC (rev 400)
@@ -28,6 +28,7 @@
     cdef ogg.ogg_page   *_page
     cdef ogg.yuv_buffer  _yuv
     cdef ogg.ogg_packet  _packet
+    cdef timeval         _tv
     if data == NULL :
       stdio.printf('done?\n')
       if self._stage > 0 :
@@ -69,12 +70,15 @@
                            <float> self._info.aspect_denominator )
       else :
         ogg.theora_decode_init(&self._decode, &self._info)
+        gettimeofday(&_tv, NULL)
+        self._startTime = _tv.tv_sec + ( <double> _tv.tv_usec / 1000000.0 )
         self._stage = 2
     if self._stage == 2 :
       # Theora frames are 1:1 with Ogg packets, but packets != pages
       while ogg.ogg_stream_packetout(&self._stream, &_packet) :
         ogg.theora_decode_packetin(&self._decode, &_packet)
-        # _time=theora_granule_time(&self._decode, self._decode.granulepos)
+        self._frameTime = ogg.theora_granule_time(&self._decode, 
+                                              ogg.ogg_page_granulepos(_page))
         ogg.theora_decode_YUVout(&self._decode, &_yuv)
         #
         # cx/cy = chroma x/y due to 4:2:0
@@ -109,7 +113,19 @@
         self._update = 1
     return 1
 
+
   cdef int _save(self, void *data) :
     cdef ogg.ogg_page   *_page
     _page = <ogg.ogg_page *> data
     return 1
+
+  cdef int _ready(self) :
+    cdef timeval _tv
+    cdef double  _now
+    gettimeofday(&_tv, NULL)
+    _now = _tv.tv_sec + ( <double> _tv.tv_usec / 1000000.0 )
+    if self._startTime == 0.0 :
+      return 0
+    if self._frameTime == 0.0 or self._startTime + self._frameTime < _now :
+      return 1
+    return 0

Modified: trunk/pysoy/src/textures/soy.textures.pxd
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pxd   2007-07-07 09:58:16 UTC (rev 
399)
+++ trunk/pysoy/src/textures/soy.textures.pxd   2007-07-07 10:33:20 UTC (rev 
400)
@@ -55,3 +55,14 @@
   cdef ogg.theora_info      _info
   cdef ogg.theora_comment   _comment
   cdef ogg.theora_state     _decode
+  cdef double               _startTime
+  cdef double               _frameTime
+
+
+cdef extern from "sys/time.h" :
+  cdef struct timeval :
+    long int    tv_sec
+    long int    tv_usec
+  int gettimeofday (timeval *tv, void *tz )
+
+

Modified: trunk/pysoy/src/transports/Transport.pxi
===================================================================
--- trunk/pysoy/src/transports/Transport.pxi    2007-07-07 09:58:16 UTC (rev 
399)
+++ trunk/pysoy/src/transports/Transport.pxi    2007-07-07 10:33:20 UTC (rev 
400)
@@ -189,6 +189,8 @@
   cdef void _loadOgg(self) :
     cdef int i, _sn
     cdef ogg.ogg_page _page
+    if not (<soy._internals.Loadable> self._objs[0].object)._ready() :
+      return
     if self._readOggPage(&_page) :
       _sn = ogg.ogg_page_serialno(&_page)
       i = self._findSrno(_sn)

_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to