text stringlengths 0 234 |
|---|
type Pcardinal_array is access Tcardinal_array; |
procedure Dispose is new Ada.Unchecked_Deallocation (Tcardinal_array, Pcardinal_array); |
tt : Pcardinal_array; |
tt_count : Natural; |
rle_run_left : Natural := 0; |
rle_run_data : Unsigned_8 := 0; |
decode_available : Natural := Natural'Last; |
block_origin : Natural := 0; |
read_data : Unsigned_8 := 0; |
bits_available : Natural := 0; |
inuse_count : Natural; |
seq_to_unseq : array (0 .. 255) of Natural; |
global_alpha_size : Natural; |
group_count : Natural; |
-- |
selector_count : Natural; |
selector, selector_mtf : array (0 .. max_selectors) of Unsigned_8; |
-- |
type Alpha_U32_array is array (0 .. max_alpha_size) of Unsigned_32; |
type Alpha_Nat_array is array (0 .. max_alpha_size) of Natural; |
len : array (0 .. max_groups) of Alpha_Nat_array; |
global_limit, |
global_base, |
global_perm : array (0 .. max_groups) of Alpha_U32_array; |
-- |
minlens : Length_array (0 .. max_groups); |
cftab : array (0 .. 257) of Natural; |
-- |
end_reached : Boolean := False; |
in_buf : Buffer (1 .. input_buffer_size); |
in_idx : Natural := in_buf'Last + 1; |
function Read_byte return Unsigned_8 is |
res : Unsigned_8; |
begin |
if in_idx > in_buf'Last then |
Read (in_buf); |
in_idx := in_buf'First; |
end if; |
res := in_buf (in_idx); |
in_idx := in_idx + 1; |
return res; |
end Read_byte; |
procedure hb_create_decode_tables (limit, base, perm : in out Alpha_U32_array; |
length : Alpha_Nat_array; |
min_len, max_len : Natural; |
alpha_size : Integer) is |
pp, idx : Integer; |
vec : Unsigned_32; |
begin |
pp := 0; |
for i in min_len .. max_len loop |
for j in 0 .. alpha_size - 1 loop |
if length (j) = i then |
perm (pp) := Unsigned_32 (j); |
pp := pp + 1; |
end if; |
end loop; |
end loop; |
for i in 0 .. max_code_len - 1 loop |
base (i) := 0; |
limit (i) := 0; |
end loop; |
for i in 0 .. alpha_size - 1 loop |
idx := length (i) + 1; |
base (idx) := base (idx) + 1; |
end loop; |
for i in 1 .. max_code_len - 1 loop |
base (i) := base (i) + base (i - 1); |
end loop; |
vec := 0; |
for i in min_len .. max_len loop |
vec := vec + base (i + 1) - base (i); |
limit (i) := vec - 1; |
vec := vec * 2; |
end loop; |
for i in min_len + 1 .. max_len loop |
base (i) := (limit (i - 1) + 1) * 2 - base (i); |
end loop; |
end hb_create_decode_tables; |
procedure Init is |
magic : String (1 .. 3); |
b : Unsigned_8; |
begin |
-- Read the magic. |
for i in magic'Range loop |
b := Read_byte; |
magic (i) := Character'Val (b); |
end loop; |
if magic /= "BZh" then |
raise bad_header_magic; |
end if; |
-- Read the block size and allocate the working array. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.