15 #define JPEG_INTERNALS 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)) 106 start_pass_phuff (
j_compress_ptr cinfo,
boolean gather_statistics)
113 entropy->
cinfo = cinfo;
116 is_DC_band = (cinfo->
Ss == 0);
121 if (cinfo->
Ah == 0) {
138 if (gather_statistics)
158 if (gather_statistics) {
162 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
198 #define emit_byte(entropy,val) \ 199 { *(entropy)->next_output_byte++ = (JOCTET) (val); \ 200 if (--(entropy)->free_in_buffer == 0) \ 201 dump_buffer(entropy); } 210 if (! (*dest->empty_output_buffer) (entropy->cinfo))
211 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
233 register 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]++;
300 if (entropy->gather_statistics)
304 emit_bits(entropy, (
unsigned int) (*bufstart), 1);
318 register int temp,
nbits;
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(entropy, entropy->EOBRUN, nbits);
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;
380 register int temp, temp2;
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) {
467 register int temp, temp2;
478 if (cinfo->restart_interval)
489 for (k = cinfo->Ss; k <= Se; k++) {
529 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
543 if (entropy->
EOBRUN == 0x7FFF)
551 if (cinfo->restart_interval) {
583 if (cinfo->restart_interval)
588 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
589 block = MCU_data[blkn];
593 emit_bits(entropy, (
unsigned int) (temp >> Al), 1);
600 if (cinfo->restart_interval) {
635 if (cinfo->restart_interval)
646 for (k = cinfo->Ss; k <= Se; k++) {
666 for (k = cinfo->Ss; k <= Se; k++) {
667 if ((temp = absvalues[k]) == 0) {
673 while (r > 15 && k <= EOB) {
692 BR_buffer[BR++] = (char) (temp & 1);
704 emit_bits(entropy, (
unsigned int) temp, 1);
713 if (r > 0 || BR > 0) {
728 if (cinfo->restart_interval) {
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;
unsigned int restarts_to_go
#define emit_byte(entropy, val)
emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart, unsigned int nbits)
const int jpeg_natural_order[]
struct jpeg_common_struct * j_common_ptr
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
#define ERREXIT(cinfo, code)
jpeg_alloc_huff_table(j_common_ptr cinfo)
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
finish_pass_gather_phuff(j_compress_ptr cinfo)
emit_eobrun(phuff_entropy_ptr entropy)
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]
JOCTET * next_output_byte
struct jpeg_entropy_encoder * entropy
#define IRIGHT_SHIFT(x, shft)
jpeg_component_info * compptr
finish_pass_phuff(j_compress_ptr cinfo)
struct jpeg_entropy_encoder pub
INLINE emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
flush_bits(phuff_entropy_ptr entropy)
phuff_entropy_encoder * phuff_entropy_ptr
register bit_buf_type register int int nbits
jinit_phuff_encoder(j_compress_ptr cinfo)
jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno, c_derived_tbl **pdtbl)
unsigned int restart_interval
#define ERREXIT1(cinfo, code, p1)
emit_restart(phuff_entropy_ptr entropy, int restart_num)
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
boolean gather_statistics
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
INLINE emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
int last_dc_val[MAX_COMPS_IN_SCAN]
dump_buffer(phuff_entropy_ptr entropy)
JOCTET * next_output_byte
long * count_ptrs[NUM_HUFF_TBLS]
#define MAX_COMPS_IN_SCAN
#define MEMZERO(target, size)