54 if (cinfo->block_size < 1 || cinfo->block_size > 16)
55 ERREXIT2(cinfo, JERR_BAD_DCTSIZE, cinfo->block_size, cinfo->block_size);
58 switch (cinfo->block_size) {
69 cinfo->lim_Se = cinfo->block_size <
DCTSIZE ?
70 cinfo->block_size * cinfo->block_size - 1 :
DCTSIZE2-1;
73 if (cinfo->jpeg_height <= 0 || cinfo->jpeg_width <= 0 ||
74 cinfo->num_components <= 0)
75 ERREXIT(cinfo, JERR_EMPTY_IMAGE);
83 if (cinfo->data_precision < 8 || cinfo->data_precision > 12)
84 ERREXIT1(cinfo, JERR_BAD_PRECISION, cinfo->data_precision);
88 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
92 cinfo->max_h_samp_factor = 1;
93 cinfo->max_v_samp_factor = 1;
94 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
98 ERREXIT(cinfo, JERR_BAD_SAMPLING);
99 cinfo->max_h_samp_factor =
MAX(cinfo->max_h_samp_factor,
101 cinfo->max_v_samp_factor =
MAX(cinfo->max_v_samp_factor,
106 for (ci = 0,
compptr = cinfo->comp_info; ci < cinfo->num_components;
116#ifdef DCT_SCALING_SUPPORTED
117 if (! cinfo->raw_data_in)
118 while (cinfo->min_DCT_h_scaled_size * ssize <=
127#ifdef DCT_SCALING_SUPPORTED
128 if (! cinfo->raw_data_in)
129 while (cinfo->min_DCT_v_scaled_size * ssize <=
147 (
long) (cinfo->max_h_samp_factor * cinfo->block_size));
150 (
long) (cinfo->max_v_samp_factor * cinfo->block_size));
155 (
long) (cinfo->max_h_samp_factor * cinfo->block_size));
159 (
long) (cinfo->max_v_samp_factor * cinfo->block_size));
171 (
long) (cinfo->max_v_samp_factor * cinfo->block_size));
175#ifdef C_MULTISCAN_FILES_SUPPORTED
184 int scanno, ncomps, ci, coefi, thisi;
187#ifdef C_PROGRESSIVE_SUPPORTED
188 int * last_bitpos_ptr;
194 ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, 0);
201#ifdef C_PROGRESSIVE_SUPPORTED
203 last_bitpos_ptr = & last_bitpos[0][0];
205 for (coefi = 0; coefi <
DCTSIZE2; coefi++)
206 *last_bitpos_ptr++ = -1;
208 ERREXIT(cinfo, JERR_NOT_COMPILED);
213 component_sent[ci] =
FALSE;
216 for (scanno = 1; scanno <= cinfo->
num_scans; scanptr++, scanno++) {
221 for (ci = 0; ci < ncomps; ci++) {
224 ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
226 if (ci > 0 && thisi <= scanptr->component_index[ci-1])
227 ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
235#ifdef C_PROGRESSIVE_SUPPORTED
246 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
249 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
252 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
254 for (ci = 0; ci < ncomps; ci++) {
256 if (Ss != 0 && last_bitpos_ptr[0] < 0)
257 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
258 for (coefi = Ss; coefi <= Se; coefi++) {
259 if (last_bitpos_ptr[coefi] < 0) {
262 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
265 if (Ah != last_bitpos_ptr[coefi] || Al != Ah-1)
266 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
268 last_bitpos_ptr[coefi] = Al;
274 if (Ss != 0 || Se !=
DCTSIZE2-1 || Ah != 0 || Al != 0)
275 ERREXIT1(cinfo, JERR_BAD_PROG_SCRIPT, scanno);
277 for (ci = 0; ci < ncomps; ci++) {
279 if (component_sent[thisi])
280 ERREXIT1(cinfo, JERR_BAD_SCAN_SCRIPT, scanno);
281 component_sent[thisi] =
TRUE;
288#ifdef C_PROGRESSIVE_SUPPORTED
295 if (last_bitpos[ci][0] < 0)
296 ERREXIT(cinfo, JERR_MISSING_DATA);
301 if (! component_sent[ci])
302 ERREXIT(cinfo, JERR_MISSING_DATA);
327 scanptr[idxout] = scanptr[idxin];
328 if (scanptr[idxout].Ss > cinfo->
lim_Se)
331 if (scanptr[idxout].Se > cinfo->
lim_Se)
349#ifdef C_MULTISCAN_FILES_SUPPORTED
350 if (cinfo->scan_info !=
NULL) {
357 cinfo->cur_comp_info[ci] =
360 if (cinfo->progressive_mode) {
361 cinfo->Ss = scanptr->
Ss;
362 cinfo->Se = scanptr->
Se;
363 cinfo->Ah = scanptr->
Ah;
364 cinfo->Al = scanptr->
Al;
373 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->num_components,
375 cinfo->comps_in_scan = cinfo->num_components;
376 for (ci = 0; ci < cinfo->num_components; ci++) {
377 cinfo->cur_comp_info[ci] = &cinfo->comp_info[ci];
381 cinfo->Se = cinfo->block_size * cinfo->block_size - 1;
392 int ci, mcublks, tmp;
395 if (cinfo->comps_in_scan == 1) {
398 compptr = cinfo->cur_comp_info[0];
418 cinfo->blocks_in_MCU = 1;
419 cinfo->MCU_membership[0] = 0;
425 ERREXIT2(cinfo, JERR_COMPONENT_COUNT, cinfo->comps_in_scan,
431 (
long) (cinfo->max_h_samp_factor * cinfo->block_size));
434 (
long) (cinfo->max_v_samp_factor * cinfo->block_size));
436 cinfo->blocks_in_MCU = 0;
438 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
439 compptr = cinfo->cur_comp_info[ci];
455 ERREXIT(cinfo, JERR_BAD_MCU_SIZE);
456 while (mcublks-- > 0) {
457 cinfo->MCU_membership[cinfo->blocks_in_MCU++] = ci;
465 if (cinfo->restart_in_rows > 0) {
466 long nominal = (
long) cinfo->restart_in_rows * (
long) cinfo->MCUs_per_row;
467 cinfo->restart_interval = (
unsigned int)
MIN(nominal, 65535L);
492 if (! cinfo->raw_data_in) {
493 (*cinfo->cconvert->start_pass) (cinfo);
494 (*cinfo->downsample->start_pass) (cinfo);
497 (*cinfo->fdct->start_pass) (cinfo);
498 (*cinfo->entropy->start_pass) (cinfo, cinfo->optimize_coding);
499 (*cinfo->coef->start_pass) (cinfo,
503 if (cinfo->optimize_coding) {
505 master->
pub.call_pass_startup =
FALSE;
508 master->
pub.call_pass_startup =
TRUE;
511#ifdef ENTROPY_OPT_SUPPORTED
516 if (cinfo->Ss != 0 || cinfo->Ah == 0) {
517 (*cinfo->entropy->start_pass) (cinfo,
TRUE);
519 master->
pub.call_pass_startup =
FALSE;
532 if (! cinfo->optimize_coding) {
536 (*cinfo->entropy->start_pass) (cinfo,
FALSE);
540 (*cinfo->marker->write_frame_header) (cinfo);
541 (*cinfo->marker->write_scan_header) (cinfo);
542 master->
pub.call_pass_startup =
FALSE;
545 ERREXIT(cinfo, JERR_NOT_COMPILED);
551 if (cinfo->progress !=
NULL) {
552 cinfo->progress->completed_passes = master->
pass_number;
571 cinfo->master->call_pass_startup =
FALSE;
573 (*cinfo->marker->write_frame_header) (cinfo);
574 (*cinfo->marker->write_scan_header) (cinfo);
590 (*cinfo->entropy->finish_pass) (cinfo);
599 if (! cinfo->optimize_coding)
608 if (cinfo->optimize_coding)
629 cinfo->master = &master->
pub;
638 if (cinfo->scan_info !=
NULL) {
639#ifdef C_MULTISCAN_FILES_SUPPORTED
640 validate_script(cinfo);
641 if (cinfo->block_size <
DCTSIZE)
642 reduce_script(cinfo);
644 ERREXIT(cinfo, JERR_NOT_COMPILED);
647 cinfo->progressive_mode =
FALSE;
648 cinfo->num_scans = 1;
651 if (cinfo->optimize_coding)
652 cinfo->arith_code =
FALSE;
653 else if (! cinfo->arith_code &&
654 (cinfo->progressive_mode ||
655 (cinfo->block_size > 1 && cinfo->block_size <
DCTSIZE)))
658 cinfo->optimize_coding =
TRUE;
663 if (cinfo->optimize_coding)
673 if (cinfo->optimize_coding)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
my_comp_master * my_master_ptr
pass_startup(j_compress_ptr cinfo)
per_scan_setup(j_compress_ptr cinfo)
jinit_c_master_control(j_compress_ptr cinfo, boolean transcode_only)
prepare_for_pass(j_compress_ptr cinfo)
finish_pass_master(j_compress_ptr cinfo)
select_scan_parameters(j_compress_ptr cinfo)
initial_setup(j_compress_ptr cinfo)
jpeg_component_info * compptr
#define ERREXIT1(cinfo, code, p1)
#define ERREXIT2(cinfo, code, p1, p2)
#define JPEG_MAX_DIMENSION
struct jpeg_common_struct * j_common_ptr
#define C_MAX_BLOCKS_IN_MCU
#define MAX_COMPS_IN_SCAN
jdiv_round_up(long a, long b)
const int jpeg_natural_order4[4 *4+16]
const int jpeg_natural_order[DCTSIZE2+16]
const int jpeg_natural_order2[2 *2+16]
const int jpeg_natural_order5[5 *5+16]
const int jpeg_natural_order7[7 *7+16]
const int jpeg_natural_order6[6 *6+16]
const int jpeg_natural_order3[3 *3+16]
JDIMENSION downsampled_height
JDIMENSION width_in_blocks
JDIMENSION height_in_blocks
JDIMENSION downsampled_width
const jpeg_scan_info * scan_info
int component_index[MAX_COMPS_IN_SCAN]
struct jpeg_comp_master pub