Add an x86 optimized version of extend().
[fjl] / dehuff.c
index 8fd4c2072fce46cbe792295fc977a3e7f53b2deb..c4a65eea8a0619153bb9910cd5421db53bd01193 100644 (file)
--- a/dehuff.c
+++ b/dehuff.c
@@ -8,7 +8,7 @@
 
 void read_huffman_tables(huffman_tables_t* dst, input_func_t* input_func, void* userdata)
 {
-       size_t len = read_length(input_func, userdata);
+       size_t len = read_uint16(input_func, userdata);
        assert(len > 2);
        len -= 2;
 
@@ -32,7 +32,7 @@ void read_huffman_tables(huffman_tables_t* dst, input_func_t* input_func, void*
                        exit(1);
                }
 
-               struct huffman_table* tbl = dst[table_class][table_dest];
+               struct huffman_table* tbl = &((*dst)[table_class][table_dest]);
                if (len < 16) {
                        fprintf(stderr, "Short read for num_codes\n");
                        exit(1);
@@ -114,7 +114,7 @@ void read_huffman_tables(huffman_tables_t* dst, input_func_t* input_func, void*
                                for (unsigned elem = prefix_min; elem < prefix_max; ++elem) {
                                        assert(tbl->lookup_table_codes[elem] == DEHUF_SLOW_PATH);
                                        assert(tbl->lookup_table_length[elem] == DEHUF_SLOW_PATH);
-                                       tbl->lookup_table_codes[elem] = k;
+                                       tbl->lookup_table_codes[elem] = tbl->codes[k];
                                        tbl->lookup_table_length[elem] = length;
                                }
                        }