From f0bbf02bfd33ef9adbff44246b6f93ffb2543cb3 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Fri, 27 Nov 2020 22:51:08 -0600 Subject: [PATCH] basic nim jpg works, png dir --- src/pixie/fileformats/jpg.nim | 340 +++++++++++++++++- tests/fuzz_png.nim | 4 +- tests/images/{ => png}/lenna.png | Bin .../{ => png}/pngsuite/PngSuite.LICENSE | 0 .../images/{ => png}/pngsuite/PngSuite.README | 0 tests/images/{ => png}/pngsuite/PngSuite.png | Bin tests/images/{ => png}/pngsuite/basi0g01.png | Bin tests/images/{ => png}/pngsuite/basi0g02.png | Bin tests/images/{ => png}/pngsuite/basi0g04.png | Bin tests/images/{ => png}/pngsuite/basi0g08.png | Bin tests/images/{ => png}/pngsuite/basi0g16.png | Bin tests/images/{ => png}/pngsuite/basi2c08.png | Bin tests/images/{ => png}/pngsuite/basi2c16.png | Bin tests/images/{ => png}/pngsuite/basi3p01.png | Bin tests/images/{ => png}/pngsuite/basi3p02.png | Bin tests/images/{ => png}/pngsuite/basi3p04.png | Bin tests/images/{ => png}/pngsuite/basi3p08.png | Bin tests/images/{ => png}/pngsuite/basi4a08.png | Bin tests/images/{ => png}/pngsuite/basi4a16.png | Bin tests/images/{ => png}/pngsuite/basi6a08.png | Bin tests/images/{ => png}/pngsuite/basi6a16.png | Bin tests/images/{ => png}/pngsuite/basn0g01.png | Bin tests/images/{ => png}/pngsuite/basn0g02.png | Bin tests/images/{ => png}/pngsuite/basn0g04.png | Bin tests/images/{ => png}/pngsuite/basn0g08.png | Bin tests/images/{ => png}/pngsuite/basn0g16.png | Bin tests/images/{ => png}/pngsuite/basn2c08.png | Bin tests/images/{ => png}/pngsuite/basn2c16.png | Bin tests/images/{ => png}/pngsuite/basn3p01.png | Bin tests/images/{ => png}/pngsuite/basn3p02.png | Bin tests/images/{ => png}/pngsuite/basn3p04.png | Bin tests/images/{ => png}/pngsuite/basn3p08.png | Bin tests/images/{ => png}/pngsuite/basn4a08.png | Bin tests/images/{ => png}/pngsuite/basn4a16.png | Bin tests/images/{ => png}/pngsuite/basn6a08.png | Bin tests/images/{ => png}/pngsuite/basn6a16.png | Bin tests/images/{ => png}/pngsuite/bgai4a08.png | Bin tests/images/{ => png}/pngsuite/bgai4a16.png | Bin tests/images/{ => png}/pngsuite/bgan6a08.png | Bin tests/images/{ => png}/pngsuite/bgan6a16.png | Bin tests/images/{ => png}/pngsuite/bgbn4a08.png | Bin tests/images/{ => png}/pngsuite/bggn4a16.png | Bin tests/images/{ => png}/pngsuite/bgwn6a08.png | Bin tests/images/{ => png}/pngsuite/bgyn6a16.png | Bin tests/images/{ => png}/pngsuite/ccwn2c08.png | Bin tests/images/{ => png}/pngsuite/ccwn3p08.png | Bin tests/images/{ => png}/pngsuite/cdfn2c08.png | Bin tests/images/{ => png}/pngsuite/cdhn2c08.png | Bin tests/images/{ => png}/pngsuite/cdsn2c08.png | Bin tests/images/{ => png}/pngsuite/cdun2c08.png | Bin tests/images/{ => png}/pngsuite/ch1n3p04.png | Bin tests/images/{ => png}/pngsuite/ch2n3p08.png | Bin tests/images/{ => png}/pngsuite/cm0n0g04.png | Bin tests/images/{ => png}/pngsuite/cm7n0g04.png | Bin tests/images/{ => png}/pngsuite/cm9n0g04.png | Bin tests/images/{ => png}/pngsuite/cs3n2c16.png | Bin tests/images/{ => png}/pngsuite/cs3n3p08.png | Bin tests/images/{ => png}/pngsuite/cs5n2c08.png | Bin tests/images/{ => png}/pngsuite/cs5n3p08.png | Bin tests/images/{ => png}/pngsuite/cs8n2c08.png | Bin tests/images/{ => png}/pngsuite/cs8n3p08.png | Bin tests/images/{ => png}/pngsuite/ct0n0g04.png | Bin tests/images/{ => png}/pngsuite/ct1n0g04.png | Bin tests/images/{ => png}/pngsuite/cten0g04.png | Bin tests/images/{ => png}/pngsuite/ctfn0g04.png | Bin tests/images/{ => png}/pngsuite/ctgn0g04.png | Bin tests/images/{ => png}/pngsuite/cthn0g04.png | Bin tests/images/{ => png}/pngsuite/ctjn0g04.png | Bin tests/images/{ => png}/pngsuite/ctzn0g04.png | Bin tests/images/{ => png}/pngsuite/exif2c08.png | Bin tests/images/{ => png}/pngsuite/f00n0g08.png | Bin tests/images/{ => png}/pngsuite/f00n2c08.png | Bin tests/images/{ => png}/pngsuite/f01n0g08.png | Bin tests/images/{ => png}/pngsuite/f01n2c08.png | Bin tests/images/{ => png}/pngsuite/f02n0g08.png | Bin tests/images/{ => png}/pngsuite/f02n2c08.png | Bin tests/images/{ => png}/pngsuite/f03n0g08.png | Bin tests/images/{ => png}/pngsuite/f03n2c08.png | Bin tests/images/{ => png}/pngsuite/f04n0g08.png | Bin tests/images/{ => png}/pngsuite/f04n2c08.png | Bin tests/images/{ => png}/pngsuite/f99n0g04.png | Bin tests/images/{ => png}/pngsuite/g03n0g16.png | Bin tests/images/{ => png}/pngsuite/g03n2c08.png | Bin tests/images/{ => png}/pngsuite/g03n3p04.png | Bin tests/images/{ => png}/pngsuite/g04n0g16.png | Bin tests/images/{ => png}/pngsuite/g04n2c08.png | Bin tests/images/{ => png}/pngsuite/g04n3p04.png | Bin tests/images/{ => png}/pngsuite/g05n0g16.png | Bin tests/images/{ => png}/pngsuite/g05n2c08.png | Bin tests/images/{ => png}/pngsuite/g05n3p04.png | Bin tests/images/{ => png}/pngsuite/g07n0g16.png | Bin tests/images/{ => png}/pngsuite/g07n2c08.png | Bin tests/images/{ => png}/pngsuite/g07n3p04.png | Bin tests/images/{ => png}/pngsuite/g10n0g16.png | Bin tests/images/{ => png}/pngsuite/g10n2c08.png | Bin tests/images/{ => png}/pngsuite/g10n3p04.png | Bin tests/images/{ => png}/pngsuite/g25n0g16.png | Bin tests/images/{ => png}/pngsuite/g25n2c08.png | Bin tests/images/{ => png}/pngsuite/g25n3p04.png | Bin tests/images/{ => png}/pngsuite/oi1n0g16.png | Bin tests/images/{ => png}/pngsuite/oi1n2c16.png | Bin tests/images/{ => png}/pngsuite/oi2n0g16.png | Bin tests/images/{ => png}/pngsuite/oi2n2c16.png | Bin tests/images/{ => png}/pngsuite/oi4n0g16.png | Bin tests/images/{ => png}/pngsuite/oi4n2c16.png | Bin tests/images/{ => png}/pngsuite/oi9n0g16.png | Bin tests/images/{ => png}/pngsuite/oi9n2c16.png | Bin tests/images/{ => png}/pngsuite/pp0n2c16.png | Bin tests/images/{ => png}/pngsuite/pp0n6a08.png | Bin tests/images/{ => png}/pngsuite/ps1n0g08.png | Bin tests/images/{ => png}/pngsuite/ps1n2c16.png | Bin tests/images/{ => png}/pngsuite/ps2n0g08.png | Bin tests/images/{ => png}/pngsuite/ps2n2c16.png | Bin tests/images/{ => png}/pngsuite/s01i3p01.png | Bin tests/images/{ => png}/pngsuite/s01n3p01.png | Bin tests/images/{ => png}/pngsuite/s02i3p01.png | Bin tests/images/{ => png}/pngsuite/s02n3p01.png | Bin tests/images/{ => png}/pngsuite/s03i3p01.png | Bin tests/images/{ => png}/pngsuite/s03n3p01.png | Bin tests/images/{ => png}/pngsuite/s04i3p01.png | Bin tests/images/{ => png}/pngsuite/s04n3p01.png | Bin tests/images/{ => png}/pngsuite/s05i3p02.png | Bin tests/images/{ => png}/pngsuite/s05n3p02.png | Bin tests/images/{ => png}/pngsuite/s06i3p02.png | Bin tests/images/{ => png}/pngsuite/s06n3p02.png | Bin tests/images/{ => png}/pngsuite/s07i3p02.png | Bin tests/images/{ => png}/pngsuite/s07n3p02.png | Bin tests/images/{ => png}/pngsuite/s08i3p02.png | Bin tests/images/{ => png}/pngsuite/s08n3p02.png | Bin tests/images/{ => png}/pngsuite/s09i3p02.png | Bin tests/images/{ => png}/pngsuite/s09n3p02.png | Bin tests/images/{ => png}/pngsuite/s32i3p04.png | Bin tests/images/{ => png}/pngsuite/s32n3p04.png | Bin tests/images/{ => png}/pngsuite/s33i3p04.png | Bin tests/images/{ => png}/pngsuite/s33n3p04.png | Bin tests/images/{ => png}/pngsuite/s34i3p04.png | Bin tests/images/{ => png}/pngsuite/s34n3p04.png | Bin tests/images/{ => png}/pngsuite/s35i3p04.png | Bin tests/images/{ => png}/pngsuite/s35n3p04.png | Bin tests/images/{ => png}/pngsuite/s36i3p04.png | Bin tests/images/{ => png}/pngsuite/s36n3p04.png | Bin tests/images/{ => png}/pngsuite/s37i3p04.png | Bin tests/images/{ => png}/pngsuite/s37n3p04.png | Bin tests/images/{ => png}/pngsuite/s38i3p04.png | Bin tests/images/{ => png}/pngsuite/s38n3p04.png | Bin tests/images/{ => png}/pngsuite/s39i3p04.png | Bin tests/images/{ => png}/pngsuite/s39n3p04.png | Bin tests/images/{ => png}/pngsuite/s40i3p04.png | Bin tests/images/{ => png}/pngsuite/s40n3p04.png | Bin tests/images/{ => png}/pngsuite/tbbn0g04.png | Bin tests/images/{ => png}/pngsuite/tbbn2c16.png | Bin tests/images/{ => png}/pngsuite/tbbn3p08.png | Bin tests/images/{ => png}/pngsuite/tbgn2c16.png | Bin tests/images/{ => png}/pngsuite/tbgn3p08.png | Bin tests/images/{ => png}/pngsuite/tbrn2c08.png | Bin tests/images/{ => png}/pngsuite/tbwn0g16.png | Bin tests/images/{ => png}/pngsuite/tbwn3p08.png | Bin tests/images/{ => png}/pngsuite/tbyn3p08.png | Bin tests/images/{ => png}/pngsuite/tm3n3p02.png | Bin tests/images/{ => png}/pngsuite/tp0n0g08.png | Bin tests/images/{ => png}/pngsuite/tp0n2c08.png | Bin tests/images/{ => png}/pngsuite/tp0n3p08.png | Bin tests/images/{ => png}/pngsuite/tp1n3p08.png | Bin tests/images/{ => png}/pngsuite/xc1n0g08.png | Bin tests/images/{ => png}/pngsuite/xc9n2c08.png | Bin tests/images/{ => png}/pngsuite/xcrn0g04.png | Bin tests/images/{ => png}/pngsuite/xcsn0g01.png | Bin tests/images/{ => png}/pngsuite/xd0n2c08.png | Bin tests/images/{ => png}/pngsuite/xd3n2c08.png | Bin tests/images/{ => png}/pngsuite/xd9n2c08.png | Bin tests/images/{ => png}/pngsuite/xdtn0g01.png | Bin tests/images/{ => png}/pngsuite/xhdn0g08.png | Bin tests/images/{ => png}/pngsuite/xlfn0g04.png | Bin tests/images/{ => png}/pngsuite/xs1n0g01.png | Bin tests/images/{ => png}/pngsuite/xs2n0g01.png | Bin tests/images/{ => png}/pngsuite/xs4n0g01.png | Bin tests/images/{ => png}/pngsuite/xs7n0g01.png | Bin tests/images/{ => png}/pngsuite/z00n2c08.png | Bin tests/images/{ => png}/pngsuite/z03n2c08.png | Bin tests/images/{ => png}/pngsuite/z06n2c08.png | Bin tests/images/{ => png}/pngsuite/z09n2c08.png | Bin tests/test_jpg.nim | 27 +- tests/test_png.nim | 6 +- tests/validate_jpg.nim | 3 + 184 files changed, 359 insertions(+), 21 deletions(-) rename tests/images/{ => png}/lenna.png (100%) rename tests/images/{ => png}/pngsuite/PngSuite.LICENSE (100%) rename tests/images/{ => png}/pngsuite/PngSuite.README (100%) rename tests/images/{ => png}/pngsuite/PngSuite.png (100%) rename tests/images/{ => png}/pngsuite/basi0g01.png (100%) rename tests/images/{ => png}/pngsuite/basi0g02.png (100%) rename tests/images/{ => png}/pngsuite/basi0g04.png (100%) rename tests/images/{ => png}/pngsuite/basi0g08.png (100%) rename tests/images/{ => png}/pngsuite/basi0g16.png (100%) rename tests/images/{ => png}/pngsuite/basi2c08.png (100%) rename tests/images/{ => png}/pngsuite/basi2c16.png (100%) rename tests/images/{ => png}/pngsuite/basi3p01.png (100%) rename tests/images/{ => png}/pngsuite/basi3p02.png (100%) rename tests/images/{ => png}/pngsuite/basi3p04.png (100%) rename tests/images/{ => png}/pngsuite/basi3p08.png (100%) rename tests/images/{ => png}/pngsuite/basi4a08.png (100%) rename tests/images/{ => png}/pngsuite/basi4a16.png (100%) rename tests/images/{ => png}/pngsuite/basi6a08.png (100%) rename tests/images/{ => png}/pngsuite/basi6a16.png (100%) rename tests/images/{ => png}/pngsuite/basn0g01.png (100%) rename tests/images/{ => png}/pngsuite/basn0g02.png (100%) rename tests/images/{ => png}/pngsuite/basn0g04.png (100%) rename tests/images/{ => png}/pngsuite/basn0g08.png (100%) rename tests/images/{ => png}/pngsuite/basn0g16.png (100%) rename tests/images/{ => png}/pngsuite/basn2c08.png (100%) rename tests/images/{ => png}/pngsuite/basn2c16.png (100%) rename tests/images/{ => png}/pngsuite/basn3p01.png (100%) rename tests/images/{ => png}/pngsuite/basn3p02.png (100%) rename tests/images/{ => png}/pngsuite/basn3p04.png (100%) rename tests/images/{ => png}/pngsuite/basn3p08.png (100%) rename tests/images/{ => png}/pngsuite/basn4a08.png (100%) rename tests/images/{ => png}/pngsuite/basn4a16.png (100%) rename tests/images/{ => png}/pngsuite/basn6a08.png (100%) rename tests/images/{ => png}/pngsuite/basn6a16.png (100%) rename tests/images/{ => png}/pngsuite/bgai4a08.png (100%) rename tests/images/{ => png}/pngsuite/bgai4a16.png (100%) rename tests/images/{ => png}/pngsuite/bgan6a08.png (100%) rename tests/images/{ => png}/pngsuite/bgan6a16.png (100%) rename tests/images/{ => png}/pngsuite/bgbn4a08.png (100%) rename tests/images/{ => png}/pngsuite/bggn4a16.png (100%) rename tests/images/{ => png}/pngsuite/bgwn6a08.png (100%) rename tests/images/{ => png}/pngsuite/bgyn6a16.png (100%) rename tests/images/{ => png}/pngsuite/ccwn2c08.png (100%) rename tests/images/{ => png}/pngsuite/ccwn3p08.png (100%) rename tests/images/{ => png}/pngsuite/cdfn2c08.png (100%) rename tests/images/{ => png}/pngsuite/cdhn2c08.png (100%) rename tests/images/{ => png}/pngsuite/cdsn2c08.png (100%) rename tests/images/{ => png}/pngsuite/cdun2c08.png (100%) rename tests/images/{ => png}/pngsuite/ch1n3p04.png (100%) rename tests/images/{ => png}/pngsuite/ch2n3p08.png (100%) rename tests/images/{ => png}/pngsuite/cm0n0g04.png (100%) rename tests/images/{ => png}/pngsuite/cm7n0g04.png (100%) rename tests/images/{ => png}/pngsuite/cm9n0g04.png (100%) rename tests/images/{ => png}/pngsuite/cs3n2c16.png (100%) rename tests/images/{ => png}/pngsuite/cs3n3p08.png (100%) rename tests/images/{ => png}/pngsuite/cs5n2c08.png (100%) rename tests/images/{ => png}/pngsuite/cs5n3p08.png (100%) rename tests/images/{ => png}/pngsuite/cs8n2c08.png (100%) rename tests/images/{ => png}/pngsuite/cs8n3p08.png (100%) rename tests/images/{ => png}/pngsuite/ct0n0g04.png (100%) rename tests/images/{ => png}/pngsuite/ct1n0g04.png (100%) rename tests/images/{ => png}/pngsuite/cten0g04.png (100%) rename tests/images/{ => png}/pngsuite/ctfn0g04.png (100%) rename tests/images/{ => png}/pngsuite/ctgn0g04.png (100%) rename tests/images/{ => png}/pngsuite/cthn0g04.png (100%) rename tests/images/{ => png}/pngsuite/ctjn0g04.png (100%) rename tests/images/{ => png}/pngsuite/ctzn0g04.png (100%) rename tests/images/{ => png}/pngsuite/exif2c08.png (100%) rename tests/images/{ => png}/pngsuite/f00n0g08.png (100%) rename tests/images/{ => png}/pngsuite/f00n2c08.png (100%) rename tests/images/{ => png}/pngsuite/f01n0g08.png (100%) rename tests/images/{ => png}/pngsuite/f01n2c08.png (100%) rename tests/images/{ => png}/pngsuite/f02n0g08.png (100%) rename tests/images/{ => png}/pngsuite/f02n2c08.png (100%) rename tests/images/{ => png}/pngsuite/f03n0g08.png (100%) rename tests/images/{ => png}/pngsuite/f03n2c08.png (100%) rename tests/images/{ => png}/pngsuite/f04n0g08.png (100%) rename tests/images/{ => png}/pngsuite/f04n2c08.png (100%) rename tests/images/{ => png}/pngsuite/f99n0g04.png (100%) rename tests/images/{ => png}/pngsuite/g03n0g16.png (100%) rename tests/images/{ => png}/pngsuite/g03n2c08.png (100%) rename tests/images/{ => png}/pngsuite/g03n3p04.png (100%) rename tests/images/{ => png}/pngsuite/g04n0g16.png (100%) rename tests/images/{ => png}/pngsuite/g04n2c08.png (100%) rename tests/images/{ => png}/pngsuite/g04n3p04.png (100%) rename tests/images/{ => png}/pngsuite/g05n0g16.png (100%) rename tests/images/{ => png}/pngsuite/g05n2c08.png (100%) rename tests/images/{ => png}/pngsuite/g05n3p04.png (100%) rename tests/images/{ => png}/pngsuite/g07n0g16.png (100%) rename tests/images/{ => png}/pngsuite/g07n2c08.png (100%) rename tests/images/{ => png}/pngsuite/g07n3p04.png (100%) rename tests/images/{ => png}/pngsuite/g10n0g16.png (100%) rename tests/images/{ => png}/pngsuite/g10n2c08.png (100%) rename tests/images/{ => png}/pngsuite/g10n3p04.png (100%) rename tests/images/{ => png}/pngsuite/g25n0g16.png (100%) rename tests/images/{ => png}/pngsuite/g25n2c08.png (100%) rename tests/images/{ => png}/pngsuite/g25n3p04.png (100%) rename tests/images/{ => png}/pngsuite/oi1n0g16.png (100%) rename tests/images/{ => png}/pngsuite/oi1n2c16.png (100%) rename tests/images/{ => png}/pngsuite/oi2n0g16.png (100%) rename tests/images/{ => png}/pngsuite/oi2n2c16.png (100%) rename tests/images/{ => png}/pngsuite/oi4n0g16.png (100%) rename tests/images/{ => png}/pngsuite/oi4n2c16.png (100%) rename tests/images/{ => png}/pngsuite/oi9n0g16.png (100%) rename tests/images/{ => png}/pngsuite/oi9n2c16.png (100%) rename tests/images/{ => png}/pngsuite/pp0n2c16.png (100%) rename tests/images/{ => png}/pngsuite/pp0n6a08.png (100%) rename tests/images/{ => png}/pngsuite/ps1n0g08.png (100%) rename tests/images/{ => png}/pngsuite/ps1n2c16.png (100%) rename tests/images/{ => png}/pngsuite/ps2n0g08.png (100%) rename tests/images/{ => png}/pngsuite/ps2n2c16.png (100%) rename tests/images/{ => png}/pngsuite/s01i3p01.png (100%) rename tests/images/{ => png}/pngsuite/s01n3p01.png (100%) rename tests/images/{ => png}/pngsuite/s02i3p01.png (100%) rename tests/images/{ => png}/pngsuite/s02n3p01.png (100%) rename tests/images/{ => png}/pngsuite/s03i3p01.png (100%) rename tests/images/{ => png}/pngsuite/s03n3p01.png (100%) rename tests/images/{ => png}/pngsuite/s04i3p01.png (100%) rename tests/images/{ => png}/pngsuite/s04n3p01.png (100%) rename tests/images/{ => png}/pngsuite/s05i3p02.png (100%) rename tests/images/{ => png}/pngsuite/s05n3p02.png (100%) rename tests/images/{ => png}/pngsuite/s06i3p02.png (100%) rename tests/images/{ => png}/pngsuite/s06n3p02.png (100%) rename tests/images/{ => png}/pngsuite/s07i3p02.png (100%) rename tests/images/{ => png}/pngsuite/s07n3p02.png (100%) rename tests/images/{ => png}/pngsuite/s08i3p02.png (100%) rename tests/images/{ => png}/pngsuite/s08n3p02.png (100%) rename tests/images/{ => png}/pngsuite/s09i3p02.png (100%) rename tests/images/{ => png}/pngsuite/s09n3p02.png (100%) rename tests/images/{ => png}/pngsuite/s32i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s32n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s33i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s33n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s34i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s34n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s35i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s35n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s36i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s36n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s37i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s37n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s38i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s38n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s39i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s39n3p04.png (100%) rename tests/images/{ => png}/pngsuite/s40i3p04.png (100%) rename tests/images/{ => png}/pngsuite/s40n3p04.png (100%) rename tests/images/{ => png}/pngsuite/tbbn0g04.png (100%) rename tests/images/{ => png}/pngsuite/tbbn2c16.png (100%) rename tests/images/{ => png}/pngsuite/tbbn3p08.png (100%) rename tests/images/{ => png}/pngsuite/tbgn2c16.png (100%) rename tests/images/{ => png}/pngsuite/tbgn3p08.png (100%) rename tests/images/{ => png}/pngsuite/tbrn2c08.png (100%) rename tests/images/{ => png}/pngsuite/tbwn0g16.png (100%) rename tests/images/{ => png}/pngsuite/tbwn3p08.png (100%) rename tests/images/{ => png}/pngsuite/tbyn3p08.png (100%) rename tests/images/{ => png}/pngsuite/tm3n3p02.png (100%) rename tests/images/{ => png}/pngsuite/tp0n0g08.png (100%) rename tests/images/{ => png}/pngsuite/tp0n2c08.png (100%) rename tests/images/{ => png}/pngsuite/tp0n3p08.png (100%) rename tests/images/{ => png}/pngsuite/tp1n3p08.png (100%) rename tests/images/{ => png}/pngsuite/xc1n0g08.png (100%) rename tests/images/{ => png}/pngsuite/xc9n2c08.png (100%) rename tests/images/{ => png}/pngsuite/xcrn0g04.png (100%) rename tests/images/{ => png}/pngsuite/xcsn0g01.png (100%) rename tests/images/{ => png}/pngsuite/xd0n2c08.png (100%) rename tests/images/{ => png}/pngsuite/xd3n2c08.png (100%) rename tests/images/{ => png}/pngsuite/xd9n2c08.png (100%) rename tests/images/{ => png}/pngsuite/xdtn0g01.png (100%) rename tests/images/{ => png}/pngsuite/xhdn0g08.png (100%) rename tests/images/{ => png}/pngsuite/xlfn0g04.png (100%) rename tests/images/{ => png}/pngsuite/xs1n0g01.png (100%) rename tests/images/{ => png}/pngsuite/xs2n0g01.png (100%) rename tests/images/{ => png}/pngsuite/xs4n0g01.png (100%) rename tests/images/{ => png}/pngsuite/xs7n0g01.png (100%) rename tests/images/{ => png}/pngsuite/z00n2c08.png (100%) rename tests/images/{ => png}/pngsuite/z03n2c08.png (100%) rename tests/images/{ => png}/pngsuite/z06n2c08.png (100%) rename tests/images/{ => png}/pngsuite/z09n2c08.png (100%) create mode 100644 tests/validate_jpg.nim diff --git a/src/pixie/fileformats/jpg.nim b/src/pixie/fileformats/jpg.nim index 81bcac7..5065d6f 100644 --- a/src/pixie/fileformats/jpg.nim +++ b/src/pixie/fileformats/jpg.nim @@ -30,13 +30,24 @@ type deltas: array[17, int] maxCodes: array[18, int] + ResampleProc = proc(dst, line0, line1: ptr UncheckedArray[uint8], + widthPreExpansion, horizontalExpansionFactor: int + ): ptr UncheckedArray[uint8] + + Resample = object + horizontalExpansionFactor, verticalExpansionFactor: int + yStep, yPos, widthPreExpansion: int + line0, line1: ptr UncheckedArray[uint8] + resample: ResampleProc + Component = object id, quantizationTable: uint8 - verticalSamplingFactor, horizontalSamplingFactor: int + horizontalSamplingFactor, verticalSamplingFactor: int width, height: int - w2, h2: int # TODO what are these + widthStride, heightStride: int huffmanDC, huffmanAC: int dcPred: int + data, lineBuf: seq[uint8] DecoderState = object buffer: seq[uint8] @@ -237,11 +248,15 @@ proc decodeSOF(state: var DecoderState) = state.maxVerticalSamplingFactor - 1 ) div state.maxVerticalSamplingFactor - state.components[i].w2 = + state.components[i].widthStride = state.numMcuWide * state.components[i].horizontalSamplingFactor * 8 - state.components[i].h2 = + state.components[i].heightStride = state.numMcuHigh * state.components[i].verticalSamplingFactor * 8 + state.components[i].data.setLen( + state.components[i].widthStride * state.components[i].heightStride + ) + proc decodeSOS(state: var DecoderState) = var len = state.readUint16be() - 2 @@ -316,8 +331,6 @@ proc huffmanDecode(state: var DecoderState, tableCurrent, table: int): uint8 = state.bits = state.bits shl i state.bitCount -= i - echo "post-decode: ", state.bitCount, " ", state.bits - template lrot(value: uint32, shift: int): uint32 = (value shl shift) or (value shr (32 - shift)) @@ -325,22 +338,18 @@ proc extendReceive(state: var DecoderState, t: int): int = if state.bitCount < t: state.fillBits() - let sign = (state.bits shr 31).int32 + let sign = cast[int32](state.bits) shr 31 var k = lrot(state.bits, t) state.bits = k and (not bitmasks[t]) k = k and bitmasks[t] state.bitCount -= t result = k.int + (biases[t] and (not sign)) - echo "sgn: ", sign - echo "post: ", state.bits proc decodeImageBlock(state: var DecoderState, component: int): array[64, int16] = let t = state.huffmanDecode(0, state.components[component].huffmanDC).int if t < 0: failInvalid() - echo "t: ", t - let diff = if t == 0: 0 else: state.extendReceive(t) dc = state.components[component].dcPred + diff @@ -349,7 +358,146 @@ proc decodeImageBlock(state: var DecoderState, component: int): array[64, int16] state.components[component].quantizationTable ][0].int).int16 - echo "data[0]: ", result[0] + var i = 1 + while i < 64: + if state.bitCount < 16: + state.fillBits() + let + rs = state.huffmanDecode(1, state.components[component].huffmanAC) + s = rs and 15 + r = rs shr 4 + if s == 0: + if rs != 0xF0: + break + i += 16 + else: + i += r.int + let zig = deZigZag[i] + result[zig] = (state.extendReceive(s.int) * state.quantizationTables[ + state.components[component].quantizationTable + ][zig].int).int16 + inc i + +proc clamp(x: int): uint8 {.inline.} = + if cast[uint](x) > 255: + if x < 0: + return 0 + if x > 255: + return 255 + x.uint8 + +template idct1D(s0, s1, s2, s3, s4, s5, s6, s7: int32) = + template f2f(x: float32): int32 = (x * 4096 + 0.5).int32 + template fsh(x: int32): int32 = x * 4096 + p2 = s2 + p3 = s6 + p1 = (p2 + p3) * f2f(0.5411961f) + t2 = p1 + p3*f2f(-1.847759065f) + t3 = p1 + p2*f2f(0.765366865f) + p2 = s0 + p3 = s4 + t0 = fsh(p2 + p3) + t1 = fsh(p2 - p3) + x0 = t0 + t3 + x3 = t0 - t3 + x1 = t1 + t2 + x2 = t1 - t2 + t0 = s7 + t1 = s5 + t2 = s3 + t3 = s1 + p3 = t0 + t2 + p4 = t1 + t3 + p1 = t0 + t3 + p2 = t1 + t2 + p5 = (p3 + p4) * f2f(1.175875602f) + t0 = t0 * f2f(0.298631336f) + t1 = t1 * f2f(2.053119869f) + t2 = t2 * f2f(3.072711026f) + t3 = t3 * f2f(1.501321110f) + p1 = p5 + p1*f2f(-0.899976223f) + p2 = p5 + p2*f2f(-2.562915447f) + p3 = p3 * f2f(-1.961570560f) + p4 = p4 * f2f(-0.390180644f) + t3 += p1 + p4 + t2 += p2 + p3 + t1 += p2 + p4 + t0 += p1 + p3 + +proc idctBlock(component: var Component, offset: int, data: array[64, int16]) = + var values: array[64, int32] + for i in 0 ..< 8: + if data[i + 8] == 0 and + data[i + 16] == 0 and + data[i + 24] == 0 and + data[i + 32] == 0 and + data[i + 40] == 0 and + data[i + 48] == 0 and + data[i + 56] == 0: + let dcterm = data[i] * 4 + values[i + 0] = dcterm + values[i + 8] = dcterm + values[i + 16] = dcterm + values[i + 24] = dcterm + values[i + 32] = dcterm + values[i + 40] = dcterm + values[i + 48] = dcterm + values[i + 56] = dcterm + else: + var t0, t1, t2, t3, p1, p2, p3, p4, p5, x0, x1, x2, x3: int32 + idct1D( + data[i + 0], + data[i + 8], + data[i + 16], + data[i + 24], + data[i + 32], + data[i + 40], + data[i + 48], + data[i + 56] + ) + x0 += 512 + x1 += 512 + x2 += 512 + x3 += 512 + values[i + 0] = (x0 + t3) shr 10 + values[i + 56] = (x0 - t3) shr 10 + values[i + 8] = (x1 + t2) shr 10 + values[i + 48] = (x1 - t2) shr 10 + values[i + 16] = (x2 + t1) shr 10 + values[i + 40] = (x2 - t1) shr 10 + values[i + 24] = (x3 + t0) shr 10 + values[i + 32] = (x3 - t0) shr 10 + + for i in 0 ..< 8: + let + valuesPos = i * 8 + outPos = i * component.widthStride + offset + + var t0, t1, t2, t3, p1, p2, p3, p4, p5, x0, x1, x2, x3: int32 + idct1D( + values[valuesPos + 0], + values[valuesPos + 1], + values[valuesPos + 2], + values[valuesPos + 3], + values[valuesPos + 4], + values[valuesPos + 5], + values[valuesPos + 6], + values[valuesPos + 7] + ) + + x0 += 65536 + (128 shl 17) + x1 += 65536 + (128 shl 17) + x2 += 65536 + (128 shl 17) + x3 += 65536 + (128 shl 17) + + component.data[outPos + 0] = clamp((x0 + t3) shr 17) + component.data[outPos + 7] = clamp((x0 - t3) shr 17) + component.data[outPos + 1] = clamp((x1 + t2) shr 17) + component.data[outPos + 6] = clamp((x1 - t2) shr 17) + component.data[outPos + 2] = clamp((x2 + t1) shr 17) + component.data[outPos + 5] = clamp((x2 - t1) shr 17) + component.data[outPos + 3] = clamp((x3 + t0) shr 17) + component.data[outPos + 4] = clamp((x3 - t0) shr 17) proc decodeImageData(state: var DecoderState) = for y in 0 ..< state.numMcuHigh: @@ -357,8 +505,95 @@ proc decodeImageData(state: var DecoderState) = for component in state.componentOrder: for j in 0 ..< state.components[component].verticalSamplingFactor: for i in 0 ..< state.components[component].horizontalSamplingFactor: - let data = state.decodeImageBlock(component) - return + let + data = state.decodeImageBlock(component) + rowPos = ( + x * state.components[component].horizontalSamplingFactor + i + ) * 8 + column = ( + y * state.components[component].verticalSamplingFactor + j + ) * 8 + state.components[component].idctBlock( + state.components[component].widthStride * column + rowPos, + data + ) + +proc resampleRowH1V1( + dst, a, b: ptr UncheckedArray[uint8], + widthPreExpansion, horizontalExpansionFactor: int +): ptr UncheckedArray[uint8] = + a + +proc resampleRowH1V2( + dst, a, b: ptr UncheckedArray[uint8], + widthPreExpansion, horizontalExpansionFactor: int +): ptr UncheckedArray[uint8] = + for i in 0 ..< widthPreExpansion: + dst[i] = ((3 * a[i].int + b[i].int + 2) shr 2).uint8 + dst + +proc resampleRowH2V1( + dst, a, b: ptr UncheckedArray[uint8], + widthPreExpansion, horizontalExpansionFactor: int +): ptr UncheckedArray[uint8] = + if widthPreExpansion == 1: + dst[0] = a[0] + dst[1] = dst[0] + else: + dst[0] = a[0] + dst[1] = ((a[0].int * 3 + a[1].int + 2) shr 2).uint8 + for i in 1 ..< widthPreExpansion - 1: + let n = 3 * a[i].int + 2 + dst[i * 2 + 0] = ((n + a[i - 1].int) shr 2).uint8 + dst[i * 2 + 1] = ((n + a[i + 1].int) shr 2).uint8 + + dst[widthPreExpansion * 2 + 0] = (( + a[widthPreExpansion - 2].int * 3 + a[widthPreExpansion - 1].int + 2 + ) shr 2).uint8 + dst[widthPreExpansion * 2 + 1] = (a[widthPreExpansion - 1]) shr 2 + dst + +proc resampleRowH2V2( + dst, a, b: ptr UncheckedArray[uint8], + widthPreExpansion, horizontalExpansionFactor: int +): ptr UncheckedArray[uint8] = + if widthPreExpansion == 1: + dst[0] = ((3 * a[0].int + b[0].int + 2) shr 2).uint8 + dst[1] = dst[0] + else: + var + t0: int + t1 = 3 * a[0].int + b[0].int + dst[0] = ((t1 + 2) shr 2).uint8 + for i in 1 ..< widthPreExpansion: + t0 = t1 + t1 = 3 * a[i].int + b[i].int + dst[i * 2 - 1] = ((3 * t0 + t1 + 8) shr 4).uint8 + dst[i * 2 + 0] = ((3 * t1 + t0 + 8) shr 4).uint8 + dst[widthPreExpansion * 2 - 1] = ((t1 + 2) shr 2).uint8 + dst + +proc yCbCrToRgb(dst, py, pcb, pcr: ptr UncheckedArray[uint8], width: int) = + template float2Fixed(x: float32): int = + (x * 4096 + 0.5).int shl 8 + + var pos: int + for i in 0 ..< width: + let + yFixed = (py[][i].int shl 20) + (1 shl 19) + cb = pcb[][i].int - 128 + cr = pcr[][i].int - 128 + var + r = yFixed + cr * float2Fixed(1.40200) + g = yFixed + + (cr * -float2Fixed(0.71414)) + + ((cb * -float2Fixed(0.34414)) and -65536) + b = yFixed + cb * float2Fixed(1.77200) + dst[pos + 0] = clamp(r shr 20) + dst[pos + 1] = clamp(g shr 20) + dst[pos + 2] = clamp(b shr 20) + dst[pos + 3] = 255 + pos += 4 proc decodeJpg*(data: seq[uint8]): Image = ## Decodes the JPEG into an Image. @@ -385,7 +620,82 @@ proc decodeJpg*(data: seq[uint8]): Image = state.decodeImageData() - # raise newException(PixieError, "Decoding JPG not supported yet") + if not state.hitEOI: + failInvalid() + + result = newImage(state.imageWidth, state.imageHeight) + + var resamples: array[3, Resample] + for i in 0 ..< 3: + resamples[i].horizontalExpansionFactor = + state.maxHorizontalSamplingFactor div + state.components[i].horizontalSamplingFactor + resamples[i].verticalExpansionFactor = + state.maxVerticalSamplingFactor div + state.components[i].verticalSamplingFactor + resamples[i].yStep = resamples[i].verticalExpansionFactor shr 1 + resamples[i].widthPreExpansion = ( + state.imageWidth + resamples[i].horizontalExpansionFactor - 1 + ) div resamples[i].horizontalExpansionFactor + + resamples[i].line0 = cast[ptr UncheckedArray[uint8]]( + state.components[i].data[0].addr + ) + resamples[i].line1 = cast[ptr UncheckedArray[uint8]]( + state.components[i].data[0].addr + ) + state.components[i].lineBuf.setLen(state.imageWidth + 3) + + if resamples[i].horizontalExpansionFactor == 1 and + resamples[i].verticalExpansionFactor == 1: + resamples[i].resample = resampleRowH1V1 + elif resamples[i].horizontalExpansionFactor == 1 and + resamples[i].verticalExpansionFactor == 2: + resamples[i].resample = resampleRowH1V2 + elif resamples[i].horizontalExpansionFactor == 2 and + resamples[i].verticalExpansionFactor == 1: + resamples[i].resample = resampleRowH2V1 + elif resamples[i].horizontalExpansionFactor == 2 and + resamples[i].verticalExpansionFactor == 2: + resamples[i].resample = resampleRowH2V2 + else: + failInvalid() + + var componentOutputs: array[3, ptr UncheckedArray[uint8]] + for y in 0 ..< state.imageHeight: + for i in 0 ..< 3: + let yBottom = + resamples[i].yStep >= (resamples[i].verticalExpansionFactor shr 1) + componentOutputs[i] = resamples[i].resample( + cast[ptr UncheckedArray[uint8]](state.components[i].lineBuf[0].addr), + if yBottom: resamples[i].line1 else: resamples[i].line0, + if yBottom: resamples[i].line0 else: resamples[i].line1, + resamples[i].widthPreExpansion, + resamples[i].horizontalExpansionFactor + ) + + inc resamples[i].yStep + if resamples[i].yStep >= resamples[i].verticalExpansionFactor: + resamples[i].yStep = 0 + resamples[i].line0 = resamples[i].line1 + inc resamples[i].yPos + if resamples[i].yPos < state.components[i].height: + resamples[i].line1 = cast[ptr UncheckedArray[uint8]]( + state.components[i].data[ + resamples[i].yPos * state.components[i].widthStride + ].addr + ) + + let dst = cast[ptr UncheckedArray[uint8]]( + result.data[state.imageWidth * y].addr + ) + yCbCrToRgb( + dst, + componentOutputs[0], + componentOutputs[1], + componentOutputs[2], + state.imageWidth + ) proc decodeJpg*(data: string): Image {.inline.} = decodeJpg(cast[seq[uint8]](data)) diff --git a/tests/fuzz_png.nim b/tests/fuzz_png.nim index ee949a8..2c0a4a7 100644 --- a/tests/fuzz_png.nim +++ b/tests/fuzz_png.nim @@ -4,7 +4,9 @@ randomize() for i in 0 ..< 10_000: let file = pngSuiteFiles[rand(pngSuiteFiles.len - 1)] - var data = cast[seq[uint8]](readFile(&"tests/images/pngsuite/{file}.png")) + var data = cast[seq[uint8]]( + readFile(&"tests/images/png/pngsuite/{file}.png") + ) let pos = 29 + rand(data.len - 30) value = rand(255).uint8 diff --git a/tests/images/lenna.png b/tests/images/png/lenna.png similarity index 100% rename from tests/images/lenna.png rename to tests/images/png/lenna.png diff --git a/tests/images/pngsuite/PngSuite.LICENSE b/tests/images/png/pngsuite/PngSuite.LICENSE similarity index 100% rename from tests/images/pngsuite/PngSuite.LICENSE rename to tests/images/png/pngsuite/PngSuite.LICENSE diff --git a/tests/images/pngsuite/PngSuite.README b/tests/images/png/pngsuite/PngSuite.README similarity index 100% rename from tests/images/pngsuite/PngSuite.README rename to tests/images/png/pngsuite/PngSuite.README diff --git a/tests/images/pngsuite/PngSuite.png b/tests/images/png/pngsuite/PngSuite.png similarity index 100% rename from tests/images/pngsuite/PngSuite.png rename to tests/images/png/pngsuite/PngSuite.png diff --git a/tests/images/pngsuite/basi0g01.png b/tests/images/png/pngsuite/basi0g01.png similarity index 100% rename from tests/images/pngsuite/basi0g01.png rename to tests/images/png/pngsuite/basi0g01.png diff --git a/tests/images/pngsuite/basi0g02.png b/tests/images/png/pngsuite/basi0g02.png similarity index 100% rename from tests/images/pngsuite/basi0g02.png rename to tests/images/png/pngsuite/basi0g02.png diff --git a/tests/images/pngsuite/basi0g04.png b/tests/images/png/pngsuite/basi0g04.png similarity index 100% rename from tests/images/pngsuite/basi0g04.png rename to tests/images/png/pngsuite/basi0g04.png diff --git a/tests/images/pngsuite/basi0g08.png b/tests/images/png/pngsuite/basi0g08.png similarity index 100% rename from tests/images/pngsuite/basi0g08.png rename to tests/images/png/pngsuite/basi0g08.png diff --git a/tests/images/pngsuite/basi0g16.png b/tests/images/png/pngsuite/basi0g16.png similarity index 100% rename from tests/images/pngsuite/basi0g16.png rename to tests/images/png/pngsuite/basi0g16.png diff --git a/tests/images/pngsuite/basi2c08.png b/tests/images/png/pngsuite/basi2c08.png similarity index 100% rename from tests/images/pngsuite/basi2c08.png rename to tests/images/png/pngsuite/basi2c08.png diff --git a/tests/images/pngsuite/basi2c16.png b/tests/images/png/pngsuite/basi2c16.png similarity index 100% rename from tests/images/pngsuite/basi2c16.png rename to tests/images/png/pngsuite/basi2c16.png diff --git a/tests/images/pngsuite/basi3p01.png b/tests/images/png/pngsuite/basi3p01.png similarity index 100% rename from tests/images/pngsuite/basi3p01.png rename to tests/images/png/pngsuite/basi3p01.png diff --git a/tests/images/pngsuite/basi3p02.png b/tests/images/png/pngsuite/basi3p02.png similarity index 100% rename from tests/images/pngsuite/basi3p02.png rename to tests/images/png/pngsuite/basi3p02.png diff --git a/tests/images/pngsuite/basi3p04.png b/tests/images/png/pngsuite/basi3p04.png similarity index 100% rename from tests/images/pngsuite/basi3p04.png rename to tests/images/png/pngsuite/basi3p04.png diff --git a/tests/images/pngsuite/basi3p08.png b/tests/images/png/pngsuite/basi3p08.png similarity index 100% rename from tests/images/pngsuite/basi3p08.png rename to tests/images/png/pngsuite/basi3p08.png diff --git a/tests/images/pngsuite/basi4a08.png b/tests/images/png/pngsuite/basi4a08.png similarity index 100% rename from tests/images/pngsuite/basi4a08.png rename to tests/images/png/pngsuite/basi4a08.png diff --git a/tests/images/pngsuite/basi4a16.png b/tests/images/png/pngsuite/basi4a16.png similarity index 100% rename from tests/images/pngsuite/basi4a16.png rename to tests/images/png/pngsuite/basi4a16.png diff --git a/tests/images/pngsuite/basi6a08.png b/tests/images/png/pngsuite/basi6a08.png similarity index 100% rename from tests/images/pngsuite/basi6a08.png rename to tests/images/png/pngsuite/basi6a08.png diff --git a/tests/images/pngsuite/basi6a16.png b/tests/images/png/pngsuite/basi6a16.png similarity index 100% rename from tests/images/pngsuite/basi6a16.png rename to tests/images/png/pngsuite/basi6a16.png diff --git a/tests/images/pngsuite/basn0g01.png b/tests/images/png/pngsuite/basn0g01.png similarity index 100% rename from tests/images/pngsuite/basn0g01.png rename to tests/images/png/pngsuite/basn0g01.png diff --git a/tests/images/pngsuite/basn0g02.png b/tests/images/png/pngsuite/basn0g02.png similarity index 100% rename from tests/images/pngsuite/basn0g02.png rename to tests/images/png/pngsuite/basn0g02.png diff --git a/tests/images/pngsuite/basn0g04.png b/tests/images/png/pngsuite/basn0g04.png similarity index 100% rename from tests/images/pngsuite/basn0g04.png rename to tests/images/png/pngsuite/basn0g04.png diff --git a/tests/images/pngsuite/basn0g08.png b/tests/images/png/pngsuite/basn0g08.png similarity index 100% rename from tests/images/pngsuite/basn0g08.png rename to tests/images/png/pngsuite/basn0g08.png diff --git a/tests/images/pngsuite/basn0g16.png b/tests/images/png/pngsuite/basn0g16.png similarity index 100% rename from tests/images/pngsuite/basn0g16.png rename to tests/images/png/pngsuite/basn0g16.png diff --git a/tests/images/pngsuite/basn2c08.png b/tests/images/png/pngsuite/basn2c08.png similarity index 100% rename from tests/images/pngsuite/basn2c08.png rename to tests/images/png/pngsuite/basn2c08.png diff --git a/tests/images/pngsuite/basn2c16.png b/tests/images/png/pngsuite/basn2c16.png similarity index 100% rename from tests/images/pngsuite/basn2c16.png rename to tests/images/png/pngsuite/basn2c16.png diff --git a/tests/images/pngsuite/basn3p01.png b/tests/images/png/pngsuite/basn3p01.png similarity index 100% rename from tests/images/pngsuite/basn3p01.png rename to tests/images/png/pngsuite/basn3p01.png diff --git a/tests/images/pngsuite/basn3p02.png b/tests/images/png/pngsuite/basn3p02.png similarity index 100% rename from tests/images/pngsuite/basn3p02.png rename to tests/images/png/pngsuite/basn3p02.png diff --git a/tests/images/pngsuite/basn3p04.png b/tests/images/png/pngsuite/basn3p04.png similarity index 100% rename from tests/images/pngsuite/basn3p04.png rename to tests/images/png/pngsuite/basn3p04.png diff --git a/tests/images/pngsuite/basn3p08.png b/tests/images/png/pngsuite/basn3p08.png similarity index 100% rename from tests/images/pngsuite/basn3p08.png rename to tests/images/png/pngsuite/basn3p08.png diff --git a/tests/images/pngsuite/basn4a08.png b/tests/images/png/pngsuite/basn4a08.png similarity index 100% rename from tests/images/pngsuite/basn4a08.png rename to tests/images/png/pngsuite/basn4a08.png diff --git a/tests/images/pngsuite/basn4a16.png b/tests/images/png/pngsuite/basn4a16.png similarity index 100% rename from tests/images/pngsuite/basn4a16.png rename to tests/images/png/pngsuite/basn4a16.png diff --git a/tests/images/pngsuite/basn6a08.png b/tests/images/png/pngsuite/basn6a08.png similarity index 100% rename from tests/images/pngsuite/basn6a08.png rename to tests/images/png/pngsuite/basn6a08.png diff --git a/tests/images/pngsuite/basn6a16.png b/tests/images/png/pngsuite/basn6a16.png similarity index 100% rename from tests/images/pngsuite/basn6a16.png rename to tests/images/png/pngsuite/basn6a16.png diff --git a/tests/images/pngsuite/bgai4a08.png b/tests/images/png/pngsuite/bgai4a08.png similarity index 100% rename from tests/images/pngsuite/bgai4a08.png rename to tests/images/png/pngsuite/bgai4a08.png diff --git a/tests/images/pngsuite/bgai4a16.png b/tests/images/png/pngsuite/bgai4a16.png similarity index 100% rename from tests/images/pngsuite/bgai4a16.png rename to tests/images/png/pngsuite/bgai4a16.png diff --git a/tests/images/pngsuite/bgan6a08.png b/tests/images/png/pngsuite/bgan6a08.png similarity index 100% rename from tests/images/pngsuite/bgan6a08.png rename to tests/images/png/pngsuite/bgan6a08.png diff --git a/tests/images/pngsuite/bgan6a16.png b/tests/images/png/pngsuite/bgan6a16.png similarity index 100% rename from tests/images/pngsuite/bgan6a16.png rename to tests/images/png/pngsuite/bgan6a16.png diff --git a/tests/images/pngsuite/bgbn4a08.png b/tests/images/png/pngsuite/bgbn4a08.png similarity index 100% rename from tests/images/pngsuite/bgbn4a08.png rename to tests/images/png/pngsuite/bgbn4a08.png diff --git a/tests/images/pngsuite/bggn4a16.png b/tests/images/png/pngsuite/bggn4a16.png similarity index 100% rename from tests/images/pngsuite/bggn4a16.png rename to tests/images/png/pngsuite/bggn4a16.png diff --git a/tests/images/pngsuite/bgwn6a08.png b/tests/images/png/pngsuite/bgwn6a08.png similarity index 100% rename from tests/images/pngsuite/bgwn6a08.png rename to tests/images/png/pngsuite/bgwn6a08.png diff --git a/tests/images/pngsuite/bgyn6a16.png b/tests/images/png/pngsuite/bgyn6a16.png similarity index 100% rename from tests/images/pngsuite/bgyn6a16.png rename to tests/images/png/pngsuite/bgyn6a16.png diff --git a/tests/images/pngsuite/ccwn2c08.png b/tests/images/png/pngsuite/ccwn2c08.png similarity index 100% rename from tests/images/pngsuite/ccwn2c08.png rename to tests/images/png/pngsuite/ccwn2c08.png diff --git a/tests/images/pngsuite/ccwn3p08.png b/tests/images/png/pngsuite/ccwn3p08.png similarity index 100% rename from tests/images/pngsuite/ccwn3p08.png rename to tests/images/png/pngsuite/ccwn3p08.png diff --git a/tests/images/pngsuite/cdfn2c08.png b/tests/images/png/pngsuite/cdfn2c08.png similarity index 100% rename from tests/images/pngsuite/cdfn2c08.png rename to tests/images/png/pngsuite/cdfn2c08.png diff --git a/tests/images/pngsuite/cdhn2c08.png b/tests/images/png/pngsuite/cdhn2c08.png similarity index 100% rename from tests/images/pngsuite/cdhn2c08.png rename to tests/images/png/pngsuite/cdhn2c08.png diff --git a/tests/images/pngsuite/cdsn2c08.png b/tests/images/png/pngsuite/cdsn2c08.png similarity index 100% rename from tests/images/pngsuite/cdsn2c08.png rename to tests/images/png/pngsuite/cdsn2c08.png diff --git a/tests/images/pngsuite/cdun2c08.png b/tests/images/png/pngsuite/cdun2c08.png similarity index 100% rename from tests/images/pngsuite/cdun2c08.png rename to tests/images/png/pngsuite/cdun2c08.png diff --git a/tests/images/pngsuite/ch1n3p04.png b/tests/images/png/pngsuite/ch1n3p04.png similarity index 100% rename from tests/images/pngsuite/ch1n3p04.png rename to tests/images/png/pngsuite/ch1n3p04.png diff --git a/tests/images/pngsuite/ch2n3p08.png b/tests/images/png/pngsuite/ch2n3p08.png similarity index 100% rename from tests/images/pngsuite/ch2n3p08.png rename to tests/images/png/pngsuite/ch2n3p08.png diff --git a/tests/images/pngsuite/cm0n0g04.png b/tests/images/png/pngsuite/cm0n0g04.png similarity index 100% rename from tests/images/pngsuite/cm0n0g04.png rename to tests/images/png/pngsuite/cm0n0g04.png diff --git a/tests/images/pngsuite/cm7n0g04.png b/tests/images/png/pngsuite/cm7n0g04.png similarity index 100% rename from tests/images/pngsuite/cm7n0g04.png rename to tests/images/png/pngsuite/cm7n0g04.png diff --git a/tests/images/pngsuite/cm9n0g04.png b/tests/images/png/pngsuite/cm9n0g04.png similarity index 100% rename from tests/images/pngsuite/cm9n0g04.png rename to tests/images/png/pngsuite/cm9n0g04.png diff --git a/tests/images/pngsuite/cs3n2c16.png b/tests/images/png/pngsuite/cs3n2c16.png similarity index 100% rename from tests/images/pngsuite/cs3n2c16.png rename to tests/images/png/pngsuite/cs3n2c16.png diff --git a/tests/images/pngsuite/cs3n3p08.png b/tests/images/png/pngsuite/cs3n3p08.png similarity index 100% rename from tests/images/pngsuite/cs3n3p08.png rename to tests/images/png/pngsuite/cs3n3p08.png diff --git a/tests/images/pngsuite/cs5n2c08.png b/tests/images/png/pngsuite/cs5n2c08.png similarity index 100% rename from tests/images/pngsuite/cs5n2c08.png rename to tests/images/png/pngsuite/cs5n2c08.png diff --git a/tests/images/pngsuite/cs5n3p08.png b/tests/images/png/pngsuite/cs5n3p08.png similarity index 100% rename from tests/images/pngsuite/cs5n3p08.png rename to tests/images/png/pngsuite/cs5n3p08.png diff --git a/tests/images/pngsuite/cs8n2c08.png b/tests/images/png/pngsuite/cs8n2c08.png similarity index 100% rename from tests/images/pngsuite/cs8n2c08.png rename to tests/images/png/pngsuite/cs8n2c08.png diff --git a/tests/images/pngsuite/cs8n3p08.png b/tests/images/png/pngsuite/cs8n3p08.png similarity index 100% rename from tests/images/pngsuite/cs8n3p08.png rename to tests/images/png/pngsuite/cs8n3p08.png diff --git a/tests/images/pngsuite/ct0n0g04.png b/tests/images/png/pngsuite/ct0n0g04.png similarity index 100% rename from tests/images/pngsuite/ct0n0g04.png rename to tests/images/png/pngsuite/ct0n0g04.png diff --git a/tests/images/pngsuite/ct1n0g04.png b/tests/images/png/pngsuite/ct1n0g04.png similarity index 100% rename from tests/images/pngsuite/ct1n0g04.png rename to tests/images/png/pngsuite/ct1n0g04.png diff --git a/tests/images/pngsuite/cten0g04.png b/tests/images/png/pngsuite/cten0g04.png similarity index 100% rename from tests/images/pngsuite/cten0g04.png rename to tests/images/png/pngsuite/cten0g04.png diff --git a/tests/images/pngsuite/ctfn0g04.png b/tests/images/png/pngsuite/ctfn0g04.png similarity index 100% rename from tests/images/pngsuite/ctfn0g04.png rename to tests/images/png/pngsuite/ctfn0g04.png diff --git a/tests/images/pngsuite/ctgn0g04.png b/tests/images/png/pngsuite/ctgn0g04.png similarity index 100% rename from tests/images/pngsuite/ctgn0g04.png rename to tests/images/png/pngsuite/ctgn0g04.png diff --git a/tests/images/pngsuite/cthn0g04.png b/tests/images/png/pngsuite/cthn0g04.png similarity index 100% rename from tests/images/pngsuite/cthn0g04.png rename to tests/images/png/pngsuite/cthn0g04.png diff --git a/tests/images/pngsuite/ctjn0g04.png b/tests/images/png/pngsuite/ctjn0g04.png similarity index 100% rename from tests/images/pngsuite/ctjn0g04.png rename to tests/images/png/pngsuite/ctjn0g04.png diff --git a/tests/images/pngsuite/ctzn0g04.png b/tests/images/png/pngsuite/ctzn0g04.png similarity index 100% rename from tests/images/pngsuite/ctzn0g04.png rename to tests/images/png/pngsuite/ctzn0g04.png diff --git a/tests/images/pngsuite/exif2c08.png b/tests/images/png/pngsuite/exif2c08.png similarity index 100% rename from tests/images/pngsuite/exif2c08.png rename to tests/images/png/pngsuite/exif2c08.png diff --git a/tests/images/pngsuite/f00n0g08.png b/tests/images/png/pngsuite/f00n0g08.png similarity index 100% rename from tests/images/pngsuite/f00n0g08.png rename to tests/images/png/pngsuite/f00n0g08.png diff --git a/tests/images/pngsuite/f00n2c08.png b/tests/images/png/pngsuite/f00n2c08.png similarity index 100% rename from tests/images/pngsuite/f00n2c08.png rename to tests/images/png/pngsuite/f00n2c08.png diff --git a/tests/images/pngsuite/f01n0g08.png b/tests/images/png/pngsuite/f01n0g08.png similarity index 100% rename from tests/images/pngsuite/f01n0g08.png rename to tests/images/png/pngsuite/f01n0g08.png diff --git a/tests/images/pngsuite/f01n2c08.png b/tests/images/png/pngsuite/f01n2c08.png similarity index 100% rename from tests/images/pngsuite/f01n2c08.png rename to tests/images/png/pngsuite/f01n2c08.png diff --git a/tests/images/pngsuite/f02n0g08.png b/tests/images/png/pngsuite/f02n0g08.png similarity index 100% rename from tests/images/pngsuite/f02n0g08.png rename to tests/images/png/pngsuite/f02n0g08.png diff --git a/tests/images/pngsuite/f02n2c08.png b/tests/images/png/pngsuite/f02n2c08.png similarity index 100% rename from tests/images/pngsuite/f02n2c08.png rename to tests/images/png/pngsuite/f02n2c08.png diff --git a/tests/images/pngsuite/f03n0g08.png b/tests/images/png/pngsuite/f03n0g08.png similarity index 100% rename from tests/images/pngsuite/f03n0g08.png rename to tests/images/png/pngsuite/f03n0g08.png diff --git a/tests/images/pngsuite/f03n2c08.png b/tests/images/png/pngsuite/f03n2c08.png similarity index 100% rename from tests/images/pngsuite/f03n2c08.png rename to tests/images/png/pngsuite/f03n2c08.png diff --git a/tests/images/pngsuite/f04n0g08.png b/tests/images/png/pngsuite/f04n0g08.png similarity index 100% rename from tests/images/pngsuite/f04n0g08.png rename to tests/images/png/pngsuite/f04n0g08.png diff --git a/tests/images/pngsuite/f04n2c08.png b/tests/images/png/pngsuite/f04n2c08.png similarity index 100% rename from tests/images/pngsuite/f04n2c08.png rename to tests/images/png/pngsuite/f04n2c08.png diff --git a/tests/images/pngsuite/f99n0g04.png b/tests/images/png/pngsuite/f99n0g04.png similarity index 100% rename from tests/images/pngsuite/f99n0g04.png rename to tests/images/png/pngsuite/f99n0g04.png diff --git a/tests/images/pngsuite/g03n0g16.png b/tests/images/png/pngsuite/g03n0g16.png similarity index 100% rename from tests/images/pngsuite/g03n0g16.png rename to tests/images/png/pngsuite/g03n0g16.png diff --git a/tests/images/pngsuite/g03n2c08.png b/tests/images/png/pngsuite/g03n2c08.png similarity index 100% rename from tests/images/pngsuite/g03n2c08.png rename to tests/images/png/pngsuite/g03n2c08.png diff --git a/tests/images/pngsuite/g03n3p04.png b/tests/images/png/pngsuite/g03n3p04.png similarity index 100% rename from tests/images/pngsuite/g03n3p04.png rename to tests/images/png/pngsuite/g03n3p04.png diff --git a/tests/images/pngsuite/g04n0g16.png b/tests/images/png/pngsuite/g04n0g16.png similarity index 100% rename from tests/images/pngsuite/g04n0g16.png rename to tests/images/png/pngsuite/g04n0g16.png diff --git a/tests/images/pngsuite/g04n2c08.png b/tests/images/png/pngsuite/g04n2c08.png similarity index 100% rename from tests/images/pngsuite/g04n2c08.png rename to tests/images/png/pngsuite/g04n2c08.png diff --git a/tests/images/pngsuite/g04n3p04.png b/tests/images/png/pngsuite/g04n3p04.png similarity index 100% rename from tests/images/pngsuite/g04n3p04.png rename to tests/images/png/pngsuite/g04n3p04.png diff --git a/tests/images/pngsuite/g05n0g16.png b/tests/images/png/pngsuite/g05n0g16.png similarity index 100% rename from tests/images/pngsuite/g05n0g16.png rename to tests/images/png/pngsuite/g05n0g16.png diff --git a/tests/images/pngsuite/g05n2c08.png b/tests/images/png/pngsuite/g05n2c08.png similarity index 100% rename from tests/images/pngsuite/g05n2c08.png rename to tests/images/png/pngsuite/g05n2c08.png diff --git a/tests/images/pngsuite/g05n3p04.png b/tests/images/png/pngsuite/g05n3p04.png similarity index 100% rename from tests/images/pngsuite/g05n3p04.png rename to tests/images/png/pngsuite/g05n3p04.png diff --git a/tests/images/pngsuite/g07n0g16.png b/tests/images/png/pngsuite/g07n0g16.png similarity index 100% rename from tests/images/pngsuite/g07n0g16.png rename to tests/images/png/pngsuite/g07n0g16.png diff --git a/tests/images/pngsuite/g07n2c08.png b/tests/images/png/pngsuite/g07n2c08.png similarity index 100% rename from tests/images/pngsuite/g07n2c08.png rename to tests/images/png/pngsuite/g07n2c08.png diff --git a/tests/images/pngsuite/g07n3p04.png b/tests/images/png/pngsuite/g07n3p04.png similarity index 100% rename from tests/images/pngsuite/g07n3p04.png rename to tests/images/png/pngsuite/g07n3p04.png diff --git a/tests/images/pngsuite/g10n0g16.png b/tests/images/png/pngsuite/g10n0g16.png similarity index 100% rename from tests/images/pngsuite/g10n0g16.png rename to tests/images/png/pngsuite/g10n0g16.png diff --git a/tests/images/pngsuite/g10n2c08.png b/tests/images/png/pngsuite/g10n2c08.png similarity index 100% rename from tests/images/pngsuite/g10n2c08.png rename to tests/images/png/pngsuite/g10n2c08.png diff --git a/tests/images/pngsuite/g10n3p04.png b/tests/images/png/pngsuite/g10n3p04.png similarity index 100% rename from tests/images/pngsuite/g10n3p04.png rename to tests/images/png/pngsuite/g10n3p04.png diff --git a/tests/images/pngsuite/g25n0g16.png b/tests/images/png/pngsuite/g25n0g16.png similarity index 100% rename from tests/images/pngsuite/g25n0g16.png rename to tests/images/png/pngsuite/g25n0g16.png diff --git a/tests/images/pngsuite/g25n2c08.png b/tests/images/png/pngsuite/g25n2c08.png similarity index 100% rename from tests/images/pngsuite/g25n2c08.png rename to tests/images/png/pngsuite/g25n2c08.png diff --git a/tests/images/pngsuite/g25n3p04.png b/tests/images/png/pngsuite/g25n3p04.png similarity index 100% rename from tests/images/pngsuite/g25n3p04.png rename to tests/images/png/pngsuite/g25n3p04.png diff --git a/tests/images/pngsuite/oi1n0g16.png b/tests/images/png/pngsuite/oi1n0g16.png similarity index 100% rename from tests/images/pngsuite/oi1n0g16.png rename to tests/images/png/pngsuite/oi1n0g16.png diff --git a/tests/images/pngsuite/oi1n2c16.png b/tests/images/png/pngsuite/oi1n2c16.png similarity index 100% rename from tests/images/pngsuite/oi1n2c16.png rename to tests/images/png/pngsuite/oi1n2c16.png diff --git a/tests/images/pngsuite/oi2n0g16.png b/tests/images/png/pngsuite/oi2n0g16.png similarity index 100% rename from tests/images/pngsuite/oi2n0g16.png rename to tests/images/png/pngsuite/oi2n0g16.png diff --git a/tests/images/pngsuite/oi2n2c16.png b/tests/images/png/pngsuite/oi2n2c16.png similarity index 100% rename from tests/images/pngsuite/oi2n2c16.png rename to tests/images/png/pngsuite/oi2n2c16.png diff --git a/tests/images/pngsuite/oi4n0g16.png b/tests/images/png/pngsuite/oi4n0g16.png similarity index 100% rename from tests/images/pngsuite/oi4n0g16.png rename to tests/images/png/pngsuite/oi4n0g16.png diff --git a/tests/images/pngsuite/oi4n2c16.png b/tests/images/png/pngsuite/oi4n2c16.png similarity index 100% rename from tests/images/pngsuite/oi4n2c16.png rename to tests/images/png/pngsuite/oi4n2c16.png diff --git a/tests/images/pngsuite/oi9n0g16.png b/tests/images/png/pngsuite/oi9n0g16.png similarity index 100% rename from tests/images/pngsuite/oi9n0g16.png rename to tests/images/png/pngsuite/oi9n0g16.png diff --git a/tests/images/pngsuite/oi9n2c16.png b/tests/images/png/pngsuite/oi9n2c16.png similarity index 100% rename from tests/images/pngsuite/oi9n2c16.png rename to tests/images/png/pngsuite/oi9n2c16.png diff --git a/tests/images/pngsuite/pp0n2c16.png b/tests/images/png/pngsuite/pp0n2c16.png similarity index 100% rename from tests/images/pngsuite/pp0n2c16.png rename to tests/images/png/pngsuite/pp0n2c16.png diff --git a/tests/images/pngsuite/pp0n6a08.png b/tests/images/png/pngsuite/pp0n6a08.png similarity index 100% rename from tests/images/pngsuite/pp0n6a08.png rename to tests/images/png/pngsuite/pp0n6a08.png diff --git a/tests/images/pngsuite/ps1n0g08.png b/tests/images/png/pngsuite/ps1n0g08.png similarity index 100% rename from tests/images/pngsuite/ps1n0g08.png rename to tests/images/png/pngsuite/ps1n0g08.png diff --git a/tests/images/pngsuite/ps1n2c16.png b/tests/images/png/pngsuite/ps1n2c16.png similarity index 100% rename from tests/images/pngsuite/ps1n2c16.png rename to tests/images/png/pngsuite/ps1n2c16.png diff --git a/tests/images/pngsuite/ps2n0g08.png b/tests/images/png/pngsuite/ps2n0g08.png similarity index 100% rename from tests/images/pngsuite/ps2n0g08.png rename to tests/images/png/pngsuite/ps2n0g08.png diff --git a/tests/images/pngsuite/ps2n2c16.png b/tests/images/png/pngsuite/ps2n2c16.png similarity index 100% rename from tests/images/pngsuite/ps2n2c16.png rename to tests/images/png/pngsuite/ps2n2c16.png diff --git a/tests/images/pngsuite/s01i3p01.png b/tests/images/png/pngsuite/s01i3p01.png similarity index 100% rename from tests/images/pngsuite/s01i3p01.png rename to tests/images/png/pngsuite/s01i3p01.png diff --git a/tests/images/pngsuite/s01n3p01.png b/tests/images/png/pngsuite/s01n3p01.png similarity index 100% rename from tests/images/pngsuite/s01n3p01.png rename to tests/images/png/pngsuite/s01n3p01.png diff --git a/tests/images/pngsuite/s02i3p01.png b/tests/images/png/pngsuite/s02i3p01.png similarity index 100% rename from tests/images/pngsuite/s02i3p01.png rename to tests/images/png/pngsuite/s02i3p01.png diff --git a/tests/images/pngsuite/s02n3p01.png b/tests/images/png/pngsuite/s02n3p01.png similarity index 100% rename from tests/images/pngsuite/s02n3p01.png rename to tests/images/png/pngsuite/s02n3p01.png diff --git a/tests/images/pngsuite/s03i3p01.png b/tests/images/png/pngsuite/s03i3p01.png similarity index 100% rename from tests/images/pngsuite/s03i3p01.png rename to tests/images/png/pngsuite/s03i3p01.png diff --git a/tests/images/pngsuite/s03n3p01.png b/tests/images/png/pngsuite/s03n3p01.png similarity index 100% rename from tests/images/pngsuite/s03n3p01.png rename to tests/images/png/pngsuite/s03n3p01.png diff --git a/tests/images/pngsuite/s04i3p01.png b/tests/images/png/pngsuite/s04i3p01.png similarity index 100% rename from tests/images/pngsuite/s04i3p01.png rename to tests/images/png/pngsuite/s04i3p01.png diff --git a/tests/images/pngsuite/s04n3p01.png b/tests/images/png/pngsuite/s04n3p01.png similarity index 100% rename from tests/images/pngsuite/s04n3p01.png rename to tests/images/png/pngsuite/s04n3p01.png diff --git a/tests/images/pngsuite/s05i3p02.png b/tests/images/png/pngsuite/s05i3p02.png similarity index 100% rename from tests/images/pngsuite/s05i3p02.png rename to tests/images/png/pngsuite/s05i3p02.png diff --git a/tests/images/pngsuite/s05n3p02.png b/tests/images/png/pngsuite/s05n3p02.png similarity index 100% rename from tests/images/pngsuite/s05n3p02.png rename to tests/images/png/pngsuite/s05n3p02.png diff --git a/tests/images/pngsuite/s06i3p02.png b/tests/images/png/pngsuite/s06i3p02.png similarity index 100% rename from tests/images/pngsuite/s06i3p02.png rename to tests/images/png/pngsuite/s06i3p02.png diff --git a/tests/images/pngsuite/s06n3p02.png b/tests/images/png/pngsuite/s06n3p02.png similarity index 100% rename from tests/images/pngsuite/s06n3p02.png rename to tests/images/png/pngsuite/s06n3p02.png diff --git a/tests/images/pngsuite/s07i3p02.png b/tests/images/png/pngsuite/s07i3p02.png similarity index 100% rename from tests/images/pngsuite/s07i3p02.png rename to tests/images/png/pngsuite/s07i3p02.png diff --git a/tests/images/pngsuite/s07n3p02.png b/tests/images/png/pngsuite/s07n3p02.png similarity index 100% rename from tests/images/pngsuite/s07n3p02.png rename to tests/images/png/pngsuite/s07n3p02.png diff --git a/tests/images/pngsuite/s08i3p02.png b/tests/images/png/pngsuite/s08i3p02.png similarity index 100% rename from tests/images/pngsuite/s08i3p02.png rename to tests/images/png/pngsuite/s08i3p02.png diff --git a/tests/images/pngsuite/s08n3p02.png b/tests/images/png/pngsuite/s08n3p02.png similarity index 100% rename from tests/images/pngsuite/s08n3p02.png rename to tests/images/png/pngsuite/s08n3p02.png diff --git a/tests/images/pngsuite/s09i3p02.png b/tests/images/png/pngsuite/s09i3p02.png similarity index 100% rename from tests/images/pngsuite/s09i3p02.png rename to tests/images/png/pngsuite/s09i3p02.png diff --git a/tests/images/pngsuite/s09n3p02.png b/tests/images/png/pngsuite/s09n3p02.png similarity index 100% rename from tests/images/pngsuite/s09n3p02.png rename to tests/images/png/pngsuite/s09n3p02.png diff --git a/tests/images/pngsuite/s32i3p04.png b/tests/images/png/pngsuite/s32i3p04.png similarity index 100% rename from tests/images/pngsuite/s32i3p04.png rename to tests/images/png/pngsuite/s32i3p04.png diff --git a/tests/images/pngsuite/s32n3p04.png b/tests/images/png/pngsuite/s32n3p04.png similarity index 100% rename from tests/images/pngsuite/s32n3p04.png rename to tests/images/png/pngsuite/s32n3p04.png diff --git a/tests/images/pngsuite/s33i3p04.png b/tests/images/png/pngsuite/s33i3p04.png similarity index 100% rename from tests/images/pngsuite/s33i3p04.png rename to tests/images/png/pngsuite/s33i3p04.png diff --git a/tests/images/pngsuite/s33n3p04.png b/tests/images/png/pngsuite/s33n3p04.png similarity index 100% rename from tests/images/pngsuite/s33n3p04.png rename to tests/images/png/pngsuite/s33n3p04.png diff --git a/tests/images/pngsuite/s34i3p04.png b/tests/images/png/pngsuite/s34i3p04.png similarity index 100% rename from tests/images/pngsuite/s34i3p04.png rename to tests/images/png/pngsuite/s34i3p04.png diff --git a/tests/images/pngsuite/s34n3p04.png b/tests/images/png/pngsuite/s34n3p04.png similarity index 100% rename from tests/images/pngsuite/s34n3p04.png rename to tests/images/png/pngsuite/s34n3p04.png diff --git a/tests/images/pngsuite/s35i3p04.png b/tests/images/png/pngsuite/s35i3p04.png similarity index 100% rename from tests/images/pngsuite/s35i3p04.png rename to tests/images/png/pngsuite/s35i3p04.png diff --git a/tests/images/pngsuite/s35n3p04.png b/tests/images/png/pngsuite/s35n3p04.png similarity index 100% rename from tests/images/pngsuite/s35n3p04.png rename to tests/images/png/pngsuite/s35n3p04.png diff --git a/tests/images/pngsuite/s36i3p04.png b/tests/images/png/pngsuite/s36i3p04.png similarity index 100% rename from tests/images/pngsuite/s36i3p04.png rename to tests/images/png/pngsuite/s36i3p04.png diff --git a/tests/images/pngsuite/s36n3p04.png b/tests/images/png/pngsuite/s36n3p04.png similarity index 100% rename from tests/images/pngsuite/s36n3p04.png rename to tests/images/png/pngsuite/s36n3p04.png diff --git a/tests/images/pngsuite/s37i3p04.png b/tests/images/png/pngsuite/s37i3p04.png similarity index 100% rename from tests/images/pngsuite/s37i3p04.png rename to tests/images/png/pngsuite/s37i3p04.png diff --git a/tests/images/pngsuite/s37n3p04.png b/tests/images/png/pngsuite/s37n3p04.png similarity index 100% rename from tests/images/pngsuite/s37n3p04.png rename to tests/images/png/pngsuite/s37n3p04.png diff --git a/tests/images/pngsuite/s38i3p04.png b/tests/images/png/pngsuite/s38i3p04.png similarity index 100% rename from tests/images/pngsuite/s38i3p04.png rename to tests/images/png/pngsuite/s38i3p04.png diff --git a/tests/images/pngsuite/s38n3p04.png b/tests/images/png/pngsuite/s38n3p04.png similarity index 100% rename from tests/images/pngsuite/s38n3p04.png rename to tests/images/png/pngsuite/s38n3p04.png diff --git a/tests/images/pngsuite/s39i3p04.png b/tests/images/png/pngsuite/s39i3p04.png similarity index 100% rename from tests/images/pngsuite/s39i3p04.png rename to tests/images/png/pngsuite/s39i3p04.png diff --git a/tests/images/pngsuite/s39n3p04.png b/tests/images/png/pngsuite/s39n3p04.png similarity index 100% rename from tests/images/pngsuite/s39n3p04.png rename to tests/images/png/pngsuite/s39n3p04.png diff --git a/tests/images/pngsuite/s40i3p04.png b/tests/images/png/pngsuite/s40i3p04.png similarity index 100% rename from tests/images/pngsuite/s40i3p04.png rename to tests/images/png/pngsuite/s40i3p04.png diff --git a/tests/images/pngsuite/s40n3p04.png b/tests/images/png/pngsuite/s40n3p04.png similarity index 100% rename from tests/images/pngsuite/s40n3p04.png rename to tests/images/png/pngsuite/s40n3p04.png diff --git a/tests/images/pngsuite/tbbn0g04.png b/tests/images/png/pngsuite/tbbn0g04.png similarity index 100% rename from tests/images/pngsuite/tbbn0g04.png rename to tests/images/png/pngsuite/tbbn0g04.png diff --git a/tests/images/pngsuite/tbbn2c16.png b/tests/images/png/pngsuite/tbbn2c16.png similarity index 100% rename from tests/images/pngsuite/tbbn2c16.png rename to tests/images/png/pngsuite/tbbn2c16.png diff --git a/tests/images/pngsuite/tbbn3p08.png b/tests/images/png/pngsuite/tbbn3p08.png similarity index 100% rename from tests/images/pngsuite/tbbn3p08.png rename to tests/images/png/pngsuite/tbbn3p08.png diff --git a/tests/images/pngsuite/tbgn2c16.png b/tests/images/png/pngsuite/tbgn2c16.png similarity index 100% rename from tests/images/pngsuite/tbgn2c16.png rename to tests/images/png/pngsuite/tbgn2c16.png diff --git a/tests/images/pngsuite/tbgn3p08.png b/tests/images/png/pngsuite/tbgn3p08.png similarity index 100% rename from tests/images/pngsuite/tbgn3p08.png rename to tests/images/png/pngsuite/tbgn3p08.png diff --git a/tests/images/pngsuite/tbrn2c08.png b/tests/images/png/pngsuite/tbrn2c08.png similarity index 100% rename from tests/images/pngsuite/tbrn2c08.png rename to tests/images/png/pngsuite/tbrn2c08.png diff --git a/tests/images/pngsuite/tbwn0g16.png b/tests/images/png/pngsuite/tbwn0g16.png similarity index 100% rename from tests/images/pngsuite/tbwn0g16.png rename to tests/images/png/pngsuite/tbwn0g16.png diff --git a/tests/images/pngsuite/tbwn3p08.png b/tests/images/png/pngsuite/tbwn3p08.png similarity index 100% rename from tests/images/pngsuite/tbwn3p08.png rename to tests/images/png/pngsuite/tbwn3p08.png diff --git a/tests/images/pngsuite/tbyn3p08.png b/tests/images/png/pngsuite/tbyn3p08.png similarity index 100% rename from tests/images/pngsuite/tbyn3p08.png rename to tests/images/png/pngsuite/tbyn3p08.png diff --git a/tests/images/pngsuite/tm3n3p02.png b/tests/images/png/pngsuite/tm3n3p02.png similarity index 100% rename from tests/images/pngsuite/tm3n3p02.png rename to tests/images/png/pngsuite/tm3n3p02.png diff --git a/tests/images/pngsuite/tp0n0g08.png b/tests/images/png/pngsuite/tp0n0g08.png similarity index 100% rename from tests/images/pngsuite/tp0n0g08.png rename to tests/images/png/pngsuite/tp0n0g08.png diff --git a/tests/images/pngsuite/tp0n2c08.png b/tests/images/png/pngsuite/tp0n2c08.png similarity index 100% rename from tests/images/pngsuite/tp0n2c08.png rename to tests/images/png/pngsuite/tp0n2c08.png diff --git a/tests/images/pngsuite/tp0n3p08.png b/tests/images/png/pngsuite/tp0n3p08.png similarity index 100% rename from tests/images/pngsuite/tp0n3p08.png rename to tests/images/png/pngsuite/tp0n3p08.png diff --git a/tests/images/pngsuite/tp1n3p08.png b/tests/images/png/pngsuite/tp1n3p08.png similarity index 100% rename from tests/images/pngsuite/tp1n3p08.png rename to tests/images/png/pngsuite/tp1n3p08.png diff --git a/tests/images/pngsuite/xc1n0g08.png b/tests/images/png/pngsuite/xc1n0g08.png similarity index 100% rename from tests/images/pngsuite/xc1n0g08.png rename to tests/images/png/pngsuite/xc1n0g08.png diff --git a/tests/images/pngsuite/xc9n2c08.png b/tests/images/png/pngsuite/xc9n2c08.png similarity index 100% rename from tests/images/pngsuite/xc9n2c08.png rename to tests/images/png/pngsuite/xc9n2c08.png diff --git a/tests/images/pngsuite/xcrn0g04.png b/tests/images/png/pngsuite/xcrn0g04.png similarity index 100% rename from tests/images/pngsuite/xcrn0g04.png rename to tests/images/png/pngsuite/xcrn0g04.png diff --git a/tests/images/pngsuite/xcsn0g01.png b/tests/images/png/pngsuite/xcsn0g01.png similarity index 100% rename from tests/images/pngsuite/xcsn0g01.png rename to tests/images/png/pngsuite/xcsn0g01.png diff --git a/tests/images/pngsuite/xd0n2c08.png b/tests/images/png/pngsuite/xd0n2c08.png similarity index 100% rename from tests/images/pngsuite/xd0n2c08.png rename to tests/images/png/pngsuite/xd0n2c08.png diff --git a/tests/images/pngsuite/xd3n2c08.png b/tests/images/png/pngsuite/xd3n2c08.png similarity index 100% rename from tests/images/pngsuite/xd3n2c08.png rename to tests/images/png/pngsuite/xd3n2c08.png diff --git a/tests/images/pngsuite/xd9n2c08.png b/tests/images/png/pngsuite/xd9n2c08.png similarity index 100% rename from tests/images/pngsuite/xd9n2c08.png rename to tests/images/png/pngsuite/xd9n2c08.png diff --git a/tests/images/pngsuite/xdtn0g01.png b/tests/images/png/pngsuite/xdtn0g01.png similarity index 100% rename from tests/images/pngsuite/xdtn0g01.png rename to tests/images/png/pngsuite/xdtn0g01.png diff --git a/tests/images/pngsuite/xhdn0g08.png b/tests/images/png/pngsuite/xhdn0g08.png similarity index 100% rename from tests/images/pngsuite/xhdn0g08.png rename to tests/images/png/pngsuite/xhdn0g08.png diff --git a/tests/images/pngsuite/xlfn0g04.png b/tests/images/png/pngsuite/xlfn0g04.png similarity index 100% rename from tests/images/pngsuite/xlfn0g04.png rename to tests/images/png/pngsuite/xlfn0g04.png diff --git a/tests/images/pngsuite/xs1n0g01.png b/tests/images/png/pngsuite/xs1n0g01.png similarity index 100% rename from tests/images/pngsuite/xs1n0g01.png rename to tests/images/png/pngsuite/xs1n0g01.png diff --git a/tests/images/pngsuite/xs2n0g01.png b/tests/images/png/pngsuite/xs2n0g01.png similarity index 100% rename from tests/images/pngsuite/xs2n0g01.png rename to tests/images/png/pngsuite/xs2n0g01.png diff --git a/tests/images/pngsuite/xs4n0g01.png b/tests/images/png/pngsuite/xs4n0g01.png similarity index 100% rename from tests/images/pngsuite/xs4n0g01.png rename to tests/images/png/pngsuite/xs4n0g01.png diff --git a/tests/images/pngsuite/xs7n0g01.png b/tests/images/png/pngsuite/xs7n0g01.png similarity index 100% rename from tests/images/pngsuite/xs7n0g01.png rename to tests/images/png/pngsuite/xs7n0g01.png diff --git a/tests/images/pngsuite/z00n2c08.png b/tests/images/png/pngsuite/z00n2c08.png similarity index 100% rename from tests/images/pngsuite/z00n2c08.png rename to tests/images/png/pngsuite/z00n2c08.png diff --git a/tests/images/pngsuite/z03n2c08.png b/tests/images/png/pngsuite/z03n2c08.png similarity index 100% rename from tests/images/pngsuite/z03n2c08.png rename to tests/images/png/pngsuite/z03n2c08.png diff --git a/tests/images/pngsuite/z06n2c08.png b/tests/images/png/pngsuite/z06n2c08.png similarity index 100% rename from tests/images/pngsuite/z06n2c08.png rename to tests/images/png/pngsuite/z06n2c08.png diff --git a/tests/images/pngsuite/z09n2c08.png b/tests/images/png/pngsuite/z09n2c08.png similarity index 100% rename from tests/images/pngsuite/z09n2c08.png rename to tests/images/png/pngsuite/z09n2c08.png diff --git a/tests/test_jpg.nim b/tests/test_jpg.nim index 413e3cc..13798e2 100644 --- a/tests/test_jpg.nim +++ b/tests/test_jpg.nim @@ -1,5 +1,26 @@ -import pixie/fileformats/jpgstb +import pixie/images, pixie/fileformats/jpg, pixie/fileformats/stb_image/stb_image -let original = readFile("tests/images/jpg/jpeg420exif.jpg") +proc stbDecode*(data: string): Image = + ## Decodes the JPEG into an Image. + var + width: int + height: int + let pixels = loadFromMemory(cast[seq[uint8]](data), width, height) -discard decodeJpg(original) + result = newImage(width, height) + copyMem(result.data[0].addr, pixels[0].unsafeAddr, pixels.len) + +let + original = readFile("tests/images/jpg/jpeg420exif.jpg") + pixieDecoded = decodeJpg(original) + stbDecoded = stbDecode(original) + +doAssert pixieDecoded.width == stbDecoded.width +doAssert pixieDecoded.height == stbDecoded.height +doAssert pixieDecoded.data.len == stbDecoded.data.len +# doAssert pixieDecoded.data == stbDecoded.data + +for i in 0 ..< pixieDecoded.data.len: + if pixieDecoded.data[i] != stbDecoded.data[i]: + echo pixieDecoded.data[i], " != ", stbDecoded.data[i], " @ ", i + break diff --git a/tests/test_png.nim b/tests/test_png.nim index b3eaa01..7fa59c1 100644 --- a/tests/test_png.nim +++ b/tests/test_png.nim @@ -2,7 +2,9 @@ import pixie/fileformats/png, strformat, pngsuite, pixie/common for file in pngSuiteFiles: let - original = cast[seq[uint8]](readFile(&"tests/images/pngsuite/{file}.png")) + original = cast[seq[uint8]]( + readFile(&"tests/images/png/pngsuite/{file}.png") + ) decoded = decodePng(original) encoded = encodePng(decoded) decoded2 = decodePng(cast[seq[uint8]](encoded)) @@ -23,7 +25,7 @@ for channels in 1 .. 4: for file in pngSuiteCorruptedFiles: try: - discard decodePng(readFile(&"tests/images/pngsuite/{file}.png")) + discard decodePng(readFile(&"tests/images/png/pngsuite/{file}.png")) doAssert false except PixieError: discard diff --git a/tests/validate_jpg.nim b/tests/validate_jpg.nim new file mode 100644 index 0000000..93de6ad --- /dev/null +++ b/tests/validate_jpg.nim @@ -0,0 +1,3 @@ +import pixie/fileformats/jpg, pixie/fileformats/stb_image/stb_image + +let original = readFile("tests/images/jpg/jpeg420exif.jpg")