Back-port the -subsamp option from 1.4 rather than use the hackish approach of replacing 4:2:2 with 4:4:0. This has the added advantage of allowing the user to test only a specific level of subsampling.
git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/branches/1.3.x@1153 632fc199-4ca6-4c93-a231-07263d6284db
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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:
|
||||
@@ -600,7 +600,9 @@ class TJBench {
|
||||
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");
|
||||
@@ -637,7 +639,7 @@ class TJBench {
|
||||
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 {
|
||||
|
||||
@@ -715,8 +717,6 @@ class TJBench {
|
||||
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"))
|
||||
@@ -786,6 +786,19 @@ class TJBench {
|
||||
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();
|
||||
}
|
||||
@@ -829,21 +842,27 @@ class TJBench {
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
59
tjbench.c
59
tjbench.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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:
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <cdjpeg.h>
|
||||
@@ -686,7 +687,9 @@ void usage(char *progname)
|
||||
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");
|
||||
@@ -720,7 +723,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
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()");
|
||||
@@ -811,7 +814,6 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
@@ -858,6 +860,22 @@ int main(int argc, char *argv[])
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,18 +915,27 @@ int main(int argc, char *argv[])
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user