Coverage Report

Created: 2025-10-13 06:04

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/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-2025, 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
2.15M
{
74
2.15M
  int bit;
75
76
2.15M
  bit = 16;
77
78
2.15M
  if (!val)
79
0
    return 0;
80
81
2.15M
  if (!(val & 0xff00)) {
82
1.11M
    bit -= 8;
83
1.11M
    val <<= 8;
84
1.11M
  }
85
2.15M
  if (!(val & 0xf000)) {
86
1.40M
    bit -= 4;
87
1.40M
    val <<= 4;
88
1.40M
  }
89
2.15M
  if (!(val & 0xc000)) {
90
1.19M
    bit -= 2;
91
1.19M
    val <<= 2;
92
1.19M
  }
93
2.15M
  if (!(val & 0x8000)) {
94
937k
    bit -= 1;
95
937k
    val <<= 1;
96
937k
  }
97
98
2.15M
  return bit;
99
2.15M
}
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
2.15M
{
164
2.15M
  UDCTELEM2 fq, fr;
165
2.15M
  UDCTELEM c;
166
2.15M
  int b, r;
167
168
2.15M
  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
0
    dtbl[DCTSIZE2 * 0] = (DCTELEM)1;                        /* reciprocal */
175
0
    dtbl[DCTSIZE2 * 1] = (DCTELEM)0;                        /* correction */
176
0
    dtbl[DCTSIZE2 * 2] = (DCTELEM)1;                        /* scale */
177
0
    dtbl[DCTSIZE2 * 3] = -(DCTELEM)(sizeof(DCTELEM) * 8);   /* shift */
178
0
    return 0;
179
0
  }
180
181
2.15M
  b = flss(divisor) - 1;
182
2.15M
  r  = sizeof(DCTELEM) * 8 + b;
183
184
2.15M
  fq = ((UDCTELEM2)1 << r) / divisor;
185
2.15M
  fr = ((UDCTELEM2)1 << r) % divisor;
186
187
2.15M
  c = divisor / 2;                      /* for rounding */
188
189
2.15M
  if (fr == 0) {                        /* divisor is power of two */
190
    /* fq will be one bit too large to fit in DCTELEM, so adjust */
191
426k
    fq >>= 1;
192
426k
    r--;
193
1.72M
  } else if (fr <= (divisor / 2U)) {    /* fractional part is < 0.5 */
194
706k
    c++;
195
1.01M
  } else {                              /* fractional part is > 0.5 */
196
1.01M
    fq++;
197
1.01M
  }
198
199
2.15M
  dtbl[DCTSIZE2 * 0] = (DCTELEM)fq;     /* reciprocal */
200
2.15M
  dtbl[DCTSIZE2 * 1] = (DCTELEM)c;      /* correction + roundfactor */
201
2.15M
#ifdef WITH_SIMD
202
2.15M
  dtbl[DCTSIZE2 * 2] = (DCTELEM)(1 << (sizeof(DCTELEM) * 8 * 2 - r)); /* scale */
203
#else
204
  dtbl[DCTSIZE2 * 2] = 1;
205
#endif
206
2.15M
  dtbl[DCTSIZE2 * 3] = (DCTELEM)r - sizeof(DCTELEM) * 8; /* shift */
207
208
2.15M
  if (r <= 16) return 0;
209
2.15M
  else return 1;
210
2.15M
}
211
212
#endif
213
214
215
/*
216
 * Initialize for a processing pass.
217
 * Verify that all referenced Q-tables are present, and set up
218
 * the divisor table for each one.
219
 * In the current implementation, DCT of all components is done during
220
 * the first pass, even if only some components will be output in the
221
 * first scan.  Hence all components should be examined here.
222
 */
223
224
METHODDEF(void)
225
start_pass_fdctmgr(j_compress_ptr cinfo)
226
12.8k
{
227
12.8k
  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
228
12.8k
  int ci, qtblno, i;
229
12.8k
  jpeg_component_info *compptr;
230
12.8k
  JQUANT_TBL *qtbl;
231
12.8k
  DCTELEM *dtbl;
232
233
46.4k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
234
33.6k
       ci++, compptr++) {
235
33.6k
    qtblno = compptr->quant_tbl_no;
236
    /* Make sure specified quantization table is present */
237
33.6k
    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
238
33.6k
        cinfo->quant_tbl_ptrs[qtblno] == NULL)
239
0
      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
240
33.6k
    qtbl = cinfo->quant_tbl_ptrs[qtblno];
241
    /* Compute divisors for this quant table */
242
    /* We may do this more than once for same table, but it's not a big deal */
243
33.6k
    switch (cinfo->dct_method) {
244
0
#ifdef DCT_ISLOW_SUPPORTED
245
27.9k
    case JDCT_ISLOW:
246
      /* For LL&M IDCT method, divisors are equal to raw quantization
247
       * coefficients multiplied by 8 (to counteract scaling).
248
       */
249
27.9k
      if (fdct->divisors[qtblno] == NULL) {
250
18.5k
        fdct->divisors[qtblno] = (DCTELEM *)
251
18.5k
          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
252
18.5k
                                      (DCTSIZE2 * 4) * sizeof(DCTELEM));
253
18.5k
      }
254
27.9k
      dtbl = fdct->divisors[qtblno];
255
1.81M
      for (i = 0; i < DCTSIZE2; i++) {
256
#if BITS_IN_JSAMPLE == 8
257
#ifdef WITH_SIMD
258
1.78M
        if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
259
0
            fdct->quantize != quantize)
260
0
          fdct->quantize = quantize;
261
#else
262
        compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]);
263
#endif
264
#else
265
        dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
266
#endif
267
1.78M
      }
268
27.9k
      break;
269
0
#endif
270
0
#ifdef DCT_IFAST_SUPPORTED
271
5.66k
    case JDCT_IFAST:
272
5.66k
      {
273
        /* For AA&N IDCT method, divisors are equal to quantization
274
         * coefficients scaled by scalefactor[row]*scalefactor[col], where
275
         *   scalefactor[0] = 1
276
         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
277
         * We apply a further scale factor of 8.
278
         */
279
5.66k
#define CONST_BITS  14
280
5.66k
        static const INT16 aanscales[DCTSIZE2] = {
281
          /* precomputed values scaled up by 14 bits */
282
5.66k
          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
283
5.66k
          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
284
5.66k
          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
285
5.66k
          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
286
5.66k
          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
287
5.66k
          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
288
5.66k
           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
289
5.66k
           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
290
5.66k
        };
291
5.66k
        SHIFT_TEMPS
292
293
5.66k
        if (fdct->divisors[qtblno] == NULL) {
294
3.77k
          fdct->divisors[qtblno] = (DCTELEM *)
295
3.77k
            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
296
3.77k
                                        (DCTSIZE2 * 4) * sizeof(DCTELEM));
297
3.77k
        }
298
5.66k
        dtbl = fdct->divisors[qtblno];
299
368k
        for (i = 0; i < DCTSIZE2; i++) {
300
#if BITS_IN_JSAMPLE == 8
301
#ifdef WITH_SIMD
302
362k
          if (!compute_reciprocal(
303
362k
                DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
304
362k
                                      (JLONG)aanscales[i]),
305
362k
                        CONST_BITS - 3), &dtbl[i]) &&
306
0
              fdct->quantize != quantize)
307
0
            fdct->quantize = quantize;
308
#else
309
          compute_reciprocal(
310
            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
311
                                  (JLONG)aanscales[i]),
312
                    CONST_BITS-3), &dtbl[i]);
313
#endif
314
#else
315
          dtbl[i] = (DCTELEM)
316
0
            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
317
                                  (JLONG)aanscales[i]),
318
                    CONST_BITS - 3);
319
#endif
320
362k
        }
321
5.66k
      }
322
5.66k
      break;
323
0
#endif
324
0
#ifdef DCT_FLOAT_SUPPORTED
325
0
    case JDCT_FLOAT:
326
0
      {
327
        /* For float AA&N IDCT method, divisors are equal to quantization
328
         * coefficients scaled by scalefactor[row]*scalefactor[col], where
329
         *   scalefactor[0] = 1
330
         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
331
         * We apply a further scale factor of 8.
332
         * What's actually stored is 1/divisor so that the inner loop can
333
         * use a multiplication rather than a division.
334
         */
335
0
        FAST_FLOAT *fdtbl;
336
0
        int row, col;
337
0
        static const double aanscalefactor[DCTSIZE] = {
338
0
          1.0, 1.387039845, 1.306562965, 1.175875602,
339
0
          1.0, 0.785694958, 0.541196100, 0.275899379
340
0
        };
341
342
0
        if (fdct->float_divisors[qtblno] == NULL) {
343
0
          fdct->float_divisors[qtblno] = (FAST_FLOAT *)
344
0
            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
345
0
                                        DCTSIZE2 * sizeof(FAST_FLOAT));
346
0
        }
347
0
        fdtbl = fdct->float_divisors[qtblno];
348
0
        i = 0;
349
0
        for (row = 0; row < DCTSIZE; row++) {
350
0
          for (col = 0; col < DCTSIZE; col++) {
351
0
            fdtbl[i] = (FAST_FLOAT)
352
0
              (1.0 / (((double)qtbl->quantval[i] *
353
0
                       aanscalefactor[row] * aanscalefactor[col] * 8.0)));
354
0
            i++;
355
0
          }
356
0
        }
357
0
      }
358
0
      break;
359
0
#endif
360
0
    default:
361
0
      ERREXIT(cinfo, JERR_NOT_COMPILED);
362
0
      break;
363
33.6k
    }
364
33.6k
  }
365
12.8k
}
jcdctmgr-8.c:start_pass_fdctmgr
Line
Count
Source
226
12.8k
{
227
12.8k
  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
228
12.8k
  int ci, qtblno, i;
229
12.8k
  jpeg_component_info *compptr;
230
12.8k
  JQUANT_TBL *qtbl;
231
12.8k
  DCTELEM *dtbl;
232
233
46.4k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
234
33.6k
       ci++, compptr++) {
235
33.6k
    qtblno = compptr->quant_tbl_no;
236
    /* Make sure specified quantization table is present */
237
33.6k
    if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
238
33.6k
        cinfo->quant_tbl_ptrs[qtblno] == NULL)
239
0
      ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
240
33.6k
    qtbl = cinfo->quant_tbl_ptrs[qtblno];
241
    /* Compute divisors for this quant table */
242
    /* We may do this more than once for same table, but it's not a big deal */
243
33.6k
    switch (cinfo->dct_method) {
244
0
#ifdef DCT_ISLOW_SUPPORTED
245
27.9k
    case JDCT_ISLOW:
246
      /* For LL&M IDCT method, divisors are equal to raw quantization
247
       * coefficients multiplied by 8 (to counteract scaling).
248
       */
249
27.9k
      if (fdct->divisors[qtblno] == NULL) {
250
18.5k
        fdct->divisors[qtblno] = (DCTELEM *)
251
18.5k
          (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
252
18.5k
                                      (DCTSIZE2 * 4) * sizeof(DCTELEM));
253
18.5k
      }
254
27.9k
      dtbl = fdct->divisors[qtblno];
255
1.81M
      for (i = 0; i < DCTSIZE2; i++) {
256
1.78M
#if BITS_IN_JSAMPLE == 8
257
1.78M
#ifdef WITH_SIMD
258
1.78M
        if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&
259
0
            fdct->quantize != quantize)
260
0
          fdct->quantize = quantize;
261
#else
262
        compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]);
263
#endif
264
#else
265
        dtbl[i] = ((DCTELEM)qtbl->quantval[i]) << 3;
266
#endif
267
1.78M
      }
268
27.9k
      break;
269
0
#endif
270
0
#ifdef DCT_IFAST_SUPPORTED
271
5.66k
    case JDCT_IFAST:
272
5.66k
      {
273
        /* For AA&N IDCT method, divisors are equal to quantization
274
         * coefficients scaled by scalefactor[row]*scalefactor[col], where
275
         *   scalefactor[0] = 1
276
         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
277
         * We apply a further scale factor of 8.
278
         */
279
5.66k
#define CONST_BITS  14
280
5.66k
        static const INT16 aanscales[DCTSIZE2] = {
281
          /* precomputed values scaled up by 14 bits */
282
5.66k
          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
283
5.66k
          22725, 31521, 29692, 26722, 22725, 17855, 12299,  6270,
284
5.66k
          21407, 29692, 27969, 25172, 21407, 16819, 11585,  5906,
285
5.66k
          19266, 26722, 25172, 22654, 19266, 15137, 10426,  5315,
286
5.66k
          16384, 22725, 21407, 19266, 16384, 12873,  8867,  4520,
287
5.66k
          12873, 17855, 16819, 15137, 12873, 10114,  6967,  3552,
288
5.66k
           8867, 12299, 11585, 10426,  8867,  6967,  4799,  2446,
289
5.66k
           4520,  6270,  5906,  5315,  4520,  3552,  2446,  1247
290
5.66k
        };
291
5.66k
        SHIFT_TEMPS
292
293
5.66k
        if (fdct->divisors[qtblno] == NULL) {
294
3.77k
          fdct->divisors[qtblno] = (DCTELEM *)
295
3.77k
            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
296
3.77k
                                        (DCTSIZE2 * 4) * sizeof(DCTELEM));
297
3.77k
        }
298
5.66k
        dtbl = fdct->divisors[qtblno];
299
368k
        for (i = 0; i < DCTSIZE2; i++) {
300
362k
#if BITS_IN_JSAMPLE == 8
301
362k
#ifdef WITH_SIMD
302
362k
          if (!compute_reciprocal(
303
362k
                DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
304
362k
                                      (JLONG)aanscales[i]),
305
362k
                        CONST_BITS - 3), &dtbl[i]) &&
306
0
              fdct->quantize != quantize)
307
0
            fdct->quantize = quantize;
308
#else
309
          compute_reciprocal(
310
            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
311
                                  (JLONG)aanscales[i]),
312
                    CONST_BITS-3), &dtbl[i]);
313
#endif
314
#else
315
          dtbl[i] = (DCTELEM)
316
            DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i],
317
                                  (JLONG)aanscales[i]),
318
                    CONST_BITS - 3);
319
#endif
320
362k
        }
321
5.66k
      }
322
5.66k
      break;
323
0
#endif
324
0
#ifdef DCT_FLOAT_SUPPORTED
325
0
    case JDCT_FLOAT:
326
0
      {
327
        /* For float AA&N IDCT method, divisors are equal to quantization
328
         * coefficients scaled by scalefactor[row]*scalefactor[col], where
329
         *   scalefactor[0] = 1
330
         *   scalefactor[k] = cos(k*PI/16) * sqrt(2)    for k=1..7
331
         * We apply a further scale factor of 8.
332
         * What's actually stored is 1/divisor so that the inner loop can
333
         * use a multiplication rather than a division.
334
         */
335
0
        FAST_FLOAT *fdtbl;
336
0
        int row, col;
337
0
        static const double aanscalefactor[DCTSIZE] = {
338
0
          1.0, 1.387039845, 1.306562965, 1.175875602,
339
0
          1.0, 0.785694958, 0.541196100, 0.275899379
340
0
        };
341
342
0
        if (fdct->float_divisors[qtblno] == NULL) {
343
0
          fdct->float_divisors[qtblno] = (FAST_FLOAT *)
344
0
            (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
345
0
                                        DCTSIZE2 * sizeof(FAST_FLOAT));
346
0
        }
347
0
        fdtbl = fdct->float_divisors[qtblno];
348
0
        i = 0;
349
0
        for (row = 0; row < DCTSIZE; row++) {
350
0
          for (col = 0; col < DCTSIZE; col++) {
351
0
            fdtbl[i] = (FAST_FLOAT)
352
0
              (1.0 / (((double)qtbl->quantval[i] *
353
0
                       aanscalefactor[row] * aanscalefactor[col] * 8.0)));
354
0
            i++;
355
0
          }
356
0
        }
357
0
      }
358
0
      break;
359
0
#endif
360
0
    default:
361
0
      ERREXIT(cinfo, JERR_NOT_COMPILED);
362
0
      break;
363
33.6k
    }
364
33.6k
  }
365
12.8k
}
Unexecuted instantiation: jcdctmgr-12.c:start_pass_fdctmgr
366
367
368
/*
369
 * Load data into workspace, applying unsigned->signed conversion.
370
 */
371
372
METHODDEF(void)
373
convsamp(_JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)
374
0
{
375
0
  register DCTELEM *workspaceptr;
376
0
  register _JSAMPROW elemptr;
377
0
  register int elemr;
378
379
0
  workspaceptr = workspace;
380
0
  for (elemr = 0; elemr < DCTSIZE; elemr++) {
381
0
    elemptr = sample_data[elemr] + start_col;
382
383
0
#if DCTSIZE == 8                /* unroll the inner loop */
384
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
385
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
386
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
387
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
388
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
389
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
390
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
391
0
    *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
392
#else
393
    {
394
      register int elemc;
395
      for (elemc = DCTSIZE; elemc > 0; elemc--)
396
        *workspaceptr++ = (*elemptr++) - _CENTERJSAMPLE;
397
    }
398
#endif
399
0
  }
400
0
}
Unexecuted instantiation: jcdctmgr-8.c:convsamp
Unexecuted instantiation: jcdctmgr-12.c:convsamp
401
402
403
/*
404
 * Quantize/descale the coefficients, and store into coef_blocks[].
405
 */
406
407
METHODDEF(void)
408
quantize(JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)
409
0
{
410
0
  int i;
411
0
  DCTELEM temp;
412
0
  JCOEFPTR output_ptr = coef_block;
413
414
#if BITS_IN_JSAMPLE == 8
415
416
  UDCTELEM recip, corr;
417
  int shift;
418
  UDCTELEM2 product;
419
420
0
  for (i = 0; i < DCTSIZE2; i++) {
421
0
    temp = workspace[i];
422
0
    recip = divisors[i + DCTSIZE2 * 0];
423
0
    corr =  divisors[i + DCTSIZE2 * 1];
424
0
    shift = divisors[i + DCTSIZE2 * 3];
425
426
0
    if (temp < 0) {
427
0
      temp = -temp;
428
0
      product = (UDCTELEM2)(temp + corr) * recip;
429
0
      product >>= shift + sizeof(DCTELEM) * 8;
430
0
      temp = (DCTELEM)product;
431
0
      temp = -temp;
432
0
    } else {
433
0
      product = (UDCTELEM2)(temp + corr) * recip;
434
0
      product >>= shift + sizeof(DCTELEM) * 8;
435
0
      temp = (DCTELEM)product;
436
0
    }
437
0
    output_ptr[i] = (JCOEF)temp;
438
0
  }
439
440
#else
441
442
  register DCTELEM qval;
443
444
0
  for (i = 0; i < DCTSIZE2; i++) {
445
0
    qval = divisors[i];
446
0
    temp = workspace[i];
447
    /* Divide the coefficient value by qval, ensuring proper rounding.
448
     * Since C does not specify the direction of rounding for negative
449
     * quotients, we have to force the dividend positive for portability.
450
     *
451
     * In most files, at least half of the output values will be zero
452
     * (at default quantization settings, more like three-quarters...)
453
     * so we should ensure that this case is fast.  On many machines,
454
     * a comparison is enough cheaper than a divide to make a special test
455
     * a win.  Since both inputs will be nonnegative, we need only test
456
     * for a < b to discover whether a/b is 0.
457
     * If your machine's division is fast enough, define FAST_DIVIDE.
458
     */
459
#ifdef FAST_DIVIDE
460
#define DIVIDE_BY(a, b)  a /= b
461
#else
462
0
#define DIVIDE_BY(a, b)  if (a >= b) a /= b;  else a = 0
463
0
#endif
464
0
    if (temp < 0) {
465
0
      temp = -temp;
466
0
      temp += qval >> 1;        /* for rounding */
467
0
      DIVIDE_BY(temp, qval);
468
0
      temp = -temp;
469
0
    } else {
470
0
      temp += qval >> 1;        /* for rounding */
471
0
      DIVIDE_BY(temp, qval);
472
0
    }
473
0
    output_ptr[i] = (JCOEF)temp;
474
0
  }
475
476
#endif
477
478
0
}
Unexecuted instantiation: jcdctmgr-8.c:quantize
Unexecuted instantiation: jcdctmgr-12.c:quantize
479
480
481
/*
482
 * Perform forward DCT on one or more blocks of a component.
483
 *
484
 * The input samples are taken from the sample_data[] array starting at
485
 * position start_row/start_col, and moving to the right for any additional
486
 * blocks. The quantized coefficients are returned in coef_blocks[].
487
 */
488
489
METHODDEF(void)
490
forward_DCT(j_compress_ptr cinfo, jpeg_component_info *compptr,
491
            _JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
492
            JDIMENSION start_row, JDIMENSION start_col, JDIMENSION num_blocks)
493
/* This version is used for integer DCT implementations. */
494
15.4M
{
495
  /* This routine is heavily used, so it's worth coding it tightly. */
496
15.4M
  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
497
15.4M
  DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
498
15.4M
  DCTELEM *workspace;
499
15.4M
  JDIMENSION bi;
500
501
  /* Make sure the compiler doesn't look up these every pass */
502
15.4M
  forward_DCT_method_ptr do_dct = fdct->dct;
503
15.4M
  convsamp_method_ptr do_convsamp = fdct->convsamp;
504
15.4M
  quantize_method_ptr do_quantize = fdct->quantize;
505
15.4M
  workspace = fdct->workspace;
506
507
15.4M
  sample_data += start_row;     /* fold in the vertical offset once */
508
509
34.9M
  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
510
    /* Load data into workspace, applying unsigned->signed conversion */
511
#ifdef WITH_PROFILE
512
    cinfo->master->start = getTime();
513
#endif
514
19.4M
    (*do_convsamp) (sample_data, start_col, workspace);
515
#ifdef WITH_PROFILE
516
    cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start;
517
    cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.;
518
#endif
519
520
    /* Perform the DCT */
521
#ifdef WITH_PROFILE
522
    cinfo->master->start = getTime();
523
#endif
524
19.4M
    (*do_dct) (workspace);
525
#ifdef WITH_PROFILE
526
    cinfo->master->fdct_elapsed += getTime() - cinfo->master->start;
527
    cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.;
528
#endif
529
530
    /* Quantize/descale the coefficients, and store into coef_blocks[] */
531
#ifdef WITH_PROFILE
532
    cinfo->master->start = getTime();
533
#endif
534
19.4M
    (*do_quantize) (coef_blocks[bi], divisors, workspace);
535
#ifdef WITH_PROFILE
536
    cinfo->master->quantize_elapsed += getTime() - cinfo->master->start;
537
    cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.;
538
#endif
539
19.4M
  }
540
15.4M
}
jcdctmgr-8.c:forward_DCT
Line
Count
Source
494
15.4M
{
495
  /* This routine is heavily used, so it's worth coding it tightly. */
496
15.4M
  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
497
15.4M
  DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];
498
15.4M
  DCTELEM *workspace;
499
15.4M
  JDIMENSION bi;
500
501
  /* Make sure the compiler doesn't look up these every pass */
502
15.4M
  forward_DCT_method_ptr do_dct = fdct->dct;
503
15.4M
  convsamp_method_ptr do_convsamp = fdct->convsamp;
504
15.4M
  quantize_method_ptr do_quantize = fdct->quantize;
505
15.4M
  workspace = fdct->workspace;
506
507
15.4M
  sample_data += start_row;     /* fold in the vertical offset once */
508
509
34.9M
  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
510
    /* Load data into workspace, applying unsigned->signed conversion */
511
#ifdef WITH_PROFILE
512
    cinfo->master->start = getTime();
513
#endif
514
19.4M
    (*do_convsamp) (sample_data, start_col, workspace);
515
#ifdef WITH_PROFILE
516
    cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start;
517
    cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.;
518
#endif
519
520
    /* Perform the DCT */
521
#ifdef WITH_PROFILE
522
    cinfo->master->start = getTime();
523
#endif
524
19.4M
    (*do_dct) (workspace);
525
#ifdef WITH_PROFILE
526
    cinfo->master->fdct_elapsed += getTime() - cinfo->master->start;
527
    cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.;
528
#endif
529
530
    /* Quantize/descale the coefficients, and store into coef_blocks[] */
531
#ifdef WITH_PROFILE
532
    cinfo->master->start = getTime();
533
#endif
534
19.4M
    (*do_quantize) (coef_blocks[bi], divisors, workspace);
535
#ifdef WITH_PROFILE
536
    cinfo->master->quantize_elapsed += getTime() - cinfo->master->start;
537
    cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.;
538
#endif
539
19.4M
  }
540
15.4M
}
Unexecuted instantiation: jcdctmgr-12.c:forward_DCT
541
542
543
#ifdef DCT_FLOAT_SUPPORTED
544
545
METHODDEF(void)
546
convsamp_float(_JSAMPARRAY sample_data, JDIMENSION start_col,
547
               FAST_FLOAT *workspace)
548
0
{
549
0
  register FAST_FLOAT *workspaceptr;
550
0
  register _JSAMPROW elemptr;
551
0
  register int elemr;
552
553
0
  workspaceptr = workspace;
554
0
  for (elemr = 0; elemr < DCTSIZE; elemr++) {
555
0
    elemptr = sample_data[elemr] + start_col;
556
0
#if DCTSIZE == 8                /* unroll the inner loop */
557
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
558
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
559
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
560
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
561
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
562
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
563
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
564
0
    *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
565
#else
566
    {
567
      register int elemc;
568
      for (elemc = DCTSIZE; elemc > 0; elemc--)
569
        *workspaceptr++ = (FAST_FLOAT)((*elemptr++) - _CENTERJSAMPLE);
570
    }
571
#endif
572
0
  }
573
0
}
Unexecuted instantiation: jcdctmgr-8.c:convsamp_float
Unexecuted instantiation: jcdctmgr-12.c:convsamp_float
574
575
576
METHODDEF(void)
577
quantize_float(JCOEFPTR coef_block, FAST_FLOAT *divisors,
578
               FAST_FLOAT *workspace)
579
0
{
580
0
  register FAST_FLOAT temp;
581
0
  register int i;
582
0
  register JCOEFPTR output_ptr = coef_block;
583
584
0
  for (i = 0; i < DCTSIZE2; i++) {
585
    /* Apply the quantization and scaling factor */
586
0
    temp = workspace[i] * divisors[i];
587
588
    /* Round to nearest integer.
589
     * Since C does not specify the direction of rounding for negative
590
     * quotients, we have to force the dividend positive for portability.
591
     * The maximum coefficient size is +-16K (for 12-bit data), so this
592
     * code should work for either 16-bit or 32-bit ints.
593
     */
594
0
    output_ptr[i] = (JCOEF)((int)(temp + (FAST_FLOAT)16384.5) - 16384);
595
0
  }
596
0
}
Unexecuted instantiation: jcdctmgr-8.c:quantize_float
Unexecuted instantiation: jcdctmgr-12.c:quantize_float
597
598
599
METHODDEF(void)
600
forward_DCT_float(j_compress_ptr cinfo, jpeg_component_info *compptr,
601
                  _JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
602
                  JDIMENSION start_row, JDIMENSION start_col,
603
                  JDIMENSION num_blocks)
604
/* This version is used for floating-point DCT implementations. */
605
0
{
606
  /* This routine is heavily used, so it's worth coding it tightly. */
607
0
  my_fdct_ptr fdct = (my_fdct_ptr)cinfo->fdct;
608
0
  FAST_FLOAT *divisors = fdct->float_divisors[compptr->quant_tbl_no];
609
0
  FAST_FLOAT *workspace;
610
0
  JDIMENSION bi;
611
612
613
  /* Make sure the compiler doesn't look up these every pass */
614
0
  float_DCT_method_ptr do_dct = fdct->float_dct;
615
0
  float_convsamp_method_ptr do_convsamp = fdct->float_convsamp;
616
0
  float_quantize_method_ptr do_quantize = fdct->float_quantize;
617
0
  workspace = fdct->float_workspace;
618
619
0
  sample_data += start_row;     /* fold in the vertical offset once */
620
621
0
  for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {
622
    /* Load data into workspace, applying unsigned->signed conversion */
623
#ifdef WITH_PROFILE
624
    cinfo->master->start = getTime();
625
#endif
626
0
    (*do_convsamp) (sample_data, start_col, workspace);
627
#ifdef WITH_PROFILE
628
    cinfo->master->convsamp_elapsed += getTime() - cinfo->master->start;
629
    cinfo->master->convsamp_msamples += (double)DCTSIZE2 / 1000000.;
630
#endif
631
632
    /* Perform the DCT */
633
#ifdef WITH_PROFILE
634
    cinfo->master->start = getTime();
635
#endif
636
0
    (*do_dct) (workspace);
637
#ifdef WITH_PROFILE
638
    cinfo->master->fdct_elapsed += getTime() - cinfo->master->start;
639
    cinfo->master->fdct_mcoeffs += (double)DCTSIZE2 / 1000000.;
640
#endif
641
642
    /* Quantize/descale the coefficients, and store into coef_blocks[] */
643
#ifdef WITH_PROFILE
644
    cinfo->master->start = getTime();
645
#endif
646
0
    (*do_quantize) (coef_blocks[bi], divisors, workspace);
647
#ifdef WITH_PROFILE
648
    cinfo->master->quantize_elapsed += getTime() - cinfo->master->start;
649
    cinfo->master->quantize_mcoeffs += (double)DCTSIZE2 / 1000000.;
650
#endif
651
0
  }
652
0
}
Unexecuted instantiation: jcdctmgr-8.c:forward_DCT_float
Unexecuted instantiation: jcdctmgr-12.c:forward_DCT_float
653
654
#endif /* DCT_FLOAT_SUPPORTED */
655
656
657
/*
658
 * Initialize FDCT manager.
659
 */
660
661
GLOBAL(void)
662
_jinit_forward_dct(j_compress_ptr cinfo)
663
12.8k
{
664
12.8k
  my_fdct_ptr fdct;
665
12.8k
  int i;
666
667
12.8k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
668
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
669
670
12.8k
  fdct = (my_fdct_ptr)
671
12.8k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
672
12.8k
                                sizeof(my_fdct_controller));
673
12.8k
  cinfo->fdct = (struct jpeg_forward_dct *)fdct;
674
12.8k
  fdct->pub.start_pass = start_pass_fdctmgr;
675
676
  /* First determine the DCT... */
677
12.8k
  switch (cinfo->dct_method) {
678
0
#ifdef DCT_ISLOW_SUPPORTED
679
10.9k
  case JDCT_ISLOW:
680
10.9k
    fdct->pub._forward_DCT = forward_DCT;
681
#ifdef WITH_SIMD
682
10.9k
    if (!jsimd_set_fdct_islow(cinfo, &fdct->dct))
683
0
#endif
684
0
      fdct->dct = _jpeg_fdct_islow;
685
10.9k
    break;
686
0
#endif
687
0
#ifdef DCT_IFAST_SUPPORTED
688
1.88k
  case JDCT_IFAST:
689
1.88k
    fdct->pub._forward_DCT = forward_DCT;
690
#ifdef WITH_SIMD
691
1.88k
    if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct))
692
0
#endif
693
0
      fdct->dct = _jpeg_fdct_ifast;
694
1.88k
    break;
695
0
#endif
696
0
#ifdef DCT_FLOAT_SUPPORTED
697
0
  case JDCT_FLOAT:
698
0
    fdct->pub._forward_DCT = forward_DCT_float;
699
#ifdef WITH_SIMD
700
0
    if (!jsimd_set_fdct_float(cinfo, &fdct->float_dct))
701
0
#endif
702
0
      fdct->float_dct = jpeg_fdct_float;
703
0
    break;
704
0
#endif
705
0
  default:
706
0
    ERREXIT(cinfo, JERR_NOT_COMPILED);
707
0
    break;
708
12.8k
  }
709
710
  /* ...then the supporting stages. */
711
12.8k
  switch (cinfo->dct_method) {
712
0
#ifdef DCT_ISLOW_SUPPORTED
713
10.9k
  case JDCT_ISLOW:
714
10.9k
#endif
715
10.9k
#ifdef DCT_IFAST_SUPPORTED
716
12.8k
  case JDCT_IFAST:
717
12.8k
#endif
718
12.8k
#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
719
#ifdef WITH_SIMD
720
12.8k
    if (!jsimd_set_convsamp(cinfo, &fdct->convsamp))
721
0
#endif
722
0
      fdct->convsamp = convsamp;
723
#ifdef WITH_SIMD
724
12.8k
    if (!jsimd_set_quantize(cinfo, &fdct->quantize))
725
0
#endif
726
0
      fdct->quantize = quantize;
727
12.8k
    break;
728
0
#endif
729
0
#ifdef DCT_FLOAT_SUPPORTED
730
0
  case JDCT_FLOAT:
731
#ifdef WITH_SIMD
732
0
    if (!jsimd_set_convsamp_float(cinfo, &fdct->float_convsamp))
733
0
#endif
734
0
      fdct->float_convsamp = convsamp_float;
735
#ifdef WITH_SIMD
736
0
    if (!jsimd_set_quantize_float(cinfo, &fdct->float_quantize))
737
0
#endif
738
0
      fdct->float_quantize = quantize_float;
739
0
    break;
740
0
#endif
741
0
  default:
742
0
    ERREXIT(cinfo, JERR_NOT_COMPILED);
743
0
    break;
744
12.8k
  }
745
746
  /* Allocate workspace memory */
747
12.8k
#ifdef DCT_FLOAT_SUPPORTED
748
12.8k
  if (cinfo->dct_method == JDCT_FLOAT)
749
0
    fdct->float_workspace = (FAST_FLOAT *)
750
0
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
751
0
                                  sizeof(FAST_FLOAT) * DCTSIZE2);
752
12.8k
  else
753
12.8k
#endif
754
12.8k
    fdct->workspace = (DCTELEM *)
755
12.8k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
756
12.8k
                                  sizeof(DCTELEM) * DCTSIZE2);
757
758
  /* Mark divisor tables unallocated */
759
64.2k
  for (i = 0; i < NUM_QUANT_TBLS; i++) {
760
51.4k
    fdct->divisors[i] = NULL;
761
51.4k
#ifdef DCT_FLOAT_SUPPORTED
762
    fdct->float_divisors[i] = NULL;
763
51.4k
#endif
764
51.4k
  }
765
12.8k
}
jinit_forward_dct
Line
Count
Source
663
12.8k
{
664
12.8k
  my_fdct_ptr fdct;
665
12.8k
  int i;
666
667
12.8k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
668
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
669
670
12.8k
  fdct = (my_fdct_ptr)
671
12.8k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
672
12.8k
                                sizeof(my_fdct_controller));
673
12.8k
  cinfo->fdct = (struct jpeg_forward_dct *)fdct;
674
12.8k
  fdct->pub.start_pass = start_pass_fdctmgr;
675
676
  /* First determine the DCT... */
677
12.8k
  switch (cinfo->dct_method) {
678
0
#ifdef DCT_ISLOW_SUPPORTED
679
10.9k
  case JDCT_ISLOW:
680
10.9k
    fdct->pub._forward_DCT = forward_DCT;
681
10.9k
#ifdef WITH_SIMD
682
10.9k
    if (!jsimd_set_fdct_islow(cinfo, &fdct->dct))
683
0
#endif
684
0
      fdct->dct = _jpeg_fdct_islow;
685
10.9k
    break;
686
0
#endif
687
0
#ifdef DCT_IFAST_SUPPORTED
688
1.88k
  case JDCT_IFAST:
689
1.88k
    fdct->pub._forward_DCT = forward_DCT;
690
1.88k
#ifdef WITH_SIMD
691
1.88k
    if (!jsimd_set_fdct_ifast(cinfo, &fdct->dct))
692
0
#endif
693
0
      fdct->dct = _jpeg_fdct_ifast;
694
1.88k
    break;
695
0
#endif
696
0
#ifdef DCT_FLOAT_SUPPORTED
697
0
  case JDCT_FLOAT:
698
0
    fdct->pub._forward_DCT = forward_DCT_float;
699
0
#ifdef WITH_SIMD
700
0
    if (!jsimd_set_fdct_float(cinfo, &fdct->float_dct))
701
0
#endif
702
0
      fdct->float_dct = jpeg_fdct_float;
703
0
    break;
704
0
#endif
705
0
  default:
706
0
    ERREXIT(cinfo, JERR_NOT_COMPILED);
707
0
    break;
708
12.8k
  }
709
710
  /* ...then the supporting stages. */
711
12.8k
  switch (cinfo->dct_method) {
712
0
#ifdef DCT_ISLOW_SUPPORTED
713
10.9k
  case JDCT_ISLOW:
714
10.9k
#endif
715
10.9k
#ifdef DCT_IFAST_SUPPORTED
716
12.8k
  case JDCT_IFAST:
717
12.8k
#endif
718
12.8k
#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)
719
12.8k
#ifdef WITH_SIMD
720
12.8k
    if (!jsimd_set_convsamp(cinfo, &fdct->convsamp))
721
0
#endif
722
0
      fdct->convsamp = convsamp;
723
12.8k
#ifdef WITH_SIMD
724
12.8k
    if (!jsimd_set_quantize(cinfo, &fdct->quantize))
725
0
#endif
726
0
      fdct->quantize = quantize;
727
12.8k
    break;
728
0
#endif
729
0
#ifdef DCT_FLOAT_SUPPORTED
730
0
  case JDCT_FLOAT:
731
0
#ifdef WITH_SIMD
732
0
    if (!jsimd_set_convsamp_float(cinfo, &fdct->float_convsamp))
733
0
#endif
734
0
      fdct->float_convsamp = convsamp_float;
735
0
#ifdef WITH_SIMD
736
0
    if (!jsimd_set_quantize_float(cinfo, &fdct->float_quantize))
737
0
#endif
738
0
      fdct->float_quantize = quantize_float;
739
0
    break;
740
0
#endif
741
0
  default:
742
0
    ERREXIT(cinfo, JERR_NOT_COMPILED);
743
0
    break;
744
12.8k
  }
745
746
  /* Allocate workspace memory */
747
12.8k
#ifdef DCT_FLOAT_SUPPORTED
748
12.8k
  if (cinfo->dct_method == JDCT_FLOAT)
749
0
    fdct->float_workspace = (FAST_FLOAT *)
750
0
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
751
0
                                  sizeof(FAST_FLOAT) * DCTSIZE2);
752
12.8k
  else
753
12.8k
#endif
754
12.8k
    fdct->workspace = (DCTELEM *)
755
12.8k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
756
12.8k
                                  sizeof(DCTELEM) * DCTSIZE2);
757
758
  /* Mark divisor tables unallocated */
759
64.2k
  for (i = 0; i < NUM_QUANT_TBLS; i++) {
760
51.4k
    fdct->divisors[i] = NULL;
761
51.4k
#ifdef DCT_FLOAT_SUPPORTED
762
    fdct->float_divisors[i] = NULL;
763
51.4k
#endif
764
51.4k
  }
765
12.8k
}
Unexecuted instantiation: j12init_forward_dct