Developer World
Spresense SDK Library v3.2.0-ebc0364
jmorecfg.h
1/*
2 * jmorecfg.h
3 *
4 * Copyright (C) 1991-1997, Thomas G. Lane.
5 * Modified 1997-2013 by Guido Vollbeding.
6 * Copyright 2021 Sony Semiconductor Solutions Corporation
7 * This file is part of the Independent JPEG Group's software.
8 * For conditions of distribution and use, see the accompanying README file.
9 *
10 * This file contains additional configuration options that customize the
11 * JPEG software for special applications or support machine-dependent
12 * optimizations. Most users will not need to touch this file.
13 */
14
15/* Modified for Spresense by Sony Semiconductor Solutions. */
16#define SPRESENSE_PORT
17
18/*
19 * Define BITS_IN_JSAMPLE as either
20 * 8 for 8-bit sample values (the usual setting)
21 * 9 for 9-bit sample values
22 * 10 for 10-bit sample values
23 * 11 for 11-bit sample values
24 * 12 for 12-bit sample values
25 * Only 8, 9, 10, 11, and 12 bits sample data precision are supported for
26 * full-feature DCT processing. Further depths up to 16-bit may be added
27 * later for the lossless modes of operation.
28 * Run-time selection and conversion of data precision will be added later
29 * and are currently not supported, sorry.
30 * Exception: The transcoding part (jpegtran) supports all settings in a
31 * single instance, since it operates on the level of DCT coefficients and
32 * not sample values. The DCT coefficients are of the same type (16 bits)
33 * in all cases (see below).
34 */
35
36#define BITS_IN_JSAMPLE 8 /* use 8, 9, 10, 11, or 12 */
37
38
39/*
40 * Maximum number of components (color channels) allowed in JPEG image.
41 * To meet the letter of the JPEG spec, set this to 255. However, darn
42 * few applications need more than 4 channels (maybe 5 for CMYK + alpha
43 * mask). We recommend 10 as a reasonable compromise; use 4 if you are
44 * really short on memory. (Each allowed component costs a hundred or so
45 * bytes of storage, whether actually used in an image or not.)
46 */
47
48#ifdef SPRESENSE_PORT
49/* Modified for Spresense by Sony Semiconductor Solutions.
50 * Spresense supports only CbYCrY format,
51 * So, components number is 3.
52 */
53#define MAX_COMPONENTS 3 /* maximum number of image components */
54#else
55#define MAX_COMPONENTS 10 /* maximum number of image components */
56#endif
57
58/*
59 * Basic data types.
60 * You may need to change these if you have a machine with unusual data
61 * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
62 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
63 * but it had better be at least 16.
64 */
65
66/* Representation of a single sample (pixel element value).
67 * We frequently allocate large arrays of these, so it's important to keep
68 * them small. But if you have memory to burn and access to char or short
69 * arrays is very slow on your hardware, you might want to change these.
70 */
71
72#if BITS_IN_JSAMPLE == 8
73/* JSAMPLE should be the smallest type that will hold the values 0..255.
74 * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
75 */
76
77#ifdef HAVE_UNSIGNED_CHAR
78
79typedef unsigned char JSAMPLE;
80#define GETJSAMPLE(value) ((int) (value))
81
82#else /* not HAVE_UNSIGNED_CHAR */
83
84typedef char JSAMPLE;
85#ifdef CHAR_IS_UNSIGNED
86#define GETJSAMPLE(value) ((int) (value))
87#else
88#define GETJSAMPLE(value) ((int) (value) & 0xFF)
89#endif /* CHAR_IS_UNSIGNED */
90
91#endif /* HAVE_UNSIGNED_CHAR */
92
93#define MAXJSAMPLE 255
94#define CENTERJSAMPLE 128
95
96#endif /* BITS_IN_JSAMPLE == 8 */
97
98
99#if BITS_IN_JSAMPLE == 9
100/* JSAMPLE should be the smallest type that will hold the values 0..511.
101 * On nearly all machines "short" will do nicely.
102 */
103
104typedef short JSAMPLE;
105#define GETJSAMPLE(value) ((int) (value))
106
107#define MAXJSAMPLE 511
108#define CENTERJSAMPLE 256
109
110#endif /* BITS_IN_JSAMPLE == 9 */
111
112
113#if BITS_IN_JSAMPLE == 10
114/* JSAMPLE should be the smallest type that will hold the values 0..1023.
115 * On nearly all machines "short" will do nicely.
116 */
117
118typedef short JSAMPLE;
119#define GETJSAMPLE(value) ((int) (value))
120
121#define MAXJSAMPLE 1023
122#define CENTERJSAMPLE 512
123
124#endif /* BITS_IN_JSAMPLE == 10 */
125
126
127#if BITS_IN_JSAMPLE == 11
128/* JSAMPLE should be the smallest type that will hold the values 0..2047.
129 * On nearly all machines "short" will do nicely.
130 */
131
132typedef short JSAMPLE;
133#define GETJSAMPLE(value) ((int) (value))
134
135#define MAXJSAMPLE 2047
136#define CENTERJSAMPLE 1024
137
138#endif /* BITS_IN_JSAMPLE == 11 */
139
140
141#if BITS_IN_JSAMPLE == 12
142/* JSAMPLE should be the smallest type that will hold the values 0..4095.
143 * On nearly all machines "short" will do nicely.
144 */
145
146typedef short JSAMPLE;
147#define GETJSAMPLE(value) ((int) (value))
148
149#define MAXJSAMPLE 4095
150#define CENTERJSAMPLE 2048
151
152#endif /* BITS_IN_JSAMPLE == 12 */
153
154
155/* Representation of a DCT frequency coefficient.
156 * This should be a signed value of at least 16 bits; "short" is usually OK.
157 * Again, we allocate large arrays of these, but you can change to int
158 * if you have memory to burn and "short" is really slow.
159 */
160
161typedef short JCOEF;
162
163
164/* Compressed datastreams are represented as arrays of JOCTET.
165 * These must be EXACTLY 8 bits wide, at least once they are written to
166 * external storage. Note that when using the stdio data source/destination
167 * managers, this is also the data type passed to fread/fwrite.
168 */
169
170#ifdef HAVE_UNSIGNED_CHAR
171
172typedef unsigned char JOCTET;
173#define GETJOCTET(value) (value)
174
175#else /* not HAVE_UNSIGNED_CHAR */
176
177typedef char JOCTET;
178#ifdef CHAR_IS_UNSIGNED
179#define GETJOCTET(value) (value)
180#else
181#define GETJOCTET(value) ((value) & 0xFF)
182#endif /* CHAR_IS_UNSIGNED */
183
184#endif /* HAVE_UNSIGNED_CHAR */
185
186
187/* These typedefs are used for various table entries and so forth.
188 * They must be at least as wide as specified; but making them too big
189 * won't cost a huge amount of memory, so we don't provide special
190 * extraction code like we did for JSAMPLE. (In other words, these
191 * typedefs live at a different point on the speed/space tradeoff curve.)
192 */
193
194/* UINT8 must hold at least the values 0..255. */
195
196#ifdef HAVE_UNSIGNED_CHAR
197typedef unsigned char UINT8;
198#else /* not HAVE_UNSIGNED_CHAR */
199#ifdef CHAR_IS_UNSIGNED
200typedef char UINT8;
201#else /* not CHAR_IS_UNSIGNED */
202typedef short UINT8;
203#endif /* CHAR_IS_UNSIGNED */
204#endif /* HAVE_UNSIGNED_CHAR */
205
206/* UINT16 must hold at least the values 0..65535. */
207
208#ifdef HAVE_UNSIGNED_SHORT
209typedef unsigned short UINT16;
210#else /* not HAVE_UNSIGNED_SHORT */
211typedef unsigned int UINT16;
212#endif /* HAVE_UNSIGNED_SHORT */
213
214/* INT16 must hold at least the values -32768..32767. */
215
216#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
217typedef short INT16;
218#endif
219
220/* INT32 must hold at least signed 32-bit values. */
221
222#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
223#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
224#ifndef _BASETSD_H /* MinGW is slightly different */
225#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
226typedef long INT32;
227#endif
228#endif
229#endif
230#endif
231
232/* Datatype used for image dimensions. The JPEG standard only supports
233 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
234 * "unsigned int" is sufficient on all machines. However, if you need to
235 * handle larger images and you don't mind deviating from the spec, you
236 * can change this datatype.
237 */
238
239typedef unsigned int JDIMENSION;
240
241#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
242
243
244/* These macros are used in all function definitions and extern declarations.
245 * You could modify them if you need to change function linkage conventions;
246 * in particular, you'll need to do that to make the library a Windows DLL.
247 * Another application is to make all functions global for use with debuggers
248 * or code profilers that require it.
249 */
250
251/* a function called through method pointers: */
252#define METHODDEF(type) static type
253/* a function used only in its module: */
254#define LOCAL(type) static type
255/* a function referenced thru EXTERNs: */
256#define GLOBAL(type) type
257/* a reference to a GLOBAL function: */
258#define EXTERN(type) extern type
259
260
261/* This macro is used to declare a "method", that is, a function pointer.
262 * We want to supply prototype parameters if the compiler can cope.
263 * Note that the arglist parameter must be parenthesized!
264 * Again, you can customize this if you need special linkage keywords.
265 */
266
267#ifdef HAVE_PROTOTYPES
268#define JMETHOD(type,methodname,arglist) type (*methodname) arglist
269#else
270#define JMETHOD(type,methodname,arglist) type (*methodname) ()
271#endif
272
273
274/* The noreturn type identifier is used to declare functions
275 * which cannot return.
276 * Compilers can thus create more optimized code and perform
277 * better checks for warnings and errors.
278 * Static analyzer tools can make improved inferences about
279 * execution paths and are prevented from giving false alerts.
280 *
281 * Unfortunately, the proposed specifications of corresponding
282 * extensions in the Dec 2011 ISO C standard revision (C11),
283 * GCC, MSVC, etc. are not viable.
284 * Thus we introduce a user defined type to declare noreturn
285 * functions at least for clarity. A proper compiler would
286 * have a suitable noreturn type to match in place of void.
287 */
288
289#ifndef HAVE_NORETURN_T
290typedef void noreturn_t;
291#endif
292
293
294/* Here is the pseudo-keyword for declaring pointers that must be "far"
295 * on 80x86 machines. Most of the specialized coding for 80x86 is handled
296 * by just saying "FAR *" where such a pointer is needed. In a few places
297 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol.
298 */
299
300#ifndef FAR
301#ifdef NEED_FAR_POINTERS
302#define FAR far
303#else
304#define FAR
305#endif
306#endif
307
308
309/*
310 * On a few systems, type boolean and/or its values FALSE, TRUE may appear
311 * in standard header files. Or you may have conflicts with application-
312 * specific header files that you want to include together with these files.
313 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
314 */
315
316#ifndef HAVE_BOOLEAN
317#if defined FALSE || defined TRUE || defined QGLOBAL_H
318/* Qt3 defines FALSE and TRUE as "const" variables in qglobal.h */
319typedef int boolean;
320#ifndef FALSE /* in case these macros already exist */
321#define FALSE 0 /* values of boolean */
322#endif
323#ifndef TRUE
324#define TRUE 1
325#endif
326#else
327typedef enum { FALSE = 0, TRUE = 1 } boolean;
328#endif
329#endif
330
331
332/*
333 * The remaining options affect code selection within the JPEG library,
334 * but they don't need to be visible to most applications using the library.
335 * To minimize application namespace pollution, the symbols won't be
336 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
337 */
338
339#ifdef JPEG_INTERNALS
340#define JPEG_INTERNAL_OPTIONS
341#endif
342
343#ifdef JPEG_INTERNAL_OPTIONS
344
345
346/*
347 * These defines indicate whether to include various optional functions.
348 * Undefining some of these symbols will produce a smaller but less capable
349 * library. Note that you can leave certain source files out of the
350 * compilation/linking process if you've #undef'd the corresponding symbols.
351 * (You may HAVE to do that if your compiler doesn't like null source files.)
352 */
353
354/* Capability options common to encoder and decoder: */
355
356#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
357#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
358#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
359
360/* Encoder capability options: */
361
362#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
363#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
364#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
365#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/
366#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
367/* Note: if you selected more than 8-bit data precision, it is dangerous to
368 * turn off ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only
369 * good for 8-bit precision, so arithmetic coding is recommended for higher
370 * precision. The Huffman encoder normally uses entropy optimization to
371 * compute usable tables for higher precision. Otherwise, you'll have to
372 * supply different default Huffman tables.
373 * The exact same statements apply for progressive JPEG: the default tables
374 * don't work for progressive mode. (This may get fixed, however.)
375 */
376#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
377
378/* Decoder capability options: */
379
380#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */
381#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
382#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
383#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? (Requires DCT_ISLOW)*/
384#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
385#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
386#define UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
387#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
388#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
389#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
390
391/* more capability options later, no doubt */
392
393
394/*
395 * Ordering of RGB data in scanlines passed to or from the application.
396 * If your application wants to deal with data in the order B,G,R, just
397 * change these macros. You can also deal with formats such as R,G,B,X
398 * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing
399 * the offsets will also change the order in which colormap data is organized.
400 * RESTRICTIONS:
401 * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
402 * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
403 * is not 3 (they don't understand about dummy color components!). So you
404 * can't use color quantization if you change that value.
405 */
406
407#define RGB_RED 0 /* Offset of Red in an RGB scanline element */
408#define RGB_GREEN 1 /* Offset of Green */
409#define RGB_BLUE 2 /* Offset of Blue */
410#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
411
412
413/* Definitions for speed-related optimizations. */
414
415
416/* If your compiler supports inline functions, define INLINE
417 * as the inline keyword; otherwise define it as empty.
418 */
419
420#ifndef INLINE
421#ifdef __GNUC__ /* for instance, GNU C knows about inline */
422#define INLINE __inline__
423#endif
424#ifndef INLINE
425#define INLINE /* default is to define it as empty */
426#endif
427#endif
428
429
430/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
431 * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
432 * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
433 */
434
435#ifndef MULTIPLIER
436#define MULTIPLIER int /* type for fastest integer multiply */
437#endif
438
439
440/* FAST_FLOAT should be either float or double, whichever is done faster
441 * by your compiler. (Note that this type is only used in the floating point
442 * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
443 * Typically, float is faster in ANSI C compilers, while double is faster in
444 * pre-ANSI compilers (because they insist on converting to double anyway).
445 * The code below therefore chooses float if we have ANSI-style prototypes.
446 */
447
448#ifndef FAST_FLOAT
449#ifdef HAVE_PROTOTYPES
450#define FAST_FLOAT float
451#else
452#define FAST_FLOAT double
453#endif
454#endif
455
456#endif /* JPEG_INTERNAL_OPTIONS */