Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tjbench.c

Issue 8720003: Update libjpeg-turbo to r722. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/libjpeg_turbo/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « simd/jsimdcfg.inc.h ('k') | tjunittest.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved. 2 * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
7 * - Redistributions of source code must retain the above copyright notice, 7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer. 8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice, 9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation 10 * this list of conditions and the following disclaimer in the documentation
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 { 52 {
53 "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY" 53 "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
54 }; 54 };
55 const char *subNameLong[TJ_NUMSAMP]= 55 const char *subNameLong[TJ_NUMSAMP]=
56 { 56 {
57 "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0" 57 "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0"
58 }; 58 };
59 const char *subName[NUMSUBOPT]={"444", "422", "420", "GRAY", "440"}; 59 const char *subName[NUMSUBOPT]={"444", "422", "420", "GRAY", "440"};
60 tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0; 60 tjscalingfactor *scalingfactors=NULL, sf={1, 1}; int nsf=0;
61 int xformop=TJXOP_NONE, xformopt=0; 61 int xformop=TJXOP_NONE, xformopt=0;
62 int (*customFilter)(short *, tjregion, tjregion, int, int, tjtransform *);
62 double benchtime=5.0; 63 double benchtime=5.0;
63 64
64 65
65 char *sigfig(double val, int figs, char *buf, int len) 66 char *sigfig(double val, int figs, char *buf, int len)
66 { 67 {
67 char format[80]; 68 char format[80];
68 int digitsafterdecimal=figs-(int)ceil(log10(fabs(val))); 69 int digitsafterdecimal=figs-(int)ceil(log10(fabs(val)));
69 if(digitsafterdecimal<1) snprintf(format, 80, "%%.0f"); 70 if(digitsafterdecimal<1) snprintf(format, 80, "%%.0f");
70 else snprintf(format, 80, "%%.%df", digitsafterdecimal); 71 else snprintf(format, 80, "%%.%df", digitsafterdecimal);
71 snprintf(buf, len, format, val); 72 snprintf(buf, len, format, val);
72 return buf; 73 return buf;
73 } 74 }
74 75
75 76
77 /* Custom DCT filter which produces a negative of the image */
78 int dummyDCTFilter(short *coeffs, tjregion arrayRegion, tjregion planeRegion,
79 int componentIndex, int transformIndex, tjtransform *transform)
80 {
81 int i;
82 for(i=0; i<arrayRegion.w*arrayRegion.h; i++) coeffs[i]=-coeffs[i];
83 return 0;
84 }
85
86
76 /* Decompression test */ 87 /* Decompression test */
77 int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf, 88 int decomptest(unsigned char *srcbuf, unsigned char **jpegbuf,
78 unsigned long *jpegsize, unsigned char *dstbuf, int w, int h, 89 unsigned long *jpegsize, unsigned char *dstbuf, int w, int h,
79 int subsamp, int jpegqual, char *filename, int tilew, int tileh) 90 int subsamp, int jpegqual, char *filename, int tilew, int tileh)
80 { 91 {
81 char tempstr[1024], sizestr[20]="\0", qualstr[6]="\0", *ptr; 92 char tempstr[1024], sizestr[20]="\0", qualstr[6]="\0", *ptr;
82 FILE *file=NULL; tjhandle handle=NULL; 93 FILE *file=NULL; tjhandle handle=NULL;
83 int row, col, i, dstbufalloc=0, retval=0; 94 int row, col, i, dstbufalloc=0, retval=0;
84 double start, elapsed; 95 double start, elapsed;
85 int ps=tjPixelSize[pf]; 96 int ps=tjPixelSize[pf];
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 462
452 void dodecomptest(char *filename) 463 void dodecomptest(char *filename)
453 { 464 {
454 FILE *file=NULL; tjhandle handle=NULL; 465 FILE *file=NULL; tjhandle handle=NULL;
455 unsigned char **jpegbuf=NULL, *srcbuf=NULL; 466 unsigned char **jpegbuf=NULL, *srcbuf=NULL;
456 unsigned long *jpegsize=NULL, srcsize, totaljpegsize; 467 unsigned long *jpegsize=NULL, srcsize, totaljpegsize;
457 tjtransform *t=NULL; 468 tjtransform *t=NULL;
458 int w=0, h=0, subsamp=-1, _w, _h, _tilew, _tileh, 469 int w=0, h=0, subsamp=-1, _w, _h, _tilew, _tileh,
459 _ntilesw, _ntilesh, _subsamp; 470 _ntilesw, _ntilesh, _subsamp;
460 char *temp=NULL, tempstr[80], tempstr2[80]; 471 char *temp=NULL, tempstr[80], tempstr2[80];
461 » int row, col, i, tilew, tileh, ntilesw, ntilesh, retval=0; 472 » int row, col, i, tilew, tileh, ntilesw=1, ntilesh=1, retval=0;
462 double start, elapsed; 473 double start, elapsed;
463 int ps=tjPixelSize[pf], tile; 474 int ps=tjPixelSize[pf], tile;
464 475
465 if((file=fopen(filename, "rb"))==NULL) 476 if((file=fopen(filename, "rb"))==NULL)
466 _throwunix("opening file"); 477 _throwunix("opening file");
467 if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))<0) 478 if(fseek(file, 0, SEEK_END)<0 || (srcsize=ftell(file))<0)
468 _throwunix("determining file size"); 479 _throwunix("determining file size");
469 if((srcbuf=(unsigned char *)malloc(srcsize))==NULL) 480 if((srcbuf=(unsigned char *)malloc(srcsize))==NULL)
470 _throwunix("allocating memory"); 481 _throwunix("allocating memory");
471 if(fseek(file, 0, SEEK_SET)<0) 482 if(fseek(file, 0, SEEK_SET)<0)
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
527 printf("\n"); 538 printf("\n");
528 } 539 }
529 else if(quiet==1) 540 else if(quiet==1)
530 { 541 {
531 printf("%s\t%s\t%s\t", pixFormatStr[pf], 542 printf("%s\t%s\t%s\t", pixFormatStr[pf],
532 (flags&TJFLAG_BOTTOMUP)? "BU":"TD", subNameLong[ subsamp]); 543 (flags&TJFLAG_BOTTOMUP)? "BU":"TD", subNameLong[ subsamp]);
533 printf("%-4d %-4d\t", tilew, tileh); 544 printf("%-4d %-4d\t", tilew, tileh);
534 } 545 }
535 546
536 _subsamp=subsamp; 547 _subsamp=subsamp;
537 » » if(dotile || xformop!=TJXOP_NONE || xformopt!=0) 548 » » if(dotile || xformop!=TJXOP_NONE || xformopt!=0 || customFilter)
538 { 549 {
539 if((t=(tjtransform *)malloc(sizeof(tjtransform)*ntilesw* ntilesh)) 550 if((t=(tjtransform *)malloc(sizeof(tjtransform)*ntilesw* ntilesh))
540 ==NULL) 551 ==NULL)
541 _throwunix("allocating image transform array"); 552 _throwunix("allocating image transform array");
542 553
543 if(xformop==TJXOP_TRANSPOSE || xformop==TJXOP_TRANSVERSE 554 if(xformop==TJXOP_TRANSPOSE || xformop==TJXOP_TRANSVERSE
544 || xformop==TJXOP_ROT90 || xformop==TJXOP_ROT270 ) 555 || xformop==TJXOP_ROT90 || xformop==TJXOP_ROT270 )
545 { 556 {
546 _w=h; _h=w; _tilew=tileh; _tileh=tilew; 557 _w=h; _h=w; _tilew=tileh; _tileh=tilew;
547 } 558 }
(...skipping 13 matching lines...) Expand all
561 for(row=0, tile=0; row<_ntilesh; row++) 572 for(row=0, tile=0; row<_ntilesh; row++)
562 { 573 {
563 for(col=0; col<_ntilesw; col++, tile++) 574 for(col=0; col<_ntilesw; col++, tile++)
564 { 575 {
565 t[tile].r.w=min(_tilew, _w-col*_tilew); 576 t[tile].r.w=min(_tilew, _w-col*_tilew);
566 t[tile].r.h=min(_tileh, _h-row*_tileh); 577 t[tile].r.h=min(_tileh, _h-row*_tileh);
567 t[tile].r.x=col*_tilew; 578 t[tile].r.x=col*_tilew;
568 t[tile].r.y=row*_tileh; 579 t[tile].r.y=row*_tileh;
569 t[tile].op=xformop; 580 t[tile].op=xformop;
570 t[tile].options=xformopt|TJXOPT_TRIM; 581 t[tile].options=xformopt|TJXOPT_TRIM;
582 t[tile].customFilter=customFilter;
583 if(t[tile].options&TJXOPT_NOOUTPUT && jp egbuf[tile])
584 {
585 free(jpegbuf[tile]); jpegbuf[ti le]=NULL;
586 }
571 } 587 }
572 } 588 }
573 589
574 start=gettime(); 590 start=gettime();
575 if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntiles h, jpegbuf, 591 if(tjTransform(handle, srcbuf, srcsize, _ntilesw*_ntiles h, jpegbuf,
576 jpegsize, t, flags)==-1) 592 jpegsize, t, flags)==-1)
577 _throwtj("executing tjTransform()"); 593 _throwtj("executing tjTransform()");
578 elapsed=gettime()-start; 594 elapsed=gettime()-start;
579 595
580 free(t); t=NULL; 596 free(t); t=NULL;
(...skipping 23 matching lines...) Expand all
604 } 620 }
605 else 621 else
606 { 622 {
607 if(quiet==1) printf("N/A\tN/A\t"); 623 if(quiet==1) printf("N/A\tN/A\t");
608 jpegsize[0]=srcsize; 624 jpegsize[0]=srcsize;
609 memcpy(jpegbuf[0], srcbuf, srcsize); 625 memcpy(jpegbuf[0], srcbuf, srcsize);
610 } 626 }
611 627
612 if(w==tilew) _tilew=_w; 628 if(w==tilew) _tilew=_w;
613 if(h==tileh) _tileh=_h; 629 if(h==tileh) _tileh=_h;
614 » » if(decomptest(NULL, jpegbuf, jpegsize, NULL, _w, _h, _subsamp, 0 , 630 » » if(!(xformopt&TJXOPT_NOOUTPUT))
615 » » » filename, _tilew, _tileh)==-1) 631 » » {
616 » » » goto bailout; 632 » » » if(decomptest(NULL, jpegbuf, jpegsize, NULL, _w, _h, _su bsamp, 0,
633 » » » » filename, _tilew, _tileh)==-1)
634 » » » » goto bailout;
635 » » }
636 » » else if(quiet==1) printf("N/A\n");
617 637
618 for(i=0; i<ntilesw*ntilesh; i++) 638 for(i=0; i<ntilesw*ntilesh; i++)
619 { 639 {
620 free(jpegbuf[i]); jpegbuf[i]=NULL; 640 free(jpegbuf[i]); jpegbuf[i]=NULL;
621 } 641 }
622 free(jpegbuf); jpegbuf=NULL; 642 free(jpegbuf); jpegbuf=NULL;
623 if(jpegsize) {free(jpegsize); jpegsize=NULL;} 643 if(jpegsize) {free(jpegsize); jpegsize=NULL;}
624 644
625 if(tilew==w && tileh==h) break; 645 if(tilew==w && tileh==h) break;
626 } 646 }
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 else usage(argv[0]); 822 else usage(argv[0]);
803 } 823 }
804 if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP; 824 if(!strcasecmp(argv[i], "-hflip")) xformop=TJXOP_HFLIP;
805 if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP; 825 if(!strcasecmp(argv[i], "-vflip")) xformop=TJXOP_VFLIP;
806 if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRA NSPOSE; 826 if(!strcasecmp(argv[i], "-transpose")) xformop=TJXOP_TRA NSPOSE;
807 if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TR ANSVERSE; 827 if(!strcasecmp(argv[i], "-transverse")) xformop=TJXOP_TR ANSVERSE;
808 if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90; 828 if(!strcasecmp(argv[i], "-rot90")) xformop=TJXOP_ROT90;
809 if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180 ; 829 if(!strcasecmp(argv[i], "-rot180")) xformop=TJXOP_ROT180 ;
810 if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270 ; 830 if(!strcasecmp(argv[i], "-rot270")) xformop=TJXOP_ROT270 ;
811 if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_ GRAY; 831 if(!strcasecmp(argv[i], "-grayscale")) xformopt|=TJXOPT_ GRAY;
832 if(!strcasecmp(argv[i], "-custom")) customFilter=dummyDC TFilter;
833 if(!strcasecmp(argv[i], "-nooutput")) xformopt|=TJXOPT_N OOUTPUT;
812 if(!strcasecmp(argv[i], "-benchtime") && i<argc-1) 834 if(!strcasecmp(argv[i], "-benchtime") && i<argc-1)
813 { 835 {
814 double temp=atof(argv[++i]); 836 double temp=atof(argv[++i]);
815 if(temp>0.0) benchtime=temp; 837 if(temp>0.0) benchtime=temp;
816 else usage(argv[0]); 838 else usage(argv[0]);
817 } 839 }
818 if(!strcmp(argv[i], "-?")) usage(argv[0]); 840 if(!strcmp(argv[i], "-?")) usage(argv[0]);
819 if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREA LLOC); 841 if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREA LLOC);
820 if(!strcasecmp(argv[i], "-bmp")) ext="bmp"; 842 if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
821 } 843 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 dotest(srcbuf, w, h, TJ_422, i, argv[1]); 889 dotest(srcbuf, w, h, TJ_422, i, argv[1]);
868 printf("\n"); 890 printf("\n");
869 for(i=maxqual; i>=minqual; i--) 891 for(i=maxqual; i>=minqual; i--)
870 dotest(srcbuf, w, h, TJ_444, i, argv[1]); 892 dotest(srcbuf, w, h, TJ_444, i, argv[1]);
871 printf("\n"); 893 printf("\n");
872 894
873 bailout: 895 bailout:
874 if(srcbuf) free(srcbuf); 896 if(srcbuf) free(srcbuf);
875 return retval; 897 return retval;
876 } 898 }
OLDNEW
« no previous file with comments | « simd/jsimdcfg.inc.h ('k') | tjunittest.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698