]> git.sesse.net Git - fjl/blobdiff - driver.c
Handle EOI marker.
[fjl] / driver.c
index aa803d6ed00aa67266495b65df93e6582bc89151..fd861f25d7b56250aadf7f1666174e9fb2fe9b41 100644 (file)
--- a/driver.c
+++ b/driver.c
@@ -151,7 +151,7 @@ void read_scan(struct byte_source* source, struct jpeg_image* image, huffman_tab
                
        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;
@@ -293,6 +293,9 @@ int main(void)
                case 0xd8:
                        /* SOI */
                        break;
+               case 0xd9:
+                       /* EOI */
+                       exit(0);
                case 0xc4:
                        /* DHT (define Huffman tables) */
                        read_huffman_tables(&tables, byte_source_input_func, &source);