TJBench: w/JPEG input imgs, set min tile= MCU size

When -tile is used with a JPEG input image, TJBench generates the tiles
using lossless cropping, which will fail if the cropping region doesn't
align with an MCU boundary.  Furthermore, there is no reason to avoid
8x8 tiles when decompressing 4:4:4 or grayscale JPEG images.
This commit is contained in:
DRC
2023-03-13 13:11:19 -05:00
parent 7313fe5aea
commit bc087d6aa9
2 changed files with 7 additions and 5 deletions

View File

@@ -499,7 +499,7 @@ final class TJBench {
// Original image
int w = 0, h = 0, ntilesw = 1, ntilesh = 1, subsamp = -1, cs = -1;
// Transformed image
int tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
int minTile, tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
FileInputStream fis = new FileInputStream(fileName);
if (fis.getChannel().size() > (long)Integer.MAX_VALUE)
@@ -541,7 +541,8 @@ final class TJBench {
(flags & TJ.FLAG_BOTTOMUP) != 0 ?
"Bottom-up" : "Top-down");
for (int tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ;
minTile = Math.max(TJ.getMCUWidth(subsamp), TJ.getMCUHeight(subsamp));
for (int tilew = doTile ? minTile : w, tileh = doTile ? minTile : h; ;
tilew *= 2, tileh *= 2) {
if (tilew > w)
tilew = w;

View File

@@ -534,8 +534,8 @@ static int decompTest(char *fileName)
int ps = tjPixelSize[pf], tile, row, col, i, iter, retval = 0, decompsrc = 0;
char *temp = NULL, tempStr[80], tempStr2[80];
/* Original image */
int w = 0, h = 0, tilew, tileh, ntilesw = 1, ntilesh = 1, subsamp = -1,
cs = -1;
int w = 0, h = 0, minTile, tilew, tileh, ntilesw = 1, ntilesh = 1,
subsamp = -1, cs = -1;
/* Transformed image */
int tw, th, ttilew, ttileh, tntilesw, tntilesh, tsubsamp;
@@ -580,7 +580,8 @@ static int decompTest(char *fileName)
formatName(subsamp, cs, tempStr), pixFormatStr[pf],
(flags & TJFLAG_BOTTOMUP) ? "Bottom-up" : "Top-down");
for (tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ;
minTile = max(tjMCUWidth[subsamp], tjMCUHeight[subsamp]);
for (tilew = doTile ? minTile : w, tileh = doTile ? minTile : h; ;
tilew *= 2, tileh *= 2) {
if (tilew > w) tilew = w;
if (tileh > h) tileh = h;