20#ifdef C_PROGRESSIVE_SUPPORTED
70#define MAX_CORR_BITS 1000
77#ifdef RIGHT_SHIFT_IS_UNSIGNED
78#define ISHIFT_TEMPS int ishift_temp;
79#define IRIGHT_SHIFT(x,shft) \
80 ((ishift_temp = (x)) < 0 ? \
81 (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \
82 (ishift_temp >> (shft)))
85#define IRIGHT_SHIFT(x,shft) ((x) >> (shft))
113 entropy->cinfo = cinfo;
114 entropy->gather_statistics = gather_statistics;
116 is_DC_band = (cinfo->Ss == 0);
121 if (cinfo->Ah == 0) {
132 if (entropy->bit_buffer ==
NULL)
133 entropy->bit_buffer = (
char *)
138 if (gather_statistics)
146 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
147 compptr = cinfo->cur_comp_info[ci];
149 entropy->last_dc_val[ci] = 0;
156 entropy->ac_tbl_no = tbl =
compptr->ac_tbl_no;
158 if (gather_statistics) {
162 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
165 if (entropy->count_ptrs[tbl] ==
NULL)
166 entropy->count_ptrs[tbl] = (
long *)
174 & entropy->derived_tbls[tbl]);
183 entropy->put_buffer = 0;
184 entropy->put_bits = 0;
187 entropy->restarts_to_go = cinfo->restart_interval;
188 entropy->next_restart_num = 0;
198#define emit_byte(entropy,val) \
199 { *(entropy)->next_output_byte++ = (JOCTET) (val); \
200 if (--(entropy)->free_in_buffer == 0) \
201 dump_buffer_p(entropy); }
210 if (! (*dest->empty_output_buffer) (entropy->cinfo))
211 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
233 int put_bits = entropy->put_bits;
237 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
239 if (entropy->gather_statistics)
246 put_buffer <<= 24 - put_bits;
248 put_buffer |= entropy->put_buffer;
250 while (put_bits >= 8) {
251 int c = (
int) ((put_buffer >> 16) & 0xFF);
261 entropy->put_buffer = put_buffer;
262 entropy->put_bits = put_bits;
270 entropy->put_buffer = 0;
271 entropy->put_bits = 0;
283 if (entropy->gather_statistics)
284 entropy->count_ptrs[tbl_no][symbol]++;
286 c_derived_tbl * tbl = entropy->derived_tbls[tbl_no];
287 emit_bits_p(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]);
300 if (entropy->gather_statistics)
320 if (entropy->EOBRUN > 0) {
321 temp = entropy->EOBRUN;
327 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
329 emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4);
331 emit_bits_p(entropy, entropy->EOBRUN, nbits);
336 emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE);
353 if (! entropy->gather_statistics) {
359 if (entropy->cinfo->Ss == 0) {
361 for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
362 entropy->last_dc_val[ci] = 0;
392 if (cinfo->restart_interval)
397 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
398 block = MCU_data[blkn];
399 ci = cinfo->MCU_membership[blkn];
400 compptr = cinfo->cur_comp_info[ci];
430 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
445 if (cinfo->restart_interval) {
446 if (entropy->restarts_to_go == 0) {
447 entropy->restarts_to_go = cinfo->restart_interval;
448 entropy->next_restart_num++;
449 entropy->next_restart_num &= 7;
478 if (cinfo->restart_interval)
489 for (
k = cinfo->Ss;
k <= Se;
k++) {
490 if ((temp = (*block)[jpeg_natural_order[k]]) == 0) {
529 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
543 if (entropy->EOBRUN == 0x7FFF)
547 cinfo->dest->next_output_byte = entropy->next_output_byte;
548 cinfo->dest->free_in_buffer = entropy->free_in_buffer;
551 if (cinfo->restart_interval) {
552 if (entropy->restarts_to_go == 0) {
553 entropy->restarts_to_go = cinfo->restart_interval;
554 entropy->next_restart_num++;
555 entropy->next_restart_num &= 7;
557 entropy->restarts_to_go--;
583 if (cinfo->restart_interval)
588 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
589 block = MCU_data[blkn];
593 emit_bits_p(entropy, (
unsigned int) (temp >> Al), 1);
600 if (cinfo->restart_interval) {
601 if (entropy->restarts_to_go == 0) {
602 entropy->restarts_to_go = cinfo->restart_interval;
603 entropy->next_restart_num++;
604 entropy->next_restart_num &= 7;
635 if (cinfo->restart_interval)
646 for (
k = cinfo->Ss;
k <= Se;
k++) {
647 temp = (*block)[jpeg_natural_order[k]];
666 for (
k = cinfo->Ss;
k <= Se;
k++) {
667 if ((temp = absvalues[k]) == 0) {
692 BR_buffer[BR++] = (char) (temp & 1);
713 if (
r > 0 || BR > 0) {
724 cinfo->dest->next_output_byte = entropy->next_output_byte;
725 cinfo->dest->free_in_buffer = entropy->free_in_buffer;
728 if (cinfo->restart_interval) {
729 if (entropy->restarts_to_go == 0) {
730 entropy->restarts_to_go = cinfo->restart_interval;
731 entropy->next_restart_num++;
732 entropy->next_restart_num &= 7;
734 entropy->restarts_to_go--;
779 is_DC_band = (cinfo->Ss == 0);
786 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
787 compptr = cinfo->cur_comp_info[ci];
797 htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
799 htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
800 if (*htblptr ==
NULL)
823 entropy->
pub.start_pass = start_pass_phuff;
static const unsigned char temp2[]
Definition DistrhoArtwork3BandEQ.cpp:2750
register unsigned k
Definition inflate.c:946
register unsigned i
Definition inflate.c:1575
jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
Definition jchuff.c:705
jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno, c_derived_tbl **pdtbl)
Definition jchuff.c:179
#define MAX_COEF_BITS
Definition jchuff.h:25
jpeg_alloc_huff_table(j_common_ptr cinfo)
Definition jcomapi.c:98
dump_buffer_p(phuff_entropy_ptr entropy)
Definition jcphuff.c:205
#define emit_byte(entropy, val)
Definition jcphuff.c:198
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
Definition jcphuff.c:464
#define ISHIFT_TEMPS
Definition jcphuff.c:84
emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart, unsigned int nbits)
Definition jcphuff.c:297
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
Definition jcphuff.c:377
flush_bits_p(phuff_entropy_ptr entropy)
Definition jcphuff.c:267
finish_pass_gather_phuff(j_compress_ptr cinfo)
Definition jcphuff.c:767
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
Definition jcphuff.c:571
phuff_entropy_encoder * phuff_entropy_ptr
Definition jcphuff.c:62
#define IRIGHT_SHIFT(x, shft)
Definition jcphuff.c:85
INLINE emit_bits_p(phuff_entropy_ptr entropy, unsigned int code, int size)
Definition jcphuff.c:228
INLINE emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
Definition jcphuff.c:281
finish_pass_phuff(j_compress_ptr cinfo)
Definition jcphuff.c:746
emit_restart_p(phuff_entropy_ptr entropy, int restart_num)
Definition jcphuff.c:347
jinit_phuff_encoder(j_compress_ptr cinfo)
Definition jcphuff.c:814
#define MAX_CORR_BITS
Definition jcphuff.c:70
emit_eobrun(phuff_entropy_ptr entropy)
Definition jcphuff.c:316
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
Definition jcphuff.c:618
jpeg_component_info * compptr
Definition jdct.h:105
bit_buf_type int int nbits
Definition jdhuff.h:159
#define ERREXIT(cinfo, code)
Definition jerror.h:205
#define ERREXIT1(cinfo, code, p1)
Definition jerror.h:208
#define SIZEOF(object)
Definition jinclude.h:83
#define MEMZERO(target, size)
Definition jinclude.h:70
long INT32
Definition jmorecfg.h:161
char JOCTET
Definition jmorecfg.h:115
#define LOCAL(type)
Definition jmorecfg.h:186
#define METHODDEF(type)
Definition jmorecfg.h:184
const int jpeg_natural_order[]
Definition jutils.c:53
JBLOCK FAR * JBLOCKROW
Definition jpeglib.h:71
struct jpeg_common_struct * j_common_ptr
Definition jpeglib.h:261
#define JPP(arglist)
Definition jpeglib.h:818
#define NUM_HUFF_TBLS
Definition jpeglib.h:44
#define JPEG_RST0
Definition jpeglib.h:1045
#define JPOOL_IMAGE
Definition jpeglib.h:749
#define MAX_COMPS_IN_SCAN
Definition jpeglib.h:46
struct jpeg_compress_struct * j_compress_ptr
Definition jpeglib.h:262
#define DCTSIZE2
Definition jpeglib.h:42
struct jpeg_entropy_encoder * entropy
Definition jpeglib.h:403
size_t free_in_buffer
Definition jpeglib.h:715
JOCTET * next_output_byte
Definition jpeglib.h:714
INT32 put_buffer
Definition jcphuff.c:35
char * bit_buffer
Definition jcphuff.c:46
int ac_tbl_no
Definition jcphuff.c:43
int put_bits
Definition jcphuff.c:36
long * count_ptrs[NUM_HUFF_TBLS]
Definition jcphuff.c:59
size_t free_in_buffer
Definition jcphuff.c:34
j_compress_ptr cinfo
Definition jcphuff.c:37
boolean gather_statistics
Definition jcphuff.c:28
unsigned int BE
Definition jcphuff.c:45
JOCTET * next_output_byte
Definition jcphuff.c:33
unsigned int restarts_to_go
Definition jcphuff.c:49
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]
Definition jcphuff.c:56
unsigned int EOBRUN
Definition jcphuff.c:44
struct jpeg_entropy_encoder pub
Definition jcphuff.c:25
int next_restart_num
Definition jcphuff.c:50
int last_dc_val[MAX_COMPS_IN_SCAN]
Definition jcphuff.c:40
#define GLOBAL(g)
Definition crypt.c:87
return c
Definition crypt.c:175
for(n=0;n< RAND_HEAD_LEN;n++)
Definition crypt.c:467
int r
Definition crypt.c:458
if(GLOBAL(newzip))
Definition crypt.c:475
typedef int(UZ_EXP MsgFn)()
#define TRUE
Definition unzpriv.h:1295