From c43cbcacad6d4085996f29a6c1701e64eae97b71 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 17 Feb 2009 01:12:47 -0800 Subject: minor minor change to jpeg (1% faster) --- src/jpeg.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/jpeg.c b/src/jpeg.c index 4271975..ea8188c 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -91,13 +91,16 @@ static int jpeg_read(struct image *img){ jpeg_start_decompress(&j->cinfo); - unsigned char *buf = img->buf; if(j->cinfo.output_components == 3){ - JSAMPARRAY buffer = &buf; - for(y = 0; y < j->cinfo.output_height; y++){ - jpeg_read_scanlines(&j->cinfo, buffer, 1); - buf += row_stride; + JSAMPROW rows[2]; + rows[0] = img->buf; + rows[1] = rows[0] + row_stride; + for(y = 0; y < j->cinfo.output_height;){ + int n = jpeg_read_scanlines(&j->cinfo, rows, 2); + y += n; + rows[0] = rows[n-1] + row_stride; + rows[1] = rows[0] + row_stride; } }else if(j->cinfo.output_components == 1){ JSAMPARRAY buffer = (*j->cinfo.mem->alloc_sarray)((j_common_ptr)&j->cinfo, JPOOL_IMAGE, row_stride, 4); -- cgit v1.2.3