Coverage Report

Created: 2026-02-26 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjpeg-turbo.3.0.x/jcprepct.c
Line
Count
Source
1
/*
2
 * jcprepct.c
3
 *
4
 * This file was part of the Independent JPEG Group's software:
5
 * Copyright (C) 1994-1996, Thomas G. Lane.
6
 * Lossless JPEG Modifications:
7
 * Copyright (C) 1999, Ken Murchison.
8
 * libjpeg-turbo Modifications:
9
 * Copyright (C) 2022, 2026, D. R. Commander.
10
 * For conditions of distribution and use, see the accompanying README.ijg
11
 * file.
12
 *
13
 * This file contains the compression preprocessing controller.
14
 * This controller manages the color conversion, downsampling,
15
 * and edge expansion steps.
16
 *
17
 * Most of the complexity here is associated with buffering input rows
18
 * as required by the downsampler.  See the comments at the head of
19
 * jcsample.c for the downsampler's needs.
20
 */
21
22
#define JPEG_INTERNALS
23
#include "jinclude.h"
24
#include "jpeglib.h"
25
#include "jsamplecomp.h"
26
27
28
#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
29
30
/* At present, jcsample.c can request context rows only for smoothing.
31
 * In the future, we might also need context rows for CCIR601 sampling
32
 * or other more-complex downsampling procedures.  The code to support
33
 * context rows should be compiled only if needed.
34
 */
35
#ifdef INPUT_SMOOTHING_SUPPORTED
36
#define CONTEXT_ROWS_SUPPORTED
37
#endif
38
39
40
/*
41
 * For the simple (no-context-row) case, we just need to buffer one row group's
42
 * worth of components for the downsampling step.  At the bottom of the image,
43
 * we pad to a full row group by replicating the last component row(s).  The
44
 * downsampler's last output row is then replicated if needed to pad out to a
45
 * full iMCU row.
46
 *
47
 * When providing context rows, we must buffer three row groups' worth of
48
 * components.  Three row groups are physically allocated, but the row pointer
49
 * arrays are made five row groups high, with the extra pointers above and
50
 * below "wrapping around" to point to the last and first real row groups.
51
 * This allows the downsampler to access the proper context rows.  At the top
52
 * and bottom of the image, we create dummy context rows by copying the first
53
 * or last real component row(s).  This copying could be avoided by pointer
54
 * hacking, as is done in jdmainct.c, but it doesn't seem worth the trouble on
55
 * the compression side.
56
 */
57
58
59
/* Private buffer controller object */
60
61
typedef struct {
62
  struct jpeg_c_prep_controller pub; /* public fields */
63
64
  /* Downsampling input buffer.  This buffer holds color-converted data
65
   * until we have enough to do a downsample step.
66
   */
67
  _JSAMPARRAY color_buf[MAX_COMPONENTS];
68
69
  JDIMENSION rows_to_go;        /* counts rows remaining in source image */
70
  int next_buf_row;             /* index of next row to store in color_buf */
71
72
#ifdef CONTEXT_ROWS_SUPPORTED   /* only needed for context case */
73
  int this_row_group;           /* starting row index of group to process */
74
  int next_buf_stop;            /* downsample when we reach this index */
75
#endif
76
} my_prep_controller;
77
78
typedef my_prep_controller *my_prep_ptr;
79
80
81
/*
82
 * Initialize for a processing pass.
83
 */
84
85
METHODDEF(void)
86
start_pass_prep(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
87
44.0k
{
88
44.0k
  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
89
90
44.0k
  if (pass_mode != JBUF_PASS_THRU)
91
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
92
93
  /* Initialize total-height counter for detecting bottom of image */
94
44.0k
  prep->rows_to_go = cinfo->image_height;
95
  /* Mark the conversion buffer empty */
96
44.0k
  prep->next_buf_row = 0;
97
44.0k
#ifdef CONTEXT_ROWS_SUPPORTED
98
  /* Preset additional state variables for context mode.
99
   * These aren't used in non-context mode, so we needn't test which mode.
100
   */
101
44.0k
  prep->this_row_group = 0;
102
  /* Set next_buf_stop to stop after two row groups have been read in. */
103
44.0k
  prep->next_buf_stop = 2 * cinfo->max_v_samp_factor;
104
44.0k
#endif
105
44.0k
}
106
107
108
/*
109
 * Expand an image vertically from height input_rows to height output_rows,
110
 * by duplicating the bottom row.
111
 */
112
113
LOCAL(void)
114
expand_bottom_edge(_JSAMPARRAY image_data, JDIMENSION num_cols, int input_rows,
115
                   int output_rows)
116
96.0k
{
117
96.0k
  register int row;
118
119
567k
  for (row = input_rows; row < output_rows; row++) {
120
470k
    _jcopy_sample_rows(image_data, input_rows - 1, image_data, row, 1,
121
470k
                       num_cols);
122
470k
  }
123
96.0k
}
124
125
126
/*
127
 * Process some data in the simple no-context case.
128
 *
129
 * Preprocessor output data is counted in "row groups".  A row group
130
 * is defined to be v_samp_factor sample rows of each component.
131
 * Downsampling will produce this much data from each max_v_samp_factor
132
 * input rows.
133
 */
134
135
METHODDEF(void)
136
pre_process_data(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
137
                 JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
138
                 _JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
139
                 JDIMENSION out_row_groups_avail)
140
68.6M
{
141
68.6M
  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
142
68.6M
  int numrows, ci;
143
68.6M
  JDIMENSION inrows;
144
68.6M
  jpeg_component_info *compptr;
145
68.6M
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
146
147
214M
  while (*in_row_ctr < in_rows_avail &&
148
198M
         *out_row_group_ctr < out_row_groups_avail) {
149
    /* Do color conversion to fill the conversion buffer. */
150
145M
    inrows = in_rows_avail - *in_row_ctr;
151
145M
    numrows = cinfo->max_v_samp_factor - prep->next_buf_row;
152
145M
    numrows = (int)MIN((JDIMENSION)numrows, inrows);
153
145M
    (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
154
145M
                                        prep->color_buf,
155
145M
                                        (JDIMENSION)prep->next_buf_row,
156
145M
                                        numrows);
157
145M
    *in_row_ctr += numrows;
158
145M
    prep->next_buf_row += numrows;
159
145M
    prep->rows_to_go -= numrows;
160
    /* If at bottom of image, pad to fill the conversion buffer. */
161
145M
    if (prep->rows_to_go == 0 &&
162
41.2k
        prep->next_buf_row < cinfo->max_v_samp_factor) {
163
19.8k
      for (ci = 0; ci < cinfo->num_components; ci++) {
164
15.4k
        expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
165
15.4k
                           prep->next_buf_row, cinfo->max_v_samp_factor);
166
15.4k
      }
167
4.45k
      prep->next_buf_row = cinfo->max_v_samp_factor;
168
4.45k
    }
169
    /* If we've filled the conversion buffer, empty it. */
170
145M
    if (prep->next_buf_row == cinfo->max_v_samp_factor) {
171
138M
      (*cinfo->downsample->_downsample) (cinfo,
172
138M
                                         prep->color_buf, (JDIMENSION)0,
173
138M
                                         output_buf, *out_row_group_ctr);
174
138M
      prep->next_buf_row = 0;
175
138M
      (*out_row_group_ctr)++;
176
138M
    }
177
    /* If at bottom of image, pad the output to a full iMCU height.
178
     * Note we assume the caller is providing a one-iMCU-height output buffer!
179
     */
180
145M
    if (prep->rows_to_go == 0 && *out_row_group_ctr < out_row_groups_avail) {
181
95.3k
      for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
182
68.9k
           ci++, compptr++) {
183
68.9k
        expand_bottom_edge(output_buf[ci],
184
68.9k
                           compptr->width_in_blocks * data_unit,
185
68.9k
                           (int)(*out_row_group_ctr * compptr->v_samp_factor),
186
68.9k
                           (int)(out_row_groups_avail * compptr->v_samp_factor));
187
68.9k
      }
188
26.4k
      *out_row_group_ctr = out_row_groups_avail;
189
26.4k
      break;                    /* can exit outer loop without test */
190
26.4k
    }
191
145M
  }
192
68.6M
}
193
194
195
#ifdef CONTEXT_ROWS_SUPPORTED
196
197
/*
198
 * Process some data in the context case.
199
 */
200
201
METHODDEF(void)
202
pre_process_context(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
203
                    JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail,
204
                    _JSAMPIMAGE output_buf, JDIMENSION *out_row_group_ctr,
205
                    JDIMENSION out_row_groups_avail)
206
13.8M
{
207
13.8M
  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
208
13.8M
  int numrows, ci;
209
13.8M
  int buf_height = cinfo->max_v_samp_factor * 3;
210
13.8M
  JDIMENSION inrows;
211
212
26.8M
  while (*out_row_group_ctr < out_row_groups_avail) {
213
26.0M
    if (*in_row_ctr < in_rows_avail) {
214
      /* Do color conversion to fill the conversion buffer. */
215
13.0M
      inrows = in_rows_avail - *in_row_ctr;
216
13.0M
      numrows = prep->next_buf_stop - prep->next_buf_row;
217
13.0M
      numrows = (int)MIN((JDIMENSION)numrows, inrows);
218
13.0M
      (*cinfo->cconvert->_color_convert) (cinfo, input_buf + *in_row_ctr,
219
13.0M
                                          prep->color_buf,
220
13.0M
                                          (JDIMENSION)prep->next_buf_row,
221
13.0M
                                          numrows);
222
      /* Pad at top of image, if first time through */
223
13.0M
      if (prep->rows_to_go == cinfo->image_height) {
224
4.57k
        for (ci = 0; ci < cinfo->num_components; ci++) {
225
3.43k
          int row;
226
10.2k
          for (row = 1; row <= cinfo->max_v_samp_factor; row++) {
227
6.86k
            _jcopy_sample_rows(prep->color_buf[ci], 0, prep->color_buf[ci],
228
6.86k
                               -row, 1, cinfo->image_width);
229
6.86k
          }
230
3.43k
        }
231
1.14k
      }
232
13.0M
      *in_row_ctr += numrows;
233
13.0M
      prep->next_buf_row += numrows;
234
13.0M
      prep->rows_to_go -= numrows;
235
13.0M
    } else {
236
      /* Return for more data, unless we are at the bottom of the image. */
237
13.0M
      if (prep->rows_to_go != 0)
238
13.0M
        break;
239
      /* When at bottom of image, pad to fill the conversion buffer. */
240
3.91k
      if (prep->next_buf_row < prep->next_buf_stop) {
241
15.6k
        for (ci = 0; ci < cinfo->num_components; ci++) {
242
11.7k
          expand_bottom_edge(prep->color_buf[ci], cinfo->image_width,
243
11.7k
                             prep->next_buf_row, prep->next_buf_stop);
244
11.7k
        }
245
3.91k
        prep->next_buf_row = prep->next_buf_stop;
246
3.91k
      }
247
3.91k
    }
248
    /* If we've gotten enough data, downsample a row group. */
249
13.0M
    if (prep->next_buf_row == prep->next_buf_stop) {
250
6.51M
      (*cinfo->downsample->_downsample) (cinfo, prep->color_buf,
251
6.51M
                                         (JDIMENSION)prep->this_row_group,
252
6.51M
                                         output_buf, *out_row_group_ctr);
253
6.51M
      (*out_row_group_ctr)++;
254
      /* Advance pointers with wraparound as necessary. */
255
6.51M
      prep->this_row_group += cinfo->max_v_samp_factor;
256
6.51M
      if (prep->this_row_group >= buf_height)
257
2.17M
        prep->this_row_group = 0;
258
6.51M
      if (prep->next_buf_row >= buf_height)
259
2.17M
        prep->next_buf_row = 0;
260
6.51M
      prep->next_buf_stop = prep->next_buf_row + cinfo->max_v_samp_factor;
261
6.51M
    }
262
13.0M
  }
263
13.8M
}
264
265
266
/*
267
 * Create the wrapped-around downsampling input buffer needed for context mode.
268
 */
269
270
LOCAL(void)
271
create_context_buffer(j_compress_ptr cinfo)
272
1.62k
{
273
1.62k
  my_prep_ptr prep = (my_prep_ptr)cinfo->prep;
274
1.62k
  int rgroup_height = cinfo->max_v_samp_factor;
275
1.62k
  int ci, i;
276
1.62k
  jpeg_component_info *compptr;
277
1.62k
  _JSAMPARRAY true_buffer, fake_buffer;
278
1.62k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
279
280
  /* Grab enough space for fake row pointers for all the components;
281
   * we need five row groups' worth of pointers for each component.
282
   */
283
1.62k
  fake_buffer = (_JSAMPARRAY)
284
1.62k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
285
1.62k
                                (cinfo->num_components * 5 * rgroup_height) *
286
1.62k
                                sizeof(_JSAMPROW));
287
288
6.49k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
289
4.87k
       ci++, compptr++) {
290
    /* Allocate the actual buffer space (3 row groups) for this component.
291
     * We make the buffer wide enough to allow the downsampler to edge-expand
292
     * horizontally within the buffer, if it so chooses.
293
     */
294
4.87k
    true_buffer = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
295
4.87k
      ((j_common_ptr)cinfo, JPOOL_IMAGE,
296
4.87k
       (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
297
4.87k
                     cinfo->max_h_samp_factor) / compptr->h_samp_factor),
298
4.87k
       (JDIMENSION)(3 * rgroup_height));
299
    /* Copy true buffer row pointers into the middle of the fake row array */
300
4.87k
    memcpy(fake_buffer + rgroup_height, true_buffer,
301
4.87k
           3 * rgroup_height * sizeof(_JSAMPROW));
302
    /* Fill in the above and below wraparound pointers */
303
14.6k
    for (i = 0; i < rgroup_height; i++) {
304
9.74k
      fake_buffer[i] = true_buffer[2 * rgroup_height + i];
305
9.74k
      fake_buffer[4 * rgroup_height + i] = true_buffer[i];
306
9.74k
    }
307
4.87k
    prep->color_buf[ci] = fake_buffer + rgroup_height;
308
4.87k
    fake_buffer += 5 * rgroup_height; /* point to space for next component */
309
4.87k
  }
310
1.62k
}
311
312
#endif /* CONTEXT_ROWS_SUPPORTED */
313
314
315
/*
316
 * Initialize preprocessing controller.
317
 */
318
319
GLOBAL(void)
320
_jinit_c_prep_controller(j_compress_ptr cinfo, boolean need_full_buffer)
321
44.0k
{
322
44.0k
  my_prep_ptr prep;
323
44.0k
  int ci;
324
44.0k
  jpeg_component_info *compptr;
325
44.0k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
326
327
44.0k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
328
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
329
330
44.0k
  if (need_full_buffer)         /* safety check */
331
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
332
333
44.0k
  prep = (my_prep_ptr)
334
44.0k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
335
44.0k
                                sizeof(my_prep_controller));
336
44.0k
  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
337
44.0k
  prep->pub.start_pass = start_pass_prep;
338
339
  /* Allocate the color conversion buffer.
340
   * We make the buffer wide enough to allow the downsampler to edge-expand
341
   * horizontally within the buffer, if it so chooses.
342
   */
343
44.0k
  if (cinfo->downsample->need_context_rows) {
344
    /* Set up to provide context rows */
345
1.62k
#ifdef CONTEXT_ROWS_SUPPORTED
346
1.62k
    prep->pub._pre_process_data = pre_process_context;
347
1.62k
    create_context_buffer(cinfo);
348
#else
349
    ERREXIT(cinfo, JERR_NOT_COMPILED);
350
#endif
351
42.4k
  } else {
352
    /* No context, just make it tall enough for one row group */
353
42.4k
    prep->pub._pre_process_data = pre_process_data;
354
156k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
355
114k
         ci++, compptr++) {
356
114k
      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
357
114k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
358
114k
         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
359
114k
                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
360
114k
         (JDIMENSION)cinfo->max_v_samp_factor);
361
114k
    }
362
42.4k
  }
363
44.0k
}
j12init_c_prep_controller
Line
Count
Source
321
18.1k
{
322
18.1k
  my_prep_ptr prep;
323
18.1k
  int ci;
324
18.1k
  jpeg_component_info *compptr;
325
18.1k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
326
327
18.1k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
328
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
329
330
18.1k
  if (need_full_buffer)         /* safety check */
331
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
332
333
18.1k
  prep = (my_prep_ptr)
334
18.1k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
335
18.1k
                                sizeof(my_prep_controller));
336
18.1k
  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
337
18.1k
  prep->pub.start_pass = start_pass_prep;
338
339
  /* Allocate the color conversion buffer.
340
   * We make the buffer wide enough to allow the downsampler to edge-expand
341
   * horizontally within the buffer, if it so chooses.
342
   */
343
18.1k
  if (cinfo->downsample->need_context_rows) {
344
    /* Set up to provide context rows */
345
0
#ifdef CONTEXT_ROWS_SUPPORTED
346
0
    prep->pub._pre_process_data = pre_process_context;
347
0
    create_context_buffer(cinfo);
348
#else
349
    ERREXIT(cinfo, JERR_NOT_COMPILED);
350
#endif
351
18.1k
  } else {
352
    /* No context, just make it tall enough for one row group */
353
18.1k
    prep->pub._pre_process_data = pre_process_data;
354
66.4k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
355
48.3k
         ci++, compptr++) {
356
48.3k
      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
357
48.3k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
358
48.3k
         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
359
48.3k
                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
360
48.3k
         (JDIMENSION)cinfo->max_v_samp_factor);
361
48.3k
    }
362
18.1k
  }
363
18.1k
}
j16init_c_prep_controller
Line
Count
Source
321
4.25k
{
322
4.25k
  my_prep_ptr prep;
323
4.25k
  int ci;
324
4.25k
  jpeg_component_info *compptr;
325
4.25k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
326
327
4.25k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
328
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
329
330
4.25k
  if (need_full_buffer)         /* safety check */
331
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
332
333
4.25k
  prep = (my_prep_ptr)
334
4.25k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
335
4.25k
                                sizeof(my_prep_controller));
336
4.25k
  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
337
4.25k
  prep->pub.start_pass = start_pass_prep;
338
339
  /* Allocate the color conversion buffer.
340
   * We make the buffer wide enough to allow the downsampler to edge-expand
341
   * horizontally within the buffer, if it so chooses.
342
   */
343
4.25k
  if (cinfo->downsample->need_context_rows) {
344
    /* Set up to provide context rows */
345
0
#ifdef CONTEXT_ROWS_SUPPORTED
346
0
    prep->pub._pre_process_data = pre_process_context;
347
0
    create_context_buffer(cinfo);
348
#else
349
    ERREXIT(cinfo, JERR_NOT_COMPILED);
350
#endif
351
4.25k
  } else {
352
    /* No context, just make it tall enough for one row group */
353
4.25k
    prep->pub._pre_process_data = pre_process_data;
354
16.5k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
355
12.3k
         ci++, compptr++) {
356
12.3k
      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
357
12.3k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
358
12.3k
         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
359
12.3k
                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
360
12.3k
         (JDIMENSION)cinfo->max_v_samp_factor);
361
12.3k
    }
362
4.25k
  }
363
4.25k
}
jinit_c_prep_controller
Line
Count
Source
321
21.7k
{
322
21.7k
  my_prep_ptr prep;
323
21.7k
  int ci;
324
21.7k
  jpeg_component_info *compptr;
325
21.7k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
326
327
21.7k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
328
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
329
330
21.7k
  if (need_full_buffer)         /* safety check */
331
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
332
333
21.7k
  prep = (my_prep_ptr)
334
21.7k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
335
21.7k
                                sizeof(my_prep_controller));
336
21.7k
  cinfo->prep = (struct jpeg_c_prep_controller *)prep;
337
21.7k
  prep->pub.start_pass = start_pass_prep;
338
339
  /* Allocate the color conversion buffer.
340
   * We make the buffer wide enough to allow the downsampler to edge-expand
341
   * horizontally within the buffer, if it so chooses.
342
   */
343
21.7k
  if (cinfo->downsample->need_context_rows) {
344
    /* Set up to provide context rows */
345
1.62k
#ifdef CONTEXT_ROWS_SUPPORTED
346
1.62k
    prep->pub._pre_process_data = pre_process_context;
347
1.62k
    create_context_buffer(cinfo);
348
#else
349
    ERREXIT(cinfo, JERR_NOT_COMPILED);
350
#endif
351
20.1k
  } else {
352
    /* No context, just make it tall enough for one row group */
353
20.1k
    prep->pub._pre_process_data = pre_process_data;
354
73.5k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
355
53.4k
         ci++, compptr++) {
356
53.4k
      prep->color_buf[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
357
53.4k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
358
53.4k
         (JDIMENSION)(((long)compptr->width_in_blocks * data_unit *
359
53.4k
                       cinfo->max_h_samp_factor) / compptr->h_samp_factor),
360
53.4k
         (JDIMENSION)cinfo->max_v_samp_factor);
361
53.4k
    }
362
20.1k
  }
363
21.7k
}
364
365
#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */