diff options
Diffstat (limited to 'tjunittest.c')
-rw-r--r-- | tjunittest.c | 236 |
1 files changed, 139 insertions, 97 deletions
diff --git a/tjunittest.c b/tjunittest.c index 6235b6f..af409a5 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2014, 2017-2018 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2014, 2017-2019 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -61,16 +61,16 @@ static void usage(char *progName) #endif -#define _throwtj() { \ +#define THROW_TJ() { \ fprintf(stderr, "TurboJPEG ERROR:\n%s\n", tjGetErrorStr()); \ - bailout() \ + BAILOUT() \ } -#define _tj(f) { if ((f) == -1) _throwtj(); } -#define _throw(m) { fprintf(stderr, "ERROR: %s\n", m); bailout() } -#define _throwmd5(filename, md5sum, ref) { \ +#define TRY_TJ(f) { if ((f) == -1) THROW_TJ(); } +#define THROW(m) { printf("ERROR: %s\n", m); BAILOUT() } +#define THROW_MD5(filename, md5sum, ref) { \ fprintf(stderr, "\n%s has an MD5 sum of %s.\n Should be %s.\n", filename, \ md5sum, ref); \ - bailout() \ + BAILOUT() \ } static const char *subNameLong[TJ_NUMSAMP] = { @@ -80,7 +80,7 @@ static const char *subName[TJ_NUMSAMP] = { "444", "422", "420", "GRAY", "440", "411" }; -const char *pixFormatStr[TJ_NUMPF] = { +static const char *pixFormatStr[TJ_NUMPF] = { "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale", "RGBA", "BGRA", "ABGR", "ARGB", "CMYK" }; @@ -95,7 +95,7 @@ static const int _onlyRGB[] = { TJPF_RGB }; static int doYUV = 0, alloc = 0, pad = 4; static int exitStatus = 0; -#define bailout() { exitStatus = -1; goto bailout; } +#define BAILOUT() { exitStatus = -1; goto bailout; } static const size_t filePathSize = 1024; @@ -155,7 +155,7 @@ static void initBuf(unsigned char *buf, int w, int h, int pf, int flags) } -#define checkval(v, cv) { \ +#define CHECKVAL(v, cv) { \ if (v < cv - 1 || v > cv + 1) { \ fprintf(stderr, "\nComp. %s at %d,%d should be %d, not %d\n", #v, row, \ col, cv, v); \ @@ -163,7 +163,7 @@ static void initBuf(unsigned char *buf, int w, int h, int pf, int flags) } \ } -#define checkval0(v) { \ +#define CHECKVAL0(v) { \ if (v > 1) { \ fprintf(stderr, "\nComp. %s at %d,%d should be 0, not %d\n", #v, row, \ col, v); \ @@ -171,7 +171,7 @@ static void initBuf(unsigned char *buf, int w, int h, int pf, int flags) } \ } -#define checkval255(v) { \ +#define CHECKVAL255(v) { \ if (v < 254) { \ fprintf(stderr, "\nComp. %s at %d,%d should be 255, not %d\n", #v, row, \ col, v); \ @@ -206,13 +206,13 @@ static int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, y = buf[index * ps + 2]; k = buf[index * ps + 3]; if (((row / blocksize) + (col / blocksize)) % 2 == 0) { - checkval255(c); checkval255(m); checkval255(y); - if (row < halfway) checkval255(k) - else checkval0(k) + CHECKVAL255(c); CHECKVAL255(m); CHECKVAL255(y); + if (row < halfway) CHECKVAL255(k) + else CHECKVAL0(k) } else { - checkval255(c); checkval0(y); checkval255(k); - if (row < halfway) checkval0(m) - else checkval255(m) + CHECKVAL255(c); CHECKVAL0(y); CHECKVAL255(k); + if (row < halfway) CHECKVAL0(m) + else CHECKVAL255(m) } } } @@ -231,26 +231,26 @@ static int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, a = aoffset >= 0 ? buf[index * ps + aoffset] : 0xFF; if (((row / blocksize) + (col / blocksize)) % 2 == 0) { if (row < halfway) { - checkval255(r); checkval255(g); checkval255(b); + CHECKVAL255(r); CHECKVAL255(g); CHECKVAL255(b); } else { - checkval0(r); checkval0(g); checkval0(b); + CHECKVAL0(r); CHECKVAL0(g); CHECKVAL0(b); } } else { if (subsamp == TJSAMP_GRAY) { if (row < halfway) { - checkval(r, 76); checkval(g, 76); checkval(b, 76); + CHECKVAL(r, 76); CHECKVAL(g, 76); CHECKVAL(b, 76); } else { - checkval(r, 226); checkval(g, 226); checkval(b, 226); + CHECKVAL(r, 226); CHECKVAL(g, 226); CHECKVAL(b, 226); } } else { if (row < halfway) { - checkval255(r); checkval0(g); checkval0(b); + CHECKVAL255(r); CHECKVAL0(g); CHECKVAL0(b); } else { - checkval255(r); checkval255(g); checkval0(b); + CHECKVAL255(r); CHECKVAL255(g); CHECKVAL0(b); } } } - checkval255(a); + CHECKVAL255(a); } } @@ -263,7 +263,8 @@ bailout: buf[(row * w + col) * ps + 1], buf[(row * w + col) * ps + 2], buf[(row * w + col) * ps + 3]); else - fprintf(stderr, "%.3d/%.3d/%.3d ", buf[(row * w + col) * ps + roffset], + fprintf(stderr, "%.3d/%.3d/%.3d ", + buf[(row * w + col) * ps + roffset], buf[(row * w + col) * ps + goffset], buf[(row * w + col) * ps + boffset]); } @@ -293,16 +294,16 @@ static int checkBufYUV(unsigned char *buf, int w, int h, int subsamp, unsigned char y = buf[ypitch * row + col]; if (((row / blocksize) + (col / blocksize)) % 2 == 0) { - if (row < halfway) checkval255(y) - else checkval0(y); + if (row < halfway) CHECKVAL255(y) + else CHECKVAL0(y); } else { - if (row < halfway) checkval(y, 76) - else checkval(y, 226); + if (row < halfway) CHECKVAL(y, 76) + else CHECKVAL(y, 226); } } } if (subsamp != TJSAMP_GRAY) { - int halfway = 16 / vsf * sf.num / sf.denom; + halfway = 16 / vsf * sf.num / sf.denom; for (row = 0; row < ch; row++) { for (col = 0; col < cw; col++) { @@ -310,12 +311,12 @@ static int checkBufYUV(unsigned char *buf, int w, int h, int subsamp, v = buf[ypitch * ph + uvpitch * ch + (uvpitch * row + col)]; if (((row * vsf / blocksize) + (col * hsf / blocksize)) % 2 == 0) { - checkval(u, 128); checkval(v, 128); + CHECKVAL(u, 128); CHECKVAL(v, 128); } else { if (row < halfway) { - checkval(u, 85); checkval255(v); + CHECKVAL(u, 85); CHECKVAL255(v); } else { - checkval0(u); checkval(v, 149); + CHECKVAL0(u); CHECKVAL(v, 149); } } } @@ -361,7 +362,7 @@ static void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize, if (!file || fwrite(jpegBuf, jpegSize, 1, file) != 1) { fprintf(stderr, "ERROR: Could not write to %s.\n%s\n", filename, strerror(errno)); - bailout() + BAILOUT() } bailout: @@ -381,7 +382,7 @@ static void compTest(tjhandle handle, unsigned char **dstBuf, const char *buStr = (flags & TJFLAG_BOTTOMUP) ? "BU" : "TD"; if ((srcBuf = (unsigned char *)malloc(w * h * tjPixelSize[pf])) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); initBuf(srcBuf, w, h, pf, flags); if (*dstBuf && *dstSize > 0) memset(*dstBuf, 0, *dstSize); @@ -392,39 +393,39 @@ static void compTest(tjhandle handle, unsigned char **dstBuf, tjscalingfactor sf = { 1, 1 }; tjhandle handle2 = tjInitCompress(); - if (!handle2) _throwtj(); + if (!handle2) THROW_TJ(); if ((yuvBuf = (unsigned char *)malloc(yuvSize)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); memset(yuvBuf, 0, yuvSize); fprintf(stderr, "%s %s -> YUV %s ... ", pfStr, buStrLong, subNameLong[subsamp]); - _tj(tjEncodeYUV3(handle2, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, - flags)); + TRY_TJ(tjEncodeYUV3(handle2, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp, + flags)); tjDestroy(handle2); if (checkBufYUV(yuvBuf, w, h, subsamp, sf)) fprintf(stderr, "Passed.\n"); else fprintf(stderr, "FAILED!\n"); - fprintf(stderr, "YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp], buStrLong, - jpegQual); - _tj(tjCompressFromYUV(handle, yuvBuf, w, pad, h, subsamp, dstBuf, dstSize, - jpegQual, flags)); + fprintf(stderr, "YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp], + buStrLong, jpegQual); + TRY_TJ(tjCompressFromYUV(handle, yuvBuf, w, pad, h, subsamp, dstBuf, + dstSize, jpegQual, flags)); } else { fprintf(stderr, "%s %s -> %s Q%d ... ", pfStr, buStrLong, subNameLong[subsamp], jpegQual); - _tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp, - jpegQual, flags)); + TRY_TJ(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp, + jpegQual, flags)); } - snprintf(tempStr, filePathSize, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pfStr, buStr, - subName[subsamp], jpegQual); + snprintf(tempStr, filePathSize, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pfStr, + buStr, subName[subsamp], jpegQual); writeJPEG(*dstBuf, *dstSize, tempStr); fprintf(stderr, "Done.\n Result in %s\n", tempStr); bailout: - if (yuvBuf) free(yuvBuf); - if (srcBuf) free(srcBuf); + free(yuvBuf); + free(srcBuf); } @@ -439,14 +440,14 @@ static void _decompTest(tjhandle handle, unsigned char *jpegBuf, int scaledHeight = TJSCALED(h, sf); unsigned long dstSize = 0; - _tj(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh, - &_hdrsubsamp)); + TRY_TJ(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh, + &_hdrsubsamp)); if (_hdrw != w || _hdrh != h || _hdrsubsamp != subsamp) - _throw("Incorrect JPEG header"); + THROW("Incorrect JPEG header"); dstSize = scaledWidth * scaledHeight * tjPixelSize[pf]; if ((dstBuf = (unsigned char *)malloc(dstSize)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); memset(dstBuf, 0, dstSize); if (doYUV) { @@ -454,18 +455,18 @@ static void _decompTest(tjhandle handle, unsigned char *jpegBuf, subsamp); tjhandle handle2 = tjInitDecompress(); - if (!handle2) _throwtj(); + if (!handle2) THROW_TJ(); if ((yuvBuf = (unsigned char *)malloc(yuvSize)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); memset(yuvBuf, 0, yuvSize); fprintf(stderr, "JPEG -> YUV %s ", subNameLong[subsamp]); if (sf.num != 1 || sf.denom != 1) fprintf(stderr, "%d/%d ... ", sf.num, sf.denom); else fprintf(stderr, "... "); - _tj(tjDecompressToYUV2(handle, jpegBuf, jpegSize, yuvBuf, scaledWidth, pad, - scaledHeight, flags)); + TRY_TJ(tjDecompressToYUV2(handle, jpegBuf, jpegSize, yuvBuf, scaledWidth, + pad, scaledHeight, flags)); if (checkBufYUV(yuvBuf, scaledWidth, scaledHeight, subsamp, sf)) fprintf(stderr, "Passed.\n"); else fprintf(stderr, "FAILED!\n"); @@ -473,8 +474,8 @@ static void _decompTest(tjhandle handle, unsigned char *jpegBuf, fprintf(stderr, "YUV %s -> %s %s ... ", subNameLong[subsamp], pixFormatStr[pf], (flags & TJFLAG_BOTTOMUP) ? "Bottom-Up" : "Top-Down "); - _tj(tjDecodeYUV(handle2, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0, - scaledHeight, pf, flags)); + TRY_TJ(tjDecodeYUV(handle2, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0, + scaledHeight, pf, flags)); tjDestroy(handle2); } else { fprintf(stderr, "JPEG -> %s %s ", pixFormatStr[pf], @@ -482,8 +483,8 @@ static void _decompTest(tjhandle handle, unsigned char *jpegBuf, if (sf.num != 1 || sf.denom != 1) fprintf(stderr, "%d/%d ... ", sf.num, sf.denom); else fprintf(stderr, "... "); - _tj(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0, - scaledHeight, pf, flags)); + TRY_TJ(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0, + scaledHeight, pf, flags)); } if (checkBuf(dstBuf, scaledWidth, scaledHeight, pf, subsamp, sf, flags)) @@ -492,8 +493,8 @@ static void _decompTest(tjhandle handle, unsigned char *jpegBuf, fprintf(stderr, "\n"); bailout: - if (yuvBuf) free(yuvBuf); - if (dstBuf) free(dstBuf); + free(yuvBuf); + free(dstBuf); } @@ -504,7 +505,7 @@ static void decompTest(tjhandle handle, unsigned char *jpegBuf, int i, n = 0; tjscalingfactor *sf = tjGetScalingFactors(&n); - if (!sf || !n) _throwtj(); + if (!sf || !n) THROW_TJ(); for (i = 0; i < n; i++) { if (subsamp == TJSAMP_444 || subsamp == TJSAMP_GRAY || @@ -533,11 +534,11 @@ static void doTest(int w, int h, const int *formats, int nformats, int subsamp, size = tjBufSize(w, h, subsamp); if (size != 0) if ((dstBuf = (unsigned char *)tjAlloc(size)) == NULL) - _throw("Memory allocation failure."); + THROW("Memory allocation failure."); if ((chandle = tjInitCompress()) == NULL || (dhandle = tjInitDecompress()) == NULL) - _throwtj(); + THROW_TJ(); for (pfi = 0; pfi < nformats; pfi++) { for (i = 0; i < 2; i++) { @@ -564,10 +565,48 @@ static void doTest(int w, int h, const int *formats, int nformats, int subsamp, bailout: if (chandle) tjDestroy(chandle); if (dhandle) tjDestroy(dhandle); - if (dstBuf) tjFree(dstBuf); + tjFree(dstBuf); } +#if SIZEOF_SIZE_T == 8 +#define CHECKSIZE(function) { \ + if ((unsigned long long)size < (unsigned long long)0xFFFFFFFF) \ + THROW(#function " overflow"); \ +} +#else +#define CHECKSIZE(function) { \ + if (size != (unsigned long)(-1) || \ + !strcmp(tjGetErrorStr2(NULL), "No error")) \ + THROW(#function " overflow"); \ +} +#endif + +#ifndef GTEST +static void overflowTest(void) +{ + /* Ensure that the various buffer size functions don't overflow */ + unsigned long size; + + size = tjBufSize(26755, 26755, TJSAMP_444); + CHECKSIZE(tjBufSize()); + size = TJBUFSIZE(26755, 26755); + CHECKSIZE(TJBUFSIZE()); + size = tjBufSizeYUV2(37838, 1, 37838, TJSAMP_444); + CHECKSIZE(tjBufSizeYUV2()); + size = TJBUFSIZEYUV(37838, 37838, TJSAMP_444); + CHECKSIZE(TJBUFSIZEYUV()); + size = tjBufSizeYUV(37838, 37838, TJSAMP_444); + CHECKSIZE(tjBufSizeYUV()); + size = tjPlaneSizeYUV(0, 65536, 0, 65536, TJSAMP_444); + CHECKSIZE(tjPlaneSizeYUV()); + +bailout: + return; +} +#endif + + static void bufSizeTest(void) { int w, h, i, subsamp; @@ -575,7 +614,7 @@ static void bufSizeTest(void) tjhandle handle = NULL; unsigned long dstSize = 0; - if ((handle = tjInitCompress()) == NULL) _throwtj(); + if ((handle = tjInitCompress()) == NULL) THROW_TJ(); fprintf(stderr, "Buffer size regression test\n"); for (subsamp = 0; subsamp < TJ_NUMSAMP; subsamp++) { @@ -586,12 +625,12 @@ static void bufSizeTest(void) if (h % 100 == 0) fprintf(stderr, "%.4d x %.4d\b\b\b\b\b\b\b\b\b\b\b", w, h); if ((srcBuf = (unsigned char *)malloc(w * h * 4)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); if (!alloc || doYUV) { if (doYUV) dstSize = tjBufSizeYUV2(w, pad, h, subsamp); else dstSize = tjBufSize(w, h, subsamp); if ((dstBuf = (unsigned char *)tjAlloc(dstSize)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); } for (i = 0; i < w * h * 4; i++) { @@ -600,12 +639,12 @@ static void bufSizeTest(void) } if (doYUV) { - _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, TJPF_BGRX, dstBuf, pad, - subsamp, 0)); + TRY_TJ(tjEncodeYUV3(handle, srcBuf, w, 0, h, TJPF_BGRX, dstBuf, pad, + subsamp, 0)); } else { - _tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_BGRX, &dstBuf, - &dstSize, subsamp, 100, - alloc ? 0 : TJFLAG_NOREALLOC)); + TRY_TJ(tjCompress2(handle, srcBuf, w, 0, h, TJPF_BGRX, &dstBuf, + &dstSize, subsamp, 100, + alloc ? 0 : TJFLAG_NOREALLOC)); } free(srcBuf); srcBuf = NULL; if (!alloc || doYUV) { @@ -613,12 +652,12 @@ static void bufSizeTest(void) } if ((srcBuf = (unsigned char *)malloc(h * w * 4)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); if (!alloc || doYUV) { if (doYUV) dstSize = tjBufSizeYUV2(h, pad, w, subsamp); else dstSize = tjBufSize(h, w, subsamp); if ((dstBuf = (unsigned char *)tjAlloc(dstSize)) == NULL) - _throw("Memory allocation failure"); + THROW("Memory allocation failure"); } for (i = 0; i < h * w * 4; i++) { @@ -627,12 +666,12 @@ static void bufSizeTest(void) } if (doYUV) { - _tj(tjEncodeYUV3(handle, srcBuf, h, 0, w, TJPF_BGRX, dstBuf, pad, - subsamp, 0)); + TRY_TJ(tjEncodeYUV3(handle, srcBuf, h, 0, w, TJPF_BGRX, dstBuf, pad, + subsamp, 0)); } else { - _tj(tjCompress2(handle, srcBuf, h, 0, w, TJPF_BGRX, &dstBuf, - &dstSize, subsamp, 100, - alloc ? 0 : TJFLAG_NOREALLOC)); + TRY_TJ(tjCompress2(handle, srcBuf, h, 0, w, TJPF_BGRX, &dstBuf, + &dstSize, subsamp, 100, + alloc ? 0 : TJFLAG_NOREALLOC)); } free(srcBuf); srcBuf = NULL; if (!alloc || doYUV) { @@ -644,8 +683,8 @@ static void bufSizeTest(void) fprintf(stderr, "Done. \n"); bailout: - if (srcBuf) free(srcBuf); - if (dstBuf) tjFree(dstBuf); + free(srcBuf); + tjFree(dstBuf); if (handle) tjDestroy(handle); } @@ -754,25 +793,26 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, } if ((buf = (unsigned char *)tjAlloc(pitch * height)) == NULL) - _throw("Could not allocate memory"); + THROW("Could not allocate memory"); initBitmap(buf, width, pitch, height, pf, flags); #if defined(ANDROID) && defined(GTEST) - snprintf(filename, filenameSize, "/sdcard/test_bmp_%s_%d_%s.%s", pixFormatStr[pf], - align, (flags & TJFLAG_BOTTOMUP) ? "bu" : "td", ext); + snprintf(filename, filenameSize, "/sdcard/test_bmp_%s_%d_%s.%s", + pixFormatStr[pf], align, (flags & TJFLAG_BOTTOMUP) ? "bu" : "td", + ext); #else - snprintf(filename, filenameSize, "test_bmp_%s_%d_%s.%s", pixFormatStr[pf], align, - (flags & TJFLAG_BOTTOMUP) ? "bu" : "td", ext); + snprintf(filename, filenameSize, "test_bmp_%s_%d_%s.%s", pixFormatStr[pf], + align, (flags & TJFLAG_BOTTOMUP) ? "bu" : "td", ext); #endif - _tj(tjSaveImage(filename, buf, width, pitch, height, pf, flags)); + TRY_TJ(tjSaveImage(filename, buf, width, pitch, height, pf, flags)); md5sum = MD5File(filename, md5buf); if (strcasecmp(md5sum, md5ref)) - _throwmd5(filename, md5sum, md5ref); + THROW_MD5(filename, md5sum, md5ref); tjFree(buf); buf = NULL; if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf, flags)) == NULL) - _throwtj(); + THROW_TJ(); if (width != loadWidth || height != loadHeight) { fprintf(stderr, "\n Image dimensions of %s are bogus\n", filename); retval = -1; goto bailout; @@ -786,7 +826,7 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, pf = TJPF_XBGR; if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf, flags)) == NULL) - _throwtj(); + THROW_TJ(); pitch = PAD(width * tjPixelSize[pf], align); if (!cmpBitmap(buf, width, pitch, height, pf, flags, 1)) { fprintf(stderr, "\n Converting %s to RGB failed\n", filename); @@ -797,7 +837,7 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, pf = TJPF_CMYK; if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf, flags)) == NULL) - _throwtj(); + THROW_TJ(); pitch = PAD(width * tjPixelSize[pf], align); if (!cmpBitmap(buf, width, pitch, height, pf, flags, 1)) { fprintf(stderr, "\n Converting %s to CMYK failed\n", filename); @@ -811,7 +851,7 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, pixelFormat = TJPF_UNKNOWN; if ((buf = tjLoadImage(filename, &loadWidth, align, &loadHeight, &pixelFormat, flags)) == NULL) - _throwtj(); + THROW_TJ(); if ((pf == TJPF_GRAY && pixelFormat != TJPF_GRAY) || (pf != TJPF_GRAY && !strcasecmp(ext, "bmp") && pixelFormat != TJPF_BGR) || @@ -825,7 +865,7 @@ static int doBmpTest(const char *ext, int width, int align, int height, int pf, unlink(filename); bailout: - if (buf) tjFree(buf); + tjFree(buf); if (exitStatus < 0) return exitStatus; return retval; } @@ -868,6 +908,7 @@ static int bmpTest(void) return 0; } + #ifdef GTEST static void initTJUnitTest(int yuv, int noyuvpad, int autoalloc) { @@ -1100,6 +1141,7 @@ int main(int argc, char *argv[]) } if (alloc) printf("Testing automatic buffer allocation\n"); if (doYUV) num4bf = 4; + overflowTest(); doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test"); doTest(39, 41, _4byteFormats, num4bf, TJSAMP_444, "test"); doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test"); |