]> git.sesse.net Git - fjl/commitdiff
More debug code moving. master
authorSteinar H. Gunderson <sesse@debian.org>
Mon, 1 Jun 2009 20:35:56 +0000 (22:35 +0200)
committerSteinar H. Gunderson <sesse@debian.org>
Mon, 1 Jun 2009 20:35:56 +0000 (22:35 +0200)
driver.c

index c4f48ac6f9557df89fea22169f995bbb52c7994a..94cce90332e7df8186c83b0aa311ef3afec61d6f 100644 (file)
--- 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);
 }