internal void build_tree(Deflate s) { int num2; int num5; short[] tree = this.dyn_tree; short[] numArray2 = this.stat_desc.static_tree; int elems = this.stat_desc.elems; int num4 = -1; s.heap_len = 0; s.heap_max = HEAP_SIZE; for (num2 = 0; num2 < elems; num2++) { if (tree[num2 * 2] != 0) { s.heap[++s.heap_len] = num4 = num2; s.depth[num2] = 0; } else { tree[(num2 * 2) + 1] = 0; } } while (s.heap_len < 2) { num5 = s.heap[++s.heap_len] = (num4 < 2) ? ++num4 : 0; tree[num5 * 2] = 1; s.depth[num5] = 0; s.opt_len--; if (numArray2 != null) { s.static_len -= numArray2[(num5 * 2) + 1]; } } this.max_code = num4; num2 = s.heap_len / 2; while (num2 >= 1) { s.pqdownheap(tree, num2); num2--; } num5 = elems; do { num2 = s.heap[1]; s.heap[1] = s.heap[s.heap_len--]; s.pqdownheap(tree, 1); int index = s.heap[1]; s.heap[--s.heap_max] = num2; s.heap[--s.heap_max] = index; tree[num5 * 2] = (short)(tree[num2 * 2] + tree[index * 2]); s.depth[num5] = (byte)(Math.Max(s.depth[num2], s.depth[index]) + 1); tree[(num2 * 2) + 1] = tree[(index * 2) + 1] = (short)num5; s.heap[1] = num5++; s.pqdownheap(tree, 1); }while(s.heap_len >= 2); s.heap[--s.heap_max] = s.heap[1]; this.gen_bitlen(s); gen_codes(tree, num4, s.bl_count); }
internal void build_tree( Deflate s ) { int num2; int num5; short[] tree = this.dyn_tree; short[] numArray2 = this.stat_desc.static_tree; int elems = this.stat_desc.elems; int num4 = -1; s.heap_len = 0; s.heap_max = HEAP_SIZE; for( num2 = 0; num2 < elems; num2++ ) { if( tree[ num2 * 2 ] != 0 ) { s.heap[ ++s.heap_len ] = num4 = num2; s.depth[ num2 ] = 0; } else { tree[ ( num2 * 2 ) + 1 ] = 0; } } while( s.heap_len < 2 ) { num5 = s.heap[ ++s.heap_len ] = ( num4 < 2 ) ? ++num4 : 0; tree[ num5 * 2 ] = 1; s.depth[ num5 ] = 0; s.opt_len--; if( numArray2 != null ) { s.static_len -= numArray2[ ( num5 * 2 ) + 1 ]; } } this.max_code = num4; num2 = s.heap_len / 2; while( num2 >= 1 ) { s.pqdownheap( tree, num2 ); num2--; } num5 = elems; do { num2 = s.heap[ 1 ]; s.heap[ 1 ] = s.heap[ s.heap_len-- ]; s.pqdownheap( tree, 1 ); int index = s.heap[ 1 ]; s.heap[ --s.heap_max ] = num2; s.heap[ --s.heap_max ] = index; tree[ num5 * 2 ] = (short)( tree[ num2 * 2 ] + tree[ index * 2 ] ); s.depth[ num5 ] = (byte)( Math.Max( s.depth[ num2 ], s.depth[ index ] ) + 1 ); tree[ ( num2 * 2 ) + 1 ] = tree[ ( index * 2 ) + 1 ] = (short)num5; s.heap[ 1 ] = num5++; s.pqdownheap( tree, 1 ); } while( s.heap_len >= 2 ); s.heap[ --s.heap_max ] = s.heap[ 1 ]; this.gen_bitlen( s ); gen_codes( tree, num4, s.bl_count ); }