text
stringlengths
0
234
CRC.Init (computed_crc); -- Initialize for next block.
end if;
end if;
exit when rle_len = 0 or else count = 0;
end loop;
end rle_write;
--
-- handle extreme cases of data of length 1, 2
input_dried : exception;
--
-- Make next_rle_idx index to the next decoded byte.
-- If next_rle_idx did index to the last
-- byte in the current block, decode the next block.
--
procedure consume_rle is
pragma Inline (consume_rle);
begin
next_rle_idx := Integer (Shift_Right (tt.all (next_rle_idx), 8));
decode_available := decode_available - 1;
if decode_available = 0 then
compare_final_CRC := True;
mem_stored_blockcrc := stored_blockcrc;
-- ^ There might be a new block when last block's
-- rle is finally emptied.
--
-- ** New block
if decode_block then
next_rle_idx := Natural (Shift_Right (tt.all (block_origin), 8));
else
next_rle_idx := -1;
end_reached := True;
end if;
-- **
if end_reached then
raise input_dried;
end if;
end if;
end consume_rle;
--
function rle_byte return Unsigned_8 is
pragma Inline (rle_byte);
begin
return Unsigned_8 (tt.all (next_rle_idx) and 16#FF#);
end rle_byte;
--
function rle_possible return Boolean is
pragma Inline (rle_possible);
begin
return decode_available > 0 and then data = rle_byte;
end rle_possible;
--
begin -- rle_read
rle_len := rle_run_left;
data := rle_run_data;
if block_randomized then
raise randomized_not_yet_implemented;
end if;
if rle_len /= 0 then
rle_write;
if count = 0 then
shorten := 0;
rle_run_data := data;
rle_run_left := rle_len;
return;
end if;
end if;
begin
-- The big loop
loop
if decode_available = 0 or else end_reached then
exit;
end if;
rle_len := 1;
data := rle_byte;
consume_rle;
if rle_possible then
rle_len := rle_len + 1;
consume_rle;
if rle_possible then
rle_len := rle_len + 1;
consume_rle;
if rle_possible then
consume_rle;
rle_len := rle_len + Natural (rle_byte) + 1;
consume_rle;
end if;
end if;
end if;
rle_write;
exit when count = 0;
end loop;
exception
when input_dried => rle_write;
Function Definition: procedure Dispose is new
Function Body: Ada.Unchecked_Deallocation (String, p_String);
procedure Dispose is new
Ada.Unchecked_Deallocation (Ada.Streams.Stream_Element_Array,
p_Stream_Element_Array);