]> granicus.if.org Git - libjpeg-turbo/commitdiff
Fix various CR/LF issues
authorDRC <dcommander@users.sourceforge.net>
Fri, 25 Feb 2011 00:25:31 +0000 (00:25 +0000)
committerDRC <dcommander@users.sourceforge.net>
Fri, 25 Feb 2011 00:25:31 +0000 (00:25 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@443 632fc199-4ca6-4c93-a231-07263d6284db

1  2 
jpgtest.c

diff --cc jpgtest.c
index 773a32e7fc9076b60341455123fe3b03897c49b4,25e9ef3ac2aafd6faf877f2b34d8d15d3852a809..b6d6579e6543f97ed6b3fd07a1c4920c358d6ec1
+++ 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<h; i+=tilesizey)
 -                      {
 -                              for(j=0; j<w; j+=tilesizex)
 -                              {
 -                                      int tempw=min(tilesizex, w-j), temph=min(tilesizey, h-i);
 -                                      if(tjDecompress(hnd, jpegbuf[tilen], comptilesize[tilen],
 -                                              &rgbbuf[pitch*i+ps*j], tempw, pitch, temph, ps, flags)==-1)
 -                                              _throwtj("executing tjDecompress()");
 -                                      tilen++;
 -                              }
 -                      }
 -                      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("\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);
 -              }
 -              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; j<h; j++)
 -                              {
 -                                      for(i=0; i<w*ps; i+=ps)
 -                                      {
 -                                              int y=(int)((double)srcbuf[w*ps*j+i+_rindex[pf]]*0.299
 -                                                      + (double)srcbuf[w*ps*j+i+_gindex[pf]]*0.587
 -                                                      + (double)srcbuf[w*ps*j+i+_bindex[pf]]*0.114 + 0.5);
 -                                              if(y>255) 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<h; j++) for(i=0; i<w*ps; i++)
 -                                      rgbbuf[pitch*j+i]=abs(rgbbuf[pitch*j+i]-srcbuf[w*ps*j+i]);
 -                      }
 -                      if(savebmp(tempstr, rgbbuf, w, h, pf, pitch, bu)==-1)
 -                              _throwbmp("saving bitmap");
 -              }
 +              if(decomptest(srcbuf, jpegbuf, comptilesize, rgbbuf, w, h, jpegsub, qual,
 +                      filename, tilesizex, tilesizey)==-1)
 +                      goto bailout;
  
                // Cleanup
                if(outfile) {fclose(outfile);  outfile=NULL;}
@@@ -400,27 -356,65 +403,27 @@@ void dodecomptest(char *filename
  
        if(quiet==1)
        {
-               printf("\nAll performance values in Mpixels/sec\n\n");
+               printf("All performance values in Mpixels/sec\n\n");
 -              printf("Bitmap\tBitmap\tImage Size\tDecomp\n"),
 -              printf("Format\tOrder\t X    Y  \tPerf\n\n");
 -              printf("%s\t%s\t%-4d %-4d\t", _pfname[pf], bu?"BU":"TD", w, h);
 +              printf("Bitmap\tBitmap\tJPEG\tImage Size\tDecomp\n"),
 +              printf("Format\tOrder\tFormat\t  X    Y  \tPerf\n\n");
 +              printf("%s\t%s\t%s\t%-4d  %-4d\t", _pfname[pf], bu?"BU":"TD",
 +                      _subnamel[jpegsub], w, h);
        }
 -
 -      if((rgbbuf=(unsigned char *)malloc(max(yuvsize, pitch*h)))==NULL)
 -              _throwunix("allocating image buffer");
 -
 -      if(!quiet)
 +      else
        {
                if(yuv==YUVDECODE)
-                       printf("\n>>>>>  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);