nl_tokens: Send one empty static block to give enough lookahead for inflate . This takes 10 bits of which 7 may remain in the bit buffer . The current inflate code requires 9 bits of lookahead . If the last two codes for the previous block ( real code plus EOB ) were coded on 5 bits or less inflate may have only 5 + 3 bits of lookahead to decode the last real code . In this case we send two empty static blocks instead of one . ( There are no problems if the previous block is stored or fixed . ) To simplify the code we assume the worst case of last real code encoded on one bit only .
pl_tokens: <mask> _tr_align ( ) { send_bits ( STATIC_TREES << 1 , 3 ) ; send_code ( END_BLOCK , StaticTree . static_ltree ) ; bi_flush ( ) ; // Of the 10 bits for the empty block, we have already sent // (10 - bi_valid) bits. The lookahead for the last real code (before // the EOB of the previous block) was thus at least one plus the length // of the EOB plus what we have just sent of the empty static block. if ( 1 + last_eob_len + 10 - bi_valid < 9 ) { send_bits ( STATIC_TREES << 1 , 3 ) ; send_code ( END_BLOCK , StaticTree . static_ltree ) ; bi_flush ( ) ; } last_eob_len = 7 ; }