NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h
Go to the documentation of this file.
1 /*
2  * jmorecfg.h
3  *
4  * SPDX-License-Identifier: IJG
5  *
6  * This file was part of the Independent JPEG Group's software:
7  * Copyright (C) 1991-1997, Thomas G. Lane.
8  * Modified 1997-2009 by Guido Vollbeding.
9  * libjpeg-turbo Modifications:
10  * Copyright (C) 2009, 2011, 2014-2015, D. R. Commander.
11  * For conditions of distribution and use, see the accompanying README.ijg
12  * file.
13  *
14  * This file contains additional configuration options that customize the
15  * JPEG software for special applications or support machine-dependent
16  * optimizations. Most users will not need to touch this file.
17  */
18 
19 
20 /*
21  * Maximum number of components (color channels) allowed in JPEG image.
22  * To meet the letter of the JPEG spec, set this to 255. However, darn
23  * few applications need more than 4 channels (maybe 5 for CMYK + alpha
24  * mask). We recommend 10 as a reasonable compromise; use 4 if you are
25  * really short on memory. (Each allowed component costs a hundred or so
26  * bytes of storage, whether actually used in an image or not.)
27  */
28 
29 #define MAX_COMPONENTS 10 /* maximum number of image components */
30 
31 
32 /*
33  * Basic data types.
34  * You may need to change these if you have a machine with unusual data
35  * type sizes; for example, "char" not 8 bits, "short" not 16 bits,
36  * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits,
37  * but it had better be at least 16.
38  */
39 
40 /* Representation of a single sample (pixel element value).
41  * We frequently allocate large arrays of these, so it's important to keep
42  * them small. But if you have memory to burn and access to char or short
43  * arrays is very slow on your hardware, you might want to change these.
44  */
45 
46 #if BITS_IN_JSAMPLE == 8
47 /* JSAMPLE should be the smallest type that will hold the values 0..255.
48  * You can use a signed char by having GETJSAMPLE mask it with 0xFF.
49  */
50 
51 #ifdef HAVE_UNSIGNED_CHAR
52 
53 typedef unsigned char JSAMPLE;
54 #define GETJSAMPLE(value) ((int) (value))
55 
56 #else /* not HAVE_UNSIGNED_CHAR */
57 
58 typedef char JSAMPLE;
59 #ifdef __CHAR_UNSIGNED__
60 #define GETJSAMPLE(value) ((int) (value))
61 #else
62 #define GETJSAMPLE(value) ((int) (value) & 0xFF)
63 #endif /* __CHAR_UNSIGNED__ */
64 
65 #endif /* HAVE_UNSIGNED_CHAR */
66 
67 #define MAXJSAMPLE 255
68 #define CENTERJSAMPLE 128
69 
70 #endif /* BITS_IN_JSAMPLE == 8 */
71 
72 
73 #if BITS_IN_JSAMPLE == 12
74 /* JSAMPLE should be the smallest type that will hold the values 0..4095.
75  * On nearly all machines "short" will do nicely.
76  */
77 
78 typedef short JSAMPLE;
79 #define GETJSAMPLE(value) ((int) (value))
80 
81 #define MAXJSAMPLE 4095
82 #define CENTERJSAMPLE 2048
83 
84 #endif /* BITS_IN_JSAMPLE == 12 */
85 
86 
87 /* Representation of a DCT frequency coefficient.
88  * This should be a signed value of at least 16 bits; "short" is usually OK.
89  * Again, we allocate large arrays of these, but you can change to int
90  * if you have memory to burn and "short" is really slow.
91  */
92 
93 typedef short JCOEF;
94 
95 
96 /* Compressed datastreams are represented as arrays of JOCTET.
97  * These must be EXACTLY 8 bits wide, at least once they are written to
98  * external storage. Note that when using the stdio data source/destination
99  * managers, this is also the data type passed to fread/fwrite.
100  */
101 
102 #ifdef HAVE_UNSIGNED_CHAR
103 
104 typedef unsigned char JOCTET;
105 #define GETJOCTET(value) (value)
106 
107 #else /* not HAVE_UNSIGNED_CHAR */
108 
109 typedef char JOCTET;
110 #ifdef __CHAR_UNSIGNED__
111 #define GETJOCTET(value) (value)
112 #else
113 #define GETJOCTET(value) ((value) & 0xFF)
114 #endif /* __CHAR_UNSIGNED__ */
115 
116 #endif /* HAVE_UNSIGNED_CHAR */
117 
118 
119 /* These typedefs are used for various table entries and so forth.
120  * They must be at least as wide as specified; but making them too big
121  * won't cost a huge amount of memory, so we don't provide special
122  * extraction code like we did for JSAMPLE. (In other words, these
123  * typedefs live at a different point on the speed/space tradeoff curve.)
124  */
125 
126 /* UINT8 must hold at least the values 0..255. */
127 
128 #ifdef HAVE_UNSIGNED_CHAR
129 typedef unsigned char UINT8;
130 #else /* not HAVE_UNSIGNED_CHAR */
131 #ifdef __CHAR_UNSIGNED__
132 typedef char UINT8;
133 #else /* not __CHAR_UNSIGNED__ */
134 typedef short UINT8;
135 #endif /* __CHAR_UNSIGNED__ */
136 #endif /* HAVE_UNSIGNED_CHAR */
137 
138 /* UINT16 must hold at least the values 0..65535. */
139 
140 #ifdef HAVE_UNSIGNED_SHORT
141 typedef unsigned short UINT16;
142 #else /* not HAVE_UNSIGNED_SHORT */
143 typedef unsigned int UINT16;
144 #endif /* HAVE_UNSIGNED_SHORT */
145 
146 /* INT16 must hold at least the values -32768..32767. */
147 
148 #ifndef XMD_H /* X11/xmd.h correctly defines INT16 */
149 typedef short INT16;
150 #endif
151 
152 /* INT32 must hold at least signed 32-bit values.
153  *
154  * NOTE: The INT32 typedef dates back to libjpeg v5 (1994.) Integers were
155  * sometimes 16-bit back then (MS-DOS), which is why INT32 is typedef'd to
156  * long. It also wasn't common (or at least as common) in 1994 for INT32 to be
157  * defined by platform headers. Since then, however, INT32 is defined in
158  * several other common places:
159  *
160  * Xmd.h (X11 header) typedefs INT32 to int on 64-bit platforms and long on
161  * 32-bit platforms (i.e always a 32-bit signed type.)
162  *
163  * basetsd.h (Win32 header) typedefs INT32 to int (always a 32-bit signed type
164  * on modern platforms.)
165  *
166  * qglobal.h (Qt header) typedefs INT32 to int (always a 32-bit signed type on
167  * modern platforms.)
168  *
169  * This is a recipe for conflict, since "long" and "int" aren't always
170  * compatible types. Since the definition of INT32 has technically been part
171  * of the libjpeg API for more than 20 years, we can't remove it, but we do not
172  * use it internally any longer. We instead define a separate type (JLONG)
173  * for internal use, which ensures that internal behavior will always be the
174  * same regardless of any external headers that may be included.
175  */
176 
177 #ifndef XMD_H /* X11/xmd.h correctly defines INT32 */
178 #ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */
179 #ifndef _BASETSD_H /* MinGW is slightly different */
180 #ifndef QGLOBAL_H /* Qt defines it in qglobal.h */
181 typedef long INT32;
182 #endif
183 #endif
184 #endif
185 #endif
186 
187 /* Datatype used for image dimensions. The JPEG standard only supports
188  * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore
189  * "unsigned int" is sufficient on all machines. However, if you need to
190  * handle larger images and you don't mind deviating from the spec, you
191  * can change this datatype. (Note that changing this datatype will
192  * potentially require modifying the SIMD code. The x86-64 SIMD extensions,
193  * in particular, assume a 32-bit JDIMENSION.)
194  */
195 
196 typedef unsigned int JDIMENSION;
197 
198 #define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */
199 
200 
201 /* These macros are used in all function definitions and extern declarations.
202  * You could modify them if you need to change function linkage conventions;
203  * in particular, you'll need to do that to make the library a Windows DLL.
204  * Another application is to make all functions global for use with debuggers
205  * or code profilers that require it.
206  */
207 
208 /* a function called through method pointers: */
209 #define METHODDEF(type) static type
210 /* a function used only in its module: */
211 #define LOCAL(type) static type
212 /* a function referenced thru EXTERNs: */
213 #define GLOBAL(type) type
214 /* a reference to a GLOBAL function: */
215 #define EXTERN(type) extern type
216 
217 
218 /* Originally, this macro was used as a way of defining function prototypes
219  * for both modern compilers as well as older compilers that did not support
220  * prototype parameters. libjpeg-turbo has never supported these older,
221  * non-ANSI compilers, but the macro is still included because there is some
222  * software out there that uses it.
223  */
224 
225 #define JMETHOD(type,methodname,arglist) type (*methodname) arglist
226 
227 
228 /* libjpeg-turbo no longer supports platforms that have far symbols (MS-DOS),
229  * but again, some software relies on this macro.
230  */
231 
232 #undef FAR
233 #define FAR
234 
235 
236 /*
237  * On a few systems, type boolean and/or its values FALSE, TRUE may appear
238  * in standard header files. Or you may have conflicts with application-
239  * specific header files that you want to include together with these files.
240  * Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
241  */
242 
243 #ifndef HAVE_BOOLEAN
244 typedef int boolean;
245 #endif
246 #ifndef FALSE /* in case these macros already exist */
247 #define FALSE 0 /* values of boolean */
248 #endif
249 #ifndef TRUE
250 #define TRUE 1
251 #endif
252 
253 
254 /*
255  * The remaining options affect code selection within the JPEG library,
256  * but they don't need to be visible to most applications using the library.
257  * To minimize application namespace pollution, the symbols won't be
258  * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined.
259  */
260 
261 #ifdef JPEG_INTERNALS
262 #define JPEG_INTERNAL_OPTIONS
263 #endif
264 
265 #ifdef JPEG_INTERNAL_OPTIONS
266 
267 
268 /*
269  * These defines indicate whether to include various optional functions.
270  * Undefining some of these symbols will produce a smaller but less capable
271  * library. Note that you can leave certain source files out of the
272  * compilation/linking process if you've #undef'd the corresponding symbols.
273  * (You may HAVE to do that if your compiler doesn't like null source files.)
274  */
275 
276 /* Capability options common to encoder and decoder: */
277 
278 #define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */
279 #define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */
280 #define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */
281 
282 /* Encoder capability options: */
283 
284 #define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
285 #define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
286 #define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */
287 /* Note: if you selected 12-bit data precision, it is dangerous to turn off
288  * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit
289  * precision, so jchuff.c normally uses entropy optimization to compute
290  * usable tables for higher precision. If you don't want to do optimization,
291  * you'll have to supply different default Huffman tables.
292  * The exact same statements apply for progressive JPEG: the default tables
293  * don't work for progressive mode. (This may get fixed, however.)
294  */
295 #define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */
296 
297 /* Decoder capability options: */
298 
299 #define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */
300 #define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/
301 #define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */
302 #define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */
303 #define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */
304 #undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */
305 #define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */
306 #define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */
307 #define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */
308 
309 /* more capability options later, no doubt */
310 
311 
312 /*
313  * The RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE macros are a vestigial
314  * feature of libjpeg. The idea was that, if an application developer needed
315  * to compress from/decompress to a BGR/BGRX/RGBX/XBGR/XRGB buffer, they could
316  * change these macros, rebuild libjpeg, and link their application statically
317  * with it. In reality, few people ever did this, because there were some
318  * severe restrictions involved (cjpeg and djpeg no longer worked properly,
319  * compressing/decompressing RGB JPEGs no longer worked properly, and the color
320  * quantizer wouldn't work with pixel sizes other than 3.) Further, since all
321  * of the O/S-supplied versions of libjpeg were built with the default values
322  * of RGB_RED, RGB_GREEN, RGB_BLUE, and RGB_PIXELSIZE, many applications have
323  * come to regard these values as immutable.
324  *
325  * The libjpeg-turbo colorspace extensions provide a much cleaner way of
326  * compressing from/decompressing to buffers with arbitrary component orders
327  * and pixel sizes. Thus, we do not support changing the values of RGB_RED,
328  * RGB_GREEN, RGB_BLUE, or RGB_PIXELSIZE. In addition to the restrictions
329  * listed above, changing these values will also break the SIMD extensions and
330  * the regression tests.
331  */
332 
333 #define RGB_RED 0 /* Offset of Red in an RGB scanline element */
334 #define RGB_GREEN 1 /* Offset of Green */
335 #define RGB_BLUE 2 /* Offset of Blue */
336 #define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */
337 
338 #define JPEG_NUMCS 17
339 
340 #define EXT_RGB_RED 0
341 #define EXT_RGB_GREEN 1
342 #define EXT_RGB_BLUE 2
343 #define EXT_RGB_PIXELSIZE 3
344 
345 #define EXT_RGBX_RED 0
346 #define EXT_RGBX_GREEN 1
347 #define EXT_RGBX_BLUE 2
348 #define EXT_RGBX_PIXELSIZE 4
349 
350 #define EXT_BGR_RED 2
351 #define EXT_BGR_GREEN 1
352 #define EXT_BGR_BLUE 0
353 #define EXT_BGR_PIXELSIZE 3
354 
355 #define EXT_BGRX_RED 2
356 #define EXT_BGRX_GREEN 1
357 #define EXT_BGRX_BLUE 0
358 #define EXT_BGRX_PIXELSIZE 4
359 
360 #define EXT_XBGR_RED 3
361 #define EXT_XBGR_GREEN 2
362 #define EXT_XBGR_BLUE 1
363 #define EXT_XBGR_PIXELSIZE 4
364 
365 #define EXT_XRGB_RED 1
366 #define EXT_XRGB_GREEN 2
367 #define EXT_XRGB_BLUE 3
368 #define EXT_XRGB_PIXELSIZE 4
369 
370 static const int rgb_red[JPEG_NUMCS] = {
371  -1, -1, RGB_RED, -1, -1, -1, EXT_RGB_RED, EXT_RGBX_RED,
372  EXT_BGR_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
373  EXT_RGBX_RED, EXT_BGRX_RED, EXT_XBGR_RED, EXT_XRGB_RED,
374  -1
375 };
376 
377 static const int rgb_green[JPEG_NUMCS] = {
378  -1, -1, RGB_GREEN, -1, -1, -1, EXT_RGB_GREEN, EXT_RGBX_GREEN,
379  EXT_BGR_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
380  EXT_RGBX_GREEN, EXT_BGRX_GREEN, EXT_XBGR_GREEN, EXT_XRGB_GREEN,
381  -1
382 };
383 
384 static const int rgb_blue[JPEG_NUMCS] = {
385  -1, -1, RGB_BLUE, -1, -1, -1, EXT_RGB_BLUE, EXT_RGBX_BLUE,
386  EXT_BGR_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
387  EXT_RGBX_BLUE, EXT_BGRX_BLUE, EXT_XBGR_BLUE, EXT_XRGB_BLUE,
388  -1
389 };
390 
391 static const int rgb_pixelsize[JPEG_NUMCS] = {
392  -1, -1, RGB_PIXELSIZE, -1, -1, -1, EXT_RGB_PIXELSIZE, EXT_RGBX_PIXELSIZE,
393  EXT_BGR_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
394  EXT_RGBX_PIXELSIZE, EXT_BGRX_PIXELSIZE, EXT_XBGR_PIXELSIZE, EXT_XRGB_PIXELSIZE,
395  -1
396 };
397 
398 /* Definitions for speed-related optimizations. */
399 
400 /* On some machines (notably 68000 series) "int" is 32 bits, but multiplying
401  * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER
402  * as short on such a machine. MULTIPLIER must be at least 16 bits wide.
403  */
404 
405 #ifndef MULTIPLIER
406 #ifndef WITH_SIMD
407 #define MULTIPLIER int /* type for fastest integer multiply */
408 #else
409 #define MULTIPLIER short /* prefer 16-bit with SIMD for parellelism */
410 #endif
411 #endif
412 
413 
414 /* FAST_FLOAT should be either float or double, whichever is done faster
415  * by your compiler. (Note that this type is only used in the floating point
416  * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.)
417  */
418 
419 #ifndef FAST_FLOAT
420 #define FAST_FLOAT float
421 #endif
422 
423 #endif /* JPEG_INTERNAL_OPTIONS */
UINT8
short UINT8
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:134
JSAMPLE
char JSAMPLE
Definition: sources/libs/nvll_batch_jpeg_encode/tegra/jmorecfg.h:79
JOCTET
char JOCTET
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:109
UINT16
unsigned int UINT16
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:143
JDIMENSION
unsigned int JDIMENSION
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:196
INT32
long INT32
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:181
INT16
short INT16
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:149
JCOEF
short JCOEF
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:93
boolean
int boolean
Definition: sources/libs/nvll_batch_jpeg_encode/oss/jmorecfg.h:244