136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * jidctred.c
336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
48e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC * This file was part of the Independent JPEG Group's software.
55ead57a34a398aa798f35bd7a6abad19b2e453e2Thomas G. Lane * Copyright (C) 1994-1998, Thomas G. Lane.
68e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC * libjpeg-turbo Modifications:
76eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis * Copyright (C) 2015, D. R. Commander.
86eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis * For conditions of distribution and use, see the accompanying README.ijg
96eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis * file.
1036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
1136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * This file contains inverse-DCT routines that produce reduced-size output:
1236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * either 4x4, 2x2, or 1x1 pixels from an 8x8 DCT block.
1336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
1436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * The implementation is based on the Loeffler, Ligtenberg and Moschytz (LL&M)
1536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * algorithm used in jidctint.c.  We simply replace each 8-to-8 1-D IDCT step
1636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * with an 8-to-4 step that produces the four averages of two adjacent outputs
1736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * (or an 8-to-2 step producing two averages of four outputs, for 2x2 output).
1836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * These steps were derived by computing the corresponding values at the end
1936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * of the normal LL&M code, then simplifying as much as possible.
2036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
2136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * 1x1 is trivial: just take the DC coefficient divided by 8.
2236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane *
2336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * See jidctint.c for additional comments.
2436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
2536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
2636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define JPEG_INTERNALS
2736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#include "jinclude.h"
2836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#include "jpeglib.h"
29e5eaf37440b8e337ab150c017df7c03faf846c51DRC#include "jdct.h"               /* Private declarations for DCT subsystem */
3036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
3136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifdef IDCT_SCALING_SUPPORTED
3236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
3336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
3436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
3536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * This module is specialized to the case DCTSIZE = 8.
3636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
3736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
3836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#if DCTSIZE != 8
3936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */
4036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
4136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
4236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
4336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Scaling is the same as in jidctint.c. */
4436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
4536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#if BITS_IN_JSAMPLE == 8
4636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define CONST_BITS  13
4736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define PASS1_BITS  2
4836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else
4936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define CONST_BITS  13
50e5eaf37440b8e337ab150c017df7c03faf846c51DRC#define PASS1_BITS  1           /* lose a little precision to avoid overflow */
5136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
5236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
5336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus
5436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * causing a lot of useless floating-point operations at run time.
5536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * To get around this we use the following pre-calculated constants.
5636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * If you change CONST_BITS you may want to add appropriate values.
5736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * (With a reasonable C compiler, you can just rely on the FIX() macro...)
5836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
5936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
6036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#if CONST_BITS == 13
616eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_211164243  ((JLONG)  1730)        /* FIX(0.211164243) */
626eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_509795579  ((JLONG)  4176)        /* FIX(0.509795579) */
636eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_601344887  ((JLONG)  4926)        /* FIX(0.601344887) */
646eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_720959822  ((JLONG)  5906)        /* FIX(0.720959822) */
656eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_765366865  ((JLONG)  6270)        /* FIX(0.765366865) */
666eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_850430095  ((JLONG)  6967)        /* FIX(0.850430095) */
676eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_0_899976223  ((JLONG)  7373)        /* FIX(0.899976223) */
686eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_1_061594337  ((JLONG)  8697)        /* FIX(1.061594337) */
696eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_1_272758580  ((JLONG)  10426)       /* FIX(1.272758580) */
706eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_1_451774981  ((JLONG)  11893)       /* FIX(1.451774981) */
716eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_1_847759065  ((JLONG)  15137)       /* FIX(1.847759065) */
726eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_2_172734803  ((JLONG)  17799)       /* FIX(2.172734803) */
736eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_2_562915447  ((JLONG)  20995)       /* FIX(2.562915447) */
746eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis#define FIX_3_624509785  ((JLONG)  29692)       /* FIX(3.624509785) */
7536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else
7636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_211164243  FIX(0.211164243)
7736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_509795579  FIX(0.509795579)
7836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_601344887  FIX(0.601344887)
7936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_720959822  FIX(0.720959822)
8036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_765366865  FIX(0.765366865)
8136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_850430095  FIX(0.850430095)
8236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_0_899976223  FIX(0.899976223)
8336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_1_061594337  FIX(1.061594337)
8436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_1_272758580  FIX(1.272758580)
8536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_1_451774981  FIX(1.451774981)
8636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_1_847759065  FIX(1.847759065)
8736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_2_172734803  FIX(2.172734803)
8836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_2_562915447  FIX(2.562915447)
8936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define FIX_3_624509785  FIX(3.624509785)
9036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
9136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
9236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
936eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis/* Multiply a JLONG variable by a JLONG constant to yield a JLONG result.
9436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * For 8-bit samples with the recommended scaling, all the variable
9536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * and constant values involved are no more than 16 bits wide, so a
9636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * 16x16->32 bit multiply can be used instead of a full 32x32 multiply.
9736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * For 12-bit samples, a full 32-bit multiplication will be needed.
9836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
9936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
10036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#if BITS_IN_JSAMPLE == 8
10136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define MULTIPLY(var,const)  MULTIPLY16C16(var,const)
10236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#else
10336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define MULTIPLY(var,const)  ((var) * (const))
10436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
10536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
10636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
10736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/* Dequantize a coefficient by multiplying it by the multiplier-table
10836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * entry; produce an int result.  In this module, both inputs and result
10936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * are 16 bits or less, so either int or short multiply will work.
11036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
11136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
11236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#define DEQUANTIZE(coef,quantval)  (((ISLOW_MULT_TYPE) (coef)) * (quantval))
11336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
11436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
11536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
11636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Perform dequantization and inverse DCT on one block of coefficients,
11736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * producing a reduced-size 4x4 output block.
11836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
11936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
120489583f5165e05d37302e8eeec58104ea0109127Thomas G. LaneGLOBAL(void)
1216eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidisjpeg_idct_4x4 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
122e5eaf37440b8e337ab150c017df7c03faf846c51DRC               JCOEFPTR coef_block,
123e5eaf37440b8e337ab150c017df7c03faf846c51DRC               JSAMPARRAY output_buf, JDIMENSION output_col)
12436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane{
1256eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  JLONG tmp0, tmp2, tmp10, tmp12;
1266eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  JLONG z1, z2, z3, z4;
12736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JCOEFPTR inptr;
1286eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  ISLOW_MULT_TYPE *quantptr;
1296eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  int *wsptr;
13036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JSAMPROW outptr;
13136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
13236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  int ctr;
133e5eaf37440b8e337ab150c017df7c03faf846c51DRC  int workspace[DCTSIZE*4];     /* buffers data between passes */
13436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  SHIFT_TEMPS
13536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
13636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  /* Pass 1: process columns from input, store into work array. */
13736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
13836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  inptr = coef_block;
13936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
14036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  wsptr = workspace;
14136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
14236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Don't bother to process column 4, because second pass won't use it */
14336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    if (ctr == DCTSIZE-4)
14436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      continue;
1455ead57a34a398aa798f35bd7a6abad19b2e453e2Thomas G. Lane    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
146e5eaf37440b8e337ab150c017df7c03faf846c51DRC        inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*5] == 0 &&
147e5eaf37440b8e337ab150c017df7c03faf846c51DRC        inptr[DCTSIZE*6] == 0 && inptr[DCTSIZE*7] == 0) {
14836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      /* AC terms all zero; we need not examine term 4 for 4x4 output */
1498e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC      int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
1508e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC                             PASS1_BITS);
151e5eaf37440b8e337ab150c017df7c03faf846c51DRC
15236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      wsptr[DCTSIZE*0] = dcval;
15336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      wsptr[DCTSIZE*1] = dcval;
15436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      wsptr[DCTSIZE*2] = dcval;
15536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      wsptr[DCTSIZE*3] = dcval;
156e5eaf37440b8e337ab150c017df7c03faf846c51DRC
15736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      continue;
15836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    }
159e5eaf37440b8e337ab150c017df7c03faf846c51DRC
16036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Even part */
161e5eaf37440b8e337ab150c017df7c03faf846c51DRC
16236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
1638e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC    tmp0 = LEFT_SHIFT(tmp0, CONST_BITS+1);
164e5eaf37440b8e337ab150c017df7c03faf846c51DRC
16536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z2 = DEQUANTIZE(inptr[DCTSIZE*2], quantptr[DCTSIZE*2]);
16636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z3 = DEQUANTIZE(inptr[DCTSIZE*6], quantptr[DCTSIZE*6]);
16736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
16836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp2 = MULTIPLY(z2, FIX_1_847759065) + MULTIPLY(z3, - FIX_0_765366865);
169e5eaf37440b8e337ab150c017df7c03faf846c51DRC
17036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp10 = tmp0 + tmp2;
17136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp12 = tmp0 - tmp2;
172e5eaf37440b8e337ab150c017df7c03faf846c51DRC
17336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Odd part */
174e5eaf37440b8e337ab150c017df7c03faf846c51DRC
17536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
17636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z2 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
17736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z3 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
17836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z4 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
179e5eaf37440b8e337ab150c017df7c03faf846c51DRC
18036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
181e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
182e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
183e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
184e5eaf37440b8e337ab150c017df7c03faf846c51DRC
18536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
186e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
187e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
188e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
18936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
19036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Final output stage */
191e5eaf37440b8e337ab150c017df7c03faf846c51DRC
19236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp2, CONST_BITS-PASS1_BITS+1);
19336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    wsptr[DCTSIZE*3] = (int) DESCALE(tmp10 - tmp2, CONST_BITS-PASS1_BITS+1);
19436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    wsptr[DCTSIZE*1] = (int) DESCALE(tmp12 + tmp0, CONST_BITS-PASS1_BITS+1);
19536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    wsptr[DCTSIZE*2] = (int) DESCALE(tmp12 - tmp0, CONST_BITS-PASS1_BITS+1);
19636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  }
197e5eaf37440b8e337ab150c017df7c03faf846c51DRC
19836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  /* Pass 2: process 4 rows from work array, store into output array. */
19936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
20036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  wsptr = workspace;
20136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  for (ctr = 0; ctr < 4; ctr++) {
20236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr = output_buf[ctr] + output_col;
20336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* It's not clear whether a zero row test is worthwhile here ... */
20436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
20536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifndef NO_ZERO_ROW_TEST
2065ead57a34a398aa798f35bd7a6abad19b2e453e2Thomas G. Lane    if (wsptr[1] == 0 && wsptr[2] == 0 && wsptr[3] == 0 &&
207e5eaf37440b8e337ab150c017df7c03faf846c51DRC        wsptr[5] == 0 && wsptr[6] == 0 && wsptr[7] == 0) {
20836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      /* AC terms all zero */
2096eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis      JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
210e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                  & RANGE_MASK];
211e5eaf37440b8e337ab150c017df7c03faf846c51DRC
21236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      outptr[0] = dcval;
21336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      outptr[1] = dcval;
21436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      outptr[2] = dcval;
21536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      outptr[3] = dcval;
216e5eaf37440b8e337ab150c017df7c03faf846c51DRC
217e5eaf37440b8e337ab150c017df7c03faf846c51DRC      wsptr += DCTSIZE;         /* advance pointer to next row */
21836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      continue;
21936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    }
22036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
221e5eaf37440b8e337ab150c017df7c03faf846c51DRC
22236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Even part */
223e5eaf37440b8e337ab150c017df7c03faf846c51DRC
2246eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    tmp0 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+1);
225e5eaf37440b8e337ab150c017df7c03faf846c51DRC
2266eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    tmp2 = MULTIPLY((JLONG) wsptr[2], FIX_1_847759065)
2276eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis         + MULTIPLY((JLONG) wsptr[6], - FIX_0_765366865);
228e5eaf37440b8e337ab150c017df7c03faf846c51DRC
22936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp10 = tmp0 + tmp2;
23036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp12 = tmp0 - tmp2;
231e5eaf37440b8e337ab150c017df7c03faf846c51DRC
23236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Odd part */
233e5eaf37440b8e337ab150c017df7c03faf846c51DRC
2346eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    z1 = (JLONG) wsptr[7];
2356eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    z2 = (JLONG) wsptr[5];
2366eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    z3 = (JLONG) wsptr[3];
2376eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    z4 = (JLONG) wsptr[1];
238e5eaf37440b8e337ab150c017df7c03faf846c51DRC
23936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 = MULTIPLY(z1, - FIX_0_211164243) /* sqrt(2) * (c3-c1) */
240e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z2, FIX_1_451774981) /* sqrt(2) * (c3+c7) */
241e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z3, - FIX_2_172734803) /* sqrt(2) * (-c1-c5) */
242e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z4, FIX_1_061594337); /* sqrt(2) * (c5+c7) */
243e5eaf37440b8e337ab150c017df7c03faf846c51DRC
24436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp2 = MULTIPLY(z1, - FIX_0_509795579) /* sqrt(2) * (c7-c5) */
245e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z2, - FIX_0_601344887) /* sqrt(2) * (c5-c1) */
246e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z3, FIX_0_899976223) /* sqrt(2) * (c3-c7) */
247e5eaf37440b8e337ab150c017df7c03faf846c51DRC         + MULTIPLY(z4, FIX_2_562915447); /* sqrt(2) * (c1+c3) */
24836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
24936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Final output stage */
250e5eaf37440b8e337ab150c017df7c03faf846c51DRC
25136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp2,
252e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                          CONST_BITS+PASS1_BITS+3+1)
253e5eaf37440b8e337ab150c017df7c03faf846c51DRC                            & RANGE_MASK];
25436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr[3] = range_limit[(int) DESCALE(tmp10 - tmp2,
255e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                          CONST_BITS+PASS1_BITS+3+1)
256e5eaf37440b8e337ab150c017df7c03faf846c51DRC                            & RANGE_MASK];
25736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr[1] = range_limit[(int) DESCALE(tmp12 + tmp0,
258e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                          CONST_BITS+PASS1_BITS+3+1)
259e5eaf37440b8e337ab150c017df7c03faf846c51DRC                            & RANGE_MASK];
26036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr[2] = range_limit[(int) DESCALE(tmp12 - tmp0,
261e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                          CONST_BITS+PASS1_BITS+3+1)
262e5eaf37440b8e337ab150c017df7c03faf846c51DRC                            & RANGE_MASK];
263e5eaf37440b8e337ab150c017df7c03faf846c51DRC
264e5eaf37440b8e337ab150c017df7c03faf846c51DRC    wsptr += DCTSIZE;           /* advance pointer to next row */
26536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  }
26636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane}
26736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
26836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
26936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
27036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Perform dequantization and inverse DCT on one block of coefficients,
27136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * producing a reduced-size 2x2 output block.
27236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
27336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
274489583f5165e05d37302e8eeec58104ea0109127Thomas G. LaneGLOBAL(void)
2756eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidisjpeg_idct_2x2 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
276e5eaf37440b8e337ab150c017df7c03faf846c51DRC               JCOEFPTR coef_block,
277e5eaf37440b8e337ab150c017df7c03faf846c51DRC               JSAMPARRAY output_buf, JDIMENSION output_col)
27836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane{
2796eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  JLONG tmp0, tmp10, z1;
28036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JCOEFPTR inptr;
2816eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  ISLOW_MULT_TYPE *quantptr;
2826eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  int *wsptr;
28336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JSAMPROW outptr;
28436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
28536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  int ctr;
286e5eaf37440b8e337ab150c017df7c03faf846c51DRC  int workspace[DCTSIZE*2];     /* buffers data between passes */
28736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  SHIFT_TEMPS
28836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
28936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  /* Pass 1: process columns from input, store into work array. */
29036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
29136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  inptr = coef_block;
29236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
29336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  wsptr = workspace;
29436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  for (ctr = DCTSIZE; ctr > 0; inptr++, quantptr++, wsptr++, ctr--) {
29536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Don't bother to process columns 2,4,6 */
29636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    if (ctr == DCTSIZE-2 || ctr == DCTSIZE-4 || ctr == DCTSIZE-6)
29736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      continue;
2985ead57a34a398aa798f35bd7a6abad19b2e453e2Thomas G. Lane    if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*3] == 0 &&
299e5eaf37440b8e337ab150c017df7c03faf846c51DRC        inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*7] == 0) {
30036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      /* AC terms all zero; we need not examine terms 2,4,6 for 2x2 output */
3018e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC      int dcval = LEFT_SHIFT(DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]),
3028e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC                             PASS1_BITS);
303e5eaf37440b8e337ab150c017df7c03faf846c51DRC
30436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      wsptr[DCTSIZE*0] = dcval;
30536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      wsptr[DCTSIZE*1] = dcval;
306e5eaf37440b8e337ab150c017df7c03faf846c51DRC
30736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      continue;
30836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    }
309e5eaf37440b8e337ab150c017df7c03faf846c51DRC
31036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Even part */
311e5eaf37440b8e337ab150c017df7c03faf846c51DRC
31236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z1 = DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
3138e9cef2e6f5156c4b055a04a8f979b7291fc6b7aDRC    tmp10 = LEFT_SHIFT(z1, CONST_BITS+2);
314e5eaf37440b8e337ab150c017df7c03faf846c51DRC
31536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Odd part */
31636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
31736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z1 = DEQUANTIZE(inptr[DCTSIZE*7], quantptr[DCTSIZE*7]);
31836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 = MULTIPLY(z1, - FIX_0_720959822); /* sqrt(2) * (c7-c5+c3-c1) */
31936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z1 = DEQUANTIZE(inptr[DCTSIZE*5], quantptr[DCTSIZE*5]);
32036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 += MULTIPLY(z1, FIX_0_850430095); /* sqrt(2) * (-c1+c3+c5+c7) */
32136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z1 = DEQUANTIZE(inptr[DCTSIZE*3], quantptr[DCTSIZE*3]);
32236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 += MULTIPLY(z1, - FIX_1_272758580); /* sqrt(2) * (-c1+c3-c5-c7) */
32336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    z1 = DEQUANTIZE(inptr[DCTSIZE*1], quantptr[DCTSIZE*1]);
32436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    tmp0 += MULTIPLY(z1, FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
32536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
32636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Final output stage */
327e5eaf37440b8e337ab150c017df7c03faf846c51DRC
32836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    wsptr[DCTSIZE*0] = (int) DESCALE(tmp10 + tmp0, CONST_BITS-PASS1_BITS+2);
32936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    wsptr[DCTSIZE*1] = (int) DESCALE(tmp10 - tmp0, CONST_BITS-PASS1_BITS+2);
33036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  }
331e5eaf37440b8e337ab150c017df7c03faf846c51DRC
33236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  /* Pass 2: process 2 rows from work array, store into output array. */
33336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
33436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  wsptr = workspace;
33536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  for (ctr = 0; ctr < 2; ctr++) {
33636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr = output_buf[ctr] + output_col;
33736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* It's not clear whether a zero row test is worthwhile here ... */
33836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
33936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#ifndef NO_ZERO_ROW_TEST
3405ead57a34a398aa798f35bd7a6abad19b2e453e2Thomas G. Lane    if (wsptr[1] == 0 && wsptr[3] == 0 && wsptr[5] == 0 && wsptr[7] == 0) {
34136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      /* AC terms all zero */
3426eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis      JSAMPLE dcval = range_limit[(int) DESCALE((JLONG) wsptr[0], PASS1_BITS+3)
343e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                  & RANGE_MASK];
344e5eaf37440b8e337ab150c017df7c03faf846c51DRC
34536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      outptr[0] = dcval;
34636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      outptr[1] = dcval;
347e5eaf37440b8e337ab150c017df7c03faf846c51DRC
348e5eaf37440b8e337ab150c017df7c03faf846c51DRC      wsptr += DCTSIZE;         /* advance pointer to next row */
34936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane      continue;
35036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    }
35136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif
352e5eaf37440b8e337ab150c017df7c03faf846c51DRC
35336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Even part */
354e5eaf37440b8e337ab150c017df7c03faf846c51DRC
3556eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    tmp10 = LEFT_SHIFT((JLONG) wsptr[0], CONST_BITS+2);
356e5eaf37440b8e337ab150c017df7c03faf846c51DRC
35736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Odd part */
35836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
3596eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis    tmp0 = MULTIPLY((JLONG) wsptr[7], - FIX_0_720959822) /* sqrt(2) * (c7-c5+c3-c1) */
3606eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis         + MULTIPLY((JLONG) wsptr[5], FIX_0_850430095) /* sqrt(2) * (-c1+c3+c5+c7) */
3616eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis         + MULTIPLY((JLONG) wsptr[3], - FIX_1_272758580) /* sqrt(2) * (-c1+c3-c5-c7) */
3626eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis         + MULTIPLY((JLONG) wsptr[1], FIX_3_624509785); /* sqrt(2) * (c1+c3+c5+c7) */
36336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
36436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    /* Final output stage */
365e5eaf37440b8e337ab150c017df7c03faf846c51DRC
36636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr[0] = range_limit[(int) DESCALE(tmp10 + tmp0,
367e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                          CONST_BITS+PASS1_BITS+3+2)
368e5eaf37440b8e337ab150c017df7c03faf846c51DRC                            & RANGE_MASK];
36936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane    outptr[1] = range_limit[(int) DESCALE(tmp10 - tmp0,
370e5eaf37440b8e337ab150c017df7c03faf846c51DRC                                          CONST_BITS+PASS1_BITS+3+2)
371e5eaf37440b8e337ab150c017df7c03faf846c51DRC                            & RANGE_MASK];
372e5eaf37440b8e337ab150c017df7c03faf846c51DRC
373e5eaf37440b8e337ab150c017df7c03faf846c51DRC    wsptr += DCTSIZE;           /* advance pointer to next row */
37436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  }
37536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane}
37636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
37736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
37836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane/*
37936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * Perform dequantization and inverse DCT on one block of coefficients,
38036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane * producing a reduced-size 1x1 output block.
38136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane */
38236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
383489583f5165e05d37302e8eeec58104ea0109127Thomas G. LaneGLOBAL(void)
3846eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidisjpeg_idct_1x1 (j_decompress_ptr cinfo, jpeg_component_info *compptr,
385e5eaf37440b8e337ab150c017df7c03faf846c51DRC               JCOEFPTR coef_block,
386e5eaf37440b8e337ab150c017df7c03faf846c51DRC               JSAMPARRAY output_buf, JDIMENSION output_col)
38736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane{
38836a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  int dcval;
3896eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  ISLOW_MULT_TYPE *quantptr;
39036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  JSAMPLE *range_limit = IDCT_range_limit(cinfo);
39136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  SHIFT_TEMPS
39236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
39336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  /* We hardly need an inverse DCT routine for this: just take the
39436a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane   * average pixel value, which is one-eighth of the DC coefficient.
39536a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane   */
39636a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  quantptr = (ISLOW_MULT_TYPE *) compptr->dct_table;
39736a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  dcval = DEQUANTIZE(coef_block[0], quantptr[0]);
3986eb7d3798b5a79347c62825fc4c16f7ce673bdd0Alex Naidis  dcval = (int) DESCALE((JLONG) dcval, 3);
39936a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
40036a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane  output_buf[0][output_col] = range_limit[dcval & RANGE_MASK];
40136a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane}
40236a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane
40336a4ccccd33f5cc9df62949554af87129ced7f84Thomas G. Lane#endif /* IDCT_SCALING_SUPPORTED */
404