Coverage Report

Created: 2026-09-03 07:18

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
315k
{
51
315k
  cinfo->input_iMCU_row = 0;
52
315k
  start_iMCU_row(cinfo);
53
315k
}
jdcoefct-8.c:start_input_pass
Line
Count
Source
50
276k
{
51
276k
  cinfo->input_iMCU_row = 0;
52
276k
  start_iMCU_row(cinfo);
53
276k
}
jdcoefct-12.c:start_input_pass
Line
Count
Source
50
38.6k
{
51
38.6k
  cinfo->input_iMCU_row = 0;
52
38.6k
  start_iMCU_row(cinfo);
53
38.6k
}
54
55
56
/*
57
 * Initialize for an output processing pass.
58
 */
59
60
METHODDEF(void)
61
start_output_pass(j_decompress_ptr cinfo)
62
99.7k
{
63
99.7k
#ifdef BLOCK_SMOOTHING_SUPPORTED
64
99.7k
  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
99.7k
  if (coef->pub.coef_arrays != NULL) {
68
77.5k
    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
69
30.3k
      coef->pub._decompress_data = decompress_smooth_data;
70
47.1k
    else
71
47.1k
      coef->pub._decompress_data = decompress_data;
72
77.5k
  }
73
99.7k
#endif
74
99.7k
  cinfo->output_iMCU_row = 0;
75
99.7k
}
jdcoefct-8.c:start_output_pass
Line
Count
Source
62
86.2k
{
63
86.2k
#ifdef BLOCK_SMOOTHING_SUPPORTED
64
86.2k
  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
86.2k
  if (coef->pub.coef_arrays != NULL) {
68
68.0k
    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
69
26.3k
      coef->pub._decompress_data = decompress_smooth_data;
70
41.6k
    else
71
41.6k
      coef->pub._decompress_data = decompress_data;
72
68.0k
  }
73
86.2k
#endif
74
86.2k
  cinfo->output_iMCU_row = 0;
75
86.2k
}
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.45k
    if (cinfo->do_block_smoothing && smoothing_ok(cinfo))
69
4.01k
      coef->pub._decompress_data = decompress_smooth_data;
70
5.43k
    else
71
5.43k
      coef->pub._decompress_data = decompress_data;
72
9.45k
  }
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
7.98M
{
91
7.98M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
92
7.98M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
93
7.98M
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
94
7.98M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
95
7.98M
  int blkn, ci, xindex, yindex, yoffset, useful_width;
96
7.98M
  _JSAMPARRAY output_ptr;
97
7.98M
  JDIMENSION start_col, output_col;
98
7.98M
  jpeg_component_info *compptr;
99
7.98M
  _inverse_DCT_method_ptr inverse_DCT;
100
101
  /* Loop to process as much as one whole iMCU row */
102
17.9M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
103
9.95M
       yoffset++) {
104
86.0M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
105
76.0M
         MCU_col_num++) {
106
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
107
76.0M
      jzero_far((void *)coef->MCU_buffer[0],
108
76.0M
                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
109
76.0M
      if (!cinfo->entropy->insufficient_data)
110
28.4M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
111
#ifdef WITH_PROFILE
112
      cinfo->master->start = getTime();
113
#endif
114
76.0M
      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
76.0M
      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
135
75.9M
          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
73.3M
        blkn = 0;               /* index of current DCT block within MCU */
142
165M
        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
143
92.1M
          compptr = cinfo->cur_comp_info[ci];
144
          /* Don't bother to IDCT an uninteresting component. */
145
92.1M
          if (!compptr->component_needed) {
146
114k
            blkn += compptr->MCU_blocks;
147
114k
            continue;
148
114k
          }
149
92.0M
          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
150
92.0M
          useful_width = (MCU_col_num < last_MCU_col) ?
151
73.3M
                         compptr->MCU_width : compptr->last_col_width;
152
92.0M
          output_ptr = output_buf[compptr->component_index] +
153
92.0M
                       yoffset * compptr->_DCT_scaled_size;
154
92.0M
          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
155
92.0M
                      compptr->MCU_sample_width;
156
191M
          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
157
99.3M
            if (cinfo->input_iMCU_row < last_iMCU_row ||
158
97.5M
                yoffset + yindex < compptr->last_row_height) {
159
97.5M
              output_col = start_col;
160
202M
              for (xindex = 0; xindex < useful_width; xindex++) {
161
#ifdef WITH_PROFILE
162
                cinfo->master->start = getTime();
163
#endif
164
104M
                (*inverse_DCT) (cinfo, compptr,
165
104M
                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
166
104M
                                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
104M
                output_col += compptr->_DCT_scaled_size;
173
104M
              }
174
97.5M
            }
175
99.3M
            blkn += compptr->MCU_width;
176
99.3M
            output_ptr += compptr->_DCT_scaled_size;
177
99.3M
          }
178
92.0M
        }
179
73.3M
      }
180
76.0M
    }
181
    /* Completed an MCU row, but perhaps not an iMCU row */
182
9.95M
    coef->MCU_ctr = 0;
183
9.95M
  }
184
  /* Completed the iMCU row, advance counters for next one */
185
7.98M
  cinfo->output_iMCU_row++;
186
7.98M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
187
7.96M
    start_iMCU_row(cinfo);
188
7.96M
    return JPEG_ROW_COMPLETED;
189
7.96M
  }
190
  /* Completed the scan */
191
19.2k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
192
19.2k
  return JPEG_SCAN_COMPLETED;
193
7.98M
}
jdcoefct-8.c:decompress_onepass
Line
Count
Source
90
7.32M
{
91
7.32M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
92
7.32M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
93
7.32M
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
94
7.32M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
95
7.32M
  int blkn, ci, xindex, yindex, yoffset, useful_width;
96
7.32M
  _JSAMPARRAY output_ptr;
97
7.32M
  JDIMENSION start_col, output_col;
98
7.32M
  jpeg_component_info *compptr;
99
7.32M
  _inverse_DCT_method_ptr inverse_DCT;
100
101
  /* Loop to process as much as one whole iMCU row */
102
16.2M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
103
8.92M
       yoffset++) {
104
68.9M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
105
60.0M
         MCU_col_num++) {
106
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
107
60.0M
      jzero_far((void *)coef->MCU_buffer[0],
108
60.0M
                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
109
60.0M
      if (!cinfo->entropy->insufficient_data)
110
21.0M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
111
#ifdef WITH_PROFILE
112
      cinfo->master->start = getTime();
113
#endif
114
60.0M
      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
60.0M
      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
135
59.9M
          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
58.5M
        blkn = 0;               /* index of current DCT block within MCU */
142
134M
        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
143
76.1M
          compptr = cinfo->cur_comp_info[ci];
144
          /* Don't bother to IDCT an uninteresting component. */
145
76.1M
          if (!compptr->component_needed) {
146
89.3k
            blkn += compptr->MCU_blocks;
147
89.3k
            continue;
148
89.3k
          }
149
76.0M
          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
150
76.0M
          useful_width = (MCU_col_num < last_MCU_col) ?
151
58.5M
                         compptr->MCU_width : compptr->last_col_width;
152
76.0M
          output_ptr = output_buf[compptr->component_index] +
153
76.0M
                       yoffset * compptr->_DCT_scaled_size;
154
76.0M
          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
155
76.0M
                      compptr->MCU_sample_width;
156
158M
          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
157
82.7M
            if (cinfo->input_iMCU_row < last_iMCU_row ||
158
80.9M
                yoffset + yindex < compptr->last_row_height) {
159
80.9M
              output_col = start_col;
160
168M
              for (xindex = 0; xindex < useful_width; xindex++) {
161
#ifdef WITH_PROFILE
162
                cinfo->master->start = getTime();
163
#endif
164
87.7M
                (*inverse_DCT) (cinfo, compptr,
165
87.7M
                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
166
87.7M
                                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
87.7M
                output_col += compptr->_DCT_scaled_size;
173
87.7M
              }
174
80.9M
            }
175
82.7M
            blkn += compptr->MCU_width;
176
82.7M
            output_ptr += compptr->_DCT_scaled_size;
177
82.7M
          }
178
76.0M
        }
179
58.5M
      }
180
60.0M
    }
181
    /* Completed an MCU row, but perhaps not an iMCU row */
182
8.92M
    coef->MCU_ctr = 0;
183
8.92M
  }
184
  /* Completed the iMCU row, advance counters for next one */
185
7.32M
  cinfo->output_iMCU_row++;
186
7.32M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
187
7.30M
    start_iMCU_row(cinfo);
188
7.30M
    return JPEG_ROW_COMPLETED;
189
7.30M
  }
190
  /* Completed the scan */
191
16.0k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
192
16.0k
  return JPEG_SCAN_COMPLETED;
193
7.32M
}
jdcoefct-12.c:decompress_onepass
Line
Count
Source
90
661k
{
91
661k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
92
661k
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
93
661k
  JDIMENSION last_MCU_col = cinfo->MCUs_per_row - 1;
94
661k
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
95
661k
  int blkn, ci, xindex, yindex, yoffset, useful_width;
96
661k
  _JSAMPARRAY output_ptr;
97
661k
  JDIMENSION start_col, output_col;
98
661k
  jpeg_component_info *compptr;
99
661k
  _inverse_DCT_method_ptr inverse_DCT;
100
101
  /* Loop to process as much as one whole iMCU row */
102
1.69M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
103
1.03M
       yoffset++) {
104
17.0M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num <= last_MCU_col;
105
16.0M
         MCU_col_num++) {
106
      /* Try to fetch an MCU.  Entropy decoder expects buffer to be zeroed. */
107
16.0M
      jzero_far((void *)coef->MCU_buffer[0],
108
16.0M
                (size_t)(cinfo->blocks_in_MCU * sizeof(JBLOCK)));
109
16.0M
      if (!cinfo->entropy->insufficient_data)
110
7.41M
        cinfo->master->last_good_iMCU_row = cinfo->input_iMCU_row;
111
#ifdef WITH_PROFILE
112
      cinfo->master->start = getTime();
113
#endif
114
16.0M
      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
16.0M
      if (MCU_col_num >= cinfo->master->first_iMCU_col &&
135
15.9M
          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
14.8M
        blkn = 0;               /* index of current DCT block within MCU */
142
30.9M
        for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
143
16.0M
          compptr = cinfo->cur_comp_info[ci];
144
          /* Don't bother to IDCT an uninteresting component. */
145
16.0M
          if (!compptr->component_needed) {
146
25.2k
            blkn += compptr->MCU_blocks;
147
25.2k
            continue;
148
25.2k
          }
149
16.0M
          inverse_DCT = cinfo->idct->_inverse_DCT[compptr->component_index];
150
16.0M
          useful_width = (MCU_col_num < last_MCU_col) ?
151
14.7M
                         compptr->MCU_width : compptr->last_col_width;
152
16.0M
          output_ptr = output_buf[compptr->component_index] +
153
16.0M
                       yoffset * compptr->_DCT_scaled_size;
154
16.0M
          start_col = (MCU_col_num - cinfo->master->first_iMCU_col) *
155
16.0M
                      compptr->MCU_sample_width;
156
32.7M
          for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
157
16.6M
            if (cinfo->input_iMCU_row < last_iMCU_row ||
158
16.5M
                yoffset + yindex < compptr->last_row_height) {
159
16.5M
              output_col = start_col;
160
33.7M
              for (xindex = 0; xindex < useful_width; xindex++) {
161
#ifdef WITH_PROFILE
162
                cinfo->master->start = getTime();
163
#endif
164
17.2M
                (*inverse_DCT) (cinfo, compptr,
165
17.2M
                                (JCOEFPTR)coef->MCU_buffer[blkn + xindex],
166
17.2M
                                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
17.2M
                output_col += compptr->_DCT_scaled_size;
173
17.2M
              }
174
16.5M
            }
175
16.6M
            blkn += compptr->MCU_width;
176
16.6M
            output_ptr += compptr->_DCT_scaled_size;
177
16.6M
          }
178
16.0M
        }
179
14.8M
      }
180
16.0M
    }
181
    /* Completed an MCU row, but perhaps not an iMCU row */
182
1.03M
    coef->MCU_ctr = 0;
183
1.03M
  }
184
  /* Completed the iMCU row, advance counters for next one */
185
661k
  cinfo->output_iMCU_row++;
186
661k
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
187
658k
    start_iMCU_row(cinfo);
188
658k
    return JPEG_ROW_COMPLETED;
189
658k
  }
190
  /* Completed the scan */
191
3.13k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
192
3.13k
  return JPEG_SCAN_COMPLETED;
193
661k
}
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
61.3M
{
219
61.3M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
220
61.3M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
221
61.3M
  int blkn, ci, xindex, yindex, yoffset;
222
61.3M
  JDIMENSION start_col;
223
61.3M
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
224
61.3M
  JBLOCKROW buffer_ptr;
225
61.3M
  jpeg_component_info *compptr;
226
227
  /* Align the virtual buffers for the components used in this scan. */
228
143M
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
229
82.2M
    compptr = cinfo->cur_comp_info[ci];
230
82.2M
    buffer[ci] = (*cinfo->mem->access_virt_barray)
231
82.2M
      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
232
82.2M
       cinfo->input_iMCU_row * compptr->v_samp_factor,
233
82.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
82.2M
  }
239
240
  /* Loop to process one whole iMCU row */
241
148M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
242
87.0M
       yoffset++) {
243
815M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
244
727M
         MCU_col_num++) {
245
      /* Construct list of pointers to DCT blocks belonging to this MCU */
246
727M
      blkn = 0;                 /* index of current DCT block within MCU */
247
1.53G
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
248
807M
        compptr = cinfo->cur_comp_info[ci];
249
807M
        start_col = MCU_col_num * compptr->MCU_width;
250
1.67G
        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
251
869M
          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
252
1.86G
          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
253
994M
            coef->MCU_buffer[blkn++] = buffer_ptr++;
254
994M
          }
255
869M
        }
256
807M
      }
257
727M
      if (!cinfo->entropy->insufficient_data)
258
465M
        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
727M
      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
727M
    }
280
    /* Completed an MCU row, but perhaps not an iMCU row */
281
87.0M
    coef->MCU_ctr = 0;
282
87.0M
  }
283
  /* Completed the iMCU row, advance counters for next one */
284
61.3M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
285
61.1M
    start_iMCU_row(cinfo);
286
61.1M
    return JPEG_ROW_COMPLETED;
287
61.1M
  }
288
  /* Completed the scan */
289
289k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
290
289k
  return JPEG_SCAN_COMPLETED;
291
61.3M
}
jdcoefct-8.c:consume_data
Line
Count
Source
218
51.1M
{
219
51.1M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
220
51.1M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
221
51.1M
  int blkn, ci, xindex, yindex, yoffset;
222
51.1M
  JDIMENSION start_col;
223
51.1M
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
224
51.1M
  JBLOCKROW buffer_ptr;
225
51.1M
  jpeg_component_info *compptr;
226
227
  /* Align the virtual buffers for the components used in this scan. */
228
116M
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
229
65.2M
    compptr = cinfo->cur_comp_info[ci];
230
65.2M
    buffer[ci] = (*cinfo->mem->access_virt_barray)
231
65.2M
      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
232
65.2M
       cinfo->input_iMCU_row * compptr->v_samp_factor,
233
65.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
65.2M
  }
239
240
  /* Loop to process one whole iMCU row */
241
125M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
242
74.7M
       yoffset++) {
243
705M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
244
631M
         MCU_col_num++) {
245
      /* Construct list of pointers to DCT blocks belonging to this MCU */
246
631M
      blkn = 0;                 /* index of current DCT block within MCU */
247
1.32G
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
248
698M
        compptr = cinfo->cur_comp_info[ci];
249
698M
        start_col = MCU_col_num * compptr->MCU_width;
250
1.44G
        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
251
748M
          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
252
1.61G
          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
253
862M
            coef->MCU_buffer[blkn++] = buffer_ptr++;
254
862M
          }
255
748M
        }
256
698M
      }
257
631M
      if (!cinfo->entropy->insufficient_data)
258
391M
        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
631M
      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
631M
    }
280
    /* Completed an MCU row, but perhaps not an iMCU row */
281
74.7M
    coef->MCU_ctr = 0;
282
74.7M
  }
283
  /* Completed the iMCU row, advance counters for next one */
284
51.1M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
285
50.8M
    start_iMCU_row(cinfo);
286
50.8M
    return JPEG_ROW_COMPLETED;
287
50.8M
  }
288
  /* Completed the scan */
289
255k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
290
255k
  return JPEG_SCAN_COMPLETED;
291
51.1M
}
jdcoefct-12.c:consume_data
Line
Count
Source
218
10.2M
{
219
10.2M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
220
10.2M
  JDIMENSION MCU_col_num;       /* index of current MCU within row */
221
10.2M
  int blkn, ci, xindex, yindex, yoffset;
222
10.2M
  JDIMENSION start_col;
223
10.2M
  JBLOCKARRAY buffer[MAX_COMPS_IN_SCAN];
224
10.2M
  JBLOCKROW buffer_ptr;
225
10.2M
  jpeg_component_info *compptr;
226
227
  /* Align the virtual buffers for the components used in this scan. */
228
27.2M
  for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
229
16.9M
    compptr = cinfo->cur_comp_info[ci];
230
16.9M
    buffer[ci] = (*cinfo->mem->access_virt_barray)
231
16.9M
      ((j_common_ptr)cinfo, coef->whole_image[compptr->component_index],
232
16.9M
       cinfo->input_iMCU_row * compptr->v_samp_factor,
233
16.9M
       (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
16.9M
  }
239
240
  /* Loop to process one whole iMCU row */
241
22.5M
  for (yoffset = coef->MCU_vert_offset; yoffset < coef->MCU_rows_per_iMCU_row;
242
12.2M
       yoffset++) {
243
109M
    for (MCU_col_num = coef->MCU_ctr; MCU_col_num < cinfo->MCUs_per_row;
244
96.9M
         MCU_col_num++) {
245
      /* Construct list of pointers to DCT blocks belonging to this MCU */
246
96.9M
      blkn = 0;                 /* index of current DCT block within MCU */
247
205M
      for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
248
108M
        compptr = cinfo->cur_comp_info[ci];
249
108M
        start_col = MCU_col_num * compptr->MCU_width;
250
230M
        for (yindex = 0; yindex < compptr->MCU_height; yindex++) {
251
121M
          buffer_ptr = buffer[ci][yindex + yoffset] + start_col;
252
253M
          for (xindex = 0; xindex < compptr->MCU_width; xindex++) {
253
131M
            coef->MCU_buffer[blkn++] = buffer_ptr++;
254
131M
          }
255
121M
        }
256
108M
      }
257
96.9M
      if (!cinfo->entropy->insufficient_data)
258
73.6M
        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
96.9M
      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
96.9M
    }
280
    /* Completed an MCU row, but perhaps not an iMCU row */
281
12.2M
    coef->MCU_ctr = 0;
282
12.2M
  }
283
  /* Completed the iMCU row, advance counters for next one */
284
10.2M
  if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) {
285
10.2M
    start_iMCU_row(cinfo);
286
10.2M
    return JPEG_ROW_COMPLETED;
287
10.2M
  }
288
  /* Completed the scan */
289
34.4k
  (*cinfo->inputctl->finish_input_pass) (cinfo);
290
34.4k
  return JPEG_SCAN_COMPLETED;
291
10.2M
}
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
10.4M
{
305
10.4M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
306
10.4M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
307
10.4M
  JDIMENSION block_num;
308
10.4M
  int ci, block_row, block_rows;
309
10.4M
  JBLOCKARRAY buffer;
310
10.4M
  JBLOCKROW buffer_ptr;
311
10.4M
  _JSAMPARRAY output_ptr;
312
10.4M
  JDIMENSION output_col;
313
10.4M
  jpeg_component_info *compptr;
314
10.4M
  _inverse_DCT_method_ptr inverse_DCT;
315
316
  /* Force some input to be done if we are getting ahead of the input. */
317
16.0M
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
318
16.0M
         (cinfo->input_scan_number == cinfo->output_scan_number &&
319
16.0M
          cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
320
5.66M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
321
0
      return JPEG_SUSPENDED;
322
5.66M
  }
323
324
  /* OK, output from the virtual arrays. */
325
35.4M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
326
25.0M
       ci++, compptr++) {
327
    /* Don't bother to IDCT an uninteresting component. */
328
25.0M
    if (!compptr->component_needed)
329
1.01M
      continue;
330
    /* Align the virtual buffer for this component. */
331
24.0M
    buffer = (*cinfo->mem->access_virt_barray)
332
24.0M
      ((j_common_ptr)cinfo, coef->whole_image[ci],
333
24.0M
       cinfo->output_iMCU_row * compptr->v_samp_factor,
334
24.0M
       (JDIMENSION)compptr->v_samp_factor, FALSE);
335
    /* Count non-dummy DCT block rows in this iMCU row. */
336
24.0M
    if (cinfo->output_iMCU_row < last_iMCU_row)
337
23.9M
      block_rows = compptr->v_samp_factor;
338
109k
    else {
339
      /* NB: can't use last_row_height here; it is input-side-dependent! */
340
109k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
341
109k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
342
109k
    }
343
24.0M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
344
24.0M
    output_ptr = output_buf[ci];
345
    /* Loop over all DCT blocks to be processed. */
346
59.5M
    for (block_row = 0; block_row < block_rows; block_row++) {
347
35.5M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
348
35.5M
      output_col = 0;
349
35.5M
      for (block_num = cinfo->master->first_MCU_col[ci];
350
237M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
351
#ifdef WITH_PROFILE
352
        cinfo->master->start = getTime();
353
#endif
354
201M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
355
201M
                        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
201M
        buffer_ptr++;
361
201M
        output_col += compptr->_DCT_scaled_size;
362
201M
      }
363
35.5M
      output_ptr += compptr->_DCT_scaled_size;
364
35.5M
    }
365
24.0M
  }
366
367
10.4M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
368
10.3M
    return JPEG_ROW_COMPLETED;
369
44.3k
  return JPEG_SCAN_COMPLETED;
370
10.4M
}
jdcoefct-8.c:decompress_data
Line
Count
Source
304
9.36M
{
305
9.36M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
306
9.36M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
307
9.36M
  JDIMENSION block_num;
308
9.36M
  int ci, block_row, block_rows;
309
9.36M
  JBLOCKARRAY buffer;
310
9.36M
  JBLOCKROW buffer_ptr;
311
9.36M
  _JSAMPARRAY output_ptr;
312
9.36M
  JDIMENSION output_col;
313
9.36M
  jpeg_component_info *compptr;
314
9.36M
  _inverse_DCT_method_ptr inverse_DCT;
315
316
  /* Force some input to be done if we are getting ahead of the input. */
317
15.0M
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
318
15.0M
         (cinfo->input_scan_number == cinfo->output_scan_number &&
319
15.0M
          cinfo->input_iMCU_row <= cinfo->output_iMCU_row)) {
320
5.66M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
321
0
      return JPEG_SUSPENDED;
322
5.66M
  }
323
324
  /* OK, output from the virtual arrays. */
325
31.7M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
326
22.4M
       ci++, compptr++) {
327
    /* Don't bother to IDCT an uninteresting component. */
328
22.4M
    if (!compptr->component_needed)
329
551k
      continue;
330
    /* Align the virtual buffer for this component. */
331
21.8M
    buffer = (*cinfo->mem->access_virt_barray)
332
21.8M
      ((j_common_ptr)cinfo, coef->whole_image[ci],
333
21.8M
       cinfo->output_iMCU_row * compptr->v_samp_factor,
334
21.8M
       (JDIMENSION)compptr->v_samp_factor, FALSE);
335
    /* Count non-dummy DCT block rows in this iMCU row. */
336
21.8M
    if (cinfo->output_iMCU_row < last_iMCU_row)
337
21.7M
      block_rows = compptr->v_samp_factor;
338
101k
    else {
339
      /* NB: can't use last_row_height here; it is input-side-dependent! */
340
101k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
341
101k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
342
101k
    }
343
21.8M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
344
21.8M
    output_ptr = output_buf[ci];
345
    /* Loop over all DCT blocks to be processed. */
346
54.0M
    for (block_row = 0; block_row < block_rows; block_row++) {
347
32.1M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
348
32.1M
      output_col = 0;
349
32.1M
      for (block_num = cinfo->master->first_MCU_col[ci];
350
209M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
351
#ifdef WITH_PROFILE
352
        cinfo->master->start = getTime();
353
#endif
354
177M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
355
177M
                        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
177M
        buffer_ptr++;
361
177M
        output_col += compptr->_DCT_scaled_size;
362
177M
      }
363
32.1M
      output_ptr += compptr->_DCT_scaled_size;
364
32.1M
    }
365
21.8M
  }
366
367
9.36M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
368
9.32M
    return JPEG_ROW_COMPLETED;
369
40.5k
  return JPEG_SCAN_COMPLETED;
370
9.36M
}
jdcoefct-12.c:decompress_data
Line
Count
Source
304
1.03M
{
305
1.03M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
306
1.03M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
307
1.03M
  JDIMENSION block_num;
308
1.03M
  int ci, block_row, block_rows;
309
1.03M
  JBLOCKARRAY buffer;
310
1.03M
  JBLOCKROW buffer_ptr;
311
1.03M
  _JSAMPARRAY output_ptr;
312
1.03M
  JDIMENSION output_col;
313
1.03M
  jpeg_component_info *compptr;
314
1.03M
  _inverse_DCT_method_ptr inverse_DCT;
315
316
  /* Force some input to be done if we are getting ahead of the input. */
317
1.03M
  while (cinfo->input_scan_number < cinfo->output_scan_number ||
318
1.03M
         (cinfo->input_scan_number == cinfo->output_scan_number &&
319
1.03M
          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.67M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
326
2.63M
       ci++, compptr++) {
327
    /* Don't bother to IDCT an uninteresting component. */
328
2.63M
    if (!compptr->component_needed)
329
466k
      continue;
330
    /* Align the virtual buffer for this component. */
331
2.16M
    buffer = (*cinfo->mem->access_virt_barray)
332
2.16M
      ((j_common_ptr)cinfo, coef->whole_image[ci],
333
2.16M
       cinfo->output_iMCU_row * compptr->v_samp_factor,
334
2.16M
       (JDIMENSION)compptr->v_samp_factor, FALSE);
335
    /* Count non-dummy DCT block rows in this iMCU row. */
336
2.16M
    if (cinfo->output_iMCU_row < last_iMCU_row)
337
2.16M
      block_rows = compptr->v_samp_factor;
338
7.27k
    else {
339
      /* NB: can't use last_row_height here; it is input-side-dependent! */
340
7.27k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
341
7.27k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
342
7.27k
    }
343
2.16M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
344
2.16M
    output_ptr = output_buf[ci];
345
    /* Loop over all DCT blocks to be processed. */
346
5.48M
    for (block_row = 0; block_row < block_rows; block_row++) {
347
3.31M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
348
3.31M
      output_col = 0;
349
3.31M
      for (block_num = cinfo->master->first_MCU_col[ci];
350
27.1M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
351
#ifdef WITH_PROFILE
352
        cinfo->master->start = getTime();
353
#endif
354
23.7M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)buffer_ptr, output_ptr,
355
23.7M
                        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
23.7M
        buffer_ptr++;
361
23.7M
        output_col += compptr->_DCT_scaled_size;
362
23.7M
      }
363
3.31M
      output_ptr += compptr->_DCT_scaled_size;
364
3.31M
    }
365
2.16M
  }
366
367
1.03M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
368
1.03M
    return JPEG_ROW_COMPLETED;
369
3.85k
  return JPEG_SCAN_COMPLETED;
370
1.03M
}
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
9.69M
#define Q01_POS  1
386
9.68M
#define Q10_POS  8
387
9.68M
#define Q20_POS  16
388
9.68M
#define Q11_POS  9
389
9.68M
#define Q02_POS  2
390
6.97M
#define Q03_POS  3
391
6.97M
#define Q12_POS  10
392
6.97M
#define Q21_POS  17
393
6.97M
#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
77.5k
{
406
77.5k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
407
77.5k
  boolean smoothing_useful = FALSE;
408
77.5k
  int ci, coefi;
409
77.5k
  jpeg_component_info *compptr;
410
77.5k
  JQUANT_TBL *qtable;
411
77.5k
  int *coef_bits, *prev_coef_bits;
412
77.5k
  int *coef_bits_latch, *prev_coef_bits_latch;
413
414
77.5k
  if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
415
23.0k
    return FALSE;
416
417
  /* Allocate latch area if not already done */
418
54.4k
  if (coef->coef_bits_latch == NULL)
419
29.9k
    coef->coef_bits_latch = (int *)
420
29.9k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
421
29.9k
                                  cinfo->num_components * 2 *
422
29.9k
                                  (SAVED_COEFS * sizeof(int)));
423
54.4k
  coef_bits_latch = coef->coef_bits_latch;
424
54.4k
  prev_coef_bits_latch =
425
54.4k
    &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
426
427
115k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
428
85.0k
       ci++, compptr++) {
429
    /* All components' quantization values must already be latched. */
430
85.0k
    if ((qtable = compptr->quant_table) == NULL)
431
5.83k
      return FALSE;
432
    /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
433
79.2k
    if (qtable->quantval[0] == 0 ||
434
77.7k
        qtable->quantval[Q01_POS] == 0 ||
435
76.2k
        qtable->quantval[Q10_POS] == 0 ||
436
74.5k
        qtable->quantval[Q20_POS] == 0 ||
437
73.1k
        qtable->quantval[Q11_POS] == 0 ||
438
71.7k
        qtable->quantval[Q02_POS] == 0 ||
439
70.6k
        qtable->quantval[Q03_POS] == 0 ||
440
69.2k
        qtable->quantval[Q12_POS] == 0 ||
441
67.1k
        qtable->quantval[Q21_POS] == 0 ||
442
65.9k
        qtable->quantval[Q30_POS] == 0)
443
14.2k
      return FALSE;
444
    /* DC values must be at least partly known for all components. */
445
64.9k
    coef_bits = cinfo->coef_bits[ci];
446
64.9k
    prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
447
64.9k
    if (coef_bits[0] < 0)
448
3.58k
      return FALSE;
449
61.3k
    coef_bits_latch[0] = coef_bits[0];
450
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
451
613k
    for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
452
552k
      if (cinfo->input_scan_number > 1)
453
477k
        prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
454
75.0k
      else
455
75.0k
        prev_coef_bits_latch[coefi] = -1;
456
552k
      coef_bits_latch[coefi] = coef_bits[coefi];
457
552k
      if (coef_bits[coefi] != 0)
458
520k
        smoothing_useful = TRUE;
459
552k
    }
460
61.3k
    coef_bits_latch += SAVED_COEFS;
461
61.3k
    prev_coef_bits_latch += SAVED_COEFS;
462
61.3k
  }
463
464
30.7k
  return smoothing_useful;
465
54.4k
}
jdcoefct-8.c:smoothing_ok
Line
Count
Source
405
68.0k
{
406
68.0k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
407
68.0k
  boolean smoothing_useful = FALSE;
408
68.0k
  int ci, coefi;
409
68.0k
  jpeg_component_info *compptr;
410
68.0k
  JQUANT_TBL *qtable;
411
68.0k
  int *coef_bits, *prev_coef_bits;
412
68.0k
  int *coef_bits_latch, *prev_coef_bits_latch;
413
414
68.0k
  if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
415
21.2k
    return FALSE;
416
417
  /* Allocate latch area if not already done */
418
46.8k
  if (coef->coef_bits_latch == NULL)
419
22.2k
    coef->coef_bits_latch = (int *)
420
22.2k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
421
22.2k
                                  cinfo->num_components * 2 *
422
22.2k
                                  (SAVED_COEFS * sizeof(int)));
423
46.8k
  coef_bits_latch = coef->coef_bits_latch;
424
46.8k
  prev_coef_bits_latch =
425
46.8k
    &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
426
427
103k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
428
76.5k
       ci++, compptr++) {
429
    /* All components' quantization values must already be latched. */
430
76.5k
    if ((qtable = compptr->quant_table) == NULL)
431
5.18k
      return FALSE;
432
    /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
433
71.3k
    if (qtable->quantval[0] == 0 ||
434
70.1k
        qtable->quantval[Q01_POS] == 0 ||
435
68.9k
        qtable->quantval[Q10_POS] == 0 ||
436
67.6k
        qtable->quantval[Q20_POS] == 0 ||
437
66.4k
        qtable->quantval[Q11_POS] == 0 ||
438
65.2k
        qtable->quantval[Q02_POS] == 0 ||
439
64.2k
        qtable->quantval[Q03_POS] == 0 ||
440
63.1k
        qtable->quantval[Q12_POS] == 0 ||
441
61.1k
        qtable->quantval[Q21_POS] == 0 ||
442
60.2k
        qtable->quantval[Q30_POS] == 0)
443
11.9k
      return FALSE;
444
    /* DC values must be at least partly known for all components. */
445
59.3k
    coef_bits = cinfo->coef_bits[ci];
446
59.3k
    prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
447
59.3k
    if (coef_bits[0] < 0)
448
2.92k
      return FALSE;
449
56.4k
    coef_bits_latch[0] = coef_bits[0];
450
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
451
564k
    for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
452
508k
      if (cinfo->input_scan_number > 1)
453
453k
        prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
454
54.2k
      else
455
54.2k
        prev_coef_bits_latch[coefi] = -1;
456
508k
      coef_bits_latch[coefi] = coef_bits[coefi];
457
508k
      if (coef_bits[coefi] != 0)
458
477k
        smoothing_useful = TRUE;
459
508k
    }
460
56.4k
    coef_bits_latch += SAVED_COEFS;
461
56.4k
    prev_coef_bits_latch += SAVED_COEFS;
462
56.4k
  }
463
464
26.7k
  return smoothing_useful;
465
46.8k
}
jdcoefct-12.c:smoothing_ok
Line
Count
Source
405
9.45k
{
406
9.45k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
407
9.45k
  boolean smoothing_useful = FALSE;
408
9.45k
  int ci, coefi;
409
9.45k
  jpeg_component_info *compptr;
410
9.45k
  JQUANT_TBL *qtable;
411
9.45k
  int *coef_bits, *prev_coef_bits;
412
9.45k
  int *coef_bits_latch, *prev_coef_bits_latch;
413
414
9.45k
  if (!cinfo->progressive_mode || cinfo->coef_bits == NULL)
415
1.82k
    return FALSE;
416
417
  /* Allocate latch area if not already done */
418
7.63k
  if (coef->coef_bits_latch == NULL)
419
7.63k
    coef->coef_bits_latch = (int *)
420
7.63k
      (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
421
7.63k
                                  cinfo->num_components * 2 *
422
7.63k
                                  (SAVED_COEFS * sizeof(int)));
423
7.63k
  coef_bits_latch = coef->coef_bits_latch;
424
7.63k
  prev_coef_bits_latch =
425
7.63k
    &coef->coef_bits_latch[cinfo->num_components * SAVED_COEFS];
426
427
12.5k
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
428
8.54k
       ci++, compptr++) {
429
    /* All components' quantization values must already be latched. */
430
8.54k
    if ((qtable = compptr->quant_table) == NULL)
431
648
      return FALSE;
432
    /* Verify DC & first 9 AC quantizers are nonzero to avoid zero-divide. */
433
7.89k
    if (qtable->quantval[0] == 0 ||
434
7.58k
        qtable->quantval[Q01_POS] == 0 ||
435
7.27k
        qtable->quantval[Q10_POS] == 0 ||
436
6.94k
        qtable->quantval[Q20_POS] == 0 ||
437
6.67k
        qtable->quantval[Q11_POS] == 0 ||
438
6.45k
        qtable->quantval[Q02_POS] == 0 ||
439
6.31k
        qtable->quantval[Q03_POS] == 0 ||
440
6.13k
        qtable->quantval[Q12_POS] == 0 ||
441
5.94k
        qtable->quantval[Q21_POS] == 0 ||
442
5.70k
        qtable->quantval[Q30_POS] == 0)
443
2.29k
      return FALSE;
444
    /* DC values must be at least partly known for all components. */
445
5.60k
    coef_bits = cinfo->coef_bits[ci];
446
5.60k
    prev_coef_bits = cinfo->coef_bits[ci + cinfo->num_components];
447
5.60k
    if (coef_bits[0] < 0)
448
664
      return FALSE;
449
4.93k
    coef_bits_latch[0] = coef_bits[0];
450
    /* Block smoothing is helpful if some AC coefficients remain inaccurate. */
451
49.3k
    for (coefi = 1; coefi < SAVED_COEFS; coefi++) {
452
44.4k
      if (cinfo->input_scan_number > 1)
453
23.6k
        prev_coef_bits_latch[coefi] = prev_coef_bits[coefi];
454
20.8k
      else
455
20.8k
        prev_coef_bits_latch[coefi] = -1;
456
44.4k
      coef_bits_latch[coefi] = coef_bits[coefi];
457
44.4k
      if (coef_bits[coefi] != 0)
458
42.4k
        smoothing_useful = TRUE;
459
44.4k
    }
460
4.93k
    coef_bits_latch += SAVED_COEFS;
461
4.93k
    prev_coef_bits_latch += SAVED_COEFS;
462
4.93k
  }
463
464
4.02k
  return smoothing_useful;
465
7.63k
}
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
6.02M
{
475
6.02M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
476
6.02M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
477
6.02M
  JDIMENSION block_num, last_block_column;
478
6.02M
  int ci, block_row, block_rows, access_rows, image_block_row,
479
6.02M
    image_block_rows;
480
6.02M
  JBLOCKARRAY buffer;
481
6.02M
  JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
482
6.02M
  JBLOCKROW next_block_row, next_next_block_row;
483
6.02M
  _JSAMPARRAY output_ptr;
484
6.02M
  JDIMENSION output_col;
485
6.02M
  jpeg_component_info *compptr;
486
6.02M
  _inverse_DCT_method_ptr inverse_DCT;
487
6.02M
  boolean change_dc;
488
6.02M
  JCOEF *workspace;
489
6.02M
  int *coef_bits;
490
6.02M
  JQUANT_TBL *quanttbl;
491
6.02M
  JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
492
6.02M
  int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
493
6.02M
      DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
494
6.02M
      DC25;
495
6.02M
  int Al, pred;
496
497
  /* Keep a local variable to avoid looking it up more than once */
498
6.02M
  workspace = coef->workspace;
499
500
  /* Force some input to be done if we are getting ahead of the input. */
501
8.79M
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
502
8.77M
         !cinfo->inputctl->eoi_reached) {
503
5.74M
    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
5.74M
      JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0;
510
5.74M
      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
511
2.95M
        break;
512
5.74M
    }
513
2.78M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
514
10.1k
      return JPEG_SUSPENDED;
515
2.78M
  }
516
517
  /* OK, output from the virtual arrays. */
518
15.7M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
519
9.77M
       ci++, compptr++) {
520
    /* Don't bother to IDCT an uninteresting component. */
521
9.77M
    if (!compptr->component_needed)
522
157k
      continue;
523
    /* Count non-dummy DCT block rows in this iMCU row. */
524
9.61M
    if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
525
9.52M
      block_rows = compptr->v_samp_factor;
526
9.52M
      access_rows = block_rows * 3; /* this and next two iMCU rows */
527
9.52M
    } else if (cinfo->output_iMCU_row < last_iMCU_row) {
528
33.8k
      block_rows = compptr->v_samp_factor;
529
33.8k
      access_rows = block_rows * 2; /* this and next iMCU row */
530
50.6k
    } else {
531
      /* NB: can't use last_row_height here; it is input-side-dependent! */
532
50.6k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
533
50.6k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
534
50.6k
      access_rows = block_rows; /* this iMCU row only */
535
50.6k
    }
536
    /* Align the virtual buffer for this component. */
537
9.61M
    if (cinfo->output_iMCU_row > 1) {
538
9.52M
      access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
539
9.52M
      buffer = (*cinfo->mem->access_virt_barray)
540
9.52M
        ((j_common_ptr)cinfo, coef->whole_image[ci],
541
9.52M
         (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
542
9.52M
         (JDIMENSION)access_rows, FALSE);
543
9.52M
      buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
544
9.52M
    } else if (cinfo->output_iMCU_row > 0) {
545
36.7k
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
546
36.7k
      buffer = (*cinfo->mem->access_virt_barray)
547
36.7k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
548
36.7k
         (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
549
36.7k
         (JDIMENSION)access_rows, FALSE);
550
36.7k
      buffer += compptr->v_samp_factor; /* point to current iMCU row */
551
48.2k
    } else {
552
48.2k
      buffer = (*cinfo->mem->access_virt_barray)
553
48.2k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
554
48.2k
         (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
555
48.2k
    }
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
9.61M
    if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
561
4.79M
      coef_bits =
562
4.79M
        coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
563
4.81M
    else
564
4.81M
      coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
565
566
    /* We only do DC interpolation if no AC coefficient data is available. */
567
9.61M
    change_dc =
568
9.61M
      coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
569
7.74M
      coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
570
7.14M
      coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
571
572
9.61M
    quanttbl = compptr->quant_table;
573
9.61M
    Q00 = quanttbl->quantval[0];
574
9.61M
    Q01 = quanttbl->quantval[Q01_POS];
575
9.61M
    Q10 = quanttbl->quantval[Q10_POS];
576
9.61M
    Q20 = quanttbl->quantval[Q20_POS];
577
9.61M
    Q11 = quanttbl->quantval[Q11_POS];
578
9.61M
    Q02 = quanttbl->quantval[Q02_POS];
579
9.61M
    if (change_dc) {
580
6.90M
      Q03 = quanttbl->quantval[Q03_POS];
581
6.90M
      Q12 = quanttbl->quantval[Q12_POS];
582
6.90M
      Q21 = quanttbl->quantval[Q21_POS];
583
6.90M
      Q30 = quanttbl->quantval[Q30_POS];
584
6.90M
    }
585
9.61M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
586
9.61M
    output_ptr = output_buf[ci];
587
    /* Loop over all DCT blocks to be processed. */
588
9.61M
    image_block_rows = block_rows * cinfo->total_iMCU_rows;
589
24.9M
    for (block_row = 0; block_row < block_rows; block_row++) {
590
15.3M
      image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
591
15.3M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
592
593
15.3M
      if (image_block_row > 0)
594
15.2M
        prev_block_row =
595
15.2M
          buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
596
48.2k
      else
597
48.2k
        prev_block_row = buffer_ptr;
598
599
15.3M
      if (image_block_row > 1)
600
15.2M
        prev_prev_block_row =
601
15.2M
          buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
602
91.6k
      else
603
91.6k
        prev_prev_block_row = prev_block_row;
604
605
15.3M
      if (image_block_row < image_block_rows - 1)
606
15.2M
        next_block_row =
607
15.2M
          buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
608
50.6k
      else
609
50.6k
        next_block_row = buffer_ptr;
610
611
15.3M
      if (image_block_row < image_block_rows - 2)
612
15.2M
        next_next_block_row =
613
15.2M
          buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
614
81.7k
      else
615
81.7k
        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
15.3M
      DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
621
15.3M
      DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
622
15.3M
      DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
623
15.3M
      DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
624
15.3M
      DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
625
15.3M
      output_col = 0;
626
15.3M
      last_block_column = compptr->width_in_blocks - 1;
627
15.3M
      for (block_num = cinfo->master->first_MCU_col[ci];
628
112M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
629
        /* Fetch current DCT block into workspace so we can modify it. */
630
97.6M
        jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
631
        /* Update DC values */
632
97.6M
        if (block_num == cinfo->master->first_MCU_col[ci] &&
633
15.3M
            block_num < last_block_column) {
634
6.79M
          DC04 = DC05 = (int)prev_prev_block_row[1][0];
635
6.79M
          DC09 = DC10 = (int)prev_block_row[1][0];
636
6.79M
          DC14 = DC15 = (int)buffer_ptr[1][0];
637
6.79M
          DC19 = DC20 = (int)next_block_row[1][0];
638
6.79M
          DC24 = DC25 = (int)next_next_block_row[1][0];
639
6.79M
        }
640
97.6M
        if (block_num + 1 < last_block_column) {
641
75.5M
          DC05 = (int)prev_prev_block_row[2][0];
642
75.5M
          DC10 = (int)prev_block_row[2][0];
643
75.5M
          DC15 = (int)buffer_ptr[2][0];
644
75.5M
          DC20 = (int)next_block_row[2][0];
645
75.5M
          DC25 = (int)next_next_block_row[2][0];
646
75.5M
        }
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
97.6M
        if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
659
89.6M
          num = Q00 * (change_dc ?
660
54.3M
                (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
661
54.3M
                 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
662
54.3M
                 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
663
54.3M
                 DC21 - DC22 + DC24 + DC25) :
664
89.6M
                (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
665
89.6M
          if (num >= 0) {
666
66.5M
            pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
667
66.5M
            if (Al > 0 && pred >= (1 << Al))
668
6.01M
              pred = (1 << Al) - 1;
669
66.5M
          } else {
670
23.0M
            pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
671
23.0M
            if (Al > 0 && pred >= (1 << Al))
672
4.49M
              pred = (1 << Al) - 1;
673
23.0M
            pred = -pred;
674
23.0M
          }
675
89.6M
          workspace[1] = (JCOEF)pred;
676
89.6M
        }
677
        /* AC10 */
678
97.6M
        if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
679
90.4M
          num = Q00 * (change_dc ?
680
54.3M
                (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
681
54.3M
                 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
682
54.3M
                 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
683
54.3M
                 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
684
90.4M
                (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
685
90.4M
          if (num >= 0) {
686
62.9M
            pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
687
62.9M
            if (Al > 0 && pred >= (1 << Al))
688
10.2M
              pred = (1 << Al) - 1;
689
62.9M
          } else {
690
27.5M
            pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
691
27.5M
            if (Al > 0 && pred >= (1 << Al))
692
8.35M
              pred = (1 << Al) - 1;
693
27.5M
            pred = -pred;
694
27.5M
          }
695
90.4M
          workspace[8] = (JCOEF)pred;
696
90.4M
        }
697
        /* AC20 */
698
97.6M
        if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
699
90.1M
          num = Q00 * (change_dc ?
700
54.3M
                (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
701
54.3M
                 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
702
90.1M
                (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
703
90.1M
          if (num >= 0) {
704
57.2M
            pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
705
57.2M
            if (Al > 0 && pred >= (1 << Al))
706
8.72M
              pred = (1 << Al) - 1;
707
57.2M
          } else {
708
32.9M
            pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
709
32.9M
            if (Al > 0 && pred >= (1 << Al))
710
8.75M
              pred = (1 << Al) - 1;
711
32.9M
            pred = -pred;
712
32.9M
          }
713
90.1M
          workspace[16] = (JCOEF)pred;
714
90.1M
        }
715
        /* AC11 */
716
97.6M
        if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
717
90.7M
          num = Q00 * (change_dc ?
718
54.3M
                (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
719
54.3M
                 9 * DC19 + DC21 - DC25) :
720
90.7M
                (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
721
36.4M
                 DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
722
90.7M
          if (num >= 0) {
723
69.4M
            pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
724
69.4M
            if (Al > 0 && pred >= (1 << Al))
725
4.26M
              pred = (1 << Al) - 1;
726
69.4M
          } else {
727
21.2M
            pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
728
21.2M
            if (Al > 0 && pred >= (1 << Al))
729
4.25M
              pred = (1 << Al) - 1;
730
21.2M
            pred = -pred;
731
21.2M
          }
732
90.7M
          workspace[9] = (JCOEF)pred;
733
90.7M
        }
734
        /* AC02 */
735
97.6M
        if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
736
90.5M
          num = Q00 * (change_dc ?
737
54.3M
                (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
738
54.3M
                 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
739
90.5M
                (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
740
90.5M
          if (num >= 0) {
741
57.4M
            pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
742
57.4M
            if (Al > 0 && pred >= (1 << Al))
743
5.38M
              pred = (1 << Al) - 1;
744
57.4M
          } else {
745
33.0M
            pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
746
33.0M
            if (Al > 0 && pred >= (1 << Al))
747
5.42M
              pred = (1 << Al) - 1;
748
33.0M
            pred = -pred;
749
33.0M
          }
750
90.5M
          workspace[2] = (JCOEF)pred;
751
90.5M
        }
752
97.6M
        if (change_dc) {
753
          /* AC03 */
754
54.3M
          if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
755
54.3M
            num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
756
54.3M
            if (num >= 0) {
757
42.9M
              pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
758
42.9M
              if (Al > 0 && pred >= (1 << Al))
759
0
                pred = (1 << Al) - 1;
760
42.9M
            } else {
761
11.3M
              pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
762
11.3M
              if (Al > 0 && pred >= (1 << Al))
763
0
                pred = (1 << Al) - 1;
764
11.3M
              pred = -pred;
765
11.3M
            }
766
54.3M
            workspace[3] = (JCOEF)pred;
767
54.3M
          }
768
          /* AC12 */
769
54.3M
          if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
770
54.3M
            num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
771
54.3M
            if (num >= 0) {
772
34.3M
              pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
773
34.3M
              if (Al > 0 && pred >= (1 << Al))
774
0
                pred = (1 << Al) - 1;
775
34.3M
            } else {
776
19.9M
              pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
777
19.9M
              if (Al > 0 && pred >= (1 << Al))
778
0
                pred = (1 << Al) - 1;
779
19.9M
              pred = -pred;
780
19.9M
            }
781
54.3M
            workspace[10] = (JCOEF)pred;
782
54.3M
          }
783
          /* AC21 */
784
54.3M
          if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
785
54.3M
            num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
786
54.3M
            if (num >= 0) {
787
33.6M
              pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
788
33.6M
              if (Al > 0 && pred >= (1 << Al))
789
0
                pred = (1 << Al) - 1;
790
33.6M
            } else {
791
20.6M
              pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
792
20.6M
              if (Al > 0 && pred >= (1 << Al))
793
0
                pred = (1 << Al) - 1;
794
20.6M
              pred = -pred;
795
20.6M
            }
796
54.3M
            workspace[17] = (JCOEF)pred;
797
54.3M
          }
798
          /* AC30 */
799
54.3M
          if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
800
54.3M
            num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
801
54.3M
            if (num >= 0) {
802
40.9M
              pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
803
40.9M
              if (Al > 0 && pred >= (1 << Al))
804
0
                pred = (1 << Al) - 1;
805
40.9M
            } else {
806
13.3M
              pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
807
13.3M
              if (Al > 0 && pred >= (1 << Al))
808
0
                pred = (1 << Al) - 1;
809
13.3M
              pred = -pred;
810
13.3M
            }
811
54.3M
            workspace[24] = (JCOEF)pred;
812
54.3M
          }
813
          /* coef_bits[0] is non-negative.  Otherwise this function would not
814
           * be called.
815
           */
816
54.3M
          num = Q00 *
817
54.3M
                (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
818
54.3M
                 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
819
54.3M
                 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
820
54.3M
                 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
821
54.3M
                 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
822
54.3M
          if (num >= 0) {
823
34.8M
            pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
824
34.8M
          } else {
825
19.4M
            pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
826
19.4M
            pred = -pred;
827
19.4M
          }
828
54.3M
          workspace[0] = (JCOEF)pred;
829
54.3M
        }  /* change_dc */
830
831
        /* OK, do the IDCT */
832
#ifdef WITH_PROFILE
833
        cinfo->master->start = getTime();
834
#endif
835
97.6M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
836
97.6M
                        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
97.6M
        DC01 = DC02;  DC02 = DC03;  DC03 = DC04;  DC04 = DC05;
843
97.6M
        DC06 = DC07;  DC07 = DC08;  DC08 = DC09;  DC09 = DC10;
844
97.6M
        DC11 = DC12;  DC12 = DC13;  DC13 = DC14;  DC14 = DC15;
845
97.6M
        DC16 = DC17;  DC17 = DC18;  DC18 = DC19;  DC19 = DC20;
846
97.6M
        DC21 = DC22;  DC22 = DC23;  DC23 = DC24;  DC24 = DC25;
847
97.6M
        buffer_ptr++, prev_block_row++, next_block_row++,
848
97.6M
          prev_prev_block_row++, next_next_block_row++;
849
97.6M
        output_col += compptr->_DCT_scaled_size;
850
97.6M
      }
851
15.3M
      output_ptr += compptr->_DCT_scaled_size;
852
15.3M
    }
853
9.61M
  }
854
855
6.01M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
856
5.98M
    return JPEG_ROW_COMPLETED;
857
25.9k
  return JPEG_SCAN_COMPLETED;
858
6.01M
}
jdcoefct-8.c:decompress_smooth_data
Line
Count
Source
474
5.28M
{
475
5.28M
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
476
5.28M
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
477
5.28M
  JDIMENSION block_num, last_block_column;
478
5.28M
  int ci, block_row, block_rows, access_rows, image_block_row,
479
5.28M
    image_block_rows;
480
5.28M
  JBLOCKARRAY buffer;
481
5.28M
  JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
482
5.28M
  JBLOCKROW next_block_row, next_next_block_row;
483
5.28M
  _JSAMPARRAY output_ptr;
484
5.28M
  JDIMENSION output_col;
485
5.28M
  jpeg_component_info *compptr;
486
5.28M
  _inverse_DCT_method_ptr inverse_DCT;
487
5.28M
  boolean change_dc;
488
5.28M
  JCOEF *workspace;
489
5.28M
  int *coef_bits;
490
5.28M
  JQUANT_TBL *quanttbl;
491
5.28M
  JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
492
5.28M
  int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
493
5.28M
      DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
494
5.28M
      DC25;
495
5.28M
  int Al, pred;
496
497
  /* Keep a local variable to avoid looking it up more than once */
498
5.28M
  workspace = coef->workspace;
499
500
  /* Force some input to be done if we are getting ahead of the input. */
501
8.06M
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
502
8.04M
         !cinfo->inputctl->eoi_reached) {
503
5.74M
    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
5.74M
      JDIMENSION delta = (cinfo->Ss == 0) ? 2 : 0;
510
5.74M
      if (cinfo->input_iMCU_row > cinfo->output_iMCU_row + delta)
511
2.95M
        break;
512
5.74M
    }
513
2.78M
    if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
514
10.1k
      return JPEG_SUSPENDED;
515
2.78M
  }
516
517
  /* OK, output from the virtual arrays. */
518
14.0M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
519
8.77M
       ci++, compptr++) {
520
    /* Don't bother to IDCT an uninteresting component. */
521
8.77M
    if (!compptr->component_needed)
522
68.1k
      continue;
523
    /* Count non-dummy DCT block rows in this iMCU row. */
524
8.70M
    if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
525
8.62M
      block_rows = compptr->v_samp_factor;
526
8.62M
      access_rows = block_rows * 3; /* this and next two iMCU rows */
527
8.62M
    } else if (cinfo->output_iMCU_row < last_iMCU_row) {
528
31.1k
      block_rows = compptr->v_samp_factor;
529
31.1k
      access_rows = block_rows * 2; /* this and next iMCU row */
530
47.6k
    } else {
531
      /* NB: can't use last_row_height here; it is input-side-dependent! */
532
47.6k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
533
47.6k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
534
47.6k
      access_rows = block_rows; /* this iMCU row only */
535
47.6k
    }
536
    /* Align the virtual buffer for this component. */
537
8.70M
    if (cinfo->output_iMCU_row > 1) {
538
8.63M
      access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
539
8.63M
      buffer = (*cinfo->mem->access_virt_barray)
540
8.63M
        ((j_common_ptr)cinfo, coef->whole_image[ci],
541
8.63M
         (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
542
8.63M
         (JDIMENSION)access_rows, FALSE);
543
8.63M
      buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
544
8.63M
    } else if (cinfo->output_iMCU_row > 0) {
545
33.5k
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
546
33.5k
      buffer = (*cinfo->mem->access_virt_barray)
547
33.5k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
548
33.5k
         (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
549
33.5k
         (JDIMENSION)access_rows, FALSE);
550
33.5k
      buffer += compptr->v_samp_factor; /* point to current iMCU row */
551
45.0k
    } else {
552
45.0k
      buffer = (*cinfo->mem->access_virt_barray)
553
45.0k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
554
45.0k
         (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
555
45.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
8.70M
    if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
561
4.42M
      coef_bits =
562
4.42M
        coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
563
4.28M
    else
564
4.28M
      coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
565
566
    /* We only do DC interpolation if no AC coefficient data is available. */
567
8.70M
    change_dc =
568
8.70M
      coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
569
7.03M
      coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
570
6.45M
      coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
571
572
8.70M
    quanttbl = compptr->quant_table;
573
8.70M
    Q00 = quanttbl->quantval[0];
574
8.70M
    Q01 = quanttbl->quantval[Q01_POS];
575
8.70M
    Q10 = quanttbl->quantval[Q10_POS];
576
8.70M
    Q20 = quanttbl->quantval[Q20_POS];
577
8.70M
    Q11 = quanttbl->quantval[Q11_POS];
578
8.70M
    Q02 = quanttbl->quantval[Q02_POS];
579
8.70M
    if (change_dc) {
580
6.23M
      Q03 = quanttbl->quantval[Q03_POS];
581
6.23M
      Q12 = quanttbl->quantval[Q12_POS];
582
6.23M
      Q21 = quanttbl->quantval[Q21_POS];
583
6.23M
      Q30 = quanttbl->quantval[Q30_POS];
584
6.23M
    }
585
8.70M
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
586
8.70M
    output_ptr = output_buf[ci];
587
    /* Loop over all DCT blocks to be processed. */
588
8.70M
    image_block_rows = block_rows * cinfo->total_iMCU_rows;
589
22.5M
    for (block_row = 0; block_row < block_rows; block_row++) {
590
13.8M
      image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
591
13.8M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
592
593
13.8M
      if (image_block_row > 0)
594
13.8M
        prev_block_row =
595
13.8M
          buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
596
45.0k
      else
597
45.0k
        prev_block_row = buffer_ptr;
598
599
13.8M
      if (image_block_row > 1)
600
13.7M
        prev_prev_block_row =
601
13.7M
          buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
602
85.2k
      else
603
85.2k
        prev_prev_block_row = prev_block_row;
604
605
13.8M
      if (image_block_row < image_block_rows - 1)
606
13.8M
        next_block_row =
607
13.8M
          buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
608
47.6k
      else
609
47.6k
        next_block_row = buffer_ptr;
610
611
13.8M
      if (image_block_row < image_block_rows - 2)
612
13.7M
        next_next_block_row =
613
13.7M
          buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
614
76.6k
      else
615
76.6k
        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
13.8M
      DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
621
13.8M
      DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
622
13.8M
      DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
623
13.8M
      DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
624
13.8M
      DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
625
13.8M
      output_col = 0;
626
13.8M
      last_block_column = compptr->width_in_blocks - 1;
627
13.8M
      for (block_num = cinfo->master->first_MCU_col[ci];
628
92.9M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
629
        /* Fetch current DCT block into workspace so we can modify it. */
630
79.1M
        jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
631
        /* Update DC values */
632
79.1M
        if (block_num == cinfo->master->first_MCU_col[ci] &&
633
13.8M
            block_num < last_block_column) {
634
5.93M
          DC04 = DC05 = (int)prev_prev_block_row[1][0];
635
5.93M
          DC09 = DC10 = (int)prev_block_row[1][0];
636
5.93M
          DC14 = DC15 = (int)buffer_ptr[1][0];
637
5.93M
          DC19 = DC20 = (int)next_block_row[1][0];
638
5.93M
          DC24 = DC25 = (int)next_next_block_row[1][0];
639
5.93M
        }
640
79.1M
        if (block_num + 1 < last_block_column) {
641
59.3M
          DC05 = (int)prev_prev_block_row[2][0];
642
59.3M
          DC10 = (int)prev_block_row[2][0];
643
59.3M
          DC15 = (int)buffer_ptr[2][0];
644
59.3M
          DC20 = (int)next_block_row[2][0];
645
59.3M
          DC25 = (int)next_next_block_row[2][0];
646
59.3M
        }
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
79.1M
        if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
659
71.8M
          num = Q00 * (change_dc ?
660
42.5M
                (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
661
42.5M
                 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
662
42.5M
                 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
663
42.5M
                 DC21 - DC22 + DC24 + DC25) :
664
71.8M
                (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
665
71.8M
          if (num >= 0) {
666
54.5M
            pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
667
54.5M
            if (Al > 0 && pred >= (1 << Al))
668
4.96M
              pred = (1 << Al) - 1;
669
54.5M
          } else {
670
17.2M
            pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
671
17.2M
            if (Al > 0 && pred >= (1 << Al))
672
3.57M
              pred = (1 << Al) - 1;
673
17.2M
            pred = -pred;
674
17.2M
          }
675
71.8M
          workspace[1] = (JCOEF)pred;
676
71.8M
        }
677
        /* AC10 */
678
79.1M
        if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
679
72.6M
          num = Q00 * (change_dc ?
680
42.5M
                (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
681
42.5M
                 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
682
42.5M
                 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
683
42.5M
                 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
684
72.6M
                (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
685
72.6M
          if (num >= 0) {
686
51.5M
            pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
687
51.5M
            if (Al > 0 && pred >= (1 << Al))
688
8.40M
              pred = (1 << Al) - 1;
689
51.5M
          } else {
690
21.0M
            pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
691
21.0M
            if (Al > 0 && pred >= (1 << Al))
692
7.06M
              pred = (1 << Al) - 1;
693
21.0M
            pred = -pred;
694
21.0M
          }
695
72.6M
          workspace[8] = (JCOEF)pred;
696
72.6M
        }
697
        /* AC20 */
698
79.1M
        if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
699
72.4M
          num = Q00 * (change_dc ?
700
42.5M
                (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
701
42.5M
                 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
702
72.4M
                (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
703
72.4M
          if (num >= 0) {
704
46.9M
            pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
705
46.9M
            if (Al > 0 && pred >= (1 << Al))
706
7.03M
              pred = (1 << Al) - 1;
707
46.9M
          } else {
708
25.4M
            pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
709
25.4M
            if (Al > 0 && pred >= (1 << Al))
710
7.04M
              pred = (1 << Al) - 1;
711
25.4M
            pred = -pred;
712
25.4M
          }
713
72.4M
          workspace[16] = (JCOEF)pred;
714
72.4M
        }
715
        /* AC11 */
716
79.1M
        if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
717
72.9M
          num = Q00 * (change_dc ?
718
42.5M
                (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
719
42.5M
                 9 * DC19 + DC21 - DC25) :
720
72.9M
                (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
721
30.4M
                 DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
722
72.9M
          if (num >= 0) {
723
56.6M
            pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
724
56.6M
            if (Al > 0 && pred >= (1 << Al))
725
3.50M
              pred = (1 << Al) - 1;
726
56.6M
          } else {
727
16.3M
            pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
728
16.3M
            if (Al > 0 && pred >= (1 << Al))
729
3.51M
              pred = (1 << Al) - 1;
730
16.3M
            pred = -pred;
731
16.3M
          }
732
72.9M
          workspace[9] = (JCOEF)pred;
733
72.9M
        }
734
        /* AC02 */
735
79.1M
        if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
736
72.7M
          num = Q00 * (change_dc ?
737
42.5M
                (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
738
42.5M
                 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
739
72.7M
                (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
740
72.7M
          if (num >= 0) {
741
47.0M
            pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
742
47.0M
            if (Al > 0 && pred >= (1 << Al))
743
4.31M
              pred = (1 << Al) - 1;
744
47.0M
          } else {
745
25.7M
            pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
746
25.7M
            if (Al > 0 && pred >= (1 << Al))
747
4.34M
              pred = (1 << Al) - 1;
748
25.7M
            pred = -pred;
749
25.7M
          }
750
72.7M
          workspace[2] = (JCOEF)pred;
751
72.7M
        }
752
79.1M
        if (change_dc) {
753
          /* AC03 */
754
42.5M
          if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
755
42.5M
            num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
756
42.5M
            if (num >= 0) {
757
34.8M
              pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
758
34.8M
              if (Al > 0 && pred >= (1 << Al))
759
0
                pred = (1 << Al) - 1;
760
34.8M
            } else {
761
7.70M
              pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
762
7.70M
              if (Al > 0 && pred >= (1 << Al))
763
0
                pred = (1 << Al) - 1;
764
7.70M
              pred = -pred;
765
7.70M
            }
766
42.5M
            workspace[3] = (JCOEF)pred;
767
42.5M
          }
768
          /* AC12 */
769
42.5M
          if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
770
42.5M
            num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
771
42.5M
            if (num >= 0) {
772
27.7M
              pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
773
27.7M
              if (Al > 0 && pred >= (1 << Al))
774
0
                pred = (1 << Al) - 1;
775
27.7M
            } else {
776
14.7M
              pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
777
14.7M
              if (Al > 0 && pred >= (1 << Al))
778
0
                pred = (1 << Al) - 1;
779
14.7M
              pred = -pred;
780
14.7M
            }
781
42.5M
            workspace[10] = (JCOEF)pred;
782
42.5M
          }
783
          /* AC21 */
784
42.5M
          if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
785
42.5M
            num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
786
42.5M
            if (num >= 0) {
787
27.1M
              pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
788
27.1M
              if (Al > 0 && pred >= (1 << Al))
789
0
                pred = (1 << Al) - 1;
790
27.1M
            } else {
791
15.3M
              pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
792
15.3M
              if (Al > 0 && pred >= (1 << Al))
793
0
                pred = (1 << Al) - 1;
794
15.3M
              pred = -pred;
795
15.3M
            }
796
42.5M
            workspace[17] = (JCOEF)pred;
797
42.5M
          }
798
          /* AC30 */
799
42.5M
          if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
800
42.5M
            num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
801
42.5M
            if (num >= 0) {
802
33.2M
              pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
803
33.2M
              if (Al > 0 && pred >= (1 << Al))
804
0
                pred = (1 << Al) - 1;
805
33.2M
            } else {
806
9.35M
              pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
807
9.35M
              if (Al > 0 && pred >= (1 << Al))
808
0
                pred = (1 << Al) - 1;
809
9.35M
              pred = -pred;
810
9.35M
            }
811
42.5M
            workspace[24] = (JCOEF)pred;
812
42.5M
          }
813
          /* coef_bits[0] is non-negative.  Otherwise this function would not
814
           * be called.
815
           */
816
42.5M
          num = Q00 *
817
42.5M
                (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
818
42.5M
                 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
819
42.5M
                 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
820
42.5M
                 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
821
42.5M
                 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
822
42.5M
          if (num >= 0) {
823
27.9M
            pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
824
27.9M
          } else {
825
14.6M
            pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
826
14.6M
            pred = -pred;
827
14.6M
          }
828
42.5M
          workspace[0] = (JCOEF)pred;
829
42.5M
        }  /* change_dc */
830
831
        /* OK, do the IDCT */
832
#ifdef WITH_PROFILE
833
        cinfo->master->start = getTime();
834
#endif
835
79.1M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
836
79.1M
                        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
79.1M
        DC01 = DC02;  DC02 = DC03;  DC03 = DC04;  DC04 = DC05;
843
79.1M
        DC06 = DC07;  DC07 = DC08;  DC08 = DC09;  DC09 = DC10;
844
79.1M
        DC11 = DC12;  DC12 = DC13;  DC13 = DC14;  DC14 = DC15;
845
79.1M
        DC16 = DC17;  DC17 = DC18;  DC18 = DC19;  DC19 = DC20;
846
79.1M
        DC21 = DC22;  DC22 = DC23;  DC23 = DC24;  DC24 = DC25;
847
79.1M
        buffer_ptr++, prev_block_row++, next_block_row++,
848
79.1M
          prev_prev_block_row++, next_next_block_row++;
849
79.1M
        output_col += compptr->_DCT_scaled_size;
850
79.1M
      }
851
13.8M
      output_ptr += compptr->_DCT_scaled_size;
852
13.8M
    }
853
8.70M
  }
854
855
5.27M
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
856
5.25M
    return JPEG_ROW_COMPLETED;
857
23.2k
  return JPEG_SCAN_COMPLETED;
858
5.27M
}
jdcoefct-12.c:decompress_smooth_data
Line
Count
Source
474
733k
{
475
733k
  my_coef_ptr coef = (my_coef_ptr)cinfo->coef;
476
733k
  JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1;
477
733k
  JDIMENSION block_num, last_block_column;
478
733k
  int ci, block_row, block_rows, access_rows, image_block_row,
479
733k
    image_block_rows;
480
733k
  JBLOCKARRAY buffer;
481
733k
  JBLOCKROW buffer_ptr, prev_prev_block_row, prev_block_row;
482
733k
  JBLOCKROW next_block_row, next_next_block_row;
483
733k
  _JSAMPARRAY output_ptr;
484
733k
  JDIMENSION output_col;
485
733k
  jpeg_component_info *compptr;
486
733k
  _inverse_DCT_method_ptr inverse_DCT;
487
733k
  boolean change_dc;
488
733k
  JCOEF *workspace;
489
733k
  int *coef_bits;
490
733k
  JQUANT_TBL *quanttbl;
491
733k
  JLONG Q00, Q01, Q02, Q03 = 0, Q10, Q11, Q12 = 0, Q20, Q21 = 0, Q30 = 0, num;
492
733k
  int DC01, DC02, DC03, DC04, DC05, DC06, DC07, DC08, DC09, DC10, DC11, DC12,
493
733k
      DC13, DC14, DC15, DC16, DC17, DC18, DC19, DC20, DC21, DC22, DC23, DC24,
494
733k
      DC25;
495
733k
  int Al, pred;
496
497
  /* Keep a local variable to avoid looking it up more than once */
498
733k
  workspace = coef->workspace;
499
500
  /* Force some input to be done if we are getting ahead of the input. */
501
733k
  while (cinfo->input_scan_number <= cinfo->output_scan_number &&
502
733k
         !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
1.72M
  for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
519
993k
       ci++, compptr++) {
520
    /* Don't bother to IDCT an uninteresting component. */
521
993k
    if (!compptr->component_needed)
522
89.8k
      continue;
523
    /* Count non-dummy DCT block rows in this iMCU row. */
524
903k
    if (cinfo->output_iMCU_row + 1 < last_iMCU_row) {
525
898k
      block_rows = compptr->v_samp_factor;
526
898k
      access_rows = block_rows * 3; /* this and next two iMCU rows */
527
898k
    } else if (cinfo->output_iMCU_row < last_iMCU_row) {
528
2.74k
      block_rows = compptr->v_samp_factor;
529
2.74k
      access_rows = block_rows * 2; /* this and next iMCU row */
530
2.98k
    } else {
531
      /* NB: can't use last_row_height here; it is input-side-dependent! */
532
2.98k
      block_rows = (int)(compptr->height_in_blocks % compptr->v_samp_factor);
533
2.98k
      if (block_rows == 0) block_rows = compptr->v_samp_factor;
534
2.98k
      access_rows = block_rows; /* this iMCU row only */
535
2.98k
    }
536
    /* Align the virtual buffer for this component. */
537
903k
    if (cinfo->output_iMCU_row > 1) {
538
897k
      access_rows += 2 * compptr->v_samp_factor; /* prior two iMCU rows too */
539
897k
      buffer = (*cinfo->mem->access_virt_barray)
540
897k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
541
897k
         (cinfo->output_iMCU_row - 2) * compptr->v_samp_factor,
542
897k
         (JDIMENSION)access_rows, FALSE);
543
897k
      buffer += 2 * compptr->v_samp_factor; /* point to current iMCU row */
544
897k
    } else if (cinfo->output_iMCU_row > 0) {
545
3.19k
      access_rows += compptr->v_samp_factor; /* prior iMCU row too */
546
3.19k
      buffer = (*cinfo->mem->access_virt_barray)
547
3.19k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
548
3.19k
         (cinfo->output_iMCU_row - 1) * compptr->v_samp_factor,
549
3.19k
         (JDIMENSION)access_rows, FALSE);
550
3.19k
      buffer += compptr->v_samp_factor; /* point to current iMCU row */
551
3.19k
    } else {
552
3.19k
      buffer = (*cinfo->mem->access_virt_barray)
553
3.19k
        ((j_common_ptr)cinfo, coef->whole_image[ci],
554
3.19k
         (JDIMENSION)0, (JDIMENSION)access_rows, FALSE);
555
3.19k
    }
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
903k
    if (cinfo->output_iMCU_row > cinfo->master->last_good_iMCU_row)
561
369k
      coef_bits =
562
369k
        coef->coef_bits_latch + ((ci + cinfo->num_components) * SAVED_COEFS);
563
534k
    else
564
534k
      coef_bits = coef->coef_bits_latch + (ci * SAVED_COEFS);
565
566
    /* We only do DC interpolation if no AC coefficient data is available. */
567
903k
    change_dc =
568
903k
      coef_bits[1] == -1 && coef_bits[2] == -1 && coef_bits[3] == -1 &&
569
713k
      coef_bits[4] == -1 && coef_bits[5] == -1 && coef_bits[6] == -1 &&
570
695k
      coef_bits[7] == -1 && coef_bits[8] == -1 && coef_bits[9] == -1;
571
572
903k
    quanttbl = compptr->quant_table;
573
903k
    Q00 = quanttbl->quantval[0];
574
903k
    Q01 = quanttbl->quantval[Q01_POS];
575
903k
    Q10 = quanttbl->quantval[Q10_POS];
576
903k
    Q20 = quanttbl->quantval[Q20_POS];
577
903k
    Q11 = quanttbl->quantval[Q11_POS];
578
903k
    Q02 = quanttbl->quantval[Q02_POS];
579
903k
    if (change_dc) {
580
674k
      Q03 = quanttbl->quantval[Q03_POS];
581
674k
      Q12 = quanttbl->quantval[Q12_POS];
582
674k
      Q21 = quanttbl->quantval[Q21_POS];
583
674k
      Q30 = quanttbl->quantval[Q30_POS];
584
674k
    }
585
903k
    inverse_DCT = cinfo->idct->_inverse_DCT[ci];
586
903k
    output_ptr = output_buf[ci];
587
    /* Loop over all DCT blocks to be processed. */
588
903k
    image_block_rows = block_rows * cinfo->total_iMCU_rows;
589
2.35M
    for (block_row = 0; block_row < block_rows; block_row++) {
590
1.45M
      image_block_row = cinfo->output_iMCU_row * block_rows + block_row;
591
1.45M
      buffer_ptr = buffer[block_row] + cinfo->master->first_MCU_col[ci];
592
593
1.45M
      if (image_block_row > 0)
594
1.45M
        prev_block_row =
595
1.45M
          buffer[block_row - 1] + cinfo->master->first_MCU_col[ci];
596
3.19k
      else
597
3.19k
        prev_block_row = buffer_ptr;
598
599
1.45M
      if (image_block_row > 1)
600
1.44M
        prev_prev_block_row =
601
1.44M
          buffer[block_row - 2] + cinfo->master->first_MCU_col[ci];
602
6.30k
      else
603
6.30k
        prev_prev_block_row = prev_block_row;
604
605
1.45M
      if (image_block_row < image_block_rows - 1)
606
1.45M
        next_block_row =
607
1.45M
          buffer[block_row + 1] + cinfo->master->first_MCU_col[ci];
608
2.98k
      else
609
2.98k
        next_block_row = buffer_ptr;
610
611
1.45M
      if (image_block_row < image_block_rows - 2)
612
1.45M
        next_next_block_row =
613
1.45M
          buffer[block_row + 2] + cinfo->master->first_MCU_col[ci];
614
5.09k
      else
615
5.09k
        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.45M
      DC01 = DC02 = DC03 = DC04 = DC05 = (int)prev_prev_block_row[0][0];
621
1.45M
      DC06 = DC07 = DC08 = DC09 = DC10 = (int)prev_block_row[0][0];
622
1.45M
      DC11 = DC12 = DC13 = DC14 = DC15 = (int)buffer_ptr[0][0];
623
1.45M
      DC16 = DC17 = DC18 = DC19 = DC20 = (int)next_block_row[0][0];
624
1.45M
      DC21 = DC22 = DC23 = DC24 = DC25 = (int)next_next_block_row[0][0];
625
1.45M
      output_col = 0;
626
1.45M
      last_block_column = compptr->width_in_blocks - 1;
627
1.45M
      for (block_num = cinfo->master->first_MCU_col[ci];
628
19.9M
           block_num <= cinfo->master->last_MCU_col[ci]; block_num++) {
629
        /* Fetch current DCT block into workspace so we can modify it. */
630
18.4M
        jcopy_block_row(buffer_ptr, (JBLOCKROW)workspace, (JDIMENSION)1);
631
        /* Update DC values */
632
18.4M
        if (block_num == cinfo->master->first_MCU_col[ci] &&
633
1.45M
            block_num < last_block_column) {
634
856k
          DC04 = DC05 = (int)prev_prev_block_row[1][0];
635
856k
          DC09 = DC10 = (int)prev_block_row[1][0];
636
856k
          DC14 = DC15 = (int)buffer_ptr[1][0];
637
856k
          DC19 = DC20 = (int)next_block_row[1][0];
638
856k
          DC24 = DC25 = (int)next_next_block_row[1][0];
639
856k
        }
640
18.4M
        if (block_num + 1 < last_block_column) {
641
16.2M
          DC05 = (int)prev_prev_block_row[2][0];
642
16.2M
          DC10 = (int)prev_block_row[2][0];
643
16.2M
          DC15 = (int)buffer_ptr[2][0];
644
16.2M
          DC20 = (int)next_block_row[2][0];
645
16.2M
          DC25 = (int)next_next_block_row[2][0];
646
16.2M
        }
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
18.4M
        if ((Al = coef_bits[1]) != 0 && workspace[1] == 0) {
659
17.8M
          num = Q00 * (change_dc ?
660
11.7M
                (-DC01 - DC02 + DC04 + DC05 - 3 * DC06 + 13 * DC07 -
661
11.7M
                 13 * DC09 + 3 * DC10 - 3 * DC11 + 38 * DC12 - 38 * DC14 +
662
11.7M
                 3 * DC15 - 3 * DC16 + 13 * DC17 - 13 * DC19 + 3 * DC20 -
663
11.7M
                 DC21 - DC22 + DC24 + DC25) :
664
17.8M
                (-7 * DC11 + 50 * DC12 - 50 * DC14 + 7 * DC15));
665
17.8M
          if (num >= 0) {
666
12.0M
            pred = (int)(((Q01 << 7) + num) / (Q01 << 8));
667
12.0M
            if (Al > 0 && pred >= (1 << Al))
668
1.05M
              pred = (1 << Al) - 1;
669
12.0M
          } else {
670
5.78M
            pred = (int)(((Q01 << 7) - num) / (Q01 << 8));
671
5.78M
            if (Al > 0 && pred >= (1 << Al))
672
921k
              pred = (1 << Al) - 1;
673
5.78M
            pred = -pred;
674
5.78M
          }
675
17.8M
          workspace[1] = (JCOEF)pred;
676
17.8M
        }
677
        /* AC10 */
678
18.4M
        if ((Al = coef_bits[2]) != 0 && workspace[8] == 0) {
679
17.8M
          num = Q00 * (change_dc ?
680
11.7M
                (-DC01 - 3 * DC02 - 3 * DC03 - 3 * DC04 - DC05 - DC06 +
681
11.7M
                 13 * DC07 + 38 * DC08 + 13 * DC09 - DC10 + DC16 -
682
11.7M
                 13 * DC17 - 38 * DC18 - 13 * DC19 + DC20 + DC21 +
683
11.7M
                 3 * DC22 + 3 * DC23 + 3 * DC24 + DC25) :
684
17.8M
                (-7 * DC03 + 50 * DC08 - 50 * DC18 + 7 * DC23));
685
17.8M
          if (num >= 0) {
686
11.3M
            pred = (int)(((Q10 << 7) + num) / (Q10 << 8));
687
11.3M
            if (Al > 0 && pred >= (1 << Al))
688
1.86M
              pred = (1 << Al) - 1;
689
11.3M
          } else {
690
6.43M
            pred = (int)(((Q10 << 7) - num) / (Q10 << 8));
691
6.43M
            if (Al > 0 && pred >= (1 << Al))
692
1.29M
              pred = (1 << Al) - 1;
693
6.43M
            pred = -pred;
694
6.43M
          }
695
17.8M
          workspace[8] = (JCOEF)pred;
696
17.8M
        }
697
        /* AC20 */
698
18.4M
        if ((Al = coef_bits[3]) != 0 && workspace[16] == 0) {
699
17.7M
          num = Q00 * (change_dc ?
700
11.7M
                (DC03 + 2 * DC07 + 7 * DC08 + 2 * DC09 - 5 * DC12 - 14 * DC13 -
701
11.7M
                 5 * DC14 + 2 * DC17 + 7 * DC18 + 2 * DC19 + DC23) :
702
17.7M
                (-DC03 + 13 * DC08 - 24 * DC13 + 13 * DC18 - DC23));
703
17.7M
          if (num >= 0) {
704
10.3M
            pred = (int)(((Q20 << 7) + num) / (Q20 << 8));
705
10.3M
            if (Al > 0 && pred >= (1 << Al))
706
1.69M
              pred = (1 << Al) - 1;
707
10.3M
          } else {
708
7.44M
            pred = (int)(((Q20 << 7) - num) / (Q20 << 8));
709
7.44M
            if (Al > 0 && pred >= (1 << Al))
710
1.70M
              pred = (1 << Al) - 1;
711
7.44M
            pred = -pred;
712
7.44M
          }
713
17.7M
          workspace[16] = (JCOEF)pred;
714
17.7M
        }
715
        /* AC11 */
716
18.4M
        if ((Al = coef_bits[4]) != 0 && workspace[9] == 0) {
717
17.7M
          num = Q00 * (change_dc ?
718
11.7M
                (-DC01 + DC05 + 9 * DC07 - 9 * DC09 - 9 * DC17 +
719
11.7M
                 9 * DC19 + DC21 - DC25) :
720
17.7M
                (DC10 + DC16 - 10 * DC17 + 10 * DC19 - DC02 - DC20 + DC22 -
721
6.00M
                 DC24 + DC04 - DC06 + 10 * DC07 - 10 * DC09));
722
17.7M
          if (num >= 0) {
723
12.8M
            pred = (int)(((Q11 << 7) + num) / (Q11 << 8));
724
12.8M
            if (Al > 0 && pred >= (1 << Al))
725
754k
              pred = (1 << Al) - 1;
726
12.8M
          } else {
727
4.93M
            pred = (int)(((Q11 << 7) - num) / (Q11 << 8));
728
4.93M
            if (Al > 0 && pred >= (1 << Al))
729
746k
              pred = (1 << Al) - 1;
730
4.93M
            pred = -pred;
731
4.93M
          }
732
17.7M
          workspace[9] = (JCOEF)pred;
733
17.7M
        }
734
        /* AC02 */
735
18.4M
        if ((Al = coef_bits[5]) != 0 && workspace[2] == 0) {
736
17.7M
          num = Q00 * (change_dc ?
737
11.7M
                (2 * DC07 - 5 * DC08 + 2 * DC09 + DC11 + 7 * DC12 - 14 * DC13 +
738
11.7M
                 7 * DC14 + DC15 + 2 * DC17 - 5 * DC18 + 2 * DC19) :
739
17.7M
                (-DC11 + 13 * DC12 - 24 * DC13 + 13 * DC14 - DC15));
740
17.7M
          if (num >= 0) {
741
10.4M
            pred = (int)(((Q02 << 7) + num) / (Q02 << 8));
742
10.4M
            if (Al > 0 && pred >= (1 << Al))
743
1.06M
              pred = (1 << Al) - 1;
744
10.4M
          } else {
745
7.32M
            pred = (int)(((Q02 << 7) - num) / (Q02 << 8));
746
7.32M
            if (Al > 0 && pred >= (1 << Al))
747
1.07M
              pred = (1 << Al) - 1;
748
7.32M
            pred = -pred;
749
7.32M
          }
750
17.7M
          workspace[2] = (JCOEF)pred;
751
17.7M
        }
752
18.4M
        if (change_dc) {
753
          /* AC03 */
754
11.7M
          if ((Al = coef_bits[6]) != 0 && workspace[3] == 0) {
755
11.7M
            num = Q00 * (DC07 - DC09 + 2 * DC12 - 2 * DC14 + DC17 - DC19);
756
11.7M
            if (num >= 0) {
757
8.11M
              pred = (int)(((Q03 << 7) + num) / (Q03 << 8));
758
8.11M
              if (Al > 0 && pred >= (1 << Al))
759
0
                pred = (1 << Al) - 1;
760
8.11M
            } else {
761
3.61M
              pred = (int)(((Q03 << 7) - num) / (Q03 << 8));
762
3.61M
              if (Al > 0 && pred >= (1 << Al))
763
0
                pred = (1 << Al) - 1;
764
3.61M
              pred = -pred;
765
3.61M
            }
766
11.7M
            workspace[3] = (JCOEF)pred;
767
11.7M
          }
768
          /* AC12 */
769
11.7M
          if ((Al = coef_bits[7]) != 0 && workspace[10] == 0) {
770
11.7M
            num = Q00 * (DC07 - 3 * DC08 + DC09 - DC17 + 3 * DC18 - DC19);
771
11.7M
            if (num >= 0) {
772
6.60M
              pred = (int)(((Q12 << 7) + num) / (Q12 << 8));
773
6.60M
              if (Al > 0 && pred >= (1 << Al))
774
0
                pred = (1 << Al) - 1;
775
6.60M
            } else {
776
5.13M
              pred = (int)(((Q12 << 7) - num) / (Q12 << 8));
777
5.13M
              if (Al > 0 && pred >= (1 << Al))
778
0
                pred = (1 << Al) - 1;
779
5.13M
              pred = -pred;
780
5.13M
            }
781
11.7M
            workspace[10] = (JCOEF)pred;
782
11.7M
          }
783
          /* AC21 */
784
11.7M
          if ((Al = coef_bits[8]) != 0 && workspace[17] == 0) {
785
11.7M
            num = Q00 * (DC07 - DC09 - 3 * DC12 + 3 * DC14 + DC17 - DC19);
786
11.7M
            if (num >= 0) {
787
6.44M
              pred = (int)(((Q21 << 7) + num) / (Q21 << 8));
788
6.44M
              if (Al > 0 && pred >= (1 << Al))
789
0
                pred = (1 << Al) - 1;
790
6.44M
            } else {
791
5.29M
              pred = (int)(((Q21 << 7) - num) / (Q21 << 8));
792
5.29M
              if (Al > 0 && pred >= (1 << Al))
793
0
                pred = (1 << Al) - 1;
794
5.29M
              pred = -pred;
795
5.29M
            }
796
11.7M
            workspace[17] = (JCOEF)pred;
797
11.7M
          }
798
          /* AC30 */
799
11.7M
          if ((Al = coef_bits[9]) != 0 && workspace[24] == 0) {
800
11.7M
            num = Q00 * (DC07 + 2 * DC08 + DC09 - DC17 - 2 * DC18 - DC19);
801
11.7M
            if (num >= 0) {
802
7.77M
              pred = (int)(((Q30 << 7) + num) / (Q30 << 8));
803
7.77M
              if (Al > 0 && pred >= (1 << Al))
804
0
                pred = (1 << Al) - 1;
805
7.77M
            } else {
806
3.96M
              pred = (int)(((Q30 << 7) - num) / (Q30 << 8));
807
3.96M
              if (Al > 0 && pred >= (1 << Al))
808
0
                pred = (1 << Al) - 1;
809
3.96M
              pred = -pred;
810
3.96M
            }
811
11.7M
            workspace[24] = (JCOEF)pred;
812
11.7M
          }
813
          /* coef_bits[0] is non-negative.  Otherwise this function would not
814
           * be called.
815
           */
816
11.7M
          num = Q00 *
817
11.7M
                (-2 * DC01 - 6 * DC02 - 8 * DC03 - 6 * DC04 - 2 * DC05 -
818
11.7M
                 6 * DC06 + 6 * DC07 + 42 * DC08 + 6 * DC09 - 6 * DC10 -
819
11.7M
                 8 * DC11 + 42 * DC12 + 152 * DC13 + 42 * DC14 - 8 * DC15 -
820
11.7M
                 6 * DC16 + 6 * DC17 + 42 * DC18 + 6 * DC19 - 6 * DC20 -
821
11.7M
                 2 * DC21 - 6 * DC22 - 8 * DC23 - 6 * DC24 - 2 * DC25);
822
11.7M
          if (num >= 0) {
823
6.89M
            pred = (int)(((Q00 << 7) + num) / (Q00 << 8));
824
6.89M
          } else {
825
4.84M
            pred = (int)(((Q00 << 7) - num) / (Q00 << 8));
826
4.84M
            pred = -pred;
827
4.84M
          }
828
11.7M
          workspace[0] = (JCOEF)pred;
829
11.7M
        }  /* change_dc */
830
831
        /* OK, do the IDCT */
832
#ifdef WITH_PROFILE
833
        cinfo->master->start = getTime();
834
#endif
835
18.4M
        (*inverse_DCT) (cinfo, compptr, (JCOEFPTR)workspace, output_ptr,
836
18.4M
                        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
18.4M
        DC01 = DC02;  DC02 = DC03;  DC03 = DC04;  DC04 = DC05;
843
18.4M
        DC06 = DC07;  DC07 = DC08;  DC08 = DC09;  DC09 = DC10;
844
18.4M
        DC11 = DC12;  DC12 = DC13;  DC13 = DC14;  DC14 = DC15;
845
18.4M
        DC16 = DC17;  DC17 = DC18;  DC18 = DC19;  DC19 = DC20;
846
18.4M
        DC21 = DC22;  DC22 = DC23;  DC23 = DC24;  DC24 = DC25;
847
18.4M
        buffer_ptr++, prev_block_row++, next_block_row++,
848
18.4M
          prev_prev_block_row++, next_next_block_row++;
849
18.4M
        output_col += compptr->_DCT_scaled_size;
850
18.4M
      }
851
1.45M
      output_ptr += compptr->_DCT_scaled_size;
852
1.45M
    }
853
903k
  }
854
855
733k
  if (++(cinfo->output_iMCU_row) < cinfo->total_iMCU_rows)
856
731k
    return JPEG_ROW_COMPLETED;
857
2.64k
  return JPEG_SCAN_COMPLETED;
858
733k
}
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
129k
{
870
129k
  my_coef_ptr coef;
871
872
129k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
873
24
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
874
875
129k
  coef = (my_coef_ptr)
876
129k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
877
129k
                                sizeof(my_coef_controller));
878
129k
  memset(coef, 0, sizeof(my_coef_controller));
879
129k
  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
880
129k
  coef->pub.start_input_pass = start_input_pass;
881
129k
  coef->pub.start_output_pass = start_output_pass;
882
129k
#ifdef BLOCK_SMOOTHING_SUPPORTED
883
129k
  coef->coef_bits_latch = NULL;
884
129k
#endif
885
886
  /* Create the coefficient buffer. */
887
129k
  if (need_full_buffer) {
888
97.5k
#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
97.5k
    int ci, access_rows;
893
97.5k
    jpeg_component_info *compptr;
894
895
287k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
896
189k
         ci++, compptr++) {
897
189k
      access_rows = compptr->v_samp_factor;
898
189k
#ifdef BLOCK_SMOOTHING_SUPPORTED
899
      /* If block smoothing could be used, need a bigger window */
900
189k
      if (cinfo->progressive_mode)
901
106k
        access_rows *= 5;
902
189k
#endif
903
189k
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
904
189k
        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
905
189k
         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
906
189k
                               (long)compptr->h_samp_factor),
907
189k
         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
908
189k
                               (long)compptr->v_samp_factor),
909
189k
         (JDIMENSION)access_rows);
910
189k
    }
911
97.5k
    coef->pub.consume_data = consume_data;
912
97.5k
    coef->pub._decompress_data = decompress_data;
913
97.5k
    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
914
#else
915
    ERREXIT(cinfo, JERR_NOT_COMPILED);
916
#endif
917
97.5k
  } else {
918
    /* We only need a single-MCU buffer. */
919
31.8k
    JBLOCKROW buffer;
920
31.8k
    int i;
921
922
31.8k
    buffer = (JBLOCKROW)
923
31.8k
      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
924
31.8k
                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
925
350k
    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
926
318k
      coef->MCU_buffer[i] = buffer + i;
927
318k
    }
928
31.8k
    coef->pub.consume_data = dummy_consume_data;
929
31.8k
    coef->pub._decompress_data = decompress_onepass;
930
31.8k
    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
931
31.8k
  }
932
933
  /* Allocate the workspace buffer */
934
129k
  coef->workspace = (JCOEF *)
935
129k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
936
129k
                                sizeof(JCOEF) * DCTSIZE2);
937
129k
}
jinit_d_coef_controller
Line
Count
Source
869
101k
{
870
101k
  my_coef_ptr coef;
871
872
101k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
873
24
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
874
875
101k
  coef = (my_coef_ptr)
876
101k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
877
101k
                                sizeof(my_coef_controller));
878
101k
  memset(coef, 0, sizeof(my_coef_controller));
879
101k
  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
880
101k
  coef->pub.start_input_pass = start_input_pass;
881
101k
  coef->pub.start_output_pass = start_output_pass;
882
101k
#ifdef BLOCK_SMOOTHING_SUPPORTED
883
101k
  coef->coef_bits_latch = NULL;
884
101k
#endif
885
886
  /* Create the coefficient buffer. */
887
101k
  if (need_full_buffer) {
888
75.1k
#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
75.1k
    int ci, access_rows;
893
75.1k
    jpeg_component_info *compptr;
894
895
222k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
896
147k
         ci++, compptr++) {
897
147k
      access_rows = compptr->v_samp_factor;
898
147k
#ifdef BLOCK_SMOOTHING_SUPPORTED
899
      /* If block smoothing could be used, need a bigger window */
900
147k
      if (cinfo->progressive_mode)
901
83.3k
        access_rows *= 5;
902
147k
#endif
903
147k
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
904
147k
        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
905
147k
         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
906
147k
                               (long)compptr->h_samp_factor),
907
147k
         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
908
147k
                               (long)compptr->v_samp_factor),
909
147k
         (JDIMENSION)access_rows);
910
147k
    }
911
75.1k
    coef->pub.consume_data = consume_data;
912
75.1k
    coef->pub._decompress_data = decompress_data;
913
75.1k
    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
914
#else
915
    ERREXIT(cinfo, JERR_NOT_COMPILED);
916
#endif
917
75.1k
  } else {
918
    /* We only need a single-MCU buffer. */
919
26.2k
    JBLOCKROW buffer;
920
26.2k
    int i;
921
922
26.2k
    buffer = (JBLOCKROW)
923
26.2k
      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
924
26.2k
                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
925
288k
    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
926
262k
      coef->MCU_buffer[i] = buffer + i;
927
262k
    }
928
26.2k
    coef->pub.consume_data = dummy_consume_data;
929
26.2k
    coef->pub._decompress_data = decompress_onepass;
930
26.2k
    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
931
26.2k
  }
932
933
  /* Allocate the workspace buffer */
934
101k
  coef->workspace = (JCOEF *)
935
101k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
936
101k
                                sizeof(JCOEF) * DCTSIZE2);
937
101k
}
j12init_d_coef_controller
Line
Count
Source
869
28.0k
{
870
28.0k
  my_coef_ptr coef;
871
872
28.0k
  if (cinfo->data_precision != BITS_IN_JSAMPLE)
873
0
    ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
874
875
28.0k
  coef = (my_coef_ptr)
876
28.0k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
877
28.0k
                                sizeof(my_coef_controller));
878
28.0k
  memset(coef, 0, sizeof(my_coef_controller));
879
28.0k
  cinfo->coef = (struct jpeg_d_coef_controller *)coef;
880
28.0k
  coef->pub.start_input_pass = start_input_pass;
881
28.0k
  coef->pub.start_output_pass = start_output_pass;
882
28.0k
#ifdef BLOCK_SMOOTHING_SUPPORTED
883
28.0k
  coef->coef_bits_latch = NULL;
884
28.0k
#endif
885
886
  /* Create the coefficient buffer. */
887
28.0k
  if (need_full_buffer) {
888
22.4k
#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
22.4k
    int ci, access_rows;
893
22.4k
    jpeg_component_info *compptr;
894
895
65.2k
    for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
896
42.8k
         ci++, compptr++) {
897
42.8k
      access_rows = compptr->v_samp_factor;
898
42.8k
#ifdef BLOCK_SMOOTHING_SUPPORTED
899
      /* If block smoothing could be used, need a bigger window */
900
42.8k
      if (cinfo->progressive_mode)
901
23.6k
        access_rows *= 5;
902
42.8k
#endif
903
42.8k
      coef->whole_image[ci] = (*cinfo->mem->request_virt_barray)
904
42.8k
        ((j_common_ptr)cinfo, JPOOL_IMAGE, TRUE,
905
42.8k
         (JDIMENSION)jround_up((long)compptr->width_in_blocks,
906
42.8k
                               (long)compptr->h_samp_factor),
907
42.8k
         (JDIMENSION)jround_up((long)compptr->height_in_blocks,
908
42.8k
                               (long)compptr->v_samp_factor),
909
42.8k
         (JDIMENSION)access_rows);
910
42.8k
    }
911
22.4k
    coef->pub.consume_data = consume_data;
912
22.4k
    coef->pub._decompress_data = decompress_data;
913
22.4k
    coef->pub.coef_arrays = coef->whole_image; /* link to virtual arrays */
914
#else
915
    ERREXIT(cinfo, JERR_NOT_COMPILED);
916
#endif
917
22.4k
  } else {
918
    /* We only need a single-MCU buffer. */
919
5.60k
    JBLOCKROW buffer;
920
5.60k
    int i;
921
922
5.60k
    buffer = (JBLOCKROW)
923
5.60k
      (*cinfo->mem->alloc_large) ((j_common_ptr)cinfo, JPOOL_IMAGE,
924
5.60k
                                  D_MAX_BLOCKS_IN_MCU * sizeof(JBLOCK));
925
61.6k
    for (i = 0; i < D_MAX_BLOCKS_IN_MCU; i++) {
926
56.0k
      coef->MCU_buffer[i] = buffer + i;
927
56.0k
    }
928
5.60k
    coef->pub.consume_data = dummy_consume_data;
929
5.60k
    coef->pub._decompress_data = decompress_onepass;
930
5.60k
    coef->pub.coef_arrays = NULL; /* flag for no virtual arrays */
931
5.60k
  }
932
933
  /* Allocate the workspace buffer */
934
28.0k
  coef->workspace = (JCOEF *)
935
28.0k
    (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE,
936
28.0k
                                sizeof(JCOEF) * DCTSIZE2);
937
28.0k
}