public byte[] Unpack() { var tree_data = new byte[0x10]; int tree_pos = m_data_pos + 0x80; for (int i = 0; i < 0x10; ++i) { tree_data[i] = (byte)(m_input[tree_pos + i] + 1); } var freq = new uint[0x20]; Buffer.BlockCopy(m_input, m_data_pos, freq, 0, 0x40); tree_dc = new HuffmanTree(tree_data, freq); Buffer.BlockCopy(m_input, m_data_pos + 0x40, freq, 0, 0x40); tree_ac = new HuffmanTree(tree_data, freq); int quant_pos = tree_pos + 0x10; if (0 != (m_format & 0x8000000)) { for (int i = 0; i < 0x40; ++i) { quant_y[i] = m_input[quant_pos + i]; quant_c[i] = m_input[quant_pos + i + 0x40]; } } int bits_offset = quant_pos + 0x80; bits_dc = new JBitStream(m_input, bits_offset, m_dc_bits); bits_ac = new JBitStream(m_input, bits_offset + m_dc_bits, m_ac_bits); Decode(); return(m_output); }
public int Read(JBitStream bits) { int v = Root; while (v >= LeafCount) { v = Nodes[v + (bits.GetNextBit() << 9)]; } return(v); }