]>
Commit | Line | Data |
---|---|---|
8414a40c VZ |
1 | |
2 | /* | |
3 | * Copyright (c) 1988-1997 Sam Leffler | |
4 | * Copyright (c) 1991-1997 Silicon Graphics, Inc. | |
5 | * | |
6 | * Permission to use, copy, modify, distribute, and sell this software and | |
7 | * its documentation for any purpose is hereby granted without fee, provided | |
8 | * that (i) the above copyright notices and this permission notice appear in | |
9 | * all copies of the software and related documentation, and (ii) the names of | |
10 | * Sam Leffler and Silicon Graphics may not be used in any advertising or | |
11 | * publicity relating to the software without the specific, prior written | |
12 | * permission of Sam Leffler and Silicon Graphics. | |
13 | * | |
14 | * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, | |
15 | * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY | |
16 | * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. | |
17 | * | |
18 | * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR | |
19 | * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, | |
20 | * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
21 | * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF | |
22 | * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
23 | * OF THIS SOFTWARE. | |
24 | */ | |
25 | ||
26 | /* | |
27 | * TIFF Library | |
28 | * | |
29 | * Builtin Compression Scheme Configuration Support. | |
30 | */ | |
31 | #include "tiffiop.h" | |
32 | ||
80ed523f | 33 | static int NotConfigured(TIFF*, int); |
8414a40c | 34 | |
80ed523f VZ |
35 | #ifndef LZW_SUPPORT |
36 | #define TIFFInitLZW NotConfigured | |
8414a40c | 37 | #endif |
80ed523f VZ |
38 | #ifndef PACKBITS_SUPPORT |
39 | #define TIFFInitPackBits NotConfigured | |
8414a40c | 40 | #endif |
80ed523f VZ |
41 | #ifndef THUNDER_SUPPORT |
42 | #define TIFFInitThunderScan NotConfigured | |
8414a40c | 43 | #endif |
80ed523f VZ |
44 | #ifndef NEXT_SUPPORT |
45 | #define TIFFInitNeXT NotConfigured | |
8414a40c | 46 | #endif |
80ed523f VZ |
47 | #ifndef JPEG_SUPPORT |
48 | #define TIFFInitJPEG NotConfigured | |
8414a40c | 49 | #endif |
80ed523f VZ |
50 | #ifndef OJPEG_SUPPORT |
51 | #define TIFFInitOJPEG NotConfigured | |
8414a40c | 52 | #endif |
80ed523f VZ |
53 | #ifndef CCITT_SUPPORT |
54 | #define TIFFInitCCITTRLE NotConfigured | |
55 | #define TIFFInitCCITTRLEW NotConfigured | |
56 | #define TIFFInitCCITTFax3 NotConfigured | |
57 | #define TIFFInitCCITTFax4 NotConfigured | |
8414a40c VZ |
58 | #endif |
59 | #ifndef JBIG_SUPPORT | |
80ed523f | 60 | #define TIFFInitJBIG NotConfigured |
8414a40c | 61 | #endif |
80ed523f VZ |
62 | #ifndef ZIP_SUPPORT |
63 | #define TIFFInitZIP NotConfigured | |
8414a40c | 64 | #endif |
80ed523f VZ |
65 | #ifndef PIXARLOG_SUPPORT |
66 | #define TIFFInitPixarLog NotConfigured | |
8414a40c VZ |
67 | #endif |
68 | #ifndef LOGLUV_SUPPORT | |
80ed523f VZ |
69 | #define TIFFInitSGILog NotConfigured |
70 | #endif | |
71 | #ifndef LZMA_SUPPORT | |
72 | #define TIFFInitLZMA NotConfigured | |
8414a40c VZ |
73 | #endif |
74 | ||
75 | /* | |
76 | * Compression schemes statically built into the library. | |
77 | */ | |
78 | #ifdef VMS | |
79 | const TIFFCodec _TIFFBuiltinCODECS[] = { | |
80 | #else | |
81 | TIFFCodec _TIFFBuiltinCODECS[] = { | |
82 | #endif | |
83 | { "None", COMPRESSION_NONE, TIFFInitDumpMode }, | |
84 | { "LZW", COMPRESSION_LZW, TIFFInitLZW }, | |
85 | { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits }, | |
86 | { "ThunderScan", COMPRESSION_THUNDERSCAN,TIFFInitThunderScan }, | |
87 | { "NeXT", COMPRESSION_NEXT, TIFFInitNeXT }, | |
88 | { "JPEG", COMPRESSION_JPEG, TIFFInitJPEG }, | |
89 | { "Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG }, | |
90 | { "CCITT RLE", COMPRESSION_CCITTRLE, TIFFInitCCITTRLE }, | |
91 | { "CCITT RLE/W", COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW }, | |
92 | { "CCITT Group 3", COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 }, | |
93 | { "CCITT Group 4", COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }, | |
94 | { "ISO JBIG", COMPRESSION_JBIG, TIFFInitJBIG }, | |
95 | { "Deflate", COMPRESSION_DEFLATE, TIFFInitZIP }, | |
96 | { "AdobeDeflate", COMPRESSION_ADOBE_DEFLATE , TIFFInitZIP }, | |
97 | { "PixarLog", COMPRESSION_PIXARLOG, TIFFInitPixarLog }, | |
98 | { "SGILog", COMPRESSION_SGILOG, TIFFInitSGILog }, | |
99 | { "SGILog24", COMPRESSION_SGILOG24, TIFFInitSGILog }, | |
80ed523f | 100 | { "LZMA", COMPRESSION_LZMA, TIFFInitLZMA }, |
8414a40c VZ |
101 | { NULL, 0, NULL } |
102 | }; | |
103 | ||
104 | static int | |
105 | _notConfigured(TIFF* tif) | |
106 | { | |
107 | const TIFFCodec* c = TIFFFindCODEC(tif->tif_dir.td_compression); | |
80ed523f VZ |
108 | char compression_code[20]; |
109 | ||
110 | sprintf( compression_code, "%d", tif->tif_dir.td_compression ); | |
8414a40c | 111 | TIFFErrorExt(tif->tif_clientdata, tif->tif_name, |
80ed523f VZ |
112 | "%s compression support is not configured", |
113 | c ? c->name : compression_code ); | |
8414a40c VZ |
114 | return (0); |
115 | } | |
116 | ||
117 | static int | |
118 | NotConfigured(TIFF* tif, int scheme) | |
119 | { | |
80ed523f VZ |
120 | (void) scheme; |
121 | ||
122 | tif->tif_fixuptags = _notConfigured; | |
123 | tif->tif_decodestatus = FALSE; | |
124 | tif->tif_setupdecode = _notConfigured; | |
125 | tif->tif_encodestatus = FALSE; | |
126 | tif->tif_setupencode = _notConfigured; | |
127 | return (1); | |
8414a40c VZ |
128 | } |
129 | ||
130 | /************************************************************************/ | |
131 | /* TIFFIsCODECConfigured() */ | |
132 | /************************************************************************/ | |
133 | ||
134 | /** | |
135 | * Check whether we have working codec for the specific coding scheme. | |
80ed523f | 136 | * |
8414a40c VZ |
137 | * @return returns 1 if the codec is configured and working. Otherwise |
138 | * 0 will be returned. | |
139 | */ | |
140 | ||
141 | int | |
142 | TIFFIsCODECConfigured(uint16 scheme) | |
143 | { | |
144 | const TIFFCodec* codec = TIFFFindCODEC(scheme); | |
145 | ||
146 | if(codec == NULL) { | |
80ed523f VZ |
147 | return 0; |
148 | } | |
149 | if(codec->init == NULL) { | |
150 | return 0; | |
151 | } | |
8414a40c | 152 | if(codec->init != NotConfigured){ |
80ed523f VZ |
153 | return 1; |
154 | } | |
8414a40c VZ |
155 | return 0; |
156 | } | |
157 | ||
80ed523f VZ |
158 | /* |
159 | * Local Variables: | |
160 | * mode: c | |
161 | * c-basic-offset: 8 | |
162 | * fill-column: 78 | |
163 | * End: | |
164 | */ |