Main MRPT website > C++ reference for MRPT 1.9.9
jdct.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2017, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 
10 /*
11  * A forward DCT routine is given a pointer to a work area of type DCTELEM[];
12  * the DCT is to be performed in-place in that buffer. Type DCTELEM is int
13  * for 8-bit samples, INT32 for 12-bit samples. (NOTE: Floating-point DCT
14  * implementations use an array of type FAST_FLOAT, instead.)
15  * The DCT inputs are expected to be signed (range +-CENTERJSAMPLE).
16  * The DCT outputs are returned scaled up by a factor of 8; they therefore
17  * have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
18  * convention improves accuracy in integer implementations and saves some
19  * work in floating-point ones.
20  * Quantization of the output coefficients is done by jcdctmgr.c.
21  */
22 
23 #if BITS_IN_JSAMPLE == 8
24 typedef int DCTELEM; /* 16 or 32 bits is fine */
25 #else
26 typedef INT32 DCTELEM; /* must have 32 bits */
27 #endif
28 
29 typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data));
30 typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data));
31 
32 /*
33  * An inverse DCT routine is given a pointer to the input JBLOCK and a pointer
34  * to an output sample array. The routine must dequantize the input data as
35  * well as perform the IDCT; for dequantization, it uses the multiplier table
36  * pointed to by compptr->dct_table. The output data is to be placed into the
37  * sample array starting at a specified column. (Any row offset needed will
38  * be applied to the array pointer before it is passed to the IDCT code.)
39  * Note that the number of samples emitted by the IDCT routine is
40  * DCT_scaled_size * DCT_scaled_size.
41  */
42 
43 /* typedef inverse_DCT_method_ptr is declared in jpegint.h */
44 
45 /*
46  * Each IDCT routine has its own ideas about the best dct_table element type.
47  */
48 
49 typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */
50 #if BITS_IN_JSAMPLE == 8
51 typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */
52 #define IFAST_SCALE_BITS 2 /* fractional bits in scale factors */
53 #else
54 typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */
55 #define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */
56 #endif
57 typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
58 
59 /*
60  * Each IDCT routine is responsible for range-limiting its results and
61  * converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
62  * be quite far out of range if the input data is corrupt, so a bulletproof
63  * range-limiting step is required. We use a mask-and-table-lookup method
64  * to do the combined operations quickly. See the comments with
65  * prepare_range_limit_table (in jdmaster.c) for more info.
66  */
67 
68 #define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit + CENTERJSAMPLE)
69 
70 #define RANGE_MASK (MAXJSAMPLE * 4 + 3) /* 2 bits wider than legal samples */
71 
72 /* Short forms of external names for systems with brain-damaged linkers. */
73 
74 #ifdef NEED_SHORT_EXTERNAL_NAMES
75 #define jpeg_fdct_islow jFDislow
76 #define jpeg_fdct_ifast jFDifast
77 #define jpeg_fdct_float jFDfloat
78 #define jpeg_idct_islow jRDislow
79 #define jpeg_idct_ifast jRDifast
80 #define jpeg_idct_float jRDfloat
81 #define jpeg_idct_4x4 jRD4x4
82 #define jpeg_idct_2x2 jRD2x2
83 #define jpeg_idct_1x1 jRD1x1
84 #endif /* NEED_SHORT_EXTERNAL_NAMES */
85 
86 /* Extern declarations for the forward and inverse DCT routines. */
87 
88 EXTERN(void) jpeg_fdct_islow JPP((DCTELEM * data));
89 EXTERN(void) jpeg_fdct_ifast JPP((DCTELEM * data));
90 EXTERN(void) jpeg_fdct_float JPP((FAST_FLOAT * data));
91 
92 EXTERN(void)
93 jpeg_idct_islow JPP(
96 EXTERN(void)
97 jpeg_idct_ifast JPP(
100 EXTERN(void)
101 jpeg_idct_float JPP(
104 EXTERN(void)
105 jpeg_idct_4x4 JPP(
108 EXTERN(void)
112 EXTERN(void)
116 
117 /*
118  * Macros for handling fixed-point arithmetic; these are used by many
119  * but not all of the DCT/IDCT modules.
120  *
121  * All values are expected to be of type INT32.
122  * Fractional constants are scaled left by CONST_BITS bits.
123  * CONST_BITS is defined within each module using these macros,
124  * and may differ from one module to the next.
125  */
126 
127 #define ONE ((INT32)1)
128 #define CONST_SCALE (ONE << CONST_BITS)
129 
130 /* Convert a positive real constant to an integer scaled by CONST_SCALE.
131  * Caution: some C compilers fail to reduce "FIX(constant)" at compile time,
132  * thus causing a lot of useless floating-point operations at run time.
133  */
134 
135 #define FIX(x) ((INT32)((x)*CONST_SCALE + 0.5))
136 
137 /* Descale and correctly round an INT32 value that's scaled by N bits.
138  * We assume RIGHT_SHIFT rounds towards minus infinity, so adding
139  * the fudge factor is correct for either sign of X.
140  */
141 
142 #define DESCALE(x, n) RIGHT_SHIFT((x) + (ONE << ((n)-1)), n)
143 
144 /* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
145  * This macro is used only when the two inputs will actually be no more than
146  * 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
147  * full 32x32 multiply. This provides a useful speedup on many machines.
148  * Unfortunately there is no way to specify a 16x16->32 multiply portably
149  * in C, but some C compilers will do the right thing if you provide the
150  * correct combination of casts.
151  */
152 
153 #ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
154 #define MULTIPLY16C16(var, const) (((INT16)(var)) * ((INT16)(const)))
155 #endif
156 #ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
157 #define MULTIPLY16C16(var, const) (((INT16)(var)) * ((INT32)(const)))
158 #endif
159 
160 #ifndef MULTIPLY16C16 /* default definition */
161 #define MULTIPLY16C16(var, const) ((var) * (const))
162 #endif
163 
164 /* Same except both inputs are variables. */
165 
166 #ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
167 #define MULTIPLY16V16(var1, var2) (((INT16)(var1)) * ((INT16)(var2)))
168 #endif
169 
170 #ifndef MULTIPLY16V16 /* default definition */
171 #define MULTIPLY16V16(var1, var2) ((var1) * (var2))
172 #endif
jpeg_idct_islow JPP((j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col))
typedef JMETHOD(void, forward_DCT_method_ptr,(DCTELEM *data))
jpeg_idct_2x2(j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)
Definition: jidctred.cpp:264
INT32 DCTELEM
Definition: jdct.h:26
long INT32
Definition: jmorecfg.h:151
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jidctflt.cpp:36
JSAMPROW * JSAMPARRAY
Definition: mrpt_jpeglib.h:61
JCOEF FAR * JCOEFPTR
Definition: mrpt_jpeglib.h:69
INT32 IFAST_MULT_TYPE
Definition: jdct.h:54
MULTIPLIER ISLOW_MULT_TYPE
Definition: jdct.h:49
FAST_FLOAT FLOAT_MULT_TYPE
Definition: jdct.h:57
EXTERN(void) jpeg_fdct_islow JPP((DCTELEM *data))
jpeg_idct_1x1(j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)
Definition: jidctred.cpp:390
unsigned int JDIMENSION
Definition: jmorecfg.h:161
jpeg_component_info JCOEFPTR coef_block
Definition: jidctflt.cpp:36
GLsizei GLsizei GLenum GLenum const GLvoid * data
Definition: glext.h:3546
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jidctflt.cpp:38
jpeg_component_info * compptr
Definition: jidctflt.cpp:36



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019