Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

jidctred.c File Reference

#include "jinclude.h"
#include "jpeglib.h"
#include "jdct.h"

Go to the source code of this file.


Defines

#define JPEG_INTERNALS
#define CONST_BITS   13
#define PASS1_BITS   2
#define FIX_0_211164243   ((INT32) 1730)
#define FIX_0_509795579   ((INT32) 4176)
#define FIX_0_601344887   ((INT32) 4926)
#define FIX_0_720959822   ((INT32) 5906)
#define FIX_0_765366865   ((INT32) 6270)
#define FIX_0_850430095   ((INT32) 6967)
#define FIX_0_899976223   ((INT32) 7373)
#define FIX_1_061594337   ((INT32) 8697)
#define FIX_1_272758580   ((INT32) 10426)
#define FIX_1_451774981   ((INT32) 11893)
#define FIX_1_847759065   ((INT32) 15137)
#define FIX_2_172734803   ((INT32) 17799)
#define FIX_2_562915447   ((INT32) 20995)
#define FIX_3_624509785   ((INT32) 29692)
#define MULTIPLY(var, const)   MULTIPLY16C16(var,const)
#define DEQUANTIZE(coef, quantval)   (((ISLOW_MULT_TYPE) (coef)) * (quantval))

Functions

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

Define Documentation

#define CONST_BITS   13
 

Definition at line 43 of file jidctred.c.

Referenced by jpeg_idct_2x2(), and jpeg_idct_4x4().

#define DEQUANTIZE coef,
quantval       (((ISLOW_MULT_TYPE) (coef)) * (quantval))
 

Definition at line 109 of file jidctred.c.

#define FIX_0_211164243   ((INT32) 1730)
 

Definition at line 58 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_0_509795579   ((INT32) 4176)
 

Definition at line 59 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_0_601344887   ((INT32) 4926)
 

Definition at line 60 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_0_720959822   ((INT32) 5906)
 

Definition at line 61 of file jidctred.c.

Referenced by jpeg_idct_2x2().

#define FIX_0_765366865   ((INT32) 6270)
 

Definition at line 62 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_0_850430095   ((INT32) 6967)
 

Definition at line 63 of file jidctred.c.

Referenced by jpeg_idct_2x2().

#define FIX_0_899976223   ((INT32) 7373)
 

Definition at line 64 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_1_061594337   ((INT32) 8697)
 

Definition at line 65 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_1_272758580   ((INT32) 10426)
 

Definition at line 66 of file jidctred.c.

Referenced by jpeg_idct_2x2().

#define FIX_1_451774981   ((INT32) 11893)
 

Definition at line 67 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_1_847759065   ((INT32) 15137)
 

Definition at line 68 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_2_172734803   ((INT32) 17799)
 

Definition at line 69 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_2_562915447   ((INT32) 20995)
 

Definition at line 70 of file jidctred.c.

Referenced by jpeg_idct_4x4().

#define FIX_3_624509785   ((INT32) 29692)
 

Definition at line 71 of file jidctred.c.

Referenced by jpeg_idct_2x2().

#define JPEG_INTERNALS
 

Definition at line 23 of file jidctred.c.

#define MULTIPLY var,
const       MULTIPLY16C16(var,const)
 

Definition at line 98 of file jidctred.c.

#define PASS1_BITS   2
 

Definition at line 44 of file jidctred.c.

Referenced by jpeg_idct_2x2(), and jpeg_idct_4x4().


Function Documentation

jpeg_idct_1x1 j_decompress_ptr    cinfo,
jpeg_component_info   compptr,
JCOEFPTR    coef_block,
JSAMPARRAY    output_buf,
JDIMENSION    output_col
 

Definition at line 379 of file jidctred.c.

References coef_block, compptr, jpeg_component_info::dct_table, DEQUANTIZE, DESCALE, IDCT_range_limit, INT32, ISLOW_MULT_TYPE, JCOEFPTR, JDIMENSION, JSAMPARRAY, JSAMPLE, output_col, and RANGE_MASK.

Referenced by start_pass().

00382 {
00383   int dcval;
00384   ISLOW_MULT_TYPE * quantptr;
00385   JSAMPLE *range_limit = IDCT_range_limit(cinfo);
00386   SHIFT_TEMPS
00387 
00388   /* We hardly need an inverse DCT routine for this: just take the
00389    * average pixel value, which is one-eighth of the DC coefficient.
00390    */
00391   quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
00392   dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
00393   dcval = (int) DESCALE((INT32) dcval, 3);
00394 
00395   output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
00396 }

jpeg_idct_2x2 j_decompress_ptr    cinfo,
jpeg_component_info   compptr,
JCOEFPTR    coef_block,
JSAMPARRAY    output_buf,
JDIMENSION    output_col
 

Definition at line 271 of file jidctred.c.

References coef_block, compptr, CONST_BITS, jpeg_component_info::dct_table, DEQUANTIZE, DESCALE, FIX_0_720959822, FIX_0_850430095, FIX_1_272758580, FIX_3_624509785, IDCT_range_limit, INT32, ISLOW_MULT_TYPE, JCOEFPTR, JDIMENSION, JSAMPARRAY, JSAMPLE, JSAMPROW, MULTIPLY, output_col, PASS1_BITS, RANGE_MASK, and z1.

Referenced by start_pass().

00274 {
00275   INT32 tmp0, tmp10, z1;
00276   JCOEFPTR inptr;
00277   ISLOW_MULT_TYPE * quantptr;
00278   int * wsptr;
00279   JSAMPROW outptr;
00280   JSAMPLE *range_limit = IDCT_range_limit(cinfo);
00281   int ctr;
00282   int workspace[DCTSIZE*2];     /* buffers data between passes */
00283   SHIFT_TEMPS
00284 
00285   /* Pass 1: process columns from input, store into work array. */
00286 
00287   inptr = coef_block;
00288   quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
00289   wsptr = workspace;
00290   for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
00291     /* Don't bother to process columns 2,4,6 */
00292     if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
00293       continue;
00294     if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
00295         inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
00296       /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
00297       int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
00298       
00299       wsptr[DCTSIZE*0] = dcval;
00300       wsptr[DCTSIZE*1] = dcval;
00301       
00302       continue;
00303     }
00304     
00305     /* Even part */
00306     
00307     z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
00308     tmp10 = z1 << (CONST_BITS+2);
00309     
00310     /* Odd part */
00311 
00312     z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
00313     tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
00314     z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
00315     tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
00316     z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
00317     tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
00318     z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
00319     tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
00320 
00321     /* Final output stage */
00322     
00323     wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
00324     wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
00325   }
00326   
00327   /* Pass 2: process 2 rows from work array, store into output array. */
00328 
00329   wsptr = workspace;
00330   for (ctr = 0; ctr < 2; ctr++) {
00331     outptr = output_buf[ctr] + output_col;
00332     /* It's not clear whether a zero row test is worthwhile here ... */
00333 
00334 #ifndef NO_ZERO_ROW_TEST
00335     if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
00336       /* AC terms all zero */
00337       JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)
00338                                   & RANGE_MASK];
00339       
00340       outptr[0] = dcval;
00341       outptr[1] = dcval;
00342       
00343       wsptr += DCTSIZE;         /* advance pointer to next row */
00344       continue;
00345     }
00346 #endif
00347     
00348     /* Even part */
00349     
00350     tmp10 = ((INT32) wsptr[0]) << (CONST_BITS+2);
00351     
00352     /* Odd part */
00353 
00354     tmp0 = MULTIPLY((INT32) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
00355          + MULTIPLY((INT32) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
00356          + MULTIPLY((INT32) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
00357          + MULTIPLY((INT32) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
00358 
00359     /* Final output stage */
00360     
00361     outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
00362                                           CONST_BITS+PASS1_BITS+3+2)
00363                             & RANGE_MASK];
00364     outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
00365                                           CONST_BITS+PASS1_BITS+3+2)
00366                             & RANGE_MASK];
00367     
00368     wsptr += DCTSIZE;           /* advance pointer to next row */
00369   }
00370 }

jpeg_idct_4x4 j_decompress_ptr    cinfo,
jpeg_component_info   compptr,
JCOEFPTR    coef_block,
JSAMPARRAY    output_buf,
JDIMENSION    output_col
 

Definition at line 118 of file jidctred.c.

References coef_block, compptr, CONST_BITS, jpeg_component_info::dct_table, DEQUANTIZE, DESCALE, FIX_0_211164243, FIX_0_509795579, FIX_0_601344887, FIX_0_765366865, FIX_0_899976223, FIX_1_061594337, FIX_1_451774981, FIX_1_847759065, FIX_2_172734803, FIX_2_562915447, IDCT_range_limit, INT32, ISLOW_MULT_TYPE, JCOEFPTR, JDIMENSION, JSAMPARRAY, JSAMPLE, JSAMPROW, MULTIPLY, output_col, PASS1_BITS, RANGE_MASK, and z1.

Referenced by start_pass().

00121 {
00122   INT32 tmp0, tmp2, tmp10, tmp12;
00123   INT32 z1, z2, z3, z4;
00124   JCOEFPTR inptr;
00125   ISLOW_MULT_TYPE * quantptr;
00126   int * wsptr;
00127   JSAMPROW outptr;
00128   JSAMPLE *range_limit = IDCT_range_limit(cinfo);
00129   int ctr;
00130   int workspace[DCTSIZE*4];     /* buffers data between passes */
00131   SHIFT_TEMPS
00132 
00133   /* Pass 1: process columns from input, store into work array. */
00134 
00135   inptr = coef_block;
00136   quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
00137   wsptr = workspace;
00138   for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
00139     /* Don't bother to process column 4, because second pass won't use it */
00140     if (ctr == DCTSIZE-4)
00141       continue;
00142     if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
00143         inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
00144         inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
00145       /* AC terms all zero; we need not examine term 4 for 4x4 output */
00146       int dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]) << PASS1_BITS;
00147       
00148       wsptr[DCTSIZE*0] = dcval;
00149       wsptr[DCTSIZE*1] = dcval;
00150       wsptr[DCTSIZE*2] = dcval;
00151       wsptr[DCTSIZE*3] = dcval;
00152       
00153       continue;
00154     }
00155     
00156     /* Even part */
00157     
00158     tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
00159     tmp0 <<= (CONST_BITS+1);
00160     
00161     z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
00162     z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
00163 
00164     tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
00165     
00166     tmp10 = tmp0 + tmp2;
00167     tmp12 = tmp0 - tmp2;
00168     
00169     /* Odd part */
00170     
00171     z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
00172     z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
00173     z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
00174     z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
00175     
00176     tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
00177          + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
00178          + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
00179          + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
00180     
00181     tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
00182          + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
00183          + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
00184          + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
00185 
00186     /* Final output stage */
00187     
00188     wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
00189     wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
00190     wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
00191     wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
00192   }
00193   
00194   /* Pass 2: process 4 rows from work array, store into output array. */
00195 
00196   wsptr = workspace;
00197   for (ctr = 0; ctr < 4; ctr++) {
00198     outptr = output_buf[ctr] + output_col;
00199     /* It's not clear whether a zero row test is worthwhile here ... */
00200 
00201 #ifndef NO_ZERO_ROW_TEST
00202     if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
00203         wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
00204       /* AC terms all zero */
00205       JSAMPLE dcval = range_limit[(int) DESCALE((INT32) wsptr[0], PASS1_BITS+3)
00206                                   & RANGE_MASK];
00207       
00208       outptr[0] = dcval;
00209       outptr[1] = dcval;
00210       outptr[2] = dcval;
00211       outptr[3] = dcval;
00212       
00213       wsptr += DCTSIZE;         /* advance pointer to next row */
00214       continue;
00215     }
00216 #endif
00217     
00218     /* Even part */
00219     
00220     tmp0 = ((INT32) wsptr[0]) << (CONST_BITS+1);
00221     
00222     tmp2 = MULTIPLY((INT32) wsptr[2], FIX_1_847759065)
00223          + MULTIPLY((INT32) wsptr[6], - FIX_0_765366865);
00224     
00225     tmp10 = tmp0 + tmp2;
00226     tmp12 = tmp0 - tmp2;
00227     
00228     /* Odd part */
00229     
00230     z1 = (INT32) wsptr[7];
00231     z2 = (INT32) wsptr[5];
00232     z3 = (INT32) wsptr[3];
00233     z4 = (INT32) wsptr[1];
00234     
00235     tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
00236          + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
00237          + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
00238          + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
00239     
00240     tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
00241          + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
00242          + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
00243          + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
00244 
00245     /* Final output stage */
00246     
00247     outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
00248                                           CONST_BITS+PASS1_BITS+3+1)
00249                             & RANGE_MASK];
00250     outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
00251                                           CONST_BITS+PASS1_BITS+3+1)
00252                             & RANGE_MASK];
00253     outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
00254                                           CONST_BITS+PASS1_BITS+3+1)
00255                             & RANGE_MASK];
00256     outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
00257                                           CONST_BITS+PASS1_BITS+3+1)
00258                             & RANGE_MASK];
00259     
00260     wsptr += DCTSIZE;           /* advance pointer to next row */
00261   }
00262 }
 

Powered by Plone

This site conforms to the following standards: