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

◆ lzw__map_write_fn()

static fl::u32 fl::third_party::lzw__map_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 colour mapped values for this code to the output.

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_lengthSize 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 code.
Returns
Number of pixel values written.

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

548{
549 fl::u32 * output_pos = (fl::u32 *)output_data + output_used;
550 const struct lzw_table_entry * const table = ctx->table;
551 fl::u32 space = output_length - output_used;
552 fl::u16 count = left;
553
554 if (count > space) {
555 left = count - space;
556 count = space;
557 } else {
558 left = 0;
559 }
560
561 ctx->output_code = code;
562 ctx->output_left = left;
563
564 for (unsigned i = left; i != 0; i--) {
565 const struct lzw_table_entry *entry = table + code;
566 code = entry->extends;
567 }
568
569 output_pos += count;
570 if (ctx->has_transparency) {
571 for (unsigned i = count; i != 0; i--) {
572 const struct lzw_table_entry *entry = table + code;
573 --output_pos;
574 if (entry->value != ctx->transparency_idx) {
575 *output_pos = ctx->colour_map[entry->value];
576 }
577 code = entry->extends;
578 }
579 } else {
580 for (unsigned i = count; i != 0; i--) {
581 const struct lzw_table_entry *entry = table + code;
582 *--output_pos = ctx->colour_map[entry->value];
583 code = entry->extends;
584 }
585 }
586
587 return count;
588}
fl::u16 extends
Offset in table to previous entry.
Definition lzw.cpp.hpp:66
bool has_transparency
Whether the image is opaque.
Definition lzw.cpp.hpp:92
struct lzw_table_entry table[LZW_TABLE_ENTRY_MAX]
LZW code table.
Definition lzw.cpp.hpp:97
const fl::u32 * colour_map
Index to colour mapping.
Definition lzw.cpp.hpp:94
fl::u8 transparency_idx
Index representing transparency.
Definition lzw.cpp.hpp:93
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_ctx::colour_map, fl::third_party::lzw_table_entry::extends, FL_NOEXCEPT, fl::third_party::lzw_ctx::has_transparency, fl::third_party::lzw_ctx::output_code, fl::third_party::lzw_ctx::output_left, fl::third_party::lzw_ctx::table, fl::third_party::lzw_ctx::transparency_idx, and fl::third_party::lzw_table_entry::value.

Referenced by lzw_decode_map().

+ Here is the caller graph for this function: