37 unsigned int ehufco[256];
60#ifndef NO_STRUCT_ASSIGN
61#define ASSIGN_STATE(dest,src) ((dest) = (src))
63#if MAX_COMPS_IN_SCAN == 4
64#define ASSIGN_STATE(dest,src) \
65 ((dest).put_buffer = (src).put_buffer, \
66 (dest).put_bits = (src).put_bits, \
67 (dest).last_dc_val[0] = (src).last_dc_val[0], \
68 (dest).last_dc_val[1] = (src).last_dc_val[1], \
69 (dest).last_dc_val[2] = (src).last_dc_val[2], \
70 (dest).last_dc_val[3] = (src).last_dc_val[3])
130#define MAX_CORR_BITS 1000
137#ifdef RIGHT_SHIFT_IS_UNSIGNED
138#define ISHIFT_TEMPS int ishift_temp;
139#define IRIGHT_SHIFT(x,shft) \
140 ((ishift_temp = (x)) < 0 ? \
141 (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
142 (ishift_temp >> (shft)))
145#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
160 int p,
i,
l, lastp,
si, maxsymbol;
162 unsigned int huffcode[257];
173 isDC ? cinfo->dc_huff_tbl_ptrs[
tblno] : cinfo->ac_huff_tbl_ptrs[
tblno];
186 for (
l = 1;
l <= 16;
l++) {
188 if (i < 0 || p + i > 256)
189 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
202 while (huffsize[
p]) {
203 while (((
int) huffsize[
p]) ==
si) {
204 huffcode[
p++] =
code;
211 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
230 maxsymbol =
isDC ? 15 : 255;
232 for (
p = 0;
p < lastp;
p++) {
234 if (i < 0 || i > maxsymbol || dtbl->
ehufsi[
i])
235 ERREXIT(cinfo, JERR_BAD_HUFF_TABLE);
248#define emit_byte_s(state,val,action) \
249 { *(state)->next_output_byte++ = (JOCTET) (val); \
250 if (--(state)->free_in_buffer == 0) \
251 if (! dump_buffer_s(state)) \
255#define emit_byte_e(entropy,val) \
256 { *(entropy)->next_output_byte++ = (JOCTET) (val); \
257 if (--(entropy)->free_in_buffer == 0) \
258 dump_buffer_e(entropy); }
267 if (! (*
dest->empty_output_buffer) (
state->cinfo))
270 state->next_output_byte =
dest->next_output_byte;
271 state->free_in_buffer =
dest->free_in_buffer;
282 if (! (*
dest->empty_output_buffer) (entropy->cinfo))
283 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
285 entropy->next_output_byte =
dest->next_output_byte;
286 entropy->free_in_buffer =
dest->free_in_buffer;
304 register INT32 put_buffer;
305 register int put_bits;
317 put_buffer <<= 24 - put_bits;
320 put_buffer |=
state->cur.put_buffer;
322 while (put_bits >= 8) {
323 int c = (
int) ((put_buffer >> 16) & 0xFF);
333 state->cur.put_buffer = put_buffer;
334 state->cur.put_bits = put_bits;
346 register INT32 put_buffer;
347 register int put_bits;
351 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
353 if (entropy->gather_statistics)
360 put_bits =
size + entropy->saved.put_bits;
362 put_buffer <<= 24 - put_bits;
365 put_buffer |= entropy->saved.put_buffer;
367 while (put_bits >= 8) {
368 int c = (
int) ((put_buffer >> 16) & 0xFF);
378 entropy->saved.put_buffer = put_buffer;
379 entropy->saved.put_bits = put_bits;
388 state->cur.put_buffer = 0;
389 state->cur.put_bits = 0;
398 entropy->saved.put_buffer = 0;
399 entropy->saved.put_bits = 0;
411 if (entropy->gather_statistics)
412 entropy->dc_count_ptrs[tbl_no][symbol]++;
424 if (entropy->gather_statistics)
425 entropy->ac_count_ptrs[tbl_no][symbol]++;
441 if (entropy->gather_statistics)
445 emit_bits_e(entropy, (
unsigned int) (*bufstart), 1);
459 register int temp, nbits;
461 if (entropy->EOBRUN > 0) {
462 temp = entropy->EOBRUN;
468 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
499 for (ci = 0; ci <
state->cinfo->comps_in_scan; ci++)
500 state->cur.last_dc_val[ci] = 0;
515 if (! entropy->gather_statistics) {
521 if (entropy->cinfo->Ss == 0) {
523 for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
524 entropy->saved.last_dc_val[ci] = 0;
542 register int temp, temp2;
552 if (cinfo->restart_interval)
557 max_coef_bits = cinfo->data_precision + 3;
560 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
561 ci = cinfo->MCU_membership[blkn];
562 tbl = cinfo->cur_comp_info[ci]->dc_tbl_no;
580 if ((
temp = temp2) < 0) {
590 while ((
temp >>= 1));
592 if (nbits > max_coef_bits)
593 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
607 if (cinfo->restart_interval) {
629 const int * natural_order;
631 register int temp, temp2;
634 int Se, Al, max_coef_bits;
640 if (cinfo->restart_interval)
646 natural_order = cinfo->natural_order;
647 max_coef_bits = cinfo->data_precision + 2;
656 for (
k = cinfo->Ss;
k <= Se;
k++) {
657 if ((
temp = (*
block)[natural_order[
k]]) == 0) {
670 if ((
temp >>= Al) == 0) {
679 if ((
temp >>= Al) == 0) {
698 while ((
temp >>= 1));
700 if (nbits > max_coef_bits)
701 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
715 if (entropy->
EOBRUN == 0x7FFF)
723 if (cinfo->restart_interval) {
752 if (cinfo->restart_interval)
759 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
761 emit_bits_e(entropy, (
unsigned int) (MCU_data[blkn][0][0] >> Al), 1);
768 if (cinfo->restart_interval) {
789 const int * natural_order;
803 if (cinfo->restart_interval)
809 natural_order = cinfo->natural_order;
818 for (
k = cinfo->Ss;
k <= Se;
k++) {
819 temp = (*block)[natural_order[
k]];
838 for (
k = cinfo->Ss;
k <= Se;
k++) {
839 if ((
temp = absvalues[
k]) == 0) {
845 while (
r > 15 &&
k <= EOB) {
864 BR_buffer[BR++] = (
char) (
temp & 1);
875 temp = ((*block)[natural_order[
k]] < 0) ? 0 : 1;
885 if (
r > 0 || BR > 0) {
900 if (cinfo->restart_interval) {
919 register int temp, temp2;
922 int Se =
state->cinfo->lim_Se;
923 int max_coef_bits =
state->cinfo->data_precision + 3;
924 const int * natural_order =
state->cinfo->natural_order;
928 if ((
temp =
block[0] - last_dc_val) == 0) {
933 if ((temp2 =
temp) < 0) {
943 while ((
temp >>= 1));
947 if (nbits > max_coef_bits)
964 for (
k = 1;
k <= Se;
k++) {
977 if ((temp2 =
temp) < 0) {
987 while ((
temp >>= 1));
992 if (nbits >= max_coef_bits)
996 temp = (
r << 4) + nbits;
1030 state.next_output_byte = cinfo->dest->next_output_byte;
1031 state.free_in_buffer = cinfo->dest->free_in_buffer;
1033 state.cinfo = cinfo;
1036 if (cinfo->restart_interval) {
1043 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1044 ci = cinfo->MCU_membership[blkn];
1045 compptr = cinfo->cur_comp_info[ci];
1047 MCU_data[blkn][0],
state.cur.last_dc_val[ci],
1052 state.cur.last_dc_val[ci] = MCU_data[blkn][0][0];
1056 cinfo->dest->next_output_byte =
state.next_output_byte;
1057 cinfo->dest->free_in_buffer =
state.free_in_buffer;
1061 if (cinfo->restart_interval) {
1084 if (cinfo->progressive_mode) {
1096 state.next_output_byte = cinfo->dest->next_output_byte;
1097 state.free_in_buffer = cinfo->dest->free_in_buffer;
1099 state.cinfo = cinfo;
1103 ERREXIT(cinfo, JERR_CANT_SUSPEND);
1106 cinfo->dest->next_output_byte =
state.next_output_byte;
1107 cinfo->dest->free_in_buffer =
state.free_in_buffer;
1129 long dc_counts[],
long ac_counts[])
1134 int Se = cinfo->lim_Se;
1135 int max_coef_bits = cinfo->data_precision + 3;
1136 const int * natural_order = cinfo->natural_order;
1140 if ((
temp =
block[0] - last_dc_val) == 0) {
1150 while ((
temp >>= 1));
1154 if (nbits > max_coef_bits)
1155 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
1165 for (
k = 1;
k <= Se;
k++) {
1183 while ((
temp >>= 1));
1188 if (nbits >= max_coef_bits)
1189 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
1192 ac_counts[(
r << 4) + nbits]++;
1216 if (cinfo->restart_interval) {
1219 for (ci = 0; ci < cinfo->comps_in_scan; ci++)
1227 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
1228 ci = cinfo->MCU_membership[blkn];
1229 compptr = cinfo->cur_comp_info[ci];
1286#ifndef DONT_USE_FANCY_HUFF_OPT
1332 while ((c1 = others[256]) >= 0) {
1336 while ((c2 = others[c1]) >= 0) {
1344 others[
j] = others[
i];
1354 for (
i = 0;
i < 257;
i++)
1364 for (
i = 0;
i <= 256;
i++) {
1365 if (freq[
i] && freq[
i] <=
v) {
1375 for (
i = 0;
i <= 256;
i++) {
1376 if (freq[
i] && freq[
i] <=
v &&
i != c1) {
1387 freq[c1] += freq[c2];
1392 while (others[c1] >= 0) {
1401 while (others[c2] >= 0) {
1408 for (
i = 0;
i <= 256;
i++) {
1413 ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
1415 bits[codesize[
i]]++;
1431 while (
bits[
i] > 0) {
1433 while (
bits[
j] == 0) {
1435 ERREXIT(cinfo, JERR_HUFF_CLEN_OUTOFBOUNDS);
1447 while (
bits[
i] == 0)
1454#ifdef DONT_USE_FANCY_HUFF_OPT
1462 for (
j = 0;
j <= 255;
j++) {
1463 if (codesize[
j] ==
i) {
1472 htbl->sent_table =
FALSE;
1490 if (cinfo->progressive_mode)
1500 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1501 compptr = cinfo->cur_comp_info[ci];
1503 if (cinfo->Ss == 0 && cinfo->Ah == 0) {
1505 if (! did_dc[tbl]) {
1506 htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
1507 if (*htblptr ==
NULL)
1516 if (! did_ac[tbl]) {
1517 htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
1518 if (*htblptr ==
NULL)
1541 if (gather_statistics)
1546 if (cinfo->progressive_mode) {
1547 entropy->
cinfo = cinfo;
1553 if (cinfo->Ah == 0) {
1565 entropy->
bit_buffer = (
char *) (*cinfo->mem->alloc_small)
1571 entropy->
ac_tbl_no = cinfo->cur_comp_info[0]->ac_tbl_no;
1575 if (gather_statistics)
1581 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
1582 compptr = cinfo->cur_comp_info[ci];
1584 if (cinfo->Ss == 0 && cinfo->Ah == 0) {
1586 if (gather_statistics) {
1590 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
1594 entropy->
dc_count_ptrs[tbl] = (
long *) (*cinfo->mem->alloc_small)
1609 if (gather_statistics) {
1611 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
1613 entropy->
ac_count_ptrs[tbl] = (
long *) (*cinfo->mem->alloc_small)
1645 cinfo->entropy = &entropy->
pub;
1654 if (cinfo->progressive_mode)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
GLdouble GLdouble GLdouble r
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
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
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 GLint GLint j
htest_one_block(j_compress_ptr cinfo, JCOEFPTR block, int last_dc_val, long dc_counts[], long ac_counts[])
INLINE emit_ac_symbol(huff_entropy_ptr entropy, int tbl_no, int symbol)
#define ASSIGN_STATE(dest, src)
dump_buffer_e(huff_entropy_ptr entropy)
#define emit_byte_e(entropy, val)
jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno, c_derived_tbl **pdtbl)
jinit_huff_encoder(j_compress_ptr cinfo)
dump_buffer_s(working_state *state)
emit_restart_e(huff_entropy_ptr entropy, int restart_num)
#define IRIGHT_SHIFT(x, shft)
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
#define emit_byte_s(state, val, action)
finish_pass_gather(j_compress_ptr cinfo)
INLINE emit_bits_e(huff_entropy_ptr entropy, unsigned int code, int size)
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
INLINE emit_bits_s(working_state *state, unsigned int code, int size)
flush_bits_s(working_state *state)
INLINE emit_dc_symbol(huff_entropy_ptr entropy, int tbl_no, int symbol)
finish_pass_huff(j_compress_ptr cinfo)
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
emit_buffered_bits(huff_entropy_ptr entropy, char *bufstart, unsigned int nbits)
emit_eobrun(huff_entropy_ptr entropy)
flush_bits_e(huff_entropy_ptr entropy)
encode_mcu_gather(j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
encode_mcu_huff(j_compress_ptr cinfo, JBLOCKARRAY MCU_data)
encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val, c_derived_tbl *dctbl, c_derived_tbl *actbl)
start_pass_huff(j_compress_ptr cinfo, boolean gather_statistics)
emit_restart_s(working_state *state, int restart_num)
huff_entropy_encoder * huff_entropy_ptr
jpeg_std_huff_table(j_common_ptr cinfo, boolean isDC, int tblno)
jpeg_alloc_huff_table(j_common_ptr cinfo)
jpeg_component_info * compptr
#define ERREXIT1(cinfo, code, p1)
#define MEMCOPY(dest, src, size)
struct jpeg_common_struct * j_common_ptr
#define MAX_COMPS_IN_SCAN
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
boolean gather_statistics
long * ac_count_ptrs[NUM_HUFF_TBLS]
JOCTET * next_output_byte
long * dc_count_ptrs[NUM_HUFF_TBLS]
int last_dc_val[MAX_COMPS_IN_SCAN]
JOCTET * next_output_byte
#define MEMZERO(addr, type, size)
static unsigned int block