 : V.M ( x A -- x.A ) Mtranspose swap M.V ;
 : idct-blas ( b -- b' ) >float-blas-vector dct-matrix-blas V.M ;
 
-: idct ( b -- b' ) idct-blas ;
+: idct ( b -- b' ) idct-factor ;
 
 :: draw-block ( block x,y color-id jpeg-image -- )
     block dup length>> sqrt >fixnum group flip

    ] with-byte-reader ;

: decode-huff-table ( chunk -- )
    data>>
    binary
    [
        1 ! %fixme: Should handle multiple tables at once
        [
            read4/4 swap 2 * +
            16 read
            dup [ ] [ + ] map-reduce read
            binary [ [ read [ B{ } ] unless* ] { } map-as ] with-byte-reader
            swap jpeg> huff-tables>> set-nth
        ] times
    ] with-byte-reader ;

: decode-scan ( chunk -- )
    data>>

io.streams.byte-array kernel locals math math.bitwise
math.constants math.functions math.matrices math.order
math.ranges math.vectors memoize multiline namespaces
sequences sequences.deep images.loader io.streams.limited ;
IN: images.jpeg

QUALIFIED-WITH: bitstreams bs
