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



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 8277875f6 Mon Jun 11 02:47:32 2018 +0200 at lun oct 28 01:50:49 CET 2019