private void ReadLengths(int[] lens, long first, long last, BitBuffer bitbuf) {
		long x, y;
		int z;

		// hufftbl pointer here?

		for (x = 0; x < 20; x++) {
			y = bitbuf.ReadBits(4);
			m_state.PRETREE_len[(int)x] = (byte)y;
		}
		MakeDecodeTable(LZXConstants.PRETREE_MAXSYMBOLS,LZXConstants.PRETREE_TABLEBITS,m_state.PRETREE_len,m_state.PRETREE_table);

		for (x = first; x < last;) {
			z = (int)ReadHuffSym(m_state.PRETREE_table,m_state.PRETREE_len,LZXConstants.PRETREE_MAXSYMBOLS,LZXConstants.PRETREE_TABLEBITS,bitbuf);
			if (z == 17) {
				y = bitbuf.ReadBits(4);
				y += 4;
				while (y-- != 0)
					lens[(int)x++] = 0;
			} else if (z == 18) {
				y = bitbuf.ReadBits(5);
				y += 20;
				while (y-- != 0)
					lens[(int)x++] = 0;
			} else if (z == 19) {
				y = bitbuf.ReadBits(1);
				y += 4;
				z = (int)ReadHuffSym(m_state.PRETREE_table,m_state.PRETREE_len,LZXConstants.PRETREE_MAXSYMBOLS,LZXConstants.PRETREE_TABLEBITS,bitbuf);
				z = lens[(int)x] - z;
				if (z < 0) z += 17;
				while (y-- != 0)
					lens[(int)x++] = (byte)z;
			} else {
				z = lens[(int)x] - z;
				if (z < 0) z += 17;
				lens[(int)x++] = (byte)z;
			}
		}
	}