diff options
author | noel@chromium.org <noel@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c> | 2014-04-14 06:56:00 +0000 |
---|---|---|
committer | noel@chromium.org <noel@chromium.org@4ff67af0-8c30-449e-8e8b-ad334ec8d88c> | 2014-04-14 06:56:00 +0000 |
commit | 3395bcc26e390d2960d15020d4a4d27ae0c122fe (patch) | |
tree | 70d532ca62c1eb0b3c8d44f818dc304a9a2a80ae /tjunittest.c | |
parent | 24cafe92b7a98c36a8062e1ac2fef9832588ac85 (diff) |
Upgrade libjpeg_turbo to 1.3.1 (r1219)
Remove google.jdmarker.patch, since the fixes for CVE-2013-6629
and CVE-2013-6630 are upstream most everywhere now [1]. Version
number to 1.3.1 (config.h, jconfig.h).
README.chromium: "Fixed valgrind error" patch was upstreamed in
r839 http://sourceforge.net/p/libjpeg-turbo/code/839. The r1188
cherry-pick was put in config.h, say that.
[1] http://seclists.org/fulldisclosure/2013/Nov/83
TBR=darin@chromium.org
BUG=258723, 299835
Review URL: https://codereview.appspot.com/87110044
git-svn-id: http://src.chromium.org/svn/trunk/deps/third_party/libjpeg_turbo@263594 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
Diffstat (limited to 'tjunittest.c')
-rw-r--r-- | tjunittest.c | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/tjunittest.c b/tjunittest.c index 89a6d1d..3bb194d 100644 --- a/tjunittest.c +++ b/tjunittest.c @@ -1,5 +1,5 @@ /* - * Copyright (C)2009-2012 D. R. Commander. All Rights Reserved. + * Copyright (C)2009-2012, 2014 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: @@ -219,7 +219,6 @@ int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp, bailout: if(retval==0) { - printf("\n"); for(row=0; row<h; row++) { for(col=0; col<w; col++) @@ -312,7 +311,6 @@ int checkBufYUV(unsigned char *buf, int w, int h, int subsamp) printf("%.3d ", buf[ypitch*ph + uvpitch*ch + (uvpitch*row+col)]); printf("\n"); } - printf("\n"); } return retval; @@ -405,7 +403,7 @@ void _decompTest(tjhandle handle, unsigned char *jpegBuf, if(yuv==YUVENCODE) return; if(yuv==YUVDECODE) - printf("JPEG -> YUV %s ... ", subName[subsamp]); + printf("JPEG -> YUV %s ... ", subNameLong[subsamp]); else { printf("JPEG -> %s %s ", pixFormatStr[pf], @@ -475,7 +473,7 @@ void decompTest(tjhandle handle, unsigned char *jpegBuf, sf1); bailout: - printf("\n"); + return; } @@ -515,10 +513,15 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, decompTest(dhandle, dstBuf, size, w, h, pf, basename, subsamp, flags); if(pf>=TJPF_RGBX && pf<=TJPF_XRGB) + { + printf("\n"); decompTest(dhandle, dstBuf, size, w, h, pf+(TJPF_RGBA-TJPF_RGBX), basename, subsamp, flags); + } + printf("\n"); } } + printf("--------------------\n\n"); bailout: if(chandle) tjDestroy(chandle); @@ -531,9 +534,9 @@ void doTest(int w, int h, const int *formats, int nformats, int subsamp, void bufSizeTest(void) { int w, h, i, subsamp; - unsigned char *srcBuf=NULL, *jpegBuf=NULL; + unsigned char *srcBuf=NULL, *dstBuf=NULL; tjhandle handle=NULL; - unsigned long jpegSize=0; + unsigned long dstSize=0; if((handle=tjInitCompress())==NULL) _throwtj(); @@ -548,12 +551,12 @@ void bufSizeTest(void) if(h%100==0) printf("%.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"); - if(!alloc) + if(!alloc || yuv==YUVENCODE) { - if((jpegBuf=(unsigned char *)tjAlloc(tjBufSize(w, h, subsamp))) - ==NULL) + if(yuv==YUVENCODE) dstSize=tjBufSizeYUV(w, h, subsamp); + else dstSize=tjBufSize(w, h, subsamp); + if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL) _throw("Memory allocation failure"); - jpegSize=tjBufSize(w, h, subsamp); } for(i=0; i<w*h*4; i++) @@ -562,19 +565,27 @@ void bufSizeTest(void) else srcBuf[i]=255; } - _tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_BGRX, &jpegBuf, - &jpegSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC)); + if(yuv==YUVENCODE) + { + _tj(tjEncodeYUV2(handle, srcBuf, w, 0, h, TJPF_BGRX, dstBuf, subsamp, + 0)); + } + else + { + _tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_BGRX, &dstBuf, + &dstSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC)); + } free(srcBuf); srcBuf=NULL; - tjFree(jpegBuf); jpegBuf=NULL; + tjFree(dstBuf); dstBuf=NULL; if((srcBuf=(unsigned char *)malloc(h*w*4))==NULL) _throw("Memory allocation failure"); - if(!alloc) + if(!alloc || yuv==YUVENCODE) { - if((jpegBuf=(unsigned char *)tjAlloc(tjBufSize(h, w, subsamp))) - ==NULL) + if(yuv==YUVENCODE) dstSize=tjBufSizeYUV(h, w, subsamp); + else dstSize=tjBufSize(h, w, subsamp); + if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL) _throw("Memory allocation failure"); - jpegSize=tjBufSize(h, w, subsamp); } for(i=0; i<h*w*4; i++) @@ -583,10 +594,18 @@ void bufSizeTest(void) else srcBuf[i]=255; } - _tj(tjCompress2(handle, srcBuf, h, 0, w, TJPF_BGRX, &jpegBuf, - &jpegSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC)); + if(yuv==YUVENCODE) + { + _tj(tjEncodeYUV2(handle, srcBuf, h, 0, w, TJPF_BGRX, dstBuf, subsamp, + 0)); + } + else + { + _tj(tjCompress2(handle, srcBuf, h, 0, w, TJPF_BGRX, &dstBuf, + &dstSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC)); + } free(srcBuf); srcBuf=NULL; - tjFree(jpegBuf); jpegBuf=NULL; + tjFree(dstBuf); dstBuf=NULL; } } } @@ -594,7 +613,7 @@ void bufSizeTest(void) bailout: if(srcBuf) free(srcBuf); - if(jpegBuf) free(jpegBuf); + if(dstBuf) free(dstBuf); if(handle) tjDestroy(handle); } @@ -628,9 +647,10 @@ int main(int argc, char *argv[]) doTest(35, 39, _onlyGray, 1, TJSAMP_GRAY, "test"); doTest(39, 41, _3byteFormats, 2, TJSAMP_GRAY, "test"); doTest(41, 35, _4byteFormats, 4, TJSAMP_GRAY, "test"); - if(!doyuv) bufSizeTest(); + bufSizeTest(); if(doyuv) { + printf("\n--------------------\n\n"); yuv=YUVDECODE; doTest(48, 48, _onlyRGB, 1, TJSAMP_444, "test_yuv0"); doTest(35, 39, _onlyRGB, 1, TJSAMP_444, "test_yuv1"); |