Lines Matching refs:entropy
200 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in start_pass_phuff() local
205 entropy->cinfo = cinfo; in start_pass_phuff()
206 entropy->gather_statistics = gather_statistics; in start_pass_phuff()
215 entropy->pub.encode_mcu = encode_mcu_DC_first; in start_pass_phuff()
217 entropy->pub.encode_mcu = encode_mcu_AC_first; in start_pass_phuff()
219 entropy->AC_first_prepare = jsimd_encode_mcu_AC_first_prepare; in start_pass_phuff()
221 entropy->AC_first_prepare = encode_mcu_AC_first_prepare; in start_pass_phuff()
224 entropy->pub.encode_mcu = encode_mcu_DC_refine; in start_pass_phuff()
226 entropy->pub.encode_mcu = encode_mcu_AC_refine; in start_pass_phuff()
228 entropy->AC_refine_prepare = jsimd_encode_mcu_AC_refine_prepare; in start_pass_phuff()
230 entropy->AC_refine_prepare = encode_mcu_AC_refine_prepare; in start_pass_phuff()
232 if (entropy->bit_buffer == NULL) in start_pass_phuff()
233 entropy->bit_buffer = (char *) in start_pass_phuff()
239 entropy->pub.finish_pass = finish_pass_gather_phuff; in start_pass_phuff()
241 entropy->pub.finish_pass = finish_pass_phuff; in start_pass_phuff()
249 entropy->last_dc_val[ci] = 0; in start_pass_phuff()
256 entropy->ac_tbl_no = tbl = compptr->ac_tbl_no; in start_pass_phuff()
265 if (entropy->count_ptrs[tbl] == NULL) in start_pass_phuff()
266 entropy->count_ptrs[tbl] = (long *) in start_pass_phuff()
269 MEMZERO(entropy->count_ptrs[tbl], 257 * sizeof(long)); in start_pass_phuff()
274 &entropy->derived_tbls[tbl]); in start_pass_phuff()
279 entropy->EOBRUN = 0; in start_pass_phuff()
280 entropy->BE = 0; in start_pass_phuff()
283 entropy->put_buffer = 0; in start_pass_phuff()
284 entropy->put_bits = 0; in start_pass_phuff()
287 entropy->restarts_to_go = cinfo->restart_interval; in start_pass_phuff()
288 entropy->next_restart_num = 0; in start_pass_phuff()
298 #define emit_byte(entropy, val) { \ argument
299 *(entropy)->next_output_byte++ = (JOCTET)(val); \
300 if (--(entropy)->free_in_buffer == 0) \
301 dump_buffer(entropy); \
306 dump_buffer(phuff_entropy_ptr entropy) in dump_buffer() argument
309 struct jpeg_destination_mgr *dest = entropy->cinfo->dest; in dump_buffer()
311 if (!(*dest->empty_output_buffer) (entropy->cinfo)) in dump_buffer()
312 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); in dump_buffer()
314 entropy->next_output_byte = dest->next_output_byte; in dump_buffer()
315 entropy->free_in_buffer = dest->free_in_buffer; in dump_buffer()
328 emit_bits(phuff_entropy_ptr entropy, unsigned int code, int size) in emit_bits() argument
333 register int put_bits = entropy->put_bits; in emit_bits()
337 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); in emit_bits()
339 if (entropy->gather_statistics) in emit_bits()
348 put_buffer |= entropy->put_buffer; /* and merge with old buffer contents */ in emit_bits()
353 emit_byte(entropy, c); in emit_bits()
355 emit_byte(entropy, 0); in emit_bits()
361 entropy->put_buffer = put_buffer; /* update variables */ in emit_bits()
362 entropy->put_bits = put_bits; in emit_bits()
367 flush_bits(phuff_entropy_ptr entropy) in flush_bits() argument
369 emit_bits(entropy, 0x7F, 7); /* fill any partial byte with ones */ in flush_bits()
370 entropy->put_buffer = 0; /* and reset bit-buffer to empty */ in flush_bits()
371 entropy->put_bits = 0; in flush_bits()
380 emit_symbol(phuff_entropy_ptr entropy, int tbl_no, int symbol) in emit_symbol() argument
382 if (entropy->gather_statistics) in emit_symbol()
383 entropy->count_ptrs[tbl_no][symbol]++; in emit_symbol()
385 c_derived_tbl *tbl = entropy->derived_tbls[tbl_no]; in emit_symbol()
386 emit_bits(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); in emit_symbol()
396 emit_buffered_bits(phuff_entropy_ptr entropy, char *bufstart, in emit_buffered_bits() argument
399 if (entropy->gather_statistics) in emit_buffered_bits()
403 emit_bits(entropy, (unsigned int)(*bufstart), 1); in emit_buffered_bits()
415 emit_eobrun(phuff_entropy_ptr entropy) in emit_eobrun() argument
419 if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ in emit_eobrun()
420 temp = entropy->EOBRUN; in emit_eobrun()
424 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); in emit_eobrun()
426 emit_symbol(entropy, entropy->ac_tbl_no, nbits << 4); in emit_eobrun()
428 emit_bits(entropy, entropy->EOBRUN, nbits); in emit_eobrun()
430 entropy->EOBRUN = 0; in emit_eobrun()
433 emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); in emit_eobrun()
434 entropy->BE = 0; in emit_eobrun()
444 emit_restart(phuff_entropy_ptr entropy, int restart_num) in emit_restart() argument
448 emit_eobrun(entropy); in emit_restart()
450 if (!entropy->gather_statistics) { in emit_restart()
451 flush_bits(entropy); in emit_restart()
452 emit_byte(entropy, 0xFF); in emit_restart()
453 emit_byte(entropy, JPEG_RST0 + restart_num); in emit_restart()
456 if (entropy->cinfo->Ss == 0) { in emit_restart()
458 for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) in emit_restart()
459 entropy->last_dc_val[ci] = 0; in emit_restart()
462 entropy->EOBRUN = 0; in emit_restart()
463 entropy->BE = 0; in emit_restart()
476 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in encode_mcu_DC_first() local
485 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_DC_first()
486 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_DC_first()
490 if (entropy->restarts_to_go == 0) in encode_mcu_DC_first()
491 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_DC_first()
505 temp = temp2 - entropy->last_dc_val[ci]; in encode_mcu_DC_first()
506 entropy->last_dc_val[ci] = temp2; in encode_mcu_DC_first()
530 emit_symbol(entropy, compptr->dc_tbl_no, nbits); in encode_mcu_DC_first()
535 emit_bits(entropy, (unsigned int)temp2, nbits); in encode_mcu_DC_first()
538 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_DC_first()
539 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_DC_first()
543 if (entropy->restarts_to_go == 0) { in encode_mcu_DC_first()
544 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_DC_first()
545 entropy->next_restart_num++; in encode_mcu_DC_first()
546 entropy->next_restart_num &= 7; in encode_mcu_DC_first()
548 entropy->restarts_to_go--; in encode_mcu_DC_first()
630 emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
641 emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); \
645 emit_bits(entropy, (unsigned int)temp2, nbits); \
655 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in encode_mcu_AC_first() local
666 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_AC_first()
667 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_AC_first()
671 if (entropy->restarts_to_go == 0) in encode_mcu_AC_first()
672 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_AC_first()
682 entropy->AC_first_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss, in encode_mcu_AC_first()
691 if (zerobits && (entropy->EOBRUN > 0)) in encode_mcu_AC_first()
692 emit_eobrun(entropy); in encode_mcu_AC_first()
716 entropy->EOBRUN++; /* count an EOB */ in encode_mcu_AC_first()
717 if (entropy->EOBRUN == 0x7FFF) in encode_mcu_AC_first()
718 emit_eobrun(entropy); /* force it out to avoid overflow */ in encode_mcu_AC_first()
721 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_AC_first()
722 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_AC_first()
726 if (entropy->restarts_to_go == 0) { in encode_mcu_AC_first()
727 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_AC_first()
728 entropy->next_restart_num++; in encode_mcu_AC_first()
729 entropy->next_restart_num &= 7; in encode_mcu_AC_first()
731 entropy->restarts_to_go--; in encode_mcu_AC_first()
747 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in encode_mcu_DC_refine() local
753 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_DC_refine()
754 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_DC_refine()
758 if (entropy->restarts_to_go == 0) in encode_mcu_DC_refine()
759 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_DC_refine()
767 emit_bits(entropy, (unsigned int)(temp >> Al), 1); in encode_mcu_DC_refine()
770 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_DC_refine()
771 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_DC_refine()
775 if (entropy->restarts_to_go == 0) { in encode_mcu_DC_refine()
776 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_DC_refine()
777 entropy->next_restart_num++; in encode_mcu_DC_refine()
778 entropy->next_restart_num &= 7; in encode_mcu_DC_refine()
780 entropy->restarts_to_go--; in encode_mcu_DC_refine()
871 emit_eobrun(entropy); \
873 emit_symbol(entropy, entropy->ac_tbl_no, 0xF0); \
876 emit_buffered_bits(entropy, BR_buffer, BR); \
877 BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
897 emit_eobrun(entropy); \
900 emit_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); \
904 emit_bits(entropy, (unsigned int)temp, 1); \
907 emit_buffered_bits(entropy, BR_buffer, BR); \
908 BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ \
919 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in encode_mcu_AC_refine() local
931 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_AC_refine()
932 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_AC_refine()
936 if (entropy->restarts_to_go == 0) in encode_mcu_AC_refine()
937 emit_restart(entropy, entropy->next_restart_num); in encode_mcu_AC_refine()
948 entropy->AC_refine_prepare(MCU_data[0][0], jpeg_natural_order + cinfo->Ss, in encode_mcu_AC_refine()
955 BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ in encode_mcu_AC_refine()
985 entropy->EOBRUN++; /* count an EOB */ in encode_mcu_AC_refine()
986 entropy->BE += BR; /* concat my correction bits to older ones */ in encode_mcu_AC_refine()
991 if (entropy->EOBRUN == 0x7FFF || in encode_mcu_AC_refine()
992 entropy->BE > (MAX_CORR_BITS - DCTSIZE2 + 1)) in encode_mcu_AC_refine()
993 emit_eobrun(entropy); in encode_mcu_AC_refine()
996 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_AC_refine()
997 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_AC_refine()
1001 if (entropy->restarts_to_go == 0) { in encode_mcu_AC_refine()
1002 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_AC_refine()
1003 entropy->next_restart_num++; in encode_mcu_AC_refine()
1004 entropy->next_restart_num &= 7; in encode_mcu_AC_refine()
1006 entropy->restarts_to_go--; in encode_mcu_AC_refine()
1020 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in finish_pass_phuff() local
1022 entropy->next_output_byte = cinfo->dest->next_output_byte; in finish_pass_phuff()
1023 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in finish_pass_phuff()
1026 emit_eobrun(entropy); in finish_pass_phuff()
1027 flush_bits(entropy); in finish_pass_phuff()
1029 cinfo->dest->next_output_byte = entropy->next_output_byte; in finish_pass_phuff()
1030 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in finish_pass_phuff()
1041 phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; in finish_pass_gather_phuff() local
1049 emit_eobrun(entropy); in finish_pass_gather_phuff()
1074 jpeg_gen_optimal_table(cinfo, *htblptr, entropy->count_ptrs[tbl]); in finish_pass_gather_phuff()
1088 phuff_entropy_ptr entropy; in jinit_phuff_encoder() local
1091 entropy = (phuff_entropy_ptr) in jinit_phuff_encoder()
1094 cinfo->entropy = (struct jpeg_entropy_encoder *)entropy; in jinit_phuff_encoder()
1095 entropy->pub.start_pass = start_pass_phuff; in jinit_phuff_encoder()
1099 entropy->derived_tbls[i] = NULL; in jinit_phuff_encoder()
1100 entropy->count_ptrs[i] = NULL; in jinit_phuff_encoder()
1102 entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ in jinit_phuff_encoder()