X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=driver.c;h=fd861f25d7b56250aadf7f1666174e9fb2fe9b41;hp=06d94d99d553e6aa4e784e22cfc99a4d19216df5;hb=a733460846675aab7117c5cf1213d1b62785793d;hpb=8445e04bae016b6bd74705902972e66ae7fe37c1 diff --git a/driver.c b/driver.c index 06d94d9..fd861f2 100644 --- 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; @@ -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);