10 #define JPEG_INTERNALS 15 #ifdef D_PROGRESSIVE_SUPPORTED 35 #ifndef NO_STRUCT_ASSIGN 36 #define ASSIGN_STATE(dest, src) ((dest) = (src)) 38 #if MAX_COMPS_IN_SCAN == 4 39 #define ASSIGN_STATE(dest, src) \ 40 ((dest).EOBRUN = (src).EOBRUN, \ 41 (dest).last_dc_val[0] = (src).last_dc_val[0], \ 42 (dest).last_dc_val[1] = (src).last_dc_val[1], \ 43 (dest).last_dc_val[2] = (src).last_dc_val[2], \ 44 (dest).last_dc_val[3] = (src).last_dc_val[3]) 87 boolean is_DC_band, bad;
92 is_DC_band = (cinfo->Ss == 0);
98 if (cinfo->Se != 0) bad =
TRUE;
103 if (cinfo->Ss > cinfo->Se || cinfo->Se >=
DCTSIZE2) bad =
TRUE;
105 if (cinfo->comps_in_scan != 1) bad =
TRUE;
110 if (cinfo->Al != cinfo->Ah - 1) bad =
TRUE;
122 cinfo, JERR_BAD_PROGRESSION, cinfo->Ss, cinfo->Se, cinfo->Ah,
128 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
130 int cindex = cinfo->cur_comp_info[ci]->component_index;
131 coef_bit_ptr = &cinfo->coef_bits[cindex][0];
132 if (!is_DC_band && coef_bit_ptr[0] < 0)
133 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
134 for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++)
136 int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
137 if (cinfo->Ah != expected)
138 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
139 coef_bit_ptr[coefi] = cinfo->Al;
159 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
161 compptr = cinfo->cur_comp_info[ci];
188 entropy->bitstate.bits_left = 0;
189 entropy->bitstate.get_buffer = 0;
190 entropy->
pub.insufficient_data =
FALSE;
193 entropy->saved.
EOBRUN = 0;
206 #define HUFF_EXTEND(x, s) \ 207 ((x) < (1 << ((s)-1)) ? (x) + (((-1) << (s)) + 1) : (x)) 211 #define HUFF_EXTEND(x, s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) 214 {0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040,
215 0x0080, 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000};
218 {0, -1, -3, -7, -15, -31, -63, -127,
219 -255, -511, -1023, -2047, -4095, -8191, -16383, -32767};
236 cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
237 entropy->bitstate.bits_left = 0;
240 if (!(*cinfo->marker->read_restart_marker)(cinfo))
return FALSE;
243 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
246 entropy->saved.
EOBRUN = 0;
256 if (cinfo->unread_marker == 0) entropy->
pub.insufficient_data =
FALSE;
297 if (cinfo->restart_interval)
306 if (!entropy->
pub.insufficient_data)
314 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++)
316 block = MCU_data[blkn];
317 ci = cinfo->MCU_membership[blkn];
318 compptr = cinfo->cur_comp_info[ci];
333 s += state.last_dc_val[ci];
334 state.last_dc_val[ci] =
s;
337 (*block)[0] = (
JCOEF)(
s << Al);
369 if (cinfo->restart_interval)
378 if (!entropy->
pub.insufficient_data)
383 EOBRUN = entropy->saved.
EOBRUN;
393 tbl = entropy->ac_derived_tbl;
395 for (k = cinfo->Ss; k <= Se; k++)
435 entropy->saved.
EOBRUN = EOBRUN;
454 int p1 = 1 << cinfo->Al;
460 if (cinfo->restart_interval)
475 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++)
477 block = MCU_data[blkn];
504 int p1 = 1 << cinfo->Al;
505 int m1 = (-1) << cinfo->Al;
516 if (cinfo->restart_interval)
524 if (!entropy->
pub.insufficient_data)
528 EOBRUN = entropy->saved.
EOBRUN;
532 tbl = entropy->ac_derived_tbl;
558 WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
595 if ((*thiscoef & p1) == 0)
617 newnz_pos[num_newnz++] = pos;
638 if ((*thiscoef & p1) == 0)
654 entropy->saved.
EOBRUN = EOBRUN;
664 while (num_newnz > 0) (*block)[newnz_pos[--num_newnz]] = 0;
692 cinfo->coef_bits = (int(*)[
DCTSIZE2])(*cinfo->mem->alloc_small)(
695 coef_bit_ptr = &cinfo->coef_bits[0][0];
696 for (ci = 0; ci < cinfo->num_components; ci++)
697 for (i = 0; i <
DCTSIZE2; i++) *coef_bit_ptr++ = -1;
#define BITREAD_STATE_VARS
unsigned int restarts_to_go
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
decode_mcu_DC_first JPP((j_decompress_ptr cinfo, JBLOCKROW *MCU_data))
#define MAX_COMPS_IN_SCAN
const int jpeg_natural_order[]
struct jpeg_common_struct * j_common_ptr
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
#define WARNMS2(cinfo, code, p1, p2)
phuff_entropy_decoder * phuff_entropy_ptr
#define ERREXIT4(cinfo, code, p1, p2, p3, p4)
struct jpeg_entropy_encoder pub
#define CHECK_BIT_BUFFER(state, nbits, action)
static const int extend_test[16]
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
bitread_perm_state bitstate
process_restart(j_decompress_ptr cinfo)
#define WARNMS(cinfo, code)
start_pass_phuff_decoder(j_decompress_ptr cinfo)
jinit_phuff_decoder(j_decompress_ptr cinfo)
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
unsigned int restarts_to_go
#define BITREAD_SAVE_STATE(cinfop, permstate)
GLdouble GLdouble GLdouble r
static const int extend_offset[16]
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno, d_derived_tbl **pdtbl)
#define ASSIGN_STATE(dest, src)
#define BITREAD_LOAD_STATE(cinfop, permstate)
int last_dc_val[MAX_COMPS_IN_SCAN]
#define HUFF_EXTEND(x, s)
jpeg_component_info * compptr
d_derived_tbl * ac_derived_tbl