Lines Matching +full:codeword +full:- +full:by +full:- +full:codeword
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * decompress_common.h - Code shared by the XPRESS and LZX decompressors
21 /* Enable whole-word match copying on selected architectures */
36 /* Generate a "word" with platform-dependent size whose bytes all contain the
50 /* Structure that encapsulates a block of in-memory data being interpreted as a
52 * to be stored in little endian 16-bit coding units, with the bits ordered high
58 * left-justified; the next bit is always bit 31.
76 is->bitbuf = 0; in init_input_bitstream()
77 is->bitsleft = 0; in init_input_bitstream()
78 is->next = buffer; in init_input_bitstream()
79 is->end = is->next + size; in init_input_bitstream()
90 if (is->bitsleft < num_bits) { in bitstream_ensure_bits()
91 if (is->end - is->next >= 2) { in bitstream_ensure_bits()
92 is->bitbuf |= (u32)get_unaligned_le16(is->next) in bitstream_ensure_bits()
93 << (16 - is->bitsleft); in bitstream_ensure_bits()
94 is->next += 2; in bitstream_ensure_bits()
96 is->bitsleft += 16; in bitstream_ensure_bits()
107 return (is->bitbuf >> 1) >> (sizeof(is->bitbuf) * 8 - num_bits - 1); in bitstream_peek_bits()
117 is->bitbuf <<= num_bits; in bitstream_remove_bits()
118 is->bitsleft -= num_bits; in bitstream_remove_bits()
146 if (unlikely(is->end == is->next)) in bitstream_read_byte()
148 return *is->next++; in bitstream_read_byte()
151 /* Read and return the next 16-bit integer embedded in the bitstream. */
157 if (unlikely(is->end - is->next < 2)) in bitstream_read_u16()
159 v = get_unaligned_le16(is->next); in bitstream_read_u16()
160 is->next += 2; in bitstream_read_u16()
164 /* Read and return the next 32-bit integer embedded in the bitstream. */
170 if (unlikely(is->end - is->next < 4)) in bitstream_read_u32()
172 v = get_unaligned_le32(is->next); in bitstream_read_u32()
173 is->next += 4; in bitstream_read_u32()
184 if ((size_t)(is->end - is->next) < count) in bitstream_read_bytes()
186 memcpy(dst_buffer, is->next, count); in bitstream_read_bytes()
187 is->next += count; in bitstream_read_bytes()
191 /* Align the input bitstream on a coding-unit boundary. */
194 is->bitsleft = 0; in bitstream_align()
195 is->bitbuf = 0; in bitstream_align()
204 /* Reads and returns the next Huffman-encoded symbol from a bitstream. If the
218 /* Index the decode table by the next table_bits bits of the input. */ in read_huffsym()
223 * symbol and codeword length. The low 11 bits are the in read_huffsym()
224 * symbol, and the high 5 bits are the codeword length. in read_huffsym()
229 /* Slow case: The codeword for the symbol is longer than in read_huffsym()
233 * bit-by-bit to decode the symbol. in read_huffsym()
243 * Copy an LZ77 match at (dst - offset) to dst.
245 * The length and offset must be already validated --- that is, (dst - offset)
257 const u8 *src = dst - offset; in lz_copy()
262 * near-random and all the matches have very short lengths. Note that in lz_copy()
269 * beyond the end of the output buffer, hence the check for (bufend - in lz_copy()
270 * end >= WORDBYTES - 1). in lz_copy()
275 if (bufend - end >= (ptrdiff_t)(WORDBYTES - 1)) { in lz_copy()
301 /* Offset 1 matches are equivalent to run-length in lz_copy()
305 size_t v = repeat_byte(*(dst - 1)); in lz_copy()
330 length--; in lz_copy()
334 length--; in lz_copy()
338 } while (--length); in lz_copy()