0N/A * reserved comment block 0N/A * DO NOT REMOVE OR ALTER! 0N/A * Copyright (C) 1994-1996, Thomas G. Lane. 0N/A * This file is part of the Independent JPEG Group's software. 0N/A * For conditions of distribution and use, see the accompanying README file. 0N/A * This file contains the forward-DCT management logic. 0N/A * This code selects a particular DCT implementation to be used, 0N/A * and it performs related housekeeping chores including coefficient 0N/A#
include "jdct.h" /* Private declarations for DCT subsystem */ 0N/A/* Private subobject for this module */ 0N/A /* Pointer to the DCT routine actually in use */ 0N/A /* The actual post-DCT divisors --- not identical to the quant table 0N/A * entries, because of scaling (especially for an unnormalized DCT). 0N/A * Each table is given in normal array order. 0N/A /* Same as above for the floating-point case. */ 0N/A * Initialize for a processing pass. 0N/A * Verify that all referenced Q-tables are present, and set up 0N/A * the divisor table for each one. 0N/A * In the current implementation, DCT of all components is done during 0N/A * the first pass, even if only some components will be output in the 0N/A * first scan. Hence all components should be examined here. 0N/A /* Make sure specified quantization table is present */ 0N/A /* Compute divisors for this quant table */ 0N/A /* We may do this more than once for same table, but it's not a big deal */ 0N/A /* For LL&M IDCT method, divisors are equal to raw quantization 0N/A * coefficients multiplied by 8 (to counteract scaling). 0N/A /* For AA&N IDCT method, divisors are equal to quantization 0N/A * coefficients scaled by scalefactor[row]*scalefactor[col], where 0N/A * scalefactor[0] = 1 0N/A * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 0N/A * We apply a further scale factor of 8. 0N/A /* precomputed values scaled up by 14 bits */ 0N/A 16384,
22725,
21407,
19266,
16384,
12873,
8867,
4520,
0N/A 22725,
31521,
29692,
26722,
22725,
17855,
12299,
6270,
0N/A 21407,
29692,
27969,
25172,
21407,
16819,
11585,
5906,
0N/A 19266,
26722,
25172,
22654,
19266,
15137,
10426,
5315,
0N/A 16384,
22725,
21407,
19266,
16384,
12873,
8867,
4520,
0N/A 12873,
17855,
16819,
15137,
12873,
10114,
6967,
3552,
0N/A 8867,
12299,
11585,
10426,
8867,
6967,
4799,
2446,
0N/A 4520,
6270,
5906,
5315,
4520,
3552,
2446,
1247 0N/A /* For float AA&N IDCT method, divisors are equal to quantization 0N/A * coefficients scaled by scalefactor[row]*scalefactor[col], where 0N/A * scalefactor[0] = 1 0N/A * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 0N/A * We apply a further scale factor of 8. 0N/A * What's actually stored is 1/divisor so that the inner loop can 0N/A * use a multiplication rather than a division. 0N/A 1.0,
1.387039845,
1.306562965,
1.175875602,
0N/A 1.0,
0.785694958,
0.541196100,
0.275899379 0N/A * Perform forward DCT on one or more blocks of a component. 0N/A * The input samples are taken from the sample_data[] array starting at 0N/A * blocks. The quantized coefficients are returned in coef_blocks[]. 0N/A/* This version is used for integer DCT implementations. */ 0N/A /* This routine is heavily used, so it's worth coding it tightly. */ 0N/A /* Load data into workspace, applying unsigned->signed conversion */ 0N/A /* Perform the DCT */ 0N/A /* Divide the coefficient value by qval, ensuring proper rounding. 0N/A * Since C does not specify the direction of rounding for negative 0N/A * quotients, we have to force the dividend positive for portability. 0N/A * In most files, at least half of the output values will be zero 0N/A * (at default quantization settings, more like three-quarters...) 0N/A * so we should ensure that this case is fast. On many machines, 0N/A * a comparison is enough cheaper than a divide to make a special test 0N/A * a win. Since both inputs will be nonnegative, we need only test 0N/A * for a < b to discover whether a/b is 0. 0N/A * If your machine's division is fast enough, define FAST_DIVIDE. 0N/A/* This version is used for floating-point DCT implementations. */ 0N/A /* This routine is heavily used, so it's worth coding it tightly. */ 0N/A /* Load data into workspace, applying unsigned->signed conversion */ 0N/A /* Perform the DCT */ 0N/A /* Apply the quantization and scaling factor */ 0N/A /* Round to nearest integer. 0N/A * Since C does not specify the direction of rounding for negative 0N/A * quotients, we have to force the dividend positive for portability. 0N/A * The maximum coefficient size is +-16K (for 12-bit data), so this 0N/A * code should work for either 16-bit or 32-bit ints. 0N/A#
endif /* DCT_FLOAT_SUPPORTED */ 0N/A * Initialize FDCT manager. 0N/A /* Mark divisor tables unallocated */