26#define HUFF_LOOKAHEAD 8
70#define BIT_BUF_SIZE 32
99#define BITREAD_STATE_VARS \
100 register bit_buf_type get_buffer; \
101 register int bits_left; \
102 bitread_working_state br_state
104#define BITREAD_LOAD_STATE(cinfop,permstate) \
105 br_state.cinfo = cinfop; \
106 br_state.next_input_byte = cinfop->src->next_input_byte; \
107 br_state.bytes_in_buffer = cinfop->src->bytes_in_buffer; \
108 get_buffer = permstate.get_buffer; \
109 bits_left = permstate.bits_left;
111#define BITREAD_SAVE_STATE(cinfop,permstate) \
112 cinfop->src->next_input_byte = br_state.next_input_byte; \
113 cinfop->src->bytes_in_buffer = br_state.bytes_in_buffer; \
114 permstate.get_buffer = get_buffer; \
115 permstate.bits_left = bits_left
135#define CHECK_BIT_BUFFER(state,nbits,action) \
136 { if (bits_left < (nbits)) { \
137 if (! jpeg_fill_bit_buffer(&(state),get_buffer,bits_left,nbits)) \
139 get_buffer = (state).get_buffer; bits_left = (state).bits_left; } }
141#define GET_BITS(nbits) \
142 (((int) (get_buffer >> (bits_left -= (nbits)))) & BIT_MASK(nbits))
144#define PEEK_BITS(nbits) \
145 (((int) (get_buffer >> (bits_left - (nbits)))) & BIT_MASK(nbits))
147#define DROP_BITS(nbits) \
148 (bits_left -= (nbits))
168#define HUFF_DECODE(result,state,htbl,failaction,slowlabel) \
169{ register int nb, look; \
170 if (bits_left < HUFF_LOOKAHEAD) { \
171 if (! jpeg_fill_bit_buffer(&state,get_buffer,bits_left, 0)) {failaction;} \
172 get_buffer = state.get_buffer; bits_left = state.bits_left; \
173 if (bits_left < HUFF_LOOKAHEAD) { \
174 nb = 1; goto slowlabel; \
177 look = PEEK_BITS(HUFF_LOOKAHEAD); \
178 if ((nb = htbl->look_nbits[look]) != 0) { \
180 result = htbl->look_sym[look]; \
182 nb = HUFF_LOOKAHEAD+1; \
184 if ((result=jpeg_huff_decode(&state,get_buffer,bits_left,htbl,nb)) < 0) \
186 get_buffer = state.get_buffer; bits_left = state.bits_left; \
208#ifndef NO_STRUCT_ASSIGN
209#define ASSIGN_STATE(dest,src) ((dest) = (src))
211#if MAX_COMPS_IN_SCAN == 4
212#define ASSIGN_STATE(dest,src) \
213 ((dest).EOBRUN = (src).EOBRUN, \
214 (dest).last_dc_val[0] = (src).last_dc_val[0], \
215 (dest).last_dc_val[1] = (src).last_dc_val[1], \
216 (dest).last_dc_val[2] = (src).last_dc_val[2], \
217 (dest).last_dc_val[3] = (src).last_dc_val[3])
261 { 0, 1, 5, 6, 14, 15, 27, 28 },
262 { 2, 4, 7, 13, 16, 26, 29, 42 },
263 { 3, 8, 12, 17, 25, 30, 41, 43 },
264 { 9, 11, 18, 24, 31, 40, 44, 53 },
265 { 10, 19, 23, 32, 39, 45, 52, 54 },
266 { 20, 22, 33, 38, 46, 51, 55, 60 },
267 { 21, 34, 37, 47, 50, 56, 59, 61 },
268 { 35, 36, 48, 49, 57, 58, 62, 63 }
272 { 0, 1, 5, 6, 14, 15, 27 },
273 { 2, 4, 7, 13, 16, 26, 28 },
274 { 3, 8, 12, 17, 25, 29, 38 },
275 { 9, 11, 18, 24, 30, 37, 39 },
276 { 10, 19, 23, 31, 36, 40, 45 },
277 { 20, 22, 32, 35, 41, 44, 46 },
278 { 21, 33, 34, 42, 43, 47, 48 }
282 { 0, 1, 5, 6, 14, 15 },
283 { 2, 4, 7, 13, 16, 25 },
284 { 3, 8, 12, 17, 24, 26 },
285 { 9, 11, 18, 23, 27, 32 },
286 { 10, 19, 22, 28, 31, 33 },
287 { 20, 21, 29, 30, 34, 35 }
293 { 3, 8, 12, 16, 21 },
294 { 9, 11, 17, 20, 22 },
295 { 10, 18, 19, 23, 24 }
328 int p,
i,
l, si, numsymbols;
331 unsigned int huffcode[257];
342 isDC ? cinfo->dc_huff_tbl_ptrs[
tblno] : cinfo->ac_huff_tbl_ptrs[
tblno];
356 for (
l = 1;
l <= 16;
l++) {
358 if (i < 0 || p + i > 256)
359 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
372 while (huffsize[
p]) {
373 while (((
int) huffsize[
p]) == si) {
374 huffcode[
p++] =
code;
381 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
389 for (
l = 1;
l <= 16;
l++) {
433 for (
i = 0;
i < numsymbols;
i++) {
435 if (sym < 0 || sym > 15)
436 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
457#define MIN_GET_BITS 15
459#define MIN_GET_BITS (BIT_BUF_SIZE-7)
470 register const JOCTET * next_input_byte =
state->next_input_byte;
471 register size_t bytes_in_buffer =
state->bytes_in_buffer;
483 if (bytes_in_buffer == 0) {
484 if (! (*cinfo->
src->fill_input_buffer) (cinfo))
486 next_input_byte = cinfo->
src->next_input_byte;
487 bytes_in_buffer = cinfo->
src->bytes_in_buffer;
500 if (bytes_in_buffer == 0) {
501 if (! (*cinfo->
src->fill_input_buffer) (cinfo))
503 next_input_byte = cinfo->
src->next_input_byte;
504 bytes_in_buffer = cinfo->
src->bytes_in_buffer;
538 if (nbits > bits_left) {
545 WARNMS(cinfo, JWRN_HIT_MARKER);
555 state->next_input_byte = next_input_byte;
556 state->bytes_in_buffer = bytes_in_buffer;
558 state->bits_left = bits_left;
571#define BIT_MASK(nbits) ((1<<(nbits))-1)
572#define HUFF_EXTEND(x,s) ((x) < (1<<((s)-1)) ? (x) - ((1<<(s))-1) : (x))
576#define BIT_MASK(nbits) bmask[nbits]
577#define HUFF_EXTEND(x,s) ((x) <= bmask[(s) - 1] ? (x) - bmask[s] : (x))
580 { 0, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF,
581 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF };
595 register int l = min_bits;
607 while (
code > htbl->maxcode[
l]) {
616 state->bits_left = bits_left;
625 return htbl->pub->huffval[ (
int) (
code + htbl->valoffset[
l]) ];
640 cinfo->marker->discarded_bytes += entropy->bitstate.bits_left / 8;
641 entropy->bitstate.bits_left = 0;
659 if (! (*cinfo->marker->read_restart_marker) (cinfo))
663 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
676 if (cinfo->unread_marker == 0)
677 entropy->insufficient_data =
FALSE;
720 if (cinfo->restart_interval) {
729 if (! entropy->insufficient_data) {
737 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
738 block = MCU_data[blkn];
739 ci = cinfo->MCU_membership[blkn];
740 compptr = cinfo->cur_comp_info[ci];
754 s +=
state.last_dc_val[ci];
755 state.last_dc_val[ci] =
s;
757 (*block)[0] = (
JCOEF) (
s << Al);
766 if (cinfo->restart_interval)
782 register int s,
k,
r;
785 const int * natural_order;
791 if (cinfo->restart_interval) {
800 if (! entropy->insufficient_data) {
815 natural_order = cinfo->natural_order;
817 tbl = entropy->ac_derived_tbl;
819 for (
k = cinfo->Ss;
k <= Se;
k++) {
829 (*block)[natural_order[
k]] = (
JCOEF) (
s << Al);
853 if (cinfo->restart_interval)
875 if (cinfo->restart_interval) {
892 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
896 MCU_data[blkn][0][0] |= p1;
904 if (cinfo->restart_interval)
919 register int s,
k,
r;
923 const int * natural_order;
932 if (cinfo->restart_interval) {
940 if (! entropy->insufficient_data) {
945 natural_order = cinfo->natural_order;
953 tbl = entropy->ac_derived_tbl;
973 WARNMS(cinfo, JWRN_HUFF_BAD_CODE);
996 thiscoef = *
block + natural_order[
k];
1000 if ((*thiscoef & p1) == 0) {
1014 int pos = natural_order[
k];
1018 newnz_pos[num_newnz++] =
pos;
1031 thiscoef = *
block + natural_order[
k];
1035 if ((*thiscoef & p1) == 0) {
1055 if (cinfo->restart_interval)
1063 (*block)[newnz_pos[--num_newnz]] = 0;
1078 const int * natural_order;
1084 if (cinfo->restart_interval) {
1093 if (! entropy->insufficient_data) {
1095 natural_order = cinfo->natural_order;
1104 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1107 register int s,
k,
r;
1113 htbl = entropy->dc_cur_tbls[blkn];
1116 htbl = entropy->ac_cur_tbls[blkn];
1118 coef_limit = entropy->coef_limit[blkn];
1126 ci = cinfo->MCU_membership[blkn];
1127 s +=
state.last_dc_val[ci];
1128 state.last_dc_val[ci] =
s;
1134 for (;
k < coef_limit;
k++) {
1149 (*block)[natural_order[
k]] = (
JCOEF)
s;
1165 for (;
k <= Se;
k++) {
1191 if (cinfo->restart_interval)
1212 if (cinfo->restart_interval) {
1221 if (! entropy->insufficient_data) {
1229 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1232 register int s,
k,
r;
1238 htbl = entropy->dc_cur_tbls[blkn];
1241 htbl = entropy->ac_cur_tbls[blkn];
1243 coef_limit = entropy->coef_limit[blkn];
1251 ci = cinfo->MCU_membership[blkn];
1252 s +=
state.last_dc_val[ci];
1253 state.last_dc_val[ci] =
s;
1259 for (;
k < coef_limit;
k++) {
1316 if (cinfo->restart_interval)
1331 int ci, blkn, tbl,
i;
1334 if (cinfo->progressive_mode) {
1336 if (cinfo->Ss == 0) {
1341 if (cinfo->Se < cinfo->Ss || cinfo->Se > cinfo->lim_Se)
1344 if (cinfo->comps_in_scan != 1)
1347 if (cinfo->Ah != 0) {
1349 if (cinfo->Ah-1 != cinfo->Al)
1352 if (cinfo->Al > 13) {
1360 ERREXIT4(cinfo, JERR_BAD_PROGRESSION,
1361 cinfo->Ss, cinfo->Se, cinfo->Ah, cinfo->Al);
1367 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1368 int coefi, cindex = cinfo->cur_comp_info[ci]->component_index;
1369 int *coef_bit_ptr = & cinfo->coef_bits[cindex][0];
1370 if (cinfo->Ss && coef_bit_ptr[0] < 0)
1371 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, 0);
1372 for (coefi = cinfo->Ss; coefi <= cinfo->Se; coefi++) {
1373 int expected = (coef_bit_ptr[coefi] < 0) ? 0 : coef_bit_ptr[coefi];
1375 WARNMS2(cinfo, JWRN_BOGUS_PROGRESSION, cindex, coefi);
1376 coef_bit_ptr[coefi] = cinfo->Al;
1381 if (cinfo->Ah == 0) {
1393 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1394 compptr = cinfo->cur_comp_info[ci];
1398 if (cinfo->Ss == 0) {
1399 if (cinfo->Ah == 0) {
1402 & entropy->derived_tbls[tbl]);
1407 & entropy->derived_tbls[tbl]);
1409 entropy->ac_derived_tbl = entropy->derived_tbls[tbl];
1422 if (cinfo->Ss != 0 || cinfo->Ah != 0 || cinfo->Al != 0 ||
1423 ((cinfo->is_baseline || cinfo->Se <
DCTSIZE2) &&
1424 cinfo->Se != cinfo->lim_Se))
1425 WARNMS(cinfo, JWRN_NOT_SEQUENTIAL);
1439 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1440 compptr = cinfo->cur_comp_info[ci];
1446 if (cinfo->lim_Se) {
1456 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1457 ci = cinfo->MCU_membership[blkn];
1458 compptr = cinfo->cur_comp_info[ci];
1461 entropy->ac_cur_tbls[blkn] =
1467 switch (cinfo->lim_Se) {
1469 entropy->coef_limit[blkn] = 1;
1472 if (ci <= 0 || ci > 2) ci = 2;
1473 if (i <= 0 || i > 2)
i = 2;
1477 if (ci <= 0 || ci > 3) ci = 3;
1478 if (i <= 0 || i > 3)
i = 3;
1482 if (ci <= 0 || ci > 4) ci = 4;
1483 if (i <= 0 || i > 4)
i = 4;
1487 if (ci <= 0 || ci > 5) ci = 5;
1488 if (i <= 0 || i > 5)
i = 5;
1492 if (ci <= 0 || ci > 6) ci = 6;
1493 if (i <= 0 || i > 6)
i = 6;
1497 if (ci <= 0 || ci > 7) ci = 7;
1498 if (i <= 0 || i > 7)
i = 7;
1502 if (ci <= 0 || ci > 8) ci = 8;
1503 if (i <= 0 || i > 8)
i = 8;
1507 entropy->coef_limit[blkn] = 0;
1513 entropy->bitstate.bits_left = 0;
1514 entropy->bitstate.get_buffer = 0;
1515 entropy->insufficient_data =
FALSE;
1534 cinfo->entropy = &entropy->
pub;
1538 if (cinfo->progressive_mode) {
1540 int *coef_bit_ptr, ci;
1541 cinfo->coef_bits = (
int (*)[
DCTSIZE2]) (*cinfo->mem->alloc_small)
1544 coef_bit_ptr = & cinfo->coef_bits[0][0];
1545 for (ci = 0; ci < cinfo->num_components; ci++)
1547 *coef_bit_ptr++ = -1;
1551 entropy->derived_tbls[
i] =
NULL;
NTSTATUS get_buffer(LPWSTR *buffer, SIZE_T needed, PUNICODE_STRING CallerBuffer, BOOLEAN bAllocateBuffer)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLdouble GLdouble GLdouble r
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
jpeg_std_huff_table(j_common_ptr cinfo, boolean isDC, int tblno)
jpeg_component_info * compptr
#define ASSIGN_STATE(dest, src)
static const int jpeg_zigzag_order6[6][6]
static const int jpeg_zigzag_order4[4][4]
huff_entropy_decoder * huff_entropy_ptr
jpeg_fill_bit_buffer(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, int nbits)
static const int jpeg_zigzag_order2[2][2]
finish_pass_huff(j_decompress_ptr cinfo)
#define HUFF_EXTEND(x, s)
static const int bmask[16]
decode_mcu_DC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
decode_mcu(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
jinit_huff_decoder(j_decompress_ptr cinfo)
decode_mcu_AC_refine(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
decode_mcu_sub(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
static const int jpeg_zigzag_order5[5][5]
#define BITREAD_STATE_VARS
process_restart(j_decompress_ptr cinfo)
#define BITREAD_LOAD_STATE(cinfop, permstate)
#define HUFF_DECODE(result, state, htbl, failaction, slowlabel)
static const int jpeg_zigzag_order[8][8]
static const int jpeg_zigzag_order3[3][3]
static const int jpeg_zigzag_order7[7][7]
jpeg_huff_decode(bitread_working_state *state, register bit_buf_type get_buffer, register int bits_left, d_derived_tbl *htbl, int min_bits)
start_pass_huff_decoder(j_decompress_ptr cinfo)
jpeg_make_d_derived_tbl(j_decompress_ptr cinfo, boolean isDC, int tblno, d_derived_tbl **pdtbl)
decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
#define CHECK_BIT_BUFFER(state, nbits, action)
#define BITREAD_SAVE_STATE(cinfop, permstate)
#define WARNMS2(cinfo, code, p1, p2)
#define ERREXIT4(cinfo, code, p1, p2, p3, p4)
#define ERREXIT1(cinfo, code, p1)
#define WARNMS(cinfo, code)
struct jpeg_common_struct * j_common_ptr
#define MAX_COMPS_IN_SCAN
#define D_MAX_BLOCKS_IN_MCU
const int jpeg_natural_order[DCTSIZE2+16]
static const WCHAR label2[]
const JOCTET * next_input_byte
UINT8 look_sym[1<< HUFF_LOOKAHEAD]
int look_nbits[1<< HUFF_LOOKAHEAD]
bitread_perm_state bitstate
boolean insufficient_data
d_derived_tbl * ac_derived_tbl
unsigned int restarts_to_go
c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS]
struct jpeg_entropy_encoder pub
c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS]
unsigned int restarts_to_go
struct jpeg_source_mgr * src
struct jpeg_entropy_decoder * entropy
int last_dc_val[MAX_COMPS_IN_SCAN]
#define MEMZERO(addr, type, size)
static unsigned int block