10 #define JPEG_INTERNALS 32 #ifndef NO_STRUCT_ASSIGN 33 #define ASSIGN_STATE(dest,src) ((dest) = (src)) 35 #if MAX_COMPS_IN_SCAN == 4 36 #define ASSIGN_STATE(dest,src) \ 37 ((dest).last_dc_val[0] = (src).last_dc_val[0], \ 38 (dest).last_dc_val[1] = (src).last_dc_val[1], \ 39 (dest).last_dc_val[2] = (src).last_dc_val[2], \ 40 (dest).last_dc_val[3] = (src).last_dc_val[3]) 82 int ci, blkn, dctbl, actbl;
89 if (cinfo->Ss != 0 || cinfo->Se !=
DCTSIZE2-1 ||
90 cinfo->Ah != 0 || cinfo->Al != 0)
91 WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
93 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
94 compptr = cinfo->cur_comp_info[ci];
108 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
109 ci = cinfo->MCU_membership[blkn];
110 compptr = cinfo->cur_comp_info[ci];
116 entropy->dc_needed[blkn] =
TRUE;
120 entropy->dc_needed[blkn] = entropy->ac_needed[blkn] =
FALSE;
125 entropy->bitstate.bits_left = 0;
126 entropy->bitstate.get_buffer = 0;
127 entropy->
pub.insufficient_data =
FALSE;
147 int p, i, l, si, numsymbols;
150 unsigned int huffcode[257];
161 isDC ? cinfo->dc_huff_tbl_ptrs[
tblno] : cinfo->ac_huff_tbl_ptrs[
tblno];
176 for (l = 1; l <= 16; l++) {
178 if (i < 0 || p + i > 256)
179 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
181 huffsize[
p++] = (char) l;
192 while (huffsize[
p]) {
193 while (((
int) huffsize[
p]) == si) {
194 huffcode[
p++] =
code;
201 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
209 for (l = 1; l <= 16; l++) {
234 for (i = 1; i <= (int)
htbl->
bits[l]; i++,
p++) {
253 for (i = 0; i < numsymbols; i++) {
255 if (sym < 0 || sym > 15)
256 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
278 #define MIN_GET_BITS 15 280 #define MIN_GET_BITS (BIT_BUF_SIZE-7) 291 const JOCTET * next_input_byte = state->next_input_byte;
292 size_t bytes_in_buffer = state->bytes_in_buffer;
304 if (bytes_in_buffer == 0) {
305 if (! (*cinfo->
src->fill_input_buffer) (cinfo))
321 if (bytes_in_buffer == 0) {
322 if (! (*cinfo->
src->fill_input_buffer) (cinfo))
366 WARNMS(cinfo, JWRN_HIT_MARKER);
376 state->next_input_byte = next_input_byte;
377 state->bytes_in_buffer = bytes_in_buffer;
421 WARNMS(state->cinfo, JWRN_HUFF_BAD_CODE);
436 #define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) + (((-1)<<(s)) + 1) : (x)) 440 #define HUFF_EXTEND(x,s) ((x) < extend_test[s] ? (x) + extend_offset[s] : (x)) 443 { 0, 0x0001, 0x0002, 0x0004, 0x0008, 0x0010, 0x0020, 0x0040, 0x0080,
444 0x0100, 0x0200, 0x0400, 0x0800, 0x1000, 0x2000, 0x4000 };
447 { 0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023,-2047,-4095,-8191,-16383,-32767 };
465 cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
466 entropy->bitstate.bits_left = 0;
469 if (! (*cinfo->marker->read_restart_marker) (cinfo))
473 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
484 if (cinfo->unread_marker == 0)
485 entropy->
pub.insufficient_data =
FALSE;
515 if (cinfo->restart_interval) {
524 if (! entropy->
pub.insufficient_data) {
532 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
548 if (entropy->dc_needed[blkn]) {
550 int ci = cinfo->MCU_membership[blkn];
551 s += state.last_dc_val[ci];
552 state.last_dc_val[ci] =
s;
557 if (entropy->ac_needed[blkn]) {
#define HUFF_EXTEND(x, s)
#define BITREAD_STATE_VARS
#define ASSIGN_STATE(dest, src)
unsigned int restarts_to_go
UINT8 look_sym[1<< HUFF_LOOKAHEAD]
boolean int c_derived_tbl ** pdtbl
static const int extend_test[16]
jpeg_huff_decode(bitread_working_state *state, bit_buf_type get_buffer, int bits_left, d_derived_tbl *htbl, int min_bits)
int look_nbits[1<< HUFF_LOOKAHEAD]
#define MAX_COMPS_IN_SCAN
jpeg_fill_bit_buffer(bitread_working_state *state, bit_buf_type get_buffer, int bits_left, int nbits)
static const int extend_offset[16]
#define D_MAX_BLOCKS_IN_MCU
const int jpeg_natural_order[]
bit_buf_type int d_derived_tbl int min_bits
start_pass_huff_decoder(j_decompress_ptr cinfo)
struct jpeg_common_struct * j_common_ptr
bit_buf_type int bits_left
#define ERREXIT(cinfo, code)
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
jpeg_component_info * compptr
bitread_perm_state bitstate
c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]
jinit_huff_decoder(j_decompress_ptr cinfo)
bit_buf_type int int nbits
#define CHECK_BIT_BUFFER(state, nbits, action)
struct jpeg_entropy_encoder pub
#define WARNMS(cinfo, code)
huff_entropy_decoder * huff_entropy_ptr
#define ERREXIT1(cinfo, code, p1)
#define BITREAD_SAVE_STATE(cinfop, permstate)
GLdouble GLdouble GLdouble r
struct jpeg_source_mgr * src
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno, d_derived_tbl **pdtbl)
int last_dc_val[MAX_COMPS_IN_SCAN]
#define BITREAD_LOAD_STATE(cinfop, permstate)
unsigned int restarts_to_go
boolean insufficient_data
const JOCTET * next_input_byte
c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]
struct jpeg_entropy_decoder * entropy
process_restart(j_decompress_ptr cinfo)
#define MEMZERO(target, size)