GraphicsMagick: Upgraded libtiff to libtiff-4.4.0; but code is s...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.25860.1670027369.1459.graphicsmagick-commit@lists.sourceforge.net> |
changeset 3ad6ff7604bd in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=3ad6ff7604bd summary: Upgraded libtiff to libtiff-4.4.0; but code is still compilable with MSVC2008! diffstat: ChangeLog | 9 + coders/ps2.c | 2 +- coders/ps3.c | 2 +- coders/tiff.c | 2 +- tiff/libtiff/mkg3states.c | 17 +- tiff/libtiff/tif_aux.c | 122 +- tiff/libtiff/tif_close.c | 17 +- tiff/libtiff/tif_codec.c | 12 +- tiff/libtiff/tif_color.c | 73 +- tiff/libtiff/tif_compress.c | 32 +- tiff/libtiff/tif_config.h | 4 +- tiff/libtiff/tif_dir.c | 568 +++-- tiff/libtiff/tif_dir.h | 90 +- tiff/libtiff/tif_dirinfo.c | 366 +++- tiff/libtiff/tif_dirread.c | 2991 +++++++++++++++++++----------- tiff/libtiff/tif_dirwrite.c | 1495 ++++++++++----- tiff/libtiff/tif_dumpmode.c | 22 +- tiff/libtiff/tif_extension.c | 4 +- tiff/libtiff/tif_fax3.c | 457 ++-- tiff/libtiff/tif_fax3.h | 53 +- tiff/libtiff/tif_fax3sm.c | 2 + tiff/libtiff/tif_getimage.c | 529 ++-- tiff/libtiff/tif_jbig.c | 25 +- tiff/libtiff/tif_jpeg.c | 3962 ++++++++++++++++++++--------------------- tiff/libtiff/tif_jpeg_12.c | 83 +- tiff/libtiff/tif_lerc.c | 1277 +++++++++++++ tiff/libtiff/tif_luv.c | 343 +- tiff/libtiff/tif_lzma.c | 39 +- tiff/libtiff/tif_lzw.c | 748 ++++--- tiff/libtiff/tif_next.c | 24 +- tiff/libtiff/tif_ojpeg.c | 626 +++--- tiff/libtiff/tif_open.c | 64 +- tiff/libtiff/tif_packbits.c | 74 +- tiff/libtiff/tif_pixarlog.c | 245 +- tiff/libtiff/tif_predict.c | 226 +- tiff/libtiff/tif_predict.h | 2 +- tiff/libtiff/tif_print.c | 253 +- tiff/libtiff/tif_read.c | 515 ++--- tiff/libtiff/tif_strip.c | 115 +- tiff/libtiff/tif_swab.c | 28 +- tiff/libtiff/tif_thunder.c | 27 +- tiff/libtiff/tif_tile.c | 82 +- tiff/libtiff/tif_unix.c | 18 +- tiff/libtiff/tif_webp.c | 131 +- tiff/libtiff/tif_win32.c | 97 +- tiff/libtiff/tif_write.c | 258 +- tiff/libtiff/tif_zip.c | 314 ++- tiff/libtiff/tif_zstd.c | 57 +- tiff/libtiff/tiff.h | 183 +- tiff/libtiff/tiffio.h | 278 +- tiff/libtiff/tiffiop.h | 187 +- tiff/libtiff/tiffvers.h | 4 +- webp/src/webp/types.h | 254 ++- 53 files changed, 10509 insertions(+), 6899 deletions(-) diffs (truncated from 31527 to 500 lines): diff -r 15545e750d39 -r 3ad6ff7604bd ChangeLog --- a/ChangeLog Sun Nov 27 15:36:03 2022 -0600 +++ b/ChangeLog Sat Dec 03 01:28:31 2022 +0100 @@ -1,3 +1,12 @@ +2022-12-01 Fojtik Jaroslav <[email protected]> + + coders/ps2.c + coders/ps3.c + coders/tiff.c + webp/src/webp/types.h + tiff/libtiff/* Upgraded libtiff to libtiff-4.4.0 + But code is still compilable with MSVC2008! + 2022-11-27 Bob Friesenhahn <[email protected]> * Magick++/lib/Image.cpp: Don't just blindly return DisposeMethod diff -r 15545e750d39 -r 3ad6ff7604bd coders/ps2.c --- a/coders/ps2.c Sun Nov 27 15:36:03 2022 -0600 +++ b/coders/ps2.c Sat Dec 03 01:28:31 2022 +0100 @@ -66,7 +66,7 @@ #endif #include "tiffio.h" -#if defined(HAVE_STDINT_H) && (TIFFLIB_VERSION >= 20201219) +#if (TIFFLIB_VERSION >= 20201219) # undef uint16 # define uint16 uint16_t # undef uint32 diff -r 15545e750d39 -r 3ad6ff7604bd coders/ps3.c --- a/coders/ps3.c Sun Nov 27 15:36:03 2022 -0600 +++ b/coders/ps3.c Sat Dec 03 01:28:31 2022 +0100 @@ -85,7 +85,7 @@ #endif #include "tiffio.h" -#if defined(HAVE_STDINT_H) && (TIFFLIB_VERSION >= 20201219) +#if (TIFFLIB_VERSION >= 20201219) # undef uint16 # define uint16 uint16_t # undef uint32 diff -r 15545e750d39 -r 3ad6ff7604bd coders/tiff.c --- a/coders/tiff.c Sun Nov 27 15:36:03 2022 -0600 +++ b/coders/tiff.c Sat Dec 03 01:28:31 2022 +0100 @@ -87,7 +87,7 @@ # define HasBigTIFF 1 #endif /* defined(TIFF_BIGTIFF_VERSION) */ -#if defined(HAVE_STDINT_H) && (TIFFLIB_VERSION >= 20201219) +#if (TIFFLIB_VERSION >= 20201219) # undef uint16 # define uint16 uint16_t # undef uint32 diff -r 15545e750d39 -r 3ad6ff7604bd tiff/libtiff/mkg3states.c --- a/tiff/libtiff/mkg3states.c Sun Nov 27 15:36:03 2022 -0600 +++ b/tiff/libtiff/mkg3states.c Sat Dec 03 01:28:31 2022 +0100 @@ -28,6 +28,7 @@ * Copyright (C) 1990, 1995 Frank D. Cringle. */ #include "tif_config.h" +#include "libport.h" #include <stdio.h> #include <stdlib.h> @@ -39,10 +40,6 @@ #include "tif_fax3.h" -#ifndef HAVE_GETOPT -extern int getopt(int argc, char * const argv[], const char *optstring); -#endif - #define streq(a,b) (strcmp(a,b) == 0) /* NB: can't use names in tif_fax3.h 'cuz they are declared const */ @@ -51,8 +48,8 @@ TIFFFaxTabEnt BlackTable[8192]; struct proto { - uint16 code; /* right justified, lsb-first, zero filled */ - uint16 val; /* (pixel count)<<4 + code width */ + uint16_t code; /* right justified, lsb-first, zero filled */ + uint16_t val; /* (pixel count)<<4 + code width */ }; static struct proto Pass[] = { @@ -433,11 +430,19 @@ fprintf(fd, "/* WARNING, this file was automatically generated by the\n"); fprintf(fd, " mkg3states program */\n"); + fprintf(fd, "#include <stdint.h>\n"); fprintf(fd, "#include \"tiff.h\"\n"); fprintf(fd, "#include \"tif_fax3.h\"\n"); WriteTable(fd, MainTable, 128, "TIFFFaxMainTable"); WriteTable(fd, WhiteTable, 4096, "TIFFFaxWhiteTable"); WriteTable(fd, BlackTable, 8192, "TIFFFaxBlackTable"); + fprintf(fd, "/*\n" + " * Local Variables:\n" + " * mode: c\n" + " * c-basic-offset: 8\n" + " * fill-column: 78\n" + " * End:\n" + " */\n"); fclose(fd); return (0); } diff -r 15545e750d39 -r 3ad6ff7604bd tiff/libtiff/tif_aux.c --- a/tiff/libtiff/tif_aux.c Sun Nov 27 15:36:03 2022 -0600 +++ b/tiff/libtiff/tif_aux.c Sat Dec 03 01:28:31 2022 +0100 @@ -32,10 +32,10 @@ #include <math.h> #include <float.h> -uint32 -_TIFFMultiply32(TIFF* tif, uint32 first, uint32 second, const char* where) +uint32_t +_TIFFMultiply32(TIFF* tif, uint32_t first, uint32_t second, const char* where) { - if (second && first > TIFF_UINT32_MAX / second) { + if (second && first > UINT32_MAX / second) { TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); return 0; } @@ -43,10 +43,10 @@ return first * second; } -uint64 -_TIFFMultiply64(TIFF* tif, uint64 first, uint64 second, const char* where) +uint64_t +_TIFFMultiply64(TIFF* tif, uint64_t first, uint64_t second, const char* where) { - if (second && first > TIFF_UINT64_MAX / second) { + if (second && first > UINT64_MAX / second) { TIFFErrorExt(tif->tif_clientdata, where, "Integer overflow in %s", where); return 0; } @@ -79,9 +79,9 @@ return first * second; } -tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64 val, const char* module) +tmsize_t _TIFFCastUInt64ToSSize(TIFF* tif, uint64_t val, const char* module) { - if( val > (uint64)TIFF_TMSIZE_T_MAX ) + if( val > (uint64_t)TIFF_TMSIZE_T_MAX ) { if( tif != NULL && module != NULL ) { @@ -109,8 +109,8 @@ if (cp == NULL) { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Failed to allocate memory for %s " - "(%ld elements of %ld bytes each)", - what,(long) nmemb, (long) elem_size); + "(%"TIFF_SSIZE_FORMAT" elements of %"TIFF_SSIZE_FORMAT" bytes each)", + what, nmemb, elem_size); } return cp; @@ -125,7 +125,7 @@ static int TIFFDefaultTransferFunction(TIFFDirectory* td) { - uint16 **tf = td->td_transferfunction; + uint16_t **tf = td->td_transferfunction; tmsize_t i, n, nbytes; tf[0] = tf[1] = tf[2] = 0; @@ -133,22 +133,22 @@ return 0; n = ((tmsize_t)1)<<td->td_bitspersample; - nbytes = n * sizeof (uint16); - tf[0] = (uint16 *)_TIFFmalloc(nbytes); + nbytes = n * sizeof (uint16_t); + tf[0] = (uint16_t *)_TIFFmalloc(nbytes); if (tf[0] == NULL) return 0; tf[0][0] = 0; for (i = 1; i < n; i++) { double t = (double)i/((double) n-1.); - tf[0][i] = (uint16)floor(65535.*pow(t, 2.2) + .5); + tf[0][i] = (uint16_t)floor(65535. * pow(t, 2.2) + .5); } if (td->td_samplesperpixel - td->td_extrasamples > 1) { - tf[1] = (uint16 *)_TIFFmalloc(nbytes); + tf[1] = (uint16_t *)_TIFFmalloc(nbytes); if(tf[1] == NULL) goto bad; _TIFFmemcpy(tf[1], tf[0], nbytes); - tf[2] = (uint16 *)_TIFFmalloc(nbytes); + tf[2] = (uint16_t *)_TIFFmalloc(nbytes); if (tf[2] == NULL) goto bad; _TIFFmemcpy(tf[2], tf[0], nbytes); @@ -205,7 +205,7 @@ * place in the library -- in TIFFDefaultDirectory. */ int -TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap) +TIFFVGetFieldDefaulted(TIFF* tif, uint32_t tag, va_list ap) { TIFFDirectory *td = &tif->tif_dir; @@ -213,37 +213,37 @@ return (1); switch (tag) { case TIFFTAG_SUBFILETYPE: - *va_arg(ap, uint32 *) = td->td_subfiletype; + *va_arg(ap, uint32_t *) = td->td_subfiletype; return (1); case TIFFTAG_BITSPERSAMPLE: - *va_arg(ap, uint16 *) = td->td_bitspersample; + *va_arg(ap, uint16_t *) = td->td_bitspersample; return (1); case TIFFTAG_THRESHHOLDING: - *va_arg(ap, uint16 *) = td->td_threshholding; + *va_arg(ap, uint16_t *) = td->td_threshholding; return (1); case TIFFTAG_FILLORDER: - *va_arg(ap, uint16 *) = td->td_fillorder; + *va_arg(ap, uint16_t *) = td->td_fillorder; return (1); case TIFFTAG_ORIENTATION: - *va_arg(ap, uint16 *) = td->td_orientation; + *va_arg(ap, uint16_t *) = td->td_orientation; return (1); case TIFFTAG_SAMPLESPERPIXEL: - *va_arg(ap, uint16 *) = td->td_samplesperpixel; + *va_arg(ap, uint16_t *) = td->td_samplesperpixel; return (1); case TIFFTAG_ROWSPERSTRIP: - *va_arg(ap, uint32 *) = td->td_rowsperstrip; + *va_arg(ap, uint32_t *) = td->td_rowsperstrip; return (1); case TIFFTAG_MINSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_minsamplevalue; + *va_arg(ap, uint16_t *) = td->td_minsamplevalue; return (1); case TIFFTAG_MAXSAMPLEVALUE: - *va_arg(ap, uint16 *) = td->td_maxsamplevalue; + *va_arg(ap, uint16_t *) = td->td_maxsamplevalue; return (1); case TIFFTAG_PLANARCONFIG: - *va_arg(ap, uint16 *) = td->td_planarconfig; + *va_arg(ap, uint16_t *) = td->td_planarconfig; return (1); case TIFFTAG_RESOLUTIONUNIT: - *va_arg(ap, uint16 *) = td->td_resolutionunit; + *va_arg(ap, uint16_t *) = td->td_resolutionunit; return (1); case TIFFTAG_PREDICTOR: { @@ -252,67 +252,67 @@ { TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "Cannot get \"Predictor\" tag as plugin is not configured"); - *va_arg(ap, uint16*) = 0; + *va_arg(ap, uint16_t*) = 0; return 0; } - *va_arg(ap, uint16*) = (uint16) sp->predictor; + *va_arg(ap, uint16_t*) = (uint16_t) sp->predictor; return 1; } case TIFFTAG_DOTRANGE: - *va_arg(ap, uint16 *) = 0; - *va_arg(ap, uint16 *) = (1<<td->td_bitspersample)-1; + *va_arg(ap, uint16_t *) = 0; + *va_arg(ap, uint16_t *) = (1 << td->td_bitspersample) - 1; return (1); case TIFFTAG_INKSET: - *va_arg(ap, uint16 *) = INKSET_CMYK; + *va_arg(ap, uint16_t *) = INKSET_CMYK; return 1; case TIFFTAG_NUMBEROFINKS: - *va_arg(ap, uint16 *) = 4; + *va_arg(ap, uint16_t *) = 4; return (1); case TIFFTAG_EXTRASAMPLES: - *va_arg(ap, uint16 *) = td->td_extrasamples; - *va_arg(ap, uint16 **) = td->td_sampleinfo; + *va_arg(ap, uint16_t *) = td->td_extrasamples; + *va_arg(ap, const uint16_t **) = td->td_sampleinfo; return (1); case TIFFTAG_MATTEING: - *va_arg(ap, uint16 *) = + *va_arg(ap, uint16_t *) = (td->td_extrasamples == 1 && td->td_sampleinfo[0] == EXTRASAMPLE_ASSOCALPHA); return (1); case TIFFTAG_TILEDEPTH: - *va_arg(ap, uint32 *) = td->td_tiledepth; + *va_arg(ap, uint32_t *) = td->td_tiledepth; return (1); case TIFFTAG_DATATYPE: - *va_arg(ap, uint16 *) = td->td_sampleformat-1; + *va_arg(ap, uint16_t *) = td->td_sampleformat - 1; return (1); case TIFFTAG_SAMPLEFORMAT: - *va_arg(ap, uint16 *) = td->td_sampleformat; + *va_arg(ap, uint16_t *) = td->td_sampleformat; return(1); case TIFFTAG_IMAGEDEPTH: - *va_arg(ap, uint32 *) = td->td_imagedepth; + *va_arg(ap, uint32_t *) = td->td_imagedepth; return (1); case TIFFTAG_YCBCRCOEFFICIENTS: { /* defaults are from CCIR Recommendation 601-1 */ - static float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f }; - *va_arg(ap, float **) = ycbcrcoeffs; + static const float ycbcrcoeffs[] = { 0.299f, 0.587f, 0.114f }; + *va_arg(ap, const float **) = ycbcrcoeffs; return 1; } case TIFFTAG_YCBCRSUBSAMPLING: - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[0]; - *va_arg(ap, uint16 *) = td->td_ycbcrsubsampling[1]; + *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[0]; + *va_arg(ap, uint16_t *) = td->td_ycbcrsubsampling[1]; return (1); case TIFFTAG_YCBCRPOSITIONING: - *va_arg(ap, uint16 *) = td->td_ycbcrpositioning; + *va_arg(ap, uint16_t *) = td->td_ycbcrpositioning; return (1); case TIFFTAG_WHITEPOINT: { - static float whitepoint[2]; - /* TIFF 6.0 specification tells that it is no default value for the WhitePoint, but AdobePhotoshop TIFF Technical Note tells that it should be CIE D50. */ - whitepoint[0] = D50_X0 / (D50_X0 + D50_Y0 + D50_Z0); - whitepoint[1] = D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0); - *va_arg(ap, float **) = whitepoint; + static const float whitepoint[] = { + D50_X0 / (D50_X0 + D50_Y0 + D50_Z0), + D50_Y0 / (D50_X0 + D50_Y0 + D50_Z0) + }; + *va_arg(ap, const float **) = whitepoint; return 1; } case TIFFTAG_TRANSFERFUNCTION: @@ -321,16 +321,16 @@ TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "No space for \"TransferFunction\" tag"); return (0); } - *va_arg(ap, uint16 **) = td->td_transferfunction[0]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[0]; if (td->td_samplesperpixel - td->td_extrasamples > 1) { - *va_arg(ap, uint16 **) = td->td_transferfunction[1]; - *va_arg(ap, uint16 **) = td->td_transferfunction[2]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[1]; + *va_arg(ap, const uint16_t **) = td->td_transferfunction[2]; } return (1); case TIFFTAG_REFERENCEBLACKWHITE: if (!td->td_refblackwhite && !TIFFDefaultRefBlackWhite(td)) return (0); - *va_arg(ap, float **) = td->td_refblackwhite; + *va_arg(ap, const float **) = td->td_refblackwhite; return (1); } return 0; @@ -341,7 +341,7 @@ * value if the tag is not present in the directory. */ int -TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...) +TIFFGetFieldDefaulted(TIFF* tif, uint32_t tag, ...) { int ok; va_list ap; @@ -353,16 +353,16 @@ } struct _Int64Parts { - int32 low, high; + int32_t low, high; }; typedef union { struct _Int64Parts part; - int64 value; + int64_t value; } _Int64; float -_TIFFUInt64ToFloat(uint64 ui64) +_TIFFUInt64ToFloat(uint64_t ui64) { _Int64 i; @@ -378,7 +378,7 @@ } double -_TIFFUInt64ToDouble(uint64 ui64) +_TIFFUInt64ToDouble(uint64_t ui64) { _Int64 i; @@ -406,7 +406,7 @@ { /* Huge offsets, especially -1 / UINT64_MAX, can cause issues */ /* See http://bugzilla.maptools.org/show_bug.cgi?id=2726 */ - return off <= (~(uint64)0)/2 && TIFFSeekFile(tif,off,SEEK_SET)==off; + return off <= (~(uint64_t)0) / 2 && TIFFSeekFile(tif, off, SEEK_SET) == off; } /* vim: set ts=8 sts=8 sw=8 noet: */ diff -r 15545e750d39 -r 3ad6ff7604bd tiff/libtiff/tif_close.c --- a/tiff/libtiff/tif_close.c Sun Nov 27 15:36:03 2022 -0600 +++ b/tiff/libtiff/tif_close.c Sat Dec 03 01:28:31 2022 +0100 @@ -76,14 +76,19 @@ * Clean up custom fields. */ if (tif->tif_fields && tif->tif_nfields > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfields; i++) { TIFFField *fld = tif->tif_fields[i]; - if (fld->field_bit == FIELD_CUSTOM && - strncmp("Tag ", fld->field_name, 4) == 0) { - _TIFFfree(fld->field_name); - _TIFFfree(fld); + if (fld->field_name != NULL) { + if (fld->field_bit == FIELD_CUSTOM && + /* caution: tif_fields[i] must not be the beginning of a fields-array. + * Otherwise the following tags are also freed with the first free(). + */ + TIFFFieldIsAnonymous(fld)) { + _TIFFfree(fld->field_name); + _TIFFfree(fld); + } } } @@ -91,7 +96,7 @@ } if (tif->tif_nfieldscompat > 0) { - uint32 i; + uint32_t i; for (i = 0; i < tif->tif_nfieldscompat; i++) { if (tif->tif_fieldscompat[i].allocated_size) diff -r 15545e750d39 -r 3ad6ff7604bd tiff/libtiff/tif_codec.c --- a/tiff/libtiff/tif_codec.c Sun Nov 27 15:36:03 2022 -0600 +++ b/tiff/libtiff/tif_codec.c Sat Dec 03 01:28:31 2022 +0100 @@ -67,6 +67,9 @@ #ifndef LOGLUV_SUPPORT #define TIFFInitSGILog NotConfigured #endif +#ifndef LERC_SUPPORT +#define TIFFInitLERC NotConfigured +#endif #ifndef LZMA_SUPPORT #define TIFFInitLZMA NotConfigured #endif @@ -80,11 +83,7 @@ /* * Compression schemes statically built into the library. */ -#ifdef VMS const TIFFCodec _TIFFBuiltinCODECS[] = { -#else -TIFFCodec _TIFFBuiltinCODECS[] = { -#endif { "None", COMPRESSION_NONE, TIFFInitDumpMode }, { "LZW", COMPRESSION_LZW, TIFFInitLZW }, { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, @@ -105,6 +104,7 @@ { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, { "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD }, { "WEBP", COMPRESSION_WEBP, TIFFInitWebP }, + { "LERC", COMPRESSION_LERC, TIFFInitLERC }, { NULL, 0, NULL } }; @@ -114,7 +114,7 @@ const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); char compression_code[20]; - sprintf(compression_code, "%d",tif->tif_dir.td_compression ); + sprintf(compression_code, "%"PRIu16, tif->tif_dir.td_compression ); TIFFErrorExt(tif->tif_clientdata, tif->tif_name, "%s compression support is not configured", c ? c->name : compression_code ); @@ -146,7 +146,7 @@ */ int -TIFFIsCODECConfigured(uint16 scheme) +TIFFIsCODECConfigured(uint16_t scheme) { const TIFFCodec* codec = TIFFFindCODEC(scheme);