text
stringlengths
0
234
16#f0a5bd1d#, 16#f464a0aa#, 16#f9278673#, 16#fde69bc4#,
16#89b8fd09#, 16#8d79e0be#, 16#803ac667#, 16#84fbdbd0#,
16#9abc8bd5#, 16#9e7d9662#, 16#933eb0bb#, 16#97ffad0c#,
16#afb010b1#, 16#ab710d06#, 16#a6322bdf#, 16#a2f33668#,
16#bcb4666d#, 16#b8757bda#, 16#b5365d03#, 16#b1f740b4#
);
procedure Update (CRC_Value : in out Unsigned_32; val : Unsigned_8) is
begin
CRC_Value :=
CRC32_Table (16#FF# and (Shift_Right (CRC_Value, 24) xor Unsigned_32 (val)))
xor
Shift_Left (CRC_Value, 8);
end Update;
procedure Init (CRC_Value : out Unsigned_32) is
begin
CRC_Value := 16#FFFF_FFFF#;
end Init;
function Final (CRC_Value : Unsigned_32) return Unsigned_32 is
begin
return not CRC_Value;
end Final;
end CRC;
compare_final_CRC : Boolean := False;
stored_blockcrc, mem_stored_blockcrc, computed_crc : Unsigned_32;
-- Decode a new compressed block.
function decode_block return Boolean is
magic : String (1 .. 6);
begin
for i in 1 .. 6 loop
magic (i) := Character'Val (get_byte);
end loop;
if magic = "1AY&SY" then
if check_CRC then
if compare_final_CRC then
null; -- initialisation is delayed until the rle buffer is empty
else
CRC.Init (computed_crc); -- Initialize for next block.
end if;
end if;
stored_blockcrc := get_cardinal;
block_randomized := get_boolean;
block_origin := Natural (get_cardinal24);
-- Receive the mapping table.
receive_mapping_table;
global_alpha_size := inuse_count + 2;
-- Receive the selectors.
receive_selectors;
-- Undo the MTF values for the selectors.
undo_mtf_values;
-- Receive the coding tables.
receive_coding_tables;
-- Build the Huffman tables.
make_hufftab;
-- Receive the MTF values.
receive_mtf_values;
-- Undo the Burrows Wheeler transformation.
detransform;
decode_available := tt_count;
return True;
elsif magic = Character'Val (16#17#) & "rE8P" & Character'Val (16#90#) then
return False;
else
raise bad_block_magic;
end if;
end decode_block;
next_rle_idx : Integer := -2;
buf : Buffer (1 .. output_buffer_size);
last : Natural;
procedure Read is
shorten : Natural := 0;
procedure rle_read is
rle_len : Natural;
data : Unsigned_8;
idx : Integer := buf'First;
count : Integer := buf'Length;
--
procedure rle_write is
pragma Inline (rle_write);
begin
loop
buf (idx) := data;
idx := idx + 1;
count := count - 1;
rle_len := rle_len - 1;
if check_CRC then
CRC.Update (computed_crc, data);
if rle_len = 0 and then compare_final_CRC then
if CRC.Final (computed_crc) /= mem_stored_blockcrc then
raise block_crc_check_failed;
end if;
compare_final_CRC := False;