Hi Chris, There are various reasons why this is slow. I'll make this a top priority for 0.90! There are more efficient ways of expressing this algorithm and the compiler could be improved too. Right now this compiles into a whole bunch of C calls, for set-uchar-nth, etc, and most arithmetic is generic. I'll work on it and hopefully the compiler can generate something much tighter.
Slava On 31-Mar-07, at 10:43 AM, Chris Double wrote: > -------------------------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<------------------------- ------------------------------------------------------------------------- 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