diff options
author | Michael Drake <tlsa@netsurf-browser.org> | 2021-09-24 20:19:53 +0100 |
---|---|---|
committer | Michael Drake <tlsa@netsurf-browser.org> | 2021-09-24 20:19:53 +0100 |
commit | 35dd8d132bf4c5433ac1e358cf26b987f566fd23 (patch) | |
tree | 84304f82de7c47a8fc2cf702cd2534c444dc8aaf | |
parent | 58c6e9393a794556bc3a192ce8227400d275d4e0 (diff) | |
download | libnsgif-35dd8d132bf4c5433ac1e358cf26b987f566fd23.tar.gz libnsgif-35dd8d132bf4c5433ac1e358cf26b987f566fd23.tar.bz2 |
lzw: Optimise mapped output for frames without transparency.
-rw-r--r-- | src/lzw.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -568,13 +568,21 @@ static inline uint32_t lzw__map_write_fn(struct lzw_ctx *ctx, } output_pos += count; - for (unsigned i = count; i != 0; i--) { - const struct lzw_table_entry *entry = table + code; - --output_pos; - if (entry->value != ctx->transparency_idx) { - *output_pos = ctx->colour_map[entry->value]; + if (ctx->has_transparency) { + for (unsigned i = count; i != 0; i--) { + const struct lzw_table_entry *entry = table + code; + --output_pos; + if (entry->value != ctx->transparency_idx) { + *output_pos = ctx->colour_map[entry->value]; + } + code = entry->extends; + } + } else { + for (unsigned i = count; i != 0; i--) { + const struct lzw_table_entry *entry = table + code; + *--output_pos = ctx->colour_map[entry->value]; + code = entry->extends; } - code = entry->extends; } return count; |