FastLED 3.9.15
Loading...
Searching...
No Matches

◆ lzw__handle_clear()

static lzw_result fl::third_party::lzw__handle_clear ( struct lzw_ctx * ctx,
fl::u16 * code_out )
inlinestatic

Handle clear code.

Parameters
[in]ctxLZW reading context, updated.
[out]code_outReturns next code after a clear code.
Returns
LZW_OK or error code.

Definition at line 233 of file lzw.cpp.hpp.

236{
237 fl::u16 code = 0;
238
239 /* Reset table building context */
240 ctx->code_size = ctx->initial_code_size;
241 ctx->code_max = (1 << ctx->initial_code_size) - 1;
242 ctx->table_size = ctx->eoi_code + 1;
243
244 /* There might be a sequence of clear codes, so process them all */
245 do {
246 lzw_result res = lzw__read_code(&ctx->input,
247 ctx->code_size, &code);
248 if (res != LZW_OK) {
249 return res;
250 }
251 } while (code == ctx->clear_code);
252
253 /* The initial code must be from the initial table. */
254 if (code > ctx->clear_code) {
255 return LZW_BAD_ICODE;
256 }
257
258 *code_out = code;
259 return LZW_OK;
260}
static lzw_result lzw__read_code(struct lzw_read_ctx *ctx, fl::u16 code_size, fl::u16 *code_out) FL_NOEXCEPT
Get the next LZW code of given size from the raw input data.
Definition lzw.cpp.hpp:167
lzw_result
LZW decoding response codes.
Definition lzw.h:33
@ LZW_OK
Success.
Definition lzw.h:34
@ LZW_BAD_ICODE
Error: Bad initial LZW code.
Definition lzw.h:40
fl::u16 table_size
Next position in table to fill.
Definition lzw.cpp.hpp:87
fl::u16 clear_code
Special Clear code value.
Definition lzw.cpp.hpp:84
fl::u16 eoi_code
Special End of Information code value.
Definition lzw.cpp.hpp:85
fl::u8 initial_code_size
Starting LZW code size.
Definition lzw.cpp.hpp:79
fl::u8 code_size
Current LZW code size.
Definition lzw.cpp.hpp:81
struct lzw_read_ctx input
Input reading context.
Definition lzw.cpp.hpp:73
fl::u16 code_max
Max code value for current code size.
Definition lzw.cpp.hpp:82

References FL_NOEXCEPT, lzw__read_code(), LZW_BAD_ICODE, and LZW_OK.

Referenced by lzw__decode(), and lzw_decode_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: