xref: /utopia/UTPA2-700.0.x/modules/ojpd_vdec_v1/api/jpeg/cmodel/src/jidctfst.c (revision 53ee8cc121a030b8d368113ac3e966b4705770ef)
1 //<MStar Software>
2 //******************************************************************************
3 // MStar Software
4 // Copyright (c) 2010 - 2012 MStar Semiconductor, Inc. All rights reserved.
5 // All software, firmware and related documentation herein ("MStar Software") are
6 // intellectual property of MStar Semiconductor, Inc. ("MStar") and protected by
7 // law, including, but not limited to, copyright law and international treaties.
8 // Any use, modification, reproduction, retransmission, or republication of all
9 // or part of MStar Software is expressly prohibited, unless prior written
10 // permission has been granted by MStar.
11 //
12 // By accessing, browsing and/or using MStar Software, you acknowledge that you
13 // have read, understood, and agree, to be bound by below terms ("Terms") and to
14 // comply with all applicable laws and regulations:
15 //
16 // 1. MStar shall retain any and all right, ownership and interest to MStar
17 //    Software and any modification/derivatives thereof.
18 //    No right, ownership, or interest to MStar Software and any
19 //    modification/derivatives thereof is transferred to you under Terms.
20 //
21 // 2. You understand that MStar Software might include, incorporate or be
22 //    supplied together with third party`s software and the use of MStar
23 //    Software may require additional licenses from third parties.
24 //    Therefore, you hereby agree it is your sole responsibility to separately
25 //    obtain any and all third party right and license necessary for your use of
26 //    such third party`s software.
27 //
28 // 3. MStar Software and any modification/derivatives thereof shall be deemed as
29 //    MStar`s confidential information and you agree to keep MStar`s
30 //    confidential information in strictest confidence and not disclose to any
31 //    third party.
32 //
33 // 4. MStar Software is provided on an "AS IS" basis without warranties of any
34 //    kind. Any warranties are hereby expressly disclaimed by MStar, including
35 //    without limitation, any warranties of merchantability, non-infringement of
36 //    intellectual property rights, fitness for a particular purpose, error free
37 //    and in conformity with any international standard.  You agree to waive any
38 //    claim against MStar for any loss, damage, cost or expense that you may
39 //    incur related to your use of MStar Software.
40 //    In no event shall MStar be liable for any direct, indirect, incidental or
41 //    consequential damages, including without limitation, lost of profit or
42 //    revenues, lost or damage of data, and unauthorized system use.
43 //    You agree that this Section 4 shall still apply without being affected
44 //    even if MStar Software has been modified by MStar in accordance with your
45 //    request or instruction for your use, except otherwise agreed by both
46 //    parties in writing.
47 //
48 // 5. If requested, MStar may from time to time provide technical supports or
49 //    services in relation with MStar Software to you for your use of
50 //    MStar Software in conjunction with your or your customer`s product
51 //    ("Services").
52 //    You understand and agree that, except otherwise agreed by both parties in
53 //    writing, Services are provided on an "AS IS" basis and the warranty
54 //    disclaimer set forth in Section 4 above shall apply.
55 //
56 // 6. Nothing contained herein shall be construed as by implication, estoppels
57 //    or otherwise:
58 //    (a) conferring any license or right to use MStar name, trademark, service
59 //        mark, symbol or any other identification;
60 //    (b) obligating MStar or any of its affiliates to furnish any person,
61 //        including without limitation, you and your customers, any assistance
62 //        of any kind whatsoever, or any information; or
63 //    (c) conferring any license or right under any intellectual property right.
64 //
65 // 7. These terms shall be governed by and construed in accordance with the laws
66 //    of Taiwan, R.O.C., excluding its conflict of law rules.
67 //    Any and all dispute arising out hereof or related hereto shall be finally
68 //    settled by arbitration referred to the Chinese Arbitration Association,
69 //    Taipei in accordance with the ROC Arbitration Law and the Arbitration
70 //    Rules of the Association by three (3) arbitrators appointed in accordance
71 //    with the said Rules.
72 //    The place of arbitration shall be in Taipei, Taiwan and the language shall
73 //    be English.
74 //    The arbitration award shall be final and binding to both parties.
75 //
76 //******************************************************************************
77 //<MStar Software>
78 /*
79  * jidctfst.c
80  *
81  * Copyright (C) 1994-1998, Thomas G. Lane.
82  * This file is part of the Independent JPEG Group's software.
83  * For conditions of distribution and use, see the accompanying README file.
84  *
85  * This file contains a fast, not so accurate integer implementation of the
86  * inverse DCT (Discrete Cosine Transform).  In the IJG code, this routine
87  * must also perform dequantization of the input coefficients.
88  *
89  * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
90  * on each row (or vice versa, but it's more convenient to emit a row at
91  * a time).  Direct algorithms are also available, but they are much more
92  * complex and seem not to be any faster when reduced to code.
93  *
94  * This implementation is based on Arai, Agui, and Nakajima's algorithm for
95  * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in
96  * Japanese, but the algorithm is described in the Pennebaker & Mitchell
97  * JPEG textbook (see REFERENCES section in file README).  The following code
98  * is based directly on figure 4-8 in P&M.
99  * While an 8-point DCT cannot be done in less than 11 multiplies, it is
100  * possible to arrange the computation so that many of the multiplies are
101  * simple scalings of the final outputs.  These multiplies can then be
102  * folded into the multiplications or divisions by the JPEG quantization
103  * table entries.  The AA&N method leaves only 5 multiplies and 29 adds
104  * to be done in the DCT itself.
105  * The primary disadvantage of this method is that with fixed-point math,
106  * accuracy is lost due to imprecise representation of the scaled
107  * quantization values.  The smaller the quantization table entry, the less
108  * precise the scaled value, so this implementation does worse with high-
109  * quality-setting files than with low-quality ones.
110  */
111 
112 ///#define JPEG_INTERNALS
113 ///#include "jinclude.h"
114 ///#include "jpeglib.h"
115 ///#include "jdct.h"        /* Private declarations for DCT subsystem */
116 #include "jpegmain.h"
117 #include "apiJPEG.h"
118 
119 #define DCTSIZE 8
120 #define BITS_IN_JSAMPLE 8
121 #define DCT_IFAST_SUPPORTED
122 
123 #ifdef DCT_IFAST_SUPPORTED
124 
125 /*
126  * This module is specialized to the case DCTSIZE = 8.
127  */
128 
129 #if DCTSIZE != 8
130 Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
131 #endif
132 
133 
134 /* Scaling decisions are generally the same as in the LL&M algorithm;
135  * see jidctint.c for more details.  However, we choose to descale
136  * (right shift) multiplication products as soon as they are formed,
137  * rather than carrying additional fractional bits into subsequent additions.
138  * This compromises accuracy slightly, but it lets us save a few shifts.
139  * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
140  * everywhere except in the multiplications proper; this saves a good deal
141  * of work on 16-bit-int machines.
142  *
143  * The dequantized coefficients are not integers because the AA&N scaling
144  * factors have been incorporated.  We represent them scaled up by PASS1_BITS,
145  * so that the first and second IDCT rounds have the same input scaling.
146  * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to
147  * avoid a descaling shift; this compromises accuracy rather drastically
148  * for small quantization table entries, but it saves a lot of shifts.
149  * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway,
150  * so we use a much larger scaling factor to preserve accuracy.
151  *
152  * A final compromise is to represent the multiplicative constants to only
153  * 8 fractional bits, rather than 13.  This saves some shifting work on some
154  * machines, and may also reduce the cost of multiplication (since there
155  * are fewer one-bits in the constants).
156  */
157 
158 #if BITS_IN_JSAMPLE == 8
159 #define CONST_BITS  8
160 #define PASS1_BITS  2
161 #else
162 #define CONST_BITS  8
163 #define PASS1_BITS  1       /* lose a little precision to avoid overflow */
164 #endif
165 
166 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
167  * causing a lot of useless floating-point operations at run time.
168  * To get around this we use the following pre-calculated constants.
169  * If you change CONST_BITS you may want to add appropriate values.
170  * (With a reasonable C compiler, you can just rely on the FIX() macro...)
171  */
172 
173 #if CONST_BITS == 8
174 #define FIX_1_082392200  ((INT32)  277)     /* FIX(1.082392200) */
175 #define FIX_1_414213562  ((INT32)  362)     /* FIX(1.414213562) */
176 #define FIX_1_847759065  ((INT32)  473)     /* FIX(1.847759065) */
177 #define FIX_2_613125930  ((INT32)  669)     /* FIX(2.613125930) */
178 #else
179 #define FIX_1_082392200  FIX(1.082392200)
180 #define FIX_1_414213562  FIX(1.414213562)
181 #define FIX_1_847759065  FIX(1.847759065)
182 #define FIX_2_613125930  FIX(2.613125930)
183 #endif
184 
185 
186 /* We can gain a little more speed, with a further compromise in accuracy,
187  * by omitting the addition in a descaling shift.  This yields an incorrectly
188  * rounded result half the time...
189  */
190 
191 #ifndef USE_ACCURATE_ROUNDING
192 #undef DESCALE
193 //#define DESCALE(x,n)  RIGHT_SHIFT(x, n)
194 #define DESCALE(x,n)  ((x) >> (n)) //=> speed a little with a compromise in accuracy
195 //#define DESCALE(x,n)  (((x) + ( ((int32)1) << ((n)-1))) >> (n))  //
196 #endif
197 
198 
199 /* Multiply a DCTELEM variable by an INT32 constant, and immediately
200  * descale to yield a DCTELEM result.
201  */
202 
203 typedef int DCTELEM;        /* 16 or 32 bits is fine */
204 #define MULTIPLY(var,cnst)  ((DCTELEM) DESCALE((var) * (cnst), CONST_BITS))
205 
206 
207 /* Dequantize a coefficient by multiplying it by the multiplier-table
208  * entry; produce a DCTELEM result.  For 8-bit data a 16x16->16
209  * multiplication will do.  For 12-bit data, the multiplier table is
210  * declared INT32, so a 32-bit multiply will be used.
211  */
212 
213 #if BITS_IN_JSAMPLE == 8
214 //#define DEQUANTIZE(coef,quantval)  (((IFAST_MULT_TYPE) (coef)) * (quantval))
215 #define DEQUANTIZE(coef,quantval)  (coef)
216 #else
217 #define DEQUANTIZE(coef,quantval)  \
218     DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)
219 #endif
220 
221 
222 /* Like DESCALE, but applies to a DCTELEM and produces an int.
223  * We assume that int right shift is unsigned if INT32 right shift is.
224  */
225 
226 #ifdef RIGHT_SHIFT_IS_UNSIGNED
227 #define ISHIFT_TEMPS    DCTELEM ishift_temp;
228 #if BITS_IN_JSAMPLE == 8
229 #define DCTELEMBITS  16     /* DCTELEM may be 16 or 32 bits */
230 #else
231 #define DCTELEMBITS  32     /* DCTELEM must be 32 bits */
232 #endif
233 #define IRIGHT_SHIFT(x,shft)  \
234     ((ishift_temp = (x)) < 0 ? \
235      (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
236      (ishift_temp >> (shft)))
237 #else
238 #define ISHIFT_TEMPS
239 #define IRIGHT_SHIFT(x,shft)    ((x) >> (shft))
240 #endif
241 
242 #if 1///def USE_ACCURATE_ROUNDING
243 #define IDESCALE(x,n)  ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))
244 //#define IDESCALE(x,n)  ( ( (int)(x) + (1 << ((n)-1)) ) >> (n) )
245 #else
246 #define IDESCALE(x,n)  ((int) IRIGHT_SHIFT(x, n))
247 #endif
248 
249 #define IFAST_MULT_TYPE int
250 
251 #define clamp(i) if (i & 0xFF00) i = (((~i) >> 15) & 0xFF);
252 
253 /*
254  * Perform dequantization and inverse DCT on one block of coefficients.
255  */
256 
257 ///GLOBAL(void)
258 ///jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
259 ///      JCOEFPTR coef_block,
260 ///      JSAMPARRAY output_buf, JDIMENSION output_col)
jpeg_idct_ifast(JPEG_BLOCK_TYPE * data,U8 * Pdst_ptr)261 void jpeg_idct_ifast( JPEG_BLOCK_TYPE *data, U8 *Pdst_ptr )
262 {
263     #define INT32   S32
264     #define DCTSIZE2 64
265     #define DCTSIZE 8
266 
267     DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
268     DCTELEM tmp10, tmp11, tmp12, tmp13;
269     DCTELEM z5, z10, z11, z12, z13;
270     ///JCOEFPTR inptr;
271     register JPEG_BLOCK_TYPE *inptr;
272     IFAST_MULT_TYPE *quantptr;
273     ///JSAMPROW outptr;
274     U8 *outptr = Pdst_ptr;
275     ///JSAMPLE *range_limit = IDCT_range_limit(cinfo);
276     int ctr;
277     ///int workspace[DCTSIZE2]; /* buffers data between passes */
278     JPEG_BLOCK_TYPE workspace[DCTSIZE2];
279     JPEG_BLOCK_TYPE *wsptr;
280     ///SHIFT_TEMPS          /* for DESCALE */
281     ///ISHIFT_TEMPS         /* for IDESCALE */
282     S16 i;
283 //printf("jidctfst::jpeg_idct_ifast\n");
284     /* Pass 1: process columns from input, store into work array. */
285 
286     inptr = data;
287     ///quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
288     wsptr = workspace;
289     for ( ctr = DCTSIZE; ctr > 0; ctr-- )
290     {
291         /* Due to quantization, we will usually find that many of the input
292          * coefficients are zero, especially the AC terms.  We can exploit this
293          * by short-circuiting the IDCT calculation for any column in which all
294          * the AC terms are zero.  In that case each output is equal to the
295          * DC coefficient (with scale factor as needed).
296          * With typical images and quantization tables, half or more of the
297          * column DCT calculations can be simplified this way.
298          */
299 
300         if ( inptr[DCTSIZE * 1] == 0 && inptr[DCTSIZE * 2] == 0 && inptr[DCTSIZE * 3] == 0 && inptr[DCTSIZE * 4] == 0 && inptr[DCTSIZE * 5] == 0 && inptr[DCTSIZE * 6] == 0 && inptr[DCTSIZE * 7] == 0 )
301         {
302             /* AC terms all zero */
303             int dcval = ( int )DEQUANTIZE( inptr[DCTSIZE*0], quantptr[DCTSIZE*0] );
304 
305             wsptr[DCTSIZE * 0] = dcval;
306             wsptr[DCTSIZE * 1] = dcval;
307             wsptr[DCTSIZE * 2] = dcval;
308             wsptr[DCTSIZE * 3] = dcval;
309             wsptr[DCTSIZE * 4] = dcval;
310             wsptr[DCTSIZE * 5] = dcval;
311             wsptr[DCTSIZE * 6] = dcval;
312             wsptr[DCTSIZE * 7] = dcval;
313 
314             inptr++;            /* advance pointers to next column */
315             quantptr++;
316             wsptr++;
317             continue;
318         }
319 
320         /* Even part */
321 
322         tmp0 = DEQUANTIZE( inptr[DCTSIZE * 0], quantptr[DCTSIZE * 0] );
323         tmp1 = DEQUANTIZE( inptr[DCTSIZE * 2], quantptr[DCTSIZE * 2] );
324         tmp2 = DEQUANTIZE( inptr[DCTSIZE * 4], quantptr[DCTSIZE * 4] );
325         tmp3 = DEQUANTIZE( inptr[DCTSIZE * 6], quantptr[DCTSIZE * 6] );
326 
327         tmp10 = tmp0 + tmp2;    /* phase 3 */
328         tmp11 = tmp0 - tmp2;
329 
330         tmp13 = tmp1 + tmp3;    /* phases 5-3 */
331         tmp12 = MULTIPLY( tmp1 - tmp3, FIX_1_414213562 ) - tmp13; /* 2*c4 */
332 
333         tmp0 = tmp10 + tmp13;   /* phase 2 */
334         tmp3 = tmp10 - tmp13;
335         tmp1 = tmp11 + tmp12;
336         tmp2 = tmp11 - tmp12;
337 
338         /* Odd part */
339 
340         tmp4 = DEQUANTIZE( inptr[DCTSIZE * 1], quantptr[DCTSIZE * 1] );
341         tmp5 = DEQUANTIZE( inptr[DCTSIZE * 3], quantptr[DCTSIZE * 3] );
342         tmp6 = DEQUANTIZE( inptr[DCTSIZE * 5], quantptr[DCTSIZE * 5] );
343         tmp7 = DEQUANTIZE( inptr[DCTSIZE * 7], quantptr[DCTSIZE * 7] );
344 
345         z13 = tmp6 + tmp5;      /* phase 6 */
346         z10 = tmp6 - tmp5;
347         z11 = tmp4 + tmp7;
348         z12 = tmp4 - tmp7;
349 
350         tmp7 = z11 + z13;       /* phase 5 */
351         tmp11 = MULTIPLY( z11 - z13, FIX_1_414213562 ); /* 2*c4 */
352 
353         z5 = MULTIPLY( z10 + z12, FIX_1_847759065 ); /* 2*c2 */
354         tmp10 = MULTIPLY( z12, FIX_1_082392200 ) - z5; /* 2*(c2-c6) */
355         tmp12 = MULTIPLY( z10, -FIX_2_613125930 ) + z5; /* -2*(c2+c6) */
356 
357         tmp6 = tmp12 - tmp7;    /* phase 2 */
358         tmp5 = tmp11 - tmp6;
359         tmp4 = tmp10 + tmp5;
360 
361         wsptr[DCTSIZE * 0] = ( int )( tmp0 + tmp7 );
362         wsptr[DCTSIZE * 7] = ( int )( tmp0 - tmp7 );
363         wsptr[DCTSIZE * 1] = ( int )( tmp1 + tmp6 );
364         wsptr[DCTSIZE * 6] = ( int )( tmp1 - tmp6 );
365         wsptr[DCTSIZE * 2] = ( int )( tmp2 + tmp5 );
366         wsptr[DCTSIZE * 5] = ( int )( tmp2 - tmp5 );
367         wsptr[DCTSIZE * 4] = ( int )( tmp3 + tmp4 );
368         wsptr[DCTSIZE * 3] = ( int )( tmp3 - tmp4 );
369 
370         inptr++;            /* advance pointers to next column */
371         quantptr++;
372         wsptr++;
373     }
374 
375     /* Pass 2: process rows from work array, store into output array. */
376     /* Note that we must descale the results by a factor of 8 == 2**3, */
377     /* and also undo the PASS1_BITS scaling. */
378 
379     wsptr = workspace;
380     for ( ctr = 0; ctr < DCTSIZE; ctr++ )
381     {
382         ///outptr = output_buf[ctr] + output_col;
383         /* Rows of zeroes can be exploited in the same way as we did with columns.
384          * However, the column calculation has created many nonzero AC terms, so
385          * the simplification applies less often (typically 5% to 10% of the time).
386          * On machines with very fast multiplication, it's possible that the
387          * test takes more time than it's worth.  In that case this section
388          * may be commented out.
389          */
390 
391         #if 1///ndef NO_ZERO_ROW_TEST
392         if ( wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 && wsptr[4] == 0 && wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0 )
393         {
394             /* AC terms all zero */
395             //JSAMPLE dcval = range_limit[IDESCALE(wsptr[0], PASS1_BITS+3) & RANGE_MASK];
396             int dcval = IDESCALE( wsptr[0], PASS1_BITS + 3 ) + 128;
397             clamp( dcval );
398 
399             outptr[0] = dcval;
400             outptr[1] = dcval;
401             outptr[2] = dcval;
402             outptr[3] = dcval;
403             outptr[4] = dcval;
404             outptr[5] = dcval;
405             outptr[6] = dcval;
406             outptr[7] = dcval;
407 
408             wsptr += DCTSIZE;       /* advance pointer to next row */
409             outptr += DCTSIZE;
410             continue;
411         }
412         #endif
413 
414         /* Even part */
415 
416         tmp10 = ( ( DCTELEM )wsptr[0] + ( DCTELEM )wsptr[4] );
417         tmp11 = ( ( DCTELEM )wsptr[0] - ( DCTELEM )wsptr[4] );
418 
419         tmp13 = ( ( DCTELEM )wsptr[2] + ( DCTELEM )wsptr[6] );
420         tmp12 = MULTIPLY( ( DCTELEM )wsptr[2] - ( DCTELEM )wsptr[6], FIX_1_414213562 ) - tmp13;
421 
422         tmp0 = tmp10 + tmp13;
423         tmp3 = tmp10 - tmp13;
424         tmp1 = tmp11 + tmp12;
425         tmp2 = tmp11 - tmp12;
426 
427         /* Odd part */
428 
429         z13 = ( DCTELEM )wsptr[5] + ( DCTELEM )wsptr[3];
430         z10 = ( DCTELEM )wsptr[5] - ( DCTELEM )wsptr[3];
431         z11 = ( DCTELEM )wsptr[1] + ( DCTELEM )wsptr[7];
432         z12 = ( DCTELEM )wsptr[1] - ( DCTELEM )wsptr[7];
433 
434         tmp7 = z11 + z13;       /* phase 5 */
435         tmp11 = MULTIPLY( z11 - z13, FIX_1_414213562 ); /* 2*c4 */
436 
437         z5 = MULTIPLY( z10 + z12, FIX_1_847759065 ); /* 2*c2 */
438         tmp10 = MULTIPLY( z12, FIX_1_082392200 ) - z5; /* 2*(c2-c6) */
439         tmp12 = MULTIPLY( z10, -FIX_2_613125930 ) + z5; /* -2*(c2+c6) */
440 
441         tmp6 = tmp12 - tmp7;    /* phase 2 */
442         tmp5 = tmp11 - tmp6;
443         tmp4 = tmp10 + tmp5;
444 
445         /* Final output stage: scale down by a factor of 8 and range-limit */
446         /*
447         outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
448                 & RANGE_MASK];
449         outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
450                 & RANGE_MASK];
451         outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
452                 & RANGE_MASK];
453         outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
454                 & RANGE_MASK];
455         outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
456                 & RANGE_MASK];
457         outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
458                 & RANGE_MASK];
459         outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
460                 & RANGE_MASK];
461         outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
462                 & RANGE_MASK];
463         */
464         i = IDESCALE( tmp0 + tmp7, PASS1_BITS + 3 ) + 128;
465         clamp( i );
466         outptr[0] = ( U8 )i;
467         i = IDESCALE( tmp0 - tmp7, PASS1_BITS + 3 ) + 128;
468         clamp( i );
469         outptr[7] = ( U8 )i;
470         i = IDESCALE( tmp1 + tmp6, PASS1_BITS + 3 ) + 128;
471         clamp( i );
472         outptr[1] = ( U8 )i;
473         i = IDESCALE( tmp1 - tmp6, PASS1_BITS + 3 ) + 128;
474         clamp( i );
475         outptr[6] = ( U8 )i;
476         i = IDESCALE( tmp2 + tmp5, PASS1_BITS + 3 ) + 128;
477         clamp( i );
478         outptr[2] = ( U8 )i;
479         i = IDESCALE( tmp2 - tmp5, PASS1_BITS + 3 ) + 128;
480         clamp( i );
481         outptr[5] = ( U8 )i;
482         i = IDESCALE( tmp3 + tmp4, PASS1_BITS + 3 ) + 128;
483         clamp( i );
484         outptr[4] = ( U8 )i;
485         i = IDESCALE( tmp3 - tmp4, PASS1_BITS + 3 ) + 128;
486         clamp( i );
487         outptr[3] = ( U8 )i;
488 
489         wsptr += DCTSIZE;       /* advance pointer to next row */
490         outptr += DCTSIZE;
491     }
492 }
493 
494 #endif /* DCT_IFAST_SUPPORTED */
495