]> git.sesse.net Git - fjl/blobdiff - driver.c
Let the bit source alert about EOF as soon as we have started eating into padding...
[fjl] / driver.c
index 06d94d99d553e6aa4e784e22cfc99a4d19216df5..35934da1d72d711efafdb588b62dae22cdcd8e54 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -147,11 +147,11 @@ void read_scan(struct byte_source* source, struct jpeg_image* image, huffman_tab
        }
 
        struct bit_source bits;
-       init_bit_source(&bits, byte_source_input_func, source);
+       init_bit_source(&bits, byte_source_input_func, 8, source);
                
        unsigned mcu_x = 0, mcu_y = 0;
 
-       for ( ;; ) {
+       while (!bits.source_eof) {
                for (unsigned c = 0; c < num_components; ++c) {
                        unsigned cn = component_num[c];
                        unsigned stride = image->num_blocks_horizontal * image->hsample[cn] * DCTSIZE;