10 #define JPEG_INTERNALS 16 #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]) 88 boolean is_DC_band, bad;
93 is_DC_band = (cinfo->Ss == 0);
102 if (cinfo->Ss > cinfo->Se || cinfo->Se >=
DCTSIZE2)
105 if (cinfo->comps_in_scan != 1)
108 if (cinfo->Ah != 0) {
110 if (cinfo->Al != cinfo->Ah-1)
122 ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
123 cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
128 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
129 int cindex = cinfo->cur_comp_info[ci]->component_index;
130 coef_bit_ptr = & cinfo->coef_bits[cindex][0];
131 if (!is_DC_band && coef_bit_ptr[0] < 0)
132 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
133 for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
134 int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
135 if (cinfo->Ah != expected)
136 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
137 coef_bit_ptr[coefi] = cinfo->Al;
142 if (cinfo->Ah == 0) {
154 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
155 compptr = cinfo->cur_comp_info[ci];
160 if (cinfo->Ah == 0) {
177 entropy->bitstate.bits_left = 0;
178 entropy->bitstate.get_buffer = 0;
179 entropy->
pub.insufficient_data =
FALSE;
182 entropy->saved.
EOBRUN = 0;
196 #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) 200 #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) 203 { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
204 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
207 { 0, -1, -3, -7, -15, -31, -63, -127, -255, -511, -1023, -2047, -4095, -8191, -16383, -32767 };
225 cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
226 entropy->bitstate.bits_left = 0;
229 if (! (*cinfo->marker->read_restart_marker) (cinfo))
233 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
236 entropy->saved.
EOBRUN = 0;
246 if (cinfo->unread_marker == 0)
247 entropy->
pub.insufficient_data =
FALSE;
289 if (cinfo->restart_interval) {
298 if (! entropy->
pub.insufficient_data) {
306 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
308 ci = cinfo->MCU_membership[blkn];
309 compptr = cinfo->cur_comp_info[ci];
323 s += state.last_dc_val[ci];
324 state.last_dc_val[ci] =
s;
326 (*block)[0] = (
JCOEF) (
s << Al);
359 if (cinfo->restart_interval) {
368 if (! entropy->
pub.insufficient_data) {
373 EOBRUN = entropy->saved.
EOBRUN;
382 tbl = entropy->ac_derived_tbl;
384 for (k = cinfo->Ss; k <= Se; k++) {
415 entropy->saved.
EOBRUN = EOBRUN;
435 int p1 = 1 << cinfo->Al;
441 if (cinfo->restart_interval) {
456 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
485 int p1 = 1 << cinfo->Al;
486 int m1 = (-1) << cinfo->Al;
497 if (cinfo->restart_interval) {
505 if (! entropy->
pub.insufficient_data) {
509 EOBRUN = entropy->saved.
EOBRUN;
513 tbl = entropy->ac_derived_tbl;
527 for (; k <= Se; k++) {
533 WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
557 if (*thiscoef != 0) {
560 if ((*thiscoef & p1) == 0) {
576 (*block)[pos] = (
JCOEF)
s;
578 newnz_pos[num_newnz++] = pos;
589 for (; k <= Se; k++) {
591 if (*thiscoef != 0) {
594 if ((*thiscoef & p1) == 0) {
609 entropy->saved.
EOBRUN = EOBRUN;
619 while (num_newnz > 0)
620 (*block)[newnz_pos[--num_newnz]] = 0;
649 cinfo->coef_bits = (int (*)[
DCTSIZE2])
652 coef_bit_ptr = & cinfo->coef_bits[0][0];
653 for (ci = 0; ci < cinfo->num_components; ci++)
655 *coef_bit_ptr++ = -1;
#define BITREAD_STATE_VARS
unsigned int restarts_to_go
decode_mcu_DC_first(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)
jpeg_component_info * compptr
#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]
METHODDEF(boolean) decode_mcu_DC_first JPP((j_decompress_ptr cinfo
#define HUFF_EXTEND(x, s)
d_derived_tbl * ac_derived_tbl