Get the next LZW code of given size from the raw input data.
Reads codes from the input data stream coping with GIF data sub-blocks.
171{
172 fl::u32 code = 0;
173 fl::u32 current_bit = ctx->
sb_bit & 0x7;
174
176
178 code |= static_cast<fl::u32>(*data++) << 0;
179 code |= static_cast<fl::u32>(*data++) << 8;
180 code |= static_cast<fl::u32>(*data) << 16;
182 } else {
183
184 fl::u8 byte_advance = (current_bit + code_size) >> 3;
186 fl::u8 bits_remaining_0 = (code_size < (8u - current_bit)) ?
187 code_size : (8u - current_bit);
188 fl::u8 bits_remaining_1 = code_size - bits_remaining_0;
190 bits_remaining_0,
191 (
fl::u8)(bits_remaining_1 < 8 ? bits_remaining_1 : 8),
192 (
fl::u8)(bits_remaining_1 - 8),
193 };
194
195 FL_ASSERT(byte_advance <= 2,
"Byte advance too large");
196
197 while (true) {
200
201
202 while (byte <= byte_advance &&
204 code |= data[ctx->
sb_bit >> 3] << (
byte << 3);
206 byte++;
207 }
208
209
210 if (byte > byte_advance) {
211 break;
212 }
213
214
217 return res;
218 }
219 }
220 }
221
222 *code_out = (code >> current_bit) & ((1 << code_size) - 1);
224}
#define FL_ASSERT(x, MSG)
lzw_result
LZW decoding response codes.
static lzw_result lzw__block_advance(struct lzw_read_ctx *ctx) FL_NOEXCEPT
Advance the context to the next sub-block in the input data.
const fl::u8 * sb_data
Pointer to current sub-block in data.
fl::u32 sb_bit_count
Bit count in sub-block.
fl::size sb_bit
Current bit offset in sub-block.