OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C)2009-2011 D. R. Commander. All Rights Reserved. | 2 * Copyright (C)2009-2012 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 |
11 * and/or other materials provided with the distribution. | 11 * and/or other materials provided with the distribution. |
12 * - Neither the name of the libjpeg-turbo Project nor the names of its | 12 * - Neither the name of the libjpeg-turbo Project nor the names of its |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 }; | 70 }; |
71 | 71 |
72 const int alphaOffset[TJ_NUMPF] = {-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0}; | 72 const int alphaOffset[TJ_NUMPF] = {-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0}; |
73 | 73 |
74 const int _3byteFormats[]={TJPF_RGB, TJPF_BGR}; | 74 const int _3byteFormats[]={TJPF_RGB, TJPF_BGR}; |
75 const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB}; | 75 const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB}; |
76 const int _onlyGray[]={TJPF_GRAY}; | 76 const int _onlyGray[]={TJPF_GRAY}; |
77 const int _onlyRGB[]={TJPF_RGB}; | 77 const int _onlyRGB[]={TJPF_RGB}; |
78 | 78 |
79 enum {YUVENCODE=1, YUVDECODE}; | 79 enum {YUVENCODE=1, YUVDECODE}; |
80 int yuv=0, alloc=0, alpha=0; | 80 int yuv=0, alloc=0; |
81 | 81 |
82 int exitStatus=0; | 82 int exitStatus=0; |
83 #define bailout() {exitStatus=-1; goto bailout;} | 83 #define bailout() {exitStatus=-1; goto bailout;} |
84 | 84 |
85 | 85 |
86 void initBuf(unsigned char *buf, int w, int h, int pf, int flags) | 86 void initBuf(unsigned char *buf, int w, int h, int pf, int flags) |
87 { | 87 { |
88 int roffset=tjRedOffset[pf]; | 88 int roffset=tjRedOffset[pf]; |
89 int goffset=tjGreenOffset[pf]; | 89 int goffset=tjGreenOffset[pf]; |
90 int boffset=tjBlueOffset[pf]; | 90 int boffset=tjBlueOffset[pf]; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 } | 495 } |
496 | 496 |
497 if((chandle=tjInitCompress())==NULL || (dhandle=tjInitDecompress())==NUL
L) | 497 if((chandle=tjInitCompress())==NULL || (dhandle=tjInitDecompress())==NUL
L) |
498 _throwtj(); | 498 _throwtj(); |
499 | 499 |
500 for(pfi=0; pfi<nformats; pfi++) | 500 for(pfi=0; pfi<nformats; pfi++) |
501 { | 501 { |
502 for(i=0; i<2; i++) | 502 for(i=0; i<2; i++) |
503 { | 503 { |
504 int flags=0; | 504 int flags=0; |
| 505 if(subsamp==TJSAMP_422 || subsamp==TJSAMP_420 || subsamp
==TJSAMP_440) |
| 506 flags|=TJFLAG_FASTUPSAMPLE; |
505 if(i==1) | 507 if(i==1) |
506 { | 508 { |
507 if(yuv==YUVDECODE) goto bailout; | 509 if(yuv==YUVDECODE) goto bailout; |
508 else flags|=TJFLAG_BOTTOMUP; | 510 else flags|=TJFLAG_BOTTOMUP; |
509 } | 511 } |
510 pf=formats[pfi]; | 512 pf=formats[pfi]; |
511 compTest(chandle, &dstBuf, &size, w, h, pf, basename, su
bsamp, 100, | 513 compTest(chandle, &dstBuf, &size, w, h, pf, basename, su
bsamp, 100, |
512 flags); | 514 flags); |
513 decompTest(dhandle, dstBuf, size, w, h, pf, basename, su
bsamp, | 515 decompTest(dhandle, dstBuf, size, w, h, pf, basename, su
bsamp, |
514 flags); | 516 flags); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 if(!strcasecmp(argv[i], "-yuv")) doyuv=1; | 612 if(!strcasecmp(argv[i], "-yuv")) doyuv=1; |
611 if(!strcasecmp(argv[i], "-alloc")) alloc=1; | 613 if(!strcasecmp(argv[i], "-alloc")) alloc=1; |
612 if(!strncasecmp(argv[i], "-h", 2) || !strcasecmp(argv[i]
, "-?")) | 614 if(!strncasecmp(argv[i], "-h", 2) || !strcasecmp(argv[i]
, "-?")) |
613 usage(argv[0]); | 615 usage(argv[0]); |
614 } | 616 } |
615 } | 617 } |
616 if(alloc) printf("Testing automatic buffer allocation\n"); | 618 if(alloc) printf("Testing automatic buffer allocation\n"); |
617 if(doyuv) {yuv=YUVENCODE; alloc=0;} | 619 if(doyuv) {yuv=YUVENCODE; alloc=0;} |
618 doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test"); | 620 doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test"); |
619 doTest(39, 41, _4byteFormats, 4, TJSAMP_444, "test"); | 621 doTest(39, 41, _4byteFormats, 4, TJSAMP_444, "test"); |
620 » if(doyuv) | 622 » doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test"); |
621 » { | 623 » doTest(35, 39, _4byteFormats, 4, TJSAMP_422, "test"); |
622 » » doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test"); | 624 » doTest(39, 41, _3byteFormats, 2, TJSAMP_420, "test"); |
623 » » doTest(35, 39, _4byteFormats, 4, TJSAMP_422, "test"); | 625 » doTest(41, 35, _4byteFormats, 4, TJSAMP_420, "test"); |
624 » » doTest(39, 41, _3byteFormats, 2, TJSAMP_420, "test"); | 626 » doTest(35, 39, _3byteFormats, 2, TJSAMP_440, "test"); |
625 » » doTest(41, 35, _4byteFormats, 4, TJSAMP_420, "test"); | 627 » doTest(39, 41, _4byteFormats, 4, TJSAMP_440, "test"); |
626 » » doTest(35, 39, _3byteFormats, 2, TJSAMP_440, "test"); | |
627 » » doTest(39, 41, _4byteFormats, 4, TJSAMP_440, "test"); | |
628 » } | |
629 doTest(35, 39, _onlyGray, 1, TJSAMP_GRAY, "test"); | 628 doTest(35, 39, _onlyGray, 1, TJSAMP_GRAY, "test"); |
630 doTest(39, 41, _3byteFormats, 2, TJSAMP_GRAY, "test"); | 629 doTest(39, 41, _3byteFormats, 2, TJSAMP_GRAY, "test"); |
631 doTest(41, 35, _4byteFormats, 4, TJSAMP_GRAY, "test"); | 630 doTest(41, 35, _4byteFormats, 4, TJSAMP_GRAY, "test"); |
632 if(!doyuv) bufSizeTest(); | 631 if(!doyuv) bufSizeTest(); |
633 if(doyuv) | 632 if(doyuv) |
634 { | 633 { |
635 yuv=YUVDECODE; | 634 yuv=YUVDECODE; |
636 doTest(48, 48, _onlyRGB, 1, TJSAMP_444, "test_yuv0"); | 635 doTest(48, 48, _onlyRGB, 1, TJSAMP_444, "test_yuv0"); |
637 doTest(35, 39, _onlyRGB, 1, TJSAMP_444, "test_yuv1"); | 636 doTest(35, 39, _onlyRGB, 1, TJSAMP_444, "test_yuv1"); |
638 doTest(48, 48, _onlyRGB, 1, TJSAMP_422, "test_yuv0"); | 637 doTest(48, 48, _onlyRGB, 1, TJSAMP_422, "test_yuv0"); |
639 doTest(39, 41, _onlyRGB, 1, TJSAMP_422, "test_yuv1"); | 638 doTest(39, 41, _onlyRGB, 1, TJSAMP_422, "test_yuv1"); |
640 doTest(48, 48, _onlyRGB, 1, TJSAMP_420, "test_yuv0"); | 639 doTest(48, 48, _onlyRGB, 1, TJSAMP_420, "test_yuv0"); |
641 doTest(41, 35, _onlyRGB, 1, TJSAMP_420, "test_yuv1"); | 640 doTest(41, 35, _onlyRGB, 1, TJSAMP_420, "test_yuv1"); |
642 doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0"); | 641 doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0"); |
643 doTest(35, 39, _onlyRGB, 1, TJSAMP_440, "test_yuv1"); | 642 doTest(35, 39, _onlyRGB, 1, TJSAMP_440, "test_yuv1"); |
644 doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0"); | 643 doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0"); |
645 doTest(35, 39, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv1"); | 644 doTest(35, 39, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv1"); |
646 doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0"); | 645 doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0"); |
647 doTest(39, 41, _onlyGray, 1, TJSAMP_GRAY, "test_yuv1"); | 646 doTest(39, 41, _onlyGray, 1, TJSAMP_GRAY, "test_yuv1"); |
648 } | 647 } |
649 | 648 |
650 return exitStatus; | 649 return exitStatus; |
651 } | 650 } |
OLD | NEW |