Hi Chris,
I pushed a patch which fixes load.factor for Mac OS X. Basically on
OS X, libraries have similar names to Linux but the extension
is .dylib and not .so. I tested it with your test.ogg file; I'm
guessing it works, but it only displays one frame, which has a URL in
it; is this the same problem as on your slow laptop?
Also, closing the window doesn't stop playback; you need to implement
ungraft*.
I cleaned up yuv>rgb a little bit; it doesn't crash with the changed
code loaded but I wasn't able to really test it, because of the above
issue, so I'm not going to push a patch. Instead, here it is; you can
add it yourself if you're convinced it works:
------------------------------------------------------------------------
: clamp ( n -- n )
255 min 0 max ; inline
: stride ( line yuv -- uvy yy )
[ yuv_buffer-uv_stride swap 2/ * ] 2keep
yuv_buffer-y_stride * ; inline
: each-with4 ( obj obj obj obj seq quot -- )
4 each-withn ; inline
: compute-y ( yuv uvy yy x -- y )
+ nip swap yuv_buffer-y uchar-nth 16 - ; inline
: compute-v ( yuv uvy yy x -- v )
nip 2/ + swap yuv_buffer-u uchar-nth 128 - ; inline
: compute-u ( yuv uvy yy x -- v )
nip 2/ + swap yuv_buffer-v uchar-nth 128 - ; inline
: compute-yuv ( yuv uvy yy x -- y u v )
[ compute-y ] 4keep [ compute-u ] 4keep compute-v ; inline
: compute-blue ( y u v -- b )
drop 516 * 128 + swap 298 * + -8 shift clamp ; inline
: compute-green ( y u v -- g )
>r >r 298 * r> 100 * - r> 208 * - 128 + -8 shift clamp ;
inline
: compute-red ( y u v -- g )
nip 409 * swap 298 * + 128 + -8 shift clamp ; inline
: compute-rgb ( y u v -- b g r )
[ compute-blue ] 3keep [ compute-green ] 3keep compute-red ;
inline
: store-rgb ( index rgb b g r -- index )
>r >r pick pick set-uchar-nth
r> pick 1+ pick set-uchar-nth
r> pick 2 + pick set-uchar-nth
drop ; inline
: yuv>rgb-pixel ( index rgb yuv uvy yy x -- index )
compute-yuv compute-rgb store-rgb 3 + ; inline
: yuv>rgb-row ( index rgb yuv y -- index )
over stride
pick yuv_buffer-y_width
[ yuv>rgb-pixel ] each-with4 ; inline
: yuv>rgb ( rgb yuv -- )
0 -rot
dup yuv_buffer-y_height [ yuv>rgb-row ] each-with2
drop ;
------------------------------------------------------------------------
Basically, any time you're putting a stack comment in the middle of a
word, break that word up into two words at that location! This is all
I did to the above code. It is much cleaner now (but just as slow).
And 5keep is gone :)
Anyway, I'll think about compiler optimizations which can help here.
Being able to do real time YUV to RGB conversion is an impressive
accomplishment for a high level language like Factor.
I know you wanted to experiment with using a GL shader to perform
this conversion, but it would be nice if we could get pure software
conversion to be fast too.
Nice work Chris, as usual. I'm impressed with your continued
contributions and I'm looking forward to seeing more.
Slava
-------------------------------------------------------------------------
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
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk