From: DRC Date: Fri, 4 Mar 2011 02:25:00 +0000 (+0000) Subject: Transform tests; Variable benchmark time; General cleanup X-Git-Tag: 1.1.90~170 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f2cef492b141e085841acbfd89a98c2eb782781f;p=libjpeg-turbo Transform tests; Variable benchmark time; General cleanup git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@494 632fc199-4ca6-4c93-a231-07263d6284db --- diff --git a/jpgtest.c b/jpgtest.c index 6b9cc4c..80dc8e7 100644 --- a/jpgtest.c +++ b/jpgtest.c @@ -46,6 +46,8 @@ const char *_pfname[]={"RGB", "RGBX", "BGR", "BGRX", "XBGR", "XRGB"}; const char *_subnamel[NUMSUBOPT]={"4:4:4", "4:2:2", "4:2:0", "GRAY"}; const char *_subnames[NUMSUBOPT]={"444", "422", "420", "GRAY"}; tjscalingfactor *sf=NULL; int nsf=0; +int xformop=TJXFORM_NONE, xformopt=0; +double benchtime=5.0; void printsigfig(double val, int figs) { @@ -136,7 +138,7 @@ int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf, } } ITER++; - } while((elapsed=rrtime()-start)<5.); + } while((elapsed=rrtime()-start)h) tilesizey=h; numtilesx=(w+tilesizex-1)/tilesizex; numtilesy=(h+tilesizey-1)/tilesizey; - if((comptilesize=(unsigned long *)malloc(sizeof(unsigned long)*numtilesx*numtilesy)) == NULL - || (jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *)*numtilesx*numtilesy)) == NULL) - _throwunix("allocating image buffers"); + + if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) + *numtilesx*numtilesy))==NULL) + _throwunix("allocating image buffer array"); + if((comptilesize=(unsigned long *)malloc(sizeof(unsigned long) + *numtilesx*numtilesy))==NULL) + _throwunix("allocating image size array"); memset(jpegbuf, 0, sizeof(unsigned char *)*numtilesx*numtilesy); + for(i=0; i Frame rate: %f fps\n", (double)ITER/elapsed); printf(" Output image size: %d bytes\n", jpgbufsize); printf(" Compression ratio: %f:1\n", @@ -394,7 +398,8 @@ void dodecomptest(char *filename) unsigned char **jpegbuf=NULL, *srcbuf=NULL; unsigned long *comptilesize=NULL, srcbufsize, jpgbufsize; tjtransform *t=NULL; - int w=0, h=0, jpegsub=-1; + int w=0, h=0, jpegsub=-1, _w, _h, _tilesizex, _tilesizey, + _numtilesx, _numtilesy; char *temp=NULL; int i, j, tilesizex, tilesizey, numtilesx, numtilesy, retval=0; double start, elapsed; @@ -425,75 +430,102 @@ void dodecomptest(char *filename) if(yuv) dotile=0; - if(dotile) + if(dotile) {tilesizex=tilesizey=8;} else {tilesizex=w; tilesizey=h;} + + if(quiet==1) + { + printf("All performance values in Mpixels/sec\n\n"); + printf("Bitmap\tBitmap\tJPEG\t%s %s \tXform\tCompr\tDecomp\n", + dotile? "Tile ":"Image", dotile? "Tile ":"Image"); + printf("Format\tOrder\tFormat\tWidth Height\tPerf \tRatio\tPerf\n\n"); + } + else if(!quiet) + { + printf(">>>>> JPEG %s --> %s (%s) <<<<<\n", _subnamel[jpegsub], + _pfname[pf], bu?"Bottom-up":"Top-down"); + } + + do { - tilesizex=tilesizey=8; - if(quiet==1) + tilesizex*=2; if(tilesizex>w) tilesizex=w; + tilesizey*=2; if(tilesizey>h) tilesizey=h; + numtilesx=(w+tilesizex-1)/tilesizex; + numtilesy=(h+tilesizey-1)/tilesizey; + + if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) + *numtilesx*numtilesy))==NULL) + _throwunix("allocating image buffer array"); + if((comptilesize=(unsigned long *)malloc(sizeof(unsigned long) + *numtilesx*numtilesy))==NULL) + _throwunix("allocating image size array"); + memset(jpegbuf, 0, sizeof(unsigned char *)*numtilesx*numtilesy); + + for(i=0; i>>>> JPEG %s --> %s (%s) <<<<<\n", _subnamel[jpegsub], - _pfname[pf], bu?"Bottom-up":"Top-down"); + printf("\n%s size: %d x %d\n", dotile? "Tile":"Image", _tilesizex, + _tilesizey); + if(scale_num!=1 || scale_denom!=1) + printf(" --> %d x %d", (_w*scale_num+scale_denom-1)/scale_denom, + (_h*scale_num+scale_denom-1)/scale_denom); } - do + else if(quiet==1) + { + printf("%s\t%s\t%s\t", _pfname[pf], bu?"BU":"TD", _subnamel[jpegsub]); + printf("%-4d %-4d\t", tilesizex, tilesizey); + } + + if(dotile || xformop!=TJXFORM_NONE || xformopt!=0) { - tilesizex*=2; if(tilesizex>w) tilesizex=w; - tilesizey*=2; if(tilesizey>h) tilesizey=h; - numtilesx=(w+tilesizex-1)/tilesizex; - numtilesy=(h+tilesizey-1)/tilesizey; - - if((jpegbuf=(unsigned char **)malloc(sizeof(unsigned char *) - *numtilesx*numtilesy))==NULL) - _throwunix("allocating image buffer array"); - if((comptilesize=(unsigned long *)malloc(sizeof(unsigned long) - *numtilesx*numtilesy))==NULL) - _throwunix("allocating image size array"); if((t=(tjtransform *)malloc(sizeof(tjtransform)*numtilesx*numtilesy)) ==NULL) _throwunix("allocating image transform array"); - memset(jpegbuf, 0, sizeof(unsigned char *)*numtilesx*numtilesy); - - for(i=0; i Frame rate: %f fps\n", 1.0/elapsed); printf(" Output image size: %lu bytes\n", jpgbufsize); printf(" Compression ratio: %f:1\n", @@ -515,45 +545,26 @@ void dodecomptest(char *filename) printf(" Output bit stream: %f Megabits/sec\n", (double)jpgbufsize*8./1000000./elapsed); } - - if(decomptest(NULL, jpegbuf, comptilesize, NULL, w, h, jpegsub, 0, - filename, tilesizex, tilesizey)==-1) - goto bailout; - - // Cleanup - for(i=0; i>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]); - else - printf(">>>>> JPEG %s --> %s (%s) <<<<<\n", _subnamel[jpegsub], - _pfname[pf], bu?"Bottom-up":"Top-down"); - printf("\nImage size: %d x %d", w, h); - if(scale_num!=1 || scale_denom!=1) - printf(" --> %d x %d", (w*scale_num+scale_denom-1)/scale_denom, - (h*scale_num+scale_denom-1)/scale_denom); - printf("\n"); + if(quiet==1) printf("N/A\tN/A\t"); + comptilesize[0]=srcbufsize; + memcpy(jpegbuf[0], srcbuf, srcbufsize); } - decomptest(NULL, &srcbuf, &srcbufsize, NULL, w, h, jpegsub, 0, filename, - w, h); - } + if(w==tilesizex) _tilesizex=_w; + if(h==tilesizey) _tilesizey=_h; + if(decomptest(NULL, jpegbuf, comptilesize, NULL, _w, _h, jpegsub, 0, + filename, _tilesizex, _tilesizey)==-1) + goto bailout; + + // Cleanup + for(i=0; i = Run each benchmark for at least seconds (default = 5.0)\n\n"); printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n"); printf("test will be performed for all quality values in the range.\n\n"); exit(1); @@ -664,7 +681,10 @@ int main(int argc, char *argv[]) { for(i=minarg; i0.0) benchtime=temp; + else usage(argv[0]); + } } } @@ -737,8 +771,9 @@ int main(int argc, char *argv[]) if(quiet==1 && !decomponly) { printf("All performance values in Mpixels/sec\n\n"); - printf("Bitmap\tBitmap\tJPEG\tJPEG\tTile Size\tCompr\tCompr\tDecomp\n"); - printf("Format\tOrder\tFormat\tQual\t X Y \tPerf \tRatio\tPerf\n\n"); + printf("Bitmap\tBitmap\tJPEG\tJPEG\t%s %s \tCompr\tCompr\tDecomp\n", + dotile? "Tile ":"Image", dotile? "Tile ":"Image"); + printf("Format\tOrder\tFormat\tQual\tWidth Height\tPerf \tRatio\tPerf\n\n"); } if(decomponly)