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))
113 entropy->
cinfo = cinfo;
116 is_DC_band = (cinfo->
Ss == 0);
121 if (cinfo->
Ah == 0) {
138 if (gather_statistics)
155 tbl = compptr->dc_tbl_no;
158 ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl);
160 entropy->
ac_tbl_no = tbl = compptr->ac_tbl_no;
163 ERREXIT1(cinfo,JERR_NO_HUFF_TABLE, tbl);
165 if (gather_statistics) {
205 #define emit_byte(entropy,val) \
206 { *(entropy)->next_output_byte++ = (JOCTET) (val); \
207 if (--(entropy)->free_in_buffer == 0) \
208 dump_buffer(entropy); }
217 if (! (*dest->empty_output_buffer) (entropy->
cinfo))
240 register int put_bits = entropy->
put_bits;
253 put_buffer <<= 24 - put_bits;
257 while (put_bits >= 8) {
258 int c = (
int) ((put_buffer >> 16) & 0xFF);
311 emit_bits(entropy, (
unsigned int) (*bufstart), 1);
325 register int temp, nbits;
327 if (entropy->
EOBRUN > 0) {
384 register int temp, temp2;
402 block = MCU_data[blkn];
437 emit_bits(entropy, (
unsigned int) temp2, nbits);
466 register int temp, temp2;
488 for (k = cinfo->
Ss; k <= Se; k++) {
532 emit_bits(entropy, (
unsigned int) temp2, nbits);
539 if (entropy->
EOBRUN == 0x7FFF)
585 block = MCU_data[blkn];
589 emit_bits(entropy, (
unsigned int) (temp >> Al), 1);
642 for (k = cinfo->
Ss; k <= Se; k++) {
662 for (k = cinfo->
Ss; k <= Se; k++) {
663 if ((temp = absvalues[k]) == 0) {
669 while (r > 15 && k <= EOB) {
688 BR_buffer[BR++] = (char) (temp & 1);
700 emit_bits(entropy, (
unsigned int) temp, 1);
709 if (r > 0 || BR > 0) {
775 is_DC_band = (cinfo->
Ss == 0);
789 tbl = compptr->ac_tbl_no;
796 if (*htblptr ==
NULL)
METHODDEF boolean encode_mcu_DC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
unsigned int restarts_to_go
JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]
LOCAL void dump_buffer(phuff_entropy_ptr entropy)
METHODDEF boolean encode_mcu_DC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
#define emit_byte(entropy, val)
const int jpeg_natural_order[]
struct jpeg_common_struct * j_common_ptr
GLOBAL JHUFF_TBL * jpeg_alloc_huff_table(j_common_ptr cinfo)
#define ERREXIT(cinfo, code)
METHODDEF boolean encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]
c_derived_tbl * derived_tbls[NUM_HUFF_TBLS]
JOCTET * next_output_byte
struct jpeg_entropy_encoder * entropy
LOCAL void flush_bits(phuff_entropy_ptr entropy)
#define IRIGHT_SHIFT(x, shft)
LOCAL void emit_eobrun(phuff_entropy_ptr entropy)
LOCAL void emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart, unsigned int nbits)
int MCU_membership[C_MAX_BLOCKS_IN_MCU]
METHODDEF boolean encode_mcu_DC_first JPP((j_compress_ptr cinfo, JBLOCKROW *MCU_data))
METHODDEF void start_pass_phuff(j_compress_ptr cinfo, boolean gather_statistics)
struct jpeg_entropy_encoder pub
struct jpeg_destination_mgr * dest
phuff_entropy_encoder * phuff_entropy_ptr
LOCAL void emit_restart(phuff_entropy_ptr entropy, int restart_num)
GLOBAL void jinit_phuff_encoder(j_compress_ptr cinfo)
unsigned int restart_interval
INLINE LOCAL void emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol)
METHODDEF void finish_pass_phuff(j_compress_ptr cinfo)
#define ERREXIT1(cinfo, code, p1)
GLdouble GLdouble GLdouble r
METHODDEF boolean encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]
METHODDEF void finish_pass_gather_phuff(j_compress_ptr cinfo)
INLINE LOCAL void emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size)
boolean gather_statistics
int last_dc_val[MAX_COMPS_IN_SCAN]
if(!ValidDisplayID(prefInfo.prefDisplayID)) prefInfo.prefDisplayID
JOCTET * next_output_byte
long * count_ptrs[NUM_HUFF_TBLS]
GLOBAL void jpeg_gen_optimal_table(j_compress_ptr cinfo, JHUFF_TBL *htbl, long freq[])
GLOBAL void jpeg_make_c_derived_tbl(j_compress_ptr cinfo, JHUFF_TBL *htbl, c_derived_tbl **pdtbl)
#define MAX_COMPS_IN_SCAN
#define MEMZERO(target, size)