TJBench: Require known subsamp type w/tiled decomp
(oversight from 386ec0abc7)
Tiled decompression will ultimately fail if the subsampling type of the
JPEG input image is unknown, but the C version of TJBench needs to fail
earlier in order to avoid using -1 (TJSAMP_UNKNOWN) as an array index
for tjMCUWidth[]/tjMCUHeight[]. The Java version now fails earlier as
well, although there is no benefit to that other than making the error
message less cryptic.
This commit is contained in:
@@ -530,7 +530,7 @@ final class TJBench {
|
|||||||
// Original image
|
// Original image
|
||||||
int w = 0, h = 0, ntilesw = 1, ntilesh = 1, subsamp = -1, cs = -1;
|
int w = 0, h = 0, ntilesw = 1, ntilesh = 1, subsamp = -1, cs = -1;
|
||||||
// Transformed image
|
// Transformed image
|
||||||
int minTile, tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
|
int minTile = 16, tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
|
||||||
|
|
||||||
FileInputStream fis = new FileInputStream(fileName);
|
FileInputStream fis = new FileInputStream(fileName);
|
||||||
if (fis.getChannel().size() > (long)Integer.MAX_VALUE)
|
if (fis.getChannel().size() > (long)Integer.MAX_VALUE)
|
||||||
@@ -593,7 +593,11 @@ final class TJBench {
|
|||||||
precision, formatName(subsamp, cs), PIXFORMATSTR[pf],
|
precision, formatName(subsamp, cs), PIXFORMATSTR[pf],
|
||||||
bottomUp ? "Bottom-up" : "Top-down");
|
bottomUp ? "Bottom-up" : "Top-down");
|
||||||
|
|
||||||
|
if (doTile) {
|
||||||
|
if (subsamp == TJ.SAMP_UNKNOWN)
|
||||||
|
throw new Exception("Could not determine subsampling level of JPEG image");
|
||||||
minTile = Math.max(TJ.getMCUWidth(subsamp), TJ.getMCUHeight(subsamp));
|
minTile = Math.max(TJ.getMCUWidth(subsamp), TJ.getMCUHeight(subsamp));
|
||||||
|
}
|
||||||
for (int tilew = doTile ? minTile : w, tileh = doTile ? minTile : h; ;
|
for (int tilew = doTile ? minTile : w, tileh = doTile ? minTile : h; ;
|
||||||
tilew *= 2, tileh *= 2) {
|
tilew *= 2, tileh *= 2) {
|
||||||
if (tilew > w)
|
if (tilew > w)
|
||||||
|
|||||||
@@ -617,7 +617,7 @@ static int decompTest(char *fileName)
|
|||||||
int ps = tjPixelSize[pf], tile, row, col, i, iter, retval = 0, decompsrc = 0;
|
int ps = tjPixelSize[pf], tile, row, col, i, iter, retval = 0, decompsrc = 0;
|
||||||
char *temp = NULL, tempStr[80], tempStr2[80];
|
char *temp = NULL, tempStr[80], tempStr2[80];
|
||||||
/* Original image */
|
/* Original image */
|
||||||
int w = 0, h = 0, minTile, tilew, tileh, ntilesw = 1, ntilesh = 1,
|
int w = 0, h = 0, minTile = 16, tilew, tileh, ntilesw = 1, ntilesh = 1,
|
||||||
subsamp = -1, cs = -1;
|
subsamp = -1, cs = -1;
|
||||||
/* Transformed image */
|
/* Transformed image */
|
||||||
int tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
|
int tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
|
||||||
@@ -697,7 +697,12 @@ static int decompTest(char *fileName)
|
|||||||
formatName(subsamp, cs, tempStr), pixFormatStr[pf],
|
formatName(subsamp, cs, tempStr), pixFormatStr[pf],
|
||||||
bottomUp ? "Bottom-up" : "Top-down");
|
bottomUp ? "Bottom-up" : "Top-down");
|
||||||
|
|
||||||
|
if (doTile) {
|
||||||
|
if (subsamp == TJSAMP_UNKNOWN)
|
||||||
|
THROW("transforming",
|
||||||
|
"Could not determine subsampling level of JPEG image");
|
||||||
minTile = max(tjMCUWidth[subsamp], tjMCUHeight[subsamp]);
|
minTile = max(tjMCUWidth[subsamp], tjMCUHeight[subsamp]);
|
||||||
|
}
|
||||||
for (tilew = doTile ? minTile : w, tileh = doTile ? minTile : h; ;
|
for (tilew = doTile ? minTile : w, tileh = doTile ? minTile : h; ;
|
||||||
tilew *= 2, tileh *= 2) {
|
tilew *= 2, tileh *= 2) {
|
||||||
if (tilew > w) tilew = w;
|
if (tilew > w) tilew = w;
|
||||||
|
|||||||
Reference in New Issue
Block a user