Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/jpeg/jdct.h
8666 views
1
/*
2
* jdct.h
3
*
4
* Copyright (C) 1994-1996, Thomas G. Lane.
5
* Modified 2002-2025 by Guido Vollbeding.
6
* This file is part of the Independent JPEG Group's software.
7
* For conditions of distribution and use, see the accompanying README file.
8
*
9
* This include file contains common declarations for the forward and
10
* inverse DCT modules. These declarations are private to the DCT managers
11
* (jcdctmgr.c, jddctmgr.c) and the individual DCT algorithms.
12
* The individual DCT algorithms are kept in separate files to ease
13
* machine-dependent tuning (e.g., assembly coding).
14
*/
15
16
17
/*
18
* A forward DCT routine is given a pointer to an input sample array and
19
* a pointer to a work area of type DCTELEM[]; the DCT is to be performed
20
* in-place in that buffer. Type DCTELEM is int or INT32, depending on
21
* bit depth parameters. (NOTE: Floating-point DCT implementations use
22
* an array of type FAST_FLOAT, instead.)
23
* The input data is to be fetched from the sample array starting at a
24
* specified column. (Any row offset needed will be applied to the array
25
* pointer before it is passed to the FDCT code.)
26
* Note that the number of samples fetched by the FDCT routine is
27
* DCT_h_scaled_size * DCT_v_scaled_size.
28
* The DCT outputs are returned scaled up by a factor of 8; they therefore
29
* have a range of +-8K for 8-bit data, +-128K for 12-bit data. This
30
* convention improves accuracy in integer implementations and saves some
31
* work in floating-point ones.
32
* Quantization of the output coefficients is done by jcdctmgr.c.
33
*/
34
35
/* Condition for FDCT:
36
* BITS_IN_JSAMPLE <= 10 && JPEG_DATA_PRECISION <= 10
37
* Condition for int IDCT where DCTELEM is used (2x2, 1x1, 2x1, 1x2):
38
* JPEG_DATA_PRECISION + RANGE_BITS <= 12
39
* [BITS_IN_JSAMPLE - 1 + RANGE_BITS +
40
* 3 - (BITS_IN_JSAMPLE - JPEG_DATA_PRECISION) <= 14]
41
* {3 - (BITS_IN_JSAMPLE - JPEG_DATA_PRECISION) = PASS2_BITS - PASS1_BITS}
42
* Condition for fast IDCT where DCTELEM is used:
43
* JPEG_DATA_PRECISION <= 10 && BITS_IN_JSAMPLE <= 13 && RANGE_BITS <= 2
44
* [BITS_IN_JSAMPLE - 1 + RANGE_BITS + PASS2BITS <= 14]
45
* Combined for all:
46
*/
47
48
#if BITS_IN_JSAMPLE <= 10 && JPEG_DATA_PRECISION <= 10 && RANGE_BITS <= 2
49
typedef int DCTELEM; /* 16 or 32 bits is fine */
50
#else
51
typedef INT32 DCTELEM; /* must have 32 bits */
52
#endif
53
54
typedef JMETHOD(void, forward_DCT_method_ptr, (DCTELEM * data,
55
JSAMPARRAY sample_data,
56
JDIMENSION start_col));
57
typedef JMETHOD(void, float_DCT_method_ptr, (FAST_FLOAT * data,
58
JSAMPARRAY sample_data,
59
JDIMENSION start_col));
60
61
62
/*
63
* An inverse DCT routine is given a pointer to the input JBLOCK and a pointer
64
* to an output sample array. The routine must dequantize the input data as
65
* well as perform the IDCT; for dequantization, it uses the multiplier table
66
* pointed to by compptr->dct_table. The output data is to be placed into the
67
* sample array starting at a specified column. (Any row offset needed will
68
* be applied to the array pointer before it is passed to the IDCT code.)
69
* Note that the number of samples emitted by the IDCT routine is
70
* DCT_h_scaled_size * DCT_v_scaled_size.
71
*/
72
73
/* typedef inverse_DCT_method_ptr is declared in jpegint.h */
74
75
/*
76
* Each IDCT routine has its own ideas about the best dct_table element type.
77
*/
78
79
typedef MULTIPLIER ISLOW_MULT_TYPE; /* short or int, whichever is faster */
80
#if JPEG_DATA_PRECISION <= 10 && BITS_IN_JSAMPLE <= 13
81
typedef MULTIPLIER IFAST_MULT_TYPE; /* 16 bits is OK, use short if faster */
82
#define IFAST_SCALE_BITS (10 - JPEG_DATA_PRECISION)
83
/* fractional bits in scale factors */
84
#else
85
typedef INT32 IFAST_MULT_TYPE; /* need 32 bits for scaled quantizers */
86
#define IFAST_SCALE_BITS 13 /* fractional bits in scale factors */
87
#endif
88
typedef FAST_FLOAT FLOAT_MULT_TYPE; /* preferred floating type */
89
90
91
/*
92
* Each IDCT routine is responsible for range-limiting its results and
93
* converting them to unsigned form (0..MAXJSAMPLE). The raw outputs could
94
* be quite far out of range if the input data is corrupt, so a bulletproof
95
* range-limiting step is required. We use a mask-and-table-lookup method
96
* to do the combined operations quickly, assuming that RANGE_CENTER
97
* (defined in jpegint.h) is a power of 2. See the comments with
98
* prepare_range_limit_table (in jdmaster.c) for more info.
99
*/
100
101
#define RANGE_MASK (RANGE_CENTER * 2 - 1)
102
#define RANGE_SUBSET (RANGE_CENTER - CENTERJSAMPLE)
103
104
#define IDCT_range_limit(cinfo) ((cinfo)->sample_range_limit - RANGE_SUBSET)
105
106
107
/* Short forms of external names for systems with brain-damaged linkers. */
108
109
#ifdef NEED_SHORT_EXTERNAL_NAMES
110
#define jpeg_fdct_islow jFDislow
111
#define jpeg_fdct_ifast jFDifast
112
#define jpeg_fdct_float jFDfloat
113
#define jpeg_fdct_7x7 jFD7x7
114
#define jpeg_fdct_6x6 jFD6x6
115
#define jpeg_fdct_5x5 jFD5x5
116
#define jpeg_fdct_4x4 jFD4x4
117
#define jpeg_fdct_3x3 jFD3x3
118
#define jpeg_fdct_2x2 jFD2x2
119
#define jpeg_fdct_1x1 jFD1x1
120
#define jpeg_fdct_9x9 jFD9x9
121
#define jpeg_fdct_10x10 jFD10x10
122
#define jpeg_fdct_11x11 jFD11x11
123
#define jpeg_fdct_12x12 jFD12x12
124
#define jpeg_fdct_13x13 jFD13x13
125
#define jpeg_fdct_14x14 jFD14x14
126
#define jpeg_fdct_15x15 jFD15x15
127
#define jpeg_fdct_16x16 jFD16x16
128
#define jpeg_fdct_16x8 jFD16x8
129
#define jpeg_fdct_14x7 jFD14x7
130
#define jpeg_fdct_12x6 jFD12x6
131
#define jpeg_fdct_10x5 jFD10x5
132
#define jpeg_fdct_8x4 jFD8x4
133
#define jpeg_fdct_6x3 jFD6x3
134
#define jpeg_fdct_4x2 jFD4x2
135
#define jpeg_fdct_2x1 jFD2x1
136
#define jpeg_fdct_8x16 jFD8x16
137
#define jpeg_fdct_7x14 jFD7x14
138
#define jpeg_fdct_6x12 jFD6x12
139
#define jpeg_fdct_5x10 jFD5x10
140
#define jpeg_fdct_4x8 jFD4x8
141
#define jpeg_fdct_3x6 jFD3x6
142
#define jpeg_fdct_2x4 jFD2x4
143
#define jpeg_fdct_1x2 jFD1x2
144
#define jpeg_idct_islow jRDislow
145
#define jpeg_idct_ifast jRDifast
146
#define jpeg_idct_float jRDfloat
147
#define jpeg_idct_7x7 jRD7x7
148
#define jpeg_idct_6x6 jRD6x6
149
#define jpeg_idct_5x5 jRD5x5
150
#define jpeg_idct_4x4 jRD4x4
151
#define jpeg_idct_3x3 jRD3x3
152
#define jpeg_idct_2x2 jRD2x2
153
#define jpeg_idct_1x1 jRD1x1
154
#define jpeg_idct_9x9 jRD9x9
155
#define jpeg_idct_10x10 jRD10x10
156
#define jpeg_idct_11x11 jRD11x11
157
#define jpeg_idct_12x12 jRD12x12
158
#define jpeg_idct_13x13 jRD13x13
159
#define jpeg_idct_14x14 jRD14x14
160
#define jpeg_idct_15x15 jRD15x15
161
#define jpeg_idct_16x16 jRD16x16
162
#define jpeg_idct_16x8 jRD16x8
163
#define jpeg_idct_14x7 jRD14x7
164
#define jpeg_idct_12x6 jRD12x6
165
#define jpeg_idct_10x5 jRD10x5
166
#define jpeg_idct_8x4 jRD8x4
167
#define jpeg_idct_6x3 jRD6x3
168
#define jpeg_idct_4x2 jRD4x2
169
#define jpeg_idct_2x1 jRD2x1
170
#define jpeg_idct_8x16 jRD8x16
171
#define jpeg_idct_7x14 jRD7x14
172
#define jpeg_idct_6x12 jRD6x12
173
#define jpeg_idct_5x10 jRD5x10
174
#define jpeg_idct_4x8 jRD4x8
175
#define jpeg_idct_3x6 jRD3x6
176
#define jpeg_idct_2x4 jRD2x4
177
#define jpeg_idct_1x2 jRD1x2
178
#endif /* NEED_SHORT_EXTERNAL_NAMES */
179
180
/* Extern declarations for the forward and inverse DCT routines. */
181
182
EXTERN(void) jpeg_fdct_islow
183
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
184
EXTERN(void) jpeg_fdct_ifast
185
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
186
EXTERN(void) jpeg_fdct_float
187
JPP((FAST_FLOAT * data, JSAMPARRAY sample_data, JDIMENSION start_col));
188
EXTERN(void) jpeg_fdct_7x7
189
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
190
EXTERN(void) jpeg_fdct_6x6
191
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
192
EXTERN(void) jpeg_fdct_5x5
193
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
194
EXTERN(void) jpeg_fdct_4x4
195
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
196
EXTERN(void) jpeg_fdct_3x3
197
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
198
EXTERN(void) jpeg_fdct_2x2
199
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
200
EXTERN(void) jpeg_fdct_1x1
201
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
202
EXTERN(void) jpeg_fdct_9x9
203
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
204
EXTERN(void) jpeg_fdct_10x10
205
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
206
EXTERN(void) jpeg_fdct_11x11
207
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
208
EXTERN(void) jpeg_fdct_12x12
209
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
210
EXTERN(void) jpeg_fdct_13x13
211
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
212
EXTERN(void) jpeg_fdct_14x14
213
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
214
EXTERN(void) jpeg_fdct_15x15
215
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
216
EXTERN(void) jpeg_fdct_16x16
217
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
218
EXTERN(void) jpeg_fdct_16x8
219
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
220
EXTERN(void) jpeg_fdct_14x7
221
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
222
EXTERN(void) jpeg_fdct_12x6
223
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
224
EXTERN(void) jpeg_fdct_10x5
225
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
226
EXTERN(void) jpeg_fdct_8x4
227
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
228
EXTERN(void) jpeg_fdct_6x3
229
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
230
EXTERN(void) jpeg_fdct_4x2
231
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
232
EXTERN(void) jpeg_fdct_2x1
233
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
234
EXTERN(void) jpeg_fdct_8x16
235
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
236
EXTERN(void) jpeg_fdct_7x14
237
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
238
EXTERN(void) jpeg_fdct_6x12
239
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
240
EXTERN(void) jpeg_fdct_5x10
241
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
242
EXTERN(void) jpeg_fdct_4x8
243
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
244
EXTERN(void) jpeg_fdct_3x6
245
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
246
EXTERN(void) jpeg_fdct_2x4
247
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
248
EXTERN(void) jpeg_fdct_1x2
249
JPP((DCTELEM * data, JSAMPARRAY sample_data, JDIMENSION start_col));
250
251
EXTERN(void) jpeg_idct_islow
252
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
253
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
254
EXTERN(void) jpeg_idct_ifast
255
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
256
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
257
EXTERN(void) jpeg_idct_float
258
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
259
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
260
EXTERN(void) jpeg_idct_7x7
261
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
262
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
263
EXTERN(void) jpeg_idct_6x6
264
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
265
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
266
EXTERN(void) jpeg_idct_5x5
267
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
268
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
269
EXTERN(void) jpeg_idct_4x4
270
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
271
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
272
EXTERN(void) jpeg_idct_3x3
273
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
274
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
275
EXTERN(void) jpeg_idct_2x2
276
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
277
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
278
EXTERN(void) jpeg_idct_1x1
279
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
280
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
281
EXTERN(void) jpeg_idct_9x9
282
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
283
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
284
EXTERN(void) jpeg_idct_10x10
285
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
286
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
287
EXTERN(void) jpeg_idct_11x11
288
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
289
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
290
EXTERN(void) jpeg_idct_12x12
291
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
292
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
293
EXTERN(void) jpeg_idct_13x13
294
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
295
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
296
EXTERN(void) jpeg_idct_14x14
297
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
298
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
299
EXTERN(void) jpeg_idct_15x15
300
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
301
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
302
EXTERN(void) jpeg_idct_16x16
303
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
304
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
305
EXTERN(void) jpeg_idct_16x8
306
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
307
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
308
EXTERN(void) jpeg_idct_14x7
309
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
310
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
311
EXTERN(void) jpeg_idct_12x6
312
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
313
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
314
EXTERN(void) jpeg_idct_10x5
315
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
316
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
317
EXTERN(void) jpeg_idct_8x4
318
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
319
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
320
EXTERN(void) jpeg_idct_6x3
321
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
322
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
323
EXTERN(void) jpeg_idct_4x2
324
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
325
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
326
EXTERN(void) jpeg_idct_2x1
327
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
328
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
329
EXTERN(void) jpeg_idct_8x16
330
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
331
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
332
EXTERN(void) jpeg_idct_7x14
333
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
334
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
335
EXTERN(void) jpeg_idct_6x12
336
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
337
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
338
EXTERN(void) jpeg_idct_5x10
339
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
340
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
341
EXTERN(void) jpeg_idct_4x8
342
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
343
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
344
EXTERN(void) jpeg_idct_3x6
345
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
346
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
347
EXTERN(void) jpeg_idct_2x4
348
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
349
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
350
EXTERN(void) jpeg_idct_1x2
351
JPP((j_decompress_ptr cinfo, jpeg_component_info * compptr,
352
JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col));
353
354
355
/*
356
* Macros for handling fixed-point arithmetic; these are used by many
357
* but not all of the DCT/IDCT modules.
358
*
359
* All values are expected to be of type INT32.
360
* Fractional constants are scaled left by CONST_BITS bits.
361
* CONST_BITS is defined within each module using these macros,
362
* and may differ from one module to the next.
363
*/
364
365
#define ONE ((INT32) 1)
366
#define CONST_SCALE (ONE << CONST_BITS)
367
368
/* Convert a positive real constant to an integer scaled by CONST_SCALE.
369
* Caution: some C compilers fail to reduce "FIX(constant)" at compile time,
370
* thus causing a lot of useless floating-point operations at run time.
371
*/
372
373
#define FIX(x) ((INT32) ((x) * CONST_SCALE + 0.5))
374
375
/* Multiply an INT32 variable by an INT32 constant to yield an INT32 result.
376
* This macro is used only when the two inputs will actually be no more than
377
* 16 bits wide, so that a 16x16->32 bit multiply can be used instead of a
378
* full 32x32 multiply. This provides a useful speedup on many machines.
379
* Unfortunately there is no way to specify a 16x16->32 multiply portably
380
* in C, but some C compilers will do the right thing if you provide the
381
* correct combination of casts.
382
*/
383
384
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
385
#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT16) (const)))
386
#endif
387
#ifdef SHORTxLCONST_32 /* known to work with Microsoft C 6.0 */
388
#define MULTIPLY16C16(var,const) (((INT16) (var)) * ((INT32) (const)))
389
#endif
390
391
#ifndef MULTIPLY16C16 /* default definition */
392
#define MULTIPLY16C16(var,const) ((var) * (const))
393
#endif
394
395
/* Same except both inputs are variables. */
396
397
#ifdef SHORTxSHORT_32 /* may work if 'int' is 32 bits */
398
#define MULTIPLY16V16(var1,var2) (((INT16) (var1)) * ((INT16) (var2)))
399
#endif
400
401
#ifndef MULTIPLY16V16 /* default definition */
402
#define MULTIPLY16V16(var1,var2) ((var1) * (var2))
403
#endif
404
405
/* Like RIGHT_SHIFT, but applies to a DCTELEM.
406
* We assume that int right shift is unsigned if INT32 right shift is.
407
*/
408
409
#ifdef RIGHT_SHIFT_IS_UNSIGNED
410
#define ISHIFT_TEMPS DCTELEM ishift_temp;
411
#if BITS_IN_JSAMPLE <= 10 && JPEG_DATA_PRECISION <= 10 && RANGE_BITS <= 2
412
#define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
413
#else
414
#define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
415
#endif
416
#define IRIGHT_SHIFT(x,shft) \
417
((ishift_temp = (x)) < 0 ? \
418
(ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
419
(ishift_temp >> (shft)))
420
#else
421
#define ISHIFT_TEMPS
422
#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
423
#endif
424
425