| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 #define _throw(m) {printf("ERROR: %s\n", m); bailout();} | 58 #define _throw(m) {printf("ERROR: %s\n", m); bailout();} |
| 59 | 59 |
| 60 const char *subNameLong[TJ_NUMSAMP]= | 60 const char *subNameLong[TJ_NUMSAMP]= |
| 61 { | 61 { |
| 62 "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0" | 62 "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0" |
| 63 }; | 63 }; |
| 64 const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440"}; | 64 const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440"}; |
| 65 | 65 |
| 66 const char *pixFormatStr[TJ_NUMPF]= | 66 const char *pixFormatStr[TJ_NUMPF]= |
| 67 { | 67 { |
| 68 » "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale" | 68 » "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale", |
| 69 » "RGBA", "BGRA", "ABGR", "ARGB" |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 const int alphaOffset[TJ_NUMPF] = {-1, -1, 3, 3, 0, 0, -1}; | 72 const int alphaOffset[TJ_NUMPF] = {-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0}; |
| 72 | 73 |
| 73 const int _3byteFormats[]={TJPF_RGB, TJPF_BGR}; | 74 const int _3byteFormats[]={TJPF_RGB, TJPF_BGR}; |
| 74 const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB}; | 75 const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB}; |
| 75 const int _onlyGray[]={TJPF_GRAY}; | 76 const int _onlyGray[]={TJPF_GRAY}; |
| 76 const int _onlyRGB[]={TJPF_RGB}; | 77 const int _onlyRGB[]={TJPF_RGB}; |
| 77 | 78 |
| 78 enum {YUVENCODE=1, YUVDECODE}; | 79 enum {YUVENCODE=1, YUVDECODE}; |
| 79 int yuv=0, alloc=0; | 80 int yuv=0, alloc=0, alpha=0; |
| 80 | 81 |
| 81 int exitStatus=0; | 82 int exitStatus=0; |
| 82 #define bailout() {exitStatus=-1; goto bailout;} | 83 #define bailout() {exitStatus=-1; goto bailout;} |
| 83 | 84 |
| 84 | 85 |
| 85 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) |
| 86 { | 87 { |
| 87 int roffset=tjRedOffset[pf]; | 88 int roffset=tjRedOffset[pf]; |
| 88 int goffset=tjGreenOffset[pf]; | 89 int goffset=tjGreenOffset[pf]; |
| 89 int boffset=tjBlueOffset[pf]; | 90 int boffset=tjBlueOffset[pf]; |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 if(i==1) | 505 if(i==1) |
| 505 { | 506 { |
| 506 if(yuv==YUVDECODE) goto bailout; | 507 if(yuv==YUVDECODE) goto bailout; |
| 507 else flags|=TJFLAG_BOTTOMUP; | 508 else flags|=TJFLAG_BOTTOMUP; |
| 508 } | 509 } |
| 509 pf=formats[pfi]; | 510 pf=formats[pfi]; |
| 510 compTest(chandle, &dstBuf, &size, w, h, pf, basename, su
bsamp, 100, | 511 compTest(chandle, &dstBuf, &size, w, h, pf, basename, su
bsamp, 100, |
| 511 flags); | 512 flags); |
| 512 decompTest(dhandle, dstBuf, size, w, h, pf, basename, su
bsamp, | 513 decompTest(dhandle, dstBuf, size, w, h, pf, basename, su
bsamp, |
| 513 flags); | 514 flags); |
| 515 if(pf>=TJPF_RGBX && pf<=TJPF_XRGB) |
| 516 decompTest(dhandle, dstBuf, size, w, h, pf+(TJPF
_RGBA-TJPF_RGBX), |
| 517 basename, subsamp, flags); |
| 514 } | 518 } |
| 515 } | 519 } |
| 516 | 520 |
| 517 bailout: | 521 bailout: |
| 518 if(chandle) tjDestroy(chandle); | 522 if(chandle) tjDestroy(chandle); |
| 519 if(dhandle) tjDestroy(dhandle); | 523 if(dhandle) tjDestroy(dhandle); |
| 520 | 524 |
| 521 if(dstBuf) tjFree(dstBuf); | 525 if(dstBuf) tjFree(dstBuf); |
| 522 } | 526 } |
| 523 | 527 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0"); | 642 doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0"); |
| 639 doTest(35, 39, _onlyRGB, 1, TJSAMP_440, "test_yuv1"); | 643 doTest(35, 39, _onlyRGB, 1, TJSAMP_440, "test_yuv1"); |
| 640 doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0"); | 644 doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0"); |
| 641 doTest(35, 39, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv1"); | 645 doTest(35, 39, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv1"); |
| 642 doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0"); | 646 doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0"); |
| 643 doTest(39, 41, _onlyGray, 1, TJSAMP_GRAY, "test_yuv1"); | 647 doTest(39, 41, _onlyGray, 1, TJSAMP_GRAY, "test_yuv1"); |
| 644 } | 648 } |
| 645 | 649 |
| 646 return exitStatus; | 650 return exitStatus; |
| 647 } | 651 } |
| OLD | NEW |