blob: ffe6fc707216ef638ca8c36cf511a29bcf65d843 [file] [log] [blame]
DRCb8b359a2011-05-25 03:54:56 +00001/*
DRCf3ad13e2017-11-13 16:00:35 -06002 * Copyright (C)2009-2014, 2017 D. R. Commander. All Rights Reserved.
DRCb8b359a2011-05-25 03:54:56 +00003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * - Redistributions of source code must retain the above copyright notice,
8 * this list of conditions and the following disclaimer.
9 * - Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
12 * - Neither the name of the libjpeg-turbo Project nor the names of its
13 * contributors may be used to endorse or promote products derived from this
14 * software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS",
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/*
DRCc52c5562011-06-15 02:43:42 +000030 * This program tests the various code paths in the TurboJPEG C Wrapper
DRCb8b359a2011-05-25 03:54:56 +000031 */
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include <errno.h>
DRCaa745902017-11-16 18:09:07 -060037#include "tjutil.h"
38#include "turbojpeg.h"
39#include "md5/md5.h"
40#include "cmyk.h"
DRCe835ee32011-07-15 10:06:56 +000041#ifdef _WIN32
42 #include <time.h>
43 #define random() rand()
DRCaa745902017-11-16 18:09:07 -060044#else
45 #include <unistd.h>
DRCe835ee32011-07-15 10:06:56 +000046#endif
DRCb8b359a2011-05-25 03:54:56 +000047
48
49void usage(char *progName)
50{
DRC5426a4c2017-09-02 04:08:06 +000051 printf("\nUSAGE: %s [options]\n\n", progName);
DRCb8b359a2011-05-25 03:54:56 +000052 printf("Options:\n");
53 printf("-yuv = test YUV encoding/decoding support\n");
DRCf610d612013-04-26 10:33:29 +000054 printf("-noyuvpad = do not pad each line of each Y, U, and V plane to the nearest\n");
DRCfef98522013-04-28 01:32:52 +000055 printf(" 4-byte boundary\n");
DRCaa745902017-11-16 18:09:07 -060056 printf("-alloc = test automatic buffer allocation\n");
57 printf("-bmp = tjLoadImage()/tjSaveImage() unit test\n\n");
DRCb8b359a2011-05-25 03:54:56 +000058 exit(1);
59}
60
61
62#define _throwtj() {printf("TurboJPEG ERROR:\n%s\n", tjGetErrorStr()); \
63 bailout();}
64#define _tj(f) {if((f)==-1) _throwtj();}
65#define _throw(m) {printf("ERROR: %s\n", m); bailout();}
DRCaa745902017-11-16 18:09:07 -060066#define _throwmd5(filename, md5sum, ref) { \
67 printf("\n%s has an MD5 sum of %s.\n Should be %s.\n", filename, \
68 md5sum, ref); \
69 bailout(); \
70}
71
72#define RGB2GRAY(r, g, b) \
73 (unsigned char)((double)(r)*0.299+(double)(g)*0.587+(double)(b)*0.114+0.5)
DRCb8b359a2011-05-25 03:54:56 +000074
75const char *subNameLong[TJ_NUMSAMP]=
76{
DRC1f3635c2013-08-18 10:19:00 +000077 "4:4:4", "4:2:2", "4:2:0", "GRAY", "4:4:0", "4:1:1"
DRCb8b359a2011-05-25 03:54:56 +000078};
DRC1f3635c2013-08-18 10:19:00 +000079const char *subName[TJ_NUMSAMP]={"444", "422", "420", "GRAY", "440", "411"};
DRCb8b359a2011-05-25 03:54:56 +000080
81const char *pixFormatStr[TJ_NUMPF]=
82{
DRC67ce3b22011-12-19 02:21:03 +000083 "RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale",
DRCcd7c3e62013-08-23 02:49:25 +000084 "RGBA", "BGRA", "ABGR", "ARGB", "CMYK"
DRCb8b359a2011-05-25 03:54:56 +000085};
86
DRCcd7c3e62013-08-23 02:49:25 +000087const int alphaOffset[TJ_NUMPF] = {-1, -1, -1, -1, -1, -1, -1, 3, 3, 0, 0, -1};
DRCc08e8c12011-09-08 23:54:40 +000088
DRCb8b359a2011-05-25 03:54:56 +000089const int _3byteFormats[]={TJPF_RGB, TJPF_BGR};
DRCcd7c3e62013-08-23 02:49:25 +000090const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB,
91 TJPF_CMYK};
DRCb8b359a2011-05-25 03:54:56 +000092const int _onlyGray[]={TJPF_GRAY};
93const int _onlyRGB[]={TJPF_RGB};
94
DRC34dca052014-02-28 09:17:14 +000095int doyuv=0, alloc=0, pad=4;
DRCb8b359a2011-05-25 03:54:56 +000096
97int exitStatus=0;
98#define bailout() {exitStatus=-1; goto bailout;}
99
DRCb8b359a2011-05-25 03:54:56 +0000100
101void initBuf(unsigned char *buf, int w, int h, int pf, int flags)
102{
103 int roffset=tjRedOffset[pf];
104 int goffset=tjGreenOffset[pf];
105 int boffset=tjBlueOffset[pf];
106 int ps=tjPixelSize[pf];
107 int index, row, col, halfway=16;
108
DRCb8b359a2011-05-25 03:54:56 +0000109 if(pf==TJPF_GRAY)
110 {
DRCcd7c3e62013-08-23 02:49:25 +0000111 memset(buf, 0, w*h*ps);
DRCb8b359a2011-05-25 03:54:56 +0000112 for(row=0; row<h; row++)
113 {
114 for(col=0; col<w; col++)
115 {
116 if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
117 else index=row*w+col;
118 if(((row/8)+(col/8))%2==0) buf[index]=(row<halfway)? 255:0;
119 else buf[index]=(row<halfway)? 76:226;
120 }
121 }
122 }
DRCcd7c3e62013-08-23 02:49:25 +0000123 else if(pf==TJPF_CMYK)
124 {
125 memset(buf, 255, w*h*ps);
126 for(row=0; row<h; row++)
127 {
128 for(col=0; col<w; col++)
129 {
130 if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
131 else index=row*w+col;
132 if(((row/8)+(col/8))%2==0)
133 {
134 if(row>=halfway) buf[index*ps+3]=0;
135 }
136 else
137 {
138 buf[index*ps+2]=0;
139 if(row<halfway) buf[index*ps+1]=0;
140 }
141 }
142 }
143 }
DRCb8b359a2011-05-25 03:54:56 +0000144 else
145 {
DRCcd7c3e62013-08-23 02:49:25 +0000146 memset(buf, 0, w*h*ps);
DRCb8b359a2011-05-25 03:54:56 +0000147 for(row=0; row<h; row++)
148 {
149 for(col=0; col<w; col++)
150 {
151 if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
152 else index=row*w+col;
153 if(((row/8)+(col/8))%2==0)
154 {
155 if(row<halfway)
156 {
157 buf[index*ps+roffset]=255;
158 buf[index*ps+goffset]=255;
159 buf[index*ps+boffset]=255;
160 }
161 }
162 else
163 {
164 buf[index*ps+roffset]=255;
165 if(row>=halfway) buf[index*ps+goffset]=255;
166 }
167 }
168 }
169 }
170}
171
172
173#define checkval(v, cv) { \
174 if(v<cv-1 || v>cv+1) { \
175 printf("\nComp. %s at %d,%d should be %d, not %d\n", \
176 #v, row, col, cv, v); \
177 retval=0; exitStatus=-1; goto bailout; \
178 }}
179
180#define checkval0(v) { \
181 if(v>1) { \
182 printf("\nComp. %s at %d,%d should be 0, not %d\n", #v, row, col, v); \
183 retval=0; exitStatus=-1; goto bailout; \
184 }}
185
186#define checkval255(v) { \
187 if(v<254) { \
188 printf("\nComp. %s at %d,%d should be 255, not %d\n", #v, row, col, v); \
189 retval=0; exitStatus=-1; goto bailout; \
190 }}
191
192
193int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
194 tjscalingfactor sf, int flags)
195{
196 int roffset=tjRedOffset[pf];
197 int goffset=tjGreenOffset[pf];
198 int boffset=tjBlueOffset[pf];
DRCc08e8c12011-09-08 23:54:40 +0000199 int aoffset=alphaOffset[pf];
DRCb8b359a2011-05-25 03:54:56 +0000200 int ps=tjPixelSize[pf];
201 int index, row, col, retval=1;
202 int halfway=16*sf.num/sf.denom;
203 int blocksize=8*sf.num/sf.denom;
204
DRCcd7c3e62013-08-23 02:49:25 +0000205 if(pf==TJPF_CMYK)
206 {
207 for(row=0; row<h; row++)
208 {
209 for(col=0; col<w; col++)
210 {
211 unsigned char c, m, y, k;
212 if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
213 else index=row*w+col;
214 c=buf[index*ps];
215 m=buf[index*ps+1];
216 y=buf[index*ps+2];
217 k=buf[index*ps+3];
218 if(((row/blocksize)+(col/blocksize))%2==0)
219 {
220 checkval255(c); checkval255(m); checkval255(y);
221 if(row<halfway) checkval255(k)
222 else checkval0(k)
223 }
224 else
225 {
226 checkval255(c); checkval0(y); checkval255(k);
227 if(row<halfway) checkval0(m)
228 else checkval255(m)
229 }
230 }
231 }
232 return 1;
233 }
234
DRCb8b359a2011-05-25 03:54:56 +0000235 for(row=0; row<h; row++)
236 {
237 for(col=0; col<w; col++)
238 {
DRCc08e8c12011-09-08 23:54:40 +0000239 unsigned char r, g, b, a;
DRCb8b359a2011-05-25 03:54:56 +0000240 if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
241 else index=row*w+col;
242 r=buf[index*ps+roffset];
243 g=buf[index*ps+goffset];
244 b=buf[index*ps+boffset];
DRCc08e8c12011-09-08 23:54:40 +0000245 a=aoffset>=0? buf[index*ps+aoffset]:0xFF;
DRCb8b359a2011-05-25 03:54:56 +0000246 if(((row/blocksize)+(col/blocksize))%2==0)
247 {
248 if(row<halfway)
249 {
250 checkval255(r); checkval255(g); checkval255(b);
251 }
252 else
253 {
254 checkval0(r); checkval0(g); checkval0(b);
255 }
256 }
257 else
258 {
259 if(subsamp==TJSAMP_GRAY)
260 {
261 if(row<halfway)
262 {
263 checkval(r, 76); checkval(g, 76); checkval(b, 76);
264 }
265 else
266 {
267 checkval(r, 226); checkval(g, 226); checkval(b, 226);
268 }
269 }
270 else
271 {
272 if(row<halfway)
273 {
274 checkval255(r); checkval0(g); checkval0(b);
275 }
276 else
277 {
278 checkval255(r); checkval255(g); checkval0(b);
279 }
280 }
281 }
DRCc08e8c12011-09-08 23:54:40 +0000282 checkval255(a);
DRCb8b359a2011-05-25 03:54:56 +0000283 }
284 }
285
286 bailout:
287 if(retval==0)
288 {
DRCb8b359a2011-05-25 03:54:56 +0000289 for(row=0; row<h; row++)
290 {
291 for(col=0; col<w; col++)
292 {
DRCcd7c3e62013-08-23 02:49:25 +0000293 if(pf==TJPF_CMYK)
294 printf("%.3d/%.3d/%.3d/%.3d ", buf[(row*w+col)*ps],
295 buf[(row*w+col)*ps+1], buf[(row*w+col)*ps+2],
296 buf[(row*w+col)*ps+3]);
297 else
298 printf("%.3d/%.3d/%.3d ", buf[(row*w+col)*ps+roffset],
299 buf[(row*w+col)*ps+goffset], buf[(row*w+col)*ps+boffset]);
DRCb8b359a2011-05-25 03:54:56 +0000300 }
301 printf("\n");
302 }
303 }
304 return retval;
305}
306
307
308#define PAD(v, p) ((v+(p)-1)&(~((p)-1)))
309
DRCf610d612013-04-26 10:33:29 +0000310int checkBufYUV(unsigned char *buf, int w, int h, int subsamp,
311 tjscalingfactor sf)
DRCb8b359a2011-05-25 03:54:56 +0000312{
313 int row, col;
314 int hsf=tjMCUWidth[subsamp]/8, vsf=tjMCUHeight[subsamp]/8;
315 int pw=PAD(w, hsf), ph=PAD(h, vsf);
316 int cw=pw/hsf, ch=ph/vsf;
DRCf610d612013-04-26 10:33:29 +0000317 int ypitch=PAD(pw, pad), uvpitch=PAD(cw, pad);
DRCb8b359a2011-05-25 03:54:56 +0000318 int retval=1;
DRCf610d612013-04-26 10:33:29 +0000319 int halfway=16*sf.num/sf.denom;
320 int blocksize=8*sf.num/sf.denom;
DRCb8b359a2011-05-25 03:54:56 +0000321
DRC215aa8b2011-05-27 02:10:42 +0000322 for(row=0; row<ph; row++)
DRCb8b359a2011-05-25 03:54:56 +0000323 {
324 for(col=0; col<pw; col++)
325 {
326 unsigned char y=buf[ypitch*row+col];
DRCf610d612013-04-26 10:33:29 +0000327 if(((row/blocksize)+(col/blocksize))%2==0)
DRC215aa8b2011-05-27 02:10:42 +0000328 {
329 if(row<halfway) checkval255(y) else checkval0(y);
330 }
331 else
332 {
333 if(row<halfway) checkval(y, 76) else checkval(y, 226);
334 }
DRCb8b359a2011-05-25 03:54:56 +0000335 }
336 }
337 if(subsamp!=TJSAMP_GRAY)
338 {
DRCf610d612013-04-26 10:33:29 +0000339 int halfway=16/vsf*sf.num/sf.denom;
DRC215aa8b2011-05-27 02:10:42 +0000340 for(row=0; row<ch; row++)
DRCb8b359a2011-05-25 03:54:56 +0000341 {
342 for(col=0; col<cw; col++)
343 {
344 unsigned char u=buf[ypitch*ph + (uvpitch*row+col)],
345 v=buf[ypitch*ph + uvpitch*ch + (uvpitch*row+col)];
DRCf610d612013-04-26 10:33:29 +0000346 if(((row*vsf/blocksize)+(col*hsf/blocksize))%2==0)
DRCb8b359a2011-05-25 03:54:56 +0000347 {
348 checkval(u, 128); checkval(v, 128);
349 }
350 else
351 {
DRC215aa8b2011-05-27 02:10:42 +0000352 if(row<halfway)
353 {
354 checkval(u, 85); checkval255(v);
355 }
356 else
357 {
358 checkval0(u); checkval(v, 149);
359 }
DRCb8b359a2011-05-25 03:54:56 +0000360 }
361 }
362 }
363 }
364
365 bailout:
366 if(retval==0)
367 {
368 for(row=0; row<ph; row++)
369 {
370 for(col=0; col<pw; col++)
371 printf("%.3d ", buf[ypitch*row+col]);
372 printf("\n");
373 }
374 printf("\n");
375 for(row=0; row<ch; row++)
376 {
377 for(col=0; col<cw; col++)
378 printf("%.3d ", buf[ypitch*ph + (uvpitch*row+col)]);
379 printf("\n");
380 }
381 printf("\n");
382 for(row=0; row<ch; row++)
383 {
384 for(col=0; col<cw; col++)
385 printf("%.3d ", buf[ypitch*ph + uvpitch*ch + (uvpitch*row+col)]);
386 printf("\n");
387 }
DRCb8b359a2011-05-25 03:54:56 +0000388 }
389
390 return retval;
391}
392
393
394void writeJPEG(unsigned char *jpegBuf, unsigned long jpegSize, char *filename)
395{
396 FILE *file=fopen(filename, "wb");
397 if(!file || fwrite(jpegBuf, jpegSize, 1, file)!=1)
398 {
399 printf("ERROR: Could not write to %s.\n%s\n", filename, strerror(errno));
400 bailout();
401 }
402
403 bailout:
404 if(file) fclose(file);
405}
406
407
408void compTest(tjhandle handle, unsigned char **dstBuf,
409 unsigned long *dstSize, int w, int h, int pf, char *basename,
410 int subsamp, int jpegQual, int flags)
411{
DRC34dca052014-02-28 09:17:14 +0000412 char tempStr[1024]; unsigned char *srcBuf=NULL, *yuvBuf=NULL;
413 const char *pfStr=pixFormatStr[pf];
DRCfe739652013-10-31 04:53:27 +0000414 const char *buStrLong=(flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down ";
415 const char *buStr=(flags&TJFLAG_BOTTOMUP)? "BU":"TD";
DRCb8b359a2011-05-25 03:54:56 +0000416
DRC34dca052014-02-28 09:17:14 +0000417 if((srcBuf=(unsigned char *)malloc(w*h*tjPixelSize[pf]))==NULL)
418 _throw("Memory allocation failure");
419 initBuf(srcBuf, w, h, pf, flags);
DRCb8b359a2011-05-25 03:54:56 +0000420
DRCb8b359a2011-05-25 03:54:56 +0000421 if(*dstBuf && *dstSize>0) memset(*dstBuf, 0, *dstSize);
422
DRCb8b359a2011-05-25 03:54:56 +0000423
DRC34dca052014-02-28 09:17:14 +0000424 if(!alloc) flags|=TJFLAG_NOREALLOC;
425 if(doyuv)
426 {
427 unsigned long yuvSize=tjBufSizeYUV2(w, pad, h, subsamp);
428 tjscalingfactor sf={1, 1};
DRCc9014492014-03-10 09:34:04 +0000429 tjhandle handle2=tjInitCompress();
430 if(!handle2) _throwtj();
DRC34dca052014-02-28 09:17:14 +0000431
432 if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL)
433 _throw("Memory allocation failure");
DRC20e158d2014-03-08 20:50:35 +0000434 memset(yuvBuf, 0, yuvSize);
DRC34dca052014-02-28 09:17:14 +0000435
436 printf("%s %s -> YUV %s ... ", pfStr, buStrLong, subNameLong[subsamp]);
DRCc9014492014-03-10 09:34:04 +0000437 _tj(tjEncodeYUV3(handle2, srcBuf, w, 0, h, pf, yuvBuf, pad, subsamp,
DRC34dca052014-02-28 09:17:14 +0000438 flags));
DRCc9014492014-03-10 09:34:04 +0000439 tjDestroy(handle2);
DRC34dca052014-02-28 09:17:14 +0000440 if(checkBufYUV(yuvBuf, w, h, subsamp, sf)) printf("Passed.\n");
441 else printf("FAILED!\n");
442
443 printf("YUV %s %s -> JPEG Q%d ... ", subNameLong[subsamp], buStrLong,
444 jpegQual);
445 _tj(tjCompressFromYUV(handle, yuvBuf, w, pad, h, subsamp, dstBuf,
446 dstSize, jpegQual, flags));
DRCb8b359a2011-05-25 03:54:56 +0000447 }
DRC34dca052014-02-28 09:17:14 +0000448 else
449 {
450 printf("%s %s -> %s Q%d ... ", pfStr, buStrLong, subNameLong[subsamp],
451 jpegQual);
452 _tj(tjCompress2(handle, srcBuf, w, 0, h, pf, dstBuf, dstSize, subsamp,
453 jpegQual, flags));
454 }
455
456 snprintf(tempStr, 1024, "%s_enc_%s_%s_%s_Q%d.jpg", basename, pfStr, buStr,
457 subName[subsamp], jpegQual);
458 writeJPEG(*dstBuf, *dstSize, tempStr);
459 printf("Done.\n Result in %s\n", tempStr);
DRCb8b359a2011-05-25 03:54:56 +0000460
461 bailout:
DRC34dca052014-02-28 09:17:14 +0000462 if(yuvBuf) free(yuvBuf);
DRCb8b359a2011-05-25 03:54:56 +0000463 if(srcBuf) free(srcBuf);
464}
465
466
467void _decompTest(tjhandle handle, unsigned char *jpegBuf,
468 unsigned long jpegSize, int w, int h, int pf, char *basename, int subsamp,
469 int flags, tjscalingfactor sf)
470{
DRC34dca052014-02-28 09:17:14 +0000471 unsigned char *dstBuf=NULL, *yuvBuf=NULL;
DRC2bdadb42014-02-28 09:06:42 +0000472 int _hdrw=0, _hdrh=0, _hdrsubsamp=-1;
DRCb8b359a2011-05-25 03:54:56 +0000473 int scaledWidth=TJSCALED(w, sf);
474 int scaledHeight=TJSCALED(h, sf);
475 unsigned long dstSize=0;
476
DRCb8b359a2011-05-25 03:54:56 +0000477 _tj(tjDecompressHeader2(handle, jpegBuf, jpegSize, &_hdrw, &_hdrh,
478 &_hdrsubsamp));
479 if(_hdrw!=w || _hdrh!=h || _hdrsubsamp!=subsamp)
480 _throw("Incorrect JPEG header");
481
DRC34dca052014-02-28 09:17:14 +0000482 dstSize=scaledWidth*scaledHeight*tjPixelSize[pf];
DRCb8b359a2011-05-25 03:54:56 +0000483 if((dstBuf=(unsigned char *)malloc(dstSize))==NULL)
484 _throw("Memory allocation failure");
485 memset(dstBuf, 0, dstSize);
486
DRC34dca052014-02-28 09:17:14 +0000487 if(doyuv)
DRCb8b359a2011-05-25 03:54:56 +0000488 {
DRC34dca052014-02-28 09:17:14 +0000489 unsigned long yuvSize=tjBufSizeYUV2(scaledWidth, pad, scaledHeight,
490 subsamp);
DRCc9014492014-03-10 09:34:04 +0000491 tjhandle handle2=tjInitDecompress();
492 if(!handle2) _throwtj();
DRC34dca052014-02-28 09:17:14 +0000493
494 if((yuvBuf=(unsigned char *)malloc(yuvSize))==NULL)
495 _throw("Memory allocation failure");
DRC20e158d2014-03-08 20:50:35 +0000496 memset(yuvBuf, 0, yuvSize);
DRC34dca052014-02-28 09:17:14 +0000497
498 printf("JPEG -> YUV %s ", subNameLong[subsamp]);
499 if(sf.num!=1 || sf.denom!=1)
500 printf("%d/%d ... ", sf.num, sf.denom);
501 else printf("... ");
502 _tj(tjDecompressToYUV2(handle, jpegBuf, jpegSize, yuvBuf, scaledWidth,
DRCf610d612013-04-26 10:33:29 +0000503 pad, scaledHeight, flags));
DRC34dca052014-02-28 09:17:14 +0000504 if(checkBufYUV(yuvBuf, scaledWidth, scaledHeight, subsamp, sf))
505 printf("Passed.\n");
506 else printf("FAILED!\n");
507
508 printf("YUV %s -> %s %s ... ", subNameLong[subsamp], pixFormatStr[pf],
509 (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down ");
DRCc9014492014-03-10 09:34:04 +0000510 _tj(tjDecodeYUV(handle2, yuvBuf, pad, subsamp, dstBuf, scaledWidth, 0,
DRC34dca052014-02-28 09:17:14 +0000511 scaledHeight, pf, flags));
DRCc9014492014-03-10 09:34:04 +0000512 tjDestroy(handle2);
DRCb8b359a2011-05-25 03:54:56 +0000513 }
514 else
515 {
DRC34dca052014-02-28 09:17:14 +0000516 printf("JPEG -> %s %s ", pixFormatStr[pf],
517 (flags&TJFLAG_BOTTOMUP)? "Bottom-Up":"Top-Down ");
518 if(sf.num!=1 || sf.denom!=1)
519 printf("%d/%d ... ", sf.num, sf.denom);
520 else printf("... ");
DRCb8b359a2011-05-25 03:54:56 +0000521 _tj(tjDecompress2(handle, jpegBuf, jpegSize, dstBuf, scaledWidth, 0,
522 scaledHeight, pf, flags));
523 }
DRCb8b359a2011-05-25 03:54:56 +0000524
DRC34dca052014-02-28 09:17:14 +0000525 if(checkBuf(dstBuf, scaledWidth, scaledHeight, pf, subsamp, sf, flags))
526 printf("Passed.");
527 else printf("FAILED!");
DRC2bdadb42014-02-28 09:06:42 +0000528 printf("\n");
DRCb8b359a2011-05-25 03:54:56 +0000529
530 bailout:
DRC34dca052014-02-28 09:17:14 +0000531 if(yuvBuf) free(yuvBuf);
DRCb8b359a2011-05-25 03:54:56 +0000532 if(dstBuf) free(dstBuf);
533}
534
535
536void decompTest(tjhandle handle, unsigned char *jpegBuf,
537 unsigned long jpegSize, int w, int h, int pf, char *basename, int subsamp,
538 int flags)
539{
540 int i, n=0;
DRC418fe282013-05-07 21:17:35 +0000541 tjscalingfactor *sf=tjGetScalingFactors(&n);
DRCb8b359a2011-05-25 03:54:56 +0000542 if(!sf || !n) _throwtj();
543
DRC418fe282013-05-07 21:17:35 +0000544 for(i=0; i<n; i++)
DRCb8b359a2011-05-25 03:54:56 +0000545 {
DRC418fe282013-05-07 21:17:35 +0000546 if(subsamp==TJSAMP_444 || subsamp==TJSAMP_GRAY ||
DRC1f3635c2013-08-18 10:19:00 +0000547 (subsamp==TJSAMP_411 && sf[i].num==1 &&
548 (sf[i].denom==2 || sf[i].denom==1)) ||
549 (subsamp!=TJSAMP_411 && sf[i].num==1 &&
550 (sf[i].denom==4 || sf[i].denom==2 || sf[i].denom==1)))
DRCb8b359a2011-05-25 03:54:56 +0000551 _decompTest(handle, jpegBuf, jpegSize, w, h, pf, basename, subsamp,
552 flags, sf[i]);
553 }
DRCb8b359a2011-05-25 03:54:56 +0000554
555 bailout:
DRCb7c41932013-05-04 23:41:33 +0000556 return;
DRCb8b359a2011-05-25 03:54:56 +0000557}
558
559
560void doTest(int w, int h, const int *formats, int nformats, int subsamp,
561 char *basename)
562{
563 tjhandle chandle=NULL, dhandle=NULL;
564 unsigned char *dstBuf=NULL;
565 unsigned long size=0; int pfi, pf, i;
566
DRC34dca052014-02-28 09:17:14 +0000567 if(!alloc)
DRC910a3572013-10-30 23:02:57 +0000568 size=tjBufSize(w, h, subsamp);
569 if(size!=0)
DRCb8b359a2011-05-25 03:54:56 +0000570 if((dstBuf=(unsigned char *)tjAlloc(size))==NULL)
571 _throw("Memory allocation failure.");
DRCb8b359a2011-05-25 03:54:56 +0000572
573 if((chandle=tjInitCompress())==NULL || (dhandle=tjInitDecompress())==NULL)
574 _throwtj();
575
576 for(pfi=0; pfi<nformats; pfi++)
577 {
578 for(i=0; i<2; i++)
579 {
580 int flags=0;
DRC1f3635c2013-08-18 10:19:00 +0000581 if(subsamp==TJSAMP_422 || subsamp==TJSAMP_420 || subsamp==TJSAMP_440 ||
582 subsamp==TJSAMP_411)
DRCcac10512012-03-16 14:37:36 +0000583 flags|=TJFLAG_FASTUPSAMPLE;
DRC34dca052014-02-28 09:17:14 +0000584 if(i==1) flags|=TJFLAG_BOTTOMUP;
DRCb8b359a2011-05-25 03:54:56 +0000585 pf=formats[pfi];
586 compTest(chandle, &dstBuf, &size, w, h, pf, basename, subsamp, 100,
587 flags);
588 decompTest(dhandle, dstBuf, size, w, h, pf, basename, subsamp,
589 flags);
DRC67ce3b22011-12-19 02:21:03 +0000590 if(pf>=TJPF_RGBX && pf<=TJPF_XRGB)
DRC4798b7e2014-03-08 20:31:31 +0000591 {
592 printf("\n");
DRC67ce3b22011-12-19 02:21:03 +0000593 decompTest(dhandle, dstBuf, size, w, h, pf+(TJPF_RGBA-TJPF_RGBX),
594 basename, subsamp, flags);
DRC4798b7e2014-03-08 20:31:31 +0000595 }
DRCb7c41932013-05-04 23:41:33 +0000596 printf("\n");
DRCb8b359a2011-05-25 03:54:56 +0000597 }
598 }
DRCb7c41932013-05-04 23:41:33 +0000599 printf("--------------------\n\n");
DRCb8b359a2011-05-25 03:54:56 +0000600
601 bailout:
602 if(chandle) tjDestroy(chandle);
603 if(dhandle) tjDestroy(dhandle);
604
605 if(dstBuf) tjFree(dstBuf);
606}
607
608
DRC724c56b2011-07-12 06:22:06 +0000609void bufSizeTest(void)
DRCb8b359a2011-05-25 03:54:56 +0000610{
DRC724c56b2011-07-12 06:22:06 +0000611 int w, h, i, subsamp;
DRC38c99702014-02-11 09:45:18 +0000612 unsigned char *srcBuf=NULL, *dstBuf=NULL;
DRCb8b359a2011-05-25 03:54:56 +0000613 tjhandle handle=NULL;
DRC38c99702014-02-11 09:45:18 +0000614 unsigned long dstSize=0;
DRCb8b359a2011-05-25 03:54:56 +0000615
616 if((handle=tjInitCompress())==NULL) _throwtj();
617
618 printf("Buffer size regression test\n");
DRC724c56b2011-07-12 06:22:06 +0000619 for(subsamp=0; subsamp<TJ_NUMSAMP; subsamp++)
DRCb8b359a2011-05-25 03:54:56 +0000620 {
DRC724c56b2011-07-12 06:22:06 +0000621 for(w=1; w<48; w++)
DRCb8b359a2011-05-25 03:54:56 +0000622 {
DRC724c56b2011-07-12 06:22:06 +0000623 int maxh=(w==1)? 2048:48;
624 for(h=1; h<maxh; h++)
DRCb8b359a2011-05-25 03:54:56 +0000625 {
DRC724c56b2011-07-12 06:22:06 +0000626 if(h%100==0) printf("%.4d x %.4d\b\b\b\b\b\b\b\b\b\b\b", w, h);
627 if((srcBuf=(unsigned char *)malloc(w*h*4))==NULL)
DRCb8b359a2011-05-25 03:54:56 +0000628 _throw("Memory allocation failure");
DRC34dca052014-02-28 09:17:14 +0000629 if(!alloc || doyuv)
DRC724c56b2011-07-12 06:22:06 +0000630 {
DRC34dca052014-02-28 09:17:14 +0000631 if(doyuv) dstSize=tjBufSizeYUV2(w, pad, h, subsamp);
DRC38c99702014-02-11 09:45:18 +0000632 else dstSize=tjBufSize(w, h, subsamp);
633 if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL)
DRC724c56b2011-07-12 06:22:06 +0000634 _throw("Memory allocation failure");
DRC724c56b2011-07-12 06:22:06 +0000635 }
DRCb8b359a2011-05-25 03:54:56 +0000636
DRC724c56b2011-07-12 06:22:06 +0000637 for(i=0; i<w*h*4; i++)
638 {
639 if(random()<RAND_MAX/2) srcBuf[i]=0;
640 else srcBuf[i]=255;
641 }
DRCb8b359a2011-05-25 03:54:56 +0000642
DRC34dca052014-02-28 09:17:14 +0000643 if(doyuv)
DRC38c99702014-02-11 09:45:18 +0000644 {
645 _tj(tjEncodeYUV3(handle, srcBuf, w, 0, h, TJPF_BGRX, dstBuf, pad,
646 subsamp, 0));
647 }
648 else
649 {
650 _tj(tjCompress2(handle, srcBuf, w, 0, h, TJPF_BGRX, &dstBuf,
651 &dstSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC));
652 }
DRC724c56b2011-07-12 06:22:06 +0000653 free(srcBuf); srcBuf=NULL;
mayeutf57bae02016-02-25 23:14:45 +0100654 if(!alloc || doyuv)
DRCfe80ec22014-08-21 15:51:47 +0000655 {
656 tjFree(dstBuf); dstBuf=NULL;
657 }
DRCb8b359a2011-05-25 03:54:56 +0000658
DRC724c56b2011-07-12 06:22:06 +0000659 if((srcBuf=(unsigned char *)malloc(h*w*4))==NULL)
DRCb8b359a2011-05-25 03:54:56 +0000660 _throw("Memory allocation failure");
DRC34dca052014-02-28 09:17:14 +0000661 if(!alloc || doyuv)
DRC724c56b2011-07-12 06:22:06 +0000662 {
DRC34dca052014-02-28 09:17:14 +0000663 if(doyuv) dstSize=tjBufSizeYUV2(h, pad, w, subsamp);
DRC38c99702014-02-11 09:45:18 +0000664 else dstSize=tjBufSize(h, w, subsamp);
665 if((dstBuf=(unsigned char *)tjAlloc(dstSize))==NULL)
DRC724c56b2011-07-12 06:22:06 +0000666 _throw("Memory allocation failure");
DRC724c56b2011-07-12 06:22:06 +0000667 }
DRCb8b359a2011-05-25 03:54:56 +0000668
DRC724c56b2011-07-12 06:22:06 +0000669 for(i=0; i<h*w*4; i++)
670 {
671 if(random()<RAND_MAX/2) srcBuf[i]=0;
672 else srcBuf[i]=255;
673 }
674
DRC34dca052014-02-28 09:17:14 +0000675 if(doyuv)
DRC38c99702014-02-11 09:45:18 +0000676 {
677 _tj(tjEncodeYUV3(handle, srcBuf, h, 0, w, TJPF_BGRX, dstBuf, pad,
678 subsamp, 0));
679 }
680 else
681 {
682 _tj(tjCompress2(handle, srcBuf, h, 0, w, TJPF_BGRX, &dstBuf,
683 &dstSize, subsamp, 100, alloc? 0:TJFLAG_NOREALLOC));
684 }
DRC724c56b2011-07-12 06:22:06 +0000685 free(srcBuf); srcBuf=NULL;
mayeutf57bae02016-02-25 23:14:45 +0100686 if(!alloc || doyuv)
DRCfe80ec22014-08-21 15:51:47 +0000687 {
688 tjFree(dstBuf); dstBuf=NULL;
689 }
DRCb8b359a2011-05-25 03:54:56 +0000690 }
DRCb8b359a2011-05-25 03:54:56 +0000691 }
692 }
693 printf("Done. \n");
694
695 bailout:
696 if(srcBuf) free(srcBuf);
DRCeb669742014-08-22 19:59:51 +0000697 if(dstBuf) tjFree(dstBuf);
DRCb8b359a2011-05-25 03:54:56 +0000698 if(handle) tjDestroy(handle);
699}
700
701
DRCaa745902017-11-16 18:09:07 -0600702void initBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
703 int flags)
704{
705 int roffset=tjRedOffset[pf];
706 int goffset=tjGreenOffset[pf];
707 int boffset=tjBlueOffset[pf];
708 int ps=tjPixelSize[pf];
709 int i, j;
710
711 for(j=0; j<height; j++)
712 {
713 int row=(flags&TJFLAG_BOTTOMUP)? height-j-1:j;
714 for(i=0; i<width; i++)
715 {
716 unsigned char r=(i*256/width)%256;
717 unsigned char g=(j*256/height)%256;
718 unsigned char b=(j*256/height+i*256/width)%256;
719 memset(&buf[row*pitch+i*ps], 0, ps);
720 if(pf==TJPF_GRAY) buf[row*pitch+i*ps]=RGB2GRAY(r, g, b);
721 else if(pf==TJPF_CMYK)
722 rgb_to_cmyk(r, g, b, &buf[row*pitch+i*ps+0], &buf[row*pitch+i*ps+1],
723 &buf[row*pitch+i*ps+2], &buf[row*pitch+i*ps+3]);
724 else
725 {
726 buf[row*pitch+i*ps+roffset]=r;
727 buf[row*pitch+i*ps+goffset]=g;
728 buf[row*pitch+i*ps+boffset]=b;
729 }
730 }
731 }
732}
733
734
735int cmpBitmap(unsigned char *buf, int width, int pitch, int height, int pf,
736 int flags, int gray2rgb)
737{
738 int roffset=tjRedOffset[pf];
739 int goffset=tjGreenOffset[pf];
740 int boffset=tjBlueOffset[pf];
741 int aoffset=alphaOffset[pf];
742 int ps=tjPixelSize[pf];
743 int i, j;
744
745 for(j=0; j<height; j++)
746 {
747 int row=(flags&TJFLAG_BOTTOMUP)? height-j-1:j;
748 for(i=0; i<width; i++)
749 {
750 unsigned char r=(i*256/width)%256;
751 unsigned char g=(j*256/height)%256;
752 unsigned char b=(j*256/height+i*256/width)%256;
753 if(pf==TJPF_GRAY)
754 {
755 if(buf[row*pitch+i*ps]!=RGB2GRAY(r, g, b))
756 return 0;
757 }
758 else if(pf==TJPF_CMYK)
759 {
760 unsigned char rf, gf, bf;
761 cmyk_to_rgb(buf[row*pitch+i*ps+0], buf[row*pitch+i*ps+1],
762 buf[row*pitch+i*ps+2], buf[row*pitch+i*ps+3], &rf, &gf,
763 &bf);
764 if(gray2rgb)
765 {
766 unsigned char gray=RGB2GRAY(r, g, b);
767 if(rf!=gray || gf!=gray || bf!=gray)
768 return 0;
769 }
770 else if(rf!=r || gf!=g || bf!=b) return 0;
771 }
772 else
773 {
774 if(gray2rgb)
775 {
776 unsigned char gray=RGB2GRAY(r, g, b);
777 if(buf[row*pitch+i*ps+roffset]!=gray ||
778 buf[row*pitch+i*ps+goffset]!=gray ||
779 buf[row*pitch+i*ps+boffset]!=gray)
780 return 0;
781 }
782 else if(buf[row*pitch+i*ps+roffset]!=r ||
783 buf[row*pitch+i*ps+goffset]!=g ||
784 buf[row*pitch+i*ps+boffset]!=b)
785 return 0;
786 if(aoffset>=0 && buf[row*pitch+i*ps+aoffset]!=0xFF)
787 return 0;
788 }
789 }
790 }
791 return 1;
792}
793
794
795int doBmpTest(const char *ext, int width, int align, int height, int pf,
796 int flags)
797{
798 char filename[80], *md5sum, md5buf[65];
799 int ps=tjPixelSize[pf], pitch=PAD(width*ps, align),
800 loadWidth=0, loadHeight=0, retval=0;
801 unsigned char *buf=NULL;
802 char *md5ref;
803
804 if(pf==TJPF_GRAY)
805 {
806 md5ref=!strcasecmp(ext, "ppm")? "bc77dea8eaf006aa187582b301f67e02":
807 "2670a3f8cf19d855183c02ccf18d2a35";
808 }
809 else
810 {
811 md5ref=!strcasecmp(ext, "ppm")? "c0c9f772b464d1896326883a5c79c545":
812 "6d659071b9bfcdee2def22cb58ddadca";
813 }
814
815 if((buf=(unsigned char *)tjAlloc(pitch*height))==NULL)
816 _throw("Could not allocate memory");
817 initBitmap(buf, width, pitch, height, pf, flags);
818
819 snprintf(filename, 80, "test_bmp_%s_%d_%s.%s", pixFormatStr[pf], align,
820 (flags&TJFLAG_BOTTOMUP)? "bu":"td", ext);
821 _tj(tjSaveImage(filename, buf, width, pitch, height, pf, flags));
822 md5sum=MD5File(filename, md5buf);
823 if(strcasecmp(md5sum, md5ref))
824 _throwmd5(filename, md5sum, md5ref);
825
826 tjFree(buf); buf=NULL;
827 if((buf=tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
828 flags))==NULL)
829 _throwtj();
830 if(width!=loadWidth || height!=loadHeight)
831 {
832 printf("\n Image dimensions of %s are bogus\n", filename);
833 retval=-1; goto bailout;
834 }
835 if(!cmpBitmap(buf, width, pitch, height, pf, flags, 0))
836 {
837 printf("\n Pixel data in %s is bogus\n", filename);
838 retval=-1; goto bailout;
839 }
840 if(pf==TJPF_GRAY)
841 {
842 tjFree(buf); buf=NULL;
843 pf=TJPF_XBGR;
844 if((buf=tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
845 flags))==NULL)
846 _throwtj();
847 pitch=PAD(width*tjPixelSize[pf], align);
848 if(!cmpBitmap(buf, width, pitch, height, pf, flags, 1))
849 {
850 printf("\n Converting %s to RGB failed\n", filename);
851 retval=-1; goto bailout;
852 }
853
854 tjFree(buf); buf=NULL;
855 pf=TJPF_CMYK;
856 if((buf=tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
857 flags))==NULL)
858 _throwtj();
859 pitch=PAD(width*tjPixelSize[pf], align);
860 if(!cmpBitmap(buf, width, pitch, height, pf, flags, 1))
861 {
862 printf("\n Converting %s to CMYK failed\n", filename);
863 retval=-1; goto bailout;
864 }
865 }
866 else if(pf!=TJPF_CMYK)
867 {
868 tjFree(buf); buf=NULL;
869 pf=TJPF_GRAY;
870 if((buf=tjLoadImage(filename, &loadWidth, align, &loadHeight, &pf,
871 flags))==NULL)
872 _throwtj();
873 pitch=PAD(width, align);
874 if(!cmpBitmap(buf, width, pitch, height, pf, flags, 0))
875 {
876 printf("\n Converting %s to grayscale failed\n", filename);
877 retval=-1; goto bailout;
878 }
879 }
880 unlink(filename);
881
882 bailout:
883 if(buf) tjFree(buf);
884 if(exitStatus<0) return exitStatus;
885 return retval;
886}
887
888
889int bmpTest(void)
890{
891 int align, width=35, height=39, format;
892
893 for(align=1; align<=8; align*=2)
894 {
895 for(format=0; format<TJ_NUMPF; format++)
896 {
897 printf("%s Top-Down BMP (row alignment = %d bytes) ... ",
898 pixFormatStr[format], align);
899 if(doBmpTest("bmp", width, align, height, format, 0)==-1)
900 return -1;
901 printf("OK.\n");
902
903 printf("%s Top-Down PPM (row alignment = %d bytes) ... ",
904 pixFormatStr[format], align);
905 if(doBmpTest("ppm", width, align, height, format, TJFLAG_BOTTOMUP)==-1)
906 return -1;
907 printf("OK.\n");
908
909 printf("%s Bottom-Up BMP (row alignment = %d bytes) ... ",
910 pixFormatStr[format], align);
911 if(doBmpTest("bmp", width, align, height, format, 0)==-1)
912 return -1;
913 printf("OK.\n");
914
915 printf("%s Bottom-Up PPM (row alignment = %d bytes) ... ",
916 pixFormatStr[format], align);
917 if(doBmpTest("ppm", width, align, height, format, TJFLAG_BOTTOMUP)==-1)
918 return -1;
919 printf("OK.\n");
920 }
921 }
922
923 return 0;
924}
925
926
DRCb8b359a2011-05-25 03:54:56 +0000927int main(int argc, char *argv[])
928{
DRC34dca052014-02-28 09:17:14 +0000929 int i, num4bf=5;
DRCe835ee32011-07-15 10:06:56 +0000930 #ifdef _WIN32
931 srand((unsigned int)time(NULL));
932 #endif
DRCb8b359a2011-05-25 03:54:56 +0000933 if(argc>1)
934 {
935 for(i=1; i<argc; i++)
936 {
937 if(!strcasecmp(argv[i], "-yuv")) doyuv=1;
DRCf3ad13e2017-11-13 16:00:35 -0600938 else if(!strcasecmp(argv[i], "-noyuvpad")) pad=1;
939 else if(!strcasecmp(argv[i], "-alloc")) alloc=1;
DRCaa745902017-11-16 18:09:07 -0600940 else if(!strcasecmp(argv[i], "-bmp")) return bmpTest();
DRCf3ad13e2017-11-13 16:00:35 -0600941 else usage(argv[0]);
DRCb8b359a2011-05-25 03:54:56 +0000942 }
943 }
944 if(alloc) printf("Testing automatic buffer allocation\n");
DRC34dca052014-02-28 09:17:14 +0000945 if(doyuv) num4bf=4;
DRCb8b359a2011-05-25 03:54:56 +0000946 doTest(35, 39, _3byteFormats, 2, TJSAMP_444, "test");
DRCcd7c3e62013-08-23 02:49:25 +0000947 doTest(39, 41, _4byteFormats, num4bf, TJSAMP_444, "test");
DRCcac10512012-03-16 14:37:36 +0000948 doTest(41, 35, _3byteFormats, 2, TJSAMP_422, "test");
DRCcd7c3e62013-08-23 02:49:25 +0000949 doTest(35, 39, _4byteFormats, num4bf, TJSAMP_422, "test");
DRCcac10512012-03-16 14:37:36 +0000950 doTest(39, 41, _3byteFormats, 2, TJSAMP_420, "test");
DRCcd7c3e62013-08-23 02:49:25 +0000951 doTest(41, 35, _4byteFormats, num4bf, TJSAMP_420, "test");
DRCcac10512012-03-16 14:37:36 +0000952 doTest(35, 39, _3byteFormats, 2, TJSAMP_440, "test");
DRCcd7c3e62013-08-23 02:49:25 +0000953 doTest(39, 41, _4byteFormats, num4bf, TJSAMP_440, "test");
DRC1f3635c2013-08-18 10:19:00 +0000954 doTest(41, 35, _3byteFormats, 2, TJSAMP_411, "test");
DRCcd7c3e62013-08-23 02:49:25 +0000955 doTest(35, 39, _4byteFormats, num4bf, TJSAMP_411, "test");
DRC1f3635c2013-08-18 10:19:00 +0000956 doTest(39, 41, _onlyGray, 1, TJSAMP_GRAY, "test");
957 doTest(41, 35, _3byteFormats, 2, TJSAMP_GRAY, "test");
958 doTest(35, 39, _4byteFormats, 4, TJSAMP_GRAY, "test");
DRC38c99702014-02-11 09:45:18 +0000959 bufSizeTest();
DRCb8b359a2011-05-25 03:54:56 +0000960 if(doyuv)
961 {
DRC38c99702014-02-11 09:45:18 +0000962 printf("\n--------------------\n\n");
DRCb8b359a2011-05-25 03:54:56 +0000963 doTest(48, 48, _onlyRGB, 1, TJSAMP_444, "test_yuv0");
DRCb8b359a2011-05-25 03:54:56 +0000964 doTest(48, 48, _onlyRGB, 1, TJSAMP_422, "test_yuv0");
DRCb8b359a2011-05-25 03:54:56 +0000965 doTest(48, 48, _onlyRGB, 1, TJSAMP_420, "test_yuv0");
DRCb8b359a2011-05-25 03:54:56 +0000966 doTest(48, 48, _onlyRGB, 1, TJSAMP_440, "test_yuv0");
DRC1f3635c2013-08-18 10:19:00 +0000967 doTest(48, 48, _onlyRGB, 1, TJSAMP_411, "test_yuv0");
DRCb8b359a2011-05-25 03:54:56 +0000968 doTest(48, 48, _onlyRGB, 1, TJSAMP_GRAY, "test_yuv0");
DRCb8b359a2011-05-25 03:54:56 +0000969 doTest(48, 48, _onlyGray, 1, TJSAMP_GRAY, "test_yuv0");
DRCb8b359a2011-05-25 03:54:56 +0000970 }
971
972 return exitStatus;
973}