1 module libjpeg.jmorecfg; 2 /* 3 * jmorecfg.h 4 * 5 * This file was part of the Independent JPEG Group's software: 6 * Copyright (C) 1991-1997, Thomas G. Lane. 7 * Modifications: 8 * Copyright (C) 2009, 2011, D. R. Commander. 9 * For conditions of distribution and use, see the accompanying README file. 10 * 11 * This file contains additional configuration options that customize the 12 * JPEG software for special applications or support machine-dependent 13 * optimizations. Most users will not need to touch this file. 14 */ 15 16 17 /* 18 * Define BITS_IN_JSAMPLE as either 19 * 8 for 8-bit sample values (the usual setting) 20 * 12 for 12-bit sample values 21 * Only 8 and 12 are legal data precisions for lossy JPEG according to the 22 * JPEG standard, and the IJG code does not support anything else! 23 * We do not support run-time selection of data precision, sorry. 24 */ 25 26 enum BITS_IN_JSAMPLE = 8; /* use 8 or 12 */ 27 28 29 /* 30 * Maximum number of components (color channels) allowed in JPEG image. 31 * To meet the letter of the JPEG spec, set this to 255. However, darn 32 * few applications need more than 4 channels (maybe 5 for CMYK + alpha 33 * mask). We recommend 10 as a reasonable compromise; use 4 if you are 34 * really short on memory. (Each allowed component costs a hundred or so 35 * bytes of storage, whether actually used in an image or not.) 36 */ 37 38 enum MAX_COMPONENTS = 10; /* maximum number of image components */ 39 40 41 /* 42 * Basic data types. 43 * You may need to change these if you have a machine with unusual data 44 * type sizes; for example, "char" not 8 bits, "short" not 16 bits, 45 * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, 46 * but it had better be at least 16. 47 */ 48 49 /* Representation of a single sample (pixel element value). 50 * We frequently allocate large arrays of these, so it's important to keep 51 * them small. But if you have memory to burn and access to char or short 52 * arrays is very slow on your hardware, you might want to change these. 53 */ 54 55 static if (BITS_IN_JSAMPLE == 8){ 56 /* JSAMPLE should be the smallest type that will hold the values 0..255. 57 * You can use a signed char by having GETJSAMPLE mask it with 0xFF. 58 */ 59 60 alias ubyte JSAMPLE; 61 auto GETJSAMPLE(JSAMPLE value) pure @safe nothrow { return cast(int)value; } 62 63 enum MAXJSAMPLE = 255; 64 enum CENTERJSAMPLE = 128; 65 66 } /* BITS_IN_JSAMPLE == 8 */ 67 68 69 static if (BITS_IN_JSAMPLE == 12){ 70 /* JSAMPLE should be the smallest type that will hold the values 0..4095. 71 * On nearly all machines "short" will do nicely. 72 */ 73 74 alias short JSAMPLE; 75 auto GETJSAMPLE(JSAMPLE value) pure @safe nothrow { return cast(int)value; } 76 77 enum MAXJSAMPLE = 4095; 78 enum CENTERJSAMPLE = 2048; 79 80 } /* BITS_IN_JSAMPLE == 12 */ 81 82 83 /* Representation of a DCT frequency coefficient. 84 * This should be a signed value of at least 16 bits; "short" is usually OK. 85 * Again, we allocate large arrays of these, but you can change to int 86 * if you have memory to burn and "short" is really slow. 87 */ 88 89 alias short JCOEF; 90 91 92 /* Compressed datastreams are represented as arrays of JOCTET. 93 * These must be EXACTLY 8 bits wide, at least once they are written to 94 * external storage. Note that when using the stdio data source/destination 95 * managers, this is also the data type passed to fread/fwrite. 96 */ 97 98 alias ubyte JOCTET; 99 auto GETJOCTET(JOCTET value) pure @safe nothrow { return value; } 100 101 102 /* These typedefs are used for various table entries and so forth. 103 * They must be at least as wide as specified; but making them too big 104 * won't cost a huge amount of memory, so we don't provide special 105 * extraction code like we did for JSAMPLE. (In other words, these 106 * typedefs live at a different point on the speed/space tradeoff curve.) 107 */ 108 109 /* UINT8 must hold at least the values 0..255. */ 110 111 alias ubyte UINT8; 112 113 /* UINT16 must hold at least the values 0..65535. */ 114 115 alias ushort UINT16; 116 117 /* INT16 must hold at least the values -32768..32767. */ 118 119 alias short INT16; 120 121 /* INT32 must hold at least signed 32-bit values. */ 122 123 alias int INT32; 124 125 /* Datatype used for image dimensions. The JPEG standard only supports 126 * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore 127 * "unsigned int" is sufficient on all machines. However, if you need to 128 * handle larger images and you don't mind deviating from the spec, you 129 * can change this datatype. 130 */ 131 132 alias uint JDIMENSION; 133 134 enum JPEG_MAX_DIMENSION = 65500L; /* a tad under 64K to prevent overflows */ 135 136 137 /* These macros are used in all function definitions and extern declarations. 138 * You could modify them if you need to change function linkage conventions; 139 * in particular, you'll need to do that to make the library a Windows DLL. 140 * Another application is to make all functions global for use with debuggers 141 * or code profilers that require it. 142 */ 143 144 145 /* This macro is used to declare a "method", that is, a function pointer. 146 * We want to supply prototype parameters if the compiler can cope. 147 * Note that the arglist parameter must be parenthesized! 148 * Again, you can customize this if you need special linkage keywords. 149 */ 150 151 152 153 /* Here is the pseudo-keyword for declaring pointers that must be "far" 154 * on 80x86 machines. Most of the specialized coding for 80x86 is handled 155 * by just saying "FAR *" where such a pointer is needed. In a few places 156 * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. 157 */ 158 159 160 161 /* 162 * On a few systems, type boolean and/or its values FALSE, TRUE may appear 163 * in standard header files. Or you may have conflicts with application- 164 * specific header files that you want to include together with these files. 165 * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. 166 */ 167 168 alias int boolean; 169 enum FALSE = 0; /* values of boolean */ 170 enum TRUE = 1; 171 172 173 /* 174 * The remaining options affect code selection within the JPEG library, 175 * but they don't need to be visible to most applications using the library. 176 * To minimize application namespace pollution, the symbols won't be 177 * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. 178 */ 179