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:
DRC
2023-01-18 15:31:04 -06:00
parent fb15efe94f
commit 28c2e60770
2 changed files with 12 additions and 4 deletions

View File

@@ -717,7 +717,8 @@ final class TJBench {
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("-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.print(" factor of M/N (M/N = ");
for (i = 0; i < nsf; i++) {
@@ -907,8 +908,10 @@ final class TJBench {
try {
temp = Integer.parseInt(argv[++i]);
} catch (NumberFormatException e) {}
if (temp >= 1)
if (temp >= 1 && (temp & (temp - 1)) == 0)
yuvAlign = temp;
else
usage();
} else if (argv[i].equalsIgnoreCase("-subsamp") &&
i < argv.length - 1) {
i++;
@@ -924,6 +927,8 @@ final class TJBench {
subsamp = TJ.SAMP_420;
else if (argv[i].equals("411"))
subsamp = TJ.SAMP_411;
else
usage();
} else if (argv[i].equalsIgnoreCase("-componly"))
compOnly = true;
else if (argv[i].equalsIgnoreCase("-nowrite"))