Author: ArcRiley
Date: 2007-07-07 08:34:37 -0400 (Sat, 07 Jul 2007)
New Revision: 403
Modified:
trunk/pysoy/src/textures/Video.pxi
Log:
small optimizations, still taking ~6 times longer for YUV420->RGB8 than theora
decode
Modified: trunk/pysoy/src/textures/Video.pxi
===================================================================
--- trunk/pysoy/src/textures/Video.pxi 2007-07-07 11:15:04 UTC (rev 402)
+++ trunk/pysoy/src/textures/Video.pxi 2007-07-07 12:34:37 UTC (rev 403)
@@ -24,11 +24,12 @@
'''
cdef int _load(self, void *data) :
cdef int x, y, _cx, _cy, _tx, _ty, _yl, _yc
- cdef float _py, _pu, _pv, _pr, _pg, _pb
+ cdef int _py, _pu, _pv, _pr, _pg, _pb
cdef ogg.ogg_page *_page
cdef ogg.yuv_buffer _yuv
cdef ogg.ogg_packet _packet
cdef timeval _tv
+ cdef double _start # for benchmarking
if data == NULL :
stdio.printf('done?\n')
if self._stage > 0 :
@@ -86,6 +87,8 @@
# yl/yc = yuv l/c offsets
#
# This can and should be optimized further
+ #gettimeofday(&_tv, NULL)
+ #_start = _tv.tv_sec + ( <double> _tv.tv_usec / 1000000.0 )
_cx = self._info.frame_width
_cy = self._info.frame_height
for y from 0 <= y < _cy :
@@ -95,21 +98,29 @@
for x from 0 <= x < _cx :
_tx = (_ty + x) * 3
_py = _yuv.y[_yl + x]
- _pu = _yuv.u[_yc + (x/2)]
- _pv = _yuv.v[_yc + (x/2)]
- _pr = _py + ((<float> 1.370705) * (_pv-128))
- _pg = _py - ((<float> 0.698001) * (_pv-128)) \
- - ((<float> 0.337633) * (_pu-128))
- _pb = _py + ((<float> 1.732446) * (_pu-128))
- if _pr < 0 : _pr = 0
- if _pg < 0 : _pg = 0
- if _pb < 0 : _pb = 0
- if _pr > 255 : _pr = 255
- if _pg > 255 : _pg = 255
- if _pb > 255 : _pb = 255
- self._texels[_tx ] = <gl.GLubyte> _pr
- self._texels[_tx+1] = <gl.GLubyte> _pg
- self._texels[_tx+2] = <gl.GLubyte> _pb
+ _pu = _yuv.u[_yc + (x/2)] - 128
+ _pv = _yuv.v[_yc + (x/2)] - 128
+ _pr = <int> (_py + ((<float> 1.402) * _pv))
+ if _pr < 0 :
+ _pr = 0
+ if _pr > 255 :
+ _pr = 255
+ self._texels[_tx ] = _pr
+ _pg = <int> (_py - ((<float> 0.714) * _pv) \
+ - ((<float> 0.344) * _pu))
+ if _pg < 0 :
+ _pg = 0
+ if _pg > 255 :
+ _pg = 255
+ self._texels[_tx+1] = _pg
+ _pb = <int> (_py + ((<float> 1.772) * _pu))
+ if _pb < 0 :
+ _pb = 0
+ if _pb > 255 :
+ _pb = 255
+ self._texels[_tx+2] = _pb
+ #gettimeofday(&_tv, NULL)
+ #stdio.printf('%f\n', (_tv.tv_sec + ( <double> _tv.tv_usec / 1000000.0
))- _start)
self._update = 1
return 1
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn