10 #define JPEG_INTERNALS 15 #ifdef C_PROGRESSIVE_SUPPORTED 65 #define MAX_CORR_BITS 1000 72 #ifdef RIGHT_SHIFT_IS_UNSIGNED 73 #define ISHIFT_TEMPS int ishift_temp; 74 #define IRIGHT_SHIFT(x,shft) \ 75 ((ishift_temp = (x)) < 0 ? \ 76 (ishift_temp >> (shft)) | ((~0) << (16-(shft))) : \ 77 (ishift_temp >> (shft))) 80 #define IRIGHT_SHIFT(x,shft) ((x) >> (shft)) 108 entropy->
cinfo = cinfo;
111 is_DC_band = (cinfo->Ss == 0);
116 if (cinfo->Ah == 0) {
133 if (gather_statistics)
141 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
142 compptr = cinfo->cur_comp_info[ci];
153 if (gather_statistics) {
157 ERREXIT1(cinfo, JERR_NO_HUFF_TABLE, tbl);
193 #define emit_byte(entropy,val) \ 194 { *(entropy)->next_output_byte++ = (JOCTET) (val); \ 195 if (--(entropy)->free_in_buffer == 0) \ 196 dump_buffer(entropy); } 205 if (! (*dest->empty_output_buffer) (entropy->cinfo))
206 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND);
228 int put_bits = entropy->put_bits;
232 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
234 if (entropy->gather_statistics)
241 put_buffer <<= 24 - put_bits;
243 put_buffer |= entropy->put_buffer;
245 while (put_bits >= 8) {
246 int c = (int) ((put_buffer >> 16) & 0xFF);
256 entropy->put_buffer = put_buffer;
257 entropy->put_bits = put_bits;
265 entropy->put_buffer = 0;
266 entropy->put_bits = 0;
278 if (entropy->gather_statistics)
279 entropy->count_ptrs[tbl_no][symbol]++;
295 if (entropy->gather_statistics)
299 emit_bits(entropy, (
unsigned int) (*bufstart), 1);
315 if (entropy->EOBRUN > 0) {
316 temp = entropy->EOBRUN;
322 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE);
348 if (! entropy->gather_statistics) {
354 if (entropy->cinfo->Ss == 0) {
356 for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++)
357 entropy->last_dc_val[ci] = 0;
387 if (cinfo->restart_interval)
392 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
394 ci = cinfo->MCU_membership[blkn];
395 compptr = cinfo->cur_comp_info[ci];
425 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
440 if (cinfo->restart_interval) {
473 if (cinfo->restart_interval)
484 for (k = cinfo->Ss; k <= Se; k++) {
524 ERREXIT(cinfo, JERR_BAD_DCT_COEF);
538 if (entropy->
EOBRUN == 0x7FFF)
546 if (cinfo->restart_interval) {
578 if (cinfo->restart_interval)
583 for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) {
588 emit_bits(entropy, (
unsigned int) (temp >> Al), 1);
595 if (cinfo->restart_interval) {
630 if (cinfo->restart_interval)
641 for (k = cinfo->Ss; k <= Se; k++) {
661 for (k = cinfo->Ss; k <= Se; k++) {
662 if ((temp = absvalues[k]) == 0) {
668 while (
r > 15 && k <= EOB) {
687 BR_buffer[BR++] = (char) (temp & 1);
699 emit_bits(entropy, (
unsigned int) temp, 1);
708 if (
r > 0 || BR > 0) {
723 if (cinfo->restart_interval) {
774 is_DC_band = (cinfo->Ss == 0);
781 for (ci = 0; ci < cinfo->comps_in_scan; ci++) {
782 compptr = cinfo->cur_comp_info[ci];
792 htblptr = & cinfo->dc_huff_tbl_ptrs[tbl];
794 htblptr = & cinfo->ac_huff_tbl_ptrs[tbl];
795 if (*htblptr == NULL)
unsigned int restarts_to_go
encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
INLINE emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
#define MAX_COMPS_IN_SCAN
jpeg_make_c_derived_tbl(j_compress_ptr cinfo, boolean isDC, int tblno, c_derived_tbl **pdtbl)
const int jpeg_natural_order[]
encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
struct jpeg_common_struct * j_common_ptr
phuff_entropy_encoder * phuff_entropy_ptr
#define ERREXIT(cinfo, code)
encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]
JOCTET * next_output_byte
jpeg_component_info * compptr
jinit_phuff_encoder(j_compress_ptr cinfo)
start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
INLINE emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
bit_buf_type int int nbits
METHODDEF(boolean) encode_mcu_DC_first JPP((j_compress_ptr cinfo
struct jpeg_entropy_encoder pub
emit_eobrun(phuff_entropy_ptr entropy)
flush_bits(phuff_entropy_ptr entropy)
jpeg_alloc_huff_table(j_common_ptr cinfo)
finish_pass_phuff(j_compress_ptr cinfo)
#define IRIGHT_SHIFT(x, shft)
encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
#define ERREXIT1(cinfo, code, p1)
GLdouble GLdouble GLdouble r
emit_restart(phuff_entropy_ptr entropy, int restart_num)
dump_buffer(phuff_entropy_ptr entropy)
boolean gather_statistics
int last_dc_val[MAX_COMPS_IN_SCAN]
#define emit_byte(entropy, val)
emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart, unsigned int nbits)
JOCTET * next_output_byte
long * count_ptrs[NUM_HUFF_TBLS]
finish_pass_gather_phuff(j_compress_ptr cinfo)
#define MEMZERO(target, size)