From cbc9970ecb9701ec807c5e587b020a808bd9d2c2 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 16 Jan 2015 06:29:52 +0000 Subject: [PATCH] Add the ability to benchmark YCCK JPEG compression/decompression. This is particularly useful since that is the only way to test the performance of the "plain" upsampling routines, which are accelerated on some platforms. git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.4.x@1511 632fc199-4ca6-4c93-a231-07263d6284db --- ChangeLog.txt | 14 +++++++++ bmp.c | 82 ++++++++++++++++++++++++++++++++++++++++++++------- tjbench.c | 21 +++++++++---- 3 files changed, 101 insertions(+), 16 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 8866455..05cef74 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,17 @@ +1.4.1 +===== + +[1] tjbench now properly handles CMYK/YCCK JPEG files. Passing an argument of +-cmyk (instead of, for instance, -rgb) will cause tjbench to internally convert +the source bitmap to CMYK prior to compression, to generate YCCK JPEG files, +and to internally convert the decompressed CMYK pixels back to RGB after +decompression (the latter is done automatically if a CMYK or YCCK JPEG is +passed to tjbench as a source image.) The CMYK<->RGB conversion operation is +not benchmarked. NOTE: The quick & dirty CMYK<->RGB conversions that tjbench +uses are suitable for testing only. Proper conversion between CMYK and RGB +requires a color management system. + + 1.4.0 ===== diff --git a/bmp.c b/bmp.c index 4986055..9fcf7bb 100644 --- a/bmp.c +++ b/bmp.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2011 D. R. Commander. All Rights Reserved. + * Copyright (C)2011, 2015 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -75,24 +75,84 @@ static void my_output_message(j_common_ptr cinfo) static void pixelconvert(unsigned char *srcbuf, int srcpf, int srcbottomup, unsigned char *dstbuf, int dstpf, int dstbottomup, int w, int h) { - unsigned char *srcptr=srcbuf, *srcptr2; + unsigned char *srcrowptr=srcbuf, *srccolptr; int srcps=tjPixelSize[srcpf]; int srcstride=srcbottomup? -w*srcps:w*srcps; - unsigned char *dstptr=dstbuf, *dstptr2; + unsigned char *dstrowptr=dstbuf, *dstcolptr; int dstps=tjPixelSize[dstpf]; int dststride=dstbottomup? -w*dstps:w*dstps; int row, col; - if(srcbottomup) srcptr=&srcbuf[w*srcps*(h-1)]; - if(dstbottomup) dstptr=&dstbuf[w*dstps*(h-1)]; - for(row=0; rowRGB conversion routines are for testing + purposes only. Properly converting between CMYK and RGB requires a color + management system. */ + + if(dstpf==TJPF_CMYK) + { + for(row=0; row1.0) c=1.0; if(c<0.) c=0.; + if(m>1.0) m=1.0; if(m<0.) m=0.; + if(y>1.0) y=1.0; if(y<0.) y=0.; + if(k>1.0) k=1.0; if(k<0.) k=0.; + *dstcolptr++=(unsigned char)(255.0-c*255.0+0.5); + *dstcolptr++=(unsigned char)(255.0-m*255.0+0.5); + *dstcolptr++=(unsigned char)(255.0-y*255.0+0.5); + *dstcolptr++=(unsigned char)(255.0-k*255.0+0.5); + } + } + } + else if(srcpf==TJPF_CMYK) + { + for(row=0; row255.0) r=255.0; if(r<0.) r=0.; + if(g>255.0) g=255.0; if(g<0.) g=0.; + if(b>255.0) b=255.0; if(b<0.) b=0.; + dstcolptr[tjRedOffset[dstpf]]=(unsigned char)(r+0.5); + dstcolptr[tjGreenOffset[dstpf]]=(unsigned char)(g+0.5); + dstcolptr[tjBlueOffset[dstpf]]=(unsigned char)(b+0.5); + } + } + } + else { - for(col=0, srcptr2=srcptr, dstptr2=dstptr; col=minqual; i--) - fullTest(srcbuf, w, h, TJSAMP_GRAY, i, argv[1]); - printf("\n"); + if(pf!=TJPF_CMYK) + { + for(i=maxqual; i>=minqual; i--) + fullTest(srcbuf, w, h, TJSAMP_GRAY, i, argv[1]); + printf("\n"); + } for(i=maxqual; i>=minqual; i--) fullTest(srcbuf, w, h, TJSAMP_420, i, argv[1]); printf("\n"); -- 2.40.0