Gitweb links:

...log 
http://git.netsurf-browser.org/libnsgif.git/shortlog/9be2acf63d9f293d0ca1321dfd985889bce4e37d
...commit 
http://git.netsurf-browser.org/libnsgif.git/commit/9be2acf63d9f293d0ca1321dfd985889bce4e37d
...tree 
http://git.netsurf-browser.org/libnsgif.git/tree/9be2acf63d9f293d0ca1321dfd985889bce4e37d

The branch, tlsa/lzw-optimise has been created
        at  9be2acf63d9f293d0ca1321dfd985889bce4e37d (commit)

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/libnsgif.git/commit/?id=9be2acf63d9f293d0ca1321dfd985889bce4e37d
commit 9be2acf63d9f293d0ca1321dfd985889bce4e37d
Author: Michael Drake <[email protected]>
Commit: Michael Drake <[email protected]>

    lzw: Use relative offset to next output entry, rather than absolute.

diff --git a/src/lzw.c b/src/lzw.c
index 710895e..59c74a6 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -364,7 +364,7 @@ static inline void lzw__table_add_entry(
        entry->value = code;
        entry->first = ctx->prev_code_first;
        entry->count = ctx->prev_code_count + 1;
-       entry->extends = ctx->prev_code;
+       entry->extends = ctx->table_size - ctx->prev_code;
 
        ctx->table_size++;
 }
@@ -467,7 +467,7 @@ static inline uint32_t lzw__write_fn(struct lzw_ctx *ctx,
                uint16_t left)
 {
        uint8_t *restrict output_pos = (uint8_t *)output_data + output_used;
-       const struct lzw_table_entry * const table = ctx->table;
+       const struct lzw_table_entry *entry = ctx->table + code;
        uint32_t space = output_length - output_used;
        uint16_t count = left;
 
@@ -483,15 +483,13 @@ static inline uint32_t lzw__write_fn(struct lzw_ctx *ctx,
 
        /* Skip over any values we don't have space for. */
        for (unsigned i = left; i != 0; i--) {
-               const struct lzw_table_entry *entry = table + code;
-               code = entry->extends;
+               entry -= entry->extends;
        }
 
        output_pos += count;
        for (unsigned i = count; i != 0; i--) {
-               const struct lzw_table_entry *entry = table + code;
                *--output_pos = entry->value;
-               code = entry->extends;
+               entry -= entry->extends;
        }
 
        return count;
@@ -548,7 +546,7 @@ static inline uint32_t lzw__map_write_fn(struct lzw_ctx 
*ctx,
                uint16_t left)
 {
        uint32_t *restrict output_pos = (uint32_t *)output_data + output_used;
-       const struct lzw_table_entry * const table = ctx->table;
+       const struct lzw_table_entry *entry = ctx->table + code;
        uint32_t space = output_length - output_used;
        uint16_t count = left;
 
@@ -563,25 +561,22 @@ static inline uint32_t lzw__map_write_fn(struct lzw_ctx 
*ctx,
        ctx->output_left = left;
 
        for (unsigned i = left; i != 0; i--) {
-               const struct lzw_table_entry *entry = table + code;
-               code = entry->extends;
+               entry -= entry->extends;
        }
 
        output_pos += count;
        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;
+                       entry -= 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;
+                       entry -= entry->extends;
                }
        }
 


-----------------------------------------------------------------------


-- 
NetSurf GIF Decoder
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to