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

◆ lzw__block_advance()

static lzw_result fl::third_party::lzw__block_advance ( struct lzw_read_ctx * ctx)
static

Advance the context to the next sub-block in the input data.

Parameters
[in]ctxLZW reading context, updated on success.
Returns
LZW_OK or LZW_OK_EOD on success, appropriate error otherwise.

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

128{
129 fl::size block_size;
130 fl::size next_block_pos = ctx->data_sb_next;
131 const fl::u8 *data_next = ctx->data + next_block_pos;
132
133 if (next_block_pos >= ctx->data_len) {
134 return LZW_NO_DATA;
135 }
136
137 block_size = *data_next;
138
139 if ((next_block_pos + block_size) >= ctx->data_len) {
140 return LZW_NO_DATA;
141 }
142
143 ctx->sb_bit = 0;
144 ctx->sb_bit_count = block_size * 8;
145
146 if (block_size == 0) {
147 ctx->data_sb_next += 1;
148 return LZW_OK_EOD;
149 }
150
151 ctx->sb_data = data_next + 1;
152 ctx->data_sb_next += block_size + 1;
153
154 return LZW_OK;
155}
unsigned char u8
Definition coder.h:132
@ LZW_NO_DATA
Error: Out of data.
Definition lzw.h:37
@ LZW_OK
Success.
Definition lzw.h:34
@ LZW_OK_EOD
Success; reached zero-length sub-block.
Definition lzw.h:35
fl::size data_sb_next
Offset to sub-block size.
Definition lzw.cpp.hpp:45
const fl::u8 * sb_data
Pointer to current sub-block in data.
Definition lzw.cpp.hpp:47
fl::u32 sb_bit_count
Bit count in sub-block.
Definition lzw.cpp.hpp:49
fl::size sb_bit
Current bit offset in sub-block.
Definition lzw.cpp.hpp:48
fl::size data_len
Input data length.
Definition lzw.cpp.hpp:44
const fl::u8 * data
Pointer to start of input data.
Definition lzw.cpp.hpp:43

References FL_NOEXCEPT, LZW_NO_DATA, LZW_OK, and LZW_OK_EOD.

Referenced by lzw__read_code().

+ Here is the caller graph for this function: