/*
- * Copyright (C)2009-2013 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-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:
System.out.println(" codec");
System.out.println("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the");
System.out.println(" underlying codec");
- System.out.println("-440 = Test 4:4:0 chrominance subsampling instead of 4:2:2");
+ System.out.println("-subsamp <s> = When testing JPEG compression, this option specifies the level");
+ System.out.println(" of chrominance subsampling to use (<s> = 444, 422, 440, 420, or GRAY).");
+ System.out.println(" The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in sequence.");
System.out.println("-quiet = Output results in tabular rather than verbose format");
System.out.println("-yuvencode = Encode RGB input as planar YUV rather than compressing as JPEG");
System.out.println("-yuvdecode = Decode JPEG image to planar YUV rather than RGB");
byte[] srcBuf = null; int w = 0, h = 0;
int minQual = -1, maxQual = -1;
int minArg = 1; int retval = 0;
- boolean do440 = false;
+ int subsamp = -1;
try {
System.out.println("Using most accurate DCT/IDCT algorithm\n");
flags |= TJ.FLAG_ACCURATEDCT;
}
- if (argv[i].equals("-440"))
- do440 = true;
if (argv[i].equalsIgnoreCase("-rgb"))
pf = TJ.PF_RGB;
if (argv[i].equalsIgnoreCase("-rgbx"))
else
usage();
}
+ if (argv[i].equalsIgnoreCase("-subsamp") && i < argv.length - 1) {
+ i++;
+ if (argv[i].toUpperCase().startsWith("G"))
+ subsamp = TJ.SAMP_GRAY;
+ else if (argv[i].equals("444"))
+ subsamp = TJ.SAMP_444;
+ else if (argv[i].equals("422"))
+ subsamp = TJ.SAMP_422;
+ else if (argv[i].equals("440"))
+ subsamp = TJ.SAMP_440;
+ else if (argv[i].equals("420"))
+ subsamp = TJ.SAMP_420;
+ }
if (argv[i].equalsIgnoreCase("-?"))
usage();
}
}
System.gc();
- for (int i = maxQual; i >= minQual; i--)
- doTest(srcBuf, w, h, TJ.SAMP_GRAY, i, argv[0]);
- System.out.println("");
- System.gc();
- for (int i = maxQual; i >= minQual; i--)
- doTest(srcBuf, w, h, TJ.SAMP_420, i, argv[0]);
- System.out.println("");
- System.gc();
- for (int i = maxQual; i >= minQual; i--)
- doTest(srcBuf, w, h, do440 ? TJ.SAMP_440 : TJ.SAMP_422, i, argv[0]);
- System.out.println("");
- System.gc();
- for (int i = maxQual; i >= minQual; i--)
- doTest(srcBuf, w, h, TJ.SAMP_444, i, argv[0]);
- System.out.println("");
+ if (subsamp >= 0 && subsamp < TJ.NUMSAMP) {
+ for (int i = maxQual; i >= minQual; i--)
+ doTest(srcBuf, w, h, subsamp, i, argv[0]);
+ System.out.println("");
+ } else {
+ for (int i = maxQual; i >= minQual; i--)
+ doTest(srcBuf, w, h, TJ.SAMP_GRAY, i, argv[0]);
+ System.out.println("");
+ System.gc();
+ for (int i = maxQual; i >= minQual; i--)
+ doTest(srcBuf, w, h, TJ.SAMP_420, i, argv[0]);
+ System.out.println("");
+ System.gc();
+ for (int i = maxQual; i >= minQual; i--)
+ doTest(srcBuf, w, h, TJ.SAMP_422, i, argv[0]);
+ System.out.println("");
+ System.gc();
+ for (int i = maxQual; i >= minQual; i--)
+ doTest(srcBuf, w, h, TJ.SAMP_444, i, argv[0]);
+ System.out.println("");
+ }
} catch (Exception e) {
System.out.println("ERROR: " + e.getMessage());
/*
- * Copyright (C)2009-2013 D. R. Commander. All Rights Reserved.
+ * Copyright (C)2009-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:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <math.h>
#include <errno.h>
#include <cdjpeg.h>
printf(" codec\n");
printf("-accuratedct = Use the most accurate DCT/IDCT algorithms available in the\n");
printf(" underlying codec\n");
- printf("-440 = Test 4:4:0 chrominance subsampling instead of 4:2:2\n");
+ printf("-subsamp <s> = When testing JPEG compression, this option specifies the level\n");
+ printf(" of chrominance subsampling to use (<s> = 444, 422, 440, 420, or GRAY).\n");
+ printf(" The default is to test Grayscale, 4:2:0, 4:2:2, and 4:4:4 in sequence.\n");
printf("-quiet = Output results in tabular rather than verbose format\n");
printf("-yuvencode = Encode RGB input as planar YUV rather than compressing as JPEG\n");
printf("-yuvdecode = Decode JPEG image to planar YUV rather than RGB\n");
{
unsigned char *srcbuf=NULL; int w, h, i, j;
int minqual=-1, maxqual=-1; char *temp;
- int minarg=2, retval=0, do440=0;
+ int minarg=2, retval=0, subsamp=-1;
if((scalingfactors=tjGetScalingFactors(&nsf))==NULL || nsf==0)
_throwtj("executing tjGetScalingFactors()");
printf("Using most accurate DCT/IDCT algorithm\n\n");
flags|=TJFLAG_ACCURATEDCT;
}
- if(!strcmp(argv[i], "-440")) do440=1;
if(!strcasecmp(argv[i], "-rgb")) pf=TJPF_RGB;
if(!strcasecmp(argv[i], "-rgbx")) pf=TJPF_RGBX;
if(!strcasecmp(argv[i], "-bgr")) pf=TJPF_BGR;
if(!strcmp(argv[i], "-?")) usage(argv[0]);
if(!strcasecmp(argv[i], "-alloc")) flags&=(~TJFLAG_NOREALLOC);
if(!strcasecmp(argv[i], "-bmp")) ext="bmp";
+ if(!strcasecmp(argv[i], "-subsamp") && i<argc-1)
+ {
+ i++;
+ if(toupper(argv[i][0])=='G') subsamp=TJSAMP_GRAY;
+ else
+ {
+ int temp=atoi(argv[i]);
+ switch(temp)
+ {
+ case 444: subsamp=TJSAMP_444; break;
+ case 422: subsamp=TJSAMP_422; break;
+ case 440: subsamp=TJSAMP_440; break;
+ case 420: subsamp=TJSAMP_420; break;
+ }
+ }
+ }
}
}
printf("\n");
goto bailout;
}
- for(i=maxqual; i>=minqual; i--)
- dotest(srcbuf, w, h, TJ_GRAYSCALE, i, argv[1]);
- printf("\n");
- for(i=maxqual; i>=minqual; i--)
- dotest(srcbuf, w, h, TJ_420, i, argv[1]);
- printf("\n");
- for(i=maxqual; i>=minqual; i--)
- dotest(srcbuf, w, h, do440? TJSAMP_440:TJ_422, i, argv[1]);
- printf("\n");
- for(i=maxqual; i>=minqual; i--)
- dotest(srcbuf, w, h, TJ_444, i, argv[1]);
- printf("\n");
+ if(subsamp>=0 && subsamp<TJ_NUMSAMP)
+ {
+ for(i=maxqual; i>=minqual; i--)
+ dotest(srcbuf, w, h, subsamp, i, argv[1]);
+ printf("\n");
+ }
+ else
+ {
+ for(i=maxqual; i>=minqual; i--)
+ dotest(srcbuf, w, h, TJSAMP_GRAY, i, argv[1]);
+ printf("\n");
+ for(i=maxqual; i>=minqual; i--)
+ dotest(srcbuf, w, h, TJSAMP_420, i, argv[1]);
+ printf("\n");
+ for(i=maxqual; i>=minqual; i--)
+ dotest(srcbuf, w, h, TJSAMP_422, i, argv[1]);
+ printf("\n");
+ for(i=maxqual; i>=minqual; i--)
+ dotest(srcbuf, w, h, TJSAMP_444, i, argv[1]);
+ printf("\n");
+ }
bailout:
if(srcbuf) free(srcbuf);