TJBench/Java: Fix parsing of quality ranges

This commit is contained in:
DRC
2023-01-20 10:50:21 -06:00
parent 28c2e60770
commit b99e7590b0
2 changed files with 8 additions and 5 deletions

View File

@@ -45,6 +45,9 @@ image dimensions.
(`-DWITH_12BIT=1`) using an alpha-enabled output color space such as
`JCS_EXT_RGBA`, the alpha channel was set to 255 rather than 4095.
8. Fixed an issue whereby the Java version of TJBench did not accept a range of
quality values.
2.1.4
=====

View File

@@ -782,18 +782,18 @@ final class TJBench {
minArg = 2;
if (argv.length < minArg)
usage();
String[] quals = argv[1].split("-", 2);
try {
minQual = Integer.parseInt(argv[1]);
minQual = Integer.parseInt(quals[0]);
} catch (NumberFormatException e) {}
if (minQual < 1 || minQual > 100)
throw new Exception("Quality must be between 1 and 100.");
int dashIndex = argv[1].indexOf('-');
if (dashIndex > 0 && argv[1].length() > dashIndex + 1) {
if (quals.length > 1) {
try {
maxQual = Integer.parseInt(argv[1].substring(dashIndex + 1));
maxQual = Integer.parseInt(quals[1]);
} catch (NumberFormatException e) {}
}
if (maxQual < 1 || maxQual > 100)
if (maxQual < 1 || maxQual > 100 || maxQual < minQual)
maxQual = minQual;
}