From: DRC Date: Wed, 14 Jan 2015 19:39:01 +0000 (+0000) Subject: Add the ability to benchmark YCCK JPEG compression/decompression. This is particular... X-Git-Tag: 1.4.90~104 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2ab5ea6c48f0ab5eb9b77212f0ca2407a57215ac;p=libjpeg-turbo 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/trunk@1505 632fc199-4ca6-4c93-a231-07263d6284db --- 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");