1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
27
28
29
30
31
32
33
34
35
38
39
40
45
46
47
48
51
52
53
54
55
56
57
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
193
194
195
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
249
250
255
260
265
270
275
280
285
290
295
300
305
310
315
320
325
330
334
335
336
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
519
520
521
522
523
524
525
526
527
528
529
530
531
536
537
538
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
611
612
613
614
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
658
659
660
661
/* ... */
#define JPEG_INTERNALS
#include "jinclude.h"
#include "jpeglib.h"
typedef struct {
struct jpeg_input_controller pub;
int inheaders;
...} my_input_controller;
typedef my_input_controller * my_inputctl_ptr;
METHODDEF(int) consume_markers JPP((j_decompress_ptr cinfo));
/* ... */
/* ... */
GLOBAL(void)
jpeg_core_output_dimensions (j_decompress_ptr cinfo)
/* ... */
{
#ifdef IDCT_SCALING_SUPPORTED
int ci;
jpeg_component_info *compptr;
if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 1;
cinfo->min_DCT_v_scaled_size = 1;
}if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 2L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 2L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 2;
cinfo->min_DCT_v_scaled_size = 2;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 2) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 3) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 3L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 3L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 3;
cinfo->min_DCT_v_scaled_size = 3;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 3) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 4L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 4L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 4;
cinfo->min_DCT_v_scaled_size = 4;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 4) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 5) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 5L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 5L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 5;
cinfo->min_DCT_v_scaled_size = 5;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 5) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 6) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 6L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 6L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 6;
cinfo->min_DCT_v_scaled_size = 6;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 6) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 7) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 7L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 7L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 7;
cinfo->min_DCT_v_scaled_size = 7;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 7) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 8L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 8L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 8;
cinfo->min_DCT_v_scaled_size = 8;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 8) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 9) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 9L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 9L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 9;
cinfo->min_DCT_v_scaled_size = 9;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 9) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 10) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 10L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 10L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 10;
cinfo->min_DCT_v_scaled_size = 10;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 10) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 11) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 11L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 11L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 11;
cinfo->min_DCT_v_scaled_size = 11;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 11) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 12) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 12L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 12L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 12;
cinfo->min_DCT_v_scaled_size = 12;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 12) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 13) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 13L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 13L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 13;
cinfo->min_DCT_v_scaled_size = 13;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 13) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 14) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 14L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 14L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 14;
cinfo->min_DCT_v_scaled_size = 14;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 14) { ... } else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 15) {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 15L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 15L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 15;
cinfo->min_DCT_v_scaled_size = 15;
}else if (cinfo->scale_num * cinfo->block_size <= cinfo->scale_denom * 15) { ... } else {
cinfo->output_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * 16L, (long) cinfo->block_size);
cinfo->output_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * 16L, (long) cinfo->block_size);
cinfo->min_DCT_h_scaled_size = 16;
cinfo->min_DCT_v_scaled_size = 16;
}else { ... }
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
compptr->DCT_h_scaled_size = cinfo->min_DCT_h_scaled_size;
compptr->DCT_v_scaled_size = cinfo->min_DCT_v_scaled_size;
}for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ... }
/* ... */
#else
cinfo->output_width = cinfo->image_width;
cinfo->output_height = cinfo->image_height;
/* ... */
/* ... */
#endif
...}
LOCAL(void)
initial_setup (j_decompress_ptr cinfo)
{
int ci;
jpeg_component_info *compptr;
if ((long) cinfo->image_height > (long) JPEG_MAX_DIMENSION ||
(long) cinfo->image_width > (long) JPEG_MAX_DIMENSION)
ERREXIT1(cinfo, JERR_IMAGE_TOO_BIG, (unsigned int) JPEG_MAX_DIMENSION);
if (cinfo->data_precision != BITS_IN_JSAMPLE)
ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
if (cinfo->num_components > MAX_COMPONENTS)
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
MAX_COMPONENTS);
cinfo->max_h_samp_factor = 1;
cinfo->max_v_samp_factor = 1;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
if (compptr->h_samp_factor<=0 || compptr->h_samp_factor>MAX_SAMP_FACTOR ||
compptr->v_samp_factor<=0 || compptr->v_samp_factor>MAX_SAMP_FACTOR)
ERREXIT(cinfo, JERR_BAD_SAMPLING);
cinfo->max_h_samp_factor = MAX(cinfo->max_h_samp_factor,
compptr->h_samp_factor);
cinfo->max_v_samp_factor = MAX(cinfo->max_v_samp_factor,
compptr->v_samp_factor);
}for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ... }
if (cinfo->is_baseline || (cinfo->progressive_mode &&
cinfo->comps_in_scan)) {
cinfo->block_size = DCTSIZE;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
}if (cinfo->is_baseline || (cinfo->progressive_mode && cinfo->comps_in_scan)) { ... } else
switch (cinfo->Se) {
case (1*1-1):
cinfo->block_size = 1;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = cinfo->Se;
break;case (1*1-1):
case (2*2-1):
cinfo->block_size = 2;
cinfo->natural_order = jpeg_natural_order2;
cinfo->lim_Se = cinfo->Se;
break;case (2*2-1):
case (3*3-1):
cinfo->block_size = 3;
cinfo->natural_order = jpeg_natural_order3;
cinfo->lim_Se = cinfo->Se;
break;case (3*3-1):
case (4*4-1):
cinfo->block_size = 4;
cinfo->natural_order = jpeg_natural_order4;
cinfo->lim_Se = cinfo->Se;
break;case (4*4-1):
case (5*5-1):
cinfo->block_size = 5;
cinfo->natural_order = jpeg_natural_order5;
cinfo->lim_Se = cinfo->Se;
break;case (5*5-1):
case (6*6-1):
cinfo->block_size = 6;
cinfo->natural_order = jpeg_natural_order6;
cinfo->lim_Se = cinfo->Se;
break;case (6*6-1):
case (7*7-1):
cinfo->block_size = 7;
cinfo->natural_order = jpeg_natural_order7;
cinfo->lim_Se = cinfo->Se;
break;case (7*7-1):
case (8*8-1):
cinfo->block_size = 8;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (8*8-1):
case (9*9-1):
cinfo->block_size = 9;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (9*9-1):
case (10*10-1):
cinfo->block_size = 10;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (10*10-1):
case (11*11-1):
cinfo->block_size = 11;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (11*11-1):
case (12*12-1):
cinfo->block_size = 12;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (12*12-1):
case (13*13-1):
cinfo->block_size = 13;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (13*13-1):
case (14*14-1):
cinfo->block_size = 14;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (14*14-1):
case (15*15-1):
cinfo->block_size = 15;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (15*15-1):
case (16*16-1):
cinfo->block_size = 16;
cinfo->natural_order = jpeg_natural_order;
cinfo->lim_Se = DCTSIZE2-1;
break;case (16*16-1):
default:
ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
break;default
}else switch (cinfo->Se) { ... }
/* ... */
cinfo->min_DCT_h_scaled_size = cinfo->block_size;
cinfo->min_DCT_v_scaled_size = cinfo->block_size;
for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;
ci++, compptr++) {
compptr->DCT_h_scaled_size = cinfo->block_size;
compptr->DCT_v_scaled_size = cinfo->block_size;
compptr->width_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
compptr->height_in_blocks = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
/* ... */
compptr->downsampled_width = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width * (long) compptr->h_samp_factor,
(long) cinfo->max_h_samp_factor);
compptr->downsampled_height = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height * (long) compptr->v_samp_factor,
(long) cinfo->max_v_samp_factor);
compptr->component_needed = TRUE;
compptr->quant_table = NULL;
}for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; ci++, compptr++) { ... }
cinfo->total_iMCU_rows = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height,
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
if (cinfo->comps_in_scan < cinfo->num_components || cinfo->progressive_mode)
cinfo->inputctl->has_multiple_scans = TRUE;
else
cinfo->inputctl->has_multiple_scans = FALSE;
...}
LOCAL(void)
per_scan_setup (j_decompress_ptr cinfo)
{
int ci, mcublks, tmp;
jpeg_component_info *compptr;
if (cinfo->comps_in_scan == 1) {
compptr = cinfo->cur_comp_info[0];
cinfo->MCUs_per_row = compptr->width_in_blocks;
cinfo->MCU_rows_in_scan = compptr->height_in_blocks;
compptr->MCU_width = 1;
compptr->MCU_height = 1;
compptr->MCU_blocks = 1;
compptr->MCU_sample_width = compptr->DCT_h_scaled_size;
compptr->last_col_width = 1;
/* ... */
tmp = (int) (compptr->height_in_blocks % compptr->v_samp_factor);
if (tmp == 0) tmp = compptr->v_samp_factor;
compptr->last_row_height = tmp;
cinfo->blocks_in_MCU = 1;
cinfo->MCU_membership[0] = 0;
}if (cinfo->comps_in_scan == 1) { ... } else {
if (cinfo->comps_in_scan <= 0 || cinfo->comps_in_scan > MAX_COMPS_IN_SCAN)
ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
MAX_COMPS_IN_SCAN);
cinfo->MCUs_per_row = (JDIMENSION)
jdiv_round_up((long) cinfo->image_width,
(long) (cinfo->max_h_samp_factor * cinfo->block_size));
cinfo->MCU_rows_in_scan = (JDIMENSION)
jdiv_round_up((long) cinfo->image_height,
(long) (cinfo->max_v_samp_factor * cinfo->block_size));
cinfo->blocks_in_MCU = 0;
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
compptr->MCU_width = compptr->h_samp_factor;
compptr->MCU_height = compptr->v_samp_factor;
compptr->MCU_blocks = compptr->MCU_width * compptr->MCU_height;
compptr->MCU_sample_width = compptr->MCU_width * compptr->DCT_h_scaled_size;
tmp = (int) (compptr->width_in_blocks % compptr->MCU_width);
if (tmp == 0) tmp = compptr->MCU_width;
compptr->last_col_width = tmp;
tmp = (int) (compptr->height_in_blocks % compptr->MCU_height);
if (tmp == 0) tmp = compptr->MCU_height;
compptr->last_row_height = tmp;
mcublks = compptr->MCU_blocks;
if (cinfo->blocks_in_MCU + mcublks > D_MAX_BLOCKS_IN_MCU)
ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
while (mcublks-- > 0) {
cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
}while (mcublks-- > 0) { ... }
}for (ci = 0; ci < cinfo->comps_in_scan; ci++) { ... }
}else { ... }
...}
/* ... */
LOCAL(void)
latch_quant_tables (j_decompress_ptr cinfo)
{
int ci, qtblno;
jpeg_component_info *compptr;
JQUANT_TBL * qtbl;
for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
compptr = cinfo->cur_comp_info[ci];
if (compptr->quant_table != NULL)
continue;
qtblno = compptr->quant_tbl_no;
if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||
cinfo->quant_tbl_ptrs[qtblno] == NULL)
ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);
qtbl = (JQUANT_TBL *)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,
SIZEOF(JQUANT_TBL));
MEMCOPY(qtbl, cinfo->quant_tbl_ptrs[qtblno], SIZEOF(JQUANT_TBL));
compptr->quant_table = qtbl;
}for (ci = 0; ci < cinfo->comps_in_scan; ci++) { ... }
}{ ... }
/* ... */
METHODDEF(void)
start_input_pass (j_decompress_ptr cinfo)
{
per_scan_setup(cinfo);
latch_quant_tables(cinfo);
(*cinfo->entropy->start_pass) (cinfo);
(*cinfo->coef->start_input_pass) (cinfo);
cinfo->inputctl->consume_input = cinfo->coef->consume_data;
}{ ... }
/* ... */
METHODDEF(void)
finish_input_pass (j_decompress_ptr cinfo)
{
cinfo->inputctl->consume_input = consume_markers;
}{ ... }
/* ... */
METHODDEF(int)
consume_markers (j_decompress_ptr cinfo)
{
my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
int val;
if (inputctl->pub.eoi_reached)
return JPEG_REACHED_EOI;
for (;;) {
val = (*cinfo->marker->read_markers) (cinfo);
switch (val) {
case JPEG_REACHED_SOS:
if (inputctl->inheaders) {
if (inputctl->inheaders == 1)
initial_setup(cinfo);
if (cinfo->comps_in_scan == 0) {
inputctl->inheaders = 2;
break;
}if (cinfo->comps_in_scan == 0) { ... }
inputctl->inheaders = 0;
/* ... */
}if (inputctl->inheaders) { ... } else {
if (! inputctl->pub.has_multiple_scans)
ERREXIT(cinfo, JERR_EOI_EXPECTED);
if (cinfo->comps_in_scan == 0)
break;
start_input_pass(cinfo);
}else { ... }
return val;case JPEG_REACHED_SOS:
case JPEG_REACHED_EOI:
inputctl->pub.eoi_reached = TRUE;
if (inputctl->inheaders) {
if (cinfo->marker->saw_SOF)
ERREXIT(cinfo, JERR_SOF_NO_SOS);
}if (inputctl->inheaders) { ... } else {
/* ... */
if (cinfo->output_scan_number > cinfo->input_scan_number)
cinfo->output_scan_number = cinfo->input_scan_number;
}else { ... }
return val;case JPEG_REACHED_EOI:
case JPEG_SUSPENDED:
return val;case JPEG_SUSPENDED:
default:
return val;default
}switch (val) { ... }
}for (;;) { ... }
}{ ... }
/* ... */
METHODDEF(void)
reset_input_controller (j_decompress_ptr cinfo)
{
my_inputctl_ptr inputctl = (my_inputctl_ptr) cinfo->inputctl;
inputctl->pub.consume_input = consume_markers;
inputctl->pub.has_multiple_scans = FALSE;
inputctl->pub.eoi_reached = FALSE;
inputctl->inheaders = 1;
(*cinfo->err->reset_error_mgr) ((j_common_ptr) cinfo);
(*cinfo->marker->reset_marker_reader) (cinfo);
cinfo->coef_bits = NULL;
}{ ... }
/* ... */
GLOBAL(void)
jinit_input_controller (j_decompress_ptr cinfo)
{
my_inputctl_ptr inputctl;
inputctl = (my_inputctl_ptr)
(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT,
SIZEOF(my_input_controller));
cinfo->inputctl = (struct jpeg_input_controller *) inputctl;
inputctl->pub.consume_input = consume_markers;
inputctl->pub.reset_input_controller = reset_input_controller;
inputctl->pub.start_input_pass = start_input_pass;
inputctl->pub.finish_input_pass = finish_input_pass;
/* ... */
inputctl->pub.has_multiple_scans = FALSE;
inputctl->pub.eoi_reached = FALSE;
inputctl->inheaders = 1;
}{ ... }