(s, tree, max_code)
| 11188 | * bl_tree. |
| 11189 | */ |
| 11190 | function send_tree(s, tree, max_code) |
| 11191 | // deflate_state *s; |
| 11192 | // ct_data *tree; /* the tree to be scanned */ |
| 11193 | // int max_code; /* and its largest code of non zero frequency */ |
| 11194 | { |
| 11195 | var n; /* iterates over all tree elements */ |
| 11196 | var prevlen = -1; /* last emitted length */ |
| 11197 | var curlen; /* length of current code */ |
| 11198 | |
| 11199 | var nextlen = tree[0 * 2 + 1]/*.Len*/; /* length of next code */ |
| 11200 | |
| 11201 | var count = 0; /* repeat count of the current code */ |
| 11202 | var max_count = 7; /* max repeat count */ |
| 11203 | var min_count = 4; /* min repeat count */ |
| 11204 | |
| 11205 | /* tree[max_code+1].Len = -1; */ /* guard already set */ |
| 11206 | if (nextlen === 0) { |
| 11207 | max_count = 138; |
| 11208 | min_count = 3; |
| 11209 | } |
| 11210 | |
| 11211 | for (n = 0; n <= max_code; n++) { |
| 11212 | curlen = nextlen; |
| 11213 | nextlen = tree[(n + 1) * 2 + 1]/*.Len*/; |
| 11214 | |
| 11215 | if (++count < max_count && curlen === nextlen) { |
| 11216 | continue; |
| 11217 | |
| 11218 | } else if (count < min_count) { |
| 11219 | do { send_code(s, curlen, s.bl_tree); } while (--count !== 0); |
| 11220 | |
| 11221 | } else if (curlen !== 0) { |
| 11222 | if (curlen !== prevlen) { |
| 11223 | send_code(s, curlen, s.bl_tree); |
| 11224 | count--; |
| 11225 | } |
| 11226 | //Assert(count >= 3 && count <= 6, " 3_6?"); |
| 11227 | send_code(s, REP_3_6, s.bl_tree); |
| 11228 | send_bits(s, count - 3, 2); |
| 11229 | |
| 11230 | } else if (count <= 10) { |
| 11231 | send_code(s, REPZ_3_10, s.bl_tree); |
| 11232 | send_bits(s, count - 3, 3); |
| 11233 | |
| 11234 | } else { |
| 11235 | send_code(s, REPZ_11_138, s.bl_tree); |
| 11236 | send_bits(s, count - 11, 7); |
| 11237 | } |
| 11238 | |
| 11239 | count = 0; |
| 11240 | prevlen = curlen; |
| 11241 | if (nextlen === 0) { |
| 11242 | max_count = 138; |
| 11243 | min_count = 3; |
| 11244 | |
| 11245 | } else if (curlen === nextlen) { |
| 11246 | max_count = 6; |
| 11247 | min_count = 3; |
no test coverage detected