1 /*
2  * jerror.h
3  *
4  * Copyright (C) 1994-1998, Thomas G. Lane.
5  * This file is part of the Independent JPEG Group's software.
6  * For conditions of distribution and use, see the accompanying README file.
7  *
8  * This file defines the error and message codes for the JPEG library.
9  * Edit this file to add new codes, or to translate the message strings to
10  * some other language.
11  * A set of error-reporting macros are defined too.  Some applications using
12  * the JPEG library may wish to include this file to get the error codes
13  * and/or the macros.
14  */
15 
16 /*
17  * To define the enum list of message codes, include this file without
18  * defining macro JMESSAGE.  To create a message string table, include it
19  * again with a suitable JMESSAGE definition (see jerror.c for an example).
20  */
21 #ifndef JMESSAGE
22 #ifndef JERROR_H
23 /* First time through, define the enum list */
24 #define JMAKE_ENUM_LIST
25 #else
26 /* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */
27 #define JMESSAGE(code,string)
28 #endif /* JERROR_H */
29 #endif /* JMESSAGE */
30 
31 #ifdef JMAKE_ENUM_LIST
32 
33 typedef enum {
34 
35 #define JMESSAGE(code,string)	code ,
36 
37 #endif /* JMAKE_ENUM_LIST */
38 
39 JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */
40 
41 /* For maintenance convenience, list is alphabetical by message code name */
42 JMESSAGE(JERR_ARITH_NOTIMPL,
43 	 "Sorry, there are legal restrictions on arithmetic coding")
44 JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix")
45 JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix")
46 JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode")
47 JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS")
48 JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range")
49 JMESSAGE(JERR_BAD_DCTSIZE, "IDCT output block size %d not supported")
50 JMESSAGE(JERR_BAD_DIFF, "spatial difference out of range")
51 JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition")
52 JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace")
53 JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace")
54 JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length")
55 JMESSAGE(JERR_BAD_LIB_VERSION,
56 	 "Wrong JPEG library version: library is %d, caller expects %d")
57 JMESSAGE(JERR_BAD_LOSSLESS,
58 	 "Invalid lossless parameters Ss=%d Se=%d Ah=%d Al=%d")
59 JMESSAGE(JERR_BAD_LOSSLESS_SCRIPT,
60 	 "Invalid lossless parameters at scan script entry %d")
61 JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan")
62 JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d")
63 JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d")
64 JMESSAGE(JERR_BAD_PROGRESSION,
65 	 "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d")
66 JMESSAGE(JERR_BAD_PROG_SCRIPT,
67 	 "Invalid progressive parameters at scan script entry %d")
68 JMESSAGE(JERR_BAD_RESTART, "Invalid restart interval: %d, must be an integer multiple of the number of MCUs in an MCU_row (%d)")
69 JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors")
70 JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d")
71 JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d")
72 JMESSAGE(JERR_BAD_STRUCT_SIZE,
73 	 "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u")
74 JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access")
75 JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small")
76 JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here")
77 JMESSAGE(JERR_CANT_TRANSCODE,
78 	 "Cannot transcode to/from lossless JPEG datastreams")
79 JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet")
80 JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d")
81 JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request")
82 JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d")
83 JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x")
84 JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d")
85 JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d")
86 JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)")
87 JMESSAGE(JERR_EMS_READ, "Read from EMS failed")
88 JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed")
89 JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan")
90 JMESSAGE(JERR_FILE_READ, "Input file read error")
91 JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?")
92 JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet")
93 JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow")
94 JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry")
95 JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels")
96 JMESSAGE(JERR_INPUT_EMPTY, "Empty input file")
97 JMESSAGE(JERR_INPUT_EOF, "Premature end of input file")
98 JMESSAGE(JERR_MISMATCHED_QUANT_TABLE,
99 	 "Cannot transcode due to multiple use of quantization table %d")
100 JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data")
101 JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change")
102 JMESSAGE(JERR_NOTIMPL, "Not implemented yet")
103 JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time")
104 #ifdef WITH_ARITHMETIC_PATCH
105 JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined")
106 #endif
107 JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported")
108 JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined")
109 JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image")
110 JMESSAGE(JERR_NO_LOSSLESS_SCRIPT, "Lossless encoding was requested but no scan script was supplied")
111 JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined")
112 JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x")
113 JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)")
114 JMESSAGE(JERR_QUANT_COMPONENTS,
115 	 "Cannot quantize more than %d color components")
116 JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
117 JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
118 JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
119 JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
120 JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
121 JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
122 JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
123 JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
124 JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
125 JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")
126 JMESSAGE(JERR_TFILE_WRITE,
127 	 "Write failed on temporary file --- out of disk space?")
128 JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines")
129 JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x")
130 JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up")
131 JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation")
132 JMESSAGE(JERR_XMS_READ, "Read from XMS failed")
133 JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed")
134 JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT)
135 JMESSAGE(JMSG_VERSION, JVERSION)
136 JMESSAGE(JTRC_16BIT_TABLES,
137 	 "Caution: quantization tables are too coarse for baseline JPEG")
138 JMESSAGE(JTRC_ADOBE,
139 	 "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d")
140 JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u")
141 JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u")
142 JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x")
143 JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x")
144 JMESSAGE(JTRC_DQT, "Define Quantization Table %d  precision %d")
145 JMESSAGE(JTRC_DRI, "Define Restart Interval %u")
146 JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u")
147 JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u")
148 JMESSAGE(JTRC_EOI, "End Of Image")
149 JMESSAGE(JTRC_HUFFBITS, "        %3d %3d %3d %3d %3d %3d %3d %3d")
150 JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d  %d")
151 JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE,
152 	 "Warning: thumbnail image size does not match data length %u")
153 JMESSAGE(JTRC_JFIF_EXTENSION,
154 	 "JFIF extension marker: type 0x%02x, length %u")
155 JMESSAGE(JTRC_JFIF_THUMBNAIL, "    with %d x %d thumbnail image")
156 JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u")
157 JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x")
158 JMESSAGE(JTRC_QUANTVALS, "        %4u %4u %4u %4u %4u %4u %4u %4u")
159 JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors")
160 JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors")
161 JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization")
162 JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d")
163 JMESSAGE(JTRC_RST, "RST%d")
164 JMESSAGE(JTRC_SMOOTH_NOTIMPL,
165 	 "Smoothing not supported with nonstandard sampling ratios")
166 JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d")
167 JMESSAGE(JTRC_SOF_COMPONENT, "    Component %d: %dhx%dv q=%d")
168 JMESSAGE(JTRC_SOI, "Start of Image")
169 JMESSAGE(JTRC_SOS, "Start Of Scan: %d components")
170 JMESSAGE(JTRC_SOS_COMPONENT, "    Component %d: dc=%d ac=%d")
171 JMESSAGE(JTRC_SOS_PARAMS, "  Ss=%d, Se=%d, Ah=%d, Al=%d")
172 JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s")
173 JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s")
174 JMESSAGE(JTRC_THUMB_JPEG,
175 	 "JFIF extension marker: JPEG-compressed thumbnail image, length %u")
176 JMESSAGE(JTRC_THUMB_PALETTE,
177 	 "JFIF extension marker: palette thumbnail image, length %u")
178 JMESSAGE(JTRC_THUMB_RGB,
179 	 "JFIF extension marker: RGB thumbnail image, length %u")
180 JMESSAGE(JTRC_UNKNOWN_LOSSLESS_IDS,
181 	 "Unrecognized component IDs %d %d %d, assuming RGB")
182 JMESSAGE(JTRC_UNKNOWN_LOSSY_IDS,
183 	 "Unrecognized component IDs %d %d %d, assuming YCbCr")
184 JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u")
185 JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u")
186 JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d")
187 #ifdef WITH_ARITHMETIC_PATCH
188 JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code")
189 #endif
190 JMESSAGE(JWRN_BOGUS_PROGRESSION,
191 	 "Inconsistent progression sequence for component %d coefficient %d")
192 JMESSAGE(JWRN_EXTRANEOUS_DATA,
193 	 "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x")
194 JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment")
195 JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code")
196 JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d")
197 JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file")
198 JMESSAGE(JWRN_MUST_DOWNSCALE,
199 	 "Must downscale data from %d bits to %d")
200 JMESSAGE(JWRN_MUST_RESYNC,
201 	 "Corrupt JPEG data: found marker 0x%02x instead of RST%d")
202 JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG")
203 JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines")
204 
205 #ifdef JMAKE_ENUM_LIST
206 
207   JMSG_LASTMSGCODE
208 } J_MESSAGE_CODE;
209 
210 #undef JMAKE_ENUM_LIST
211 #endif /* JMAKE_ENUM_LIST */
212 
213 /* Zap JMESSAGE macro so that future re-inclusions do nothing by default */
214 #undef JMESSAGE
215 
216 
217 #ifndef JERROR_H
218 #define JERROR_H
219 
220 /* Macros to simplify using the error and trace message stuff */
221 /* The first parameter is either type of cinfo pointer */
222 
223 /* Fatal errors (print message and exit) */
224 #define ERREXIT(cinfo,code)  \
225   ((cinfo)->err->msg_code = (code), \
226    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
227 #define ERREXIT1(cinfo,code,p1)  \
228   ((cinfo)->err->msg_code = (code), \
229    (cinfo)->err->msg_parm.i[0] = (p1), \
230    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
231 #define ERREXIT2(cinfo,code,p1,p2)  \
232   ((cinfo)->err->msg_code = (code), \
233    (cinfo)->err->msg_parm.i[0] = (p1), \
234    (cinfo)->err->msg_parm.i[1] = (p2), \
235    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
236 #define ERREXIT3(cinfo,code,p1,p2,p3)  \
237   ((cinfo)->err->msg_code = (code), \
238    (cinfo)->err->msg_parm.i[0] = (p1), \
239    (cinfo)->err->msg_parm.i[1] = (p2), \
240    (cinfo)->err->msg_parm.i[2] = (p3), \
241    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
242 #define ERREXIT4(cinfo,code,p1,p2,p3,p4)  \
243   ((cinfo)->err->msg_code = (code), \
244    (cinfo)->err->msg_parm.i[0] = (p1), \
245    (cinfo)->err->msg_parm.i[1] = (p2), \
246    (cinfo)->err->msg_parm.i[2] = (p3), \
247    (cinfo)->err->msg_parm.i[3] = (p4), \
248    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
249 #define ERREXITS(cinfo,code,str)  \
250   ((cinfo)->err->msg_code = (code), \
251    strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
252    (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo)))
253 
254 #define MAKESTMT(stuff)		do { stuff } while (0)
255 
256 /* Nonfatal errors (we can keep going, but the data is probably corrupt) */
257 #define WARNMS(cinfo,code)  \
258   ((cinfo)->err->msg_code = (code), \
259    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
260 #define WARNMS1(cinfo,code,p1)  \
261   ((cinfo)->err->msg_code = (code), \
262    (cinfo)->err->msg_parm.i[0] = (p1), \
263    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
264 #define WARNMS2(cinfo,code,p1,p2)  \
265   ((cinfo)->err->msg_code = (code), \
266    (cinfo)->err->msg_parm.i[0] = (p1), \
267    (cinfo)->err->msg_parm.i[1] = (p2), \
268    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1))
269 
270 /* Informational/debugging messages */
271 #define TRACEMS(cinfo,lvl,code)  \
272   ((cinfo)->err->msg_code = (code), \
273    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
274 #define TRACEMS1(cinfo,lvl,code,p1)  \
275   ((cinfo)->err->msg_code = (code), \
276    (cinfo)->err->msg_parm.i[0] = (p1), \
277    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
278 #define TRACEMS2(cinfo,lvl,code,p1,p2)  \
279   ((cinfo)->err->msg_code = (code), \
280    (cinfo)->err->msg_parm.i[0] = (p1), \
281    (cinfo)->err->msg_parm.i[1] = (p2), \
282    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
283 #define TRACEMS3(cinfo,lvl,code,p1,p2,p3)  \
284   MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
285 	   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \
286 	   (cinfo)->err->msg_code = (code); \
287 	   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
288 #define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4)  \
289   MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
290 	   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
291 	   (cinfo)->err->msg_code = (code); \
292 	   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
293 #define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5)  \
294   MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
295 	   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
296 	   _mp[4] = (p5); \
297 	   (cinfo)->err->msg_code = (code); \
298 	   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
299 #define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8)  \
300   MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \
301 	   _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \
302 	   _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \
303 	   (cinfo)->err->msg_code = (code); \
304 	   (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); )
305 #define TRACEMSS(cinfo,lvl,code,str)  \
306   ((cinfo)->err->msg_code = (code), \
307    strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \
308    (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)))
309 
310 #endif /* JERROR_H */
311