Unit JdHuff

Classes

Functions

jinit_huff_decoder - Module initialization routine for Huffman entropy decoding.
jpeg_fill_bit_buffer - Load up the bit buffer to a depth of at least nbits

GLOBAL
jpeg_huff_decode - GLOBAL

Out-of-line code for Huffman code decoding.
jpeg_make_d_derived_tbl - Compute the derived values for a Huffman table.

Types

bitread_perm_state
bitread_working_state
bit_buf_type
d_derived_tbl
d_derived_tbl_ptr

Constants

BIT_BUF_SIZE
HUFF_LOOKAHEAD

Variables


Functions


procedure jinit_huff_decoder (cinfo : j_decompress_ptr);

Module initialization routine for Huffman entropy decoding. } {GLOBAL

Module initialization routine for Huffman entropy decoding. } {GLOBAL


function jpeg_fill_bit_buffer (var state : bitread_working_state; get_buffer : bit_buf_type; {register} bits_left : int; {register} nbits : int) : boolean;

Load up the bit buffer to a depth of at least nbits

GLOBAL


function jpeg_huff_decode(var state : bitread_working_state; get_buffer : bit_buf_type; {register} bits_left : int; {register} htbl : d_derived_tbl_ptr; min_bits : int) : int;

GLOBAL

Out-of-line code for Huffman code decoding. See jdhuff.h for info about usage. } {GLOBAL


procedure jpeg_make_d_derived_tbl (cinfo : j_decompress_ptr; htbl : JHUFF_TBL_PTR; var pdtbl : d_derived_tbl_ptr);

Compute the derived values for a Huffman table. Note this is also used by jdphuff.c. } {GLOBAL

Compute the derived values for a Huffman table. Note this is also used by jdphuff.c. } {GLOBAL


Types


bitread_perm_state = record
get_buffer : bit_buf_type;
bits_left : int;
printed_eod : boolean;
end;
size of buffer in bits } { If long is > 32 bits on your machine, and shifting/masking longs is reasonably fast, making bit_buf_type be long and setting BIT_BUF_SIZE appropriately should be a win. Unfortunately we can't do this with something like #define BIT_BUF_SIZE (sizeof(bit_buf_type)*8) because not all machines measure sizeof in 8-bit bytes.
bitread_working_state = record
next_input_byte : JOCTETptr;
bytes_in_buffer : size_t;
unread_marker : int;
get_buffer : bit_buf_type;
bits_left : int;
cinfo : j_decompress_ptr;
printed_eod_ptr : ^boolean;
end;
flag to suppress multiple warning msgs
bit_buf_type = INT32 
Fetching the next N bits from the input stream is a time-critical operation for the Huffman decoders. We implement it with a combination of inline macros and out-of-line subroutines. Note that N (the number of bits demanded at one time) never exceeds 15 for JPEG use. We read source bytes into get_buffer and dole out bits as needed. If get_buffer already contains enough bits, they are fetched in-line by the macros CHECK_BIT_BUFFER and GET_BITS. When there aren't enough bits, jpeg_fill_bit_buffer is called; it will attempt to fill get_buffer as full as possible (not just to the number of bits needed; this prefetching reduces the overhead cost of calling jpeg_fill_bit_buffer). Note that jpeg_fill_bit_buffer may return FALSE to indicate suspension. On TRUE return, jpeg_fill_bit_buffer guarantees that get_buffer contains at least the requested number of bits --- dummy zeroes are inserted if necessary.
d_derived_tbl = record
mincode : array[0..17-1] of INT32;
maxcode : array[0..18-1] of INT32;
valptr : array[0..17-1] of int;
pub : JHUFF_TBL_PTR;
look_nbits : array[0..(1 shl HUFF_LOOKAHEAD)-1] of int;
look_sym : array[0..(1 shl HUFF_LOOKAHEAD)-1] of UINT8;
end;

d_derived_tbl_ptr = ^d_derived_tbl
# of bits of lookahead

Constants

BIT_BUF_SIZE = 32

type of bit-extraction buffer

HUFF_LOOKAHEAD = 8

Declarations shared with jdphuff.c } { Derived data constructed for each Huffman table

Variables