Lines Matching refs:entropy

108   phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy;  in start_pass_phuff()  local
113 entropy->cinfo = cinfo; in start_pass_phuff()
114 entropy->gather_statistics = gather_statistics; in start_pass_phuff()
123 entropy->pub.encode_mcu = encode_mcu_DC_first; in start_pass_phuff()
125 entropy->pub.encode_mcu = encode_mcu_AC_first; in start_pass_phuff()
128 entropy->pub.encode_mcu = encode_mcu_DC_refine; in start_pass_phuff()
130 entropy->pub.encode_mcu = encode_mcu_AC_refine; in start_pass_phuff()
132 if (entropy->bit_buffer == NULL) in start_pass_phuff()
133 entropy->bit_buffer = (char *) in start_pass_phuff()
139 entropy->pub.finish_pass = finish_pass_gather_phuff; in start_pass_phuff()
141 entropy->pub.finish_pass = finish_pass_phuff; in start_pass_phuff()
149 entropy->last_dc_val[ci] = 0; in start_pass_phuff()
156 entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; in start_pass_phuff()
165 if (entropy->count_ptrs[tbl] == NULL) in start_pass_phuff()
166 entropy->count_ptrs[tbl] = (long *) in start_pass_phuff()
169 MEMZERO(entropy->count_ptrs[tbl], 257 * SIZEOF(long)); in start_pass_phuff()
174 & entropy->derived_tbls[tbl]); in start_pass_phuff()
179 entropy->EOBRUN = 0; in start_pass_phuff()
180 entropy->BE = 0; in start_pass_phuff()
183 entropy->put_buffer = 0; in start_pass_phuff()
184 entropy->put_bits = 0; in start_pass_phuff()
187 entropy->restarts_to_go = cinfo->restart_interval; in start_pass_phuff()
188 entropy->next_restart_num = 0; in start_pass_phuff()
198 #define emit_byte(entropy,val) \ argument
199 { *(entropy)->next_output_byte++ = (JOCTET) (val); \
200 if (--(entropy)->free_in_buffer == 0) \
201 dump_buffer(entropy); }
205 dump_buffer (phuff_entropy_ptr entropy) in dump_buffer() argument
208 struct jpeg_destination_mgr * dest = entropy->cinfo->dest; in dump_buffer()
210 if (! (*dest->empty_output_buffer) (entropy->cinfo)) in dump_buffer()
211 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); in dump_buffer()
213 entropy->next_output_byte = dest->next_output_byte; in dump_buffer()
214 entropy->free_in_buffer = dest->free_in_buffer; in dump_buffer()
228 emit_bits (phuff_entropy_ptr entropy, unsigned int code, int size) in LOCAL()
233 register int put_bits = entropy->put_bits; in LOCAL()
237 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); in LOCAL()
239 if (entropy->gather_statistics) in LOCAL()
248 put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */ in LOCAL()
253 emit_byte(entropy, c); in LOCAL()
255 emit_byte(entropy, 0); in LOCAL()
261 entropy->put_buffer = put_buffer; /* update variables */ in LOCAL()
262 entropy->put_bits = put_bits; in LOCAL()
267 flush_bits (phuff_entropy_ptr entropy) in flush_bits() argument
269 emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ in flush_bits()
270 entropy->put_buffer = 0; /* and reset bit-buffer to empty */ in flush_bits()
271 entropy->put_bits = 0; in flush_bits()
281 emit_symbol (phuff_entropy_ptr entropy, int tbl_no, int symbol) in LOCAL()
283 if (entropy->gather_statistics) in LOCAL()
284 entropy->count_ptrs[tbl_no][symbol]++; in LOCAL()
286 c_derived_tbl * tbl = entropy->derived_tbls[tbl_no]; in LOCAL()
287 emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); in LOCAL()
297 emit_buffered_bits (phuff_entropy_ptr entropy, char * bufstart, in emit_buffered_bits() argument
300 if (entropy->gather_statistics) in emit_buffered_bits()
304 emit_bits(entropy, (unsigned int) (*bufstart), 1); in emit_buffered_bits()
316 emit_eobrun (phuff_entropy_ptr entropy) in emit_eobrun() argument
320 if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ in emit_eobrun()
321 temp = entropy->EOBRUN; in emit_eobrun()
327 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); in emit_eobrun()
329 emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); in emit_eobrun()
331 emit_bits(entropy, entropy->EOBRUN, nbits); in emit_eobrun()
333 entropy->EOBRUN = 0; in emit_eobrun()
336 emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); in emit_eobrun()
337 entropy->BE = 0; in emit_eobrun()
347 emit_restart (phuff_entropy_ptr entropy, int restart_num) in emit_restart() argument
351 emit_eobrun(entropy); in emit_restart()
353 if (! entropy->gather_statistics) { in emit_restart()
354 flush_bits(entropy); in emit_restart()
355 emit_byte(entropy, 0xFF); in emit_restart()
356 emit_byte(entropy, JPEG_RST0 + restart_num); in emit_restart()
359 if (entropy->cinfo->Ss == 0) { in emit_restart()
361 for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) in emit_restart()
362 entropy->last_dc_val[ci] = 0; in emit_restart()
365 entropy->EOBRUN = 0; in emit_restart()
366 entropy->BE = 0; in emit_restart()
379 phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; in encode_mcu_DC_first() local
388 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_DC_first()
389 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_DC_first()
393 if (entropy->restarts_to_go == 0) in encode_mcu_DC_first()
394 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_DC_first()
408 temp = temp2 - entropy->last_dc_val[ci]; in encode_mcu_DC_first()
409 entropy->last_dc_val[ci] = temp2; in encode_mcu_DC_first()
433 emit_symbol(entropy, compptr->dc_tbl_no, nbits); in encode_mcu_DC_first()
438 emit_bits(entropy, (unsigned int) temp2, nbits); in encode_mcu_DC_first()
441 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_DC_first()
442 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_DC_first()
446 if (entropy->restarts_to_go == 0) { in encode_mcu_DC_first()
447 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_DC_first()
448 entropy->next_restart_num++; in encode_mcu_DC_first()
449 entropy->next_restart_num &= 7; in encode_mcu_DC_first()
451 entropy->restarts_to_go--; in encode_mcu_DC_first()
466 phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; in encode_mcu_AC_first() local
474 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_AC_first()
475 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_AC_first()
479 if (entropy->restarts_to_go == 0) in encode_mcu_AC_first()
480 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_AC_first()
515 if (entropy->EOBRUN > 0) in encode_mcu_AC_first()
516 emit_eobrun(entropy); in encode_mcu_AC_first()
519 emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); in encode_mcu_AC_first()
532 emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); in encode_mcu_AC_first()
536 emit_bits(entropy, (unsigned int) temp2, nbits); in encode_mcu_AC_first()
542 entropy->EOBRUN++; /* count an EOB */ in encode_mcu_AC_first()
543 if (entropy->EOBRUN == 0x7FFF) in encode_mcu_AC_first()
544 emit_eobrun(entropy); /* force it out to avoid overflow */ in encode_mcu_AC_first()
547 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_AC_first()
548 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_AC_first()
552 if (entropy->restarts_to_go == 0) { in encode_mcu_AC_first()
553 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_AC_first()
554 entropy->next_restart_num++; in encode_mcu_AC_first()
555 entropy->next_restart_num &= 7; in encode_mcu_AC_first()
557 entropy->restarts_to_go--; in encode_mcu_AC_first()
573 phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; in encode_mcu_DC_refine() local
579 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_DC_refine()
580 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_DC_refine()
584 if (entropy->restarts_to_go == 0) in encode_mcu_DC_refine()
585 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_DC_refine()
593 emit_bits(entropy, (unsigned int) (temp >> Al), 1); in encode_mcu_DC_refine()
596 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_DC_refine()
597 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_DC_refine()
601 if (entropy->restarts_to_go == 0) { in encode_mcu_DC_refine()
602 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_DC_refine()
603 entropy->next_restart_num++; in encode_mcu_DC_refine()
604 entropy->next_restart_num &= 7; in encode_mcu_DC_refine()
606 entropy->restarts_to_go--; in encode_mcu_DC_refine()
620 phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; in encode_mcu_AC_refine() local
631 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_AC_refine()
632 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_AC_refine()
636 if (entropy->restarts_to_go == 0) in encode_mcu_AC_refine()
637 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_AC_refine()
664 BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ in encode_mcu_AC_refine()
675 emit_eobrun(entropy); in encode_mcu_AC_refine()
677 emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); in encode_mcu_AC_refine()
680 emit_buffered_bits(entropy, BR_buffer, BR); in encode_mcu_AC_refine()
681 BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ in encode_mcu_AC_refine()
697 emit_eobrun(entropy); in encode_mcu_AC_refine()
700 emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); in encode_mcu_AC_refine()
704 emit_bits(entropy, (unsigned int) temp, 1); in encode_mcu_AC_refine()
707 emit_buffered_bits(entropy, BR_buffer, BR); in encode_mcu_AC_refine()
708 BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ in encode_mcu_AC_refine()
714 entropy->EOBRUN++; /* count an EOB */ in encode_mcu_AC_refine()
715 entropy->BE += BR; /* concat my correction bits to older ones */ in encode_mcu_AC_refine()
720 if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) in encode_mcu_AC_refine()
721 emit_eobrun(entropy); in encode_mcu_AC_refine()
724 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_AC_refine()
725 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_AC_refine()
729 if (entropy->restarts_to_go == 0) { in encode_mcu_AC_refine()
730 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_AC_refine()
731 entropy->next_restart_num++; in encode_mcu_AC_refine()
732 entropy->next_restart_num &= 7; in encode_mcu_AC_refine()
734 entropy->restarts_to_go--; in encode_mcu_AC_refine()
748 phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; in finish_pass_phuff() local
750 entropy->next_output_byte = cinfo->dest->next_output_byte; in finish_pass_phuff()
751 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in finish_pass_phuff()
754 emit_eobrun(entropy); in finish_pass_phuff()
755 flush_bits(entropy); in finish_pass_phuff()
757 cinfo->dest->next_output_byte = entropy->next_output_byte; in finish_pass_phuff()
758 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in finish_pass_phuff()
769 phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; in finish_pass_gather_phuff() local
777 emit_eobrun(entropy); in finish_pass_gather_phuff()
802 jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); in finish_pass_gather_phuff()
816 phuff_entropy_ptr entropy; in jinit_phuff_encoder() local
819 entropy = (phuff_entropy_ptr) in jinit_phuff_encoder()
822 cinfo->entropy = (struct jpeg_entropy_encoder *) entropy; in jinit_phuff_encoder()
823 entropy->pub.start_pass = start_pass_phuff; in jinit_phuff_encoder()
827 entropy->derived_tbls[i] = NULL; in jinit_phuff_encoder()
828 entropy->count_ptrs[i] = NULL; in jinit_phuff_encoder()
830 entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ in jinit_phuff_encoder()