I've pushed some code to my repository to allow playback of Ogg Theora files (streaming video). It's a work in progress and has a few issues but it at least displays some video on my machine.
Repository is http://www.bluishcoder.co.nz/repos/factor Usage: "apps/ogg-player" require "c:/test.ogg" play-theora-file A test video can be obtained from http://www.bluishcoder.co.nz/test.ogg I haven't worked on synchronising the sound and video yet - I'll leave that till I've got the video playback faster. The yuv to rgb conversion code I've written is too slow. On my fast laptop (Dual Core Pentium running Windows) it takes about 78ms per frame. Any ideas on speeding it up would be appreciated! I think this is the main reason why the video display is choppy. Worse, on my slower laptop (P3 1Ghz running Windows) it doesn't even display the video. I can get it to display some only if I modify the code to display like every 10th frame and then put in a '1000 sleep' after the relayout-1. I notice relayout-1 doesn't update the display immediately. I guess the redisplay event is never being processed due to it being too busy decoding the video? How can I say 'redisplay now'? Hopefully at least something displays on any fast machine running Windows, Linux or Mac. You'll need vorbis, theora and ogg dll's. I have windows versions here: http://www.bluishcoder.co.nz/oggdlls.zip For the curious, the yuv>rgb conversion code is pasted below: -------------------------8<------------------------- : clamp ( n -- n ) 255 min 0 max ; : stride ( line yuv -- uvy yy ) [ yuv_buffer-uv_stride swap 2 /i * ] 2keep yuv_buffer-y_stride * ; : each-with4 ( obj obj obj obj seq quot -- ) 4 each-withn ; inline : 5keep ( obj obj obj obj obj quot -- obj obj obj obj obj ) 5 nkeep ; inline : compute-y ( yuv uvy yy x -- y ) + nip swap yuv_buffer-y uchar-nth 16 - ; : compute-v ( yuv uvy yy x -- v ) nip 2 /i + swap yuv_buffer-u uchar-nth 128 - ; : compute-u ( yuv uvy yy x -- v ) nip 2 /i + swap yuv_buffer-v uchar-nth 128 - ; : compute-blue ( y u v -- b ) drop 516 * 128 + swap 298 * + -8 shift clamp ; : compute-green ( y u v -- g ) >r >r 298 * r> 100 * - r> 208 * - 128 + -8 shift clamp ; : compute-red ( y u v -- g ) nip 409 * swap 298 * + 128 + -8 shift clamp ; : yuv>rgb ( rgb yuv -- ) 0 -rot dup yuv_buffer-y_height [ ! index rgb yuv y over stride ! index rgb yuv uvy yy pick yuv_buffer-y_width [ ! index rgb yuv uvy yy x [ compute-y ] 4keep [ compute-u ] 4keep compute-v ! index rgb y u v [ compute-blue -rot set-uchar-nth ] 5keep [ compute-green -rot >r 1+ r> set-char-nth ] 5keep compute-red -rot swap [ 2 + swap set-char-nth ] keep 3 + ] each-with4 ] each-with2 drop ; -------------------------8<------------------------- Chris. -- http://www.bluishcoder.co.nz ------------------------------------------------------------------------- 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 Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk