ReactOS 0.4.16-dev-2617-g01a0906
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#include "tiffiop.h"
31
32static int NotConfigured(TIFF *, int);
33
34#ifndef LZW_SUPPORT
35#define TIFFInitLZW NotConfigured
36#endif
37#ifndef PACKBITS_SUPPORT
38#define TIFFInitPackBits NotConfigured
39#endif
40#ifndef THUNDER_SUPPORT
41#define TIFFInitThunderScan NotConfigured
42#endif
43#ifndef NEXT_SUPPORT
44#define TIFFInitNeXT NotConfigured
45#endif
46#ifndef JPEG_SUPPORT
47#define TIFFInitJPEG NotConfigured
48#endif
49#ifndef OJPEG_SUPPORT
50#define TIFFInitOJPEG NotConfigured
51#endif
52#ifndef CCITT_SUPPORT
53#define TIFFInitCCITTRLE NotConfigured
54#define TIFFInitCCITTRLEW NotConfigured
55#define TIFFInitCCITTFax3 NotConfigured
56#define TIFFInitCCITTFax4 NotConfigured
57#endif
58#ifndef JBIG_SUPPORT
59#define TIFFInitJBIG NotConfigured
60#endif
61#ifndef ZIP_SUPPORT
62#define TIFFInitZIP NotConfigured
63#endif
64#ifndef PIXARLOG_SUPPORT
65#define TIFFInitPixarLog NotConfigured
66#endif
67#ifndef LOGLUV_SUPPORT
68#define TIFFInitSGILog NotConfigured
69#endif
70#ifndef LERC_SUPPORT
71#define TIFFInitLERC NotConfigured
72#endif
73#ifndef LZMA_SUPPORT
74#define TIFFInitLZMA NotConfigured
75#endif
76#ifndef ZSTD_SUPPORT
77#define TIFFInitZSTD NotConfigured
78#endif
79#ifndef WEBP_SUPPORT
80#define TIFFInitWebP NotConfigured
81#endif
82
83/*
84 * Compression schemes statically built into the library.
85 */
93 {"Old-style JPEG", COMPRESSION_OJPEG, TIFFInitOJPEG},
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},
108 {NULL, 0, NULL}};
109
110static int _notConfigured(TIFF *tif)
111{
113 char compression_code[20];
114
115 snprintf(compression_code, sizeof(compression_code), "%" PRIu16,
117 TIFFErrorExtR(tif, tif->tif_name,
118 "%s compression support is not configured",
119 c ? c->name : compression_code);
120 return (0);
121}
122
123static int NotConfigured(TIFF *tif, int scheme)
124{
125 (void)scheme;
126
128 tif->tif_decodestatus = FALSE;
130 tif->tif_encodestatus = FALSE;
132 return (1);
133}
134
135/************************************************************************/
136/* TIFFIsCODECConfigured() */
137/************************************************************************/
138
147{
148 const TIFFCodec *codec = TIFFFindCODEC(scheme);
149
150 if (codec == NULL)
151 {
152 return 0;
153 }
154 if (codec->init == NULL)
155 {
156 return 0;
157 }
158 if (codec->init != NotConfigured)
159 {
160 return 1;
161 }
162 return 0;
163}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define PRIu16
Definition: inttypes.h:83
unsigned short uint16_t
Definition: stdint.h:35
const GLubyte * c
Definition: glext.h:8905
DWORD scheme
TIFFInitMethod init
Definition: tiffio.h:274
uint16_t td_compression
Definition: tif_dir.h:88
Definition: tiffiop.h:113
TIFFBoolMethod tif_fixuptags
Definition: tiffiop.h:198
char * tif_name
Definition: tiffiop.h:114
TIFFBoolMethod tif_setupencode
Definition: tiffiop.h:201
TIFFDirectory tif_dir
Definition: tiffiop.h:157
int tif_decodestatus
Definition: tiffiop.h:197
int tif_encodestatus
Definition: tiffiop.h:202
TIFFBoolMethod tif_setupdecode
Definition: tiffiop.h:199
#define TIFFInitCCITTRLEW
Definition: tif_codec.c:54
#define TIFFInitLZW
Definition: tif_codec.c:35
#define TIFFInitPixarLog
Definition: tif_codec.c:65
#define TIFFInitJPEG
Definition: tif_codec.c:47
#define TIFFInitCCITTFax4
Definition: tif_codec.c:56
#define TIFFInitPackBits
Definition: tif_codec.c:38
#define TIFFInitNeXT
Definition: tif_codec.c:44
#define TIFFInitZSTD
Definition: tif_codec.c:77
static int _notConfigured(TIFF *tif)
Definition: tif_codec.c:110
#define TIFFInitJBIG
Definition: tif_codec.c:59
#define TIFFInitCCITTFax3
Definition: tif_codec.c:55
static int NotConfigured(TIFF *, int)
Definition: tif_codec.c:123
#define TIFFInitLZMA
Definition: tif_codec.c:74
#define TIFFInitSGILog
Definition: tif_codec.c:68
#define TIFFInitCCITTRLE
Definition: tif_codec.c:53
#define TIFFInitZIP
Definition: tif_codec.c:62
#define TIFFInitWebP
Definition: tif_codec.c:80
const TIFFCodec _TIFFBuiltinCODECS[]
Definition: tif_codec.c:86
int TIFFIsCODECConfigured(uint16_t scheme)
Definition: tif_codec.c:146
#define TIFFInitThunderScan
Definition: tif_codec.c:41
#define TIFFInitOJPEG
Definition: tif_codec.c:50
#define TIFFInitLERC
Definition: tif_codec.c:71
const TIFFCodec * TIFFFindCODEC(uint16_t scheme)
Definition: tif_compress.c:192
int TIFFInitDumpMode(TIFF *tif, int scheme)
Definition: tif_dumpmode.c:110
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107
#define COMPRESSION_NONE
Definition: tiff.h:182
#define COMPRESSION_PIXARLOG
Definition: tiff.h:204
#define COMPRESSION_ZSTD
Definition: tiff.h:216
#define COMPRESSION_CCITTFAX3
Definition: tiff.h:184
#define COMPRESSION_CCITTRLE
Definition: tiff.h:183
#define COMPRESSION_OJPEG
Definition: tiff.h:189
#define COMPRESSION_DEFLATE
Definition: tiff.h:205
#define COMPRESSION_SGILOG
Definition: tiff.h:210
#define COMPRESSION_CCITTRLEW
Definition: tiff.h:194
#define COMPRESSION_LZMA
Definition: tiff.h:215
#define COMPRESSION_WEBP
Definition: tiff.h:217
#define COMPRESSION_JBIG
Definition: tiff.h:209
#define COMPRESSION_LERC
Definition: tiff.h:213
#define COMPRESSION_ADOBE_DEFLATE
Definition: tiff.h:206
#define COMPRESSION_PACKBITS
Definition: tiff.h:195
#define COMPRESSION_LZW
Definition: tiff.h:188
#define COMPRESSION_SGILOG24
Definition: tiff.h:211
#define COMPRESSION_CCITTFAX4
Definition: tiff.h:186
#define COMPRESSION_NEXT
Definition: tiff.h:193
#define COMPRESSION_JPEG
Definition: tiff.h:190
#define COMPRESSION_THUNDERSCAN
Definition: tiff.h:196
#define snprintf
Definition: wintirpc.h:48