Coverage Report

Created: 2026-04-28 06:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libjpeg-turbo.main/src/jdcoefct.c
Line
Count
Source
1
/*
2
 * jdcoefct.c
3
 *
4
 * This file was part of the Independent JPEG Group's software:
5
 * Copyright (C) 1994-1997, Thomas G. Lane.
6
 * libjpeg-turbo Modifications:
7
 * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB
8
 * Copyright (C) 2010, 2015-2016, 2019-2020, 2022-2026, D. R. Commander.
9
 * Copyright (C) 2015, 2020, Google, Inc.
10
 * For conditions of distribution and use, see the accompanying README.ijg
11
 * file.
12
 *
13
 * This file contains the coefficient buffer controller for decompression.
14
 * This controller is the top level of the lossy JPEG decompressor proper.
15
 * The coefficient buffer lies between entropy decoding and inverse-DCT steps.
16
 *
17
 * In buffered-image mode, this controller is the interface between
18
 * input-oriented processing and output-oriented processing.
19
 * Also, the input side (only) is used when reading a file for transcoding.
20
 */
21
22
#include "jinclude.h"
23
#include "jdcoefct.h"
24
#include "jpegapicomp.h"
25
#include "jsamplecomp.h"
26
#ifdef WITH_PROFILE
27
#include "tjutil.h"
28
#endif
29
30
31
/* Forward declarations */
32
METHODDEF(int) decompress_onepass(j_decompress_ptr cinfo,
33
                                  _JSAMPIMAGE output_buf);
34
#ifdef D_MULTISCAN_FILES_SUPPORTED
35
METHODDEF(int) decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf);
36
#endif
37
#ifdef BLOCK_SMOOTHING_SUPPORTED
38
LOCAL(boolean) smoothing_ok(j_decompress_ptr cinfo);
39
METHODDEF(int) decompress_smooth_data(j_decompress_ptr cinfo,
40
                                      _JSAMPIMAGE output_buf);
41
#endif
42
43
44
/*
45
 * Initialize for an input processing pass.
46
 */
47
48
METHODDEF(void)
49
start_input_pass(j_decompress_ptr cinfo)
50
612k
{
51
612k
  cinfo->input_iMCU_row = 0;
52
612k
  start_iMCU_row(cinfo);
53
612k
}
jdcoefct-8.c:start_input_pass
Line
Count
Source
50
527k
{
51
527k
  cinfo->input_iMCU_row = 0;
52
527k
  start_iMCU_row(cinfo);
53
527k
}
jdcoefct-12.c:start_input_pass
Line
Count
Source
50
85.4k
{
51
85.4k
  cinfo->input_iMCU_row = 0;
52
85.4k
  start_iMCU_row(cinfo);
53
85.4k
}
54
55
56
/*
57
 * Initialize for an output processing pass.
58
 */
59
60
METHODDEF(void)
61
start_output_pass(j_decompress_ptr cinfo)
62
104k
{
63
104k
#ifdef BLOCK_SMOOTHING_SUPPORTED
64
104k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
65
66
  /* If multipass, check to see whether to use block smoothing on this pass */
67
104k
  if (coef->pub.coef_arrays != NULL) {
68
85.4k
    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
69
29.8k
      coef->pub._decompress_data = decompress_smooth_data;
70
55.5k
    else
71
55.5k
      coef->pub._decompress_data = decompress_data;
72
85.4k
  }
73
104k
#endif
74
104k
  cinfo->output_iMCU_row = 0;
75
104k
}
jdcoefct-8.c:start_output_pass
Line
Count
Source
62
91.4k
{
63
91.4k
#ifdef BLOCK_SMOOTHING_SUPPORTED
64
91.4k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
65
66
  /* If multipass, check to see whether to use block smoothing on this pass */
67
91.4k
  if (coef->pub.coef_arrays != NULL) {
68
76.2k
    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
69
25.8k
      coef->pub._decompress_data = decompress_smooth_data;
70
50.3k
    else
71
50.3k
      coef->pub._decompress_data = decompress_data;
72
76.2k
  }
73
91.4k
#endif
74
91.4k
  cinfo->output_iMCU_row = 0;
75
91.4k
}
jdcoefct-12.c:start_output_pass
Line
Count
Source
62
13.5k
{
63
13.5k
#ifdef BLOCK_SMOOTHING_SUPPORTED
64
13.5k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
65
66
  /* If multipass, check to see whether to use block smoothing on this pass */
67
13.5k
  if (coef->pub.coef_arrays != NULL) {
68
9.25k
    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
69
4.05k
      coef->pub._decompress_data = decompress_smooth_data;
70
5.20k
    else
71
5.20k
      coef->pub._decompress_data = decompress_data;
72
9.25k
  }
73
13.5k
#endif
74
13.5k
  cinfo->output_iMCU_row = 0;
75
13.5k
}
76
77
78
/*
79
 * Decompress and return some data in the single-pass case.
80
 * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
81
 * Input and output must run in lockstep since we have only a one-MCU buffer.
82
 * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
83
 *
84
 * NB: output_buf contains a plane for each component in image,
85
 * which we index according to the component's SOF position.
86
 */
87
88
METHODDEF(int)
89
decompress_onepass(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
90
15.9M
{
91
15.9M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
92
15.9M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
93
15.9M
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
94
15.9M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
95
15.9M
  int blkn, ci, xindex, yindex, yoffset, useful_width;
96
15.9M
  _JSAMPARRAY output_ptr;
97
15.9M
  JDIMENSION start_col, output_col;
98
15.9M
  jpeg_component_info *compptr;
99
15.9M
  _inverse_DCT_method_ptr inverse_DCT;
100
101
  /* Loop to process as much as one whole iMCU row */
102
33.5M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
103
17.5M
       yoffset++) {
104
89.5M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
105
71.9M
         MCU_col_num++) {
106
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
107
71.9M
      jzero_far((void *)coef->MCU_buffer[0],
108
71.9M
                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
109
71.9M
      if (!cinfo->entropy->insufficient_data)
110
27.1M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
111
#ifdef WITH_PROFILE
112
      cinfo->master->start = getTime();
113
#endif
114
71.9M
      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
115
        /* Suspension forced; update state counters and exit */
116
0
        coef->MCU_vert_offset = yoffset;
117
0
        coef->MCU_ctr = MCU_col_num;
118
#ifdef WITH_PROFILE
119
        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
120
        cinfo->master->entropy_mcoeffs +=
121
          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
122
#endif
123
0
        return JPEG_SUSPENDED;
124
0
      }
125
#ifdef WITH_PROFILE
126
      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
127
      cinfo->master->entropy_mcoeffs +=
128
        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
129
#endif
130
131
      /* Only perform the IDCT on blocks that are contained within the desired
132
       * cropping region.
133
       */
134
71.9M
      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
135
71.8M
          MCU_col_num <= cinfo->master->last_iMCU_col) {
136
        /* Determine where data should go in output_buf and do the IDCT thing.
137
         * We skip dummy blocks at the right and bottom edges (but blkn gets
138
         * incremented past them!).  Note the inner loop relies on having
139
         * allocated the MCU_buffer[] blocks sequentially.
140
         */
141
69.8M
        blkn = 0;               /* index of current DCT block within MCU */
142
173M
        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
143
103M
          compptr = cinfo->cur_comp_info[ci];
144
          /* Don't bother to IDCT an uninteresting component. */
145
103M
          if (!compptr->component_needed) {
146
210k
            blkn += compptr->MCU_blocks;
147
210k
            continue;
148
210k
          }
149
103M
          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
150
103M
          useful_width = (MCU_col_num < last_MCU_col) ?
151
59.5M
                         compptr->MCU_width : compptr->last_col_width;
152
103M
          output_ptr = output_buf[compptr->component_index] +
153
103M
                       yoffset * compptr->_DCT_scaled_size;
154
103M
          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
155
103M
                      compptr->MCU_sample_width;
156
211M
          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
157
108M
            if (cinfo->input_iMCU_row < last_iMCU_row ||
158
108M
                yoffset + yindex < compptr->last_row_height) {
159
108M
              output_col = start_col;
160
224M
              for (xindex = 0; xindex < useful_width; xindex++) {
161
#ifdef WITH_PROFILE
162
                cinfo->master->start = getTime();
163
#endif
164
116M
                (*inverse_DCT) (cinfo, compptr,
165
116M
                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
166
116M
                                output_ptr, output_col);
167
#ifdef WITH_PROFILE
168
                cinfo->master->idct_elapsed +=
169
                  getTime() - cinfo->master->start;
170
                cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
171
#endif
172
116M
                output_col += compptr->_DCT_scaled_size;
173
116M
              }
174
108M
            }
175
108M
            blkn += compptr->MCU_width;
176
108M
            output_ptr += compptr->_DCT_scaled_size;
177
108M
          }
178
103M
        }
179
69.8M
      }
180
71.9M
    }
181
    /* Completed an MCU row, but perhaps not an iMCU row */
182
17.5M
    coef->MCU_ctr = 0;
183
17.5M
  }
184
  /* Completed the iMCU row, advance counters for next one */
185
15.9M
  cinfo->output_iMCU_row++;
186
15.9M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
187
15.9M
    start_iMCU_row(cinfo);
188
15.9M
    return JPEG_ROW_COMPLETED;
189
15.9M
  }
190
  /* Completed the scan */
191
17.2k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
192
17.2k
  return JPEG_SCAN_COMPLETED;
193
15.9M
}
jdcoefct-8.c:decompress_onepass
Line
Count
Source
90
15.3M
{
91
15.3M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
92
15.3M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
93
15.3M
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
94
15.3M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
95
15.3M
  int blkn, ci, xindex, yindex, yoffset, useful_width;
96
15.3M
  _JSAMPARRAY output_ptr;
97
15.3M
  JDIMENSION start_col, output_col;
98
15.3M
  jpeg_component_info *compptr;
99
15.3M
  _inverse_DCT_method_ptr inverse_DCT;
100
101
  /* Loop to process as much as one whole iMCU row */
102
31.8M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
103
16.5M
       yoffset++) {
104
74.7M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
105
58.2M
         MCU_col_num++) {
106
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
107
58.2M
      jzero_far((void *)coef->MCU_buffer[0],
108
58.2M
                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
109
58.2M
      if (!cinfo->entropy->insufficient_data)
110
20.1M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
111
#ifdef WITH_PROFILE
112
      cinfo->master->start = getTime();
113
#endif
114
58.2M
      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
115
        /* Suspension forced; update state counters and exit */
116
0
        coef->MCU_vert_offset = yoffset;
117
0
        coef->MCU_ctr = MCU_col_num;
118
#ifdef WITH_PROFILE
119
        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
120
        cinfo->master->entropy_mcoeffs +=
121
          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
122
#endif
123
0
        return JPEG_SUSPENDED;
124
0
      }
125
#ifdef WITH_PROFILE
126
      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
127
      cinfo->master->entropy_mcoeffs +=
128
        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
129
#endif
130
131
      /* Only perform the IDCT on blocks that are contained within the desired
132
       * cropping region.
133
       */
134
58.2M
      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
135
58.1M
          MCU_col_num <= cinfo->master->last_iMCU_col) {
136
        /* Determine where data should go in output_buf and do the IDCT thing.
137
         * We skip dummy blocks at the right and bottom edges (but blkn gets
138
         * incremented past them!).  Note the inner loop relies on having
139
         * allocated the MCU_buffer[] blocks sequentially.
140
         */
141
57.3M
        blkn = 0;               /* index of current DCT block within MCU */
142
146M
        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
143
89.3M
          compptr = cinfo->cur_comp_info[ci];
144
          /* Don't bother to IDCT an uninteresting component. */
145
89.3M
          if (!compptr->component_needed) {
146
118k
            blkn += compptr->MCU_blocks;
147
118k
            continue;
148
118k
          }
149
89.2M
          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
150
89.2M
          useful_width = (MCU_col_num < last_MCU_col) ?
151
46.9M
                         compptr->MCU_width : compptr->last_col_width;
152
89.2M
          output_ptr = output_buf[compptr->component_index] +
153
89.2M
                       yoffset * compptr->_DCT_scaled_size;
154
89.2M
          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
155
89.2M
                      compptr->MCU_sample_width;
156
183M
          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
157
94.2M
            if (cinfo->input_iMCU_row < last_iMCU_row ||
158
93.7M
                yoffset + yindex < compptr->last_row_height) {
159
93.7M
              output_col = start_col;
160
195M
              for (xindex = 0; xindex < useful_width; xindex++) {
161
#ifdef WITH_PROFILE
162
                cinfo->master->start = getTime();
163
#endif
164
101M
                (*inverse_DCT) (cinfo, compptr,
165
101M
                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
166
101M
                                output_ptr, output_col);
167
#ifdef WITH_PROFILE
168
                cinfo->master->idct_elapsed +=
169
                  getTime() - cinfo->master->start;
170
                cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
171
#endif
172
101M
                output_col += compptr->_DCT_scaled_size;
173
101M
              }
174
93.7M
            }
175
94.2M
            blkn += compptr->MCU_width;
176
94.2M
            output_ptr += compptr->_DCT_scaled_size;
177
94.2M
          }
178
89.2M
        }
179
57.3M
      }
180
58.2M
    }
181
    /* Completed an MCU row, but perhaps not an iMCU row */
182
16.5M
    coef->MCU_ctr = 0;
183
16.5M
  }
184
  /* Completed the iMCU row, advance counters for next one */
185
15.3M
  cinfo->output_iMCU_row++;
186
15.3M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
187
15.3M
    start_iMCU_row(cinfo);
188
15.3M
    return JPEG_ROW_COMPLETED;
189
15.3M
  }
190
  /* Completed the scan */
191
13.9k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
192
13.9k
  return JPEG_SCAN_COMPLETED;
193
15.3M
}
jdcoefct-12.c:decompress_onepass
Line
Count
Source
90
622k
{
91
622k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
92
622k
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
93
622k
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
94
622k
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
95
622k
  int blkn, ci, xindex, yindex, yoffset, useful_width;
96
622k
  _JSAMPARRAY output_ptr;
97
622k
  JDIMENSION start_col, output_col;
98
622k
  jpeg_component_info *compptr;
99
622k
  _inverse_DCT_method_ptr inverse_DCT;
100
101
  /* Loop to process as much as one whole iMCU row */
102
1.66M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
103
1.04M
       yoffset++) {
104
14.8M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
105
13.7M
         MCU_col_num++) {
106
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
107
13.7M
      jzero_far((void *)coef->MCU_buffer[0],
108
13.7M
                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
109
13.7M
      if (!cinfo->entropy->insufficient_data)
110
7.02M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
111
#ifdef WITH_PROFILE
112
      cinfo->master->start = getTime();
113
#endif
114
13.7M
      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
115
        /* Suspension forced; update state counters and exit */
116
0
        coef->MCU_vert_offset = yoffset;
117
0
        coef->MCU_ctr = MCU_col_num;
118
#ifdef WITH_PROFILE
119
        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
120
        cinfo->master->entropy_mcoeffs +=
121
          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
122
#endif
123
0
        return JPEG_SUSPENDED;
124
0
      }
125
#ifdef WITH_PROFILE
126
      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
127
      cinfo->master->entropy_mcoeffs +=
128
        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
129
#endif
130
131
      /* Only perform the IDCT on blocks that are contained within the desired
132
       * cropping region.
133
       */
134
13.7M
      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
135
13.7M
          MCU_col_num <= cinfo->master->last_iMCU_col) {
136
        /* Determine where data should go in output_buf and do the IDCT thing.
137
         * We skip dummy blocks at the right and bottom edges (but blkn gets
138
         * incremented past them!).  Note the inner loop relies on having
139
         * allocated the MCU_buffer[] blocks sequentially.
140
         */
141
12.5M
        blkn = 0;               /* index of current DCT block within MCU */
142
26.4M
        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
143
13.9M
          compptr = cinfo->cur_comp_info[ci];
144
          /* Don't bother to IDCT an uninteresting component. */
145
13.9M
          if (!compptr->component_needed) {
146
92.0k
            blkn += compptr->MCU_blocks;
147
92.0k
            continue;
148
92.0k
          }
149
13.8M
          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
150
13.8M
          useful_width = (MCU_col_num < last_MCU_col) ?
151
12.6M
                         compptr->MCU_width : compptr->last_col_width;
152
13.8M
          output_ptr = output_buf[compptr->component_index] +
153
13.8M
                       yoffset * compptr->_DCT_scaled_size;
154
13.8M
          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
155
13.8M
                      compptr->MCU_sample_width;
156
28.4M
          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
157
14.6M
            if (cinfo->input_iMCU_row < last_iMCU_row ||
158
14.4M
                yoffset + yindex < compptr->last_row_height) {
159
14.4M
              output_col = start_col;
160
29.7M
              for (xindex = 0; xindex < useful_width; xindex++) {
161
#ifdef WITH_PROFILE
162
                cinfo->master->start = getTime();
163
#endif
164
15.3M
                (*inverse_DCT) (cinfo, compptr,
165
15.3M
                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
166
15.3M
                                output_ptr, output_col);
167
#ifdef WITH_PROFILE
168
                cinfo->master->idct_elapsed +=
169
                  getTime() - cinfo->master->start;
170
                cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
171
#endif
172
15.3M
                output_col += compptr->_DCT_scaled_size;
173
15.3M
              }
174
14.4M
            }
175
14.6M
            blkn += compptr->MCU_width;
176
14.6M
            output_ptr += compptr->_DCT_scaled_size;
177
14.6M
          }
178
13.8M
        }
179
12.5M
      }
180
13.7M
    }
181
    /* Completed an MCU row, but perhaps not an iMCU row */
182
1.04M
    coef->MCU_ctr = 0;
183
1.04M
  }
184
  /* Completed the iMCU row, advance counters for next one */
185
622k
  cinfo->output_iMCU_row++;
186
622k
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
187
619k
    start_iMCU_row(cinfo);
188
619k
    return JPEG_ROW_COMPLETED;
189
619k
  }
190
  /* Completed the scan */
191
3.33k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
192
3.33k
  return JPEG_SCAN_COMPLETED;
193
622k
}
194
195
196
/*
197
 * Dummy consume-input routine for single-pass operation.
198
 */
199
200
METHODDEF(int)
201
dummy_consume_data(j_decompress_ptr cinfo)
202
0
{
203
0
  return JPEG_SUSPENDED;        /* Always indicate nothing was done */
204
0
}
Unexecuted instantiation: jdcoefct-8.c:dummy_consume_data
Unexecuted instantiation: jdcoefct-12.c:dummy_consume_data
205
206
207
#ifdef D_MULTISCAN_FILES_SUPPORTED
208
209
/*
210
 * Consume input data and store it in the full-image coefficient buffer.
211
 * We read as much as one fully interleaved MCU row ("iMCU" row) per call,
212
 * ie, v_samp_factor block rows for each component in the scan.
213
 * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
214
 */
215
216
METHODDEF(int)
217
consume_data(j_decompress_ptr cinfo)
218
168M
{
219
168M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
220
168M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
221
168M
  int blkn, ci, xindex, yindex, yoffset;
222
168M
  JDIMENSION start_col;
223
168M
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
224
168M
  JBLOCKROW buffer_ptr;
225
168M
  jpeg_component_info *compptr;
226
227
  /* Align the virtual buffers for the components used in this scan. */
228
359M
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
229
190M
    compptr = cinfo->cur_comp_info[ci];
230
190M
    buffer[ci] = (*cinfo->mem->access_virt_barray)
231
190M
      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
232
190M
       cinfo->input_iMCU_row * compptr->v_samp_factor,
233
190M
       (JDIMENSION)compptr->v_samp_factor, TRUE);
234
    /* Note: entropy decoder expects buffer to be zeroed,
235
     * but this is handled automatically by the memory manager
236
     * because we requested a pre-zeroed array.
237
     */
238
190M
  }
239
240
  /* Loop to process one whole iMCU row */
241
443M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
242
274M
       yoffset++) {
243
1.45G
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
244
1.17G
         MCU_col_num++) {
245
      /* Construct list of pointers to DCT blocks belonging to this MCU */
246
1.17G
      blkn = 0;                 /* index of current DCT block within MCU */
247
2.48G
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
248
1.31G
        compptr = cinfo->cur_comp_info[ci];
249
1.31G
        start_col = MCU_col_num * compptr->MCU_width;
250
2.69G
        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
251
1.38G
          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
252
2.94G
          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
253
1.55G
            coef->MCU_buffer[blkn++] = buffer_ptr++;
254
1.55G
          }
255
1.38G
        }
256
1.31G
      }
257
1.17G
      if (!cinfo->entropy->insufficient_data)
258
794M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
259
      /* Try to fetch the MCU. */
260
#ifdef WITH_PROFILE
261
      cinfo->master->start = getTime();
262
#endif
263
1.17G
      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
264
        /* Suspension forced; update state counters and exit */
265
0
        coef->MCU_vert_offset = yoffset;
266
0
        coef->MCU_ctr = MCU_col_num;
267
#ifdef WITH_PROFILE
268
        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
269
        cinfo->master->entropy_mcoeffs +=
270
          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
271
#endif
272
0
        return JPEG_SUSPENDED;
273
0
      }
274
#ifdef WITH_PROFILE
275
      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
276
      cinfo->master->entropy_mcoeffs +=
277
        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
278
#endif
279
1.17G
    }
280
    /* Completed an MCU row, but perhaps not an iMCU row */
281
274M
    coef->MCU_ctr = 0;
282
274M
  }
283
  /* Completed the iMCU row, advance counters for next one */
284
168M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
285
167M
    start_iMCU_row(cinfo);
286
167M
    return JPEG_ROW_COMPLETED;
287
167M
  }
288
  /* Completed the scan */
289
588k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
290
588k
  return JPEG_SCAN_COMPLETED;
291
168M
}
jdcoefct-8.c:consume_data
Line
Count
Source
218
158M
{
219
158M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
220
158M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
221
158M
  int blkn, ci, xindex, yindex, yoffset;
222
158M
  JDIMENSION start_col;
223
158M
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
224
158M
  JBLOCKROW buffer_ptr;
225
158M
  jpeg_component_info *compptr;
226
227
  /* Align the virtual buffers for the components used in this scan. */
228
337M
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
229
178M
    compptr = cinfo->cur_comp_info[ci];
230
178M
    buffer[ci] = (*cinfo->mem->access_virt_barray)
231
178M
      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
232
178M
       cinfo->input_iMCU_row * compptr->v_samp_factor,
233
178M
       (JDIMENSION)compptr->v_samp_factor, TRUE);
234
    /* Note: entropy decoder expects buffer to be zeroed,
235
     * but this is handled automatically by the memory manager
236
     * because we requested a pre-zeroed array.
237
     */
238
178M
  }
239
240
  /* Loop to process one whole iMCU row */
241
419M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
242
261M
       yoffset++) {
243
1.31G
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
244
1.04G
         MCU_col_num++) {
245
      /* Construct list of pointers to DCT blocks belonging to this MCU */
246
1.04G
      blkn = 0;                 /* index of current DCT block within MCU */
247
2.22G
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
248
1.17G
        compptr = cinfo->cur_comp_info[ci];
249
1.17G
        start_col = MCU_col_num * compptr->MCU_width;
250
2.41G
        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
251
1.23G
          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
252
2.64G
          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
253
1.40G
            coef->MCU_buffer[blkn++] = buffer_ptr++;
254
1.40G
          }
255
1.23G
        }
256
1.17G
      }
257
1.04G
      if (!cinfo->entropy->insufficient_data)
258
700M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
259
      /* Try to fetch the MCU. */
260
#ifdef WITH_PROFILE
261
      cinfo->master->start = getTime();
262
#endif
263
1.04G
      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
264
        /* Suspension forced; update state counters and exit */
265
0
        coef->MCU_vert_offset = yoffset;
266
0
        coef->MCU_ctr = MCU_col_num;
267
#ifdef WITH_PROFILE
268
        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
269
        cinfo->master->entropy_mcoeffs +=
270
          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
271
#endif
272
0
        return JPEG_SUSPENDED;
273
0
      }
274
#ifdef WITH_PROFILE
275
      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
276
      cinfo->master->entropy_mcoeffs +=
277
        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
278
#endif
279
1.04G
    }
280
    /* Completed an MCU row, but perhaps not an iMCU row */
281
261M
    coef->MCU_ctr = 0;
282
261M
  }
283
  /* Completed the iMCU row, advance counters for next one */
284
158M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
285
157M
    start_iMCU_row(cinfo);
286
157M
    return JPEG_ROW_COMPLETED;
287
157M
  }
288
  /* Completed the scan */
289
507k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
290
507k
  return JPEG_SCAN_COMPLETED;
291
158M
}
jdcoefct-12.c:consume_data
Line
Count
Source
218
9.87M
{
219
9.87M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
220
9.87M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
221
9.87M
  int blkn, ci, xindex, yindex, yoffset;
222
9.87M
  JDIMENSION start_col;
223
9.87M
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
224
9.87M
  JBLOCKROW buffer_ptr;
225
9.87M
  jpeg_component_info *compptr;
226
227
  /* Align the virtual buffers for the components used in this scan. */
228
22.1M
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
229
12.2M
    compptr = cinfo->cur_comp_info[ci];
230
12.2M
    buffer[ci] = (*cinfo->mem->access_virt_barray)
231
12.2M
      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
232
12.2M
       cinfo->input_iMCU_row * compptr->v_samp_factor,
233
12.2M
       (JDIMENSION)compptr->v_samp_factor, TRUE);
234
    /* Note: entropy decoder expects buffer to be zeroed,
235
     * but this is handled automatically by the memory manager
236
     * because we requested a pre-zeroed array.
237
     */
238
12.2M
  }
239
240
  /* Loop to process one whole iMCU row */
241
23.5M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
242
13.6M
       yoffset++) {
243
140M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
244
127M
         MCU_col_num++) {
245
      /* Construct list of pointers to DCT blocks belonging to this MCU */
246
127M
      blkn = 0;                 /* index of current DCT block within MCU */
247
263M
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
248
136M
        compptr = cinfo->cur_comp_info[ci];
249
136M
        start_col = MCU_col_num * compptr->MCU_width;
250
282M
        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
251
146M
          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
252
298M
          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
253
152M
            coef->MCU_buffer[blkn++] = buffer_ptr++;
254
152M
          }
255
146M
        }
256
136M
      }
257
127M
      if (!cinfo->entropy->insufficient_data)
258
93.4M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
259
      /* Try to fetch the MCU. */
260
#ifdef WITH_PROFILE
261
      cinfo->master->start = getTime();
262
#endif
263
127M
      if (!(*cinfo->entropy->decode_mcu) (cinfo, coef->MCU_buffer)) {
264
        /* Suspension forced; update state counters and exit */
265
0
        coef->MCU_vert_offset = yoffset;
266
0
        coef->MCU_ctr = MCU_col_num;
267
#ifdef WITH_PROFILE
268
        cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
269
        cinfo->master->entropy_mcoeffs +=
270
          (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
271
#endif
272
0
        return JPEG_SUSPENDED;
273
0
      }
274
#ifdef WITH_PROFILE
275
      cinfo->master->entropy_elapsed += getTime() - cinfo->master->start;
276
      cinfo->master->entropy_mcoeffs +=
277
        (double)cinfo->blocks_in_MCU * DCTSIZE2 / 1000000.;
278
#endif
279
127M
    }
280
    /* Completed an MCU row, but perhaps not an iMCU row */
281
13.6M
    coef->MCU_ctr = 0;
282
13.6M
  }
283
  /* Completed the iMCU row, advance counters for next one */
284
9.87M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
285
9.79M
    start_iMCU_row(cinfo);
286
9.79M
    return JPEG_ROW_COMPLETED;
287
9.79M
  }
288
  /* Completed the scan */
289
80.8k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
290
80.8k
  return JPEG_SCAN_COMPLETED;
291
9.87M
}
292
293
294
/*
295
 * Decompress and return some data in the multi-pass case.
296
 * Always attempts to emit one fully interleaved MCU row ("iMCU" row).
297
 * Return value is JPEG_ROW_COMPLETED, JPEG_SCAN_COMPLETED, or JPEG_SUSPENDED.
298
 *
299
 * NB: output_buf contains a plane for each component in image.
300
 */
301
302
METHODDEF(int)
303
decompress_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
304
8.14M
{
305
8.14M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
306
8.14M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
307
8.14M
  JDIMENSION block_num;
308
8.14M
  int ci, block_row, block_rows;
309
8.14M
  JBLOCKARRAY buffer;
310
8.14M
  JBLOCKROW buffer_ptr;
311
8.14M
  _JSAMPARRAY output_ptr;
312
8.14M
  JDIMENSION output_col;
313
8.14M
  jpeg_component_info *compptr;
314
8.14M
  _inverse_DCT_method_ptr inverse_DCT;
315
316
  /* Force some input to be done if we are getting ahead of the input. */
317
12.7M
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
318
12.7M
         (cinfo->input_scan_number == cinfo->output_scan_number &&
319
12.7M
          cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
320
4.58M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
321
0
      return JPEG_SUSPENDED;
322
4.58M
  }
323
324
  /* OK, output from the virtual arrays. */
325
28.3M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
326
20.2M
       ci++, compptr++) {
327
    /* Don't bother to IDCT an uninteresting component. */
328
20.2M
    if (!compptr->component_needed)
329
642k
      continue;
330
    /* Align the virtual buffer for this component. */
331
19.6M
    buffer = (*cinfo->mem->access_virt_barray)
332
19.6M
      ((j_common_ptr)cinfo, coef->whole_image[ci],
333
19.6M
       cinfo->output_iMCU_row * compptr->v_samp_factor,
334
19.6M
       (JDIMENSION)compptr->v_samp_factor, FALSE);
335
    /* Count non-dummy DCT block rows in this iMCU row. */
336
19.6M
    if (cinfo->output_iMCU_row < last_iMCU_row)
337
19.4M
      block_rows = compptr->v_samp_factor;
338
137k
    else {
339
      /* NB: can't use last_row_height here; it is input-side-dependent! */
340
137k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
341
137k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
342
137k
    }
343
19.6M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
344
19.6M
    output_ptr = output_buf[ci];
345
    /* Loop over all DCT blocks to be processed. */
346
48.1M
    for (block_row = 0; block_row < block_rows; block_row++) {
347
28.5M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
348
28.5M
      output_col = 0;
349
28.5M
      for (block_num = cinfo->master->first_MCU_col[ci];
350
208M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
351
#ifdef WITH_PROFILE
352
        cinfo->master->start = getTime();
353
#endif
354
180M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
355
180M
                        output_col);
356
#ifdef WITH_PROFILE
357
        cinfo->master->idct_elapsed += getTime() - cinfo->master->start;
358
        cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
359
#endif
360
180M
        buffer_ptr++;
361
180M
        output_col += compptr->_DCT_scaled_size;
362
180M
      }
363
28.5M
      output_ptr += compptr->_DCT_scaled_size;
364
28.5M
    }
365
19.6M
  }
366
367
8.14M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
368
8.09M
    return JPEG_ROW_COMPLETED;
369
52.4k
  return JPEG_SCAN_COMPLETED;
370
8.14M
}
jdcoefct-8.c:decompress_data
Line
Count
Source
304
7.25M
{
305
7.25M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
306
7.25M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
307
7.25M
  JDIMENSION block_num;
308
7.25M
  int ci, block_row, block_rows;
309
7.25M
  JBLOCKARRAY buffer;
310
7.25M
  JBLOCKROW buffer_ptr;
311
7.25M
  _JSAMPARRAY output_ptr;
312
7.25M
  JDIMENSION output_col;
313
7.25M
  jpeg_component_info *compptr;
314
7.25M
  _inverse_DCT_method_ptr inverse_DCT;
315
316
  /* Force some input to be done if we are getting ahead of the input. */
317
11.8M
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
318
11.8M
         (cinfo->input_scan_number == cinfo->output_scan_number &&
319
11.8M
          cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
320
4.58M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
321
0
      return JPEG_SUSPENDED;
322
4.58M
  }
323
324
  /* OK, output from the virtual arrays. */
325
25.3M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
326
18.0M
       ci++, compptr++) {
327
    /* Don't bother to IDCT an uninteresting component. */
328
18.0M
    if (!compptr->component_needed)
329
379k
      continue;
330
    /* Align the virtual buffer for this component. */
331
17.7M
    buffer = (*cinfo->mem->access_virt_barray)
332
17.7M
      ((j_common_ptr)cinfo, coef->whole_image[ci],
333
17.7M
       cinfo->output_iMCU_row * compptr->v_samp_factor,
334
17.7M
       (JDIMENSION)compptr->v_samp_factor, FALSE);
335
    /* Count non-dummy DCT block rows in this iMCU row. */
336
17.7M
    if (cinfo->output_iMCU_row < last_iMCU_row)
337
17.5M
      block_rows = compptr->v_samp_factor;
338
129k
    else {
339
      /* NB: can't use last_row_height here; it is input-side-dependent! */
340
129k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
341
129k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
342
129k
    }
343
17.7M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
344
17.7M
    output_ptr = output_buf[ci];
345
    /* Loop over all DCT blocks to be processed. */
346
43.3M
    for (block_row = 0; block_row < block_rows; block_row++) {
347
25.6M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
348
25.6M
      output_col = 0;
349
25.6M
      for (block_num = cinfo->master->first_MCU_col[ci];
350
185M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
351
#ifdef WITH_PROFILE
352
        cinfo->master->start = getTime();
353
#endif
354
159M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
355
159M
                        output_col);
356
#ifdef WITH_PROFILE
357
        cinfo->master->idct_elapsed += getTime() - cinfo->master->start;
358
        cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
359
#endif
360
159M
        buffer_ptr++;
361
159M
        output_col += compptr->_DCT_scaled_size;
362
159M
      }
363
25.6M
      output_ptr += compptr->_DCT_scaled_size;
364
25.6M
    }
365
17.7M
  }
366
367
7.25M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
368
7.20M
    return JPEG_ROW_COMPLETED;
369
48.6k
  return JPEG_SCAN_COMPLETED;
370
7.25M
}
jdcoefct-12.c:decompress_data
Line
Count
Source
304
891k
{
305
891k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
306
891k
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
307
891k
  JDIMENSION block_num;
308
891k
  int ci, block_row, block_rows;
309
891k
  JBLOCKARRAY buffer;
310
891k
  JBLOCKROW buffer_ptr;
311
891k
  _JSAMPARRAY output_ptr;
312
891k
  JDIMENSION output_col;
313
891k
  jpeg_component_info *compptr;
314
891k
  _inverse_DCT_method_ptr inverse_DCT;
315
316
  /* Force some input to be done if we are getting ahead of the input. */
317
891k
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
318
891k
         (cinfo->input_scan_number == cinfo->output_scan_number &&
319
891k
          cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
320
0
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
321
0
      return JPEG_SUSPENDED;
322
0
  }
323
324
  /* OK, output from the virtual arrays. */
325
3.05M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
326
2.16M
       ci++, compptr++) {
327
    /* Don't bother to IDCT an uninteresting component. */
328
2.16M
    if (!compptr->component_needed)
329
263k
      continue;
330
    /* Align the virtual buffer for this component. */
331
1.89M
    buffer = (*cinfo->mem->access_virt_barray)
332
1.89M
      ((j_common_ptr)cinfo, coef->whole_image[ci],
333
1.89M
       cinfo->output_iMCU_row * compptr->v_samp_factor,
334
1.89M
       (JDIMENSION)compptr->v_samp_factor, FALSE);
335
    /* Count non-dummy DCT block rows in this iMCU row. */
336
1.89M
    if (cinfo->output_iMCU_row < last_iMCU_row)
337
1.88M
      block_rows = compptr->v_samp_factor;
338
8.12k
    else {
339
      /* NB: can't use last_row_height here; it is input-side-dependent! */
340
8.12k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
341
8.12k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
342
8.12k
    }
343
1.89M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
344
1.89M
    output_ptr = output_buf[ci];
345
    /* Loop over all DCT blocks to be processed. */
346
4.80M
    for (block_row = 0; block_row < block_rows; block_row++) {
347
2.90M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
348
2.90M
      output_col = 0;
349
2.90M
      for (block_num = cinfo->master->first_MCU_col[ci];
350
23.8M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
351
#ifdef WITH_PROFILE
352
        cinfo->master->start = getTime();
353
#endif
354
20.9M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
355
20.9M
                        output_col);
356
#ifdef WITH_PROFILE
357
        cinfo->master->idct_elapsed += getTime() - cinfo->master->start;
358
        cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
359
#endif
360
20.9M
        buffer_ptr++;
361
20.9M
        output_col += compptr->_DCT_scaled_size;
362
20.9M
      }
363
2.90M
      output_ptr += compptr->_DCT_scaled_size;
364
2.90M
    }
365
1.89M
  }
366
367
891k
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
368
887k
    return JPEG_ROW_COMPLETED;
369
3.74k
  return JPEG_SCAN_COMPLETED;
370
891k
}
371
372
#endif /* D_MULTISCAN_FILES_SUPPORTED */
373
374
375
#ifdef BLOCK_SMOOTHING_SUPPORTED
376
377
/*
378
 * This code applies interblock smoothing; the first 9 AC coefficients are
379
 * estimated from the DC values of a DCT block and its 24 neighboring blocks.
380
 * We apply smoothing only for progressive JPEG decoding, and only if
381
 * the coefficients it can estimate are not yet known to full precision.
382
 */
383
384
/* Natural-order array positions of the first 9 zigzag-order coefficients */
385
15.3M
#define Q01_POS  1
386
15.3M
#define Q10_POS  8
387
15.3M
#define Q20_POS  16
388
15.3M
#define Q11_POS  9
389
15.3M
#define Q02_POS  2
390
8.58M
#define Q03_POS  3
391
8.58M
#define Q12_POS  10
392
8.58M
#define Q21_POS  17
393
8.58M
#define Q30_POS  24
394
395
/*
396
 * Determine whether block smoothing is applicable and safe.
397
 * We also latch the current states of the coef_bits[] entries for the
398
 * AC coefficients; otherwise, if the input side of the decompressor
399
 * advances into a new scan, we might think the coefficients are known
400
 * more accurately than they really are.
401
 */
402
403
LOCAL(boolean)
404
smoothing_ok(j_decompress_ptr cinfo)
405
85.4k
{
406
85.4k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
407
85.4k
  boolean smoothing_useful = FALSE;
408
85.4k
  int ci, coefi;
409
85.4k
  jpeg_component_info *compptr;
410
85.4k
  JQUANT_TBL *qtable;
411
85.4k
  int *coef_bits, *prev_coef_bits;
412
85.4k
  int *coef_bits_latch, *prev_coef_bits_latch;
413
414
85.4k
  if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
415
26.8k
    return FALSE;
416
417
  /* Allocate latch area if not already done */
418
58.6k
  if (coef->coef_bits_latch == NULL)
419
30.4k
    coef->coef_bits_latch = (int *)
420
30.4k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
421
30.4k
                                  cinfo->num_components * 2 *
422
30.4k
                                  (SAVED_COEFS * sizeof(int)));
423
58.6k
  coef_bits_latch = coef->coef_bits_latch;
424
58.6k
  prev_coef_bits_latch =
425
58.6k
    &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
426
427
125k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
428
94.8k
       ci++, compptr++) {
429
    /* All components' quantization values must already be latched. */
430
94.8k
    if ((qtable = compptr->quant_table) == NULL)
431
9.52k
      return FALSE;
432
    /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
433
85.3k
    if (qtable->quantval[0] == 0 ||
434
83.9k
        qtable->quantval[Q01_POS] == 0 ||
435
82.1k
        qtable->quantval[Q10_POS] == 0 ||
436
80.9k
        qtable->quantval[Q20_POS] == 0 ||
437
79.0k
        qtable->quantval[Q11_POS] == 0 ||
438
77.5k
        qtable->quantval[Q02_POS] == 0 ||
439
76.3k
        qtable->quantval[Q03_POS] == 0 ||
440
75.0k
        qtable->quantval[Q12_POS] == 0 ||
441
72.8k
        qtable->quantval[Q21_POS] == 0 ||
442
71.4k
        qtable->quantval[Q30_POS] == 0)
443
15.1k
      return FALSE;
444
    /* DC values must be at least partly known for all components. */
445
70.1k
    coef_bits = cinfo->coef_bits[ci];
446
70.1k
    prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
447
70.1k
    if (coef_bits[0] < 0)
448
3.78k
      return FALSE;
449
66.4k
    coef_bits_latch[0] = coef_bits[0];
450
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
451
664k
    for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
452
597k
      if (cinfo->input_scan_number > 1)
453
517k
        prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
454
80.0k
      else
455
80.0k
        prev_coef_bits_latch[coefi] = -1;
456
597k
      coef_bits_latch[coefi] = coef_bits[coefi];
457
597k
      if (coef_bits[coefi] != 0)
458
574k
        smoothing_useful = TRUE;
459
597k
    }
460
66.4k
    coef_bits_latch += SAVED_COEFS;
461
66.4k
    prev_coef_bits_latch += SAVED_COEFS;
462
66.4k
  }
463
464
30.1k
  return smoothing_useful;
465
58.6k
}
jdcoefct-8.c:smoothing_ok
Line
Count
Source
405
76.2k
{
406
76.2k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
407
76.2k
  boolean smoothing_useful = FALSE;
408
76.2k
  int ci, coefi;
409
76.2k
  jpeg_component_info *compptr;
410
76.2k
  JQUANT_TBL *qtable;
411
76.2k
  int *coef_bits, *prev_coef_bits;
412
76.2k
  int *coef_bits_latch, *prev_coef_bits_latch;
413
414
76.2k
  if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
415
24.9k
    return FALSE;
416
417
  /* Allocate latch area if not already done */
418
51.2k
  if (coef->coef_bits_latch == NULL)
419
23.1k
    coef->coef_bits_latch = (int *)
420
23.1k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
421
23.1k
                                  cinfo->num_components * 2 *
422
23.1k
                                  (SAVED_COEFS * sizeof(int)));
423
51.2k
  coef_bits_latch = coef->coef_bits_latch;
424
51.2k
  prev_coef_bits_latch =
425
51.2k
    &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
426
427
111k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
428
85.1k
       ci++, compptr++) {
429
    /* All components' quantization values must already be latched. */
430
85.1k
    if ((qtable = compptr->quant_table) == NULL)
431
8.82k
      return FALSE;
432
    /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
433
76.2k
    if (qtable->quantval[0] == 0 ||
434
75.2k
        qtable->quantval[Q01_POS] == 0 ||
435
73.5k
        qtable->quantval[Q10_POS] == 0 ||
436
72.5k
        qtable->quantval[Q20_POS] == 0 ||
437
70.8k
        qtable->quantval[Q11_POS] == 0 ||
438
69.5k
        qtable->quantval[Q02_POS] == 0 ||
439
68.5k
        qtable->quantval[Q03_POS] == 0 ||
440
67.3k
        qtable->quantval[Q12_POS] == 0 ||
441
65.3k
        qtable->quantval[Q21_POS] == 0 ||
442
64.0k
        qtable->quantval[Q30_POS] == 0)
443
13.2k
      return FALSE;
444
    /* DC values must be at least partly known for all components. */
445
63.0k
    coef_bits = cinfo->coef_bits[ci];
446
63.0k
    prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
447
63.0k
    if (coef_bits[0] < 0)
448
3.12k
      return FALSE;
449
59.9k
    coef_bits_latch[0] = coef_bits[0];
450
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
451
599k
    for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
452
539k
      if (cinfo->input_scan_number > 1)
453
485k
        prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
454
53.3k
      else
455
53.3k
        prev_coef_bits_latch[coefi] = -1;
456
539k
      coef_bits_latch[coefi] = coef_bits[coefi];
457
539k
      if (coef_bits[coefi] != 0)
458
518k
        smoothing_useful = TRUE;
459
539k
    }
460
59.9k
    coef_bits_latch += SAVED_COEFS;
461
59.9k
    prev_coef_bits_latch += SAVED_COEFS;
462
59.9k
  }
463
464
26.0k
  return smoothing_useful;
465
51.2k
}
jdcoefct-12.c:smoothing_ok
Line
Count
Source
405
9.25k
{
406
9.25k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
407
9.25k
  boolean smoothing_useful = FALSE;
408
9.25k
  int ci, coefi;
409
9.25k
  jpeg_component_info *compptr;
410
9.25k
  JQUANT_TBL *qtable;
411
9.25k
  int *coef_bits, *prev_coef_bits;
412
9.25k
  int *coef_bits_latch, *prev_coef_bits_latch;
413
414
9.25k
  if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
415
1.92k
    return FALSE;
416
417
  /* Allocate latch area if not already done */
418
7.33k
  if (coef->coef_bits_latch == NULL)
419
7.33k
    coef->coef_bits_latch = (int *)
420
7.33k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
421
7.33k
                                  cinfo->num_components * 2 *
422
7.33k
                                  (SAVED_COEFS * sizeof(int)));
423
7.33k
  coef_bits_latch = coef->coef_bits_latch;
424
7.33k
  prev_coef_bits_latch =
425
7.33k
    &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
426
427
13.8k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
428
9.78k
       ci++, compptr++) {
429
    /* All components' quantization values must already be latched. */
430
9.78k
    if ((qtable = compptr->quant_table) == NULL)
431
701
      return FALSE;
432
    /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
433
9.08k
    if (qtable->quantval[0] == 0 ||
434
8.79k
        qtable->quantval[Q01_POS] == 0 ||
435
8.61k
        qtable->quantval[Q10_POS] == 0 ||
436
8.36k
        qtable->quantval[Q20_POS] == 0 ||
437
8.19k
        qtable->quantval[Q11_POS] == 0 ||
438
7.98k
        qtable->quantval[Q02_POS] == 0 ||
439
7.83k
        qtable->quantval[Q03_POS] == 0 ||
440
7.69k
        qtable->quantval[Q12_POS] == 0 ||
441
7.50k
        qtable->quantval[Q21_POS] == 0 ||
442
7.34k
        qtable->quantval[Q30_POS] == 0)
443
1.92k
      return FALSE;
444
    /* DC values must be at least partly known for all components. */
445
7.15k
    coef_bits = cinfo->coef_bits[ci];
446
7.15k
    prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
447
7.15k
    if (coef_bits[0] < 0)
448
656
      return FALSE;
449
6.49k
    coef_bits_latch[0] = coef_bits[0];
450
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
451
64.9k
    for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
452
58.4k
      if (cinfo->input_scan_number > 1)
453
31.8k
        prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
454
26.6k
      else
455
26.6k
        prev_coef_bits_latch[coefi] = -1;
456
58.4k
      coef_bits_latch[coefi] = coef_bits[coefi];
457
58.4k
      if (coef_bits[coefi] != 0)
458
55.8k
        smoothing_useful = TRUE;
459
58.4k
    }
460
6.49k
    coef_bits_latch += SAVED_COEFS;
461
6.49k
    prev_coef_bits_latch += SAVED_COEFS;
462
6.49k
  }
463
464
4.05k
  return smoothing_useful;
465
7.33k
}
466
467
468
/*
469
 * Variant of decompress_data for use when doing block smoothing.
470
 */
471
472
METHODDEF(int)
473
decompress_smooth_data(j_decompress_ptr cinfo, _JSAMPIMAGE output_buf)
474
7.53M
{
475
7.53M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
476
7.53M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
477
7.53M
  JDIMENSION block_num, last_block_column;
478
7.53M
  int ci, block_row, block_rows, access_rows, image_block_row,
479
7.53M
    image_block_rows;
480
7.53M
  JBLOCKARRAY buffer;
481
7.53M
  JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
482
7.53M
  JBLOCKROW next_block_row, next_next_block_row;
483
7.53M
  _JSAMPARRAY output_ptr;
484
7.53M
  JDIMENSION output_col;
485
7.53M
  jpeg_component_info *compptr;
486
7.53M
  _inverse_DCT_method_ptr inverse_DCT;
487
7.53M
  boolean change_dc;
488
7.53M
  JCOEF *workspace;
489
7.53M
  int *coef_bits;
490
7.53M
  JQUANT_TBL *quanttbl;
491
7.53M
  JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
492
7.53M
  int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
493
7.53M
      DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
494
7.53M
      DC25;
495
7.53M
  int Al, pred;
496
497
  /* Keep a local variable to avoid looking it up more than once */
498
7.53M
  workspace = coef->workspace;
499
500
  /* Force some input to be done if we are getting ahead of the input. */
501
11.8M
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
502
11.8M
         !cinfo->inputctl->eoi_reached) {
503
9.09M
    if (cinfo->input_scan_number == cinfo->output_scan_number) {
504
      /* If input is working on current scan, we ordinarily want it to
505
       * have completed the current row.  But if input scan is DC,
506
       * we want it to keep two rows ahead so that next two block rows' DC
507
       * values are up to date.
508
       */
509
9.09M
      JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0;
510
9.09M
      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
511
4.73M
        break;
512
9.09M
    }
513
4.35M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
514
19.2k
      return JPEG_SUSPENDED;
515
4.35M
  }
516
517
  /* OK, output from the virtual arrays. */
518
23.0M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
519
15.5M
       ci++, compptr++) {
520
    /* Don't bother to IDCT an uninteresting component. */
521
15.5M
    if (!compptr->component_needed)
522
292k
      continue;
523
    /* Count non-dummy DCT block rows in this iMCU row. */
524
15.2M
    if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
525
15.1M
      block_rows = compptr->v_samp_factor;
526
15.1M
      access_rows = block_rows * 3; /* this and next two iMCU rows */
527
15.1M
    } else if (cinfo->output_iMCU_row < last_iMCU_row) {
528
41.0k
      block_rows = compptr->v_samp_factor;
529
41.0k
      access_rows = block_rows * 2; /* this and next iMCU row */
530
52.2k
    } else {
531
      /* NB: can't use last_row_height here; it is input-side-dependent! */
532
52.2k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
533
52.2k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
534
52.2k
      access_rows = block_rows; /* this iMCU row only */
535
52.2k
    }
536
    /* Align the virtual buffer for this component. */
537
15.2M
    if (cinfo->output_iMCU_row > 1) {
538
15.1M
      access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
539
15.1M
      buffer = (*cinfo->mem->access_virt_barray)
540
15.1M
        ((j_common_ptr)cinfo, coef->whole_image[ci],
541
15.1M
         (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
542
15.1M
         (JDIMENSION)access_rows, FALSE);
543
15.1M
      buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
544
15.1M
    } else if (cinfo->output_iMCU_row > 0) {
545
43.2k
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
546
43.2k
      buffer = (*cinfo->mem->access_virt_barray)
547
43.2k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
548
43.2k
         (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
549
43.2k
         (JDIMENSION)access_rows, FALSE);
550
43.2k
      buffer += compptr->v_samp_factor; /* point to current iMCU row */
551
43.2k
    } else {
552
42.0k
      buffer = (*cinfo->mem->access_virt_barray)
553
42.0k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
554
42.0k
         (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
555
42.0k
    }
556
    /* Fetch component-dependent info.
557
     * If the current scan is incomplete, then we use the component-dependent
558
     * info from the previous scan.
559
     */
560
15.2M
    if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
561
8.62M
      coef_bits =
562
8.62M
        coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
563
6.65M
    else
564
6.65M
      coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
565
566
    /* We only do DC interpolation if no AC coefficient data is available. */
567
15.2M
    change_dc =
568
15.2M
      coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
569
9.91M
      coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
570
8.69M
      coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
571
572
15.2M
    quanttbl = compptr->quant_table;
573
15.2M
    Q00 = quanttbl->quantval[0];
574
15.2M
    Q01 = quanttbl->quantval[Q01_POS];
575
15.2M
    Q10 = quanttbl->quantval[Q10_POS];
576
15.2M
    Q20 = quanttbl->quantval[Q20_POS];
577
15.2M
    Q11 = quanttbl->quantval[Q11_POS];
578
15.2M
    Q02 = quanttbl->quantval[Q02_POS];
579
15.2M
    if (change_dc) {
580
8.51M
      Q03 = quanttbl->quantval[Q03_POS];
581
8.51M
      Q12 = quanttbl->quantval[Q12_POS];
582
8.51M
      Q21 = quanttbl->quantval[Q21_POS];
583
8.51M
      Q30 = quanttbl->quantval[Q30_POS];
584
8.51M
    }
585
15.2M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
586
15.2M
    output_ptr = output_buf[ci];
587
    /* Loop over all DCT blocks to be processed. */
588
15.2M
    image_block_rows = block_rows * cinfo->total_iMCU_rows;
589
33.2M
    for (block_row = 0; block_row < block_rows; block_row++) {
590
18.0M
      image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
591
18.0M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
592
593
18.0M
      if (image_block_row > 0)
594
17.9M
        prev_block_row =
595
17.9M
          buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
596
42.0k
      else
597
42.0k
        prev_block_row = buffer_ptr;
598
599
18.0M
      if (image_block_row > 1)
600
17.9M
        prev_prev_block_row =
601
17.9M
          buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
602
93.1k
      else
603
93.1k
        prev_prev_block_row = prev_block_row;
604
605
18.0M
      if (image_block_row < image_block_rows - 1)
606
17.9M
        next_block_row =
607
17.9M
          buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
608
52.2k
      else
609
52.2k
        next_block_row = buffer_ptr;
610
611
18.0M
      if (image_block_row < image_block_rows - 2)
612
17.9M
        next_next_block_row =
613
17.9M
          buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
614
88.9k
      else
615
88.9k
        next_next_block_row = next_block_row;
616
617
      /* We fetch the surrounding DC values using a sliding-register approach.
618
       * Initialize all 25 here so as to do the right thing on narrow pics.
619
       */
620
18.0M
      DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
621
18.0M
      DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
622
18.0M
      DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
623
18.0M
      DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
624
18.0M
      DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
625
18.0M
      output_col = 0;
626
18.0M
      last_block_column = compptr->width_in_blocks - 1;
627
18.0M
      for (block_num = cinfo->master->first_MCU_col[ci];
628
119M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
629
        /* Fetch current DCT block into workspace so we can modify it. */
630
101M
        jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
631
        /* Update DC values */
632
101M
        if (block_num == cinfo->master->first_MCU_col[ci] &&
633
18.0M
            block_num < last_block_column) {
634
11.1M
          DC04 = DC05 = (int)prev_prev_block_row[1][0];
635
11.1M
          DC09 = DC10 = (int)prev_block_row[1][0];
636
11.1M
          DC14 = DC15 = (int)buffer_ptr[1][0];
637
11.1M
          DC19 = DC20 = (int)next_block_row[1][0];
638
11.1M
          DC24 = DC25 = (int)next_next_block_row[1][0];
639
11.1M
        }
640
101M
        if (block_num + 1 < last_block_column) {
641
71.9M
          DC05 = (int)prev_prev_block_row[2][0];
642
71.9M
          DC10 = (int)prev_block_row[2][0];
643
71.9M
          DC15 = (int)buffer_ptr[2][0];
644
71.9M
          DC20 = (int)next_block_row[2][0];
645
71.9M
          DC25 = (int)next_next_block_row[2][0];
646
71.9M
        }
647
        /* If DC interpolation is enabled, compute coefficient estimates using
648
         * a Gaussian-like kernel, keeping the averages of the DC values.
649
         *
650
         * If DC interpolation is disabled, compute coefficient estimates using
651
         * an algorithm similar to the one described in Section K.8 of the JPEG
652
         * standard, except applied to a 5x5 window rather than a 3x3 window.
653
         *
654
         * An estimate is applied only if the coefficient is still zero and is
655
         * not known to be fully accurate.
656
         */
657
        /* AC01 */
658
101M
        if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
659
87.9M
          num = Q00 * (change_dc ?
660
55.0M
                (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
661
55.0M
                 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
662
55.0M
                 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
663
55.0M
                 DC21 - DC22 + DC24 + DC25) :
664
87.9M
                (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
665
87.9M
          if (num >= 0) {
666
64.2M
            pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
667
64.2M
            if (Al > 0 && pred >= (1 << Al))
668
5.56M
              pred = (1 << Al) - 1;
669
64.2M
          } else {
670
23.6M
            pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
671
23.6M
            if (Al > 0 && pred >= (1 << Al))
672
4.57M
              pred = (1 << Al) - 1;
673
23.6M
            pred = -pred;
674
23.6M
          }
675
87.9M
          workspace[1] = (JCOEF)pred;
676
87.9M
        }
677
        /* AC10 */
678
101M
        if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
679
88.3M
          num = Q00 * (change_dc ?
680
55.0M
                (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
681
55.0M
                 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
682
55.0M
                 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
683
55.0M
                 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
684
88.3M
                (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
685
88.3M
          if (num >= 0) {
686
61.4M
            pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
687
61.4M
            if (Al > 0 && pred >= (1 << Al))
688
8.55M
              pred = (1 << Al) - 1;
689
61.4M
          } else {
690
26.8M
            pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
691
26.8M
            if (Al > 0 && pred >= (1 << Al))
692
7.41M
              pred = (1 << Al) - 1;
693
26.8M
            pred = -pred;
694
26.8M
          }
695
88.3M
          workspace[8] = (JCOEF)pred;
696
88.3M
        }
697
        /* AC20 */
698
101M
        if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
699
88.6M
          num = Q00 * (change_dc ?
700
55.0M
                (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
701
55.0M
                 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
702
88.6M
                (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
703
88.6M
          if (num >= 0) {
704
57.1M
            pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
705
57.1M
            if (Al > 0 && pred >= (1 << Al))
706
7.61M
              pred = (1 << Al) - 1;
707
57.1M
          } else {
708
31.4M
            pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
709
31.4M
            if (Al > 0 && pred >= (1 << Al))
710
7.78M
              pred = (1 << Al) - 1;
711
31.4M
            pred = -pred;
712
31.4M
          }
713
88.6M
          workspace[16] = (JCOEF)pred;
714
88.6M
        }
715
        /* AC11 */
716
101M
        if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
717
88.4M
          num = Q00 * (change_dc ?
718
55.0M
                (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
719
55.0M
                 9 * DC19 + DC21 - DC25) :
720
88.4M
                (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
721
33.4M
                 DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
722
88.4M
          if (num >= 0) {
723
67.9M
            pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
724
67.9M
            if (Al > 0 && pred >= (1 << Al))
725
3.66M
              pred = (1 << Al) - 1;
726
67.9M
          } else {
727
20.4M
            pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
728
20.4M
            if (Al > 0 && pred >= (1 << Al))
729
3.70M
              pred = (1 << Al) - 1;
730
20.4M
            pred = -pred;
731
20.4M
          }
732
88.4M
          workspace[9] = (JCOEF)pred;
733
88.4M
        }
734
        /* AC02 */
735
101M
        if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
736
88.6M
          num = Q00 * (change_dc ?
737
55.0M
                (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
738
55.0M
                 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
739
88.6M
                (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
740
88.6M
          if (num >= 0) {
741
57.9M
            pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
742
57.9M
            if (Al > 0 && pred >= (1 << Al))
743
4.44M
              pred = (1 << Al) - 1;
744
57.9M
          } else {
745
30.6M
            pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
746
30.6M
            if (Al > 0 && pred >= (1 << Al))
747
4.43M
              pred = (1 << Al) - 1;
748
30.6M
            pred = -pred;
749
30.6M
          }
750
88.6M
          workspace[2] = (JCOEF)pred;
751
88.6M
        }
752
101M
        if (change_dc) {
753
          /* AC03 */
754
55.0M
          if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
755
55.0M
            num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
756
55.0M
            if (num >= 0) {
757
42.6M
              pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
758
42.6M
              if (Al > 0 && pred >= (1 << Al))
759
0
                pred = (1 << Al) - 1;
760
42.6M
            } else {
761
12.3M
              pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
762
12.3M
              if (Al > 0 && pred >= (1 << Al))
763
0
                pred = (1 << Al) - 1;
764
12.3M
              pred = -pred;
765
12.3M
            }
766
55.0M
            workspace[3] = (JCOEF)pred;
767
55.0M
          }
768
          /* AC12 */
769
55.0M
          if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
770
55.0M
            num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
771
55.0M
            if (num >= 0) {
772
35.9M
              pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
773
35.9M
              if (Al > 0 && pred >= (1 << Al))
774
0
                pred = (1 << Al) - 1;
775
35.9M
            } else {
776
19.0M
              pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
777
19.0M
              if (Al > 0 && pred >= (1 << Al))
778
0
                pred = (1 << Al) - 1;
779
19.0M
              pred = -pred;
780
19.0M
            }
781
55.0M
            workspace[10] = (JCOEF)pred;
782
55.0M
          }
783
          /* AC21 */
784
55.0M
          if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
785
55.0M
            num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
786
55.0M
            if (num >= 0) {
787
36.0M
              pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
788
36.0M
              if (Al > 0 && pred >= (1 << Al))
789
0
                pred = (1 << Al) - 1;
790
36.0M
            } else {
791
18.9M
              pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
792
18.9M
              if (Al > 0 && pred >= (1 << Al))
793
0
                pred = (1 << Al) - 1;
794
18.9M
              pred = -pred;
795
18.9M
            }
796
55.0M
            workspace[17] = (JCOEF)pred;
797
55.0M
          }
798
          /* AC30 */
799
55.0M
          if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
800
55.0M
            num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
801
55.0M
            if (num >= 0) {
802
40.5M
              pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
803
40.5M
              if (Al > 0 && pred >= (1 << Al))
804
0
                pred = (1 << Al) - 1;
805
40.5M
            } else {
806
14.4M
              pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
807
14.4M
              if (Al > 0 && pred >= (1 << Al))
808
0
                pred = (1 << Al) - 1;
809
14.4M
              pred = -pred;
810
14.4M
            }
811
55.0M
            workspace[24] = (JCOEF)pred;
812
55.0M
          }
813
          /* coef_bits[0] is non-negative.  Otherwise this function would not
814
           * be called.
815
           */
816
55.0M
          num = Q00 *
817
55.0M
                (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
818
55.0M
                 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
819
55.0M
                 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
820
55.0M
                 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
821
55.0M
                 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
822
55.0M
          if (num >= 0) {
823
34.4M
            pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
824
34.4M
          } else {
825
20.6M
            pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
826
20.6M
            pred = -pred;
827
20.6M
          }
828
55.0M
          workspace[0] = (JCOEF)pred;
829
55.0M
        }  /* change_dc */
830
831
        /* OK, do the IDCT */
832
#ifdef WITH_PROFILE
833
        cinfo->master->start = getTime();
834
#endif
835
101M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
836
101M
                        output_col);
837
#ifdef WITH_PROFILE
838
        cinfo->master->idct_elapsed += getTime() - cinfo->master->start;
839
        cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
840
#endif
841
        /* Advance for next column */
842
101M
        DC01 = DC02;  DC02 = DC03;  DC03 = DC04;  DC04 = DC05;
843
101M
        DC06 = DC07;  DC07 = DC08;  DC08 = DC09;  DC09 = DC10;
844
101M
        DC11 = DC12;  DC12 = DC13;  DC13 = DC14;  DC14 = DC15;
845
101M
        DC16 = DC17;  DC17 = DC18;  DC18 = DC19;  DC19 = DC20;
846
101M
        DC21 = DC22;  DC22 = DC23;  DC23 = DC24;  DC24 = DC25;
847
101M
        buffer_ptr++, prev_block_row++, next_block_row++,
848
101M
          prev_prev_block_row++, next_next_block_row++;
849
101M
        output_col += compptr->_DCT_scaled_size;
850
101M
      }
851
18.0M
      output_ptr += compptr->_DCT_scaled_size;
852
18.0M
    }
853
15.2M
  }
854
855
7.51M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
856
7.49M
    return JPEG_ROW_COMPLETED;
857
24.7k
  return JPEG_SCAN_COMPLETED;
858
7.51M
}
jdcoefct-8.c:decompress_smooth_data
Line
Count
Source
474
6.79M
{
475
6.79M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
476
6.79M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
477
6.79M
  JDIMENSION block_num, last_block_column;
478
6.79M
  int ci, block_row, block_rows, access_rows, image_block_row,
479
6.79M
    image_block_rows;
480
6.79M
  JBLOCKARRAY buffer;
481
6.79M
  JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
482
6.79M
  JBLOCKROW next_block_row, next_next_block_row;
483
6.79M
  _JSAMPARRAY output_ptr;
484
6.79M
  JDIMENSION output_col;
485
6.79M
  jpeg_component_info *compptr;
486
6.79M
  _inverse_DCT_method_ptr inverse_DCT;
487
6.79M
  boolean change_dc;
488
6.79M
  JCOEF *workspace;
489
6.79M
  int *coef_bits;
490
6.79M
  JQUANT_TBL *quanttbl;
491
6.79M
  JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
492
6.79M
  int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
493
6.79M
      DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
494
6.79M
      DC25;
495
6.79M
  int Al, pred;
496
497
  /* Keep a local variable to avoid looking it up more than once */
498
6.79M
  workspace = coef->workspace;
499
500
  /* Force some input to be done if we are getting ahead of the input. */
501
11.1M
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
502
11.1M
         !cinfo->inputctl->eoi_reached) {
503
9.09M
    if (cinfo->input_scan_number == cinfo->output_scan_number) {
504
      /* If input is working on current scan, we ordinarily want it to
505
       * have completed the current row.  But if input scan is DC,
506
       * we want it to keep two rows ahead so that next two block rows' DC
507
       * values are up to date.
508
       */
509
9.09M
      JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0;
510
9.09M
      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
511
4.73M
        break;
512
9.09M
    }
513
4.35M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
514
19.2k
      return JPEG_SUSPENDED;
515
4.35M
  }
516
517
  /* OK, output from the virtual arrays. */
518
21.0M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
519
14.2M
       ci++, compptr++) {
520
    /* Don't bother to IDCT an uninteresting component. */
521
14.2M
    if (!compptr->component_needed)
522
139k
      continue;
523
    /* Count non-dummy DCT block rows in this iMCU row. */
524
14.1M
    if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
525
14.0M
      block_rows = compptr->v_samp_factor;
526
14.0M
      access_rows = block_rows * 3; /* this and next two iMCU rows */
527
14.0M
    } else if (cinfo->output_iMCU_row < last_iMCU_row) {
528
37.4k
      block_rows = compptr->v_samp_factor;
529
37.4k
      access_rows = block_rows * 2; /* this and next iMCU row */
530
48.2k
    } else {
531
      /* NB: can't use last_row_height here; it is input-side-dependent! */
532
48.2k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
533
48.2k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
534
48.2k
      access_rows = block_rows; /* this iMCU row only */
535
48.2k
    }
536
    /* Align the virtual buffer for this component. */
537
14.1M
    if (cinfo->output_iMCU_row > 1) {
538
14.0M
      access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
539
14.0M
      buffer = (*cinfo->mem->access_virt_barray)
540
14.0M
        ((j_common_ptr)cinfo, coef->whole_image[ci],
541
14.0M
         (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
542
14.0M
         (JDIMENSION)access_rows, FALSE);
543
14.0M
      buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
544
14.0M
    } else if (cinfo->output_iMCU_row > 0) {
545
39.1k
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
546
39.1k
      buffer = (*cinfo->mem->access_virt_barray)
547
39.1k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
548
39.1k
         (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
549
39.1k
         (JDIMENSION)access_rows, FALSE);
550
39.1k
      buffer += compptr->v_samp_factor; /* point to current iMCU row */
551
39.1k
    } else {
552
37.8k
      buffer = (*cinfo->mem->access_virt_barray)
553
37.8k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
554
37.8k
         (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
555
37.8k
    }
556
    /* Fetch component-dependent info.
557
     * If the current scan is incomplete, then we use the component-dependent
558
     * info from the previous scan.
559
     */
560
14.1M
    if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
561
8.12M
      coef_bits =
562
8.12M
        coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
563
6.01M
    else
564
6.01M
      coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
565
566
    /* We only do DC interpolation if no AC coefficient data is available. */
567
14.1M
    change_dc =
568
14.1M
      coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
569
9.05M
      coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
570
7.91M
      coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
571
572
14.1M
    quanttbl = compptr->quant_table;
573
14.1M
    Q00 = quanttbl->quantval[0];
574
14.1M
    Q01 = quanttbl->quantval[Q01_POS];
575
14.1M
    Q10 = quanttbl->quantval[Q10_POS];
576
14.1M
    Q20 = quanttbl->quantval[Q20_POS];
577
14.1M
    Q11 = quanttbl->quantval[Q11_POS];
578
14.1M
    Q02 = quanttbl->quantval[Q02_POS];
579
14.1M
    if (change_dc) {
580
7.74M
      Q03 = quanttbl->quantval[Q03_POS];
581
7.74M
      Q12 = quanttbl->quantval[Q12_POS];
582
7.74M
      Q21 = quanttbl->quantval[Q21_POS];
583
7.74M
      Q30 = quanttbl->quantval[Q30_POS];
584
7.74M
    }
585
14.1M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
586
14.1M
    output_ptr = output_buf[ci];
587
    /* Loop over all DCT blocks to be processed. */
588
14.1M
    image_block_rows = block_rows * cinfo->total_iMCU_rows;
589
30.4M
    for (block_row = 0; block_row < block_rows; block_row++) {
590
16.2M
      image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
591
16.2M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
592
593
16.2M
      if (image_block_row > 0)
594
16.2M
        prev_block_row =
595
16.2M
          buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
596
37.8k
      else
597
37.8k
        prev_block_row = buffer_ptr;
598
599
16.2M
      if (image_block_row > 1)
600
16.1M
        prev_prev_block_row =
601
16.1M
          buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
602
84.7k
      else
603
84.7k
        prev_prev_block_row = prev_block_row;
604
605
16.2M
      if (image_block_row < image_block_rows - 1)
606
16.2M
        next_block_row =
607
16.2M
          buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
608
48.2k
      else
609
48.2k
        next_block_row = buffer_ptr;
610
611
16.2M
      if (image_block_row < image_block_rows - 2)
612
16.2M
        next_next_block_row =
613
16.2M
          buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
614
82.1k
      else
615
82.1k
        next_next_block_row = next_block_row;
616
617
      /* We fetch the surrounding DC values using a sliding-register approach.
618
       * Initialize all 25 here so as to do the right thing on narrow pics.
619
       */
620
16.2M
      DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
621
16.2M
      DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
622
16.2M
      DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
623
16.2M
      DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
624
16.2M
      DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
625
16.2M
      output_col = 0;
626
16.2M
      last_block_column = compptr->width_in_blocks - 1;
627
16.2M
      for (block_num = cinfo->master->first_MCU_col[ci];
628
100M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
629
        /* Fetch current DCT block into workspace so we can modify it. */
630
83.7M
        jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
631
        /* Update DC values */
632
83.7M
        if (block_num == cinfo->master->first_MCU_col[ci] &&
633
16.2M
            block_num < last_block_column) {
634
10.2M
          DC04 = DC05 = (int)prev_prev_block_row[1][0];
635
10.2M
          DC09 = DC10 = (int)prev_block_row[1][0];
636
10.2M
          DC14 = DC15 = (int)buffer_ptr[1][0];
637
10.2M
          DC19 = DC20 = (int)next_block_row[1][0];
638
10.2M
          DC24 = DC25 = (int)next_next_block_row[1][0];
639
10.2M
        }
640
83.7M
        if (block_num + 1 < last_block_column) {
641
57.1M
          DC05 = (int)prev_prev_block_row[2][0];
642
57.1M
          DC10 = (int)prev_block_row[2][0];
643
57.1M
          DC15 = (int)buffer_ptr[2][0];
644
57.1M
          DC20 = (int)next_block_row[2][0];
645
57.1M
          DC25 = (int)next_next_block_row[2][0];
646
57.1M
        }
647
        /* If DC interpolation is enabled, compute coefficient estimates using
648
         * a Gaussian-like kernel, keeping the averages of the DC values.
649
         *
650
         * If DC interpolation is disabled, compute coefficient estimates using
651
         * an algorithm similar to the one described in Section K.8 of the JPEG
652
         * standard, except applied to a 5x5 window rather than a 3x3 window.
653
         *
654
         * An estimate is applied only if the coefficient is still zero and is
655
         * not known to be fully accurate.
656
         */
657
        /* AC01 */
658
83.7M
        if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
659
71.6M
          num = Q00 * (change_dc ?
660
45.0M
                (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
661
45.0M
                 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
662
45.0M
                 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
663
45.0M
                 DC21 - DC22 + DC24 + DC25) :
664
71.6M
                (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
665
71.6M
          if (num >= 0) {
666
53.2M
            pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
667
53.2M
            if (Al > 0 && pred >= (1 << Al))
668
4.40M
              pred = (1 << Al) - 1;
669
53.2M
          } else {
670
18.3M
            pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
671
18.3M
            if (Al > 0 && pred >= (1 << Al))
672
3.41M
              pred = (1 << Al) - 1;
673
18.3M
            pred = -pred;
674
18.3M
          }
675
71.6M
          workspace[1] = (JCOEF)pred;
676
71.6M
        }
677
        /* AC10 */
678
83.7M
        if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
679
71.8M
          num = Q00 * (change_dc ?
680
45.0M
                (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
681
45.0M
                 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
682
45.0M
                 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
683
45.0M
                 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
684
71.8M
                (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
685
71.8M
          if (num >= 0) {
686
50.2M
            pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
687
50.2M
            if (Al > 0 && pred >= (1 << Al))
688
6.56M
              pred = (1 << Al) - 1;
689
50.2M
          } else {
690
21.5M
            pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
691
21.5M
            if (Al > 0 && pred >= (1 << Al))
692
5.89M
              pred = (1 << Al) - 1;
693
21.5M
            pred = -pred;
694
21.5M
          }
695
71.8M
          workspace[8] = (JCOEF)pred;
696
71.8M
        }
697
        /* AC20 */
698
83.7M
        if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
699
72.3M
          num = Q00 * (change_dc ?
700
45.0M
                (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
701
45.0M
                 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
702
72.3M
                (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
703
72.3M
          if (num >= 0) {
704
47.2M
            pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
705
47.2M
            if (Al > 0 && pred >= (1 << Al))
706
5.85M
              pred = (1 << Al) - 1;
707
47.2M
          } else {
708
25.0M
            pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
709
25.0M
            if (Al > 0 && pred >= (1 << Al))
710
5.96M
              pred = (1 << Al) - 1;
711
25.0M
            pred = -pred;
712
25.0M
          }
713
72.3M
          workspace[16] = (JCOEF)pred;
714
72.3M
        }
715
        /* AC11 */
716
83.7M
        if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
717
71.9M
          num = Q00 * (change_dc ?
718
45.0M
                (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
719
45.0M
                 9 * DC19 + DC21 - DC25) :
720
71.9M
                (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
721
26.9M
                 DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
722
71.9M
          if (num >= 0) {
723
55.8M
            pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
724
55.8M
            if (Al > 0 && pred >= (1 << Al))
725
2.93M
              pred = (1 << Al) - 1;
726
55.8M
          } else {
727
16.1M
            pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
728
16.1M
            if (Al > 0 && pred >= (1 << Al))
729
2.98M
              pred = (1 << Al) - 1;
730
16.1M
            pred = -pred;
731
16.1M
          }
732
71.9M
          workspace[9] = (JCOEF)pred;
733
71.9M
        }
734
        /* AC02 */
735
83.7M
        if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
736
72.0M
          num = Q00 * (change_dc ?
737
45.0M
                (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
738
45.0M
                 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
739
72.0M
                (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
740
72.0M
          if (num >= 0) {
741
47.7M
            pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
742
47.7M
            if (Al > 0 && pred >= (1 << Al))
743
3.30M
              pred = (1 << Al) - 1;
744
47.7M
          } else {
745
24.2M
            pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
746
24.2M
            if (Al > 0 && pred >= (1 << Al))
747
3.30M
              pred = (1 << Al) - 1;
748
24.2M
            pred = -pred;
749
24.2M
          }
750
72.0M
          workspace[2] = (JCOEF)pred;
751
72.0M
        }
752
83.7M
        if (change_dc) {
753
          /* AC03 */
754
45.0M
          if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
755
45.0M
            num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
756
45.0M
            if (num >= 0) {
757
35.5M
              pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
758
35.5M
              if (Al > 0 && pred >= (1 << Al))
759
0
                pred = (1 << Al) - 1;
760
35.5M
            } else {
761
9.42M
              pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
762
9.42M
              if (Al > 0 && pred >= (1 << Al))
763
0
                pred = (1 << Al) - 1;
764
9.42M
              pred = -pred;
765
9.42M
            }
766
45.0M
            workspace[3] = (JCOEF)pred;
767
45.0M
          }
768
          /* AC12 */
769
45.0M
          if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
770
45.0M
            num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
771
45.0M
            if (num >= 0) {
772
29.9M
              pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
773
29.9M
              if (Al > 0 && pred >= (1 << Al))
774
0
                pred = (1 << Al) - 1;
775
29.9M
            } else {
776
15.0M
              pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
777
15.0M
              if (Al > 0 && pred >= (1 << Al))
778
0
                pred = (1 << Al) - 1;
779
15.0M
              pred = -pred;
780
15.0M
            }
781
45.0M
            workspace[10] = (JCOEF)pred;
782
45.0M
          }
783
          /* AC21 */
784
45.0M
          if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
785
45.0M
            num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
786
45.0M
            if (num >= 0) {
787
29.9M
              pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
788
29.9M
              if (Al > 0 && pred >= (1 << Al))
789
0
                pred = (1 << Al) - 1;
790
29.9M
            } else {
791
15.0M
              pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
792
15.0M
              if (Al > 0 && pred >= (1 << Al))
793
0
                pred = (1 << Al) - 1;
794
15.0M
              pred = -pred;
795
15.0M
            }
796
45.0M
            workspace[17] = (JCOEF)pred;
797
45.0M
          }
798
          /* AC30 */
799
45.0M
          if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
800
45.0M
            num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
801
45.0M
            if (num >= 0) {
802
33.4M
              pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
803
33.4M
              if (Al > 0 && pred >= (1 << Al))
804
0
                pred = (1 << Al) - 1;
805
33.4M
            } else {
806
11.5M
              pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
807
11.5M
              if (Al > 0 && pred >= (1 << Al))
808
0
                pred = (1 << Al) - 1;
809
11.5M
              pred = -pred;
810
11.5M
            }
811
45.0M
            workspace[24] = (JCOEF)pred;
812
45.0M
          }
813
          /* coef_bits[0] is non-negative.  Otherwise this function would not
814
           * be called.
815
           */
816
45.0M
          num = Q00 *
817
45.0M
                (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
818
45.0M
                 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
819
45.0M
                 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
820
45.0M
                 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
821
45.0M
                 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
822
45.0M
          if (num >= 0) {
823
28.8M
            pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
824
28.8M
          } else {
825
16.1M
            pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
826
16.1M
            pred = -pred;
827
16.1M
          }
828
45.0M
          workspace[0] = (JCOEF)pred;
829
45.0M
        }  /* change_dc */
830
831
        /* OK, do the IDCT */
832
#ifdef WITH_PROFILE
833
        cinfo->master->start = getTime();
834
#endif
835
83.7M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
836
83.7M
                        output_col);
837
#ifdef WITH_PROFILE
838
        cinfo->master->idct_elapsed += getTime() - cinfo->master->start;
839
        cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
840
#endif
841
        /* Advance for next column */
842
83.7M
        DC01 = DC02;  DC02 = DC03;  DC03 = DC04;  DC04 = DC05;
843
83.7M
        DC06 = DC07;  DC07 = DC08;  DC08 = DC09;  DC09 = DC10;
844
83.7M
        DC11 = DC12;  DC12 = DC13;  DC13 = DC14;  DC14 = DC15;
845
83.7M
        DC16 = DC17;  DC17 = DC18;  DC18 = DC19;  DC19 = DC20;
846
83.7M
        DC21 = DC22;  DC22 = DC23;  DC23 = DC24;  DC24 = DC25;
847
83.7M
        buffer_ptr++, prev_block_row++, next_block_row++,
848
83.7M
          prev_prev_block_row++, next_next_block_row++;
849
83.7M
        output_col += compptr->_DCT_scaled_size;
850
83.7M
      }
851
16.2M
      output_ptr += compptr->_DCT_scaled_size;
852
16.2M
    }
853
14.1M
  }
854
855
6.77M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
856
6.75M
    return JPEG_ROW_COMPLETED;
857
21.9k
  return JPEG_SCAN_COMPLETED;
858
6.77M
}
jdcoefct-12.c:decompress_smooth_data
Line
Count
Source
474
741k
{
475
741k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
476
741k
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
477
741k
  JDIMENSION block_num, last_block_column;
478
741k
  int ci, block_row, block_rows, access_rows, image_block_row,
479
741k
    image_block_rows;
480
741k
  JBLOCKARRAY buffer;
481
741k
  JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
482
741k
  JBLOCKROW next_block_row, next_next_block_row;
483
741k
  _JSAMPARRAY output_ptr;
484
741k
  JDIMENSION output_col;
485
741k
  jpeg_component_info *compptr;
486
741k
  _inverse_DCT_method_ptr inverse_DCT;
487
741k
  boolean change_dc;
488
741k
  JCOEF *workspace;
489
741k
  int *coef_bits;
490
741k
  JQUANT_TBL *quanttbl;
491
741k
  JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
492
741k
  int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
493
741k
      DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
494
741k
      DC25;
495
741k
  int Al, pred;
496
497
  /* Keep a local variable to avoid looking it up more than once */
498
741k
  workspace = coef->workspace;
499
500
  /* Force some input to be done if we are getting ahead of the input. */
501
741k
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
502
741k
         !cinfo->inputctl->eoi_reached) {
503
0
    if (cinfo->input_scan_number == cinfo->output_scan_number) {
504
      /* If input is working on current scan, we ordinarily want it to
505
       * have completed the current row.  But if input scan is DC,
506
       * we want it to keep two rows ahead so that next two block rows' DC
507
       * values are up to date.
508
       */
509
0
      JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0;
510
0
      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
511
0
        break;
512
0
    }
513
0
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
514
0
      return JPEG_SUSPENDED;
515
0
  }
516
517
  /* OK, output from the virtual arrays. */
518
2.03M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
519
1.29M
       ci++, compptr++) {
520
    /* Don't bother to IDCT an uninteresting component. */
521
1.29M
    if (!compptr->component_needed)
522
152k
      continue;
523
    /* Count non-dummy DCT block rows in this iMCU row. */
524
1.14M
    if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
525
1.13M
      block_rows = compptr->v_samp_factor;
526
1.13M
      access_rows = block_rows * 3; /* this and next two iMCU rows */
527
1.13M
    } else if (cinfo->output_iMCU_row < last_iMCU_row) {
528
3.54k
      block_rows = compptr->v_samp_factor;
529
3.54k
      access_rows = block_rows * 2; /* this and next iMCU row */
530
4.03k
    } else {
531
      /* NB: can't use last_row_height here; it is input-side-dependent! */
532
4.03k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
533
4.03k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
534
4.03k
      access_rows = block_rows; /* this iMCU row only */
535
4.03k
    }
536
    /* Align the virtual buffer for this component. */
537
1.14M
    if (cinfo->output_iMCU_row > 1) {
538
1.13M
      access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
539
1.13M
      buffer = (*cinfo->mem->access_virt_barray)
540
1.13M
        ((j_common_ptr)cinfo, coef->whole_image[ci],
541
1.13M
         (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
542
1.13M
         (JDIMENSION)access_rows, FALSE);
543
1.13M
      buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
544
1.13M
    } else if (cinfo->output_iMCU_row > 0) {
545
4.12k
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
546
4.12k
      buffer = (*cinfo->mem->access_virt_barray)
547
4.12k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
548
4.12k
         (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
549
4.12k
         (JDIMENSION)access_rows, FALSE);
550
4.12k
      buffer += compptr->v_samp_factor; /* point to current iMCU row */
551
4.28k
    } else {
552
4.28k
      buffer = (*cinfo->mem->access_virt_barray)
553
4.28k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
554
4.28k
         (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
555
4.28k
    }
556
    /* Fetch component-dependent info.
557
     * If the current scan is incomplete, then we use the component-dependent
558
     * info from the previous scan.
559
     */
560
1.14M
    if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
561
499k
      coef_bits =
562
499k
        coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
563
646k
    else
564
646k
      coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
565
566
    /* We only do DC interpolation if no AC coefficient data is available. */
567
1.14M
    change_dc =
568
1.14M
      coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
569
861k
      coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
570
781k
      coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
571
572
1.14M
    quanttbl = compptr->quant_table;
573
1.14M
    Q00 = quanttbl->quantval[0];
574
1.14M
    Q01 = quanttbl->quantval[Q01_POS];
575
1.14M
    Q10 = quanttbl->quantval[Q10_POS];
576
1.14M
    Q20 = quanttbl->quantval[Q20_POS];
577
1.14M
    Q11 = quanttbl->quantval[Q11_POS];
578
1.14M
    Q02 = quanttbl->quantval[Q02_POS];
579
1.14M
    if (change_dc) {
580
763k
      Q03 = quanttbl->quantval[Q03_POS];
581
763k
      Q12 = quanttbl->quantval[Q12_POS];
582
763k
      Q21 = quanttbl->quantval[Q21_POS];
583
763k
      Q30 = quanttbl->quantval[Q30_POS];
584
763k
    }
585
1.14M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
586
1.14M
    output_ptr = output_buf[ci];
587
    /* Loop over all DCT blocks to be processed. */
588
1.14M
    image_block_rows = block_rows * cinfo->total_iMCU_rows;
589
2.87M
    for (block_row = 0; block_row < block_rows; block_row++) {
590
1.73M
      image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
591
1.73M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
592
593
1.73M
      if (image_block_row > 0)
594
1.72M
        prev_block_row =
595
1.72M
          buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
596
4.28k
      else
597
4.28k
        prev_block_row = buffer_ptr;
598
599
1.73M
      if (image_block_row > 1)
600
1.72M
        prev_prev_block_row =
601
1.72M
          buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
602
8.30k
      else
603
8.30k
        prev_prev_block_row = prev_block_row;
604
605
1.73M
      if (image_block_row < image_block_rows - 1)
606
1.73M
        next_block_row =
607
1.73M
          buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
608
4.03k
      else
609
4.03k
        next_block_row = buffer_ptr;
610
611
1.73M
      if (image_block_row < image_block_rows - 2)
612
1.72M
        next_next_block_row =
613
1.72M
          buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
614
6.83k
      else
615
6.83k
        next_next_block_row = next_block_row;
616
617
      /* We fetch the surrounding DC values using a sliding-register approach.
618
       * Initialize all 25 here so as to do the right thing on narrow pics.
619
       */
620
1.73M
      DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
621
1.73M
      DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
622
1.73M
      DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
623
1.73M
      DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
624
1.73M
      DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
625
1.73M
      output_col = 0;
626
1.73M
      last_block_column = compptr->width_in_blocks - 1;
627
1.73M
      for (block_num = cinfo->master->first_MCU_col[ci];
628
19.1M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
629
        /* Fetch current DCT block into workspace so we can modify it. */
630
17.3M
        jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
631
        /* Update DC values */
632
17.3M
        if (block_num == cinfo->master->first_MCU_col[ci] &&
633
1.73M
            block_num < last_block_column) {
634
892k
          DC04 = DC05 = (int)prev_prev_block_row[1][0];
635
892k
          DC09 = DC10 = (int)prev_block_row[1][0];
636
892k
          DC14 = DC15 = (int)buffer_ptr[1][0];
637
892k
          DC19 = DC20 = (int)next_block_row[1][0];
638
892k
          DC24 = DC25 = (int)next_next_block_row[1][0];
639
892k
        }
640
17.3M
        if (block_num + 1 < last_block_column) {
641
14.7M
          DC05 = (int)prev_prev_block_row[2][0];
642
14.7M
          DC10 = (int)prev_block_row[2][0];
643
14.7M
          DC15 = (int)buffer_ptr[2][0];
644
14.7M
          DC20 = (int)next_block_row[2][0];
645
14.7M
          DC25 = (int)next_next_block_row[2][0];
646
14.7M
        }
647
        /* If DC interpolation is enabled, compute coefficient estimates using
648
         * a Gaussian-like kernel, keeping the averages of the DC values.
649
         *
650
         * If DC interpolation is disabled, compute coefficient estimates using
651
         * an algorithm similar to the one described in Section K.8 of the JPEG
652
         * standard, except applied to a 5x5 window rather than a 3x3 window.
653
         *
654
         * An estimate is applied only if the coefficient is still zero and is
655
         * not known to be fully accurate.
656
         */
657
        /* AC01 */
658
17.3M
        if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
659
16.3M
          num = Q00 * (change_dc ?
660
9.99M
                (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
661
9.99M
                 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
662
9.99M
                 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
663
9.99M
                 DC21 - DC22 + DC24 + DC25) :
664
16.3M
                (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
665
16.3M
          if (num >= 0) {
666
11.0M
            pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
667
11.0M
            if (Al > 0 && pred >= (1 << Al))
668
1.15M
              pred = (1 << Al) - 1;
669
11.0M
          } else {
670
5.31M
            pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
671
5.31M
            if (Al > 0 && pred >= (1 << Al))
672
1.16M
              pred = (1 << Al) - 1;
673
5.31M
            pred = -pred;
674
5.31M
          }
675
16.3M
          workspace[1] = (JCOEF)pred;
676
16.3M
        }
677
        /* AC10 */
678
17.3M
        if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
679
16.5M
          num = Q00 * (change_dc ?
680
9.99M
                (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
681
9.99M
                 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
682
9.99M
                 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
683
9.99M
                 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
684
16.5M
                (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
685
16.5M
          if (num >= 0) {
686
11.2M
            pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
687
11.2M
            if (Al > 0 && pred >= (1 << Al))
688
1.99M
              pred = (1 << Al) - 1;
689
11.2M
          } else {
690
5.29M
            pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
691
5.29M
            if (Al > 0 && pred >= (1 << Al))
692
1.52M
              pred = (1 << Al) - 1;
693
5.29M
            pred = -pred;
694
5.29M
          }
695
16.5M
          workspace[8] = (JCOEF)pred;
696
16.5M
        }
697
        /* AC20 */
698
17.3M
        if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
699
16.3M
          num = Q00 * (change_dc ?
700
9.99M
                (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
701
9.99M
                 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
702
16.3M
                (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
703
16.3M
          if (num >= 0) {
704
9.97M
            pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
705
9.97M
            if (Al > 0 && pred >= (1 << Al))
706
1.76M
              pred = (1 << Al) - 1;
707
9.97M
          } else {
708
6.40M
            pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
709
6.40M
            if (Al > 0 && pred >= (1 << Al))
710
1.81M
              pred = (1 << Al) - 1;
711
6.40M
            pred = -pred;
712
6.40M
          }
713
16.3M
          workspace[16] = (JCOEF)pred;
714
16.3M
        }
715
        /* AC11 */
716
17.3M
        if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
717
16.4M
          num = Q00 * (change_dc ?
718
9.99M
                (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
719
9.99M
                 9 * DC19 + DC21 - DC25) :
720
16.4M
                (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
721
6.47M
                 DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
722
16.4M
          if (num >= 0) {
723
12.1M
            pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
724
12.1M
            if (Al > 0 && pred >= (1 << Al))
725
729k
              pred = (1 << Al) - 1;
726
12.1M
          } else {
727
4.31M
            pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
728
4.31M
            if (Al > 0 && pred >= (1 << Al))
729
716k
              pred = (1 << Al) - 1;
730
4.31M
            pred = -pred;
731
4.31M
          }
732
16.4M
          workspace[9] = (JCOEF)pred;
733
16.4M
        }
734
        /* AC02 */
735
17.3M
        if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
736
16.5M
          num = Q00 * (change_dc ?
737
9.99M
                (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
738
9.99M
                 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
739
16.5M
                (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
740
16.5M
          if (num >= 0) {
741
10.2M
            pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
742
10.2M
            if (Al > 0 && pred >= (1 << Al))
743
1.13M
              pred = (1 << Al) - 1;
744
10.2M
          } else {
745
6.38M
            pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
746
6.38M
            if (Al > 0 && pred >= (1 << Al))
747
1.13M
              pred = (1 << Al) - 1;
748
6.38M
            pred = -pred;
749
6.38M
          }
750
16.5M
          workspace[2] = (JCOEF)pred;
751
16.5M
        }
752
17.3M
        if (change_dc) {
753
          /* AC03 */
754
9.99M
          if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
755
9.99M
            num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
756
9.99M
            if (num >= 0) {
757
7.10M
              pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
758
7.10M
              if (Al > 0 && pred >= (1 << Al))
759
0
                pred = (1 << Al) - 1;
760
7.10M
            } else {
761
2.88M
              pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
762
2.88M
              if (Al > 0 && pred >= (1 << Al))
763
0
                pred = (1 << Al) - 1;
764
2.88M
              pred = -pred;
765
2.88M
            }
766
9.99M
            workspace[3] = (JCOEF)pred;
767
9.99M
          }
768
          /* AC12 */
769
9.99M
          if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
770
9.99M
            num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
771
9.99M
            if (num >= 0) {
772
5.98M
              pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
773
5.98M
              if (Al > 0 && pred >= (1 << Al))
774
0
                pred = (1 << Al) - 1;
775
5.98M
            } else {
776
4.00M
              pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
777
4.00M
              if (Al > 0 && pred >= (1 << Al))
778
0
                pred = (1 << Al) - 1;
779
4.00M
              pred = -pred;
780
4.00M
            }
781
9.99M
            workspace[10] = (JCOEF)pred;
782
9.99M
          }
783
          /* AC21 */
784
9.99M
          if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
785
9.99M
            num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
786
9.99M
            if (num >= 0) {
787
6.05M
              pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
788
6.05M
              if (Al > 0 && pred >= (1 << Al))
789
0
                pred = (1 << Al) - 1;
790
6.05M
            } else {
791
3.93M
              pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
792
3.93M
              if (Al > 0 && pred >= (1 << Al))
793
0
                pred = (1 << Al) - 1;
794
3.93M
              pred = -pred;
795
3.93M
            }
796
9.99M
            workspace[17] = (JCOEF)pred;
797
9.99M
          }
798
          /* AC30 */
799
9.99M
          if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
800
9.99M
            num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
801
9.99M
            if (num >= 0) {
802
7.09M
              pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
803
7.09M
              if (Al > 0 && pred >= (1 << Al))
804
0
                pred = (1 << Al) - 1;
805
7.09M
            } else {
806
2.89M
              pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
807
2.89M
              if (Al > 0 && pred >= (1 << Al))
808
0
                pred = (1 << Al) - 1;
809
2.89M
              pred = -pred;
810
2.89M
            }
811
9.99M
            workspace[24] = (JCOEF)pred;
812
9.99M
          }
813
          /* coef_bits[0] is non-negative.  Otherwise this function would not
814
           * be called.
815
           */
816
9.99M
          num = Q00 *
817
9.99M
                (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
818
9.99M
                 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
819
9.99M
                 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
820
9.99M
                 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
821
9.99M
                 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
822
9.99M
          if (num >= 0) {
823
5.58M
            pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
824
5.58M
          } else {
825
4.40M
            pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
826
4.40M
            pred = -pred;
827
4.40M
          }
828
9.99M
          workspace[0] = (JCOEF)pred;
829
9.99M
        }  /* change_dc */
830
831
        /* OK, do the IDCT */
832
#ifdef WITH_PROFILE
833
        cinfo->master->start = getTime();
834
#endif
835
17.3M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
836
17.3M
                        output_col);
837
#ifdef WITH_PROFILE
838
        cinfo->master->idct_elapsed += getTime() - cinfo->master->start;
839
        cinfo->master->idct_mcoeffs += (double)DCTSIZE2 / 1000000.;
840
#endif
841
        /* Advance for next column */
842
17.3M
        DC01 = DC02;  DC02 = DC03;  DC03 = DC04;  DC04 = DC05;
843
17.3M
        DC06 = DC07;  DC07 = DC08;  DC08 = DC09;  DC09 = DC10;
844
17.3M
        DC11 = DC12;  DC12 = DC13;  DC13 = DC14;  DC14 = DC15;
845
17.3M
        DC16 = DC17;  DC17 = DC18;  DC18 = DC19;  DC19 = DC20;
846
17.3M
        DC21 = DC22;  DC22 = DC23;  DC23 = DC24;  DC24 = DC25;
847
17.3M
        buffer_ptr++, prev_block_row++, next_block_row++,
848
17.3M
          prev_prev_block_row++, next_next_block_row++;
849
17.3M
        output_col += compptr->_DCT_scaled_size;
850
17.3M
      }
851
1.73M
      output_ptr += compptr->_DCT_scaled_size;
852
1.73M
    }
853
1.14M
  }
854
855
741k
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
856
738k
    return JPEG_ROW_COMPLETED;
857
2.83k
  return JPEG_SCAN_COMPLETED;
858
741k
}
859
860
#endif /* BLOCK_SMOOTHING_SUPPORTED */
861
862
863
/*
864
 * Initialize coefficient buffer controller.
865
 */
866
867
GLOBAL(void)
868
_jinit_d_coef_controller(j_decompress_ptr cinfo, boolean need_full_buffer)
869
159k
{
870
159k
  my_coef_ptr coef;
871
872
159k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
873
20
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
874
875
159k
  coef = (my_coef_ptr)
876
159k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
877
159k
                                sizeof(my_coef_controller));
878
159k
  memset(coef, 0, sizeof(my_coef_controller));
879
159k
  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
880
159k
  coef->pub.start_input_pass = start_input_pass;
881
159k
  coef->pub.start_output_pass = start_output_pass;
882
159k
#ifdef BLOCK_SMOOTHING_SUPPORTED
883
159k
  coef->coef_bits_latch = NULL;
884
159k
#endif
885
886
  /* Create the coefficient buffer. */
887
159k
  if (need_full_buffer) {
888
131k
#ifdef D_MULTISCAN_FILES_SUPPORTED
889
    /* Allocate a full-image virtual array for each component, */
890
    /* padded to a multiple of samp_factor DCT blocks in each direction. */
891
    /* Note we ask for a pre-zeroed array. */
892
131k
    int ci, access_rows;
893
131k
    jpeg_component_info *compptr;
894
895
409k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
896
277k
         ci++, compptr++) {
897
277k
      access_rows = compptr->v_samp_factor;
898
277k
#ifdef BLOCK_SMOOTHING_SUPPORTED
899
      /* If block smoothing could be used, need a bigger window */
900
277k
      if (cinfo->progressive_mode)
901
151k
        access_rows *= 5;
902
277k
#endif
903
277k
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
904
277k
        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
905
277k
         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
906
277k
                               (long)compptr->h_samp_factor),
907
277k
         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
908
277k
                               (long)compptr->v_samp_factor),
909
277k
         (JDIMENSION)access_rows);
910
277k
    }
911
131k
    coef->pub.consume_data = consume_data;
912
131k
    coef->pub._decompress_data = decompress_data;
913
131k
    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
914
#else
915
    ERREXIT(cinfo, JERR_NOT_COMPILED);
916
#endif
917
131k
  } else {
918
    /* We only need a single-MCU buffer. */
919
27.9k
    JBLOCKROW buffer;
920
27.9k
    int i;
921
922
27.9k
    buffer = (JBLOCKROW)
923
27.9k
      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
924
27.9k
                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
925
307k
    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
926
279k
      coef->MCU_buffer[i] = buffer + i;
927
279k
    }
928
27.9k
    coef->pub.consume_data = dummy_consume_data;
929
27.9k
    coef->pub._decompress_data = decompress_onepass;
930
27.9k
    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
931
27.9k
  }
932
933
  /* Allocate the workspace buffer */
934
159k
  coef->workspace = (JCOEF *)
935
159k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
936
159k
                                sizeof(JCOEF) * DCTSIZE2);
937
159k
}
jinit_d_coef_controller
Line
Count
Source
869
127k
{
870
127k
  my_coef_ptr coef;
871
872
127k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
873
20
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
874
875
127k
  coef = (my_coef_ptr)
876
127k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
877
127k
                                sizeof(my_coef_controller));
878
127k
  memset(coef, 0, sizeof(my_coef_controller));
879
127k
  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
880
127k
  coef->pub.start_input_pass = start_input_pass;
881
127k
  coef->pub.start_output_pass = start_output_pass;
882
127k
#ifdef BLOCK_SMOOTHING_SUPPORTED
883
127k
  coef->coef_bits_latch = NULL;
884
127k
#endif
885
886
  /* Create the coefficient buffer. */
887
127k
  if (need_full_buffer) {
888
104k
#ifdef D_MULTISCAN_FILES_SUPPORTED
889
    /* Allocate a full-image virtual array for each component, */
890
    /* padded to a multiple of samp_factor DCT blocks in each direction. */
891
    /* Note we ask for a pre-zeroed array. */
892
104k
    int ci, access_rows;
893
104k
    jpeg_component_info *compptr;
894
895
327k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
896
223k
         ci++, compptr++) {
897
223k
      access_rows = compptr->v_samp_factor;
898
223k
#ifdef BLOCK_SMOOTHING_SUPPORTED
899
      /* If block smoothing could be used, need a bigger window */
900
223k
      if (cinfo->progressive_mode)
901
124k
        access_rows *= 5;
902
223k
#endif
903
223k
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
904
223k
        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
905
223k
         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
906
223k
                               (long)compptr->h_samp_factor),
907
223k
         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
908
223k
                               (long)compptr->v_samp_factor),
909
223k
         (JDIMENSION)access_rows);
910
223k
    }
911
104k
    coef->pub.consume_data = consume_data;
912
104k
    coef->pub._decompress_data = decompress_data;
913
104k
    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
914
#else
915
    ERREXIT(cinfo, JERR_NOT_COMPILED);
916
#endif
917
104k
  } else {
918
    /* We only need a single-MCU buffer. */
919
22.4k
    JBLOCKROW buffer;
920
22.4k
    int i;
921
922
22.4k
    buffer = (JBLOCKROW)
923
22.4k
      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
924
22.4k
                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
925
246k
    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
926
224k
      coef->MCU_buffer[i] = buffer + i;
927
224k
    }
928
22.4k
    coef->pub.consume_data = dummy_consume_data;
929
22.4k
    coef->pub._decompress_data = decompress_onepass;
930
22.4k
    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
931
22.4k
  }
932
933
  /* Allocate the workspace buffer */
934
127k
  coef->workspace = (JCOEF *)
935
127k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
936
127k
                                sizeof(JCOEF) * DCTSIZE2);
937
127k
}
j12init_d_coef_controller
Line
Count
Source
869
32.4k
{
870
32.4k
  my_coef_ptr coef;
871
872
32.4k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
873
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
874
875
32.4k
  coef = (my_coef_ptr)
876
32.4k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
877
32.4k
                                sizeof(my_coef_controller));
878
32.4k
  memset(coef, 0, sizeof(my_coef_controller));
879
32.4k
  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
880
32.4k
  coef->pub.start_input_pass = start_input_pass;
881
32.4k
  coef->pub.start_output_pass = start_output_pass;
882
32.4k
#ifdef BLOCK_SMOOTHING_SUPPORTED
883
32.4k
  coef->coef_bits_latch = NULL;
884
32.4k
#endif
885
886
  /* Create the coefficient buffer. */
887
32.4k
  if (need_full_buffer) {
888
26.9k
#ifdef D_MULTISCAN_FILES_SUPPORTED
889
    /* Allocate a full-image virtual array for each component, */
890
    /* padded to a multiple of samp_factor DCT blocks in each direction. */
891
    /* Note we ask for a pre-zeroed array. */
892
26.9k
    int ci, access_rows;
893
26.9k
    jpeg_component_info *compptr;
894
895
81.8k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
896
54.8k
         ci++, compptr++) {
897
54.8k
      access_rows = compptr->v_samp_factor;
898
54.8k
#ifdef BLOCK_SMOOTHING_SUPPORTED
899
      /* If block smoothing could be used, need a bigger window */
900
54.8k
      if (cinfo->progressive_mode)
901
27.8k
        access_rows *= 5;
902
54.8k
#endif
903
54.8k
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
904
54.8k
        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
905
54.8k
         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
906
54.8k
                               (long)compptr->h_samp_factor),
907
54.8k
         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
908
54.8k
                               (long)compptr->v_samp_factor),
909
54.8k
         (JDIMENSION)access_rows);
910
54.8k
    }
911
26.9k
    coef->pub.consume_data = consume_data;
912
26.9k
    coef->pub._decompress_data = decompress_data;
913
26.9k
    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
914
#else
915
    ERREXIT(cinfo, JERR_NOT_COMPILED);
916
#endif
917
26.9k
  } else {
918
    /* We only need a single-MCU buffer. */
919
5.51k
    JBLOCKROW buffer;
920
5.51k
    int i;
921
922
5.51k
    buffer = (JBLOCKROW)
923
5.51k
      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
924
5.51k
                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
925
60.6k
    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
926
55.1k
      coef->MCU_buffer[i] = buffer + i;
927
55.1k
    }
928
5.51k
    coef->pub.consume_data = dummy_consume_data;
929
5.51k
    coef->pub._decompress_data = decompress_onepass;
930
5.51k
    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
931
5.51k
  }
932
933
  /* Allocate the workspace buffer */
934
32.4k
  coef->workspace = (JCOEF *)
935
32.4k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
936
32.4k
                                sizeof(JCOEF) * DCTSIZE2);
937
32.4k
}