=========================================================================== * 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
(s)
| 890 | * on one bit only. |
| 891 | */ |
| 892 | void _tr_align(s) |
| 893 | deflate_state *s; |
| 894 | { |
| 895 | send_bits(s, STATIC_TREES<<1, 3); |
| 896 | send_code(s, END_BLOCK, static_ltree); |
| 897 | #ifdef DEBUG |
| 898 | s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ |
| 899 | #endif |
| 900 | bi_flush(s); |
| 901 | /* Of the 10 bits for the empty block, we have already sent |
| 902 | * (10 - bi_valid) bits. The lookahead for the last real code (before |
| 903 | * the EOB of the previous block) was thus at least one plus the length |
| 904 | * of the EOB plus what we have just sent of the empty static block. |
| 905 | */ |
| 906 | if (1 + s->last_eob_len + 10 - s->bi_valid < 9) { |
| 907 | send_bits(s, STATIC_TREES<<1, 3); |
| 908 | send_code(s, END_BLOCK, static_ltree); |
| 909 | #ifdef DEBUG |
| 910 | s->compressed_len += 10L; |
| 911 | #endif |
| 912 | bi_flush(s); |
| 913 | } |
| 914 | s->last_eob_len = 7; |
| 915 | } |
| 916 | |
| 917 | /* =========================================================================== |
| 918 | * Determine the best encoding for the current block: dynamic trees, static |