()
| 10760 | * Initialize the various 'constant' tables. |
| 10761 | */ |
| 10762 | function tr_static_init() { |
| 10763 | var n; /* iterates over tree elements */ |
| 10764 | var bits; /* bit counter */ |
| 10765 | var length; /* length value */ |
| 10766 | var code; /* code value */ |
| 10767 | var dist; /* distance index */ |
| 10768 | var bl_count = new Array(MAX_BITS + 1); |
| 10769 | /* number of codes at each bit length for an optimal tree */ |
| 10770 | |
| 10771 | // do check in _tr_init() |
| 10772 | //if (static_init_done) return; |
| 10773 | |
| 10774 | /* For some embedded targets, global variables are not initialized: */ |
| 10775 | /*#ifdef NO_INIT_GLOBAL_POINTERS |
| 10776 | static_l_desc.static_tree = static_ltree; |
| 10777 | static_l_desc.extra_bits = extra_lbits; |
| 10778 | static_d_desc.static_tree = static_dtree; |
| 10779 | static_d_desc.extra_bits = extra_dbits; |
| 10780 | static_bl_desc.extra_bits = extra_blbits; |
| 10781 | #endif*/ |
| 10782 | |
| 10783 | /* Initialize the mapping length (0..255) -> length code (0..28) */ |
| 10784 | length = 0; |
| 10785 | for (code = 0; code < LENGTH_CODES - 1; code++) { |
| 10786 | base_length[code] = length; |
| 10787 | for (n = 0; n < (1 << extra_lbits[code]); n++) { |
| 10788 | _length_code[length++] = code; |
| 10789 | } |
| 10790 | } |
| 10791 | //Assert (length == 256, "tr_static_init: length != 256"); |
| 10792 | /* Note that the length 255 (match length 258) can be represented |
| 10793 | * in two different ways: code 284 + 5 bits or code 285, so we |
| 10794 | * overwrite length_code[255] to use the best encoding: |
| 10795 | */ |
| 10796 | _length_code[length - 1] = code; |
| 10797 | |
| 10798 | /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ |
| 10799 | dist = 0; |
| 10800 | for (code = 0; code < 16; code++) { |
| 10801 | base_dist[code] = dist; |
| 10802 | for (n = 0; n < (1 << extra_dbits[code]); n++) { |
| 10803 | _dist_code[dist++] = code; |
| 10804 | } |
| 10805 | } |
| 10806 | //Assert (dist == 256, "tr_static_init: dist != 256"); |
| 10807 | dist >>= 7; /* from now on, all distances are divided by 128 */ |
| 10808 | for (; code < D_CODES; code++) { |
| 10809 | base_dist[code] = dist << 7; |
| 10810 | for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { |
| 10811 | _dist_code[256 + dist++] = code; |
| 10812 | } |
| 10813 | } |
| 10814 | //Assert (dist == 256, "tr_static_init: 256+dist != 512"); |
| 10815 | |
| 10816 | /* Construct the codes of the static literal tree */ |
| 10817 | for (bits = 0; bits <= MAX_BITS; bits++) { |
| 10818 | bl_count[bits] = 0; |
| 10819 | } |
no test coverage detected