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

◆ lzw__write_fn()

static fl::u32 fl::third_party::lzw__write_fn ( struct lzw_ctx * ctx,
void * output_data,
fl::u32 output_length,
fl::u32 output_used,
fl::u16 code,
fl::u16 left )
inlinestatic

Write values for this code to the output stack.

If there isn't enough space in the output stack, this function will write the as many as it can into the output. If ctx->output_left > 0 after this call, then there is more data for this code left to output. The code is stored to the context as ctx->output_code.

Parameters
[in]ctxLZW reading context, updated.
[in]output_dataArray to write output values into.
[in]output_lengthlength Size of output array.
[in]output_usedCurrent position in output array.
[in]codeLZW code to output values for.
[in]leftNumber of values remaining to output for this code.
Returns
Number of pixel values written.

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

467{
468 fl::u8 * output_pos = (fl::u8 *)output_data + output_used;
469 const struct lzw_table_entry * const table = ctx->table;
470 fl::u32 space = output_length - output_used;
471 fl::u16 count = left;
472
473 if (count > space) {
474 left = count - space;
475 count = space;
476 } else {
477 left = 0;
478 }
479
480 ctx->output_code = code;
481 ctx->output_left = left;
482
483 /* Skip over any values we don't have space for. */
484 for (unsigned i = left; i != 0; i--) {
485 const struct lzw_table_entry *entry = table + code;
486 code = entry->extends;
487 }
488
489 output_pos += count;
490 for (unsigned i = count; i != 0; i--) {
491 const struct lzw_table_entry *entry = table + code;
492 *--output_pos = entry->value;
493 code = entry->extends;
494 }
495
496 return count;
497}
unsigned char u8
Definition coder.h:132
fl::u16 extends
Offset in table to previous entry.
Definition lzw.cpp.hpp:66
struct lzw_table_entry table[LZW_TABLE_ENTRY_MAX]
LZW code table.
Definition lzw.cpp.hpp:97
fl::u8 value
Last value for record ending at entry.
Definition lzw.cpp.hpp:63
fl::u16 output_left
Number of values left for output_code.
Definition lzw.cpp.hpp:90
fl::u16 output_code
Code that has been partially output.
Definition lzw.cpp.hpp:89
LZW table entry.
Definition lzw.cpp.hpp:62

References fl::third_party::lzw_table_entry::extends, FL_NOEXCEPT, fl::third_party::lzw_ctx::output_code, fl::third_party::lzw_ctx::output_left, fl::third_party::lzw_ctx::table, and fl::third_party::lzw_table_entry::value.

Referenced by lzw_decode().

+ Here is the caller graph for this function: