1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
73
74
75
76
77
78
79
80
81
82
83
84
85
86
93
94
95
96
97
103
104
105
106
107
108
109
110
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
163
164
165
170
171
172
173
174
175
176
177
178
179
183
184
185
186
187
188
189
190
191
192
196
197
198
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
251
252
253
254
255
265
266
271
272
273
274
275
/* ... */
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
LOCAL(boolean) output_pass_setup JPP((j_decompress_ptr cinfo));
/* ... */
GLOBAL(boolean)
jpeg_start_decompress (j_decompress_ptr cinfo)
{
if (cinfo->global_state == DSTATE_READY) {
jinit_master_decompress(cinfo);
if (cinfo->buffered_image) {
cinfo->global_state = DSTATE_BUFIMAGE;
return TRUE;
}if (cinfo->buffered_image) { ... }
cinfo->global_state = DSTATE_PRELOAD;
}if (cinfo->global_state == DSTATE_READY) { ... }
if (cinfo->global_state == DSTATE_PRELOAD) {
if (cinfo->inputctl->has_multiple_scans) {
#ifdef D_MULTISCAN_FILES_SUPPORTED
for (;;) {
int retcode;
if (cinfo->progress != NULL)
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
retcode = (*cinfo->inputctl->consume_input) (cinfo);
if (retcode == JPEG_SUSPENDED)
return FALSE;
if (retcode == JPEG_REACHED_EOI)
break;
if (cinfo->progress != NULL &&
(retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) {
if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) {
cinfo->progress->pass_limit += (long) cinfo->total_iMCU_rows;
}if (++cinfo->progress->pass_counter >= cinfo->progress->pass_limit) { ... }
}if (cinfo->progress != NULL && (retcode == JPEG_ROW_COMPLETED || retcode == JPEG_REACHED_SOS)) { ... }
}for (;;) { ... }
/* ... */#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
}if (cinfo->inputctl->has_multiple_scans) { ... }
cinfo->output_scan_number = cinfo->input_scan_number;
}if (cinfo->global_state == DSTATE_PRELOAD) { ... } else if (cinfo->global_state != DSTATE_PRESCAN)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
return output_pass_setup(cinfo);
}{ ... }
/* ... */
LOCAL(boolean)
output_pass_setup (j_decompress_ptr cinfo)
{
if (cinfo->global_state != DSTATE_PRESCAN) {
(*cinfo->master->prepare_for_output_pass) (cinfo);
cinfo->output_scanline = 0;
cinfo->global_state = DSTATE_PRESCAN;
}if (cinfo->global_state != DSTATE_PRESCAN) { ... }
while (cinfo->master->is_dummy_pass) {
#ifdef QUANT_2PASS_SUPPORTED
while (cinfo->output_scanline < cinfo->output_height) {
JDIMENSION last_scanline;
if (cinfo->progress != NULL) {
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
cinfo->progress->pass_limit = (long) cinfo->output_height;
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
}if (cinfo->progress != NULL) { ... }
last_scanline = cinfo->output_scanline;
(*cinfo->main->process_data) (cinfo, (JSAMPARRAY) NULL,
&cinfo->output_scanline, (JDIMENSION) 0);
if (cinfo->output_scanline == last_scanline)
return FALSE;
}while (cinfo->output_scanline < cinfo->output_height) { ... }
(*cinfo->master->finish_output_pass) (cinfo);
(*cinfo->master->prepare_for_output_pass) (cinfo);
cinfo->output_scanline = 0;/* ... */
#else
ERREXIT(cinfo, JERR_NOT_COMPILED);
#endif
}while (cinfo->master->is_dummy_pass) { ... }
/* ... */
cinfo->global_state = cinfo->raw_data_out ? DSTATE_RAW_OK : DSTATE_SCANNING;
return TRUE;
}{ ... }
/* ... */
GLOBAL(JDIMENSION)
jpeg_read_scanlines (j_decompress_ptr cinfo, JSAMPARRAY scanlines,
JDIMENSION max_lines)
{
JDIMENSION row_ctr;
if (cinfo->global_state != DSTATE_SCANNING)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (cinfo->output_scanline >= cinfo->output_height) {
WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
return 0;
}if (cinfo->output_scanline >= cinfo->output_height) { ... }
if (cinfo->progress != NULL) {
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
cinfo->progress->pass_limit = (long) cinfo->output_height;
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
}if (cinfo->progress != NULL) { ... }
row_ctr = 0;
(*cinfo->main->process_data) (cinfo, scanlines, &row_ctr, max_lines);
cinfo->output_scanline += row_ctr;
return row_ctr;
}{ ... }
/* ... */
GLOBAL(JDIMENSION)
jpeg_read_raw_data (j_decompress_ptr cinfo, JSAMPIMAGE data,
JDIMENSION max_lines)
{
JDIMENSION lines_per_iMCU_row;
if (cinfo->global_state != DSTATE_RAW_OK)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (cinfo->output_scanline >= cinfo->output_height) {
WARNMS(cinfo, JWRN_TOO_MUCH_DATA);
return 0;
}if (cinfo->output_scanline >= cinfo->output_height) { ... }
if (cinfo->progress != NULL) {
cinfo->progress->pass_counter = (long) cinfo->output_scanline;
cinfo->progress->pass_limit = (long) cinfo->output_height;
(*cinfo->progress->progress_monitor) ((j_common_ptr) cinfo);
}if (cinfo->progress != NULL) { ... }
lines_per_iMCU_row = cinfo->max_v_samp_factor * cinfo->min_DCT_v_scaled_size;
if (max_lines < lines_per_iMCU_row)
ERREXIT(cinfo, JERR_BUFFER_SIZE);
if (! (*cinfo->coef->decompress_data) (cinfo, data))
return 0;
cinfo->output_scanline += lines_per_iMCU_row;
return lines_per_iMCU_row;
}{ ... }
#ifdef D_MULTISCAN_FILES_SUPPORTED
/* ... */
GLOBAL(boolean)
jpeg_start_output (j_decompress_ptr cinfo, int scan_number)
{
if (cinfo->global_state != DSTATE_BUFIMAGE &&
cinfo->global_state != DSTATE_PRESCAN)
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
if (scan_number <= 0)
scan_number = 1;
if (cinfo->inputctl->eoi_reached &&
scan_number > cinfo->input_scan_number)
scan_number = cinfo->input_scan_number;
cinfo->output_scan_number = scan_number;
return output_pass_setup(cinfo);
}jpeg_start_output (j_decompress_ptr cinfo, int scan_number) { ... }
/* ... */
GLOBAL(boolean)
jpeg_finish_output (j_decompress_ptr cinfo)
{
if ((cinfo->global_state == DSTATE_SCANNING ||
cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) {
(*cinfo->master->finish_output_pass) (cinfo);
cinfo->global_state = DSTATE_BUFPOST;
}if ((cinfo->global_state == DSTATE_SCANNING || cinfo->global_state == DSTATE_RAW_OK) && cinfo->buffered_image) { ... } else if (cinfo->global_state != DSTATE_BUFPOST) {
ERREXIT1(cinfo, JERR_BAD_STATE, cinfo->global_state);
}else if (cinfo->global_state != DSTATE_BUFPOST) { ... }
while (cinfo->input_scan_number <= cinfo->output_scan_number &&
! cinfo->inputctl->eoi_reached) {
if ((*cinfo->inputctl->consume_input) (cinfo) == JPEG_SUSPENDED)
return FALSE;
}while (cinfo->input_scan_number <= cinfo->output_scan_number && ! cinfo->inputctl->eoi_reached) { ... }
cinfo->global_state = DSTATE_BUFIMAGE;
return TRUE;
}jpeg_finish_output (j_decompress_ptr cinfo) { ... }
/* ... */
#endif