1793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
2793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * jidctflt.c
3793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
4793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Copyright (C) 1994-1998, Thomas G. Lane.
5793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Modified 2010 by Guido Vollbeding.
6793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * This file is part of the Independent JPEG Group's software.
7793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * For conditions of distribution and use, see the accompanying README file.
8793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
9793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * This file contains a floating-point implementation of the
10793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * inverse DCT (Discrete Cosine Transform).  In the IJG code, this routine
11793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * must also perform dequantization of the input coefficients.
12793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
13793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * This implementation should be more accurate than either of the integer
14793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * IDCT implementations.  However, it may not give the same results on all
15793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * machines because of differences in roundoff behavior.  Speed will depend
16793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * on the hardware's floating point capacity.
17793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
18793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
19793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * on each row (or vice versa, but it's more convenient to emit a row at
20793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * a time).  Direct algorithms are also available, but they are much more
21793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * complex and seem not to be any faster when reduced to code.
22793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler *
23793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * This implementation is based on Arai, Agui, and Nakajima's algorithm for
24793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * scaled DCT.  Their original paper (Trans. IEICE E-71(11):1095) is in
25793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Japanese, but the algorithm is described in the Pennebaker & Mitchell
26793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * JPEG textbook (see REFERENCES section in file README).  The following code
27793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * is based directly on figure 4-8 in P&M.
28793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * While an 8-point DCT cannot be done in less than 11 multiplies, it is
29793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * possible to arrange the computation so that many of the multiplies are
30793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * simple scalings of the final outputs.  These multiplies can then be
31793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * folded into the multiplications or divisions by the JPEG quantization
32793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * table entries.  The AA&N method leaves only 5 multiplies and 29 adds
33793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * to be done in the DCT itself.
34793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * The primary disadvantage of this method is that with a fixed-point
35793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * implementation, accuracy is lost due to imprecise representation of the
36793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * scaled quantization values.  However, that problem does not arise if
37793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * we use floating point arithmetic.
38793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
39793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
40793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define JPEG_INTERNALS
41793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "jinclude.h"
42793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "jpeglib.h"
43793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#include "jdct.h"		/* Private declarations for DCT subsystem */
44793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
45793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#ifdef DCT_FLOAT_SUPPORTED
46793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
47793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
48793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
49793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * This module is specialized to the case DCTSIZE = 8.
50793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
51793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
52793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#if DCTSIZE != 8
53793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
54793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif
55793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
56793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
57793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/* Dequantize a coefficient by multiplying it by the multiplier-table
58793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * entry; produce a float result.
59793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
60793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
61793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#define DEQUANTIZE(coef,quantval)  (((FAST_FLOAT) (coef)) * (quantval))
62793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
63793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
64793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler/*
65793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler * Perform dequantization and inverse DCT on one block of coefficients.
66793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler */
67793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
68793ee12c6df9cad3806238d32528c49a3ff9331dNoah PreslerGLOBAL(void)
69793ee12c6df9cad3806238d32528c49a3ff9331dNoah Preslerjpeg_idct_float (j_decompress_ptr cinfo, jpeg_component_info * compptr,
70793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler                 JCOEFPTR coef_block,
71793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler                 JSAMPARRAY output_buf, JDIMENSION output_col)
72793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler{
73793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  FAST_FLOAT tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
74793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  FAST_FLOAT tmp10, tmp11, tmp12, tmp13;
75793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  FAST_FLOAT z5, z10, z11, z12, z13;
76793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  JCOEFPTR inptr;
77793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  FLOAT_MULT_TYPE * quantptr;
78793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  FAST_FLOAT * wsptr;
79793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  JSAMPROW outptr;
80793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  JSAMPLE *range_limit = cinfo->sample_range_limit;
81793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  int ctr;
82793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  FAST_FLOAT workspace[DCTSIZE2]; /* buffers data between passes */
83793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
84793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  /* Pass 1: process columns from input, store into work array. */
85793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
86793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  inptr = coef_block;
87793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  quantptr = (FLOAT_MULT_TYPE *) compptr->dct_table;
88793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  wsptr = workspace;
89793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  for (ctr = DCTSIZE; ctr > 0; ctr--) {
90793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Due to quantization, we will usually find that many of the input
91793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * coefficients are zero, especially the AC terms.  We can exploit this
92793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * by short-circuiting the IDCT calculation for any column in which all
93793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * the AC terms are zero.  In that case each output is equal to the
94793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * DC coefficient (with scale factor as needed).
95793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * With typical images and quantization tables, half or more of the
96793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * column DCT calculations can be simplified this way.
97793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     */
98793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
99793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
100793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
101793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
102793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler        inptr[DCTSIZE*7] == 0) {
103793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      /* AC terms all zero */
104793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      FAST_FLOAT dcval = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
105793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
106793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*0] = dcval;
107793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*1] = dcval;
108793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*2] = dcval;
109793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*3] = dcval;
110793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*4] = dcval;
111793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*5] = dcval;
112793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*6] = dcval;
113793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr[DCTSIZE*7] = dcval;
114793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
115793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      inptr++;			/* advance pointers to next column */
116793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      quantptr++;
117793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      wsptr++;
118793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler      continue;
119793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    }
120793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
121793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Even part */
122793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
123793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
124793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp1 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
125793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp2 = DEQUANTIZE(inptr[DCTSIZE*4], quantptr[DCTSIZE*4]);
126793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
127793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
128793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp10 = tmp0 + tmp2;	/* phase 3 */
129793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp11 = tmp0 - tmp2;
130793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
131793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp13 = tmp1 + tmp3;	/* phases 5-3 */
132793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp12 = (tmp1 - tmp3) * ((FAST_FLOAT) 1.414213562) - tmp13; /* 2*c4 */
133793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
134793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp0 = tmp10 + tmp13;	/* phase 2 */
135793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp3 = tmp10 - tmp13;
136793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp1 = tmp11 + tmp12;
137793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp2 = tmp11 - tmp12;
138793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
139793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Odd part */
140793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
141793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
142793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp5 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
143793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp6 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
144793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp7 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
145793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
146793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z13 = tmp6 + tmp5;		/* phase 6 */
147793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z10 = tmp6 - tmp5;
148793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z11 = tmp4 + tmp7;
149793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z12 = tmp4 - tmp7;
150793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
151793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp7 = z11 + z13;		/* phase 5 */
152793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562); /* 2*c4 */
153793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
154793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
155793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
156793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
157793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
158793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp6 = tmp12 - tmp7;	/* phase 2 */
159793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp5 = tmp11 - tmp6;
160793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp4 = tmp10 - tmp5;
161793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
162793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*0] = tmp0 + tmp7;
163793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*7] = tmp0 - tmp7;
164793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*1] = tmp1 + tmp6;
165793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*6] = tmp1 - tmp6;
166793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*2] = tmp2 + tmp5;
167793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*5] = tmp2 - tmp5;
168793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*3] = tmp3 + tmp4;
169793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr[DCTSIZE*4] = tmp3 - tmp4;
170793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
171793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    inptr++;			/* advance pointers to next column */
172793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    quantptr++;
173793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr++;
174793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  }
175793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
176793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  /* Pass 2: process rows from work array, store into output array. */
177793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
178793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  wsptr = workspace;
179793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  for (ctr = 0; ctr < DCTSIZE; ctr++) {
180793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr = output_buf[ctr] + output_col;
181793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Rows of zeroes can be exploited in the same way as we did with columns.
182793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * However, the column calculation has created many nonzero AC terms, so
183793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * the simplification applies less often (typically 5% to 10% of the time).
184793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     * And testing floats for zero is relatively expensive, so we don't bother.
185793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler     */
186793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
187793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Even part */
188793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
189793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Apply signed->unsigned and prepare float->int conversion */
190793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z5 = wsptr[0] + ((FAST_FLOAT) CENTERJSAMPLE + (FAST_FLOAT) 0.5);
191793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp10 = z5 + wsptr[4];
192793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp11 = z5 - wsptr[4];
193793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
194793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp13 = wsptr[2] + wsptr[6];
195793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp12 = (wsptr[2] - wsptr[6]) * ((FAST_FLOAT) 1.414213562) - tmp13;
196793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
197793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp0 = tmp10 + tmp13;
198793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp3 = tmp10 - tmp13;
199793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp1 = tmp11 + tmp12;
200793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp2 = tmp11 - tmp12;
201793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
202793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Odd part */
203793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
204793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z13 = wsptr[5] + wsptr[3];
205793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z10 = wsptr[5] - wsptr[3];
206793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z11 = wsptr[1] + wsptr[7];
207793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z12 = wsptr[1] - wsptr[7];
208793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
209793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp7 = z11 + z13;
210793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp11 = (z11 - z13) * ((FAST_FLOAT) 1.414213562);
211793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
212793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    z5 = (z10 + z12) * ((FAST_FLOAT) 1.847759065); /* 2*c2 */
213793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp10 = z5 - z12 * ((FAST_FLOAT) 1.082392200); /* 2*(c2-c6) */
214793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp12 = z5 - z10 * ((FAST_FLOAT) 2.613125930); /* 2*(c2+c6) */
215793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
216793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp6 = tmp12 - tmp7;
217793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp5 = tmp11 - tmp6;
218793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    tmp4 = tmp10 - tmp5;
219793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
220793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    /* Final output stage: float->int conversion and range-limit */
221793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
222793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[0] = range_limit[((int) (tmp0 + tmp7)) & RANGE_MASK];
223793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[7] = range_limit[((int) (tmp0 - tmp7)) & RANGE_MASK];
224793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[1] = range_limit[((int) (tmp1 + tmp6)) & RANGE_MASK];
225793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[6] = range_limit[((int) (tmp1 - tmp6)) & RANGE_MASK];
226793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[2] = range_limit[((int) (tmp2 + tmp5)) & RANGE_MASK];
227793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[5] = range_limit[((int) (tmp2 - tmp5)) & RANGE_MASK];
228793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[3] = range_limit[((int) (tmp3 + tmp4)) & RANGE_MASK];
229793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    outptr[4] = range_limit[((int) (tmp3 - tmp4)) & RANGE_MASK];
230793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
231793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler    wsptr += DCTSIZE;		/* advance pointer to next row */
232793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler  }
233793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler}
234793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler
235793ee12c6df9cad3806238d32528c49a3ff9331dNoah Presler#endif /* DCT_FLOAT_SUPPORTED */
236