text
stringlengths
0
234
UnZ_Glob.slide ( UnZ_Glob.slide_index ) :=
U8( UnZ_IO.Bit_buffer.Read_and_dump(8) );
UnZ_Glob.slide_index:= UnZ_Glob.slide_index + 1;
UnZ_IO.Flush_if_full(UnZ_Glob.slide_index);
end loop;
if full_trace then
Ada.Text_IO.Put_Line("End Inflate_stored_block");
end if;
end Inflate_stored_block;
-- Copy lengths for literal codes 257..285
copy_lengths_literal : Length_array( 0..30 ) :=
( 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 );
-- Extra bits for literal codes 257..285
extra_bits_literal : Length_array( 0..30 ) :=
( 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid, invalid );
-- Copy offsets for distance codes 0..29 (30..31: deflate_e)
copy_offset_distance : constant Length_array( 0..31 ) :=
( 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 32769, 49153 );
-- Extra bits for distance codes
extra_bits_distance : constant Length_array( 0..31 ) :=
( 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14 );
max_dist: Integer:= 29; -- changed to 31 for deflate_e
procedure Inflate_fixed_block is
Tl, -- literal/length code table
Td : p_Table_list; -- distance code table
Bl, Bd : Integer; -- lookup bits for tl/bd
huft_incomplete : Boolean;
-- length list for HufT_build (literal table)
L: constant Length_array( 0..287 ):=
( 0..143=> 8, 144..255=> 9, 256..279=> 7, 280..287=> 8);
begin
if full_trace then
Ada.Text_IO.Put_Line("Begin Inflate_fixed_block");
end if;
-- make a complete, but wrong code set
Bl := 7;
HufT_build(
L, 257, copy_lengths_literal, extra_bits_literal,
Tl, Bl, huft_incomplete
);
-- Make an incomplete code set
Bd := 5;
begin
HufT_build(
(0..max_dist => 5), 0,
copy_offset_distance, extra_bits_distance,
Td, Bd, huft_incomplete
);
if huft_incomplete then
if full_trace then
Ada.Text_IO.Put_Line(
"td is incomplete, pointer=null: " &
Boolean'Image(Td=null)
);
end if;
end if;
exception
when huft_out_of_memory | huft_error =>
HufT_free( Tl );
raise error_in_image_data;
Function Definition: procedure Inflate_dynamic_block is
Function Body: bit_order : constant array ( 0..18 ) of Natural :=
( 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 );
Lbits : constant:= 9;
Dbits : constant:= 6;
current_length: Natural:= 0;
defined, number_of_lengths: Natural;
Tl, -- literal/length code tables
Td : p_Table_list; -- distance code tables
CT_dyn_idx : Integer; -- current table element
Bl, Bd : Integer; -- lookup bits for tl/bd
Nb : Natural; -- number of bit length codes
Nl : Natural; -- number of literal length codes
Nd : Natural; -- number of distance codes