aboutsummaryrefslogtreecommitdiff
path: root/tjunittest.c
diff options
context:
space:
mode:
authordcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2013-05-07 21:17:35 +0000
committerdcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2013-05-07 21:17:35 +0000
commit6f6a8d9757b784a6e10e0ed4d52737c707a7c7c4 (patch)
tree7f1296535e76fc3d843c99d40b877d0e5c943692 /tjunittest.c
parent1e0687100ad904c2c6d2ca717a5dbcb767367ea5 (diff)
Fix incorrect data output and buffer overruns in the new tjDecompressToYUV2() function whenever scaling is used along with a 4:2:0 JPEG image; extend tjunittest and TJUnitTest to test for these issues.
git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@982 632fc199-4ca6-4c93-a231-07263d6284db
Diffstat (limited to 'tjunittest.c')
-rw-r--r--tjunittest.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/tjunittest.c b/tjunittest.c
index 85ba32e..c14c7d3 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -366,7 +366,7 @@ void compTest(tjhandle handle, unsigned char **dstBuf,
if(!alloc)
{
flags|=TJFLAG_NOREALLOC;
- *dstSize=(yuv==YUVENCODE? tjBufSizeYUV(w, h, subsamp)
+ *dstSize=(yuv==YUVENCODE? tjBufSizeYUV2(w, pad, h, subsamp)
: tjBufSize(w, h, subsamp));
}
_tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp,
@@ -466,18 +466,16 @@ void decompTest(tjhandle handle, unsigned char *jpegBuf,
int flags)
{
int i, n=0;
- tjscalingfactor *sf=tjGetScalingFactors(&n), sf1={1, 1};
+ tjscalingfactor *sf=tjGetScalingFactors(&n);
if(!sf || !n) _throwtj();
- if(subsamp==TJSAMP_444 || subsamp==TJSAMP_GRAY)
+ for(i=0; i<n; i++)
{
- for(i=0; i<n; i++)
+ if(subsamp==TJSAMP_444 || subsamp==TJSAMP_GRAY ||
+ (sf[i].num==1 && (sf[i].denom==4 || sf[i].denom==2 || sf[i].denom==1)))
_decompTest(handle, jpegBuf, jpegSize, w, h, pf, basename, subsamp,
flags, sf[i]);
}
- else
- _decompTest(handle, jpegBuf, jpegSize, w, h, pf, basename, subsamp, flags,
- sf1);
bailout:
return;