From 7f67da5de1bd6c849758f4621cc0c3e5bcbc757f Mon Sep 17 00:00:00 2001 From: Frank Warmerdam Date: Fri, 1 Jun 2012 21:04:22 +0000 Subject: [PATCH] add jpeg in tiff decode testing --- test/Makefile.am | 10 +- test/images/quad-tile.jpg.tiff | Bin 0 -> 27576 bytes test/raw_decode.c | 216 +++++++++++++++++++++++++++++++++ 3 files changed, 223 insertions(+), 3 deletions(-) create mode 100644 test/images/quad-tile.jpg.tiff create mode 100644 test/raw_decode.c diff --git a/test/Makefile.am b/test/Makefile.am index de9289a6..e86bdd8b 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -48,7 +48,7 @@ XFAIL_TESTS = CLEANFILES = test_packbits.tif o-* # Executable programs which need to be built in order to support tests -check_PROGRAMS = ascii_tag long_tag short_tag strip_rw rewrite +check_PROGRAMS = ascii_tag long_tag short_tag strip_rw rewrite raw_decode # Test scripts to execute TESTSCRIPTS = \ @@ -124,7 +124,8 @@ TESTSCRIPTS = \ tiff2rgba-palette-1c-4b.sh \ tiff2rgba-palette-1c-8b.sh \ tiff2rgba-rgb-3c-16b.sh \ - tiff2rgba-rgb-3c-8b.sh + tiff2rgba-rgb-3c-8b.sh \ + tiff2rgba-quad-tile.jpg.sh # This list should contain all of the TIFF files in the 'images' # subdirectory which are intended to be used as input images for @@ -139,7 +140,8 @@ TIFFIMAGES = \ images/palette-1c-4b.tiff \ images/palette-1c-8b.tiff \ images/rgb-3c-16b.tiff \ - images/rgb-3c-8b.tiff + images/rgb-3c-8b.tiff \ + images/quad-tile.jpg.tiff BMPIMAGES = \ images/palette-1c-8b.bmp \ @@ -175,6 +177,8 @@ strip_rw_SOURCES = strip_rw.c strip.c test_arrays.c test_arrays.h strip_rw_LDADD = $(LIBTIFF) rewrite_SOURCES = rewrite_tag.c rewrite_LDADD = $(LIBTIFF) +raw_decode_SOURCES = raw_decode.c +raw_decode_LDADD = $(LIBTIFF) INCLUDES = -I$(top_srcdir)/libtiff diff --git a/test/images/quad-tile.jpg.tiff b/test/images/quad-tile.jpg.tiff new file mode 100644 index 0000000000000000000000000000000000000000..99b0bc2e741153d305862a2ec45bfd53f1718849 GIT binary patch literal 27576 zcmeFZbx@n{w=WtBlmZ2c1c%T9#flfVLXiT+t$2Y_B*k5W6e$H#yjUn!Gz51mTC6z1 zi$ieN05{*?z5AXscV_Ro=lpSJ_TD!$YuL9kFl{ZH`t^A8Nk(D6#I_{|6f@C&C9>mHwKA|iuVBC!QO!;nw|g`Wha~z z1OB;=ro6Zi_Os_L@iGLn!^;mxe$nX8SFYX}9eV``Ub~oz`U{rkAvFforjL9%PF}M% zAIl0*Bnz`|`-Tud`f0$|f%yYO=`tkgNlNi|vp|o>A`jWFtj^%75In;-)9GEpqh;cy z3b7D=&5qa8b8+_o$%(+%K$efKQ^~5qN$h`ybsN8rf!Eq}ZP|iOJ$F`qN8C1o z?s!VO4-a13Xy5Td9eo~*geV~cG-HbUX}^4!X03$yptSp0rFK;Jq4$7iVBStBejR#9 z0DAM0Q|GX^BRZPAI~D;=tbP>~&`VP~A!JQt^`d}q!&leam&CUcE%W>MnmwoW?V(&0 zXLnLw3bK5*`y%g?&4`yw(8gy(4mSModD0DX^0{o-71J=n^DgTPLSrn;?~PP&nb{xF zUASfKXG_sU_KSM&Dw=yNC5z^RGt(U;mQv zK?oaSyd$EZoF}_Pi#{zUyzJL(gH5DVu>_-y0);_;Ru-5VwMubXY-|BX*rn)q8=171i|eLB`Q&!F#VUwMkxOm zbNkQl0nQNdRWftm9e>)n{W6(((4S~MKOGxSft2UOPS*D|vHzd<|t)Ou=<608NzN#d^bI?ZYxD-`9u z;Hpt<{$<}m8>HK(_d@xM`lIpJ8e7@fLWS9CrahA+ezq!Qn3V$XW6!*aNzh-Hz>oI; zf@R14T{L=bbgw(VAg$e}^5oR4qZ+4ql5d!clvdEHGJ4`GQ6I{Q_x2D>Wy(`f5SkAx zh2^g$H-R4X8|%TOdmi*2THFbB^*VXo1Ej|xf2&MWf-EwHilWPZe?9kHPY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5g!VZYh0=dc;7J03Q zdv`Z*v*w;yD36GDBIBp~_1)$cqRnV0?cb+d?;hw|JcysUlzr8d8H`J^s!2KEr?p7u z9V0VzW5yRUNyrVpxyEzb!eG`so|85=VU4sWZ`9^OCN!J4GY-qHe8Kcn_PV;iO^I%SC+#+07)6zyGSNw3$Hu(Y4;*_{?rXwRAU+vB>8Nf^Sdy9jykXDuWC*>4Ej7e&PTStNr|* zN)YSf5CU+pzu!Pifs1$6b#TK4C~*lu^#Hg$KKlRwqTklv@hNb&5`md9u*wKI05nnq zKokrB;8y^k`8oi+xdQ-PVgT@68UXGq1HhIR0Q7@(Pe8F3!G@h+ngQnDfoTPpPY1U& z5IceCXJP<&24ei*)_ble5cH*Jp0-UT@xd`}q3# zhlYhmL`Hpxj!8~QO-s+nL}h(0C@d;2DJ?7iR$Eu!(Ad=6(%sYB*FP{gG(0(lnVy-Q zn_s}LZ)|RD@9ggFAAsG4;edDMujO~i{z0ybpj^24_;~n)XL8|yKDS_ni}(aAJm)CH zRS1n7E?wq*MMQZ&Bq_g!n3Yd;4QlMzMMA}Pdy;+qOtjx5`{x9E{ih`RZ^8a1*U*_H zIKPQA0bV)gGj!qi^pErZGl$7d|2&5&!M49ROb6nBg~QBX{a+k@2;yHHehK1V9QFqB zA91+O{I^r^7l*_p hhvh;1M;!LG{@>y-4)_Gc`S + * + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that (i) the above copyright notices and this permission notice appear in + * all copies of the software and related documentation, and (ii) the names of + * Sam Leffler and Silicon Graphics may not be used in any advertising or + * publicity relating to the software without the specific, prior written + * permission of Sam Leffler and Silicon Graphics. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR + * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, + * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, + * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF + * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE + * OF THIS SOFTWARE. + */ + +/* + * TIFF Library + * + * The objective of this test suite is to test the JPEGRawDecode() + * interface via TIFReadEncodedTile(). This function with YCbCr subsampling + * is a frequent source of bugs. + */ + +#include "tif_config.h" + +#include +#include +#include +#ifdef HAVE_UNISTD_H +# include +#endif + +#include "tiffio.h" + +static unsigned char cluster_0[] = { 0, 0, 2, 0, 138, 139 }; +static unsigned char cluster_64[] = { 0, 0, 9, 6, 134, 119 }; +static unsigned char cluster_128[] = { 44, 40, 63, 59, 230, 95 }; + +static int check_cluster( int cluster, unsigned char *buffer, unsigned char *expected_cluster ) { + unsigned char *target = buffer + cluster*6; + + if (memcmp(target, expected_cluster, 6) == 0) { + return 0; + } + + fprintf( stderr, "Cluster %d did not match expected results.\n", cluster ); + fprintf( stderr, + "Expect: %3d %3d %3d %3d\n" + " %3d %3d\n", + expected_cluster[0], expected_cluster[1], + expected_cluster[4], expected_cluster[5], + expected_cluster[2], expected_cluster[3] ); + fprintf( stderr, + " Got: %3d %3d %3d %3d\n" + " %3d %3d\n", + target[0], target[1], + target[4], target[5], + target[2], target[3] ); + return 1; +} + +static int check_rgb_pixel( int pixel, int red, int green, int blue, unsigned char *buffer ) { + unsigned char *rgb = buffer + 3 * pixel; + + if( rgb[0] == red && rgb[1] == green && rgb[2] == blue ) { + return 0; + } + + fprintf( stderr, "Pixel %d did not match expected results.\n", pixel ); + fprintf( stderr, "Expect: %3d %3d %3d\n", red, green, blue ); + fprintf( stderr, " Got: %3d %3d %3d\n", rgb[0], rgb[1], rgb[2] ); + return 1; +} + +static int check_rgba_pixel( int pixel, int red, int green, int blue, int alpha, unsigned char *buffer ) { + /* RGBA images are upside down - adjust for normal ordering */ + int adjusted_pixel = pixel % 128 + (127 - (pixel/128)) * 128; + unsigned char *rgba = buffer + 4 * adjusted_pixel; + + if( rgba[0] == red && rgba[1] == green && rgba[2] == blue && rgba[3] == alpha ) { + return 0; + } + + fprintf( stderr, "Pixel %d did not match expected results.\n", pixel ); + fprintf( stderr, "Expect: %3d %3d %3d %3d\n", red, green, blue, alpha ); + fprintf( stderr, " Got: %3d %3d %3d %3d\n", rgba[0], rgba[1], rgba[2], rgba[3] ); + return 1; +} + +int +main(int argc, char **argv) +{ + TIFF *tif; + static const char *srcfile = "images/quad-tile.jpg.tiff"; + unsigned short h, v; + int status; + unsigned char *buffer; + tsize_t sz, szout; + + (void) argc; + (void) argv; + + tif = TIFFOpen(srcfile,"r"); + if ( tif == NULL ) { + fprintf( stderr, "Could not open %s\n", srcfile); + exit( 1 ); + } + + status = TIFFGetField(tif,TIFFTAG_YCBCRSUBSAMPLING, &h, &v); + if ( status == 0 || h != 2 || v != 2) { + fprintf( stderr, "Could not retrieve subsampling tag.\n" ); + exit(1); + } + + /* + * What is the appropriate size of a YCbCr encoded tile? + */ + sz = TIFFTileSize(tif); + if( sz != 24576) { + fprintf(stderr, "tiles are %d bytes\n", (int)sz); + exit(1); + } + + buffer = (unsigned char *) malloc(sz); + + /* + * Read a tile in decompressed form, but still YCbCr subsampled. + */ + szout = TIFFReadEncodedTile(tif,9,buffer,sz); + if (szout != sz) { + fprintf( stderr, + "Did not get expected result code from TIFFReadEncodedTile()(%d instead of %d)\n", + (int) szout, (int) sz ); + return 1; + } + + if( check_cluster( 0, buffer, cluster_0 ) + || check_cluster( 64, buffer, cluster_64 ) + || check_cluster( 128, buffer, cluster_128 ) ) { + exit(1); + } + free(buffer); + + /* + * Read a tile using the built-in conversion to RGB format provided by the JPEG library. + */ + TIFFSetField(tif, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); + + sz = TIFFTileSize(tif); + if( sz != 128*128*3) { + fprintf(stderr, "tiles are %d bytes\n", (int)sz); + exit(1); + } + + buffer = (unsigned char *) malloc(sz); + + szout = TIFFReadEncodedTile(tif,9,buffer,sz); + if (szout != sz) { + fprintf( stderr, + "Did not get expected result code from TIFFReadEncodedTile()(%d instead of %d)\n", + (int) szout, (int) sz ); + return 1; + } + + if (check_rgb_pixel( 0, 15, 0, 18, buffer ) + || check_rgb_pixel( 64, 0, 0, 2, buffer ) + || check_rgb_pixel( 512, 6, 36, 182, buffer ) ) { + exit(1); + } + + free( buffer ); + + TIFFClose(tif); + + /* + * Reopen and test reading using the RGBA interface. + */ + tif = TIFFOpen(srcfile,"r"); + + sz = 128 * 128 * 4; + buffer = (unsigned char *) malloc(sz); + + if (!TIFFReadRGBATile( tif, 1*128, 2*128, (uint32 *) buffer )) { + fprintf( stderr, "TIFFReadRGBATile() returned failure code.\n" ); + return 1; + } + + /* + * Currently TIFFReadRGBATile() just uses JPEGCOLORMODE_RGB so this + * trivally matches the last results. Eventually we should actually + * accomplish it from the YCbCr subsampled buffer ourselves in which + * case the results may be subtly different but similar. + */ + if (check_rgba_pixel( 0, 15, 0, 18, 255, buffer ) + || check_rgba_pixel( 64, 0, 0, 2, 255, buffer ) + || check_rgba_pixel( 512, 6, 36, 182, 255, buffer ) ) { + exit(1); + } + + free( buffer ); + TIFFClose(tif); + + exit( 0 ); +} + +/* vim: set ts=8 sts=8 sw=8 noet: */