X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=driver.c;h=6a7a8ec82d01996cdd83ea511575e6a65a76afc4;hb=9d2d4ff08d760e0abd83d2cea03c77d5b752a400;hp=1411b51311e7efca363b88b038a1c9a634173455;hpb=f96984c3f6474f2d85750351fd249b01245b5ec3;p=fjl diff --git a/driver.c b/driver.c index 1411b51..6a7a8ec 100644 --- a/driver.c +++ b/driver.c @@ -62,8 +62,8 @@ void read_sof(struct byte_source* source, struct jpeg_image* image) assert(len >= 8); image->precision = read_uint8(byte_source_input_func, source); assert(image->precision == 8); - image->width = read_uint16(byte_source_input_func, source); image->height = read_uint16(byte_source_input_func, source); + image->width = read_uint16(byte_source_input_func, source); image->num_components = read_uint8(byte_source_input_func, source); len -= 8; @@ -165,9 +165,9 @@ void read_scan(struct byte_source* source, struct jpeg_image* image, huffman_tab } possibly_refill(&bits, s); + coeff[unzigzag[i]] = extend(read_bits(&bits, s), s); i += r; - coeff[unzigzag[i]] = extend(read_bits(&bits, s), s); } uint8_t pixdata[DCTSIZE2]; @@ -185,8 +185,13 @@ void read_scan(struct byte_source* source, struct jpeg_image* image, huffman_tab } } - if (cn == 1 && ++xb * DCTSIZE == y_stride) { - fwrite(y_row_data, y_stride * DCTSIZE * image->vsample[1], 1, stdout); + if (cn != 1) { + continue; + } + + xb += image->hsample[cn]; + if (xb * DCTSIZE == y_stride) { + fwrite(y_row_data, y_stride * DCTSIZE * image->vsample[cn], 1, stdout); xb = 0; } }