COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
jidctred.cpp File Reference
#include "jinclude.h"
#include "jpeglib.h"
#include "jdct.h"
Include dependency graph for jidctred.cpp:

Macros

#define JPEG_INTERNALS
 
#define CONST_BITS   13
 
#define PASS1_BITS   2
 
#define FIX_0_211164243   ((int32_t) 1730) /* FIX(0.211164243) */
 
#define FIX_0_509795579   ((int32_t) 4176) /* FIX(0.509795579) */
 
#define FIX_0_601344887   ((int32_t) 4926) /* FIX(0.601344887) */
 
#define FIX_0_720959822   ((int32_t) 5906) /* FIX(0.720959822) */
 
#define FIX_0_765366865   ((int32_t) 6270) /* FIX(0.765366865) */
 
#define FIX_0_850430095   ((int32_t) 6967) /* FIX(0.850430095) */
 
#define FIX_0_899976223   ((int32_t) 7373) /* FIX(0.899976223) */
 
#define FIX_1_061594337   ((int32_t) 8697) /* FIX(1.061594337) */
 
#define FIX_1_272758580   ((int32_t) 10426) /* FIX(1.272758580) */
 
#define FIX_1_451774981   ((int32_t) 11893) /* FIX(1.451774981) */
 
#define FIX_1_847759065   ((int32_t) 15137) /* FIX(1.847759065) */
 
#define FIX_2_172734803   ((int32_t) 17799) /* FIX(2.172734803) */
 
#define FIX_2_562915447   ((int32_t) 20995) /* FIX(2.562915447) */
 
#define FIX_3_624509785   ((int32_t) 29692) /* FIX(3.624509785) */
 
#define MULTIPLY(var, const)   MULTIPLY16C16(var,const)
 
#define DEQUANTIZE(coef, quantval)   (((ISLOW_MULT_TYPE) (coef)) * (quantval))
 

Functions

void jpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)
 
void jpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)
 
void jpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col)
 

Macro Definition Documentation

#define JPEG_INTERNALS
#define CONST_BITS   13
#define PASS1_BITS   2
#define FIX_0_211164243   ((int32_t) 1730) /* FIX(0.211164243) */
#define FIX_0_509795579   ((int32_t) 4176) /* FIX(0.509795579) */
#define FIX_0_601344887   ((int32_t) 4926) /* FIX(0.601344887) */
#define FIX_0_720959822   ((int32_t) 5906) /* FIX(0.720959822) */
#define FIX_0_765366865   ((int32_t) 6270) /* FIX(0.765366865) */
#define FIX_0_850430095   ((int32_t) 6967) /* FIX(0.850430095) */
#define FIX_0_899976223   ((int32_t) 7373) /* FIX(0.899976223) */
#define FIX_1_061594337   ((int32_t) 8697) /* FIX(1.061594337) */
#define FIX_1_272758580   ((int32_t) 10426) /* FIX(1.272758580) */
#define FIX_1_451774981   ((int32_t) 11893) /* FIX(1.451774981) */
#define FIX_1_847759065   ((int32_t) 15137) /* FIX(1.847759065) */
#define FIX_2_172734803   ((int32_t) 17799) /* FIX(2.172734803) */
#define FIX_2_562915447   ((int32_t) 20995) /* FIX(2.562915447) */
#define FIX_3_624509785   ((int32_t) 29692) /* FIX(3.624509785) */
#define MULTIPLY (   var,
  const 
)    MULTIPLY16C16(var,const)
#define DEQUANTIZE (   coef,
  quantval 
)    (((ISLOW_MULT_TYPE) (coef)) * (quantval))

Function Documentation

void jpeg_idct_4x4 ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JCOEFPTR  coef_block,
JSAMPARRAY  output_buf,
JDIMENSION  output_col 
)
121 {
122  int32_t tmp0, tmp2, tmp10, tmp12;
123  int32_t z1, z2, z3, z4;
124  JCOEFPTR inptr;
125  ISLOW_MULT_TYPE * quantptr;
126  int * wsptr;
127  JSAMPROW outptr;
128  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
129  int ctr;
130  int workspace[DCTSIZE*4]; /* buffers data between passes */
132 
133  /* Pass 1: process columns from input, store into work array. */
134 
135  inptr = coef_block;
136  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
137  wsptr = workspace;
138  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
139  /* Don't bother to process column 4, because second pass won't use it */
140  if (ctr == DCTSIZE-4)
141  continue;
142  if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
143  inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
144  inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
145  /* AC terms all zero; we need not examine term 4 for 4x4 output */
146  int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
147 
148  wsptr[DCTSIZE*0] = dcval;
149  wsptr[DCTSIZE*1] = dcval;
150  wsptr[DCTSIZE*2] = dcval;
151  wsptr[DCTSIZE*3] = dcval;
152 
153  continue;
154  }
155 
156  /* Even part */
157 
158  tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
159  tmp0 <<= (CONST_BITS+1);
160 
161  z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
162  z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
163 
164  tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
165 
166  tmp10 = tmp0 + tmp2;
167  tmp12 = tmp0 - tmp2;
168 
169  /* Odd part */
170 
171  z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
172  z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
173  z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
174  z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
175 
176  tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
177  + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
178  + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
179  + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
180 
181  tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
182  + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
183  + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
184  + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
185 
186  /* Final output stage */
187 
188  wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
189  wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
190  wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
191  wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
192  }
193 
194  /* Pass 2: process 4 rows from work array, store into output array. */
195 
196  wsptr = workspace;
197  for (ctr = 0; ctr < 4; ctr++) {
198  outptr = output_buf[ctr] + output_col;
199  /* It's not clear whether a zero row test is worthwhile here ... */
200 
201 #ifndef NO_ZERO_ROW_TEST
202  if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
203  wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
204  /* AC terms all zero */
205  JSAMPLE dcval = range_limit[(int) DESCALE((int32_t) wsptr[0], PASS1_BITS+3)
206  & RANGE_MASK];
207 
208  outptr[0] = dcval;
209  outptr[1] = dcval;
210  outptr[2] = dcval;
211  outptr[3] = dcval;
212 
213  wsptr += DCTSIZE; /* advance pointer to next row */
214  continue;
215  }
216 #endif
217 
218  /* Even part */
219 
220  tmp0 = ((int32_t) wsptr[0]) << (CONST_BITS+1);
221 
222  tmp2 = MULTIPLY((int32_t) wsptr[2], FIX_1_847759065)
223  + MULTIPLY((int32_t) wsptr[6], - FIX_0_765366865);
224 
225  tmp10 = tmp0 + tmp2;
226  tmp12 = tmp0 - tmp2;
227 
228  /* Odd part */
229 
230  z1 = (int32_t) wsptr[7];
231  z2 = (int32_t) wsptr[5];
232  z3 = (int32_t) wsptr[3];
233  z4 = (int32_t) wsptr[1];
234 
235  tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
236  + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
237  + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
238  + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
239 
240  tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
241  + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
242  + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
243  + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
244 
245  /* Final output stage */
246 
247  outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
249  & RANGE_MASK];
250  outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
252  & RANGE_MASK];
253  outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
255  & RANGE_MASK];
256  outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
258  & RANGE_MASK];
259 
260  wsptr += DCTSIZE; /* advance pointer to next row */
261  }
262 }
#define DESCALE(x, n)
Definition: jdct.h:146
#define IDCT_range_limit(cinfo)
Definition: jdct.h:76
char JSAMPLE
Definition: jmorecfg.h:64
jpeg_component_info JCOEFPTR coef_block
Definition: jdct.h:102
void * dct_table
Definition: jpeglib.h:183
#define RANGE_MASK
Definition: jdct.h:78
#define FIX_0_211164243
Definition: jidctred.cpp:58
#define FIX_1_061594337
Definition: jidctred.cpp:65
#define SHIFT_TEMPS
Definition: jpegint.h:289
JSAMPLE * JSAMPROW
Definition: jpeglib.h:71
#define MULTIPLY(var, const)
Definition: jidctred.cpp:98
#define FIX_0_899976223
Definition: jidctred.cpp:64
#define FIX_0_765366865
Definition: jidctred.cpp:62
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
#define FIX_2_172734803
Definition: jidctred.cpp:69
#define CONST_BITS
Definition: jidctred.cpp:43
#define FIX_2_562915447
Definition: jidctred.cpp:70
MULTIPLIER ISLOW_MULT_TYPE
Definition: jdct.h:56
#define DEQUANTIZE(coef, quantval)
Definition: jidctred.cpp:109
JCOEF * JCOEFPTR
Definition: jpeglib.h:80
#define FIX_0_601344887
Definition: jidctred.cpp:60
#define FIX_0_509795579
Definition: jidctred.cpp:59
#define FIX_1_451774981
Definition: jidctred.cpp:67
#define DCTSIZE
Definition: jpeglib.h:46
#define FIX_1_847759065
Definition: jidctred.cpp:68
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102
#define PASS1_BITS
Definition: jidctred.cpp:44
void jpeg_idct_2x2 ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JCOEFPTR  coef_block,
JSAMPARRAY  output_buf,
JDIMENSION  output_col 
)
274 {
275  int32_t tmp0, tmp10, z1;
276  JCOEFPTR inptr;
277  ISLOW_MULT_TYPE * quantptr;
278  int * wsptr;
279  JSAMPROW outptr;
280  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
281  int ctr;
282  int workspace[DCTSIZE*2]; /* buffers data between passes */
284 
285  /* Pass 1: process columns from input, store into work array. */
286 
287  inptr = coef_block;
288  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
289  wsptr = workspace;
290  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
291  /* Don't bother to process columns 2,4,6 */
292  if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
293  continue;
294  if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
295  inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
296  /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
297  int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
298 
299  wsptr[DCTSIZE*0] = dcval;
300  wsptr[DCTSIZE*1] = dcval;
301 
302  continue;
303  }
304 
305  /* Even part */
306 
307  z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
308  tmp10 = z1 << (CONST_BITS+2);
309 
310  /* Odd part */
311 
312  z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
313  tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
314  z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
315  tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
316  z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
317  tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
318  z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
319  tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
320 
321  /* Final output stage */
322 
323  wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
324  wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
325  }
326 
327  /* Pass 2: process 2 rows from work array, store into output array. */
328 
329  wsptr = workspace;
330  for (ctr = 0; ctr < 2; ctr++) {
331  outptr = output_buf[ctr] + output_col;
332  /* It's not clear whether a zero row test is worthwhile here ... */
333 
334 #ifndef NO_ZERO_ROW_TEST
335  if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
336  /* AC terms all zero */
337  JSAMPLE dcval = range_limit[(int) DESCALE((int32_t) wsptr[0], PASS1_BITS+3)
338  & RANGE_MASK];
339 
340  outptr[0] = dcval;
341  outptr[1] = dcval;
342 
343  wsptr += DCTSIZE; /* advance pointer to next row */
344  continue;
345  }
346 #endif
347 
348  /* Even part */
349 
350  tmp10 = ((int32_t) wsptr[0]) << (CONST_BITS+2);
351 
352  /* Odd part */
353 
354  tmp0 = MULTIPLY((int32_t) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
355  + MULTIPLY((int32_t) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
356  + MULTIPLY((int32_t) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
357  + MULTIPLY((int32_t) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
358 
359  /* Final output stage */
360 
361  outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
363  & RANGE_MASK];
364  outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
366  & RANGE_MASK];
367 
368  wsptr += DCTSIZE; /* advance pointer to next row */
369  }
370 }
#define DESCALE(x, n)
Definition: jdct.h:146
#define IDCT_range_limit(cinfo)
Definition: jdct.h:76
char JSAMPLE
Definition: jmorecfg.h:64
#define FIX_0_850430095
Definition: jidctred.cpp:63
jpeg_component_info JCOEFPTR coef_block
Definition: jdct.h:102
void * dct_table
Definition: jpeglib.h:183
#define RANGE_MASK
Definition: jdct.h:78
#define FIX_1_272758580
Definition: jidctred.cpp:66
#define SHIFT_TEMPS
Definition: jpegint.h:289
JSAMPLE * JSAMPROW
Definition: jpeglib.h:71
#define MULTIPLY(var, const)
Definition: jidctred.cpp:98
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
#define CONST_BITS
Definition: jidctred.cpp:43
#define FIX_3_624509785
Definition: jidctred.cpp:71
MULTIPLIER ISLOW_MULT_TYPE
Definition: jdct.h:56
#define DEQUANTIZE(coef, quantval)
Definition: jidctred.cpp:109
JCOEF * JCOEFPTR
Definition: jpeglib.h:80
#define DCTSIZE
Definition: jpeglib.h:46
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102
#define PASS1_BITS
Definition: jidctred.cpp:44
#define FIX_0_720959822
Definition: jidctred.cpp:61
void jpeg_idct_1x1 ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JCOEFPTR  coef_block,
JSAMPARRAY  output_buf,
JDIMENSION  output_col 
)
382 {
383  int dcval;
384  ISLOW_MULT_TYPE * quantptr;
385  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
387 
388  /* We hardly need an inverse DCT routine for this: just take the
389  * average pixel value, which is one-eighth of the DC coefficient.
390  */
391  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
392  dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
393  dcval = (int) DESCALE((int32_t) dcval, 3);
394 
395  output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
396 }
#define DESCALE(x, n)
Definition: jdct.h:146
#define IDCT_range_limit(cinfo)
Definition: jdct.h:76
char JSAMPLE
Definition: jmorecfg.h:64
jpeg_component_info JCOEFPTR coef_block
Definition: jdct.h:102
void * dct_table
Definition: jpeglib.h:183
#define RANGE_MASK
Definition: jdct.h:78
#define SHIFT_TEMPS
Definition: jpegint.h:289
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
MULTIPLIER ISLOW_MULT_TYPE
Definition: jdct.h:56
#define DEQUANTIZE(coef, quantval)
Definition: jidctred.cpp:109
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102