/src/libjpeg-turbo.dev/src/jcdctmgr.c
Line | Count | Source |
1 | | /* |
2 | | * jcdctmgr.c |
3 | | * |
4 | | * This file was part of the Independent JPEG Group's software: |
5 | | * Copyright (C) 1994-1996, Thomas G. Lane. |
6 | | * libjpeg-turbo Modifications: |
7 | | * Copyright (C) 1999-2006, MIYASAKA Masaru. |
8 | | * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB |
9 | | * Copyright (C) 2011, 2014-2015, 2022, 2024-2026, D. R. Commander. |
10 | | * For conditions of distribution and use, see the accompanying README.ijg |
11 | | * file. |
12 | | * |
13 | | * This file contains the forward-DCT management logic. |
14 | | * This code selects a particular DCT implementation to be used, |
15 | | * and it performs related housekeeping chores including coefficient |
16 | | * quantization. |
17 | | */ |
18 | | |
19 | | #define JPEG_INTERNALS |
20 | | #include "jinclude.h" |
21 | | #include "jpeglib.h" |
22 | | #include "jdct.h" /* Private declarations for DCT subsystem */ |
23 | | #ifdef WITH_SIMD |
24 | | #include "../simd/jsimddct.h" |
25 | | #endif |
26 | | #ifdef WITH_PROFILE |
27 | | #include "tjutil.h" |
28 | | #endif |
29 | | |
30 | | |
31 | | /* Private subobject for this module */ |
32 | | |
33 | | METHODDEF(void) quantize(JCOEFPTR, DCTELEM *, DCTELEM *); |
34 | | |
35 | | typedef struct { |
36 | | struct jpeg_forward_dct pub; /* public fields */ |
37 | | |
38 | | /* Pointer to the DCT routine actually in use */ |
39 | | forward_DCT_method_ptr dct; |
40 | | convsamp_method_ptr convsamp; |
41 | | quantize_method_ptr quantize; |
42 | | |
43 | | /* The actual post-DCT divisors --- not identical to the quant table |
44 | | * entries, because of scaling (especially for an unnormalized DCT). |
45 | | * Each table is given in normal array order. |
46 | | */ |
47 | | DCTELEM *divisors[NUM_QUANT_TBLS]; |
48 | | |
49 | | /* work area for FDCT subroutine */ |
50 | | DCTELEM *workspace; |
51 | | |
52 | | #ifdef DCT_FLOAT_SUPPORTED |
53 | | /* Same as above for the floating-point case. */ |
54 | | float_DCT_method_ptr float_dct; |
55 | | float_convsamp_method_ptr float_convsamp; |
56 | | float_quantize_method_ptr float_quantize; |
57 | | FAST_FLOAT *float_divisors[NUM_QUANT_TBLS]; |
58 | | FAST_FLOAT *float_workspace; |
59 | | #endif |
60 | | } my_fdct_controller; |
61 | | |
62 | | typedef my_fdct_controller *my_fdct_ptr; |
63 | | |
64 | | |
65 | | #if BITS_IN_JSAMPLE == 8 |
66 | | |
67 | | /* |
68 | | * Find the highest bit in an integer through binary search. |
69 | | */ |
70 | | |
71 | | LOCAL(int) |
72 | | flss(UINT16 val) |
73 | 1.47M | { |
74 | 1.47M | int bit; |
75 | | |
76 | 1.47M | bit = 16; |
77 | | |
78 | 1.47M | if (!val) |
79 | 0 | return 0; |
80 | | |
81 | 1.47M | if (!(val & 0xff00)) { |
82 | 797k | bit -= 8; |
83 | 797k | val <<= 8; |
84 | 797k | } |
85 | 1.47M | if (!(val & 0xf000)) { |
86 | 979k | bit -= 4; |
87 | 979k | val <<= 4; |
88 | 979k | } |
89 | 1.47M | if (!(val & 0xc000)) { |
90 | 729k | bit -= 2; |
91 | 729k | val <<= 2; |
92 | 729k | } |
93 | 1.47M | if (!(val & 0x8000)) { |
94 | 594k | bit -= 1; |
95 | 594k | val <<= 1; |
96 | 594k | } |
97 | | |
98 | 1.47M | return bit; |
99 | 1.47M | } |
100 | | |
101 | | |
102 | | /* |
103 | | * Compute values to do a division using reciprocal. |
104 | | * |
105 | | * This implementation is based on an algorithm described in |
106 | | * "Optimizing subroutines in assembly language: |
107 | | * An optimization guide for x86 platforms" (https://agner.org/optimize). |
108 | | * More information about the basic algorithm can be found in |
109 | | * the paper "Integer Division Using Reciprocals" by Robert Alverson. |
110 | | * |
111 | | * The basic idea is to replace x/d by x * d^-1. In order to store |
112 | | * d^-1 with enough precision we shift it left a few places. It turns |
113 | | * out that this algoright gives just enough precision, and also fits |
114 | | * into DCTELEM: |
115 | | * |
116 | | * b = (the number of significant bits in divisor) - 1 |
117 | | * r = (word size) + b |
118 | | * f = 2^r / divisor |
119 | | * |
120 | | * f will not be an integer for most cases, so we need to compensate |
121 | | * for the rounding error introduced: |
122 | | * |
123 | | * no fractional part: |
124 | | * |
125 | | * result = input >> r |
126 | | * |
127 | | * fractional part of f < 0.5: |
128 | | * |
129 | | * round f down to nearest integer |
130 | | * result = ((input + 1) * f) >> r |
131 | | * |
132 | | * fractional part of f > 0.5: |
133 | | * |
134 | | * round f up to nearest integer |
135 | | * result = (input * f) >> r |
136 | | * |
137 | | * This is the original algorithm that gives truncated results. But we |
138 | | * want properly rounded results, so we replace "input" with |
139 | | * "input + divisor/2". |
140 | | * |
141 | | * In order to allow SIMD implementations we also tweak the values to |
142 | | * allow the same calculation to be made at all times: |
143 | | * |
144 | | * dctbl[0] = f rounded to nearest integer |
145 | | * dctbl[1] = divisor / 2 (+ 1 if fractional part of f < 0.5) |
146 | | * dctbl[2] = 1 << ((word size) * 2 - r) |
147 | | * dctbl[3] = r - (word size) |
148 | | * |
149 | | * dctbl[2] is for stupid instruction sets where the shift operation |
150 | | * isn't member wise (e.g. MMX). |
151 | | * |
152 | | * The reason dctbl[2] and dctbl[3] reduce the shift with (word size) |
153 | | * is that most SIMD implementations have a "multiply and store top |
154 | | * half" operation. |
155 | | * |
156 | | * Lastly, we store each of the values in their own table instead |
157 | | * of in a consecutive manner, yet again in order to allow SIMD |
158 | | * routines. |
159 | | */ |
160 | | |
161 | | LOCAL(int) |
162 | | compute_reciprocal(UINT16 divisor, DCTELEM *dtbl) |
163 | 1.48M | { |
164 | 1.48M | UDCTELEM2 fq, fr; |
165 | 1.48M | UDCTELEM c; |
166 | 1.48M | int b, r; |
167 | | |
168 | 1.48M | if (divisor <= 1) { |
169 | | /* divisor == 1 means unquantized, so these reciprocal/correction/shift |
170 | | * values will cause the C quantization algorithm to act like the |
171 | | * identity function. Since only the C quantization algorithm is used in |
172 | | * these cases, the scale value is irrelevant. |
173 | | * |
174 | | * divisor == 0 can never happen in a normal program, because |
175 | | * jpeg_add_quant_table() clamps values < 1. However, a program could |
176 | | * abuse the API by manually modifying the exposed quantization table just |
177 | | * before calling jpeg_start_compress(). Thus, we effectively clamp |
178 | | * values < 1 here as well, to avoid dividing by 0. |
179 | | */ |
180 | 14.9k | dtbl[DCTSIZE2 * 0] = (DCTELEM)1; /* reciprocal */ |
181 | 14.9k | dtbl[DCTSIZE2 * 1] = (DCTELEM)0; /* correction */ |
182 | 14.9k | dtbl[DCTSIZE2 * 2] = (DCTELEM)1; /* scale */ |
183 | 14.9k | dtbl[DCTSIZE2 * 3] = -(DCTELEM)(sizeof(DCTELEM) * 8); /* shift */ |
184 | 14.9k | return 0; |
185 | 14.9k | } |
186 | | |
187 | 1.47M | b = flss(divisor) - 1; |
188 | 1.47M | r = sizeof(DCTELEM) * 8 + b; |
189 | | |
190 | 1.47M | fq = ((UDCTELEM2)1 << r) / divisor; |
191 | 1.47M | fr = ((UDCTELEM2)1 << r) % divisor; |
192 | | |
193 | 1.47M | c = divisor / 2; /* for rounding */ |
194 | | |
195 | 1.47M | if (fr == 0) { /* divisor is power of two */ |
196 | | /* fq will be one bit too large to fit in DCTELEM, so adjust */ |
197 | 141k | fq >>= 1; |
198 | 141k | r--; |
199 | 1.33M | } else if (fr <= (divisor / 2U)) { /* fractional part is < 0.5 */ |
200 | 489k | c++; |
201 | 841k | } else { /* fractional part is > 0.5 */ |
202 | 841k | fq++; |
203 | 841k | } |
204 | | |
205 | 1.47M | dtbl[DCTSIZE2 * 0] = (DCTELEM)fq; /* reciprocal */ |
206 | 1.47M | dtbl[DCTSIZE2 * 1] = (DCTELEM)c; /* correction + roundfactor */ |
207 | 1.47M | #ifdef WITH_SIMD |
208 | 1.47M | dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */ |
209 | | #else |
210 | | dtbl[DCTSIZE2 * 2] = 1; |
211 | | #endif |
212 | 1.47M | dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */ |
213 | | |
214 | 1.47M | if (r <= 16) return 0; |
215 | 1.43M | else return 1; |
216 | 1.47M | } |
217 | | |
218 | | #endif |
219 | | |
220 | | |
221 | | /* |
222 | | * Initialize for a processing pass. |
223 | | * Verify that all referenced Q-tables are present, and set up |
224 | | * the divisor table for each one. |
225 | | * In the current implementation, DCT of all components is done during |
226 | | * the first pass, even if only some components will be output in the |
227 | | * first scan. Hence all components should be examined here. |
228 | | */ |
229 | | |
230 | | METHODDEF(void) |
231 | | start_pass_fdctmgr(j_compress_ptr cinfo) |
232 | 9.93k | { |
233 | 9.93k | my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct; |
234 | 9.93k | int ci, qtblno, i; |
235 | 9.93k | jpeg_component_info *compptr; |
236 | 9.93k | JQUANT_TBL *qtbl; |
237 | 9.93k | DCTELEM *dtbl; |
238 | | |
239 | 33.1k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; |
240 | 23.2k | ci++, compptr++) { |
241 | 23.2k | qtblno = compptr->quant_tbl_no; |
242 | | /* Make sure specified quantization table is present */ |
243 | 23.2k | if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || |
244 | 23.2k | cinfo->quant_tbl_ptrs[qtblno] == NULL) |
245 | 0 | ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); |
246 | 23.2k | qtbl = cinfo->quant_tbl_ptrs[qtblno]; |
247 | | /* Compute divisors for this quant table */ |
248 | | /* We may do this more than once for same table, but it's not a big deal */ |
249 | 23.2k | switch (cinfo->dct_method) { |
250 | 0 | #ifdef DCT_ISLOW_SUPPORTED |
251 | 16.6k | case JDCT_ISLOW: |
252 | | /* For LL&M IDCT method, divisors are equal to raw quantization |
253 | | * coefficients multiplied by 8 (to counteract scaling). |
254 | | */ |
255 | 16.6k | if (fdct->divisors[qtblno] == NULL) { |
256 | 11.6k | fdct->divisors[qtblno] = (DCTELEM *) |
257 | 11.6k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
258 | 11.6k | (DCTSIZE2 * 4) * sizeof(DCTELEM)); |
259 | 11.6k | } |
260 | 16.6k | dtbl = fdct->divisors[qtblno]; |
261 | 1.08M | for (i = 0; i < DCTSIZE2; i++) { |
262 | | #if BITS_IN_JSAMPLE == 8 |
263 | | #ifdef WITH_SIMD |
264 | 1.06M | if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) && |
265 | 0 | fdct->quantize != quantize) |
266 | 0 | fdct->quantize = quantize; |
267 | | #else |
268 | | compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]); |
269 | | #endif |
270 | | #else |
271 | | dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3; |
272 | | #endif |
273 | 1.06M | } |
274 | 16.6k | break; |
275 | 0 | #endif |
276 | 0 | #ifdef DCT_IFAST_SUPPORTED |
277 | 6.59k | case JDCT_IFAST: |
278 | 6.59k | { |
279 | | /* For AA&N IDCT method, divisors are equal to quantization |
280 | | * coefficients scaled by scalefactor[row]*scalefactor[col], where |
281 | | * scalefactor[0] = 1 |
282 | | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 |
283 | | * We apply a further scale factor of 8. |
284 | | */ |
285 | 6.59k | #define CONST_BITS 14 |
286 | 6.59k | static const INT16 aanscales[DCTSIZE2] = { |
287 | | /* precomputed values scaled up by 14 bits */ |
288 | 6.59k | 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, |
289 | 6.59k | 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, |
290 | 6.59k | 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, |
291 | 6.59k | 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, |
292 | 6.59k | 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, |
293 | 6.59k | 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, |
294 | 6.59k | 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, |
295 | 6.59k | 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 |
296 | 6.59k | }; |
297 | 6.59k | SHIFT_TEMPS |
298 | | |
299 | 6.59k | if (fdct->divisors[qtblno] == NULL) { |
300 | 4.93k | fdct->divisors[qtblno] = (DCTELEM *) |
301 | 4.93k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
302 | 4.93k | (DCTSIZE2 * 4) * sizeof(DCTELEM)); |
303 | 4.93k | } |
304 | 6.59k | dtbl = fdct->divisors[qtblno]; |
305 | 428k | for (i = 0; i < DCTSIZE2; i++) { |
306 | | #if BITS_IN_JSAMPLE == 8 |
307 | | #ifdef WITH_SIMD |
308 | 422k | if (!compute_reciprocal( |
309 | 422k | DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], |
310 | 422k | (JLONG)aanscales[i]), |
311 | 422k | CONST_BITS - 3), &dtbl[i]) && |
312 | 49.7k | fdct->quantize != quantize) |
313 | 1.65k | fdct->quantize = quantize; |
314 | | #else |
315 | | compute_reciprocal( |
316 | | DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], |
317 | | (JLONG)aanscales[i]), |
318 | | CONST_BITS-3), &dtbl[i]); |
319 | | #endif |
320 | | #else |
321 | | dtbl[i] = (DCTELEM) |
322 | 0 | DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], |
323 | | (JLONG)aanscales[i]), |
324 | | CONST_BITS - 3); |
325 | | #endif |
326 | 422k | } |
327 | 6.59k | } |
328 | 6.59k | break; |
329 | 0 | #endif |
330 | 0 | #ifdef DCT_FLOAT_SUPPORTED |
331 | 0 | case JDCT_FLOAT: |
332 | 0 | { |
333 | | /* For float AA&N IDCT method, divisors are equal to quantization |
334 | | * coefficients scaled by scalefactor[row]*scalefactor[col], where |
335 | | * scalefactor[0] = 1 |
336 | | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 |
337 | | * We apply a further scale factor of 8. |
338 | | * What's actually stored is 1/divisor so that the inner loop can |
339 | | * use a multiplication rather than a division. |
340 | | */ |
341 | 0 | FAST_FLOAT *fdtbl; |
342 | 0 | int row, col; |
343 | 0 | static const double aanscalefactor[DCTSIZE] = { |
344 | 0 | 1.0, 1.387039845, 1.306562965, 1.175875602, |
345 | 0 | 1.0, 0.785694958, 0.541196100, 0.275899379 |
346 | 0 | }; |
347 | |
|
348 | 0 | if (fdct->float_divisors[qtblno] == NULL) { |
349 | 0 | fdct->float_divisors[qtblno] = (FAST_FLOAT *) |
350 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
351 | 0 | DCTSIZE2 * sizeof(FAST_FLOAT)); |
352 | 0 | } |
353 | 0 | fdtbl = fdct->float_divisors[qtblno]; |
354 | 0 | i = 0; |
355 | 0 | for (row = 0; row < DCTSIZE; row++) { |
356 | 0 | for (col = 0; col < DCTSIZE; col++) { |
357 | 0 | fdtbl[i] = (FAST_FLOAT) |
358 | 0 | (1.0 / (((double)qtbl->quantval[i] * |
359 | 0 | aanscalefactor[row] * aanscalefactor[col] * 8.0))); |
360 | 0 | i++; |
361 | 0 | } |
362 | 0 | } |
363 | 0 | } |
364 | 0 | break; |
365 | 0 | #endif |
366 | 0 | default: |
367 | 0 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
368 | 0 | break; |
369 | 23.2k | } |
370 | 23.2k | } |
371 | 9.93k | } jcdctmgr-8.c:start_pass_fdctmgr Line | Count | Source | 232 | 9.93k | { | 233 | 9.93k | my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct; | 234 | 9.93k | int ci, qtblno, i; | 235 | 9.93k | jpeg_component_info *compptr; | 236 | 9.93k | JQUANT_TBL *qtbl; | 237 | 9.93k | DCTELEM *dtbl; | 238 | | | 239 | 33.1k | for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; | 240 | 23.2k | ci++, compptr++) { | 241 | 23.2k | qtblno = compptr->quant_tbl_no; | 242 | | /* Make sure specified quantization table is present */ | 243 | 23.2k | if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS || | 244 | 23.2k | cinfo->quant_tbl_ptrs[qtblno] == NULL) | 245 | 0 | ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno); | 246 | 23.2k | qtbl = cinfo->quant_tbl_ptrs[qtblno]; | 247 | | /* Compute divisors for this quant table */ | 248 | | /* We may do this more than once for same table, but it's not a big deal */ | 249 | 23.2k | switch (cinfo->dct_method) { | 250 | 0 | #ifdef DCT_ISLOW_SUPPORTED | 251 | 16.6k | case JDCT_ISLOW: | 252 | | /* For LL&M IDCT method, divisors are equal to raw quantization | 253 | | * coefficients multiplied by 8 (to counteract scaling). | 254 | | */ | 255 | 16.6k | if (fdct->divisors[qtblno] == NULL) { | 256 | 11.6k | fdct->divisors[qtblno] = (DCTELEM *) | 257 | 11.6k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 258 | 11.6k | (DCTSIZE2 * 4) * sizeof(DCTELEM)); | 259 | 11.6k | } | 260 | 16.6k | dtbl = fdct->divisors[qtblno]; | 261 | 1.08M | for (i = 0; i < DCTSIZE2; i++) { | 262 | 1.06M | #if BITS_IN_JSAMPLE == 8 | 263 | 1.06M | #ifdef WITH_SIMD | 264 | 1.06M | if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) && | 265 | 0 | fdct->quantize != quantize) | 266 | 0 | fdct->quantize = quantize; | 267 | | #else | 268 | | compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]); | 269 | | #endif | 270 | | #else | 271 | | dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3; | 272 | | #endif | 273 | 1.06M | } | 274 | 16.6k | break; | 275 | 0 | #endif | 276 | 0 | #ifdef DCT_IFAST_SUPPORTED | 277 | 6.59k | case JDCT_IFAST: | 278 | 6.59k | { | 279 | | /* For AA&N IDCT method, divisors are equal to quantization | 280 | | * coefficients scaled by scalefactor[row]*scalefactor[col], where | 281 | | * scalefactor[0] = 1 | 282 | | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | 283 | | * We apply a further scale factor of 8. | 284 | | */ | 285 | 6.59k | #define CONST_BITS 14 | 286 | 6.59k | static const INT16 aanscales[DCTSIZE2] = { | 287 | | /* precomputed values scaled up by 14 bits */ | 288 | 6.59k | 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, | 289 | 6.59k | 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, | 290 | 6.59k | 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, | 291 | 6.59k | 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, | 292 | 6.59k | 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, | 293 | 6.59k | 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, | 294 | 6.59k | 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, | 295 | 6.59k | 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 | 296 | 6.59k | }; | 297 | 6.59k | SHIFT_TEMPS | 298 | | | 299 | 6.59k | if (fdct->divisors[qtblno] == NULL) { | 300 | 4.93k | fdct->divisors[qtblno] = (DCTELEM *) | 301 | 4.93k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 302 | 4.93k | (DCTSIZE2 * 4) * sizeof(DCTELEM)); | 303 | 4.93k | } | 304 | 6.59k | dtbl = fdct->divisors[qtblno]; | 305 | 428k | for (i = 0; i < DCTSIZE2; i++) { | 306 | 422k | #if BITS_IN_JSAMPLE == 8 | 307 | 422k | #ifdef WITH_SIMD | 308 | 422k | if (!compute_reciprocal( | 309 | 422k | DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], | 310 | 422k | (JLONG)aanscales[i]), | 311 | 422k | CONST_BITS - 3), &dtbl[i]) && | 312 | 49.7k | fdct->quantize != quantize) | 313 | 1.65k | fdct->quantize = quantize; | 314 | | #else | 315 | | compute_reciprocal( | 316 | | DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], | 317 | | (JLONG)aanscales[i]), | 318 | | CONST_BITS-3), &dtbl[i]); | 319 | | #endif | 320 | | #else | 321 | | dtbl[i] = (DCTELEM) | 322 | | DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], | 323 | | (JLONG)aanscales[i]), | 324 | | CONST_BITS - 3); | 325 | | #endif | 326 | 422k | } | 327 | 6.59k | } | 328 | 6.59k | break; | 329 | 0 | #endif | 330 | 0 | #ifdef DCT_FLOAT_SUPPORTED | 331 | 0 | case JDCT_FLOAT: | 332 | 0 | { | 333 | | /* For float AA&N IDCT method, divisors are equal to quantization | 334 | | * coefficients scaled by scalefactor[row]*scalefactor[col], where | 335 | | * scalefactor[0] = 1 | 336 | | * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 | 337 | | * We apply a further scale factor of 8. | 338 | | * What's actually stored is 1/divisor so that the inner loop can | 339 | | * use a multiplication rather than a division. | 340 | | */ | 341 | 0 | FAST_FLOAT *fdtbl; | 342 | 0 | int row, col; | 343 | 0 | static const double aanscalefactor[DCTSIZE] = { | 344 | 0 | 1.0, 1.387039845, 1.306562965, 1.175875602, | 345 | 0 | 1.0, 0.785694958, 0.541196100, 0.275899379 | 346 | 0 | }; | 347 | |
| 348 | 0 | if (fdct->float_divisors[qtblno] == NULL) { | 349 | 0 | fdct->float_divisors[qtblno] = (FAST_FLOAT *) | 350 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 351 | 0 | DCTSIZE2 * sizeof(FAST_FLOAT)); | 352 | 0 | } | 353 | 0 | fdtbl = fdct->float_divisors[qtblno]; | 354 | 0 | i = 0; | 355 | 0 | for (row = 0; row < DCTSIZE; row++) { | 356 | 0 | for (col = 0; col < DCTSIZE; col++) { | 357 | 0 | fdtbl[i] = (FAST_FLOAT) | 358 | 0 | (1.0 / (((double)qtbl->quantval[i] * | 359 | 0 | aanscalefactor[row] * aanscalefactor[col] * 8.0))); | 360 | 0 | i++; | 361 | 0 | } | 362 | 0 | } | 363 | 0 | } | 364 | 0 | break; | 365 | 0 | #endif | 366 | 0 | default: | 367 | 0 | ERREXIT(cinfo, JERR_NOT_COMPILED); | 368 | 0 | break; | 369 | 23.2k | } | 370 | 23.2k | } | 371 | 9.93k | } |
Unexecuted instantiation: jcdctmgr-12.c:start_pass_fdctmgr |
372 | | |
373 | | |
374 | | /* |
375 | | * Load data into workspace, applying unsigned->signed conversion. |
376 | | */ |
377 | | |
378 | | METHODDEF(void) |
379 | | convsamp(_JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace) |
380 | 0 | { |
381 | 0 | register DCTELEM *workspaceptr; |
382 | 0 | register _JSAMPROW elemptr; |
383 | 0 | register int elemr; |
384 | |
|
385 | 0 | workspaceptr = workspace; |
386 | 0 | for (elemr = 0; elemr < DCTSIZE; elemr++) { |
387 | 0 | elemptr = sample_data[elemr] + start_col; |
388 | |
|
389 | 0 | #if DCTSIZE == 8 /* unroll the inner loop */ |
390 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
391 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
392 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
393 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
394 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
395 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
396 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
397 | 0 | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
398 | | #else |
399 | | { |
400 | | register int elemc; |
401 | | for (elemc = DCTSIZE; elemc > 0; elemc--) |
402 | | *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE; |
403 | | } |
404 | | #endif |
405 | 0 | } |
406 | 0 | } Unexecuted instantiation: jcdctmgr-8.c:convsamp Unexecuted instantiation: jcdctmgr-12.c:convsamp |
407 | | |
408 | | |
409 | | /* |
410 | | * Quantize/descale the coefficients, and store into coef_blocks[]. |
411 | | */ |
412 | | |
413 | | METHODDEF(void) |
414 | | quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace) |
415 | 4.11M | { |
416 | 4.11M | int i; |
417 | 4.11M | DCTELEM temp; |
418 | 4.11M | JCOEFPTR output_ptr = coef_block; |
419 | | |
420 | | #if BITS_IN_JSAMPLE == 8 |
421 | | |
422 | | UDCTELEM recip, corr; |
423 | | int shift; |
424 | | UDCTELEM2 product; |
425 | | |
426 | 267M | for (i = 0; i < DCTSIZE2; i++) { |
427 | 263M | temp = workspace[i]; |
428 | 263M | recip = divisors[i + DCTSIZE2 * 0]; |
429 | 263M | corr = divisors[i + DCTSIZE2 * 1]; |
430 | 263M | shift = divisors[i + DCTSIZE2 * 3]; |
431 | | |
432 | 263M | if (temp < 0) { |
433 | 12.4M | temp = -temp; |
434 | 12.4M | product = (UDCTELEM2)(temp + corr) * recip; |
435 | 12.4M | product >>= shift + sizeof(DCTELEM) * 8; |
436 | 12.4M | temp = (DCTELEM)product; |
437 | 12.4M | temp = -temp; |
438 | 250M | } else { |
439 | 250M | product = (UDCTELEM2)(temp + corr) * recip; |
440 | 250M | product >>= shift + sizeof(DCTELEM) * 8; |
441 | 250M | temp = (DCTELEM)product; |
442 | 250M | } |
443 | 263M | output_ptr[i] = (JCOEF)temp; |
444 | 263M | } |
445 | | |
446 | | #else |
447 | | |
448 | | register DCTELEM qval; |
449 | | |
450 | 0 | for (i = 0; i < DCTSIZE2; i++) { |
451 | 0 | qval = divisors[i]; |
452 | 0 | temp = workspace[i]; |
453 | | /* Divide the coefficient value by qval, ensuring proper rounding. |
454 | | * Since C does not specify the direction of rounding for negative |
455 | | * quotients, we have to force the dividend positive for portability. |
456 | | * |
457 | | * In most files, at least half of the output values will be zero |
458 | | * (at default quantization settings, more like three-quarters...) |
459 | | * so we should ensure that this case is fast. On many machines, |
460 | | * a comparison is enough cheaper than a divide to make a special test |
461 | | * a win. Since both inputs will be nonnegative, we need only test |
462 | | * for a < b to discover whether a/b is 0. |
463 | | * If your machine's division is fast enough, define FAST_DIVIDE. |
464 | | */ |
465 | | #ifdef FAST_DIVIDE |
466 | | #define DIVIDE_BY(a, b) a /= b |
467 | | #else |
468 | 0 | #define DIVIDE_BY(a, b) if (a >= b) a /= b; else a = 0 |
469 | 0 | #endif |
470 | 0 | if (temp < 0) { |
471 | 0 | temp = -temp; |
472 | 0 | temp += qval >> 1; /* for rounding */ |
473 | 0 | DIVIDE_BY(temp, qval); |
474 | 0 | temp = -temp; |
475 | 0 | } else { |
476 | 0 | temp += qval >> 1; /* for rounding */ |
477 | 0 | DIVIDE_BY(temp, qval); |
478 | 0 | } |
479 | 0 | output_ptr[i] = (JCOEF)temp; |
480 | 0 | } |
481 | | |
482 | | #endif |
483 | | |
484 | 4.11M | } Line | Count | Source | 415 | 4.11M | { | 416 | 4.11M | int i; | 417 | 4.11M | DCTELEM temp; | 418 | 4.11M | JCOEFPTR output_ptr = coef_block; | 419 | | | 420 | 4.11M | #if BITS_IN_JSAMPLE == 8 | 421 | | | 422 | 4.11M | UDCTELEM recip, corr; | 423 | 4.11M | int shift; | 424 | 4.11M | UDCTELEM2 product; | 425 | | | 426 | 267M | for (i = 0; i < DCTSIZE2; i++) { | 427 | 263M | temp = workspace[i]; | 428 | 263M | recip = divisors[i + DCTSIZE2 * 0]; | 429 | 263M | corr = divisors[i + DCTSIZE2 * 1]; | 430 | 263M | shift = divisors[i + DCTSIZE2 * 3]; | 431 | | | 432 | 263M | if (temp < 0) { | 433 | 12.4M | temp = -temp; | 434 | 12.4M | product = (UDCTELEM2)(temp + corr) * recip; | 435 | 12.4M | product >>= shift + sizeof(DCTELEM) * 8; | 436 | 12.4M | temp = (DCTELEM)product; | 437 | 12.4M | temp = -temp; | 438 | 250M | } else { | 439 | 250M | product = (UDCTELEM2)(temp + corr) * recip; | 440 | 250M | product >>= shift + sizeof(DCTELEM) * 8; | 441 | 250M | temp = (DCTELEM)product; | 442 | 250M | } | 443 | 263M | output_ptr[i] = (JCOEF)temp; | 444 | 263M | } | 445 | | | 446 | | #else | 447 | | | 448 | | register DCTELEM qval; | 449 | | | 450 | | for (i = 0; i < DCTSIZE2; i++) { | 451 | | qval = divisors[i]; | 452 | | temp = workspace[i]; | 453 | | /* Divide the coefficient value by qval, ensuring proper rounding. | 454 | | * Since C does not specify the direction of rounding for negative | 455 | | * quotients, we have to force the dividend positive for portability. | 456 | | * | 457 | | * In most files, at least half of the output values will be zero | 458 | | * (at default quantization settings, more like three-quarters...) | 459 | | * so we should ensure that this case is fast. On many machines, | 460 | | * a comparison is enough cheaper than a divide to make a special test | 461 | | * a win. Since both inputs will be nonnegative, we need only test | 462 | | * for a < b to discover whether a/b is 0. | 463 | | * If your machine's division is fast enough, define FAST_DIVIDE. | 464 | | */ | 465 | | #ifdef FAST_DIVIDE | 466 | | #define DIVIDE_BY(a, b) a /= b | 467 | | #else | 468 | | #define DIVIDE_BY(a, b) if (a >= b) a /= b; else a = 0 | 469 | | #endif | 470 | | if (temp < 0) { | 471 | | temp = -temp; | 472 | | temp += qval >> 1; /* for rounding */ | 473 | | DIVIDE_BY(temp, qval); | 474 | | temp = -temp; | 475 | | } else { | 476 | | temp += qval >> 1; /* for rounding */ | 477 | | DIVIDE_BY(temp, qval); | 478 | | } | 479 | | output_ptr[i] = (JCOEF)temp; | 480 | | } | 481 | | | 482 | | #endif | 483 | | | 484 | 4.11M | } |
Unexecuted instantiation: jcdctmgr-12.c:quantize |
485 | | |
486 | | |
487 | | /* |
488 | | * Perform forward DCT on one or more blocks of a component. |
489 | | * |
490 | | * The input samples are taken from the sample_data[] array starting at |
491 | | * position start_row/start_col, and moving to the right for any additional |
492 | | * blocks. The quantized coefficients are returned in coef_blocks[]. |
493 | | */ |
494 | | |
495 | | METHODDEF(void) |
496 | | forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr, |
497 | | _JSAMPARRAY sample_data, JBLOCKROW coef_blocks, |
498 | | JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks) |
499 | | /* This version is used for integer DCT implementations. */ |
500 | 14.3M | { |
501 | | /* This routine is heavily used, so it's worth coding it tightly. */ |
502 | 14.3M | my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct; |
503 | 14.3M | DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no]; |
504 | 14.3M | DCTELEM *workspace; |
505 | 14.3M | JDIMENSION bi; |
506 | | |
507 | | /* Make sure the compiler doesn't look up these every pass */ |
508 | 14.3M | forward_DCT_method_ptr do_dct = fdct->dct; |
509 | 14.3M | convsamp_method_ptr do_convsamp = fdct->convsamp; |
510 | 14.3M | quantize_method_ptr do_quantize = fdct->quantize; |
511 | 14.3M | workspace = fdct->workspace; |
512 | | |
513 | 14.3M | sample_data += start_row; /* fold in the vertical offset once */ |
514 | | |
515 | 30.9M | for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { |
516 | | /* Load data into workspace, applying unsigned->signed conversion */ |
517 | | #ifdef WITH_PROFILE |
518 | | cinfo->master->start = getTime(); |
519 | | #endif |
520 | 16.5M | (*do_convsamp) (sample_data, start_col, workspace); |
521 | | #ifdef WITH_PROFILE |
522 | | cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start; |
523 | | cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.; |
524 | | #endif |
525 | | |
526 | | /* Perform the DCT */ |
527 | | #ifdef WITH_PROFILE |
528 | | cinfo->master->start = getTime(); |
529 | | #endif |
530 | 16.5M | (*do_dct) (workspace); |
531 | | #ifdef WITH_PROFILE |
532 | | cinfo->master->fdct_elapsed += getTime() - cinfo->master->start; |
533 | | cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.; |
534 | | #endif |
535 | | |
536 | | /* Quantize/descale the coefficients, and store into coef_blocks[] */ |
537 | | #ifdef WITH_PROFILE |
538 | | cinfo->master->start = getTime(); |
539 | | #endif |
540 | 16.5M | (*do_quantize) (coef_blocks[bi], divisors, workspace); |
541 | | #ifdef WITH_PROFILE |
542 | | cinfo->master->quantize_elapsed += getTime() - cinfo->master->start; |
543 | | cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.; |
544 | | #endif |
545 | 16.5M | } |
546 | 14.3M | } Line | Count | Source | 500 | 14.3M | { | 501 | | /* This routine is heavily used, so it's worth coding it tightly. */ | 502 | 14.3M | my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct; | 503 | 14.3M | DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no]; | 504 | 14.3M | DCTELEM *workspace; | 505 | 14.3M | JDIMENSION bi; | 506 | | | 507 | | /* Make sure the compiler doesn't look up these every pass */ | 508 | 14.3M | forward_DCT_method_ptr do_dct = fdct->dct; | 509 | 14.3M | convsamp_method_ptr do_convsamp = fdct->convsamp; | 510 | 14.3M | quantize_method_ptr do_quantize = fdct->quantize; | 511 | 14.3M | workspace = fdct->workspace; | 512 | | | 513 | 14.3M | sample_data += start_row; /* fold in the vertical offset once */ | 514 | | | 515 | 30.9M | for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { | 516 | | /* Load data into workspace, applying unsigned->signed conversion */ | 517 | | #ifdef WITH_PROFILE | 518 | | cinfo->master->start = getTime(); | 519 | | #endif | 520 | 16.5M | (*do_convsamp) (sample_data, start_col, workspace); | 521 | | #ifdef WITH_PROFILE | 522 | | cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start; | 523 | | cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.; | 524 | | #endif | 525 | | | 526 | | /* Perform the DCT */ | 527 | | #ifdef WITH_PROFILE | 528 | | cinfo->master->start = getTime(); | 529 | | #endif | 530 | 16.5M | (*do_dct) (workspace); | 531 | | #ifdef WITH_PROFILE | 532 | | cinfo->master->fdct_elapsed += getTime() - cinfo->master->start; | 533 | | cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.; | 534 | | #endif | 535 | | | 536 | | /* Quantize/descale the coefficients, and store into coef_blocks[] */ | 537 | | #ifdef WITH_PROFILE | 538 | | cinfo->master->start = getTime(); | 539 | | #endif | 540 | 16.5M | (*do_quantize) (coef_blocks[bi], divisors, workspace); | 541 | | #ifdef WITH_PROFILE | 542 | | cinfo->master->quantize_elapsed += getTime() - cinfo->master->start; | 543 | | cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.; | 544 | | #endif | 545 | 16.5M | } | 546 | 14.3M | } |
Unexecuted instantiation: jcdctmgr-12.c:forward_DCT |
547 | | |
548 | | |
549 | | #ifdef DCT_FLOAT_SUPPORTED |
550 | | |
551 | | METHODDEF(void) |
552 | | convsamp_float(_JSAMPARRAY sample_data, JDIMENSION start_col, |
553 | | FAST_FLOAT *workspace) |
554 | 0 | { |
555 | 0 | register FAST_FLOAT *workspaceptr; |
556 | 0 | register _JSAMPROW elemptr; |
557 | 0 | register int elemr; |
558 | |
|
559 | 0 | workspaceptr = workspace; |
560 | 0 | for (elemr = 0; elemr < DCTSIZE; elemr++) { |
561 | 0 | elemptr = sample_data[elemr] + start_col; |
562 | 0 | #if DCTSIZE == 8 /* unroll the inner loop */ |
563 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
564 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
565 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
566 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
567 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
568 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
569 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
570 | 0 | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
571 | | #else |
572 | | { |
573 | | register int elemc; |
574 | | for (elemc = DCTSIZE; elemc > 0; elemc--) |
575 | | *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE); |
576 | | } |
577 | | #endif |
578 | 0 | } |
579 | 0 | } Unexecuted instantiation: jcdctmgr-8.c:convsamp_float Unexecuted instantiation: jcdctmgr-12.c:convsamp_float |
580 | | |
581 | | |
582 | | METHODDEF(void) |
583 | | quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors, |
584 | | FAST_FLOAT *workspace) |
585 | 0 | { |
586 | 0 | register FAST_FLOAT temp; |
587 | 0 | register int i; |
588 | 0 | register JCOEFPTR output_ptr = coef_block; |
589 | |
|
590 | 0 | for (i = 0; i < DCTSIZE2; i++) { |
591 | | /* Apply the quantization and scaling factor */ |
592 | 0 | temp = workspace[i] * divisors[i]; |
593 | | |
594 | | /* Round to nearest integer. |
595 | | * Since C does not specify the direction of rounding for negative |
596 | | * quotients, we have to force the dividend positive for portability. |
597 | | * The maximum coefficient size is +-16K (for 12-bit data), so this |
598 | | * code should work for either 16-bit or 32-bit ints. |
599 | | */ |
600 | 0 | output_ptr[i] = (JCOEF)((int)(temp + (FAST_FLOAT)16384.5) - 16384); |
601 | 0 | } |
602 | 0 | } Unexecuted instantiation: jcdctmgr-8.c:quantize_float Unexecuted instantiation: jcdctmgr-12.c:quantize_float |
603 | | |
604 | | |
605 | | METHODDEF(void) |
606 | | forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr, |
607 | | _JSAMPARRAY sample_data, JBLOCKROW coef_blocks, |
608 | | JDIMENSION start_row, JDIMENSION start_col, |
609 | | JDIMENSION num_blocks) |
610 | | /* This version is used for floating-point DCT implementations. */ |
611 | 0 | { |
612 | | /* This routine is heavily used, so it's worth coding it tightly. */ |
613 | 0 | my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct; |
614 | 0 | FAST_FLOAT *divisors = fdct->float_divisors[compptr->quant_tbl_no]; |
615 | 0 | FAST_FLOAT *workspace; |
616 | 0 | JDIMENSION bi; |
617 | | |
618 | | |
619 | | /* Make sure the compiler doesn't look up these every pass */ |
620 | 0 | float_DCT_method_ptr do_dct = fdct->float_dct; |
621 | 0 | float_convsamp_method_ptr do_convsamp = fdct->float_convsamp; |
622 | 0 | float_quantize_method_ptr do_quantize = fdct->float_quantize; |
623 | 0 | workspace = fdct->float_workspace; |
624 | |
|
625 | 0 | sample_data += start_row; /* fold in the vertical offset once */ |
626 | |
|
627 | 0 | for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { |
628 | | /* Load data into workspace, applying unsigned->signed conversion */ |
629 | | #ifdef WITH_PROFILE |
630 | | cinfo->master->start = getTime(); |
631 | | #endif |
632 | 0 | (*do_convsamp) (sample_data, start_col, workspace); |
633 | | #ifdef WITH_PROFILE |
634 | | cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start; |
635 | | cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.; |
636 | | #endif |
637 | | |
638 | | /* Perform the DCT */ |
639 | | #ifdef WITH_PROFILE |
640 | | cinfo->master->start = getTime(); |
641 | | #endif |
642 | 0 | (*do_dct) (workspace); |
643 | | #ifdef WITH_PROFILE |
644 | | cinfo->master->fdct_elapsed += getTime() - cinfo->master->start; |
645 | | cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.; |
646 | | #endif |
647 | | |
648 | | /* Quantize/descale the coefficients, and store into coef_blocks[] */ |
649 | | #ifdef WITH_PROFILE |
650 | | cinfo->master->start = getTime(); |
651 | | #endif |
652 | 0 | (*do_quantize) (coef_blocks[bi], divisors, workspace); |
653 | | #ifdef WITH_PROFILE |
654 | | cinfo->master->quantize_elapsed += getTime() - cinfo->master->start; |
655 | | cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.; |
656 | | #endif |
657 | 0 | } |
658 | 0 | } Unexecuted instantiation: jcdctmgr-8.c:forward_DCT_float Unexecuted instantiation: jcdctmgr-12.c:forward_DCT_float |
659 | | |
660 | | #endif /* DCT_FLOAT_SUPPORTED */ |
661 | | |
662 | | |
663 | | /* |
664 | | * Initialize FDCT manager. |
665 | | */ |
666 | | |
667 | | GLOBAL(void) |
668 | | _jinit_forward_dct(j_compress_ptr cinfo) |
669 | 9.93k | { |
670 | 9.93k | my_fdct_ptr fdct; |
671 | 9.93k | int i; |
672 | | |
673 | 9.93k | if (cinfo->data_precision != BITS_IN_JSAMPLE) |
674 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); |
675 | | |
676 | 9.93k | fdct = (my_fdct_ptr) |
677 | 9.93k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
678 | 9.93k | sizeof(my_fdct_controller)); |
679 | 9.93k | cinfo->fdct = (struct jpeg_forward_dct *)fdct; |
680 | 9.93k | fdct->pub.start_pass = start_pass_fdctmgr; |
681 | | |
682 | | /* First determine the DCT... */ |
683 | 9.93k | switch (cinfo->dct_method) { |
684 | 0 | #ifdef DCT_ISLOW_SUPPORTED |
685 | 6.66k | case JDCT_ISLOW: |
686 | 6.66k | fdct->pub._forward_DCT = forward_DCT; |
687 | | #ifdef WITH_SIMD |
688 | 6.66k | if (!jsimd_set_fdct_islow(cinfo, &fdct->dct)) |
689 | 0 | #endif |
690 | 0 | fdct->dct = _jpeg_fdct_islow; |
691 | 6.66k | break; |
692 | 0 | #endif |
693 | 0 | #ifdef DCT_IFAST_SUPPORTED |
694 | 3.27k | case JDCT_IFAST: |
695 | 3.27k | fdct->pub._forward_DCT = forward_DCT; |
696 | | #ifdef WITH_SIMD |
697 | 3.27k | if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct)) |
698 | 0 | #endif |
699 | 0 | fdct->dct = _jpeg_fdct_ifast; |
700 | 3.27k | break; |
701 | 0 | #endif |
702 | 0 | #ifdef DCT_FLOAT_SUPPORTED |
703 | 0 | case JDCT_FLOAT: |
704 | 0 | fdct->pub._forward_DCT = forward_DCT_float; |
705 | | #ifdef WITH_SIMD |
706 | 0 | if (!jsimd_set_fdct_float(cinfo, &fdct->float_dct)) |
707 | 0 | #endif |
708 | 0 | fdct->float_dct = jpeg_fdct_float; |
709 | 0 | break; |
710 | 0 | #endif |
711 | 0 | default: |
712 | 0 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
713 | 0 | break; |
714 | 9.93k | } |
715 | | |
716 | | /* ...then the supporting stages. */ |
717 | 9.93k | switch (cinfo->dct_method) { |
718 | 0 | #ifdef DCT_ISLOW_SUPPORTED |
719 | 6.66k | case JDCT_ISLOW: |
720 | 6.66k | #endif |
721 | 6.66k | #ifdef DCT_IFAST_SUPPORTED |
722 | 9.93k | case JDCT_IFAST: |
723 | 9.93k | #endif |
724 | 9.93k | #if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) |
725 | | #ifdef WITH_SIMD |
726 | 9.93k | if (!jsimd_set_convsamp(cinfo, &fdct->convsamp)) |
727 | 0 | #endif |
728 | 0 | fdct->convsamp = convsamp; |
729 | | #ifdef WITH_SIMD |
730 | 9.93k | if (!jsimd_set_quantize(cinfo, &fdct->quantize)) |
731 | 0 | #endif |
732 | 0 | fdct->quantize = quantize; |
733 | 9.93k | break; |
734 | 0 | #endif |
735 | 0 | #ifdef DCT_FLOAT_SUPPORTED |
736 | 0 | case JDCT_FLOAT: |
737 | | #ifdef WITH_SIMD |
738 | 0 | if (!jsimd_set_convsamp_float(cinfo, &fdct->float_convsamp)) |
739 | 0 | #endif |
740 | 0 | fdct->float_convsamp = convsamp_float; |
741 | | #ifdef WITH_SIMD |
742 | 0 | if (!jsimd_set_quantize_float(cinfo, &fdct->float_quantize)) |
743 | 0 | #endif |
744 | 0 | fdct->float_quantize = quantize_float; |
745 | 0 | break; |
746 | 0 | #endif |
747 | 0 | default: |
748 | 0 | ERREXIT(cinfo, JERR_NOT_COMPILED); |
749 | 0 | break; |
750 | 9.93k | } |
751 | | |
752 | | /* Allocate workspace memory */ |
753 | 9.93k | #ifdef DCT_FLOAT_SUPPORTED |
754 | 9.93k | if (cinfo->dct_method == JDCT_FLOAT) |
755 | 0 | fdct->float_workspace = (FAST_FLOAT *) |
756 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
757 | 0 | sizeof(FAST_FLOAT) * DCTSIZE2); |
758 | 9.93k | else |
759 | 9.93k | #endif |
760 | 9.93k | fdct->workspace = (DCTELEM *) |
761 | 9.93k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, |
762 | 9.93k | sizeof(DCTELEM) * DCTSIZE2); |
763 | | |
764 | | /* Mark divisor tables unallocated */ |
765 | 49.6k | for (i = 0; i < NUM_QUANT_TBLS; i++) { |
766 | 39.7k | fdct->divisors[i] = NULL; |
767 | 39.7k | #ifdef DCT_FLOAT_SUPPORTED |
768 | | fdct->float_divisors[i] = NULL; |
769 | 39.7k | #endif |
770 | 39.7k | } |
771 | 9.93k | } Line | Count | Source | 669 | 9.93k | { | 670 | 9.93k | my_fdct_ptr fdct; | 671 | 9.93k | int i; | 672 | | | 673 | 9.93k | if (cinfo->data_precision != BITS_IN_JSAMPLE) | 674 | 0 | ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision); | 675 | | | 676 | 9.93k | fdct = (my_fdct_ptr) | 677 | 9.93k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 678 | 9.93k | sizeof(my_fdct_controller)); | 679 | 9.93k | cinfo->fdct = (struct jpeg_forward_dct *)fdct; | 680 | 9.93k | fdct->pub.start_pass = start_pass_fdctmgr; | 681 | | | 682 | | /* First determine the DCT... */ | 683 | 9.93k | switch (cinfo->dct_method) { | 684 | 0 | #ifdef DCT_ISLOW_SUPPORTED | 685 | 6.66k | case JDCT_ISLOW: | 686 | 6.66k | fdct->pub._forward_DCT = forward_DCT; | 687 | 6.66k | #ifdef WITH_SIMD | 688 | 6.66k | if (!jsimd_set_fdct_islow(cinfo, &fdct->dct)) | 689 | 0 | #endif | 690 | 0 | fdct->dct = _jpeg_fdct_islow; | 691 | 6.66k | break; | 692 | 0 | #endif | 693 | 0 | #ifdef DCT_IFAST_SUPPORTED | 694 | 3.27k | case JDCT_IFAST: | 695 | 3.27k | fdct->pub._forward_DCT = forward_DCT; | 696 | 3.27k | #ifdef WITH_SIMD | 697 | 3.27k | if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct)) | 698 | 0 | #endif | 699 | 0 | fdct->dct = _jpeg_fdct_ifast; | 700 | 3.27k | break; | 701 | 0 | #endif | 702 | 0 | #ifdef DCT_FLOAT_SUPPORTED | 703 | 0 | case JDCT_FLOAT: | 704 | 0 | fdct->pub._forward_DCT = forward_DCT_float; | 705 | 0 | #ifdef WITH_SIMD | 706 | 0 | if (!jsimd_set_fdct_float(cinfo, &fdct->float_dct)) | 707 | 0 | #endif | 708 | 0 | fdct->float_dct = jpeg_fdct_float; | 709 | 0 | break; | 710 | 0 | #endif | 711 | 0 | default: | 712 | 0 | ERREXIT(cinfo, JERR_NOT_COMPILED); | 713 | 0 | break; | 714 | 9.93k | } | 715 | | | 716 | | /* ...then the supporting stages. */ | 717 | 9.93k | switch (cinfo->dct_method) { | 718 | 0 | #ifdef DCT_ISLOW_SUPPORTED | 719 | 6.66k | case JDCT_ISLOW: | 720 | 6.66k | #endif | 721 | 6.66k | #ifdef DCT_IFAST_SUPPORTED | 722 | 9.93k | case JDCT_IFAST: | 723 | 9.93k | #endif | 724 | 9.93k | #if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED) | 725 | 9.93k | #ifdef WITH_SIMD | 726 | 9.93k | if (!jsimd_set_convsamp(cinfo, &fdct->convsamp)) | 727 | 0 | #endif | 728 | 0 | fdct->convsamp = convsamp; | 729 | 9.93k | #ifdef WITH_SIMD | 730 | 9.93k | if (!jsimd_set_quantize(cinfo, &fdct->quantize)) | 731 | 0 | #endif | 732 | 0 | fdct->quantize = quantize; | 733 | 9.93k | break; | 734 | 0 | #endif | 735 | 0 | #ifdef DCT_FLOAT_SUPPORTED | 736 | 0 | case JDCT_FLOAT: | 737 | 0 | #ifdef WITH_SIMD | 738 | 0 | if (!jsimd_set_convsamp_float(cinfo, &fdct->float_convsamp)) | 739 | 0 | #endif | 740 | 0 | fdct->float_convsamp = convsamp_float; | 741 | 0 | #ifdef WITH_SIMD | 742 | 0 | if (!jsimd_set_quantize_float(cinfo, &fdct->float_quantize)) | 743 | 0 | #endif | 744 | 0 | fdct->float_quantize = quantize_float; | 745 | 0 | break; | 746 | 0 | #endif | 747 | 0 | default: | 748 | 0 | ERREXIT(cinfo, JERR_NOT_COMPILED); | 749 | 0 | break; | 750 | 9.93k | } | 751 | | | 752 | | /* Allocate workspace memory */ | 753 | 9.93k | #ifdef DCT_FLOAT_SUPPORTED | 754 | 9.93k | if (cinfo->dct_method == JDCT_FLOAT) | 755 | 0 | fdct->float_workspace = (FAST_FLOAT *) | 756 | 0 | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 757 | 0 | sizeof(FAST_FLOAT) * DCTSIZE2); | 758 | 9.93k | else | 759 | 9.93k | #endif | 760 | 9.93k | fdct->workspace = (DCTELEM *) | 761 | 9.93k | (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, | 762 | 9.93k | sizeof(DCTELEM) * DCTSIZE2); | 763 | | | 764 | | /* Mark divisor tables unallocated */ | 765 | 49.6k | for (i = 0; i < NUM_QUANT_TBLS; i++) { | 766 | 39.7k | fdct->divisors[i] = NULL; | 767 | 39.7k | #ifdef DCT_FLOAT_SUPPORTED | 768 | | fdct->float_divisors[i] = NULL; | 769 | 39.7k | #endif | 770 | 39.7k | } | 771 | 9.93k | } |
Unexecuted instantiation: j12init_forward_dct |