text
stringlengths
0
234
-- Adjust last length count to fill out codes, if needed
y := Integer (Shift_Left (Unsigned_32'(1), j)); -- y := 2 ** j;
while j < i loop
y := y - count (j);
if y < 0 then
raise huft_error;
end if;
y := y * 2;
j := j + 1;
end loop;
y := y - count (i);
if y < 0 then
raise huft_error;
end if;
count (i) := count (i) + y;
-- Generate starting offsets into the value table for each length
offset (1) := 0;
j := 0;
for idx in 2 .. i loop
j := j + count (idx - 1);
offset (idx) := j;
end loop;
-- Make table of values in order of bit length
for idx in b'Range loop
j := b (idx);
if j /= 0 then
v (offset (j)) := idx - b'First;
offset (j) := offset (j) + 1;
end if;
end loop;
-- Generate huffman codes and for each, make the table entries
code_stack (0) := 0;
i := 0;
v_idx := v'First;
bits (-1) := 0;
-- go through the bit lengths (kcc already is bits in shortest code)
for k in kcc .. g loop
for am1 in reverse 0 .. count (k) - 1 loop -- a counts codes of length k
-- here i is the huffman code of length k bits for value v (v_idx)
while k > w + bits (table_level) loop
w := w + bits (table_level); -- Length of tables to this position
table_level := table_level + 1;
z := g - w; -- Compute min size table <= m bits
if z > m then
z := m;
end if;
j := k - w;
f := Integer (Shift_Left (Unsigned_32'(1), j)); -- f := 2 ** j;
if f > am1 + 2 then -- Try a k - w bit table
f := f - (am1 + 2);
c_idx := k;
loop -- Try smaller tables up to z bits
j := j + 1;
exit when j >= z;
f := f * 2;
c_idx := c_idx + 1;
exit when f - count (c_idx) <= 0;
f := f - count (c_idx);
end loop;
end if;
if w + j > el and then w < el then
j := el - w; -- Make EOB code end at table
end if;
if w = 0 then
j := m; -- Fix : main table always m bits!
end if;
z := Integer (Shift_Left (Unsigned_32'(1), j)); -- z := 2 ** j;
bits (table_level) := j;
-- Allocate and link new table
begin
current_table_ptr := new HufT_table (0 .. z);
new_node_ptr := new Table_list'(current_table_ptr, null);
exception
when Storage_Error =>
raise huft_out_of_memory;
Function Definition: procedure Translation_inst is new Limited_Translation (No_Limitation);
Function Body: procedure Translation (actor : in out GLOBE_3D.Camera;
gc : Game_Control.Command_set;
gx, gy : GLOBE_3D.Real;
unitary_change : GLOBE_3D.Real;
deceleration : GLOBE_3D.Real;
time_step : GLOBE_3D.Real) renames Translation_inst;