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

Macros

#define JPEG_INTERNALS
 
#define CONST_BITS   8
 
#define PASS1_BITS   2
 
#define FIX_1_082392200   ((int32_t) 277) /* FIX(1.082392200) */
 
#define FIX_1_414213562   ((int32_t) 362) /* FIX(1.414213562) */
 
#define FIX_1_847759065   ((int32_t) 473) /* FIX(1.847759065) */
 
#define FIX_2_613125930   ((int32_t) 669) /* FIX(2.613125930) */
 
#define DESCALE(x, n)   RIGHT_SHIFT(x, n)
 
#define MULTIPLY(var, const)   ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
 
#define DEQUANTIZE(coef, quantval)   (((IFAST_MULT_TYPE) (coef)) * (quantval))
 
#define ISHIFT_TEMPS
 
#define IRIGHT_SHIFT(x, shft)   ((x) >> (shft))
 
#define IDESCALE(x, n)   ((int) IRIGHT_SHIFT(x, n))
 

Functions

void jpeg_idct_ifast (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   8
#define PASS1_BITS   2
#define FIX_1_082392200   ((int32_t) 277) /* FIX(1.082392200) */
#define FIX_1_414213562   ((int32_t) 362) /* FIX(1.414213562) */
#define FIX_1_847759065   ((int32_t) 473) /* FIX(1.847759065) */
#define FIX_2_613125930   ((int32_t) 669) /* FIX(2.613125930) */
#define DESCALE (   x,
 
)    RIGHT_SHIFT(x, n)
#define MULTIPLY (   var,
  const 
)    ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
#define DEQUANTIZE (   coef,
  quantval 
)    (((IFAST_MULT_TYPE) (coef)) * (quantval))
#define ISHIFT_TEMPS
#define IRIGHT_SHIFT (   x,
  shft 
)    ((x) >> (shft))
#define IDESCALE (   x,
 
)    ((int) IRIGHT_SHIFT(x, n))

Function Documentation

void jpeg_idct_ifast ( j_decompress_ptr  cinfo,
jpeg_component_info compptr,
JCOEFPTR  coef_block,
JSAMPARRAY  output_buf,
JDIMENSION  output_col 
)
171 {
172  DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
173  DCTELEM tmp10, tmp11, tmp12, tmp13;
174  DCTELEM z5, z10, z11, z12, z13;
175  JCOEFPTR inptr;
176  IFAST_MULT_TYPE * quantptr;
177  int * wsptr;
178  JSAMPROW outptr;
179  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
180  int ctr;
181  int workspace[DCTSIZE2]; /* buffers data between passes */
182  SHIFT_TEMPS /* for DESCALE */
183  ISHIFT_TEMPS /* for IDESCALE */
184 
185  /* Pass 1: process columns from input, store into work array. */
186 
187  inptr = coef_block;
188  quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
189  wsptr = workspace;
190  for (ctr = DCTSIZE; ctr > 0; ctr--) {
191  /* Due to quantization, we will usually find that many of the input
192  * coefficients are zero, especially the AC terms. We can exploit this
193  * by short-circuiting the IDCT calculation for any column in which all
194  * the AC terms are zero. In that case each output is equal to the
195  * DC coefficient (with scale factor as needed).
196  * With typical images and quantization tables, half or more of the
197  * column DCT calculations can be simplified this way.
198  */
199 
200  if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
201  inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
202  inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
203  inptr[DCTSIZE*7] == 0) {
204  /* AC terms all zero */
205  int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
206 
207  wsptr[DCTSIZE*0] = dcval;
208  wsptr[DCTSIZE*1] = dcval;
209  wsptr[DCTSIZE*2] = dcval;
210  wsptr[DCTSIZE*3] = dcval;
211  wsptr[DCTSIZE*4] = dcval;
212  wsptr[DCTSIZE*5] = dcval;
213  wsptr[DCTSIZE*6] = dcval;
214  wsptr[DCTSIZE*7] = dcval;
215 
216  inptr++; /* advance pointers to next column */
217  quantptr++;
218  wsptr++;
219  continue;
220  }
221 
222  /* Even part */
223 
224  tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
225  tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
226  tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
227  tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
228 
229  tmp10 = tmp0 + tmp2; /* phase 3 */
230  tmp11 = tmp0 - tmp2;
231 
232  tmp13 = tmp1 + tmp3; /* phases 5-3 */
233  tmp12 = MULTIPLY(tmp1 - tmp3, FIX_1_414213562) - tmp13; /* 2*c4 */
234 
235  tmp0 = tmp10 + tmp13; /* phase 2 */
236  tmp3 = tmp10 - tmp13;
237  tmp1 = tmp11 + tmp12;
238  tmp2 = tmp11 - tmp12;
239 
240  /* Odd part */
241 
242  tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
243  tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
244  tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
245  tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
246 
247  z13 = tmp6 + tmp5; /* phase 6 */
248  z10 = tmp6 - tmp5;
249  z11 = tmp4 + tmp7;
250  z12 = tmp4 - tmp7;
251 
252  tmp7 = z11 + z13; /* phase 5 */
253  tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
254 
255  z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
256  tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
257  tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
258 
259  tmp6 = tmp12 - tmp7; /* phase 2 */
260  tmp5 = tmp11 - tmp6;
261  tmp4 = tmp10 + tmp5;
262 
263  wsptr[DCTSIZE*0] = (int) (tmp0 + tmp7);
264  wsptr[DCTSIZE*7] = (int) (tmp0 - tmp7);
265  wsptr[DCTSIZE*1] = (int) (tmp1 + tmp6);
266  wsptr[DCTSIZE*6] = (int) (tmp1 - tmp6);
267  wsptr[DCTSIZE*2] = (int) (tmp2 + tmp5);
268  wsptr[DCTSIZE*5] = (int) (tmp2 - tmp5);
269  wsptr[DCTSIZE*4] = (int) (tmp3 + tmp4);
270  wsptr[DCTSIZE*3] = (int) (tmp3 - tmp4);
271 
272  inptr++; /* advance pointers to next column */
273  quantptr++;
274  wsptr++;
275  }
276 
277  /* Pass 2: process rows from work array, store into output array. */
278  /* Note that we must descale the results by a factor of 8 == 2**3, */
279  /* and also undo the PASS1_BITS scaling. */
280 
281  wsptr = workspace;
282  for (ctr = 0; ctr < DCTSIZE; ctr++) {
283  outptr = output_buf[ctr] + output_col;
284  /* Rows of zeroes can be exploited in the same way as we did with columns.
285  * However, the column calculation has created many nonzero AC terms, so
286  * the simplification applies less often (typically 5% to 10% of the time).
287  * On machines with very fast multiplication, it's possible that the
288  * test takes more time than it's worth. In that case this section
289  * may be commented out.
290  */
291 
292 #ifndef NO_ZERO_ROW_TEST
293  if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 &&
294  wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
295  /* AC terms all zero */
296  JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3)
297  & RANGE_MASK];
298 
299  outptr[0] = dcval;
300  outptr[1] = dcval;
301  outptr[2] = dcval;
302  outptr[3] = dcval;
303  outptr[4] = dcval;
304  outptr[5] = dcval;
305  outptr[6] = dcval;
306  outptr[7] = dcval;
307 
308  wsptr += DCTSIZE; /* advance pointer to next row */
309  continue;
310  }
311 #endif
312 
313  /* Even part */
314 
315  tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
316  tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
317 
318  tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
319  tmp12 = MULTIPLY((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6], FIX_1_414213562)
320  - tmp13;
321 
322  tmp0 = tmp10 + tmp13;
323  tmp3 = tmp10 - tmp13;
324  tmp1 = tmp11 + tmp12;
325  tmp2 = tmp11 - tmp12;
326 
327  /* Odd part */
328 
329  z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];
330  z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];
331  z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
332  z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];
333 
334  tmp7 = z11 + z13; /* phase 5 */
335  tmp11 = MULTIPLY(z11 - z13, FIX_1_414213562); /* 2*c4 */
336 
337  z5 = MULTIPLY(z10 + z12, FIX_1_847759065); /* 2*c2 */
338  tmp10 = MULTIPLY(z12, FIX_1_082392200) - z5; /* 2*(c2-c6) */
339  tmp12 = MULTIPLY(z10, - FIX_2_613125930) + z5; /* -2*(c2+c6) */
340 
341  tmp6 = tmp12 - tmp7; /* phase 2 */
342  tmp5 = tmp11 - tmp6;
343  tmp4 = tmp10 + tmp5;
344 
345  /* Final output stage: scale down by a factor of 8 and range-limit */
346 
347  outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
348  & RANGE_MASK];
349  outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
350  & RANGE_MASK];
351  outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
352  & RANGE_MASK];
353  outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
354  & RANGE_MASK];
355  outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
356  & RANGE_MASK];
357  outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
358  & RANGE_MASK];
359  outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
360  & RANGE_MASK];
361  outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
362  & RANGE_MASK];
363 
364  wsptr += DCTSIZE; /* advance pointer to next row */
365  }
366 }
#define IDCT_range_limit(cinfo)
Definition: jdct.h:76
char JSAMPLE
Definition: jmorecfg.h:64
#define FIX_1_847759065
Definition: jidctfst.cpp:94
#define FIX_1_082392200
Definition: jidctfst.cpp:92
jpeg_component_info JCOEFPTR coef_block
Definition: jdct.h:102
#define ISHIFT_TEMPS
Definition: jidctfst.cpp:152
void * dct_table
Definition: jpeglib.h:183
#define RANGE_MASK
Definition: jdct.h:78
#define SHIFT_TEMPS
Definition: jpegint.h:289
JSAMPLE * JSAMPROW
Definition: jpeglib.h:71
int32_t IFAST_MULT_TYPE
Definition: jdct.h:61
jpeg_component_info JCOEFPTR JSAMPARRAY JDIMENSION output_col
Definition: jdct.h:102
#define DCTSIZE2
Definition: jpeglib.h:47
JCOEF * JCOEFPTR
Definition: jpeglib.h:80
#define IDESCALE(x, n)
Definition: jidctfst.cpp:159
#define FIX_2_613125930
Definition: jidctfst.cpp:95
#define FIX_1_414213562
Definition: jidctfst.cpp:93
int32_t DCTELEM
Definition: jdct.h:32
#define DCTSIZE
Definition: jpeglib.h:46
jpeg_component_info JCOEFPTR JSAMPARRAY output_buf
Definition: jdct.h:102
#define MULTIPLY(var, const)
Definition: jidctfst.cpp:119
#define PASS1_BITS
Definition: jidctfst.cpp:78
#define DEQUANTIZE(coef, quantval)
Definition: jidctfst.cpp:129