From: Marc Fauconneau Date: Sun, 30 Aug 2009 08:31:30 +0000 (+0900) Subject: Merge branch 'master' of git://factorcode.org/git/factor X-Git-Tag: 0.97~5324^2~23^2~1 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=2d4ba8de4d48a33324eef1512f8bfb0e23bd9a09;hp=be406fa9649dac538f6ae80bc1108368f8a49ca3 Merge branch 'master' of git://factorcode.org/git/factor --- diff --git a/basis/images/jpeg/jpeg.factor b/basis/images/jpeg/jpeg.factor index 776f768036..f0280e46de 100644 --- a/basis/images/jpeg/jpeg.factor +++ b/basis/images/jpeg/jpeg.factor @@ -6,7 +6,7 @@ images.processing io io.binary io.encodings.binary io.files 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 ; +sequences sequences.deep images.loader io.streams.limited ; IN: images.jpeg QUALIFIED-WITH: bitstreams bs @@ -118,18 +118,18 @@ TUPLE: jpeg-color-info ] with-byte-reader ; : decode-huff-table ( chunk -- ) - data>> - binary - [ - 1 ! %fixme: Should handle multiple tables at once + data>> [ binary ] [ length ] bi + stream-throws limit + [ + [ input-stream get [ count>> ] [ limit>> ] bi < ] [ 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 ; + ] while + ] with-input-stream* ; : decode-scan ( chunk -- ) data>> @@ -148,7 +148,10 @@ TUPLE: jpeg-color-info : singleton-first ( seq -- elt ) [ length 1 assert= ] [ first ] bi ; +ERROR: not-a-baseline-jpeg-image ; + : baseline-parse ( -- ) + jpeg> headers>> [ type>> { SOF 0 } = ] any? [ not-a-baseline-jpeg-image ] unless jpeg> headers>> { [ [ type>> { SOF 0 } = ] filter singleton-first decode-frame ] @@ -221,7 +224,7 @@ MEMO: dct-matrix-blas ( -- m ) dct-matrix >float-blas-matrix ; : 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 diff --git a/basis/math/matrices/matrices-tests.factor b/basis/math/matrices/matrices-tests.factor index 20942356de..3ee1ddbd6d 100644 --- a/basis/math/matrices/matrices-tests.factor +++ b/basis/math/matrices/matrices-tests.factor @@ -106,4 +106,7 @@ USING: math.matrices math.vectors tools.test math ; [ { 1 0 0 } ] [ { 1 1 0 } { 1 0 0 } proj ] unit-test [ { { { 1 "a" } { 1 "b" } } { { 2 "a" } { 2 "b" } } } ] -[ { 1 2 } { "a" "b" } cross-zip ] unit-test \ No newline at end of file +[ { 1 2 } { "a" "b" } cross-zip ] unit-test + +[ { { 4181 6765 } { 6765 10946 } } ] +[ { { 0 1 } { 1 1 } } 20 m^n ] unit-test diff --git a/basis/math/matrices/matrices.factor b/basis/math/matrices/matrices.factor index 3203355bb9..4ba8e1d3d9 100644 --- a/basis/math/matrices/matrices.factor +++ b/basis/math/matrices/matrices.factor @@ -139,4 +139,4 @@ PRIVATE> : m^n ( m n -- n ) make-bits over first length identity-matrix - [ [ dupd m. ] when [ dup m. ] dip ] reduce nip ; + [ [ dupd m. ] when [ dup m. ] dip ] reduce nip ; \ No newline at end of file