2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
28 * Builtin Compression Scheme Configuration Support.
32 static int NotConfigured(TIFF
*, int);
35 #define TIFFInitLZW NotConfigured
37 #ifndef PACKBITS_SUPPORT
38 #define TIFFInitPackBits NotConfigured
40 #ifndef THUNDER_SUPPORT
41 #define TIFFInitThunderScan NotConfigured
44 #define TIFFInitNeXT NotConfigured
47 #define TIFFInitJPEG NotConfigured
50 #define TIFFInitOJPEG NotConfigured
53 #define TIFFInitCCITTRLE NotConfigured
54 #define TIFFInitCCITTRLEW NotConfigured
55 #define TIFFInitCCITTFax3 NotConfigured
56 #define TIFFInitCCITTFax4 NotConfigured
59 #define TIFFInitJBIG NotConfigured
62 #define TIFFInitZIP NotConfigured
64 #ifndef PIXARLOG_SUPPORT
65 #define TIFFInitPixarLog NotConfigured
67 #ifndef LOGLUV_SUPPORT
68 #define TIFFInitSGILog NotConfigured
71 #define TIFFInitLERC NotConfigured
74 #define TIFFInitLZMA NotConfigured
77 #define TIFFInitZSTD NotConfigured
80 #define TIFFInitWebP NotConfigured
84 * Compression schemes statically built into the library.
86 const TIFFCodec _TIFFBuiltinCODECS
[] = {
87 {"None", COMPRESSION_NONE
, TIFFInitDumpMode
},
88 {"LZW", COMPRESSION_LZW
, TIFFInitLZW
},
89 {"PackBits", COMPRESSION_PACKBITS
, TIFFInitPackBits
},
90 {"ThunderScan", COMPRESSION_THUNDERSCAN
, TIFFInitThunderScan
},
91 {"NeXT", COMPRESSION_NEXT
, TIFFInitNeXT
},
92 {"JPEG", COMPRESSION_JPEG
, TIFFInitJPEG
},
93 {"Old-style JPEG", COMPRESSION_OJPEG
, TIFFInitOJPEG
},
94 {"CCITT RLE", COMPRESSION_CCITTRLE
, TIFFInitCCITTRLE
},
95 {"CCITT RLE/W", COMPRESSION_CCITTRLEW
, TIFFInitCCITTRLEW
},
96 {"CCITT Group 3", COMPRESSION_CCITTFAX3
, TIFFInitCCITTFax3
},
97 {"CCITT Group 4", COMPRESSION_CCITTFAX4
, TIFFInitCCITTFax4
},
98 {"ISO JBIG", COMPRESSION_JBIG
, TIFFInitJBIG
},
99 {"Deflate", COMPRESSION_DEFLATE
, TIFFInitZIP
},
100 {"AdobeDeflate", COMPRESSION_ADOBE_DEFLATE
, TIFFInitZIP
},
101 {"PixarLog", COMPRESSION_PIXARLOG
, TIFFInitPixarLog
},
102 {"SGILog", COMPRESSION_SGILOG
, TIFFInitSGILog
},
103 {"SGILog24", COMPRESSION_SGILOG24
, TIFFInitSGILog
},
104 {"LZMA", COMPRESSION_LZMA
, TIFFInitLZMA
},
105 {"ZSTD", COMPRESSION_ZSTD
, TIFFInitZSTD
},
106 {"WEBP", COMPRESSION_WEBP
, TIFFInitWebP
},
107 {"LERC", COMPRESSION_LERC
, TIFFInitLERC
},
110 static int _notConfigured(TIFF
*tif
)
112 const TIFFCodec
*c
= TIFFFindCODEC(tif
->tif_dir
.td_compression
);
113 char compression_code
[20];
115 snprintf(compression_code
, sizeof(compression_code
), "%" PRIu16
,
116 tif
->tif_dir
.td_compression
);
117 TIFFErrorExtR(tif
, tif
->tif_name
,
118 "%s compression support is not configured",
119 c
? c
->name
: compression_code
);
123 static int NotConfigured(TIFF
*tif
, int scheme
)
127 tif
->tif_fixuptags
= _notConfigured
;
128 tif
->tif_decodestatus
= FALSE
;
129 tif
->tif_setupdecode
= _notConfigured
;
130 tif
->tif_encodestatus
= FALSE
;
131 tif
->tif_setupencode
= _notConfigured
;
135 /************************************************************************/
136 /* TIFFIsCODECConfigured() */
137 /************************************************************************/
140 * Check whether we have working codec for the specific coding scheme.
142 * @return returns 1 if the codec is configured and working. Otherwise
143 * 0 will be returned.
146 int TIFFIsCODECConfigured(uint16_t scheme
)
148 const TIFFCodec
*codec
= TIFFFindCODEC(scheme
);
154 if (codec
->init
== NULL
)
158 if (codec
->init
!= NotConfigured
)