ReactOS  0.4.14-dev-342-gdc047f9
tif_codec.c
Go to the documentation of this file.
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
88 #endif
90  { "LZW", COMPRESSION_LZW, TIFFInitLZW },
91  { "PackBits", COMPRESSION_PACKBITS, TIFFInitPackBits },
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
114 {
116  char compression_code[20];
117 
118  sprintf(compression_code, "%d",tif->tif_dir.td_compression );
120  "%s compression support is not configured",
121  c ? c->name : compression_code );
122  return (0);
123 }
124 
125 static int
127 {
128  (void) scheme;
129 
131  tif->tif_decodestatus = FALSE;
133  tif->tif_encodestatus = FALSE;
135  return (1);
136 }
137 
138 /************************************************************************/
139 /* TIFFIsCODECConfigured() */
140 /************************************************************************/
141 
149 int
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  */
#define COMPRESSION_PACKBITS
Definition: tiff.h:171
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
#define TIFFInitCCITTFax4
Definition: tif_codec.c:57
#define COMPRESSION_WEBP
Definition: tiff.h:194
#define TIFFInitPixarLog
Definition: tif_codec.c:66
#define TIFFInitCCITTFax3
Definition: tif_codec.c:56
static int _notConfigured(TIFF *tif)
Definition: tif_codec.c:113
#define TIFFInitCCITTRLE
Definition: tif_codec.c:54
#define TIFFInitCCITTRLEW
Definition: tif_codec.c:55
#define COMPRESSION_CCITTFAX3
Definition: tiff.h:160
#define COMPRESSION_SGILOG24
Definition: tiff.h:188
#define TIFFInitNeXT
Definition: tif_codec.c:45
DWORD scheme
#define COMPRESSION_CCITTRLE
Definition: tiff.h:159
static int NotConfigured(TIFF *, int)
Definition: tif_codec.c:126
#define COMPRESSION_OJPEG
Definition: tiff.h:165
thandle_t tif_clientdata
Definition: tiffiop.h:191
char * tif_name
Definition: tiffiop.h:103
Definition: tiffiop.h:102
#define TIFFInitOJPEG
Definition: tif_codec.c:51
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define COMPRESSION_DEFLATE
Definition: tiff.h:181
#define COMPRESSION_CCITTFAX4
Definition: tiff.h:162
#define TIFFInitThunderScan
Definition: tif_codec.c:42
smooth NULL
Definition: ftsmooth.c:416
int tif_encodestatus
Definition: tiffiop.h:161
#define TIFFInitJBIG
Definition: tif_codec.c:60
#define TIFFInitLZMA
Definition: tif_codec.c:72
#define COMPRESSION_CCITTRLEW
Definition: tiff.h:170
#define TIFFInitPackBits
Definition: tif_codec.c:39
#define COMPRESSION_PIXARLOG
Definition: tiff.h:180
#define COMPRESSION_JBIG
Definition: tiff.h:186
const GLubyte * c
Definition: glext.h:8905
#define COMPRESSION_LZMA
Definition: tiff.h:192
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65
#define TIFFInitZSTD
Definition: tif_codec.c:75
#define TIFFInitSGILog
Definition: tif_codec.c:69
const TIFFCodec * TIFFFindCODEC(uint16 scheme)
Definition: tif_compress.c:186
#define COMPRESSION_NONE
Definition: tiff.h:158
#define COMPRESSION_SGILOG
Definition: tiff.h:187
#define COMPRESSION_JPEG
Definition: tiff.h:166
TIFFInitMethod init
Definition: tiffio.h:258
TIFFCodec _TIFFBuiltinCODECS[]
Definition: tif_codec.c:87
int tif_decodestatus
Definition: tiffiop.h:156
#define COMPRESSION_THUNDERSCAN
Definition: tiff.h:172
int TIFFInitDumpMode(TIFF *tif, int scheme)
Definition: tif_dumpmode.c:123
#define COMPRESSION_ADOBE_DEFLATE
Definition: tiff.h:182
unsigned short uint16
Definition: types.h:30
TIFFBoolMethod tif_fixuptags
Definition: tiffiop.h:157
TIFFDirectory tif_dir
Definition: tiffiop.h:135
#define TIFFInitZIP
Definition: tif_codec.c:63
int TIFFIsCODECConfigured(uint16 scheme)
Definition: tif_codec.c:150
#define COMPRESSION_ZSTD
Definition: tiff.h:193
uint16 td_compression
Definition: tif_dir.h:76
#define COMPRESSION_LZW
Definition: tiff.h:164
#define TIFFInitWebP
Definition: tif_codec.c:78
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:160
#define TIFFInitLZW
Definition: tif_codec.c:36
#define COMPRESSION_NEXT
Definition: tiff.h:169
#define TIFFInitJPEG
Definition: tif_codec.c:48
TIFFBoolMethod tif_setupdecode
Definition: tiffiop.h:158