()
| 22742 | * Initialize the various 'constant' tables. |
| 22743 | */ |
| 22744 | function tr_static_init() { |
| 22745 | var n; /* iterates over tree elements */ |
| 22746 | var bits; /* bit counter */ |
| 22747 | var length; /* length value */ |
| 22748 | var code; /* code value */ |
| 22749 | var dist; /* distance index */ |
| 22750 | var bl_count = new Array(MAX_BITS + 1); |
| 22751 | /* number of codes at each bit length for an optimal tree */ |
| 22752 | |
| 22753 | // do check in _tr_init() |
| 22754 | //if (static_init_done) return; |
| 22755 | |
| 22756 | /* For some embedded targets, global variables are not initialized: */ |
| 22757 | /*#ifdef NO_INIT_GLOBAL_POINTERS |
| 22758 | static_l_desc.static_tree = static_ltree; |
| 22759 | static_l_desc.extra_bits = extra_lbits; |
| 22760 | static_d_desc.static_tree = static_dtree; |
| 22761 | static_d_desc.extra_bits = extra_dbits; |
| 22762 | static_bl_desc.extra_bits = extra_blbits; |
| 22763 | #endif*/ |
| 22764 | |
| 22765 | /* Initialize the mapping length (0..255) -> length code (0..28) */ |
| 22766 | length = 0; |
| 22767 | for (code = 0; code < LENGTH_CODES - 1; code++) { |
| 22768 | base_length[code] = length; |
| 22769 | for (n = 0; n < (1 << extra_lbits[code]); n++) { |
| 22770 | _length_code[length++] = code; |
| 22771 | } |
| 22772 | } |
| 22773 | //Assert (length == 256, "tr_static_init: length != 256"); |
| 22774 | /* Note that the length 255 (match length 258) can be represented |
| 22775 | * in two different ways: code 284 + 5 bits or code 285, so we |
| 22776 | * overwrite length_code[255] to use the best encoding: |
| 22777 | */ |
| 22778 | _length_code[length - 1] = code; |
| 22779 | |
| 22780 | /* Initialize the mapping dist (0..32K) -> dist code (0..29) */ |
| 22781 | dist = 0; |
| 22782 | for (code = 0; code < 16; code++) { |
| 22783 | base_dist[code] = dist; |
| 22784 | for (n = 0; n < (1 << extra_dbits[code]); n++) { |
| 22785 | _dist_code[dist++] = code; |
| 22786 | } |
| 22787 | } |
| 22788 | //Assert (dist == 256, "tr_static_init: dist != 256"); |
| 22789 | dist >>= 7; /* from now on, all distances are divided by 128 */ |
| 22790 | for (; code < D_CODES; code++) { |
| 22791 | base_dist[code] = dist << 7; |
| 22792 | for (n = 0; n < (1 << (extra_dbits[code] - 7)); n++) { |
| 22793 | _dist_code[256 + dist++] = code; |
| 22794 | } |
| 22795 | } |
| 22796 | //Assert (dist == 256, "tr_static_init: 256+dist != 512"); |
| 22797 | |
| 22798 | /* Construct the codes of the static literal tree */ |
| 22799 | for (bits = 0; bits <= MAX_BITS; bits++) { |
| 22800 | bl_count[bits] = 0; |
| 22801 | } |
no test coverage detected