Coverage Report

Created: 2025-08-03 06:59

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