Coverage Report

Created: 2025-11-24 06:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjpeg-turbo.dev/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
101k
{
60
101k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
101k
  if (cinfo->raw_data_in)
64
22.0k
    return;
65
66
79.0k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
79.0k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
79.0k
  main_ptr->rowgroup_ctr = 0;
71
79.0k
  main_ptr->suspended = FALSE;
72
79.0k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
79.0k
  main_ptr->pub._process_data = process_data_simple_main;
74
79.0k
}
jcmainct-8.c:start_pass_main
Line
Count
Source
59
58.0k
{
60
58.0k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
58.0k
  if (cinfo->raw_data_in)
64
22.0k
    return;
65
66
36.0k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
36.0k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
36.0k
  main_ptr->rowgroup_ctr = 0;
71
36.0k
  main_ptr->suspended = FALSE;
72
36.0k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
36.0k
  main_ptr->pub._process_data = process_data_simple_main;
74
36.0k
}
jcmainct-12.c:start_pass_main
Line
Count
Source
59
34.5k
{
60
34.5k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
34.5k
  if (cinfo->raw_data_in)
64
0
    return;
65
66
34.5k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
34.5k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
34.5k
  main_ptr->rowgroup_ctr = 0;
71
34.5k
  main_ptr->suspended = FALSE;
72
34.5k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
34.5k
  main_ptr->pub._process_data = process_data_simple_main;
74
34.5k
}
jcmainct-16.c:start_pass_main
Line
Count
Source
59
8.52k
{
60
8.52k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
61
62
  /* Do nothing in raw-data mode. */
63
8.52k
  if (cinfo->raw_data_in)
64
0
    return;
65
66
8.52k
  if (pass_mode != JBUF_PASS_THRU)
67
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
68
69
8.52k
  main_ptr->cur_iMCU_row = 0;   /* initialize counters */
70
8.52k
  main_ptr->rowgroup_ctr = 0;
71
8.52k
  main_ptr->suspended = FALSE;
72
8.52k
  main_ptr->pass_mode = pass_mode;      /* save mode for use by process_data */
73
8.52k
  main_ptr->pub._process_data = process_data_simple_main;
74
8.52k
}
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
79.0k
{
87
79.0k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
79.0k
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
109M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
109M
    if (main_ptr->rowgroup_ctr < data_unit)
93
109M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
109M
                                         in_rows_avail, main_ptr->buffer,
95
109M
                                         &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
109M
    if (main_ptr->rowgroup_ctr != data_unit)
102
0
      return;
103
104
    /* Send the completed row to the compressor */
105
109M
    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
109M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
109M
    main_ptr->rowgroup_ctr = 0;
126
109M
    main_ptr->cur_iMCU_row++;
127
109M
  }
128
79.0k
}
jcmainct-8.c:process_data_simple_main
Line
Count
Source
86
36.0k
{
87
36.0k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
36.0k
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
37.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
37.1M
    if (main_ptr->rowgroup_ctr < data_unit)
93
37.1M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
37.1M
                                         in_rows_avail, main_ptr->buffer,
95
37.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
37.1M
    if (main_ptr->rowgroup_ctr != data_unit)
102
0
      return;
103
104
    /* Send the completed row to the compressor */
105
37.1M
    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
37.1M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
37.1M
    main_ptr->rowgroup_ctr = 0;
126
37.1M
    main_ptr->cur_iMCU_row++;
127
37.1M
  }
128
36.0k
}
jcmainct-12.c:process_data_simple_main
Line
Count
Source
86
34.5k
{
87
34.5k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
34.5k
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
38.7M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
38.7M
    if (main_ptr->rowgroup_ctr < data_unit)
93
38.7M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
38.7M
                                         in_rows_avail, main_ptr->buffer,
95
38.7M
                                         &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
38.7M
    if (main_ptr->rowgroup_ctr != data_unit)
102
0
      return;
103
104
    /* Send the completed row to the compressor */
105
38.7M
    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.7M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
38.7M
    main_ptr->rowgroup_ctr = 0;
126
38.7M
    main_ptr->cur_iMCU_row++;
127
38.7M
  }
128
34.5k
}
jcmainct-16.c:process_data_simple_main
Line
Count
Source
86
8.52k
{
87
8.52k
  my_main_ptr main_ptr = (my_main_ptr)cinfo->main;
88
8.52k
  JDIMENSION data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
89
90
33.1M
  while (main_ptr->cur_iMCU_row < cinfo->total_iMCU_rows) {
91
    /* Read input data if we haven't filled the main buffer yet */
92
33.1M
    if (main_ptr->rowgroup_ctr < data_unit)
93
33.1M
      (*cinfo->prep->_pre_process_data) (cinfo, input_buf, in_row_ctr,
94
33.1M
                                         in_rows_avail, main_ptr->buffer,
95
33.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
33.1M
    if (main_ptr->rowgroup_ctr != data_unit)
102
0
      return;
103
104
    /* Send the completed row to the compressor */
105
33.1M
    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
33.1M
    if (main_ptr->suspended) {
122
0
      (*in_row_ctr)++;
123
0
      main_ptr->suspended = FALSE;
124
0
    }
125
33.1M
    main_ptr->rowgroup_ctr = 0;
126
33.1M
    main_ptr->cur_iMCU_row++;
127
33.1M
  }
128
8.52k
}
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
101k
{
138
101k
  my_main_ptr main_ptr;
139
101k
  int ci;
140
101k
  jpeg_component_info *compptr;
141
101k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
101k
#ifdef C_LOSSLESS_SUPPORTED
144
101k
  if (cinfo->master->lossless) {
145
#if BITS_IN_JSAMPLE == 8
146
8.75k
    if (cinfo->data_precision > BITS_IN_JSAMPLE || cinfo->data_precision < 2)
147
#else
148
16.6k
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
16.6k
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
0
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
25.4k
  } else
153
75.7k
#endif
154
75.7k
  {
155
75.7k
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
75.7k
  }
158
159
101k
  main_ptr = (my_main_ptr)
160
101k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
101k
                                sizeof(my_main_controller));
162
101k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
101k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
101k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
101k
  if (cinfo->raw_data_in)
168
22.0k
    return;
169
170
  /* Create the buffer.  It holds downsampled data, so each component
171
   * may be of a different size.
172
   */
173
79.0k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
79.0k
  } else {
176
    /* Allocate a strip buffer for each component */
177
292k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
213k
         ci++, compptr++) {
179
213k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
213k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
213k
         compptr->width_in_blocks * data_unit,
182
213k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
213k
    }
184
79.0k
  }
185
79.0k
}
jinit_c_main_controller
Line
Count
Source
137
58.0k
{
138
58.0k
  my_main_ptr main_ptr;
139
58.0k
  int ci;
140
58.0k
  jpeg_component_info *compptr;
141
58.0k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
58.0k
#ifdef C_LOSSLESS_SUPPORTED
144
58.0k
  if (cinfo->master->lossless) {
145
8.75k
#if BITS_IN_JSAMPLE == 8
146
8.75k
    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
8.75k
  } else
153
49.3k
#endif
154
49.3k
  {
155
49.3k
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
49.3k
  }
158
159
58.0k
  main_ptr = (my_main_ptr)
160
58.0k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
58.0k
                                sizeof(my_main_controller));
162
58.0k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
58.0k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
58.0k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
58.0k
  if (cinfo->raw_data_in)
168
22.0k
    return;
169
170
  /* Create the buffer.  It holds downsampled data, so each component
171
   * may be of a different size.
172
   */
173
36.0k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
36.0k
  } else {
176
    /* Allocate a strip buffer for each component */
177
132k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
96.8k
         ci++, compptr++) {
179
96.8k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
96.8k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
96.8k
         compptr->width_in_blocks * data_unit,
182
96.8k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
96.8k
    }
184
36.0k
  }
185
36.0k
}
j12init_c_main_controller
Line
Count
Source
137
34.5k
{
138
34.5k
  my_main_ptr main_ptr;
139
34.5k
  int ci;
140
34.5k
  jpeg_component_info *compptr;
141
34.5k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
34.5k
#ifdef C_LOSSLESS_SUPPORTED
144
34.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
8.14k
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
8.14k
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
0
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
8.14k
  } else
153
26.4k
#endif
154
26.4k
  {
155
26.4k
    if (cinfo->data_precision != BITS_IN_JSAMPLE)
156
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
157
26.4k
  }
158
159
34.5k
  main_ptr = (my_main_ptr)
160
34.5k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
34.5k
                                sizeof(my_main_controller));
162
34.5k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
34.5k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
34.5k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
34.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
34.5k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
34.5k
  } else {
176
    /* Allocate a strip buffer for each component */
177
127k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
92.4k
         ci++, compptr++) {
179
92.4k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
92.4k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
92.4k
         compptr->width_in_blocks * data_unit,
182
92.4k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
92.4k
    }
184
34.5k
  }
185
34.5k
}
j16init_c_main_controller
Line
Count
Source
137
8.52k
{
138
8.52k
  my_main_ptr main_ptr;
139
8.52k
  int ci;
140
8.52k
  jpeg_component_info *compptr;
141
8.52k
  int data_unit = cinfo->master->lossless ? 1 : DCTSIZE;
142
143
8.52k
#ifdef C_LOSSLESS_SUPPORTED
144
8.52k
  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
8.52k
    if (cinfo->data_precision > BITS_IN_JSAMPLE ||
149
8.52k
        cinfo->data_precision < BITS_IN_JSAMPLE - 3)
150
0
#endif
151
0
      ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
152
8.52k
  } 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
8.52k
  main_ptr = (my_main_ptr)
160
8.52k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
161
8.52k
                                sizeof(my_main_controller));
162
8.52k
  memset(main_ptr, 0, sizeof(my_main_controller));
163
8.52k
  cinfo->main = (struct jpeg_c_main_controller *)main_ptr;
164
8.52k
  main_ptr->pub.start_pass = start_pass_main;
165
166
  /* We don't need to create a buffer in raw-data mode. */
167
8.52k
  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
8.52k
  if (need_full_buffer) {
174
0
    ERREXIT(cinfo, JERR_BAD_BUFFER_MODE);
175
8.52k
  } else {
176
    /* Allocate a strip buffer for each component */
177
33.0k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
178
24.5k
         ci++, compptr++) {
179
24.5k
      main_ptr->buffer[ci] = (_JSAMPARRAY)(*cinfo->mem->alloc_sarray)
180
24.5k
        ((j_common_ptr)cinfo, JPOOL_IMAGE,
181
24.5k
         compptr->width_in_blocks * data_unit,
182
24.5k
         (JDIMENSION)(compptr->v_samp_factor * data_unit));
183
24.5k
    }
184
8.52k
  }
185
8.52k
}
186
187
#endif /* BITS_IN_JSAMPLE != 16 || defined(C_LOSSLESS_SUPPORTED) */