]> git.sesse.net Git - fjl/blobdiff - driver.c
Remove an increment from the fast path of the AC coefficient decoding.
[fjl] / driver.c
index 6dcc8b3da676161ecd60e05898a27ebe3d19bf3f..fcd9f7fb9aed2c1fa8629a2913ddb3b7df2117dc 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -116,7 +116,7 @@ void read_sof(struct byte_source* source, struct jpeg_image* image)
 
 void decode_ac_coefficients(const struct huffman_table* tbl, struct bit_source* bits, int16_t* coeff)
 {
-       for (unsigned i = 1; i < DCTSIZE2; ++i) {
+       for (unsigned i = 0; i < DCTSIZE2 - 1; ) {
                possibly_refill(bits, DEHUF_AC_TABLE_BITS);
                unsigned lookup = peek_bits(bits, DEHUF_AC_TABLE_BITS);
                int code = tbl->ac_table_codes[lookup];
@@ -125,7 +125,7 @@ void decode_ac_coefficients(const struct huffman_table* tbl, struct bit_source*
                        unsigned rs = read_huffman_symbol_no_refill(tbl, bits);
                        unsigned r = rs >> 4;
                        unsigned s = rs & 0xf;
-                       i += r;
+                       i += r + 1;
                        possibly_refill(bits, s);
 
                        if (rs == 0x00) {
@@ -143,7 +143,7 @@ void decode_ac_coefficients(const struct huffman_table* tbl, struct bit_source*
                } else {
                        unsigned length = tbl->ac_table_length[lookup];
                        int r = tbl->ac_table_skip[lookup];
-                       assert(r >= 0);
+                       assert(r >= 1);
                        i += r;
                        assert(bits->bits_available >= length);
                        read_bits(bits, length);