Lines Matching full:entropy
11 * This file contains portable arithmetic entropy encoding routines for JPEG
30 /* Expanded entropy decoder object for arithmetic decoding. */
117 register arith_entropy_ptr e = (arith_entropy_ptr)cinfo->entropy; in arith_decode()
201 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in process_restart() local
213 memset(entropy->dc_stats[compptr->dc_tbl_no], 0, DC_STAT_BINS); in process_restart()
215 entropy->last_dc_val[ci] = 0; in process_restart()
216 entropy->dc_context[ci] = 0; in process_restart()
219 memset(entropy->ac_stats[compptr->ac_tbl_no], 0, AC_STAT_BINS); in process_restart()
224 entropy->c = 0; in process_restart()
225 entropy->a = 0; in process_restart()
226 entropy->ct = -16; /* force reading 2 initial bytes to fill C */ in process_restart()
229 entropy->restarts_to_go = cinfo->restart_interval; in process_restart()
252 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in decode_mcu_DC_first() local
260 if (entropy->restarts_to_go == 0) in decode_mcu_DC_first()
262 entropy->restarts_to_go--; in decode_mcu_DC_first()
265 if (entropy->ct == -1) return TRUE; /* if error do nothing */ in decode_mcu_DC_first()
277 st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; in decode_mcu_DC_first()
281 entropy->dc_context[ci] = 0; in decode_mcu_DC_first()
289 st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ in decode_mcu_DC_first()
293 entropy->ct = -1; /* magnitude overflow */ in decode_mcu_DC_first()
301 entropy->dc_context[ci] = 0; /* zero diff category */ in decode_mcu_DC_first()
303 entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */ in decode_mcu_DC_first()
305 entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */ in decode_mcu_DC_first()
312 entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff; in decode_mcu_DC_first()
316 (*block)[0] = (JCOEF)LEFT_SHIFT(entropy->last_dc_val[ci], cinfo->Al); in decode_mcu_DC_first()
331 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in decode_mcu_AC_first() local
339 if (entropy->restarts_to_go == 0) in decode_mcu_AC_first()
341 entropy->restarts_to_go--; in decode_mcu_AC_first()
344 if (entropy->ct == -1) return TRUE; /* if error do nothing */ in decode_mcu_AC_first()
354 st = entropy->ac_stats[tbl] + 3 * (k - 1); in decode_mcu_AC_first()
360 entropy->ct = -1; /* spectral overflow */ in decode_mcu_AC_first()
366 sign = arith_decode(cinfo, entropy->fixed_bin); in decode_mcu_AC_first()
372 st = entropy->ac_stats[tbl] + in decode_mcu_AC_first()
377 entropy->ct = -1; /* magnitude overflow */ in decode_mcu_AC_first()
405 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in decode_mcu_DC_refine() local
411 if (entropy->restarts_to_go == 0) in decode_mcu_DC_refine()
413 entropy->restarts_to_go--; in decode_mcu_DC_refine()
416 st = entropy->fixed_bin; /* use fixed probability estimation */ in decode_mcu_DC_refine()
438 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in decode_mcu_AC_refine() local
447 if (entropy->restarts_to_go == 0) in decode_mcu_AC_refine()
449 entropy->restarts_to_go--; in decode_mcu_AC_refine()
452 if (entropy->ct == -1) return TRUE; /* if error do nothing */ in decode_mcu_AC_refine()
466 st = entropy->ac_stats[tbl] + 3 * (k - 1); in decode_mcu_AC_refine()
481 if (arith_decode(cinfo, entropy->fixed_bin)) in decode_mcu_AC_refine()
490 entropy->ct = -1; /* spectral overflow */ in decode_mcu_AC_refine()
507 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in decode_mcu() local
516 if (entropy->restarts_to_go == 0) in decode_mcu()
518 entropy->restarts_to_go--; in decode_mcu()
521 if (entropy->ct == -1) return TRUE; /* if error do nothing */ in decode_mcu()
535 st = entropy->dc_stats[tbl] + entropy->dc_context[ci]; in decode_mcu()
539 entropy->dc_context[ci] = 0; in decode_mcu()
547 st = entropy->dc_stats[tbl] + 20; /* Table F.4: X1 = 20 */ in decode_mcu()
551 entropy->ct = -1; /* magnitude overflow */ in decode_mcu()
559 entropy->dc_context[ci] = 0; /* zero diff category */ in decode_mcu()
561 entropy->dc_context[ci] = 12 + (sign * 4); /* large diff category */ in decode_mcu()
563 entropy->dc_context[ci] = 4 + (sign * 4); /* small diff category */ in decode_mcu()
570 entropy->last_dc_val[ci] = (entropy->last_dc_val[ci] + v) & 0xffff; in decode_mcu()
574 (*block)[0] = (JCOEF)entropy->last_dc_val[ci]; in decode_mcu()
582 st = entropy->ac_stats[tbl] + 3 * (k - 1); in decode_mcu()
588 entropy->ct = -1; /* spectral overflow */ in decode_mcu()
594 sign = arith_decode(cinfo, entropy->fixed_bin); in decode_mcu()
600 st = entropy->ac_stats[tbl] + in decode_mcu()
605 entropy->ct = -1; /* magnitude overflow */ in decode_mcu()
634 arith_entropy_ptr entropy = (arith_entropy_ptr)cinfo->entropy; in start_pass() local
688 entropy->pub.decode_mcu = decode_mcu_DC_first; in start_pass()
690 entropy->pub.decode_mcu = decode_mcu_AC_first; in start_pass()
693 entropy->pub.decode_mcu = decode_mcu_DC_refine; in start_pass()
695 entropy->pub.decode_mcu = decode_mcu_AC_refine; in start_pass()
705 entropy->pub.decode_mcu = decode_mcu; in start_pass()
715 if (entropy->dc_stats[tbl] == NULL) in start_pass()
716 entropy->dc_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) in start_pass()
718 memset(entropy->dc_stats[tbl], 0, DC_STAT_BINS); in start_pass()
720 entropy->last_dc_val[ci] = 0; in start_pass()
721 entropy->dc_context[ci] = 0; in start_pass()
727 if (entropy->ac_stats[tbl] == NULL) in start_pass()
728 entropy->ac_stats[tbl] = (unsigned char *)(*cinfo->mem->alloc_small) in start_pass()
730 memset(entropy->ac_stats[tbl], 0, AC_STAT_BINS); in start_pass()
735 entropy->c = 0; in start_pass()
736 entropy->a = 0; in start_pass()
737 entropy->ct = -16; /* force reading 2 initial bytes to fill C */ in start_pass()
738 entropy->pub.insufficient_data = FALSE; in start_pass()
741 entropy->restarts_to_go = cinfo->restart_interval; in start_pass()
746 * Module initialization routine for arithmetic entropy decoding.
752 arith_entropy_ptr entropy; in jinit_arith_decoder() local
755 entropy = (arith_entropy_ptr) in jinit_arith_decoder()
758 cinfo->entropy = (struct jpeg_entropy_decoder *)entropy; in jinit_arith_decoder()
759 entropy->pub.start_pass = start_pass; in jinit_arith_decoder()
763 entropy->dc_stats[i] = NULL; in jinit_arith_decoder()
764 entropy->ac_stats[i] = NULL; in jinit_arith_decoder()
768 entropy->fixed_bin[0] = 113; in jinit_arith_decoder()