- /* If the position_slot is 0, 1, or 2, the match offset is retrieved
- * from the LRU queue. Otherwise, the match offset is not in the LRU
- * queue. */
- switch (position_slot) {
- case 0:
- match_offset = queue->R0;
- break;
- case 1:
- match_offset = queue->R1;
- swap(queue->R0, queue->R1);
- break;
- case 2:
- /* The queue doesn't work quite the same as a real LRU queue,
- * since using the R2 offset doesn't bump the R1 offset down to
- * R2. */
- match_offset = queue->R2;
- swap(queue->R0, queue->R2);
- break;
- default:
- /* Otherwise, the offset was not encoded as one the offsets in
- * the queue. Depending on the position slot, there is a
- * certain number of extra bits that need to be read to fully
- * decode the match offset. */
-
- /* Look up the number of extra bits that need to be read. */
- num_extra_bits = lzx_extra_bits[position_slot];
-
- /* For aligned blocks, if there are at least 3 extra bits, the
- * actual number of extra bits is 3 less, and they encode a
- * number of 8-byte words that are added to the offset; there
- * is then an additional symbol read using the aligned tree that
- * specifies the actual byte alignment. */
- if (block_type == LZX_BLOCKTYPE_ALIGNED && num_extra_bits >= 3) {
-
- /* There is an error in the LZX "specification" at this
- * point; it indicates that a Huffman symbol is to be
- * read only if num_extra_bits is greater than 3, but
- * actually it is if num_extra_bits is greater than or
- * equal to 3. (Note that in the case with
- * num_extra_bits == 3, the assignment to verbatim_bits
- * will just set it to 0. ) */
- ret = bitstream_read_bits(istream, num_extra_bits - 3,
- &verbatim_bits);
- if (ret != 0)
- return -1;
-
- verbatim_bits <<= 3;
-
- ret = read_huffsym_using_alignedtree(istream, tables,
- &aligned_bits);
- if (ret != 0)
- return -1;
- } else {
- /* For non-aligned blocks, or for aligned blocks with
- * less than 3 extra bits, the extra bits are added
- * directly to the match offset, and the correction for
- * the alignment is taken to be 0. */
- ret = bitstream_read_bits(istream, num_extra_bits,
- &verbatim_bits);
- if (ret != 0)
- return -1;
-
- aligned_bits = 0;