1 /* 2 * Copyright (c) 1988-1997 Sam Leffler 3 * Copyright (c) 1991-1997 Silicon Graphics, Inc. 4 * 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. 12 * 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. 16 * 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 22 * OF THIS SOFTWARE. 23 */ 24 25 /* 26 * TIFF Library 27 * 28 * Builtin Compression Scheme Configuration Support. 29 */ 30 31 #include <precomp.h> 32 33 static int NotConfigured(TIFF*, int); 34 35 #ifndef LZW_SUPPORT 36 #define TIFFInitLZW NotConfigured 37 #endif 38 #ifndef PACKBITS_SUPPORT 39 #define TIFFInitPackBits NotConfigured 40 #endif 41 #ifndef THUNDER_SUPPORT 42 #define TIFFInitThunderScan NotConfigured 43 #endif 44 #ifndef NEXT_SUPPORT 45 #define TIFFInitNeXT NotConfigured 46 #endif 47 #ifndef JPEG_SUPPORT 48 #define TIFFInitJPEG NotConfigured 49 #endif 50 #ifndef OJPEG_SUPPORT 51 #define TIFFInitOJPEG NotConfigured 52 #endif 53 #ifndef CCITT_SUPPORT 54 #define TIFFInitCCITTRLE NotConfigured 55 #define TIFFInitCCITTRLEW NotConfigured 56 #define TIFFInitCCITTFax3 NotConfigured 57 #define TIFFInitCCITTFax4 NotConfigured 58 #endif 59 #ifndef JBIG_SUPPORT 60 #define TIFFInitJBIG NotConfigured 61 #endif 62 #ifndef ZIP_SUPPORT 63 #define TIFFInitZIP NotConfigured 64 #endif 65 #ifndef PIXARLOG_SUPPORT 66 #define TIFFInitPixarLog NotConfigured 67 #endif 68 #ifndef LOGLUV_SUPPORT 69 #define TIFFInitSGILog NotConfigured 70 #endif 71 #ifndef LZMA_SUPPORT 72 #define TIFFInitLZMA NotConfigured 73 #endif 74 #ifndef ZSTD_SUPPORT 75 #define TIFFInitZSTD NotConfigured 76 #endif 77 #ifndef WEBP_SUPPORT 78 #define TIFFInitWebP NotConfigured 79 #endif 80 81 /* 82 * Compression schemes statically built into the library. 83 */ 84 #ifdef VMS 85 const TIFFCodec _TIFFBuiltinCODECS[] = { 86 #else 87 TIFFCodec _TIFFBuiltinCODECS[] = { 88 #endif 89 { "None", COMPRESSION_NONE, TIFFInitDumpMode }, 90 { "LZW", COMPRESSION_LZW, TIFFInitLZW }, 91 { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, 92 { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, 93 { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, 94 { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, 95 { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, 96 { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, 97 { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, 98 { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, 99 { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, 100 { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, 101 { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, 102 { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, 103 { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, 104 { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, 105 { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, 106 { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, 107 { "ZSTD", COMPRESSION_ZSTD, TIFFInitZSTD }, 108 { "WEBP", COMPRESSION_WEBP, TIFFInitWebP }, 109 { NULL, 0, NULL } 110 }; 111 112 static int 113 _notConfigured(TIFF* tif) 114 { 115 const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); 116 char compression_code[20]; 117 118 sprintf(compression_code, "%d",tif->tif_dir.td_compression ); 119 TIFFErrorExt(tif->tif_clientdata, tif->tif_name, 120 "%s compression support is not configured", 121 c ? c->name : compression_code ); 122 return (0); 123 } 124 125 static int 126 NotConfigured(TIFF* tif, int scheme) 127 { 128 (void) scheme; 129 130 tif->tif_fixuptags = _notConfigured; 131 tif->tif_decodestatus = FALSE; 132 tif->tif_setupdecode = _notConfigured; 133 tif->tif_encodestatus = FALSE; 134 tif->tif_setupencode = _notConfigured; 135 return (1); 136 } 137 138 /************************************************************************/ 139 /* TIFFIsCODECConfigured() */ 140 /************************************************************************/ 141 142 /** 143 * Check whether we have working codec for the specific coding scheme. 144 * 145 * @return returns 1 if the codec is configured and working. Otherwise 146 * 0 will be returned. 147 */ 148 149 int 150 TIFFIsCODECConfigured(uint16 scheme) 151 { 152 const TIFFCodec* codec = TIFFFindCODEC(scheme); 153 154 if(codec == NULL) { 155 return 0; 156 } 157 if(codec->init == NULL) { 158 return 0; 159 } 160 if(codec->init != NotConfigured){ 161 return 1; 162 } 163 return 0; 164 } 165 166 /* 167 * Local Variables: 168 * mode: c 169 * c-basic-offset: 8 170 * fill-column: 78 171 * End: 172 */ 173