af545a72ca635cc047e73ebfd5aec92b6a8fc94f
3 { inftrees.h -- header to use inftrees.c
4 inftrees.c -- generate Huffman trees for efficient decoding
5 Copyright (C) 1995-1998 Mark Adler
7 WARNING: this file should *not* be used by applications. It is
8 part of the implementation of the compression library and is
12 Copyright (C) 1998 by Jacques Nomssi Nzali
13 For conditions of distribution and use, see copyright notice in readme.txt
24 { Maximum size of dynamic tree. The maximum found in a long but non-
25 exhaustive search was 1004 huft structures (850 for length/literals
26 and 154 for distances, the latter actually the result of an
27 exhaustive search). The actual maximum is not known, but the
28 value below is more than safe. }
38 function inflate_trees_bits(
39 var c
: array of uIntf
; { 19 code lengths }
40 var bb
: uIntf
; { bits tree desired/actual depth }
41 var tb
: pinflate_huft
; { bits tree result }
42 var hp
: array of Inflate_huft
; { space for trees }
43 var z
: z_stream
{ for messages }
46 function inflate_trees_dynamic(
47 nl
: uInt
; { number of literal/length codes }
48 nd
: uInt
; { number of distance codes }
49 var c
: Array of uIntf
; { that many (total) code lengths }
50 var bl
: uIntf
; { literal desired/actual bit depth }
51 var bd
: uIntf
; { distance desired/actual bit depth }
52 var tl
: pInflate_huft
; { literal/length tree result }
53 var td
: pInflate_huft
; { distance tree result }
54 var hp
: array of Inflate_huft
; { space for trees }
55 var z
: z_stream
{ for messages }
58 function inflate_trees_fixed (
59 var bl
: uInt
; { literal desired/actual bit depth }
60 var bd
: uInt
; { distance desired/actual bit depth }
61 var tl
: pInflate_huft
; { literal/length tree result }
62 var td
: pInflate_huft
; { distance tree result }
63 var z
: z_stream
{ for memory allocation }
70 inflate_copyright
= 'inflate 1.1.2 Copyright 1995-1998 Mark Adler';
73 If you use the zlib library in a product, an acknowledgment is welcome
74 in the documentation of your product. If for some reason you cannot
75 include such an acknowledgment, I would appreciate that you keep this
76 copyright string in the executable of your product.
81 { Tables for deflate from PKZIP's appnote.txt. }
82 cplens
: Array [0..30] Of uInt
{ Copy lengths for literal codes 257..285 }
83 = (3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
84 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0);
85 { actually lengths - 2; also see note #13 above about 258 }
89 cplext
: Array [0..30] Of uInt
{ Extra bits for literal codes 257..285 }
90 = (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2,
91 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, invalid_code
, invalid_code
);
93 cpdist
: Array [0..29] Of uInt
{ Copy offsets for distance codes 0..29 }
94 = (1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
95 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
96 8193, 12289, 16385, 24577);
98 cpdext
: Array [0..29] Of uInt
{ Extra bits for distance codes }
99 = (0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,
100 7, 7, 8, 8, 9, 9, 10, 10, 11, 11,
103 { Huffman code decoding is performed using a multi-level table lookup.
104 The fastest way to decode is to simply build a lookup table whose
105 size is determined by the longest code. However, the time it takes
106 to build this table can also be a factor if the data being decoded
107 is not very long. The most common codes are necessarily the
108 shortest codes, so those codes dominate the decoding time, and hence
109 the speed. The idea is you can have a shorter table that decodes the
110 shorter, more probable codes, and then point to subsidiary tables for
111 the longer codes. The time it costs to decode the longer codes is
112 then traded against the time it takes to make longer tables.
114 This results of this trade are in the variables lbits and dbits
115 below. lbits is the number of bits the first level table for literal/
116 length codes can decode in one step, and dbits is the same thing for
117 the distance codes. Subsequent tables are also less than or equal to
118 those sizes. These values may be adjusted either when all of the
119 codes are shorter than that, in which case the longest code length in
120 bits is used, or when the shortest code is *longer* than the requested
121 table size, in which case the length of the shortest code in bits is
124 There are two different values for the two tables, since they code a
125 different number of possibilities each. The literal/length table
126 codes 286 possible values, or in a flat code, a little over eight
127 bits. The distance table codes 30 possible values, or a little less
128 than five bits, flat. The optimum values for speed end up being
129 about one bit more than those, so lbits is 8+1 and dbits is 5+1.
130 The optimum values may differ though from machine to machine, and
131 possibly even between compilers. Your mileage may vary. }
134 { If BMAX needs to be larger than 16, then h and x[] should be uLong. }
136 BMAX
= 15; { maximum bit length of any code }
141 var b
: array of uIntf
; { code lengths in bits (all assumed <= BMAX) }
142 n
: uInt
; { number of codes (assumed <= N_MAX) }
143 s
: uInt
; { number of simple-valued codes (0..s-1) }
144 const d
: array of uIntf
; { list of base values for non-simple codes }
146 const e
: array of uIntf
; { list of extra bits for non-simple codes }
148 t
: ppInflate_huft
; { result: starting table }
149 var m
: uIntf
; { maximum lookup bits, returns actual }
150 var hp
: array of inflate_huft
; { space for trees }
151 var hn
: uInt
; { hufts used in space }
152 var v
: array of uIntf
{ working area: values in order of bit length }
154 { Given a list of code lengths and a maximum table size, make a set of
155 tables to decode that set of codes. Return Z_OK on success, Z_BUF_ERROR
156 if the given code set is incomplete (the tables are still built in this
157 case), Z_DATA_ERROR if the input is invalid (an over-subscribed set of
158 lengths), or Z_MEM_ERROR if not enough memory. }
160 a
: uInt
; { counter for codes of length k }
161 c
: Array [0..BMAX
] Of uInt
; { bit length count table }
162 f
: uInt
; { i repeats in table every f entries }
163 g
: int
; { maximum code length }
164 h
: int
; { table level }
165 i
: uInt
; {register} { counter, current code }
166 j
: uInt
; {register} { counter }
167 k
: Int
; {register} { number of bits in current code }
168 l
: int
; { bits per table (returned in m) }
169 mask
: uInt
; { (1 shl w) - 1, to avoid cc -O bug on HP }
170 p
: ^uIntf
; {register} { pointer into c[], b[], or v[] }
171 q
: pInflate_huft
; { points to current table }
172 r
: inflate_huft
; { table entry for structure assignment }
173 u
: Array [0..BMAX
-1] Of pInflate_huft
; { table stack }
174 w
: int
; {register} { bits before this table = (l*h) }
175 x
: Array [0..BMAX
] Of uInt
; { bit offsets, then code stack }
177 xp
: puIntf
; { pointer into x }
181 y
: int
; { number of dummy codes added }
182 z
: uInt
; { number of entries in current table }
184 { Generate counts for each bit length }
185 FillChar(c
,SizeOf(c
),0) ; { clear c[] }
188 Inc (c
[b
[i
]]); { assume all entries <= BMAX }
190 If (c
[0] = n
) Then { null input--all zero length codes }
192 t
^ := pInflate_huft(NIL);
198 { Find minimum and maximum length, bound [m] by those }
203 k
:= j
; { minimum code length }
204 if (uInt(l
) < j
) then
206 for i
:= BMAX
downto 1 do
209 g
:= i
; { maximum code length }
210 if (uInt(l
) > i
) then
214 { Adjust last length count to fill out codes, if needed }
221 huft_build
:= Z_DATA_ERROR
; { bad input: more codes than bits }
230 huft_build
:= Z_DATA_ERROR
; { bad input: more codes than bits }
235 { Generate starting offsets into the value table FOR each length }
243 dec(i
); { note that i = g from above }
262 { Make a table of values in order of bit lengths }
272 n
:= x
[g
]; { set n to length of v }
274 { Generate the Huffman codes and for each, make the table entries }
276 x
[0] := 0 ; { first Huffman code is zero }
277 p
:= Addr(v
) ; { grab values in bit order }
278 h
:= -1 ; { no tables yet--level -1 }
279 w
:= -l
; { bits decoded = (l*h) }
281 u
[0] := pInflate_huft(NIL); { just to keep compilers happy }
282 q
:= pInflate_huft(NIL); { ditto }
285 { go through the bit lengths (k already is bits in shortest code) }
292 { here i is the Huffman code of length k bits for value p^ }
293 { make tables up to required level }
298 Inc (w
, l
); { add bits already decoded }
299 { previous table always l bits }
300 { compute minimum size table less than or equal to l bits }
302 { table size upper limit }
304 If (z
> uInt(l
)) Then
307 { try a k-w bit table }
310 if (f
> a
+1) Then { too few codes for k-w bit table }
312 Dec(f
, a
+1); { deduct codes from patterns left }
320 begin { try smaller tables up to z bits }
324 break
; { enough codes to use up j bits }
325 Dec(f
, xp
^); { else deduct codes from patterns }
336 begin { try smaller tables up to z bits }
340 Break
; { enough codes to use up j bits }
341 Dec (f
, c
[xp
]) ; { else deduct codes from patterns }
348 z
:= 1 shl j
; { table entries for j-bit table }
350 { allocate new table }
351 if (hn
+ z
> MANY
) then { (note: doesn't matter for fixed) }
353 huft_build
:= Z_MEM_ERROR
; { not enough memory }
361 { connect to last table, if there is one }
364 x
[h
] := i
; { save pattern for backing up }
365 r
.bits
:= Byte(l
); { bits to dump before this table }
366 r
.exop
:= Byte(j
); { bits in this table }
368 {r.base := uInt( q - u[h-1] -j);} { offset to this table }
369 r
.base
:= (ptr2int(q
) - ptr2int(u
[h
-1]) ) div sizeof(q
^) - j
;
370 huft_Ptr(u
[h
-1])^[j
] := r
; { connect to last table }
373 t
^ := q
; { first table is returned result }
376 { set up table entry in r }
377 r
.bits
:= Byte(k
- w
);
379 { C-code: if (p >= v + n) - see ZUTIL.PAS for comments }
381 if ptr2int(p
)>=ptr2int(@(v
[n
])) then { also works under DPMI ?? }
382 r
.exop
:= 128 + 64 { out of values--invalid code }
386 if (p
^ < 256) then { 256 is end-of-block code }
389 r
.exop
:= 32 + 64; { EOB_code; }
390 r
.base
:= p
^; { simple code is just the value }
395 r
.exop
:= Byte(e
[p
^-s
] + 16 + 64); { non-simple--look up in lists }
400 { fill code-like entries with r }
405 huft_Ptr(q
)^[j
] := r
;
409 { backwards increment the k-bit code i }
411 while (i
and j
) <> 0 do
413 i
:= i
xor j
; { bitwise exclusive or }
418 { backup over finished tables }
419 mask
:= (1 shl w
) - 1; { needed on HP, cc -O bug }
420 while ((i
and mask
) <> x
[h
]) do
422 Dec(h
); { don't need to update q }
424 mask
:= (1 shl w
) - 1;
432 { Return Z_BUF_ERROR if we were given an incomplete table }
433 if (y
<> 0) And (g
<> 1) then
434 huft_build
:= Z_BUF_ERROR
440 function inflate_trees_bits(
441 var c
: array of uIntf
; { 19 code lengths }
442 var bb
: uIntf
; { bits tree desired/actual depth }
443 var tb
: pinflate_huft
; { bits tree result }
444 var hp
: array of Inflate_huft
; { space for trees }
445 var z
: z_stream
{ for messages }
449 hn
: uInt
; { hufts used in space }
450 v
: PuIntArray
; { work area for huft_build }
453 v
:= PuIntArray( ZALLOC(z
, 19, sizeof(uInt
)) );
456 inflate_trees_bits
:= Z_MEM_ERROR
;
460 r
:= huft_build(c
, 19, 19, cplens
, cplext
,
461 {puIntf(Z_NULL), puIntf(Z_NULL),}
462 @tb
, bb
, hp
, hn
, v
^);
463 if (r
= Z_DATA_ERROR
) then
464 z
.msg
:= 'oversubscribed dynamic bit lengths tree'
466 if (r
= Z_BUF_ERROR
) or (bb
= 0) then
468 z
.msg
:= 'incomplete dynamic bit lengths tree';
472 inflate_trees_bits
:= r
;
476 function inflate_trees_dynamic(
477 nl
: uInt
; { number of literal/length codes }
478 nd
: uInt
; { number of distance codes }
479 var c
: Array of uIntf
; { that many (total) code lengths }
480 var bl
: uIntf
; { literal desired/actual bit depth }
481 var bd
: uIntf
; { distance desired/actual bit depth }
482 var tl
: pInflate_huft
; { literal/length tree result }
483 var td
: pInflate_huft
; { distance tree result }
484 var hp
: array of Inflate_huft
; { space for trees }
485 var z
: z_stream
{ for messages }
489 hn
: uInt
; { hufts used in space }
490 v
: PuIntArray
; { work area for huft_build }
493 { allocate work area }
494 v
:= PuIntArray( ZALLOC(z
, 288, sizeof(uInt
)) );
497 inflate_trees_dynamic
:= Z_MEM_ERROR
;
501 { build literal/length tree }
502 r
:= huft_build(c
, nl
, 257, cplens
, cplext
, @tl
, bl
, hp
, hn
, v
^);
503 if (r
<> Z_OK
) or (bl
= 0) then
505 if (r
= Z_DATA_ERROR
) then
506 z
.msg
:= 'oversubscribed literal/length tree'
508 if (r
<> Z_MEM_ERROR
) then
510 z
.msg
:= 'incomplete literal/length tree';
515 inflate_trees_dynamic
:= r
;
519 { build distance tree }
520 r
:= huft_build(puIntArray(@c
[nl
])^, nd
, 0,
521 cpdist
, cpdext
, @td
, bd
, hp
, hn
, v
^);
522 if (r
<> Z_OK
) or ((bd
= 0) and (nl
> 257)) then
524 if (r
= Z_DATA_ERROR
) then
525 z
.msg
:= 'oversubscribed literal/length tree'
527 if (r
= Z_BUF_ERROR
) then
529 {$ifdef PKZIP_BUG_WORKAROUND}
533 z
.msg
:= 'incomplete literal/length tree';
537 if (r
<> Z_MEM_ERROR
) then
539 z
.msg
:= 'empty distance tree with lengths';
543 inflate_trees_dynamic
:= r
;
550 inflate_trees_dynamic
:= Z_OK
;
555 { build fixed tables only once--keep them here }
559 fixed_built
: Boolean = false;
561 FIXEDH
= 544; { number of hufts used by fixed tables }
563 fixed_mem
: array[0..FIXEDH
-1] of inflate_huft
;
566 fixed_tl
: pInflate_huft
;
567 fixed_td
: pInflate_huft
;
571 { inffixed.h -- table for decoding fixed codes }
581 fixed_tl
: array [0..288-1] of inflate_huft
= (
582 Exop
, { number of extra bits or operation }
583 bits
: Byte; { number of bits in this code or subcode }
584 {pad : uInt;} { pad structure to a power of 2 (4 bytes for }
585 { 16-bit, 8 bytes for 32-bit int's) }
586 base
: uInt
; { literal, length base, or distance base }
589 ((96,7),256), ((0,8),80), ((0,8),16), ((84,8),115), ((82,7),31),
590 ((0,8),112), ((0,8),48), ((0,9),192), ((80,7),10), ((0,8),96),
591 ((0,8),32), ((0,9),160), ((0,8),0), ((0,8),128), ((0,8),64),
592 ((0,9),224), ((80,7),6), ((0,8),88), ((0,8),24), ((0,9),144),
593 ((83,7),59), ((0,8),120), ((0,8),56), ((0,9),208), ((81,7),17),
594 ((0,8),104), ((0,8),40), ((0,9),176), ((0,8),8), ((0,8),136),
595 ((0,8),72), ((0,9),240), ((80,7),4), ((0,8),84), ((0,8),20),
596 ((85,8),227), ((83,7),43), ((0,8),116), ((0,8),52), ((0,9),200),
597 ((81,7),13), ((0,8),100), ((0,8),36), ((0,9),168), ((0,8),4),
598 ((0,8),132), ((0,8),68), ((0,9),232), ((80,7),8), ((0,8),92),
599 ((0,8),28), ((0,9),152), ((84,7),83), ((0,8),124), ((0,8),60),
600 ((0,9),216), ((82,7),23), ((0,8),108), ((0,8),44), ((0,9),184),
601 ((0,8),12), ((0,8),140), ((0,8),76), ((0,9),248), ((80,7),3),
602 ((0,8),82), ((0,8),18), ((85,8),163), ((83,7),35), ((0,8),114),
603 ((0,8),50), ((0,9),196), ((81,7),11), ((0,8),98), ((0,8),34),
604 ((0,9),164), ((0,8),2), ((0,8),130), ((0,8),66), ((0,9),228),
605 ((80,7),7), ((0,8),90), ((0,8),26), ((0,9),148), ((84,7),67),
606 ((0,8),122), ((0,8),58), ((0,9),212), ((82,7),19), ((0,8),106),
607 ((0,8),42), ((0,9),180), ((0,8),10), ((0,8),138), ((0,8),74),
608 ((0,9),244), ((80,7),5), ((0,8),86), ((0,8),22), ((192,8),0),
609 ((83,7),51), ((0,8),118), ((0,8),54), ((0,9),204), ((81,7),15),
610 ((0,8),102), ((0,8),38), ((0,9),172), ((0,8),6), ((0,8),134),
611 ((0,8),70), ((0,9),236), ((80,7),9), ((0,8),94), ((0,8),30),
612 ((0,9),156), ((84,7),99), ((0,8),126), ((0,8),62), ((0,9),220),
613 ((82,7),27), ((0,8),110), ((0,8),46), ((0,9),188), ((0,8),14),
614 ((0,8),142), ((0,8),78), ((0,9),252), ((96,7),256), ((0,8),81),
615 ((0,8),17), ((85,8),131), ((82,7),31), ((0,8),113), ((0,8),49),
616 ((0,9),194), ((80,7),10), ((0,8),97), ((0,8),33), ((0,9),162),
617 ((0,8),1), ((0,8),129), ((0,8),65), ((0,9),226), ((80,7),6),
618 ((0,8),89), ((0,8),25), ((0,9),146), ((83,7),59), ((0,8),121),
619 ((0,8),57), ((0,9),210), ((81,7),17), ((0,8),105), ((0,8),41),
620 ((0,9),178), ((0,8),9), ((0,8),137), ((0,8),73), ((0,9),242),
621 ((80,7),4), ((0,8),85), ((0,8),21), ((80,8),258), ((83,7),43),
622 ((0,8),117), ((0,8),53), ((0,9),202), ((81,7),13), ((0,8),101),
623 ((0,8),37), ((0,9),170), ((0,8),5), ((0,8),133), ((0,8),69),
624 ((0,9),234), ((80,7),8), ((0,8),93), ((0,8),29), ((0,9),154),
625 ((84,7),83), ((0,8),125), ((0,8),61), ((0,9),218), ((82,7),23),
626 ((0,8),109), ((0,8),45), ((0,9),186), ((0,8),13), ((0,8),141),
627 ((0,8),77), ((0,9),250), ((80,7),3), ((0,8),83), ((0,8),19),
628 ((85,8),195), ((83,7),35), ((0,8),115), ((0,8),51), ((0,9),198),
629 ((81,7),11), ((0,8),99), ((0,8),35), ((0,9),166), ((0,8),3),
630 ((0,8),131), ((0,8),67), ((0,9),230), ((80,7),7), ((0,8),91),
631 ((0,8),27), ((0,9),150), ((84,7),67), ((0,8),123), ((0,8),59),
632 ((0,9),214), ((82,7),19), ((0,8),107), ((0,8),43), ((0,9),182),
633 ((0,8),11), ((0,8),139), ((0,8),75), ((0,9),246), ((80,7),5),
634 ((0,8),87), ((0,8),23), ((192,8),0), ((83,7),51), ((0,8),119),
635 ((0,8),55), ((0,9),206), ((81,7),15), ((0,8),103), ((0,8),39),
636 ((0,9),174), ((0,8),7), ((0,8),135), ((0,8),71), ((0,9),238),
637 ((80,7),9), ((0,8),95), ((0,8),31), ((0,9),158), ((84,7),99),
638 ((0,8),127), ((0,8),63), ((0,9),222), ((82,7),27), ((0,8),111),
639 ((0,8),47), ((0,9),190), ((0,8),15), ((0,8),143), ((0,8),79),
640 ((0,9),254), ((96,7),256), ((0,8),80), ((0,8),16), ((84,8),115),
641 ((82,7),31), ((0,8),112), ((0,8),48), ((0,9),193), ((80,7),10),
642 ((0,8),96), ((0,8),32), ((0,9),161), ((0,8),0), ((0,8),128),
643 ((0,8),64), ((0,9),225), ((80,7),6), ((0,8),88), ((0,8),24),
644 ((0,9),145), ((83,7),59), ((0,8),120), ((0,8),56), ((0,9),209),
645 ((81,7),17), ((0,8),104), ((0,8),40), ((0,9),177), ((0,8),8),
646 ((0,8),136), ((0,8),72), ((0,9),241), ((80,7),4), ((0,8),84),
647 ((0,8),20), ((85,8),227), ((83,7),43), ((0,8),116), ((0,8),52),
648 ((0,9),201), ((81,7),13), ((0,8),100), ((0,8),36), ((0,9),169),
649 ((0,8),4), ((0,8),132), ((0,8),68), ((0,9),233), ((80,7),8),
650 ((0,8),92), ((0,8),28), ((0,9),153), ((84,7),83), ((0,8),124),
651 ((0,8),60), ((0,9),217), ((82,7),23), ((0,8),108), ((0,8),44),
652 ((0,9),185), ((0,8),12), ((0,8),140), ((0,8),76), ((0,9),249),
653 ((80,7),3), ((0,8),82), ((0,8),18), ((85,8),163), ((83,7),35),
654 ((0,8),114), ((0,8),50), ((0,9),197), ((81,7),11), ((0,8),98),
655 ((0,8),34), ((0,9),165), ((0,8),2), ((0,8),130), ((0,8),66),
656 ((0,9),229), ((80,7),7), ((0,8),90), ((0,8),26), ((0,9),149),
657 ((84,7),67), ((0,8),122), ((0,8),58), ((0,9),213), ((82,7),19),
658 ((0,8),106), ((0,8),42), ((0,9),181), ((0,8),10), ((0,8),138),
659 ((0,8),74), ((0,9),245), ((80,7),5), ((0,8),86), ((0,8),22),
660 ((192,8),0), ((83,7),51), ((0,8),118), ((0,8),54), ((0,9),205),
661 ((81,7),15), ((0,8),102), ((0,8),38), ((0,9),173), ((0,8),6),
662 ((0,8),134), ((0,8),70), ((0,9),237), ((80,7),9), ((0,8),94),
663 ((0,8),30), ((0,9),157), ((84,7),99), ((0,8),126), ((0,8),62),
664 ((0,9),221), ((82,7),27), ((0,8),110), ((0,8),46), ((0,9),189),
665 ((0,8),14), ((0,8),142), ((0,8),78), ((0,9),253), ((96,7),256),
666 ((0,8),81), ((0,8),17), ((85,8),131), ((82,7),31), ((0,8),113),
667 ((0,8),49), ((0,9),195), ((80,7),10), ((0,8),97), ((0,8),33),
668 ((0,9),163), ((0,8),1), ((0,8),129), ((0,8),65), ((0,9),227),
669 ((80,7),6), ((0,8),89), ((0,8),25), ((0,9),147), ((83,7),59),
670 ((0,8),121), ((0,8),57), ((0,9),211), ((81,7),17), ((0,8),105),
671 ((0,8),41), ((0,9),179), ((0,8),9), ((0,8),137), ((0,8),73),
672 ((0,9),243), ((80,7),4), ((0,8),85), ((0,8),21), ((80,8),258),
673 ((83,7),43), ((0,8),117), ((0,8),53), ((0,9),203), ((81,7),13),
674 ((0,8),101), ((0,8),37), ((0,9),171), ((0,8),5), ((0,8),133),
675 ((0,8),69), ((0,9),235), ((80,7),8), ((0,8),93), ((0,8),29),
676 ((0,9),155), ((84,7),83), ((0,8),125), ((0,8),61), ((0,9),219),
677 ((82,7),23), ((0,8),109), ((0,8),45), ((0,9),187), ((0,8),13),
678 ((0,8),141), ((0,8),77), ((0,9),251), ((80,7),3), ((0,8),83),
679 ((0,8),19), ((85,8),195), ((83,7),35), ((0,8),115), ((0,8),51),
680 ((0,9),199), ((81,7),11), ((0,8),99), ((0,8),35), ((0,9),167),
681 ((0,8),3), ((0,8),131), ((0,8),67), ((0,9),231), ((80,7),7),
682 ((0,8),91), ((0,8),27), ((0,9),151), ((84,7),67), ((0,8),123),
683 ((0,8),59), ((0,9),215), ((82,7),19), ((0,8),107), ((0,8),43),
684 ((0,9),183), ((0,8),11), ((0,8),139), ((0,8),75), ((0,9),247),
685 ((80,7),5), ((0,8),87), ((0,8),23), ((192,8),0), ((83,7),51),
686 ((0,8),119), ((0,8),55), ((0,9),207), ((81,7),15), ((0,8),103),
687 ((0,8),39), ((0,9),175), ((0,8),7), ((0,8),135), ((0,8),71),
688 ((0,9),239), ((80,7),9), ((0,8),95), ((0,8),31), ((0,9),159),
689 ((84,7),99), ((0,8),127), ((0,8),63), ((0,9),223), ((82,7),27),
690 ((0,8),111), ((0,8),47), ((0,9),191), ((0,8),15), ((0,8),143),
691 ((0,8),79), ((0,9),255)
696 fixed_td
: array[0..32-1] of inflate_huft
= (
697 (Exop
:80;bits
:5;base
:1), (Exop
:87;bits
:5;base
:257), (Exop
:83;bits
:5;base
:17),
698 (Exop
:91;bits
:5;base
:4097), (Exop
:81;bits
:5;base
), (Exop
:89;bits
:5;base
:1025),
699 (Exop
:85;bits
:5;base
:65), (Exop
:93;bits
:5;base
:16385), (Exop
:80;bits
:5;base
:3),
700 (Exop
:88;bits
:5;base
:513), (Exop
:84;bits
:5;base
:33), (Exop
:92;bits
:5;base
:8193),
701 (Exop
:82;bits
:5;base
:9), (Exop
:90;bits
:5;base
:2049), (Exop
:86;bits
:5;base
:129),
702 (Exop
:192;bits
:5;base
:24577), (Exop
:80;bits
:5;base
:2), (Exop
:87;bits
:5;base
:385),
703 (Exop
:83;bits
:5;base
:25), (Exop
:91;bits
:5;base
:6145), (Exop
:81;bits
:5;base
:7),
704 (Exop
:89;bits
:5;base
:1537), (Exop
:85;bits
:5;base
:97), (Exop
:93;bits
:5;base
:24577),
705 (Exop
:80;bits
:5;base
:4), (Exop
:88;bits
:5;base
:769), (Exop
:84;bits
:5;base
:49),
706 (Exop
:92;bits
:5;base
:12289), (Exop
:82;bits
:5;base
:13), (Exop
:90;bits
:5;base
:3073),
707 (Exop
:86;bits
:5;base
:193), (Exop
:192;bits
:5;base
:24577)
711 function inflate_trees_fixed(
712 var bl
: uInt
; { literal desired/actual bit depth }
713 var bd
: uInt
; { distance desired/actual bit depth }
714 var tl
: pInflate_huft
; { literal/length tree result }
715 var td
: pInflate_huft
; { distance tree result }
716 var z
: z_stream
{ for memory allocation }
719 pFixed_table
= ^fixed_table
;
720 fixed_table
= array[0..288-1] of uIntf
;
722 k
: int
; { temporary variable }
723 c
: pFixed_table
; { length list for huft_build }
724 v
: PuIntArray
; { work area for huft_build }
726 f
: uInt
; { number of hufts used in fixed_mem }
728 { build fixed tables if not already (multiple overlapped executions ok) }
729 if not fixed_built
then
734 c
:= pFixed_table( ZALLOC(z
, 288, sizeof(uInt
)) );
737 inflate_trees_fixed
:= Z_MEM_ERROR
;
740 v
:= PuIntArray( ZALLOC(z
, 288, sizeof(uInt
)) );
744 inflate_trees_fixed
:= Z_MEM_ERROR
;
749 for k
:= 0 to Pred(144) do
751 for k
:= 144 to Pred(256) do
753 for k
:= 256 to Pred(280) do
755 for k
:= 280 to Pred(288) do
758 huft_build(c
^, 288, 257, cplens
, cplext
, @fixed_tl
, fixed_bl
,
762 for k
:= 0 to Pred(30) do
765 huft_build(c
^, 30, 0, cpdist
, cpdext
, @fixed_td
, fixed_bd
,
777 inflate_trees_fixed
:= Z_OK
;
778 end; { inflate_trees_fixed }