Lines Matching refs:entropy
262 #define emit_byte_e(entropy,val) \ argument
263 { *(entropy)->next_output_byte++ = (JOCTET) (val); \
264 if (--(entropy)->free_in_buffer == 0) \
265 dump_buffer_e(entropy); }
284 dump_buffer_e (huff_entropy_ptr entropy) in dump_buffer_e() argument
287 struct jpeg_destination_mgr * dest = entropy->cinfo->dest; in dump_buffer_e()
289 if (! (*dest->empty_output_buffer) (entropy->cinfo)) in dump_buffer_e()
290 ERREXIT(entropy->cinfo, JERR_CANT_SUSPEND); in dump_buffer_e()
292 entropy->next_output_byte = dest->next_output_byte; in dump_buffer_e()
293 entropy->free_in_buffer = dest->free_in_buffer; in dump_buffer_e()
349 emit_bits_e (huff_entropy_ptr entropy, unsigned int code, int size) in LOCAL()
358 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); in LOCAL()
360 if (entropy->gather_statistics) in LOCAL()
367 put_bits = size + entropy->saved.put_bits; in LOCAL()
372 put_buffer |= entropy->saved.put_buffer; in LOCAL()
377 emit_byte_e(entropy, c); in LOCAL()
379 emit_byte_e(entropy, 0); in LOCAL()
385 entropy->saved.put_buffer = put_buffer; /* update variables */ in LOCAL()
386 entropy->saved.put_bits = put_bits; in LOCAL()
402 flush_bits_e (huff_entropy_ptr entropy) in flush_bits_e() argument
404 emit_bits_e(entropy, 0x7F, 7); /* fill any partial byte with ones */ in flush_bits_e()
405 entropy->saved.put_buffer = 0; /* and reset bit-buffer to empty */ in flush_bits_e()
406 entropy->saved.put_bits = 0; in flush_bits_e()
416 emit_dc_symbol (huff_entropy_ptr entropy, int tbl_no, int symbol) in LOCAL()
418 if (entropy->gather_statistics) in LOCAL()
419 entropy->dc_count_ptrs[tbl_no][symbol]++; in LOCAL()
421 c_derived_tbl * tbl = entropy->dc_derived_tbls[tbl_no]; in LOCAL()
422 emit_bits_e(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); in LOCAL()
429 emit_ac_symbol (huff_entropy_ptr entropy, int tbl_no, int symbol) in LOCAL()
431 if (entropy->gather_statistics) in LOCAL()
432 entropy->ac_count_ptrs[tbl_no][symbol]++; in LOCAL()
434 c_derived_tbl * tbl = entropy->ac_derived_tbls[tbl_no]; in LOCAL()
435 emit_bits_e(entropy, tbl->ehufco[symbol], tbl->ehufsi[symbol]); in LOCAL()
445 emit_buffered_bits (huff_entropy_ptr entropy, char * bufstart, in emit_buffered_bits() argument
448 if (entropy->gather_statistics) in emit_buffered_bits()
452 emit_bits_e(entropy, (unsigned int) (*bufstart), 1); in emit_buffered_bits()
464 emit_eobrun (huff_entropy_ptr entropy) in emit_eobrun() argument
468 if (entropy->EOBRUN > 0) { /* if there is any pending EOBRUN */ in emit_eobrun()
469 temp = entropy->EOBRUN; in emit_eobrun()
475 ERREXIT(entropy->cinfo, JERR_HUFF_MISSING_CODE); in emit_eobrun()
477 emit_ac_symbol(entropy, entropy->ac_tbl_no, nbits << 4); in emit_eobrun()
479 emit_bits_e(entropy, entropy->EOBRUN, nbits); in emit_eobrun()
481 entropy->EOBRUN = 0; in emit_eobrun()
484 emit_buffered_bits(entropy, entropy->bit_buffer, entropy->BE); in emit_eobrun()
485 entropy->BE = 0; in emit_eobrun()
516 emit_restart_e (huff_entropy_ptr entropy, int restart_num) in emit_restart_e() argument
520 emit_eobrun(entropy); in emit_restart_e()
522 if (! entropy->gather_statistics) { in emit_restart_e()
523 flush_bits_e(entropy); in emit_restart_e()
524 emit_byte_e(entropy, 0xFF); in emit_restart_e()
525 emit_byte_e(entropy, JPEG_RST0 + restart_num); in emit_restart_e()
528 if (entropy->cinfo->Ss == 0) { in emit_restart_e()
530 for (ci = 0; ci < entropy->cinfo->comps_in_scan; ci++) in emit_restart_e()
531 entropy->saved.last_dc_val[ci] = 0; in emit_restart_e()
534 entropy->EOBRUN = 0; in emit_restart_e()
535 entropy->BE = 0; in emit_restart_e()
548 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in encode_mcu_DC_first() local
554 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_DC_first()
555 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_DC_first()
559 if (entropy->restarts_to_go == 0) in encode_mcu_DC_first()
560 emit_restart_e(entropy, entropy->next_restart_num); in encode_mcu_DC_first()
573 temp2 = temp - entropy->saved.last_dc_val[ci]; in encode_mcu_DC_first()
574 entropy->saved.last_dc_val[ci] = temp; in encode_mcu_DC_first()
598 emit_dc_symbol(entropy, tbl, nbits); in encode_mcu_DC_first()
603 emit_bits_e(entropy, (unsigned int) temp2, nbits); in encode_mcu_DC_first()
606 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_DC_first()
607 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_DC_first()
611 if (entropy->restarts_to_go == 0) { in encode_mcu_DC_first()
612 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_DC_first()
613 entropy->next_restart_num++; in encode_mcu_DC_first()
614 entropy->next_restart_num &= 7; in encode_mcu_DC_first()
616 entropy->restarts_to_go--; in encode_mcu_DC_first()
631 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in encode_mcu_AC_first() local
639 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_AC_first()
640 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_AC_first()
644 if (entropy->restarts_to_go == 0) in encode_mcu_AC_first()
645 emit_restart_e(entropy, entropy->next_restart_num); in encode_mcu_AC_first()
684 if (entropy->EOBRUN > 0) in encode_mcu_AC_first()
685 emit_eobrun(entropy); in encode_mcu_AC_first()
688 emit_ac_symbol(entropy, entropy->ac_tbl_no, 0xF0); in encode_mcu_AC_first()
701 emit_ac_symbol(entropy, entropy->ac_tbl_no, (r << 4) + nbits); in encode_mcu_AC_first()
705 emit_bits_e(entropy, (unsigned int) temp2, nbits); in encode_mcu_AC_first()
711 entropy->EOBRUN++; /* count an EOB */ in encode_mcu_AC_first()
712 if (entropy->EOBRUN == 0x7FFF) in encode_mcu_AC_first()
713 emit_eobrun(entropy); /* force it out to avoid overflow */ in encode_mcu_AC_first()
716 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_AC_first()
717 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_AC_first()
721 if (entropy->restarts_to_go == 0) { in encode_mcu_AC_first()
722 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_AC_first()
723 entropy->next_restart_num++; in encode_mcu_AC_first()
724 entropy->next_restart_num &= 7; in encode_mcu_AC_first()
726 entropy->restarts_to_go--; in encode_mcu_AC_first()
742 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in encode_mcu_DC_refine() local
745 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_DC_refine()
746 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_DC_refine()
750 if (entropy->restarts_to_go == 0) in encode_mcu_DC_refine()
751 emit_restart_e(entropy, entropy->next_restart_num); in encode_mcu_DC_refine()
758 emit_bits_e(entropy, (unsigned int) (MCU_data[blkn][0][0] >> Al), 1); in encode_mcu_DC_refine()
761 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_DC_refine()
762 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_DC_refine()
766 if (entropy->restarts_to_go == 0) { in encode_mcu_DC_refine()
767 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_DC_refine()
768 entropy->next_restart_num++; in encode_mcu_DC_refine()
769 entropy->next_restart_num &= 7; in encode_mcu_DC_refine()
771 entropy->restarts_to_go--; in encode_mcu_DC_refine()
785 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in encode_mcu_AC_refine() local
796 entropy->next_output_byte = cinfo->dest->next_output_byte; in encode_mcu_AC_refine()
797 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in encode_mcu_AC_refine()
801 if (entropy->restarts_to_go == 0) in encode_mcu_AC_refine()
802 emit_restart_e(entropy, entropy->next_restart_num); in encode_mcu_AC_refine()
833 BR_buffer = entropy->bit_buffer + entropy->BE; /* Append bits to buffer */ in encode_mcu_AC_refine()
844 emit_eobrun(entropy); in encode_mcu_AC_refine()
846 emit_ac_symbol(entropy, entropy->ac_tbl_no, 0xF0); in encode_mcu_AC_refine()
849 emit_buffered_bits(entropy, BR_buffer, BR); in encode_mcu_AC_refine()
850 BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ in encode_mcu_AC_refine()
866 emit_eobrun(entropy); in encode_mcu_AC_refine()
869 emit_ac_symbol(entropy, entropy->ac_tbl_no, (r << 4) + 1); in encode_mcu_AC_refine()
873 emit_bits_e(entropy, (unsigned int) temp, 1); in encode_mcu_AC_refine()
876 emit_buffered_bits(entropy, BR_buffer, BR); in encode_mcu_AC_refine()
877 BR_buffer = entropy->bit_buffer; /* BE bits are gone now */ in encode_mcu_AC_refine()
883 entropy->EOBRUN++; /* count an EOB */ in encode_mcu_AC_refine()
884 entropy->BE += BR; /* concat my correction bits to older ones */ in encode_mcu_AC_refine()
889 if (entropy->EOBRUN == 0x7FFF || entropy->BE > (MAX_CORR_BITS-DCTSIZE2+1)) in encode_mcu_AC_refine()
890 emit_eobrun(entropy); in encode_mcu_AC_refine()
893 cinfo->dest->next_output_byte = entropy->next_output_byte; in encode_mcu_AC_refine()
894 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in encode_mcu_AC_refine()
898 if (entropy->restarts_to_go == 0) { in encode_mcu_AC_refine()
899 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_AC_refine()
900 entropy->next_restart_num++; in encode_mcu_AC_refine()
901 entropy->next_restart_num &= 7; in encode_mcu_AC_refine()
903 entropy->restarts_to_go--; in encode_mcu_AC_refine()
1015 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in encode_mcu_huff() local
1023 ASSIGN_STATE(state.cur, entropy->saved); in encode_mcu_huff()
1028 if (entropy->restarts_to_go == 0) in encode_mcu_huff()
1029 if (! emit_restart_s(&state, entropy->next_restart_num)) in encode_mcu_huff()
1039 entropy->dc_derived_tbls[compptr->dc_tbl_no], in encode_mcu_huff()
1040 entropy->ac_derived_tbls[compptr->ac_tbl_no])) in encode_mcu_huff()
1049 ASSIGN_STATE(entropy->saved, state.cur); in encode_mcu_huff()
1053 if (entropy->restarts_to_go == 0) { in encode_mcu_huff()
1054 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_huff()
1055 entropy->next_restart_num++; in encode_mcu_huff()
1056 entropy->next_restart_num &= 7; in encode_mcu_huff()
1058 entropy->restarts_to_go--; in encode_mcu_huff()
1072 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in finish_pass_huff() local
1076 entropy->next_output_byte = cinfo->dest->next_output_byte; in finish_pass_huff()
1077 entropy->free_in_buffer = cinfo->dest->free_in_buffer; in finish_pass_huff()
1080 emit_eobrun(entropy); in finish_pass_huff()
1081 flush_bits_e(entropy); in finish_pass_huff()
1083 cinfo->dest->next_output_byte = entropy->next_output_byte; in finish_pass_huff()
1084 cinfo->dest->free_in_buffer = entropy->free_in_buffer; in finish_pass_huff()
1089 ASSIGN_STATE(state.cur, entropy->saved); in finish_pass_huff()
1099 ASSIGN_STATE(entropy->saved, state.cur); in finish_pass_huff()
1196 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in encode_mcu_gather() local
1202 if (entropy->restarts_to_go == 0) { in encode_mcu_gather()
1205 entropy->saved.last_dc_val[ci] = 0; in encode_mcu_gather()
1207 entropy->restarts_to_go = cinfo->restart_interval; in encode_mcu_gather()
1209 entropy->restarts_to_go--; in encode_mcu_gather()
1215 htest_one_block(cinfo, MCU_data[blkn][0], entropy->saved.last_dc_val[ci], in encode_mcu_gather()
1216 entropy->dc_count_ptrs[compptr->dc_tbl_no], in encode_mcu_gather()
1217 entropy->ac_count_ptrs[compptr->ac_tbl_no]); in encode_mcu_gather()
1218 entropy->saved.last_dc_val[ci] = MCU_data[blkn][0][0]; in encode_mcu_gather()
1396 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in finish_pass_gather() local
1408 emit_eobrun(entropy); in finish_pass_gather()
1422 jpeg_gen_optimal_table(cinfo, *htblptr, entropy->dc_count_ptrs[tbl]); in finish_pass_gather()
1433 jpeg_gen_optimal_table(cinfo, *htblptr, entropy->ac_count_ptrs[tbl]); in finish_pass_gather()
1450 huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; in start_pass_huff() local
1455 entropy->pub.finish_pass = finish_pass_gather; in start_pass_huff()
1457 entropy->pub.finish_pass = finish_pass_huff; in start_pass_huff()
1460 entropy->cinfo = cinfo; in start_pass_huff()
1461 entropy->gather_statistics = gather_statistics; in start_pass_huff()
1468 entropy->pub.encode_mcu = encode_mcu_DC_first; in start_pass_huff()
1470 entropy->pub.encode_mcu = encode_mcu_AC_first; in start_pass_huff()
1473 entropy->pub.encode_mcu = encode_mcu_DC_refine; in start_pass_huff()
1475 entropy->pub.encode_mcu = encode_mcu_AC_refine; in start_pass_huff()
1477 if (entropy->bit_buffer == NULL) in start_pass_huff()
1478 entropy->bit_buffer = (char *) in start_pass_huff()
1485 entropy->ac_tbl_no = cinfo->cur_comp_info[0]->ac_tbl_no; in start_pass_huff()
1486 entropy->EOBRUN = 0; in start_pass_huff()
1487 entropy->BE = 0; in start_pass_huff()
1490 entropy->pub.encode_mcu = encode_mcu_gather; in start_pass_huff()
1492 entropy->pub.encode_mcu = encode_mcu_huff; in start_pass_huff()
1507 if (entropy->dc_count_ptrs[tbl] == NULL) in start_pass_huff()
1508 entropy->dc_count_ptrs[tbl] = (long *) in start_pass_huff()
1511 MEMZERO(entropy->dc_count_ptrs[tbl], 257 * SIZEOF(long)); in start_pass_huff()
1516 & entropy->dc_derived_tbls[tbl]); in start_pass_huff()
1519 entropy->saved.last_dc_val[ci] = 0; in start_pass_huff()
1527 if (entropy->ac_count_ptrs[tbl] == NULL) in start_pass_huff()
1528 entropy->ac_count_ptrs[tbl] = (long *) in start_pass_huff()
1531 MEMZERO(entropy->ac_count_ptrs[tbl], 257 * SIZEOF(long)); in start_pass_huff()
1534 & entropy->ac_derived_tbls[tbl]); in start_pass_huff()
1540 entropy->saved.put_buffer = 0; in start_pass_huff()
1541 entropy->saved.put_bits = 0; in start_pass_huff()
1544 entropy->restarts_to_go = cinfo->restart_interval; in start_pass_huff()
1545 entropy->next_restart_num = 0; in start_pass_huff()
1556 huff_entropy_ptr entropy; in jinit_huff_encoder() local
1559 entropy = (huff_entropy_ptr) in jinit_huff_encoder()
1562 cinfo->entropy = &entropy->pub; in jinit_huff_encoder()
1563 entropy->pub.start_pass = start_pass_huff; in jinit_huff_encoder()
1567 entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; in jinit_huff_encoder()
1568 entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL; in jinit_huff_encoder()
1572 entropy->bit_buffer = NULL; /* needed only in AC refinement scan */ in jinit_huff_encoder()