4 * Copyright (C) 1994-1998, Thomas G. Lane.
5 * This file is part of the Independent JPEG Group's software.
6 * For conditions of distribution and use, see the accompanying README file.
8 * This file contains a fast, not so accurate integer implementation of the
9 * inverse DCT (Discrete Cosine Transform). In the IJG code, this routine
10 * must also perform dequantization of the input coefficients.
12 * A 2-D IDCT can be done by 1-D IDCT on each column followed by 1-D IDCT
13 * on each row (or vice versa, but it's more convenient to emit a row at
14 * a time). Direct algorithms are also available, but they are much more
15 * complex and seem not to be any faster when reduced to code.
17 * This implementation is based on Arai, Agui, and Nakajima's algorithm for
18 * scaled DCT. Their original paper (Trans. IEICE E-71(11):1095) is in
19 * Japanese, but the algorithm is described in the Pennebaker & Mitchell
20 * JPEG textbook (see REFERENCES section in file README). The following code
21 * is based directly on figure 4-8 in P&M.
22 * While an 8-point DCT cannot be done in less than 11 multiplies, it is
23 * possible to arrange the computation so that many of the multiplies are
24 * simple scalings of the final outputs. These multiplies can then be
25 * folded into the multiplications or divisions by the JPEG quantization
26 * table entries. The AA&N method leaves only 5 multiplies and 29 adds
27 * to be done in the DCT itself.
28 * The primary disadvantage of this method is that with fixed-point math,
29 * accuracy is lost due to imprecise representation of the scaled
30 * quantization values. The smaller the quantization table entry, the less
31 * precise the scaled value, so this implementation does worse with high-
32 * quality-setting files than with low-quality ones.
35 #define JPEG_INTERNALS
38 #include "jdct.h" /* Private declarations for DCT subsystem */
41 #ifdef DCT_IFAST_SUPPORTED
45 * This module is specialized to the case DCTSIZE = 8.
49 Sorry
, this code only copes with
8x8 DCTs
. /* deliberate syntax err */
53 /* Scaling decisions are generally the same as in the LL&M algorithm;
54 * see jidctint.c for more details. However, we choose to descale
55 * (right shift) multiplication products as soon as they are formed,
56 * rather than carrying additional fractional bits into subsequent additions.
57 * This compromises accuracy slightly, but it lets us save a few shifts.
58 * More importantly, 16-bit arithmetic is then adequate (for 8-bit samples)
59 * everywhere except in the multiplications proper; this saves a good deal
60 * of work on 16-bit-int machines.
62 * The dequantized coefficients are not integers because the AA&N scaling
63 * factors have been incorporated. We represent them scaled up by PASS1_BITS,
64 * so that the first and second IDCT rounds have the same input scaling.
65 * For 8-bit JSAMPLEs, we choose IFAST_SCALE_BITS = PASS1_BITS so as to
66 * avoid a descaling shift; this compromises accuracy rather drastically
67 * for small quantization table entries, but it saves a lot of shifts.
68 * For 12-bit JSAMPLEs, there's no hope of using 16x16 multiplies anyway,
69 * so we use a much larger scaling factor to preserve accuracy.
71 * A final compromise is to represent the multiplicative constants to only
72 * 8 fractional bits, rather than 13. This saves some shifting work on some
73 * machines, and may also reduce the cost of multiplication (since there
74 * are fewer one-bits in the constants).
77 #if BITS_IN_JSAMPLE == 8
82 #define PASS1_BITS 1 /* lose a little precision to avoid overflow */
85 /* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
86 * causing a lot of useless floating-point operations at run time.
87 * To get around this we use the following pre-calculated constants.
88 * If you change CONST_BITS you may want to add appropriate values.
89 * (With a reasonable C compiler, you can just rely on the FIX() macro...)
93 #define FIX_1_082392200 ((INT32) 277) /* FIX(1.082392200) */
94 #define FIX_1_414213562 ((INT32) 362) /* FIX(1.414213562) */
95 #define FIX_1_847759065 ((INT32) 473) /* FIX(1.847759065) */
96 #define FIX_2_613125930 ((INT32) 669) /* FIX(2.613125930) */
98 #define FIX_1_082392200 FIX(1.082392200)
99 #define FIX_1_414213562 FIX(1.414213562)
100 #define FIX_1_847759065 FIX(1.847759065)
101 #define FIX_2_613125930 FIX(2.613125930)
105 /* We can gain a little more speed, with a further compromise in accuracy,
106 * by omitting the addition in a descaling shift. This yields an incorrectly
107 * rounded result half the time...
110 #ifndef USE_ACCURATE_ROUNDING
112 #define DESCALE(x,n) RIGHT_SHIFT(x, n)
116 /* Multiply a DCTELEM variable by an INT32 constant, and immediately
117 * descale to yield a DCTELEM result.
120 #define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
123 /* Dequantize a coefficient by multiplying it by the multiplier-table
124 * entry; produce a DCTELEM result. For 8-bit data a 16x16->16
125 * multiplication will do. For 12-bit data, the multiplier table is
126 * declared INT32, so a 32-bit multiply will be used.
129 #if BITS_IN_JSAMPLE == 8
130 #define DEQUANTIZE(coef,quantval) (((IFAST_MULT_TYPE) (coef)) * (quantval))
132 #define DEQUANTIZE(coef,quantval) \
133 DESCALE((coef)*(quantval), IFAST_SCALE_BITS-PASS1_BITS)
137 /* Like DESCALE, but applies to a DCTELEM and produces an int.
138 * We assume that int right shift is unsigned if INT32 right shift is.
141 #ifdef RIGHT_SHIFT_IS_UNSIGNED
142 #define ISHIFT_TEMPS DCTELEM ishift_temp;
143 #if BITS_IN_JSAMPLE == 8
144 #define DCTELEMBITS 16 /* DCTELEM may be 16 or 32 bits */
146 #define DCTELEMBITS 32 /* DCTELEM must be 32 bits */
148 #define IRIGHT_SHIFT(x,shft) \
149 ((ishift_temp = (x)) < 0 ? \
150 (ishift_temp >> (shft)) | ((~((DCTELEM) 0)) << (DCTELEMBITS-(shft))) : \
151 (ishift_temp >> (shft)))
154 #define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
157 #ifdef USE_ACCURATE_ROUNDING
158 #define IDESCALE(x,n) ((int) IRIGHT_SHIFT((x) + (1 << ((n)-1)), n))
160 #define IDESCALE(x,n) ((int) IRIGHT_SHIFT(x, n))
163 #ifdef HAVE_MMX_INTEL_MNEMONICS
164 __inline
GLOBAL(void)
165 jpeg_idct_ifast_mmx (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
167 JSAMPARRAY output_buf
, JDIMENSION output_col
);
168 __inline
GLOBAL(void)
169 jpeg_idct_ifast_orig (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
171 JSAMPARRAY output_buf
, JDIMENSION output_col
);
175 jpeg_idct_ifast(j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
177 JSAMPARRAY output_buf
, JDIMENSION output_col
);
180 #ifdef HAVE_MMX_INTEL_MNEMONICS
182 jpeg_idct_ifast (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
184 JSAMPARRAY output_buf
, JDIMENSION output_col
)
187 jpeg_idct_ifast_mmx(cinfo
, compptr
, coef_block
, output_buf
, output_col
);
189 jpeg_idct_ifast_orig(cinfo
, compptr
, coef_block
, output_buf
, output_col
);
194 * Perform dequantization and inverse DCT on one block of coefficients.
198 jpeg_idct_ifast (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
200 JSAMPARRAY output_buf
, JDIMENSION output_col
)
202 DCTELEM tmp0
, tmp1
, tmp2
, tmp3
, tmp4
, tmp5
, tmp6
, tmp7
;
203 DCTELEM tmp10
, tmp11
, tmp12
, tmp13
;
204 DCTELEM z5
, z10
, z11
, z12
, z13
;
206 IFAST_MULT_TYPE
* quantptr
;
209 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
211 int workspace
[DCTSIZE2
]; /* buffers data between passes */
212 SHIFT_TEMPS
/* for DESCALE */
213 ISHIFT_TEMPS
/* for IDESCALE */
215 /* Pass 1: process columns from input, store into work array. */
218 quantptr
= (IFAST_MULT_TYPE
*) compptr
->dct_table
;
220 for (ctr
= DCTSIZE
; ctr
> 0; ctr
--) {
221 /* Due to quantization, we will usually find that many of the input
222 * coefficients are zero, especially the AC terms. We can exploit this
223 * by short-circuiting the IDCT calculation for any column in which all
224 * the AC terms are zero. In that case each output is equal to the
225 * DC coefficient (with scale factor as needed).
226 * With typical images and quantization tables, half or more of the
227 * column DCT calculations can be simplified this way.
230 if (inptr
[DCTSIZE
*1] == 0 && inptr
[DCTSIZE
*2] == 0 &&
231 inptr
[DCTSIZE
*3] == 0 && inptr
[DCTSIZE
*4] == 0 &&
232 inptr
[DCTSIZE
*5] == 0 && inptr
[DCTSIZE
*6] == 0 &&
233 inptr
[DCTSIZE
*7] == 0) {
234 /* AC terms all zero */
235 int dcval
= (int) DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
237 wsptr
[DCTSIZE
*0] = dcval
;
238 wsptr
[DCTSIZE
*1] = dcval
;
239 wsptr
[DCTSIZE
*2] = dcval
;
240 wsptr
[DCTSIZE
*3] = dcval
;
241 wsptr
[DCTSIZE
*4] = dcval
;
242 wsptr
[DCTSIZE
*5] = dcval
;
243 wsptr
[DCTSIZE
*6] = dcval
;
244 wsptr
[DCTSIZE
*7] = dcval
;
246 inptr
++; /* advance pointers to next column */
254 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
255 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
256 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
257 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
259 tmp10
= tmp0
+ tmp2
; /* phase 3 */
262 tmp13
= tmp1
+ tmp3
; /* phases 5-3 */
263 tmp12
= MULTIPLY(tmp1
- tmp3
, FIX_1_414213562
) - tmp13
; /* 2*c4 */
265 tmp0
= tmp10
+ tmp13
; /* phase 2 */
266 tmp3
= tmp10
- tmp13
;
267 tmp1
= tmp11
+ tmp12
;
268 tmp2
= tmp11
- tmp12
;
272 tmp4
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
273 tmp5
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
274 tmp6
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
275 tmp7
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
277 z13
= tmp6
+ tmp5
; /* phase 6 */
282 tmp7
= z11
+ z13
; /* phase 5 */
283 tmp11
= MULTIPLY(z11
- z13
, FIX_1_414213562
); /* 2*c4 */
285 z5
= MULTIPLY(z10
+ z12
, FIX_1_847759065
); /* 2*c2 */
286 tmp10
= MULTIPLY(z12
, FIX_1_082392200
) - z5
; /* 2*(c2-c6) */
287 tmp12
= MULTIPLY(z10
, - FIX_2_613125930
) + z5
; /* -2*(c2+c6) */
289 tmp6
= tmp12
- tmp7
; /* phase 2 */
293 wsptr
[DCTSIZE
*0] = (int) (tmp0
+ tmp7
);
294 wsptr
[DCTSIZE
*7] = (int) (tmp0
- tmp7
);
295 wsptr
[DCTSIZE
*1] = (int) (tmp1
+ tmp6
);
296 wsptr
[DCTSIZE
*6] = (int) (tmp1
- tmp6
);
297 wsptr
[DCTSIZE
*2] = (int) (tmp2
+ tmp5
);
298 wsptr
[DCTSIZE
*5] = (int) (tmp2
- tmp5
);
299 wsptr
[DCTSIZE
*4] = (int) (tmp3
+ tmp4
);
300 wsptr
[DCTSIZE
*3] = (int) (tmp3
- tmp4
);
302 inptr
++; /* advance pointers to next column */
307 /* Pass 2: process rows from work array, store into output array. */
308 /* Note that we must descale the results by a factor of 8 == 2**3, */
309 /* and also undo the PASS1_BITS scaling. */
312 for (ctr
= 0; ctr
< DCTSIZE
; ctr
++) {
313 outptr
= output_buf
[ctr
] + output_col
;
314 /* Rows of zeroes can be exploited in the same way as we did with columns.
315 * However, the column calculation has created many nonzero AC terms, so
316 * the simplification applies less often (typically 5% to 10% of the time).
317 * On machines with very fast multiplication, it's possible that the
318 * test takes more time than it's worth. In that case this section
319 * may be commented out.
322 #ifndef NO_ZERO_ROW_TEST
323 if (wsptr
[1] == 0 && wsptr
[2] == 0 && wsptr
[3] == 0 && wsptr
[4] == 0 &&
324 wsptr
[5] == 0 && wsptr
[6] == 0 && wsptr
[7] == 0) {
325 /* AC terms all zero */
326 JSAMPLE dcval
= range_limit
[IDESCALE(wsptr
[0], PASS1_BITS
+3)
338 wsptr
+= DCTSIZE
; /* advance pointer to next row */
345 tmp10
= ((DCTELEM
) wsptr
[0] + (DCTELEM
) wsptr
[4]);
346 tmp11
= ((DCTELEM
) wsptr
[0] - (DCTELEM
) wsptr
[4]);
348 tmp13
= ((DCTELEM
) wsptr
[2] + (DCTELEM
) wsptr
[6]);
349 tmp12
= MULTIPLY((DCTELEM
) wsptr
[2] - (DCTELEM
) wsptr
[6], FIX_1_414213562
)
352 tmp0
= tmp10
+ tmp13
;
353 tmp3
= tmp10
- tmp13
;
354 tmp1
= tmp11
+ tmp12
;
355 tmp2
= tmp11
- tmp12
;
359 z13
= (DCTELEM
) wsptr
[5] + (DCTELEM
) wsptr
[3];
360 z10
= (DCTELEM
) wsptr
[5] - (DCTELEM
) wsptr
[3];
361 z11
= (DCTELEM
) wsptr
[1] + (DCTELEM
) wsptr
[7];
362 z12
= (DCTELEM
) wsptr
[1] - (DCTELEM
) wsptr
[7];
364 tmp7
= z11
+ z13
; /* phase 5 */
365 tmp11
= MULTIPLY(z11
- z13
, FIX_1_414213562
); /* 2*c4 */
367 z5
= MULTIPLY(z10
+ z12
, FIX_1_847759065
); /* 2*c2 */
368 tmp10
= MULTIPLY(z12
, FIX_1_082392200
) - z5
; /* 2*(c2-c6) */
369 tmp12
= MULTIPLY(z10
, - FIX_2_613125930
) + z5
; /* -2*(c2+c6) */
371 tmp6
= tmp12
- tmp7
; /* phase 2 */
375 /* Final output stage: scale down by a factor of 8 and range-limit */
377 outptr
[0] = range_limit
[IDESCALE(tmp0
+ tmp7
, PASS1_BITS
+3)
379 outptr
[7] = range_limit
[IDESCALE(tmp0
- tmp7
, PASS1_BITS
+3)
381 outptr
[1] = range_limit
[IDESCALE(tmp1
+ tmp6
, PASS1_BITS
+3)
383 outptr
[6] = range_limit
[IDESCALE(tmp1
- tmp6
, PASS1_BITS
+3)
385 outptr
[2] = range_limit
[IDESCALE(tmp2
+ tmp5
, PASS1_BITS
+3)
387 outptr
[5] = range_limit
[IDESCALE(tmp2
- tmp5
, PASS1_BITS
+3)
389 outptr
[4] = range_limit
[IDESCALE(tmp3
+ tmp4
, PASS1_BITS
+3)
391 outptr
[3] = range_limit
[IDESCALE(tmp3
- tmp4
, PASS1_BITS
+3)
394 wsptr
+= DCTSIZE
; /* advance pointer to next row */
400 #ifdef HAVE_MMX_INTEL_MNEMONICS
404 jpeg_idct_ifast_orig (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
406 JSAMPARRAY output_buf
, JDIMENSION output_col
)
408 DCTELEM tmp0
, tmp1
, tmp2
, tmp3
, tmp4
, tmp5
, tmp6
, tmp7
;
409 DCTELEM tmp10
, tmp11
, tmp12
, tmp13
;
410 DCTELEM z5
, z10
, z11
, z12
, z13
;
412 IFAST_MULT_TYPE
* quantptr
;
415 JSAMPLE
*range_limit
= IDCT_range_limit(cinfo
);
417 int workspace
[DCTSIZE2
]; /* buffers data between passes */
418 SHIFT_TEMPS
/* for DESCALE */
419 ISHIFT_TEMPS
/* for IDESCALE */
421 /* Pass 1: process columns from input, store into work array. */
424 quantptr
= (IFAST_MULT_TYPE
*) compptr
->dct_table
;
426 for (ctr
= DCTSIZE
; ctr
> 0; ctr
--) {
427 /* Due to quantization, we will usually find that many of the input
428 * coefficients are zero, especially the AC terms. We can exploit this
429 * by short-circuiting the IDCT calculation for any column in which all
430 * the AC terms are zero. In that case each output is equal to the
431 * DC coefficient (with scale factor as needed).
432 * With typical images and quantization tables, half or more of the
433 * column DCT calculations can be simplified this way.
436 if ((inptr
[DCTSIZE
*1] | inptr
[DCTSIZE
*2] | inptr
[DCTSIZE
*3] |
437 inptr
[DCTSIZE
*4] | inptr
[DCTSIZE
*5] | inptr
[DCTSIZE
*6] |
438 inptr
[DCTSIZE
*7]) == 0) {
439 /* AC terms all zero */
440 int dcval
= (int) DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
442 wsptr
[DCTSIZE
*0] = dcval
;
443 wsptr
[DCTSIZE
*1] = dcval
;
444 wsptr
[DCTSIZE
*2] = dcval
;
445 wsptr
[DCTSIZE
*3] = dcval
;
446 wsptr
[DCTSIZE
*4] = dcval
;
447 wsptr
[DCTSIZE
*5] = dcval
;
448 wsptr
[DCTSIZE
*6] = dcval
;
449 wsptr
[DCTSIZE
*7] = dcval
;
451 inptr
++; /* advance pointers to next column */
459 tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
460 tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
461 tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
462 tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
464 tmp10
= tmp0
+ tmp2
; /* phase 3 */
467 tmp13
= tmp1
+ tmp3
; /* phases 5-3 */
468 tmp12
= MULTIPLY(tmp1
- tmp3
, FIX_1_414213562
) - tmp13
; /* 2*c4 */
470 tmp0
= tmp10
+ tmp13
; /* phase 2 */
471 tmp3
= tmp10
- tmp13
;
472 tmp1
= tmp11
+ tmp12
;
473 tmp2
= tmp11
- tmp12
;
477 tmp4
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
478 tmp5
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
479 tmp6
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
480 tmp7
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
482 z13
= tmp6
+ tmp5
; /* phase 6 */
487 tmp7
= z11
+ z13
; /* phase 5 */
488 tmp11
= MULTIPLY(z11
- z13
, FIX_1_414213562
); /* 2*c4 */
490 z5
= MULTIPLY(z10
+ z12
, FIX_1_847759065
); /* 2*c2 */
491 tmp10
= MULTIPLY(z12
, FIX_1_082392200
) - z5
; /* 2*(c2-c6) */
492 tmp12
= MULTIPLY(z10
, - FIX_2_613125930
) + z5
; /* -2*(c2+c6) */
494 tmp6
= tmp12
- tmp7
; /* phase 2 */
498 wsptr
[DCTSIZE
*0] = (int) (tmp0
+ tmp7
);
499 wsptr
[DCTSIZE
*7] = (int) (tmp0
- tmp7
);
500 wsptr
[DCTSIZE
*1] = (int) (tmp1
+ tmp6
);
501 wsptr
[DCTSIZE
*6] = (int) (tmp1
- tmp6
);
502 wsptr
[DCTSIZE
*2] = (int) (tmp2
+ tmp5
);
503 wsptr
[DCTSIZE
*5] = (int) (tmp2
- tmp5
);
504 wsptr
[DCTSIZE
*4] = (int) (tmp3
+ tmp4
);
505 wsptr
[DCTSIZE
*3] = (int) (tmp3
- tmp4
);
507 inptr
++; /* advance pointers to next column */
512 /* Pass 2: process rows from work array, store into output array. */
513 /* Note that we must descale the results by a factor of 8 == 2**3, */
514 /* and also undo the PASS1_BITS scaling. */
517 for (ctr
= 0; ctr
< DCTSIZE
; ctr
++) {
518 outptr
= output_buf
[ctr
] + output_col
;
519 /* Rows of zeroes can be exploited in the same way as we did with columns.
520 * However, the column calculation has created many nonzero AC terms, so
521 * the simplification applies less often (typically 5% to 10% of the time).
522 * On machines with very fast multiplication, it's possible that the
523 * test takes more time than it's worth. In that case this section
524 * may be commented out.
527 #ifndef NO_ZERO_ROW_TEST
528 if ((wsptr
[1] | wsptr
[2] | wsptr
[3] | wsptr
[4] | wsptr
[5] | wsptr
[6] |
530 /* AC terms all zero */
531 JSAMPLE dcval
= range_limit
[IDESCALE(wsptr
[0], PASS1_BITS
+3)
543 wsptr
+= DCTSIZE
; /* advance pointer to next row */
550 tmp10
= ((DCTELEM
) wsptr
[0] + (DCTELEM
) wsptr
[4]);
551 tmp11
= ((DCTELEM
) wsptr
[0] - (DCTELEM
) wsptr
[4]);
553 tmp13
= ((DCTELEM
) wsptr
[2] + (DCTELEM
) wsptr
[6]);
554 tmp12
= MULTIPLY((DCTELEM
) wsptr
[2] - (DCTELEM
) wsptr
[6], FIX_1_414213562
)
557 tmp0
= tmp10
+ tmp13
;
558 tmp3
= tmp10
- tmp13
;
559 tmp1
= tmp11
+ tmp12
;
560 tmp2
= tmp11
- tmp12
;
564 z13
= (DCTELEM
) wsptr
[5] + (DCTELEM
) wsptr
[3];
565 z10
= (DCTELEM
) wsptr
[5] - (DCTELEM
) wsptr
[3];
566 z11
= (DCTELEM
) wsptr
[1] + (DCTELEM
) wsptr
[7];
567 z12
= (DCTELEM
) wsptr
[1] - (DCTELEM
) wsptr
[7];
569 tmp7
= z11
+ z13
; /* phase 5 */
570 tmp11
= MULTIPLY(z11
- z13
, FIX_1_414213562
); /* 2*c4 */
572 z5
= MULTIPLY(z10
+ z12
, FIX_1_847759065
); /* 2*c2 */
573 tmp10
= MULTIPLY(z12
, FIX_1_082392200
) - z5
; /* 2*(c2-c6) */
574 tmp12
= MULTIPLY(z10
, - FIX_2_613125930
) + z5
; /* -2*(c2+c6) */
576 tmp6
= tmp12
- tmp7
; /* phase 2 */
580 /* Final output stage: scale down by a factor of 8 and range-limit */
582 outptr
[0] = range_limit
[IDESCALE(tmp0
+ tmp7
, PASS1_BITS
+3)
584 outptr
[7] = range_limit
[IDESCALE(tmp0
- tmp7
, PASS1_BITS
+3)
586 outptr
[1] = range_limit
[IDESCALE(tmp1
+ tmp6
, PASS1_BITS
+3)
588 outptr
[6] = range_limit
[IDESCALE(tmp1
- tmp6
, PASS1_BITS
+3)
590 outptr
[2] = range_limit
[IDESCALE(tmp2
+ tmp5
, PASS1_BITS
+3)
592 outptr
[5] = range_limit
[IDESCALE(tmp2
- tmp5
, PASS1_BITS
+3)
594 outptr
[4] = range_limit
[IDESCALE(tmp3
+ tmp4
, PASS1_BITS
+3)
596 outptr
[3] = range_limit
[IDESCALE(tmp3
- tmp4
, PASS1_BITS
+3)
599 wsptr
+= DCTSIZE
; /* advance pointer to next row */
604 static __int64 fix_141
= 0x5a825a825a825a82;
605 static __int64 fix_184n261
= 0xcf04cf04cf04cf04;
606 static __int64 fix_184
= 0x7641764176417641;
607 static __int64 fix_n184
= 0x896f896f896f896f;
608 static __int64 fix_108n184
= 0xcf04cf04cf04cf04;
609 static __int64 const_0x0080
= 0x0080008000800080;
612 __inline
GLOBAL(void)
613 jpeg_idct_ifast_mmx (j_decompress_ptr cinfo
, jpeg_component_info
* compptr
,
615 JSAMPARRAY outptr
, JDIMENSION output_col
)
618 int16 workspace
[DCTSIZE2
+ 4]; /* buffers data between passes */
619 int16
*wsptr
=workspace
;
620 int16
*quantptr
=compptr
->dct_table
;
627 add esi
, 0x07 ;align wsptr to qword
628 and esi
, 0xfffffff8 ;align wsptr to qword
635 movq mm1
, [ebx
+ 8*10] ;load inptr
[DCTSIZE
*5]
637 pmullw mm1
, [edi
+ 8*10] ;tmp6
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
639 movq mm0
, [ebx
+ 8*6] ;load inptr
[DCTSIZE
*3]
641 pmullw mm0
, [edi
+ 8*6] ;tmp5
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
643 movq mm3
, [ebx
+ 8*2] ;load inptr
[DCTSIZE
*1]
644 movq mm2
, mm1
;copy tmp6
/* phase 6 */
646 pmullw mm3
, [edi
+ 8*2] ;tmp4
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
648 movq mm4
, [ebx
+ 8*14] ;load inptr
[DCTSIZE
*1]
649 paddw mm1
, mm0
;z13
= tmp6
+ tmp5
;
651 pmullw mm4
, [edi
+ 8*14] ;tmp7
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
652 psubw mm2
, mm0
;z10
= tmp6
- tmp5
654 psllw mm2
, 2 ;shift z10
655 movq mm0
, mm2
;copy z10
657 pmulhw mm2
, fix_184n261
;MULTIPLY( z12
, FIX_1_847759065
); /* 2*c2 */
658 movq mm5
, mm3
;copy tmp4
660 pmulhw mm0
, fix_n184
;MULTIPLY(z10
, -FIX_1_847759065
); /* 2*c2 */
661 paddw mm3
, mm4
;z11
= tmp4
+ tmp7
;
663 movq mm6
, mm3
;copy z11
/* phase 5 */
664 psubw mm5
, mm4
;z12
= tmp4
- tmp7
;
666 psubw mm6
, mm1
;z11
-z13
667 psllw mm5
, 2 ;shift z12
669 movq mm4
, [ebx
+ 8*12] ;load inptr
[DCTSIZE
*6], even part
670 movq mm7
, mm5
;copy z12
672 pmulhw mm5
, fix_108n184
;MULT(z12
, (FIX_1_08
-FIX_1_84
)) //- z5; /* 2*(c2-c6) */ even part
673 paddw mm3
, mm1
;tmp7
= z11
+ z13
;
677 pmulhw mm7
, fix_184
;MULTIPLY(z10
,(FIX_1_847759065
- FIX_2_613125930
)) //+ z5; /* -2*(c2+c6) */
680 movq mm1
, [ebx
+ 8*4] ;load inptr
[DCTSIZE
*2]
682 pmullw mm1
, [edi
+ 8*4] ;tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
683 paddw mm0
, mm5
;tmp10
685 pmullw mm4
, [edi
+ 8*12] ;tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
686 paddw mm2
, mm7
;tmp12
688 pmulhw mm6
, fix_141
;tmp11
= MULTIPLY(z11
- z13
, FIX_1_414213562
); /* 2*c4 */
689 psubw mm2
, mm3
;tmp6
= tmp12
- tmp7
691 movq mm5
, mm1
;copy tmp1
692 paddw mm1
, mm4
;tmp13
= tmp1
+ tmp3
; /* phases 5-3 */
694 psubw mm5
, mm4
;tmp1
-tmp3
695 psubw mm6
, mm2
;tmp5
= tmp11
- tmp6
;
697 movq
[esi
+8*0], mm1
;save tmp13 in workspace
698 psllw mm5
, 2 ;shift tmp1
-tmp3
700 movq mm7
, [ebx
+ 8*0] ;load inptr
[DCTSIZE
*0]
702 pmulhw mm5
, fix_141
;MULTIPLY(tmp1
- tmp3
, FIX_1_414213562
)
703 paddw mm0
, mm6
;tmp4
= tmp10
+ tmp5
;
705 pmullw mm7
, [edi
+ 8*0] ;tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
707 movq mm4
, [ebx
+ 8*8] ;load inptr
[DCTSIZE
*4]
709 pmullw mm4
, [edi
+ 8*8] ;tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
710 psubw mm5
, mm1
;tmp12
= MULTIPLY(tmp1
- tmp3
, FIX_1_414213562
) - tmp13
; /* 2*c4 */
712 movq
[esi
+8*4], mm0
;save tmp4 in workspace
713 movq mm1
, mm7
;copy tmp0
/* phase 3 */
715 movq
[esi
+8*2], mm5
;save tmp12 in workspace
716 psubw mm1
, mm4
;tmp11
= tmp0
- tmp2
;
718 paddw mm7
, mm4
;tmp10
= tmp0
+ tmp2
;
719 movq mm5
, mm1
;copy tmp11
721 paddw mm1
, [esi
+8*2] ;tmp1
= tmp11
+ tmp12
;
722 movq mm4
, mm7
;copy tmp10
/* phase 2 */
724 paddw mm7
, [esi
+8*0] ;tmp0
= tmp10
+ tmp13
;
726 psubw mm4
, [esi
+8*0] ;tmp3
= tmp10
- tmp13
;
727 movq mm0
, mm7
;copy tmp0
729 psubw mm5
, [esi
+8*2] ;tmp2
= tmp11
- tmp12
;
730 paddw mm7
, mm3
;wsptr
[DCTSIZE
*0] = (int) (tmp0
+ tmp7
);
732 psubw mm0
, mm3
;wsptr
[DCTSIZE
*7] = (int) (tmp0
- tmp7
);
734 movq
[esi
+ 8*0], mm7
;wsptr
[DCTSIZE
*0]
735 movq mm3
, mm1
;copy tmp1
737 movq
[esi
+ 8*14], mm0
;wsptr
[DCTSIZE
*7]
738 paddw mm1
, mm2
;wsptr
[DCTSIZE
*1] = (int) (tmp1
+ tmp6
);
740 psubw mm3
, mm2
;wsptr
[DCTSIZE
*6] = (int) (tmp1
- tmp6
);
742 movq
[esi
+ 8*2], mm1
;wsptr
[DCTSIZE
*1]
743 movq mm1
, mm4
;copy tmp3
745 movq
[esi
+ 8*12], mm3
;wsptr
[DCTSIZE
*6]
747 paddw mm4
, [esi
+8*4] ;wsptr
[DCTSIZE
*4] = (int) (tmp3
+ tmp4
);
749 psubw mm1
, [esi
+8*4] ;wsptr
[DCTSIZE
*3] = (int) (tmp3
- tmp4
);
751 movq
[esi
+ 8*8], mm4
752 movq mm7
, mm5
;copy tmp2
754 paddw mm5
, mm6
;wsptr
[DCTSIZE
*2] = (int) (tmp2
+ tmp5
)
756 movq
[esi
+8*6], mm1
;
757 psubw mm7
, mm6
;wsptr
[DCTSIZE
*5] = (int) (tmp2
- tmp5
);
759 movq
[esi
+ 8*4], mm5
761 movq
[esi
+ 8*10], mm7
765 /*****************************************************************/
770 /*****************************************************************/
775 movq mm1
, [ebx
+ 8*10] ;load inptr
[DCTSIZE
*5]
777 pmullw mm1
, [edi
+ 8*10] ;tmp6
= DEQUANTIZE(inptr
[DCTSIZE
*5], quantptr
[DCTSIZE
*5]);
779 movq mm0
, [ebx
+ 8*6] ;load inptr
[DCTSIZE
*3]
781 pmullw mm0
, [edi
+ 8*6] ;tmp5
= DEQUANTIZE(inptr
[DCTSIZE
*3], quantptr
[DCTSIZE
*3]);
783 movq mm3
, [ebx
+ 8*2] ;load inptr
[DCTSIZE
*1]
784 movq mm2
, mm1
;copy tmp6
/* phase 6 */
786 pmullw mm3
, [edi
+ 8*2] ;tmp4
= DEQUANTIZE(inptr
[DCTSIZE
*1], quantptr
[DCTSIZE
*1]);
788 movq mm4
, [ebx
+ 8*14] ;load inptr
[DCTSIZE
*1]
789 paddw mm1
, mm0
;z13
= tmp6
+ tmp5
;
791 pmullw mm4
, [edi
+ 8*14] ;tmp7
= DEQUANTIZE(inptr
[DCTSIZE
*7], quantptr
[DCTSIZE
*7]);
792 psubw mm2
, mm0
;z10
= tmp6
- tmp5
794 psllw mm2
, 2 ;shift z10
795 movq mm0
, mm2
;copy z10
797 pmulhw mm2
, fix_184n261
;MULTIPLY( z12
, FIX_1_847759065
); /* 2*c2 */
798 movq mm5
, mm3
;copy tmp4
800 pmulhw mm0
, fix_n184
;MULTIPLY(z10
, -FIX_1_847759065
); /* 2*c2 */
801 paddw mm3
, mm4
;z11
= tmp4
+ tmp7
;
803 movq mm6
, mm3
;copy z11
/* phase 5 */
804 psubw mm5
, mm4
;z12
= tmp4
- tmp7
;
806 psubw mm6
, mm1
;z11
-z13
807 psllw mm5
, 2 ;shift z12
809 movq mm4
, [ebx
+ 8*12] ;load inptr
[DCTSIZE
*6], even part
810 movq mm7
, mm5
;copy z12
812 pmulhw mm5
, fix_108n184
;MULT(z12
, (FIX_1_08
-FIX_1_84
)) //- z5; /* 2*(c2-c6) */ even part
813 paddw mm3
, mm1
;tmp7
= z11
+ z13
;
817 pmulhw mm7
, fix_184
;MULTIPLY(z10
,(FIX_1_847759065
- FIX_2_613125930
)) //+ z5; /* -2*(c2+c6) */
820 movq mm1
, [ebx
+ 8*4] ;load inptr
[DCTSIZE
*2]
822 pmullw mm1
, [edi
+ 8*4] ;tmp1
= DEQUANTIZE(inptr
[DCTSIZE
*2], quantptr
[DCTSIZE
*2]);
823 paddw mm0
, mm5
;tmp10
825 pmullw mm4
, [edi
+ 8*12] ;tmp3
= DEQUANTIZE(inptr
[DCTSIZE
*6], quantptr
[DCTSIZE
*6]);
826 paddw mm2
, mm7
;tmp12
828 pmulhw mm6
, fix_141
;tmp11
= MULTIPLY(z11
- z13
, FIX_1_414213562
); /* 2*c4 */
829 psubw mm2
, mm3
;tmp6
= tmp12
- tmp7
831 movq mm5
, mm1
;copy tmp1
832 paddw mm1
, mm4
;tmp13
= tmp1
+ tmp3
; /* phases 5-3 */
834 psubw mm5
, mm4
;tmp1
-tmp3
835 psubw mm6
, mm2
;tmp5
= tmp11
- tmp6
;
837 movq
[esi
+8*0], mm1
;save tmp13 in workspace
838 psllw mm5
, 2 ;shift tmp1
-tmp3
840 movq mm7
, [ebx
+ 8*0] ;load inptr
[DCTSIZE
*0]
841 paddw mm0
, mm6
;tmp4
= tmp10
+ tmp5
;
843 pmulhw mm5
, fix_141
;MULTIPLY(tmp1
- tmp3
, FIX_1_414213562
)
845 pmullw mm7
, [edi
+ 8*0] ;tmp0
= DEQUANTIZE(inptr
[DCTSIZE
*0], quantptr
[DCTSIZE
*0]);
847 movq mm4
, [ebx
+ 8*8] ;load inptr
[DCTSIZE
*4]
849 pmullw mm4
, [edi
+ 8*8] ;tmp2
= DEQUANTIZE(inptr
[DCTSIZE
*4], quantptr
[DCTSIZE
*4]);
850 psubw mm5
, mm1
;tmp12
= MULTIPLY(tmp1
- tmp3
, FIX_1_414213562
) - tmp13
; /* 2*c4 */
852 movq
[esi
+8*4], mm0
;save tmp4 in workspace
853 movq mm1
, mm7
;copy tmp0
/* phase 3 */
855 movq
[esi
+8*2], mm5
;save tmp12 in workspace
856 psubw mm1
, mm4
;tmp11
= tmp0
- tmp2
;
858 paddw mm7
, mm4
;tmp10
= tmp0
+ tmp2
;
859 movq mm5
, mm1
;copy tmp11
861 paddw mm1
, [esi
+8*2] ;tmp1
= tmp11
+ tmp12
;
862 movq mm4
, mm7
;copy tmp10
/* phase 2 */
864 paddw mm7
, [esi
+8*0] ;tmp0
= tmp10
+ tmp13
;
866 psubw mm4
, [esi
+8*0] ;tmp3
= tmp10
- tmp13
;
867 movq mm0
, mm7
;copy tmp0
869 psubw mm5
, [esi
+8*2] ;tmp2
= tmp11
- tmp12
;
870 paddw mm7
, mm3
;wsptr
[DCTSIZE
*0] = (int) (tmp0
+ tmp7
);
872 psubw mm0
, mm3
;wsptr
[DCTSIZE
*7] = (int) (tmp0
- tmp7
);
874 movq
[esi
+ 8*0], mm7
;wsptr
[DCTSIZE
*0]
875 movq mm3
, mm1
;copy tmp1
877 movq
[esi
+ 8*14], mm0
;wsptr
[DCTSIZE
*7]
878 paddw mm1
, mm2
;wsptr
[DCTSIZE
*1] = (int) (tmp1
+ tmp6
);
880 psubw mm3
, mm2
;wsptr
[DCTSIZE
*6] = (int) (tmp1
- tmp6
);
882 movq
[esi
+ 8*2], mm1
;wsptr
[DCTSIZE
*1]
883 movq mm1
, mm4
;copy tmp3
885 movq
[esi
+ 8*12], mm3
;wsptr
[DCTSIZE
*6]
887 paddw mm4
, [esi
+8*4] ;wsptr
[DCTSIZE
*4] = (int) (tmp3
+ tmp4
);
889 psubw mm1
, [esi
+8*4] ;wsptr
[DCTSIZE
*3] = (int) (tmp3
- tmp4
);
891 movq
[esi
+ 8*8], mm4
892 movq mm7
, mm5
;copy tmp2
894 paddw mm5
, mm6
;wsptr
[DCTSIZE
*2] = (int) (tmp2
+ tmp5
)
896 movq
[esi
+8*6], mm1
;
897 psubw mm7
, mm6
;wsptr
[DCTSIZE
*5] = (int) (tmp2
- tmp5
);
899 movq
[esi
+ 8*4], mm5
901 movq
[esi
+ 8*10], mm7
906 /*****************************************************************/
908 /* Pass 2: process rows from work array, store into output array. */
909 /* Note that we must descale the results by a factor of 8 == 2**3, */
910 /* and also undo the PASS1_BITS scaling. */
912 /*****************************************************************/
918 // tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
919 // tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
920 // tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
921 // tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]);
922 movq mm0
, [esi
+8*0] ;wsptr
[0,0],[0,1],[0,2],[0,3]
924 movq mm1
, [esi
+8*1] ;wsptr
[0,4],[0,5],[0,6],[0,7]
927 movq mm3
, [esi
+8*2] ;wsptr
[1,0],[1,1],[1,2],[1,3]
928 paddw mm0
, mm1
;wsptr
[0,tmp10
],[xxx
],[0,tmp13
],[xxx
]
930 movq mm4
, [esi
+8*3] ;wsptr
[1,4],[1,5],[1,6],[1,7]
931 psubw mm2
, mm1
;wsptr
[0,tmp11
],[xxx
],[0,tmp14
],[xxx
]
936 paddw mm3
, mm4
;wsptr
[1,tmp10
],[xxx
],[1,tmp13
],[xxx
]
939 psubw mm5
, mm4
;wsptr
[1,tmp11
],[xxx
],[1,tmp14
],[xxx
]
940 punpcklwd mm0
, mm3
;wsptr
[0,tmp10
],[1,tmp10
],[xxx
],[xxx
]
942 movq mm7
, [esi
+8*7] ;wsptr
[3,4],[3,5],[3,6],[3,7]
943 punpckhwd mm6
, mm3
;wsptr
[0,tmp13
],[1,tmp13
],[xxx
],[xxx
]
945 movq mm3
, [esi
+8*4] ;wsptr
[2,0],[2,1],[2,2],[2,3]
946 punpckldq mm0
, mm6
;wsptr
[0,tmp10
],[1,tmp10
],[0,tmp13
],[1,tmp13
]
948 punpcklwd mm1
, mm5
;wsptr
[0,tmp11
],[1,tmp11
],[xxx
],[xxx
]
951 movq mm6
, [esi
+8*6] ;wsptr
[3,0],[3,1],[3,2],[3,3]
952 punpckhwd mm2
, mm5
;wsptr
[0,tmp14
],[1,tmp14
],[xxx
],[xxx
]
954 movq mm5
, [esi
+8*5] ;wsptr
[2,4],[2,5],[2,6],[2,7]
955 punpckldq mm1
, mm2
;wsptr
[0,tmp11
],[1,tmp11
],[0,tmp14
],[1,tmp14
]
958 paddw mm3
, mm5
;wsptr
[2,tmp10
],[xxx
],[2,tmp13
],[xxx
]
961 psubw mm4
, mm5
;wsptr
[2,tmp11
],[xxx
],[2,tmp14
],[xxx
]
962 paddw mm6
, mm7
;wsptr
[3,tmp10
],[xxx
],[3,tmp13
],[xxx
]
965 punpcklwd mm3
, mm6
;wsptr
[2,tmp10
],[3,tmp10
],[xxx
],[xxx
]
967 psubw mm2
, mm7
;wsptr
[3,tmp11
],[xxx
],[3,tmp14
],[xxx
]
968 punpckhwd mm5
, mm6
;wsptr
[2,tmp13
],[3,tmp13
],[xxx
],[xxx
]
971 punpckldq mm3
, mm5
;wsptr
[2,tmp10
],[3,tmp10
],[2,tmp13
],[3,tmp13
]
973 punpcklwd mm4
, mm2
;wsptr
[2,tmp11
],[3,tmp11
],[xxx
],[xxx
]
975 punpckhwd mm7
, mm2
;wsptr
[2,tmp14
],[3,tmp14
],[xxx
],[xxx
]
977 punpckldq mm4
, mm7
;wsptr
[2,tmp11
],[3,tmp11
],[2,tmp14
],[3,tmp14
]
980 // mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13]
981 // mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14]
985 punpckhdq mm6
, mm4
;wsptr
[0,tmp14
],[1,tmp14
],[2,tmp14
],[3,tmp14
]
987 punpckldq mm1
, mm4
;wsptr
[0,tmp11
],[1,tmp11
],[2,tmp11
],[3,tmp11
]
991 punpckldq mm0
, mm3
;wsptr
[0,tmp10
],[1,tmp10
],[2,tmp10
],[3,tmp10
]
993 punpckhdq mm2
, mm3
;wsptr
[0,tmp13
],[1,tmp13
],[2,tmp13
],[3,tmp13
]
996 // tmp0 = tmp10 + tmp13;
997 // tmp3 = tmp10 - tmp13;
998 paddw mm0
, mm2
;[0,tmp0
],[1,tmp0
],[2,tmp0
],[3,tmp0
]
999 psubw mm7
, mm2
;[0,tmp3
],[1,tmp3
],[2,tmp3
],[3,tmp3
]
1001 // tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13;
1002 psubw mm6
, mm2
;wsptr
[0,tmp12
],[1,tmp12
],[2,tmp12
],[3,tmp12
]
1003 // tmp1 = tmp11 + tmp12;
1004 // tmp2 = tmp11 - tmp12;
1011 // z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];
1012 // z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];
1013 // z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
1014 // z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];
1015 movq mm3
, [esi
+8*0] ;wsptr
[0,0],[0,1],[0,2],[0,3]
1016 paddw mm1
, mm6
;[0,tmp1
],[1,tmp1
],[2,tmp1
],[3,tmp1
]
1018 movq mm4
, [esi
+8*1] ;wsptr
[0,4],[0,5],[0,6],[0,7]
1019 psubw mm5
, mm6
;[0,tmp2
],[1,tmp2
],[2,tmp2
],[3,tmp2
]
1022 punpckldq mm3
, mm4
;wsptr
[0,0],[0,1],[0,4],[0,5]
1024 punpckhdq mm4
, mm6
;wsptr
[0,6],[0,7],[0,2],[0,3]
1027 //Save tmp0 and tmp1 in wsptr
1028 movq
[esi
+8*0], mm0
;save tmp0
1029 paddw mm2
, mm4
;wsptr
[xxx
],[0,z11
],[xxx
],[0,z13
]
1032 //Continue with z10 --- z13
1033 movq mm6
, [esi
+8*2] ;wsptr
[1,0],[1,1],[1,2],[1,3]
1034 psubw mm3
, mm4
;wsptr
[xxx
],[0,z12
],[xxx
],[0,z10
]
1036 movq mm0
, [esi
+8*3] ;wsptr
[1,4],[1,5],[1,6],[1,7]
1039 movq
[esi
+8*1], mm1
;save tmp1
1040 punpckldq mm6
, mm0
;wsptr
[1,0],[1,1],[1,4],[1,5]
1042 punpckhdq mm0
, mm4
;wsptr
[1,6],[1,7],[1,2],[1,3]
1045 //Save tmp2 and tmp3 in wsptr
1046 paddw mm6
, mm0
;wsptr
[xxx
],[1,z11
],[xxx
],[1,z13
]
1049 //Continue with z10 --- z13
1050 movq
[esi
+8*2], mm5
;save tmp2
1051 punpcklwd mm2
, mm6
;wsptr
[xxx
],[xxx
],[0,z11
],[1,z11
]
1053 psubw mm1
, mm0
;wsptr
[xxx
],[1,z12
],[xxx
],[1,z10
]
1054 punpckhwd mm4
, mm6
;wsptr
[xxx
],[xxx
],[0,z13
],[1,z13
]
1057 punpcklwd mm3
, mm1
;wsptr
[xxx
],[xxx
],[0,z12
],[1,z12
]
1059 movq
[esi
+8*3], mm7
;save tmp3
1060 punpckhwd mm0
, mm1
;wsptr
[xxx
],[xxx
],[0,z10
],[1,z10
]
1062 movq mm6
, [esi
+8*4] ;wsptr
[2,0],[2,1],[2,2],[2,3]
1063 punpckhdq mm0
, mm2
;wsptr
[0,z10
],[1,z10
],[0,z11
],[1,z11
]
1065 movq mm7
, [esi
+8*5] ;wsptr
[2,4],[2,5],[2,6],[2,7]
1066 punpckhdq mm3
, mm4
;wsptr
[0,z12
],[1,z12
],[0,z13
],[1,z13
]
1068 movq mm1
, [esi
+8*6] ;wsptr
[3,0],[3,1],[3,2],[3,3]
1071 punpckldq mm6
, mm7
;wsptr
[2,0],[2,1],[2,4],[2,5]
1074 punpckhdq mm7
, mm4
;wsptr
[2,6],[2,7],[2,2],[2,3]
1077 movq mm4
, [esi
+8*7] ;wsptr
[3,4],[3,5],[3,6],[3,7]
1078 paddw mm6
, mm7
;wsptr
[xxx
],[2,z11
],[xxx
],[2,z13
]
1080 psubw mm2
, mm7
;wsptr
[xxx
],[2,z12
],[xxx
],[2,z10
]
1081 punpckldq mm1
, mm4
;wsptr
[3,0],[3,1],[3,4],[3,5]
1083 punpckhdq mm4
, mm5
;wsptr
[3,6],[3,7],[3,2],[3,3]
1086 paddw mm1
, mm4
;wsptr
[xxx
],[3,z11
],[xxx
],[3,z13
]
1087 psubw mm7
, mm4
;wsptr
[xxx
],[3,z12
],[xxx
],[3,z10
]
1090 punpcklwd mm6
, mm1
;wsptr
[xxx
],[xxx
],[2,z11
],[3,z11
]
1092 punpckhwd mm5
, mm1
;wsptr
[xxx
],[xxx
],[2,z13
],[3,z13
]
1095 punpcklwd mm2
, mm7
;wsptr
[xxx
],[xxx
],[2,z12
],[3,z12
]
1097 punpckhwd mm4
, mm7
;wsptr
[xxx
],[xxx
],[2,z10
],[3,z10
]
1099 punpckhdq mm4
, mm6
;wsptr
[2,z10
],[3,z10
],[2,z11
],[3,z11
]
1101 punpckhdq mm2
, mm5
;wsptr
[2,z12
],[3,z12
],[2,z13
],[3,z13
]
1104 punpckldq mm0
, mm4
;wsptr
[0,z10
],[1,z10
],[2,z10
],[3,z10
]
1106 punpckhdq mm5
, mm4
;wsptr
[0,z11
],[1,z11
],[2,z11
],[3,z11
]
1109 punpckhdq mm4
, mm2
;wsptr
[0,z13
],[1,z13
],[2,z13
],[3,z13
]
1112 punpckldq mm3
, mm2
;wsptr
[0,z12
],[1,z12
],[2,z12
],[3,z12
]
1113 // tmp7 = z11 + z13; /* phase 5 */
1114 // tmp8 = z11 - z13; /* phase 5 */
1115 psubw mm1
, mm4
;tmp8
1117 paddw mm5
, mm4
;tmp7
1118 // tmp21 = MULTIPLY(tmp8, FIX_1_414213562); /* 2*c4 */
1123 pmulhw mm1
, fix_141
;tmp21
1124 // tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) /* 2*(c2-c6) */
1125 // + MULTIPLY(z10, - FIX_1_847759065); /* 2*c2 */
1129 pmulhw mm7
, fix_n184
1132 movq mm2
, [esi
+8*0] ;tmp0
,final1
1134 pmulhw mm6
, fix_108n184
1135 // tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) /* -2*(c2+c6) */
1136 // + MULTIPLY(z12, FIX_1_847759065); /* 2*c2 */
1137 movq mm4
, mm2
;final1
1139 pmulhw mm0
, fix_184n261
1140 paddw mm2
, mm5
;tmp0
+tmp7
,final1
1143 psubw mm4
, mm5
;tmp0
-tmp7
,final1
1145 // tmp6 = tmp22 - tmp7; /* phase 2 */
1146 psraw mm2
, 5 ;outptr
[0,0],[1,0],[2,0],[3,0],final1
1148 paddsw mm2
, const_0x0080
;final1
1149 paddw mm7
, mm6
;tmp20
1150 psraw mm4
, 5 ;outptr
[0,7],[1,7],[2,7],[3,7],final1
1152 paddsw mm4
, const_0x0080
;final1
1153 paddw mm3
, mm0
;tmp22
1155 // tmp5 = tmp21 - tmp6;
1156 psubw mm3
, mm5
;tmp6
1158 // tmp4 = tmp20 + tmp5;
1159 movq mm0
, [esi
+8*1] ;tmp1
,final2
1160 psubw mm1
, mm3
;tmp5
1162 movq mm6
, mm0
;final2
1163 paddw mm0
, mm3
;tmp1
+tmp6
,final2
1165 /* Final output stage: scale down by a factor of 8 and range-limit */
1168 // outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
1170 // outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
1171 // & RANGE_MASK]; final1
1174 // outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
1176 // outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
1177 // & RANGE_MASK]; final2
1178 psubw mm6
, mm3
;tmp1
-tmp6
,final2
1179 psraw mm0
, 5 ;outptr
[0,1],[1,1],[2,1],[3,1]
1181 paddsw mm0
, const_0x0080
1182 psraw mm6
, 5 ;outptr
[0,6],[1,6],[2,6],[3,6]
1184 paddsw mm6
, const_0x0080
;need to check
this value
1185 packuswb mm0
, mm4
;out
[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7]
1187 movq mm5
, [esi
+8*2] ;tmp2
,final3
1188 packuswb mm2
, mm6
;out
[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6]
1190 // outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
1192 // outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
1193 // & RANGE_MASK]; final3
1194 paddw mm7
, mm1
;tmp4
1197 paddw mm5
, mm1
;tmp2
+tmp5
1198 psubw mm3
, mm1
;tmp2
-tmp5
1200 psraw mm5
, 5 ;outptr
[0,2],[1,2],[2,2],[3,2]
1202 paddsw mm5
, const_0x0080
1203 movq mm4
, [esi
+8*3] ;tmp3
,final4
1204 psraw mm3
, 5 ;outptr
[0,5],[1,5],[2,5],[3,5]
1206 paddsw mm3
, const_0x0080
1209 // outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
1211 // outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
1212 // & RANGE_MASK]; final4
1214 paddw mm4
, mm7
;tmp3
+tmp4
1216 psubw mm6
, mm7
;tmp3
-tmp4
1217 psraw mm4
, 5 ;outptr
[0,4],[1,4],[2,4],[3,4]
1220 paddsw mm4
, const_0x0080
1221 psraw mm6
, 5 ;outptr
[0,3],[1,3],[2,3],[3,3]
1223 paddsw mm6
, const_0x0080
1224 packuswb mm5
, mm4
;out
[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4]
1226 packuswb mm6
, mm3
;out
[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5]
1230 punpcklbw mm2
, mm0
;out
[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1]
1232 punpckhbw mm4
, mm0
;out
[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7]
1235 punpcklbw mm5
, mm6
;out
[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3]
1238 punpckhbw mm7
, mm6
;out
[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]
1240 punpcklwd mm2
, mm5
;out
[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3]
1244 punpckhwd mm1
, mm5
;out
[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]
1247 punpcklwd mm6
, mm4
;out
[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7]
1250 punpckldq mm2
, mm6
;out
[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7]
1256 punpckhwd mm7
, mm4
;out
[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7]
1259 punpckhdq mm0
, mm6
;out
[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]
1266 punpckldq mm1
, mm7
;out
[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7]
1271 punpckhdq mm3
, mm7
;out
[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7]
1279 /*******************************************************************/
1285 /*******************************************************************/
1287 // tmp10 = ((DCTELEM) wsptr[0] + (DCTELEM) wsptr[4]);
1288 // tmp13 = ((DCTELEM) wsptr[2] + (DCTELEM) wsptr[6]);
1289 // tmp11 = ((DCTELEM) wsptr[0] - (DCTELEM) wsptr[4]);
1290 // tmp14 = ((DCTELEM) wsptr[2] - (DCTELEM) wsptr[6]);
1291 movq mm0
, [esi
+8*0] ;wsptr
[0,0],[0,1],[0,2],[0,3]
1293 movq mm1
, [esi
+8*1] ;wsptr
[0,4],[0,5],[0,6],[0,7]
1296 movq mm3
, [esi
+8*2] ;wsptr
[1,0],[1,1],[1,2],[1,3]
1297 paddw mm0
, mm1
;wsptr
[0,tmp10
],[xxx
],[0,tmp13
],[xxx
]
1299 movq mm4
, [esi
+8*3] ;wsptr
[1,4],[1,5],[1,6],[1,7]
1300 psubw mm2
, mm1
;wsptr
[0,tmp11
],[xxx
],[0,tmp14
],[xxx
]
1305 paddw mm3
, mm4
;wsptr
[1,tmp10
],[xxx
],[1,tmp13
],[xxx
]
1308 psubw mm5
, mm4
;wsptr
[1,tmp11
],[xxx
],[1,tmp14
],[xxx
]
1309 punpcklwd mm0
, mm3
;wsptr
[0,tmp10
],[1,tmp10
],[xxx
],[xxx
]
1311 movq mm7
, [esi
+8*7] ;wsptr
[3,4],[3,5],[3,6],[3,7]
1312 punpckhwd mm6
, mm3
;wsptr
[0,tmp13
],[1,tmp13
],[xxx
],[xxx
]
1314 movq mm3
, [esi
+8*4] ;wsptr
[2,0],[2,1],[2,2],[2,3]
1315 punpckldq mm0
, mm6
;wsptr
[0,tmp10
],[1,tmp10
],[0,tmp13
],[1,tmp13
]
1317 punpcklwd mm1
, mm5
;wsptr
[0,tmp11
],[1,tmp11
],[xxx
],[xxx
]
1320 movq mm6
, [esi
+8*6] ;wsptr
[3,0],[3,1],[3,2],[3,3]
1321 punpckhwd mm2
, mm5
;wsptr
[0,tmp14
],[1,tmp14
],[xxx
],[xxx
]
1323 movq mm5
, [esi
+8*5] ;wsptr
[2,4],[2,5],[2,6],[2,7]
1324 punpckldq mm1
, mm2
;wsptr
[0,tmp11
],[1,tmp11
],[0,tmp14
],[1,tmp14
]
1327 paddw mm3
, mm5
;wsptr
[2,tmp10
],[xxx
],[2,tmp13
],[xxx
]
1330 psubw mm4
, mm5
;wsptr
[2,tmp11
],[xxx
],[2,tmp14
],[xxx
]
1331 paddw mm6
, mm7
;wsptr
[3,tmp10
],[xxx
],[3,tmp13
],[xxx
]
1334 punpcklwd mm3
, mm6
;wsptr
[2,tmp10
],[3,tmp10
],[xxx
],[xxx
]
1336 psubw mm2
, mm7
;wsptr
[3,tmp11
],[xxx
],[3,tmp14
],[xxx
]
1337 punpckhwd mm5
, mm6
;wsptr
[2,tmp13
],[3,tmp13
],[xxx
],[xxx
]
1340 punpckldq mm3
, mm5
;wsptr
[2,tmp10
],[3,tmp10
],[2,tmp13
],[3,tmp13
]
1342 punpcklwd mm4
, mm2
;wsptr
[2,tmp11
],[3,tmp11
],[xxx
],[xxx
]
1344 punpckhwd mm7
, mm2
;wsptr
[2,tmp14
],[3,tmp14
],[xxx
],[xxx
]
1346 punpckldq mm4
, mm7
;wsptr
[2,tmp11
],[3,tmp11
],[2,tmp14
],[3,tmp14
]
1349 // mm0 = ;wsptr[0,tmp10],[1,tmp10],[0,tmp13],[1,tmp13]
1350 // mm1 = ;wsptr[0,tmp11],[1,tmp11],[0,tmp14],[1,tmp14]
1354 punpckhdq mm6
, mm4
;wsptr
[0,tmp14
],[1,tmp14
],[2,tmp14
],[3,tmp14
]
1356 punpckldq mm1
, mm4
;wsptr
[0,tmp11
],[1,tmp11
],[2,tmp11
],[3,tmp11
]
1360 punpckldq mm0
, mm3
;wsptr
[0,tmp10
],[1,tmp10
],[2,tmp10
],[3,tmp10
]
1362 punpckhdq mm2
, mm3
;wsptr
[0,tmp13
],[1,tmp13
],[2,tmp13
],[3,tmp13
]
1365 // tmp0 = tmp10 + tmp13;
1366 // tmp3 = tmp10 - tmp13;
1367 paddw mm0
, mm2
;[0,tmp0
],[1,tmp0
],[2,tmp0
],[3,tmp0
]
1368 psubw mm7
, mm2
;[0,tmp3
],[1,tmp3
],[2,tmp3
],[3,tmp3
]
1370 // tmp12 = MULTIPLY(tmp14, FIX_1_414213562) - tmp13;
1371 psubw mm6
, mm2
;wsptr
[0,tmp12
],[1,tmp12
],[2,tmp12
],[3,tmp12
]
1372 // tmp1 = tmp11 + tmp12;
1373 // tmp2 = tmp11 - tmp12;
1380 // z13 = (DCTELEM) wsptr[5] + (DCTELEM) wsptr[3];
1381 // z10 = (DCTELEM) wsptr[5] - (DCTELEM) wsptr[3];
1382 // z11 = (DCTELEM) wsptr[1] + (DCTELEM) wsptr[7];
1383 // z12 = (DCTELEM) wsptr[1] - (DCTELEM) wsptr[7];
1384 movq mm3
, [esi
+8*0] ;wsptr
[0,0],[0,1],[0,2],[0,3]
1385 paddw mm1
, mm6
;[0,tmp1
],[1,tmp1
],[2,tmp1
],[3,tmp1
]
1387 movq mm4
, [esi
+8*1] ;wsptr
[0,4],[0,5],[0,6],[0,7]
1388 psubw mm5
, mm6
;[0,tmp2
],[1,tmp2
],[2,tmp2
],[3,tmp2
]
1391 punpckldq mm3
, mm4
;wsptr
[0,0],[0,1],[0,4],[0,5]
1393 punpckhdq mm4
, mm6
;wsptr
[0,6],[0,7],[0,2],[0,3]
1396 //Save tmp0 and tmp1 in wsptr
1397 movq
[esi
+8*0], mm0
;save tmp0
1398 paddw mm2
, mm4
;wsptr
[xxx
],[0,z11
],[xxx
],[0,z13
]
1401 //Continue with z10 --- z13
1402 movq mm6
, [esi
+8*2] ;wsptr
[1,0],[1,1],[1,2],[1,3]
1403 psubw mm3
, mm4
;wsptr
[xxx
],[0,z12
],[xxx
],[0,z10
]
1405 movq mm0
, [esi
+8*3] ;wsptr
[1,4],[1,5],[1,6],[1,7]
1408 movq
[esi
+8*1], mm1
;save tmp1
1409 punpckldq mm6
, mm0
;wsptr
[1,0],[1,1],[1,4],[1,5]
1411 punpckhdq mm0
, mm4
;wsptr
[1,6],[1,7],[1,2],[1,3]
1414 //Save tmp2 and tmp3 in wsptr
1415 paddw mm6
, mm0
;wsptr
[xxx
],[1,z11
],[xxx
],[1,z13
]
1418 //Continue with z10 --- z13
1419 movq
[esi
+8*2], mm5
;save tmp2
1420 punpcklwd mm2
, mm6
;wsptr
[xxx
],[xxx
],[0,z11
],[1,z11
]
1422 psubw mm1
, mm0
;wsptr
[xxx
],[1,z12
],[xxx
],[1,z10
]
1423 punpckhwd mm4
, mm6
;wsptr
[xxx
],[xxx
],[0,z13
],[1,z13
]
1426 punpcklwd mm3
, mm1
;wsptr
[xxx
],[xxx
],[0,z12
],[1,z12
]
1428 movq
[esi
+8*3], mm7
;save tmp3
1429 punpckhwd mm0
, mm1
;wsptr
[xxx
],[xxx
],[0,z10
],[1,z10
]
1431 movq mm6
, [esi
+8*4] ;wsptr
[2,0],[2,1],[2,2],[2,3]
1432 punpckhdq mm0
, mm2
;wsptr
[0,z10
],[1,z10
],[0,z11
],[1,z11
]
1434 movq mm7
, [esi
+8*5] ;wsptr
[2,4],[2,5],[2,6],[2,7]
1435 punpckhdq mm3
, mm4
;wsptr
[0,z12
],[1,z12
],[0,z13
],[1,z13
]
1437 movq mm1
, [esi
+8*6] ;wsptr
[3,0],[3,1],[3,2],[3,3]
1440 punpckldq mm6
, mm7
;wsptr
[2,0],[2,1],[2,4],[2,5]
1443 punpckhdq mm7
, mm4
;wsptr
[2,6],[2,7],[2,2],[2,3]
1446 movq mm4
, [esi
+8*7] ;wsptr
[3,4],[3,5],[3,6],[3,7]
1447 paddw mm6
, mm7
;wsptr
[xxx
],[2,z11
],[xxx
],[2,z13
]
1449 psubw mm2
, mm7
;wsptr
[xxx
],[2,z12
],[xxx
],[2,z10
]
1450 punpckldq mm1
, mm4
;wsptr
[3,0],[3,1],[3,4],[3,5]
1452 punpckhdq mm4
, mm5
;wsptr
[3,6],[3,7],[3,2],[3,3]
1455 paddw mm1
, mm4
;wsptr
[xxx
],[3,z11
],[xxx
],[3,z13
]
1456 psubw mm7
, mm4
;wsptr
[xxx
],[3,z12
],[xxx
],[3,z10
]
1459 punpcklwd mm6
, mm1
;wsptr
[xxx
],[xxx
],[2,z11
],[3,z11
]
1461 punpckhwd mm5
, mm1
;wsptr
[xxx
],[xxx
],[2,z13
],[3,z13
]
1464 punpcklwd mm2
, mm7
;wsptr
[xxx
],[xxx
],[2,z12
],[3,z12
]
1466 punpckhwd mm4
, mm7
;wsptr
[xxx
],[xxx
],[2,z10
],[3,z10
]
1468 punpckhdq mm4
, mm6
;wsptr
[2,z10
],[3,z10
],[2,z11
],[3,z11
]
1470 punpckhdq mm2
, mm5
;wsptr
[2,z12
],[3,z12
],[2,z13
],[3,z13
]
1473 punpckldq mm0
, mm4
;wsptr
[0,z10
],[1,z10
],[2,z10
],[3,z10
]
1475 punpckhdq mm5
, mm4
;wsptr
[0,z11
],[1,z11
],[2,z11
],[3,z11
]
1478 punpckhdq mm4
, mm2
;wsptr
[0,z13
],[1,z13
],[2,z13
],[3,z13
]
1481 punpckldq mm3
, mm2
;wsptr
[0,z12
],[1,z12
],[2,z12
],[3,z12
]
1482 // tmp7 = z11 + z13; /* phase 5 */
1483 // tmp8 = z11 - z13; /* phase 5 */
1484 psubw mm1
, mm4
;tmp8
1486 paddw mm5
, mm4
;tmp7
1487 // tmp21 = MULTIPLY(tmp8, FIX_1_414213562); /* 2*c4 */
1492 pmulhw mm1
, fix_141
;tmp21
1493 // tmp20 = MULTIPLY(z12, (FIX_1_082392200- FIX_1_847759065)) /* 2*(c2-c6) */
1494 // + MULTIPLY(z10, - FIX_1_847759065); /* 2*c2 */
1498 pmulhw mm7
, fix_n184
1501 movq mm2
, [esi
+8*0] ;tmp0
,final1
1503 pmulhw mm6
, fix_108n184
1504 // tmp22 = MULTIPLY(z10,(FIX_1_847759065 - FIX_2_613125930)) /* -2*(c2+c6) */
1505 // + MULTIPLY(z12, FIX_1_847759065); /* 2*c2 */
1506 movq mm4
, mm2
;final1
1508 pmulhw mm0
, fix_184n261
1509 paddw mm2
, mm5
;tmp0
+tmp7
,final1
1512 psubw mm4
, mm5
;tmp0
-tmp7
,final1
1514 // tmp6 = tmp22 - tmp7; /* phase 2 */
1515 psraw mm2
, 5 ;outptr
[0,0],[1,0],[2,0],[3,0],final1
1517 paddsw mm2
, const_0x0080
;final1
1518 paddw mm7
, mm6
;tmp20
1519 psraw mm4
, 5 ;outptr
[0,7],[1,7],[2,7],[3,7],final1
1521 paddsw mm4
, const_0x0080
;final1
1522 paddw mm3
, mm0
;tmp22
1524 // tmp5 = tmp21 - tmp6;
1525 psubw mm3
, mm5
;tmp6
1527 // tmp4 = tmp20 + tmp5;
1528 movq mm0
, [esi
+8*1] ;tmp1
,final2
1529 psubw mm1
, mm3
;tmp5
1531 movq mm6
, mm0
;final2
1532 paddw mm0
, mm3
;tmp1
+tmp6
,final2
1534 /* Final output stage: scale down by a factor of 8 and range-limit */
1537 // outptr[0] = range_limit[IDESCALE(tmp0 + tmp7, PASS1_BITS+3)
1539 // outptr[7] = range_limit[IDESCALE(tmp0 - tmp7, PASS1_BITS+3)
1540 // & RANGE_MASK]; final1
1543 // outptr[1] = range_limit[IDESCALE(tmp1 + tmp6, PASS1_BITS+3)
1545 // outptr[6] = range_limit[IDESCALE(tmp1 - tmp6, PASS1_BITS+3)
1546 // & RANGE_MASK]; final2
1547 psubw mm6
, mm3
;tmp1
-tmp6
,final2
1548 psraw mm0
, 5 ;outptr
[0,1],[1,1],[2,1],[3,1]
1550 paddsw mm0
, const_0x0080
1551 psraw mm6
, 5 ;outptr
[0,6],[1,6],[2,6],[3,6]
1553 paddsw mm6
, const_0x0080
;need to check
this value
1554 packuswb mm0
, mm4
;out
[0,1],[1,1],[2,1],[3,1],[0,7],[1,7],[2,7],[3,7]
1556 movq mm5
, [esi
+8*2] ;tmp2
,final3
1557 packuswb mm2
, mm6
;out
[0,0],[1,0],[2,0],[3,0],[0,6],[1,6],[2,6],[3,6]
1559 // outptr[2] = range_limit[IDESCALE(tmp2 + tmp5, PASS1_BITS+3)
1561 // outptr[5] = range_limit[IDESCALE(tmp2 - tmp5, PASS1_BITS+3)
1562 // & RANGE_MASK]; final3
1563 paddw mm7
, mm1
;tmp4
1566 paddw mm5
, mm1
;tmp2
+tmp5
1567 psubw mm3
, mm1
;tmp2
-tmp5
1569 psraw mm5
, 5 ;outptr
[0,2],[1,2],[2,2],[3,2]
1571 paddsw mm5
, const_0x0080
1572 movq mm4
, [esi
+8*3] ;tmp3
,final4
1573 psraw mm3
, 5 ;outptr
[0,5],[1,5],[2,5],[3,5]
1575 paddsw mm3
, const_0x0080
1578 // outptr[4] = range_limit[IDESCALE(tmp3 + tmp4, PASS1_BITS+3)
1580 // outptr[3] = range_limit[IDESCALE(tmp3 - tmp4, PASS1_BITS+3)
1581 // & RANGE_MASK]; final4
1583 paddw mm4
, mm7
;tmp3
+tmp4
1585 psubw mm6
, mm7
;tmp3
-tmp4
1586 psraw mm4
, 5 ;outptr
[0,4],[1,4],[2,4],[3,4]
1589 paddsw mm4
, const_0x0080
1590 psraw mm6
, 5 ;outptr
[0,3],[1,3],[2,3],[3,3]
1592 paddsw mm6
, const_0x0080
1593 packuswb mm5
, mm4
;out
[0,2],[1,2],[2,2],[3,2],[0,4],[1,4],[2,4],[3,4]
1595 packuswb mm6
, mm3
;out
[0,3],[1,3],[2,3],[3,3],[0,5],[1,5],[2,5],[3,5]
1599 punpcklbw mm2
, mm0
;out
[0,0],[0,1],[1,0],[1,1],[2,0],[2,1],[3,0],[3,1]
1601 punpckhbw mm4
, mm0
;out
[0,6],[0,7],[1,6],[1,7],[2,6],[2,7],[3,6],[3,7]
1604 punpcklbw mm5
, mm6
;out
[0,2],[0,3],[1,2],[1,3],[2,2],[2,3],[3,2],[3,3]
1607 punpckhbw mm7
, mm6
;out
[0,4],[0,5],[1,4],[1,5],[2,4],[2,5],[3,4],[3,5]
1609 punpcklwd mm2
, mm5
;out
[0,0],[0,1],[0,2],[0,3],[1,0],[1,1],[1,2],[1,3]
1613 punpckhwd mm1
, mm5
;out
[2,0],[2,1],[2,2],[2,3],[3,0],[3,1],[3,2],[3,3]
1616 punpcklwd mm6
, mm4
;out
[0,4],[0,5],[0,6],[0,7],[1,4],[1,5],[1,6],[1,7]
1619 punpckldq mm2
, mm6
;out
[0,0],[0,1],[0,2],[0,3],[0,4],[0,5],[0,6],[0,7]
1625 punpckhwd mm7
, mm4
;out
[2,4],[2,5],[2,6],[2,7],[3,4],[3,5],[3,6],[3,7]
1628 punpckhdq mm0
, mm6
;out
[1,0],[1,1],[1,2],[1,3],[1,4],[1,5],[1,6],[1,7]
1635 punpckldq mm1
, mm7
;out
[2,0],[2,1],[2,2],[2,3],[2,4],[2,5],[2,6],[2,7]
1640 punpckhdq mm3
, mm7
;out
[3,0],[3,1],[3,2],[3,3],[3,4],[3,5],[3,6],[3,7]
1650 #endif /* DCT_IFAST_SUPPORTED */