TJBench: Strictly check all non-boolean arguments
+ document that the value of -yuvpad must be a power of 2 (refer to
d260858395)
This commit is contained in:
@@ -717,7 +717,8 @@ final class TJBench {
|
|||||||
System.out.println("-quiet = Output results in tabular rather than verbose format");
|
System.out.println("-quiet = Output results in tabular rather than verbose format");
|
||||||
System.out.println("-yuv = Compress from/decompress to intermediate planar YUV images");
|
System.out.println("-yuv = Compress from/decompress to intermediate planar YUV images");
|
||||||
System.out.println("-yuvpad <p> = The number of bytes by which each row in each plane of an");
|
System.out.println("-yuvpad <p> = The number of bytes by which each row in each plane of an");
|
||||||
System.out.println(" intermediate YUV image is evenly divisible [default = 1]");
|
System.out.println(" intermediate YUV image is evenly divisible (must be a power of 2)");
|
||||||
|
System.out.println(" [default = 1]");
|
||||||
System.out.println("-scale M/N = When decompressing, scale the width/height of the JPEG image by a");
|
System.out.println("-scale M/N = When decompressing, scale the width/height of the JPEG image by a");
|
||||||
System.out.print(" factor of M/N (M/N = ");
|
System.out.print(" factor of M/N (M/N = ");
|
||||||
for (i = 0; i < nsf; i++) {
|
for (i = 0; i < nsf; i++) {
|
||||||
@@ -907,8 +908,10 @@ final class TJBench {
|
|||||||
try {
|
try {
|
||||||
temp = Integer.parseInt(argv[++i]);
|
temp = Integer.parseInt(argv[++i]);
|
||||||
} catch (NumberFormatException e) {}
|
} catch (NumberFormatException e) {}
|
||||||
if (temp >= 1)
|
if (temp >= 1 && (temp & (temp - 1)) == 0)
|
||||||
yuvAlign = temp;
|
yuvAlign = temp;
|
||||||
|
else
|
||||||
|
usage();
|
||||||
} else if (argv[i].equalsIgnoreCase("-subsamp") &&
|
} else if (argv[i].equalsIgnoreCase("-subsamp") &&
|
||||||
i < argv.length - 1) {
|
i < argv.length - 1) {
|
||||||
i++;
|
i++;
|
||||||
@@ -924,6 +927,8 @@ final class TJBench {
|
|||||||
subsamp = TJ.SAMP_420;
|
subsamp = TJ.SAMP_420;
|
||||||
else if (argv[i].equals("411"))
|
else if (argv[i].equals("411"))
|
||||||
subsamp = TJ.SAMP_411;
|
subsamp = TJ.SAMP_411;
|
||||||
|
else
|
||||||
|
usage();
|
||||||
} else if (argv[i].equalsIgnoreCase("-componly"))
|
} else if (argv[i].equalsIgnoreCase("-componly"))
|
||||||
compOnly = true;
|
compOnly = true;
|
||||||
else if (argv[i].equalsIgnoreCase("-nowrite"))
|
else if (argv[i].equalsIgnoreCase("-nowrite"))
|
||||||
|
|||||||
@@ -775,7 +775,8 @@ static void usage(char *progName)
|
|||||||
printf("-quiet = Output results in tabular rather than verbose format\n");
|
printf("-quiet = Output results in tabular rather than verbose format\n");
|
||||||
printf("-yuv = Compress from/decompress to intermediate planar YUV images\n");
|
printf("-yuv = Compress from/decompress to intermediate planar YUV images\n");
|
||||||
printf("-yuvpad <p> = The number of bytes by which each row in each plane of an\n");
|
printf("-yuvpad <p> = The number of bytes by which each row in each plane of an\n");
|
||||||
printf(" intermediate YUV image is evenly divisible [default = 1]\n");
|
printf(" intermediate YUV image is evenly divisible (must be a power of 2)\n");
|
||||||
|
printf(" [default = 1]\n");
|
||||||
printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
|
printf("-scale M/N = When decompressing, scale the width/height of the JPEG image by a\n");
|
||||||
printf(" factor of M/N (M/N = ");
|
printf(" factor of M/N (M/N = ");
|
||||||
for (i = 0; i < nsf; i++) {
|
for (i = 0; i < nsf; i++) {
|
||||||
@@ -940,7 +941,8 @@ int main(int argc, char *argv[])
|
|||||||
} else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) {
|
} else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) {
|
||||||
int tempi = atoi(argv[++i]);
|
int tempi = atoi(argv[++i]);
|
||||||
|
|
||||||
if (tempi >= 1) yuvAlign = tempi;
|
if (tempi >= 1 && (tempi & (tempi - 1)) == 0) yuvAlign = tempi;
|
||||||
|
else usage(argv[0]);
|
||||||
} else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) {
|
} else if (!strcasecmp(argv[i], "-subsamp") && i < argc - 1) {
|
||||||
i++;
|
i++;
|
||||||
if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY;
|
if (toupper(argv[i][0]) == 'G') subsamp = TJSAMP_GRAY;
|
||||||
@@ -953,6 +955,7 @@ int main(int argc, char *argv[])
|
|||||||
case 440: subsamp = TJSAMP_440; break;
|
case 440: subsamp = TJSAMP_440; break;
|
||||||
case 420: subsamp = TJSAMP_420; break;
|
case 420: subsamp = TJSAMP_420; break;
|
||||||
case 411: subsamp = TJSAMP_411; break;
|
case 411: subsamp = TJSAMP_411; break;
|
||||||
|
default: usage(argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(argv[i], "-componly"))
|
} else if (!strcasecmp(argv[i], "-componly"))
|
||||||
|
|||||||
Reference in New Issue
Block a user