aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Hawthorn <jhawthor@uvic.ca>2008-06-24 19:38:51 -0700
committerJohn Hawthorn <jhawthor@uvic.ca>2008-06-24 19:38:51 -0700
commit29510850182646a62d7969641edd8265a8cfc7ac (patch)
treeae8584a76e07cd7204ad3ccadbd3e1d2627b1c4c
parent07e510dd35cfa682d29dfdbaf02bdf5f31073f2c (diff)
downloadmirror-meh-29510850182646a62d7969641edd8265a8cfc7ac.tar.gz
mirror-meh-29510850182646a62d7969641edd8265a8cfc7ac.tar.bz2
mirror-meh-29510850182646a62d7969641edd8265a8cfc7ac.zip
eliminated a memcpy for colour jpegs
-rw-r--r--src/jpeg.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/jpeg.c b/src/jpeg.c
index e2d37d1..ecefda9 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -61,26 +61,24 @@ static struct image *jpeg_open(FILE *f){
static int jpeg_read(struct image *img){
struct jpeg_t *j = (struct jpeg_t *)img;
- JSAMPARRAY buffer;
unsigned int row_stride;
int a = 0, b;
unsigned int x, y;
row_stride = j->cinfo.output_width * j->cinfo.output_components;
- buffer = (*j->cinfo.mem->alloc_sarray)((j_common_ptr)&j->cinfo, JPOOL_IMAGE, row_stride, 4);
jpeg_start_decompress(&j->cinfo);
+ unsigned char *buf = img->buf;
+
if(j->cinfo.output_components == 3){
- for(y = 0; y < j->cinfo.output_height; ){
- int n = jpeg_read_scanlines(&j->cinfo, buffer, 4);
- for(b = 0; b < n; b++){
- memcpy(&img->buf[a], buffer[b], row_stride);
- a += row_stride;
- }
- y += n;
+ JSAMPARRAY buffer = &buf;
+ for(y = 0; y < j->cinfo.output_height; y++){
+ jpeg_read_scanlines(&j->cinfo, buffer, 1);
+ buf += 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);
for(y = 0; y < j->cinfo.output_height; ){
int n = jpeg_read_scanlines(&j->cinfo, buffer, 4);
for(b = 0; b < n; b++){