X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=driver.c;h=94cce90332e7df8186c83b0aa311ef3afec61d6f;hp=c4f48ac6f9557df89fea22169f995bbb52c7994a;hb=HEAD;hpb=4adcb962d555cba7af8e1de42d203f03d28d81a5 diff --git a/driver.c b/driver.c index c4f48ac..94cce90 100644 --- a/driver.c +++ b/driver.c @@ -217,14 +217,8 @@ void read_scan(struct byte_source* source, struct jpeg_image* image, huffman_tab unsigned cn = component_num[c]; image->pixel_write_pointer[cn] += (image->vsample[cn] * DCTSIZE - 1) * image->stride[cn]; } - - // Some debug code. - const int c = 1; if (mcu_y == image->num_blocks_vertical) { - unsigned stride = image->num_blocks_horizontal * image->hsample[c] * DCTSIZE; - unsigned height = image->num_blocks_vertical * image->vsample[c] * DCTSIZE; - printf("P5\n%u %u\n255\n", stride, height); - fwrite(image->pixel_data[c], stride * height, 1, stdout); + return; } } } @@ -302,7 +296,7 @@ void read_jpeg(struct jpeg_image* jpeg, FILE *input) break; case 0xd9: /* EOI */ - exit(0); + return; case 0xc4: /* DHT (define Huffman tables) */ read_huffman_tables(&tables, byte_source_input_func, &source); @@ -324,4 +318,11 @@ int main(void) struct jpeg_image jpeg; read_jpeg(&jpeg, stdin); + + // Some debug code. + const int c = 1; + unsigned stride = jpeg.num_blocks_horizontal * jpeg.hsample[c] * DCTSIZE; + unsigned height = jpeg.num_blocks_vertical * jpeg.vsample[c] * DCTSIZE; + printf("P5\n%u %u\n255\n", stride, height); + fwrite(jpeg.pixel_data[c], stride * height, 1, stdout); }