17 #define JPEG_INTERNALS
23 #ifdef D_PROGRESSIVE_SUPPORTED
42 #ifndef NO_STRUCT_ASSIGN
43 #define ASSIGN_STATE(dest,src) ((dest) = (src))
45 #if MAX_COMPS_IN_SCAN == 4
46 #define ASSIGN_STATE(dest,src) \
47 ((dest).EOBRUN = (src).EOBRUN, \
48 (dest).last_dc_val[0] = (src).last_dc_val[0], \
49 (dest).last_dc_val[1] = (src).last_dc_val[1], \
50 (dest).last_dc_val[2] = (src).last_dc_val[2], \
51 (dest).last_dc_val[3] = (src).last_dc_val[3])
66 unsigned int restarts_to_go;
72 } phuff_entropy_decoder;
95 boolean is_DC_band, bad;
100 is_DC_band = (cinfo->
Ss == 0);
115 if (cinfo->
Ah != 0) {
117 if (cinfo->
Al != cinfo->
Ah-1)
123 ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
124 cinfo->
Ss, cinfo->
Se, cinfo->
Ah, cinfo->
Al);
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++) {
135 int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
136 if (cinfo->
Ah != expected)
137 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
138 coef_bit_ptr[coefi] = cinfo->
Al;
143 if (cinfo->
Ah == 0) {
145 entropy->
pub.decode_mcu = decode_mcu_DC_first;
147 entropy->
pub.decode_mcu = decode_mcu_AC_first;
150 entropy->
pub.decode_mcu = decode_mcu_DC_refine;
152 entropy->
pub.decode_mcu = decode_mcu_AC_refine;
161 if (cinfo->
Ah == 0) {
165 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
170 tbl = compptr->ac_tbl_no;
173 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
184 entropy->bitstate.bits_left = 0;
185 entropy->bitstate.get_buffer = 0;
186 entropy->bitstate.printed_eod =
FALSE;
189 entropy->saved.
EOBRUN = 0;
203 #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x))
207 #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x))
209 static const int extend_test[16] =
210 { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
211 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
213 static const int extend_offset[16] =
214 { 0, ((-1)<<1) + 1, ((-1)<<2) + 1, ((-1)<<3) + 1, ((-1)<<4) + 1,
215 ((-1)<<5) + 1, ((-1)<<6) + 1, ((-1)<<7) + 1, ((-1)<<8) + 1,
216 ((-1)<<9) + 1, ((-1)<<10) + 1, ((-1)<<11) + 1, ((-1)<<12) + 1,
217 ((-1)<<13) + 1, ((-1)<<14) + 1, ((-1)<<15) + 1 };
236 entropy->bitstate.bits_left = 0;
246 entropy->saved.
EOBRUN = 0;
252 entropy->bitstate.printed_eod =
FALSE;
307 block = MCU_data[blkn];
323 s += state.last_dc_val[ci];
324 state.last_dc_val[ci] =
s;
326 (*block)[0] = (
JCOEF) (s << Al);
351 register int s, k,
r;
367 EOBRUN = entropy->saved.
EOBRUN;
376 tbl = entropy->ac_derived_tbl;
378 for (k = cinfo->
Ss; k <= Se; k++) {
409 entropy->saved.
EOBRUN = EOBRUN;
428 int p1 = 1 << cinfo->
Al;
446 block = MCU_data[blkn];
474 int p1 = 1 << cinfo->
Al;
475 int m1 = (-1) << cinfo->
Al;
476 register int s, k,
r;
494 EOBRUN = entropy->saved.
EOBRUN;
498 tbl = entropy->ac_derived_tbl;
512 for (; k <= Se; k++) {
513 HUFF_DECODE(s, br_state, tbl,
goto undoit, label3);
518 WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
542 if (*thiscoef != 0) {
545 if ((*thiscoef & p1) == 0) {
559 int pos = jpeg_natural_order[k];
561 (*block)[pos] = (
JCOEF) s;
563 newnz_pos[num_newnz++] = pos;
574 for (; k <= Se; k++) {
575 thiscoef = *block + jpeg_natural_order[k];
576 if (*thiscoef != 0) {
579 if ((*thiscoef & p1) == 0) {
594 entropy->saved.
EOBRUN = EOBRUN;
603 while (num_newnz > 0)
604 (*block)[newnz_pos[--num_newnz]] = 0;
623 SIZEOF(phuff_entropy_decoder));
625 entropy->
pub.start_pass = start_pass_phuff_decoder;
639 *coef_bit_ptr++ = -1;
#define BITREAD_STATE_VARS
unsigned int restarts_to_go
#define HUFF_EXTEND(x, s)
unsigned int discarded_bytes
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
const int jpeg_natural_order[]
struct jpeg_common_struct * j_common_ptr
struct jpeg_marker_reader * marker
#define ASSIGN_STATE(dest, src)
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
#define WARNMS2(cinfo, code, p1, p2)
#define ERREXIT4(cinfo, code, p1, p2, p3, p4)
struct jpeg_entropy_encoder pub
unsigned int restart_interval
GLOBAL void jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, JHUFF_TBL *htbl, d_derived_tbl **pdtbl)
#define CHECK_BIT_BUFFER(state, nbits, action)
phuff_entropy_encoder * phuff_entropy_ptr
#define WARNMS(cinfo, code)
#define ERREXIT1(cinfo, code, p1)
#define BITREAD_SAVE_STATE(cinfop, permstate)
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
GLdouble GLdouble GLdouble r
int MCU_membership[D_MAX_BLOCKS_IN_MCU]
LOCAL boolean process_restart(j_decompress_ptr cinfo)
#define BITREAD_LOAD_STATE(cinfop, permstate)
int(* coef_bits)[DCTSIZE2]
int last_dc_val[MAX_COMPS_IN_SCAN]
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
jpeg_marker_parser_method read_restart_marker
struct jpeg_entropy_decoder * entropy
#define MAX_COMPS_IN_SCAN