From: DRC Date: Fri, 25 Feb 2011 00:25:31 +0000 (+0000) Subject: Fix various CR/LF issues X-Git-Tag: 1.1.90~209 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f8552faa0951abb1d26668163eec9a637348bd63;p=libjpeg-turbo Fix various CR/LF issues git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@443 632fc199-4ca6-4c93-a231-07263d6284db --- f8552faa0951abb1d26668163eec9a637348bd63 diff --cc jpgtest.c index 773a32e,25e9ef3..b6d6579 --- a/jpgtest.c +++ b/jpgtest.c @@@ -331,12 -188,95 +331,15 @@@ void dotest(unsigned char *srcbuf, int fclose(outfile); outfile=NULL; if(!quiet) printf("Reference image written to %s\n", tempstr); } - if(yuv==YUVENCODE) goto bailout; + if(yuv==YUVENCODE) + { + if(quiet==1) printf("\n"); goto bailout; + } // Decompression test - if(yuv==YUVDECODE) flags |= TJ_YUV; - memset(rgbbuf, 127, max(yuvsize, pitch*h)); // Grey image means decompressor did nothing - if((hnd=tjInitDecompress())==NULL) - _throwtj("executing tjInitDecompress()"); - if(tjDecompress(hnd, jpegbuf[0], jpgbufsize, rgbbuf, tilesizex, pitch, - tilesizey, ps, flags)==-1) - _throwtj("executing tjDecompress()"); - ITER=0; - start=rrtime(); - do - { - int tilen=0; - for(i=0; i Frame rate: %f fps\n", (double)ITER/elapsed); - printf(" Dest. throughput: %f Megapixels/sec\n", - (double)(w*h)/1000000.*(double)ITER/elapsed); - } - if(yuv==YUVDECODE) - { - sprintf(tempstr, "%s_%sQ%d.yuv", filename, _subnames[jpegsub], qual); - if((outfile=fopen(tempstr, "wb"))==NULL) - _throwunix("opening YUV image for output"); - if(fwrite(rgbbuf, yuvsize, 1, outfile)!=1) - _throwunix("writing YUV image"); - fclose(outfile); outfile=NULL; - } - else - { - if(tilesizex==w && tilesizey==h) - sprintf(tempstr, "%s_%sQ%d_full.%s", filename, _subnames[jpegsub], qual, - useppm?"ppm":"bmp"); - else sprintf(tempstr, "%s_%sQ%d_%dx%d.%s", filename, _subnames[jpegsub], - qual, tilesizex, tilesizey, useppm?"ppm":"bmp"); - if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1) - _throwbmp("saving bitmap"); - sprintf(strrchr(tempstr, '.'), "-err.%s", useppm?"ppm":"bmp"); - if(!quiet) - printf("Computing compression error and saving to %s.\n", tempstr); - if(jpegsub==TJ_GRAYSCALE) - { - for(j=0; j255) y=255; if(y<0) y=0; - rgbbuf[pitch*j+i+_rindex[pf]]=abs(rgbbuf[pitch*j+i+_rindex[pf]]-y); - rgbbuf[pitch*j+i+_gindex[pf]]=abs(rgbbuf[pitch*j+i+_gindex[pf]]-y); - rgbbuf[pitch*j+i+_bindex[pf]]=abs(rgbbuf[pitch*j+i+_bindex[pf]]-y); - } - } - } - else - { - for(j=0; j>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]); + printf(">>>>> JPEG --> YUV %s <<<<<\n", _subnamel[jpegsub]); else - printf("\n>>>>> JPEG --> %s (%s) <<<<<\n", _pfname[pf], + printf(">>>>> JPEG --> %s (%s) <<<<<\n", _pfname[pf], bu?"Bottom-up":"Top-down"); - printf("\nImage size: %d x %d\n", w, h); - } - - memset(rgbbuf, 127, max(yuvsize, pitch*h)); // Grey image means decompressor did nothing - if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps, flags)==-1) - _throwtj("executing tjDecompress()"); - ITER=0; - start=rrtime(); - do - { - if(tjDecompress(hnd, jpegbuf, jpgbufsize, rgbbuf, w, pitch, h, ps, flags) - ==-1) - _throwtj("executing tjDecompress()"); - ITER++; - } while((elapsed=rrtime()-start)<5.); - if(tjDestroy(hnd)==-1) _throwtj("executing tjDestroy()"); - hnd=NULL; - if(quiet) - { - printsigfig((double)(w*h)/1000000.*(double)ITER/elapsed, 4); + printf("\nImage size: %d x %d", w, h); + if(scalefactor!=1) printf(" --> %d x %d", (w+scalefactor-1)/scalefactor, + (h+scalefactor-1)/scalefactor); printf("\n"); } - else - { - printf("D--> Frame rate: %f fps\n", (double)ITER/elapsed); - printf(" Dest. throughput: %f Megapixels/sec\n", - (double)(w*h)/1000000.*(double)ITER/elapsed); - } - sprintf(tempstr, "%s_full.%s", filename, useppm?"ppm":"bmp"); - if(yuv==YUVDECODE) - { - sprintf(tempstr, "%s_%s.yuv", filename, _subnames[jpegsub]); - if((file=fopen(tempstr, "wb"))==NULL) - _throwunix("opening YUV image for output"); - if(fwrite(rgbbuf, yuvsize, 1, file)!=1) - _throwunix("writing YUV image"); - fclose(file); file=NULL; - } - else - { - if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1) - _throwbmp("saving bitmap"); - } + + decomptest(NULL, &jpegbuf, &jpgbufsize, NULL, w, h, jpegsub, 0, filename, w, + h); bailout: if(file) {fclose(file); file=NULL;} @@@ -577,20 -560,22 +582,22 @@@ int main(int argc, char *argv[] if(decomponly) { - dodecomptest(argv[1], pf, bu, 1, quiet); + dodecomptest(argv[1]); + printf("\n"); goto bailout; } for(i=hiqual; i>=qual; i--) - dotest(bmpbuf, w, h, pf, bu, TJ_GRAYSCALE, i, argv[1], dotile, useppm, quiet); + dotest(bmpbuf, w, h, TJ_GRAYSCALE, i, argv[1]); - if(quiet) printf("\n"); + printf("\n"); for(i=hiqual; i>=qual; i--) - dotest(bmpbuf, w, h, pf, bu, TJ_420, i, argv[1], dotile, useppm, quiet); + dotest(bmpbuf, w, h, TJ_420, i, argv[1]); - if(quiet) printf("\n"); + printf("\n"); for(i=hiqual; i>=qual; i--) - dotest(bmpbuf, w, h, pf, bu, TJ_422, i, argv[1], dotile, useppm, quiet); + dotest(bmpbuf, w, h, TJ_422, i, argv[1]); - if(quiet) printf("\n"); + printf("\n"); for(i=hiqual; i>=qual; i--) - dotest(bmpbuf, w, h, pf, bu, TJ_444, i, argv[1], dotile, useppm, quiet); + dotest(bmpbuf, w, h, TJ_444, i, argv[1]); + printf("\n"); bailout: if(bmpbuf) free(bmpbuf);