Coverage Report

Created: 2026-03-12 08:02

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjpeg-turbo.main/src/jcmainct.c
Line
Count
Source
1
/*
2
 * jcmainct.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, 2024, D. R. Commander.
10
 * For conditions of distribution and use, see the accompanying README.ijg
11
 * file.
12
 *
13
 * This file contains the main buffer controller for compression.
14
 * The main buffer lies between the pre-processor and the JPEG
15
 * compressor proper; it holds downsampled data in the JPEG colorspace.
16
 */
17
18
#define JPEG_INTERNALS
19
#include "jinclude.h"
20
#include "jpeglib.h"
21
#include "jsamplecomp.h"
22
23
24
#if BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED)
25
26
/* Private buffer controller object */
27
28
typedef struct {
29
  struct jpeg_c_main_controller pub; /* public fields */
30
31
  JDIMENSION cur_iMCU_row;      /* number of current iMCU row */
32
  JDIMENSION rowgroup_ctr;      /* counts row groups received in iMCU row */
33
  boolean suspended;            /* remember if we suspended output */
34
  J_BUF_MODE pass_mode;         /* current operating mode */
35
36
  /* If using just a strip buffer, this points to the entire set of buffers
37
   * (we allocate one for each component).  In the full-image case, this
38
   * points to the currently accessible strips of the virtual arrays.
39
   */
40
  _JSAMPARRAY buffer[MAX_COMPONENTS];
41
} my_main_controller;
42
43
typedef my_main_controller *my_main_ptr;
44
45
46
/* Forward declarations */
47
METHODDEF(void) process_data_simple_main(j_compress_ptr cinfo,
48
                                         _JSAMPARRAY input_buf,
49
                                         JDIMENSION *in_row_ctr,
50
                                         JDIMENSION in_rows_avail);
51
52
53
/*
54
 * Initialize for a processing pass.
55
 */
56
57
METHODDEF(void)
58
start_pass_main(j_compress_ptr cinfo, J_BUF_MODE pass_mode)
59
115k
{
60
115k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
115k
  if (cinfo->raw_data_in)
64
20.3k
    return;
65
66
94.9k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
94.9k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
94.9k
  main_ptr->rowgroup_ctr = 0;
71
94.9k
  main_ptr->suspended = FALSE;
72
94.9k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
94.9k
  main_ptr->pub._process_data = process_data_simple_main;
74
94.9k
}
jcmainct-8.c:start_pass_main
Line
Count
Source
59
66.4k
{
60
66.4k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
66.4k
  if (cinfo->raw_data_in)
64
20.3k
    return;
65
66
46.0k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
46.0k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
46.0k
  main_ptr->rowgroup_ctr = 0;
71
46.0k
  main_ptr->suspended = FALSE;
72
46.0k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
46.0k
  main_ptr->pub._process_data = process_data_simple_main;
74
46.0k
}
jcmainct-12.c:start_pass_main
Line
Count
Source
59
37.5k
{
60
37.5k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
37.5k
  if (cinfo->raw_data_in)
64
0
    return;
65
66
37.5k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
37.5k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
37.5k
  main_ptr->rowgroup_ctr = 0;
71
37.5k
  main_ptr->suspended = FALSE;
72
37.5k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
37.5k
  main_ptr->pub._process_data = process_data_simple_main;
74
37.5k
}
jcmainct-16.c:start_pass_main
Line
Count
Source
59
11.3k
{
60
11.3k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
11.3k
  if (cinfo->raw_data_in)
64
0
    return;
65
66
11.3k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
11.3k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
11.3k
  main_ptr->rowgroup_ctr = 0;
71
11.3k
  main_ptr->suspended = FALSE;
72
11.3k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
11.3k
  main_ptr->pub._process_data = process_data_simple_main;
74
11.3k
}
75
76
77
/*
78
 * Process some data.
79
 * This routine handles the simple pass-through mode,
80
 * where we have only a strip buffer.
81
 */
82
83
METHODDEF(void)
84
process_data_simple_main(j_compress_ptr cinfo, _JSAMPARRAY input_buf,
85
                         JDIMENSION *in_row_ctr, JDIMENSION in_rows_avail)
86
7.33M
{
87
7.33M
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
7.33M
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
117M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
117M
    if (main_ptr->rowgroup_ctr < data_unit)
93
117M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
117M
                                         in_rows_avail, main_ptr->buffer,
95
117M
                                         &main_ptr->rowgroup_ctr, data_unit);
96
97
    /* If we don't have a full iMCU row buffered, return to application for
98
     * more data.  Note that preprocessor will always pad to fill the iMCU row
99
     * at the bottom of the image.
100
     */
101
117M
    if (main_ptr->rowgroup_ctr != data_unit)
102
7.24M
      return;
103
104
    /* Send the completed row to the compressor */
105
110M
    if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
106
      /* If compressor did not consume the whole row, then we must need to
107
       * suspend processing and return to the application.  In this situation
108
       * we pretend we didn't yet consume the last input row; otherwise, if
109
       * it happened to be the last row of the image, the application would
110
       * think we were done.
111
       */
112
0
      if (!main_ptr->suspended) {
113
0
        (*in_row_ctr)--;
114
0
        main_ptr->suspended = TRUE;
115
0
      }
116
0
      return;
117
0
    }
118
    /* We did finish the row.  Undo our little suspension hack if a previous
119
     * call suspended; then mark the main buffer empty.
120
     */
121
110M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
110M
    main_ptr->rowgroup_ctr = 0;
126
110M
    main_ptr->cur_iMCU_row++;
127
110M
  }
128
7.33M
}
jcmainct-8.c:process_data_simple_main
Line
Count
Source
86
7.28M
{
87
7.28M
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
7.28M
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
46.2M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
46.1M
    if (main_ptr->rowgroup_ctr < data_unit)
93
46.1M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
46.1M
                                         in_rows_avail, main_ptr->buffer,
95
46.1M
                                         &main_ptr->rowgroup_ctr, data_unit);
96
97
    /* If we don't have a full iMCU row buffered, return to application for
98
     * more data.  Note that preprocessor will always pad to fill the iMCU row
99
     * at the bottom of the image.
100
     */
101
46.1M
    if (main_ptr->rowgroup_ctr != data_unit)
102
7.24M
      return;
103
104
    /* Send the completed row to the compressor */
105
38.9M
    if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
106
      /* If compressor did not consume the whole row, then we must need to
107
       * suspend processing and return to the application.  In this situation
108
       * we pretend we didn't yet consume the last input row; otherwise, if
109
       * it happened to be the last row of the image, the application would
110
       * think we were done.
111
       */
112
0
      if (!main_ptr->suspended) {
113
0
        (*in_row_ctr)--;
114
0
        main_ptr->suspended = TRUE;
115
0
      }
116
0
      return;
117
0
    }
118
    /* We did finish the row.  Undo our little suspension hack if a previous
119
     * call suspended; then mark the main buffer empty.
120
     */
121
38.9M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
38.9M
    main_ptr->rowgroup_ctr = 0;
126
38.9M
    main_ptr->cur_iMCU_row++;
127
38.9M
  }
128
7.28M
}
jcmainct-12.c:process_data_simple_main
Line
Count
Source
86
37.5k
{
87
37.5k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
37.5k
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
39.6M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
39.5M
    if (main_ptr->rowgroup_ctr < data_unit)
93
39.5M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
39.5M
                                         in_rows_avail, main_ptr->buffer,
95
39.5M
                                         &main_ptr->rowgroup_ctr, data_unit);
96
97
    /* If we don't have a full iMCU row buffered, return to application for
98
     * more data.  Note that preprocessor will always pad to fill the iMCU row
99
     * at the bottom of the image.
100
     */
101
39.5M
    if (main_ptr->rowgroup_ctr != data_unit)
102
0
      return;
103
104
    /* Send the completed row to the compressor */
105
39.5M
    if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
106
      /* If compressor did not consume the whole row, then we must need to
107
       * suspend processing and return to the application.  In this situation
108
       * we pretend we didn't yet consume the last input row; otherwise, if
109
       * it happened to be the last row of the image, the application would
110
       * think we were done.
111
       */
112
0
      if (!main_ptr->suspended) {
113
0
        (*in_row_ctr)--;
114
0
        main_ptr->suspended = TRUE;
115
0
      }
116
0
      return;
117
0
    }
118
    /* We did finish the row.  Undo our little suspension hack if a previous
119
     * call suspended; then mark the main buffer empty.
120
     */
121
39.5M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
39.5M
    main_ptr->rowgroup_ctr = 0;
126
39.5M
    main_ptr->cur_iMCU_row++;
127
39.5M
  }
128
37.5k
}
jcmainct-16.c:process_data_simple_main
Line
Count
Source
86
11.3k
{
87
11.3k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
11.3k
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
31.6M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
31.6M
    if (main_ptr->rowgroup_ctr < data_unit)
93
31.6M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
31.6M
                                         in_rows_avail, main_ptr->buffer,
95
31.6M
                                         &main_ptr->rowgroup_ctr, data_unit);
96
97
    /* If we don't have a full iMCU row buffered, return to application for
98
     * more data.  Note that preprocessor will always pad to fill the iMCU row
99
     * at the bottom of the image.
100
     */
101
31.6M
    if (main_ptr->rowgroup_ctr != data_unit)
102
0
      return;
103
104
    /* Send the completed row to the compressor */
105
31.6M
    if (!(*cinfo->coef->_compress_data) (cinfo, main_ptr->buffer)) {
106
      /* If compressor did not consume the whole row, then we must need to
107
       * suspend processing and return to the application.  In this situation
108
       * we pretend we didn't yet consume the last input row; otherwise, if
109
       * it happened to be the last row of the image, the application would
110
       * think we were done.
111
       */
112
0
      if (!main_ptr->suspended) {
113
0
        (*in_row_ctr)--;
114
0
        main_ptr->suspended = TRUE;
115
0
      }
116
0
      return;
117
0
    }
118
    /* We did finish the row.  Undo our little suspension hack if a previous
119
     * call suspended; then mark the main buffer empty.
120
     */
121
31.6M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
31.6M
    main_ptr->rowgroup_ctr = 0;
126
31.6M
    main_ptr->cur_iMCU_row++;
127
31.6M
  }
128
11.3k
}
129
130
131
/*
132
 * Initialize main buffer controller.
133
 */
134
135
GLOBAL(void)
136
_jinit_c_main_controller(j_compress_ptr cinfo, boolean need_full_buffer)
137
115k
{
138
115k
  my_main_ptr main_ptr;
139
115k
  int ci;
140
115k
  jpeg_component_info *compptr;
141
115k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
115k
#ifdef C_LOSSLESS_SUPPORTED
144
115k
  if (cinfo->master->lossless) {
145
#if BITS_IN_JSAMPLE == 8
146
12.9k
    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
147
#else
148
22.3k
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
22.3k
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
0
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
35.2k
  } else
153
80.0k
#endif
154
80.0k
  {
155
80.0k
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
80.0k
  }
158
159
115k
  main_ptr = (my_main_ptr)
160
115k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
115k
                                sizeof(my_main_controller));
162
115k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
115k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
115k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
115k
  if (cinfo->raw_data_in)
168
20.3k
    return;
169
170
  /* Create the buffer.  It holds downsampled data, so each component
171
   * may be of a different size.
172
   */
173
94.9k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
94.9k
  } else {
176
    /* Allocate a strip buffer for each component */
177
346k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
251k
         ci++, compptr++) {
179
251k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
251k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
251k
         compptr->width_in_blocks * data_unit,
182
251k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
251k
    }
184
94.9k
  }
185
94.9k
}
jinit_c_main_controller
Line
Count
Source
137
66.4k
{
138
66.4k
  my_main_ptr main_ptr;
139
66.4k
  int ci;
140
66.4k
  jpeg_component_info *compptr;
141
66.4k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
66.4k
#ifdef C_LOSSLESS_SUPPORTED
144
66.4k
  if (cinfo->master->lossless) {
145
12.9k
#if BITS_IN_JSAMPLE == 8
146
12.9k
    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
147
#else
148
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
12.9k
  } else
153
53.5k
#endif
154
53.5k
  {
155
53.5k
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
53.5k
  }
158
159
66.4k
  main_ptr = (my_main_ptr)
160
66.4k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
66.4k
                                sizeof(my_main_controller));
162
66.4k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
66.4k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
66.4k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
66.4k
  if (cinfo->raw_data_in)
168
20.3k
    return;
169
170
  /* Create the buffer.  It holds downsampled data, so each component
171
   * may be of a different size.
172
   */
173
46.0k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
46.0k
  } else {
176
    /* Allocate a strip buffer for each component */
177
165k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
119k
         ci++, compptr++) {
179
119k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
119k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
119k
         compptr->width_in_blocks * data_unit,
182
119k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
119k
    }
184
46.0k
  }
185
46.0k
}
j12init_c_main_controller
Line
Count
Source
137
37.5k
{
138
37.5k
  my_main_ptr main_ptr;
139
37.5k
  int ci;
140
37.5k
  jpeg_component_info *compptr;
141
37.5k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
37.5k
#ifdef C_LOSSLESS_SUPPORTED
144
37.5k
  if (cinfo->master->lossless) {
145
#if BITS_IN_JSAMPLE == 8
146
    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
147
#else
148
10.9k
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
10.9k
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
0
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
10.9k
  } else
153
26.5k
#endif
154
26.5k
  {
155
26.5k
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
26.5k
  }
158
159
37.5k
  main_ptr = (my_main_ptr)
160
37.5k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
37.5k
                                sizeof(my_main_controller));
162
37.5k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
37.5k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
37.5k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
37.5k
  if (cinfo->raw_data_in)
168
0
    return;
169
170
  /* Create the buffer.  It holds downsampled data, so each component
171
   * may be of a different size.
172
   */
173
37.5k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
37.5k
  } else {
176
    /* Allocate a strip buffer for each component */
177
136k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
99.4k
         ci++, compptr++) {
179
99.4k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
99.4k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
99.4k
         compptr->width_in_blocks * data_unit,
182
99.4k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
99.4k
    }
184
37.5k
  }
185
37.5k
}
j16init_c_main_controller
Line
Count
Source
137
11.3k
{
138
11.3k
  my_main_ptr main_ptr;
139
11.3k
  int ci;
140
11.3k
  jpeg_component_info *compptr;
141
11.3k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
11.3k
#ifdef C_LOSSLESS_SUPPORTED
144
11.3k
  if (cinfo->master->lossless) {
145
#if BITS_IN_JSAMPLE == 8
146
    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
147
#else
148
11.3k
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
11.3k
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
0
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
11.3k
  } else
153
0
#endif
154
0
  {
155
0
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
0
  }
158
159
11.3k
  main_ptr = (my_main_ptr)
160
11.3k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
11.3k
                                sizeof(my_main_controller));
162
11.3k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
11.3k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
11.3k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
11.3k
  if (cinfo->raw_data_in)
168
0
    return;
169
170
  /* Create the buffer.  It holds downsampled data, so each component
171
   * may be of a different size.
172
   */
173
11.3k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
11.3k
  } else {
176
    /* Allocate a strip buffer for each component */
177
43.4k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
32.1k
         ci++, compptr++) {
179
32.1k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
32.1k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
32.1k
         compptr->width_in_blocks * data_unit,
182
32.1k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
32.1k
    }
184
11.3k
  }
185
11.3k
}
186
187
#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */