TJ: Calc. xformed buf sizes based on dst. subsamp
With respect to tj3Transform(), this addresses an oversight from
bb1d540a80.
Note to self: A convenience function/method for computing the worst-case
transformed JPEG size for a particular transform would be nice.
This commit is contained in:
@@ -629,6 +629,22 @@ final class TJBench {
|
||||
}
|
||||
|
||||
tsubsamp = subsamp;
|
||||
if ((xformOpt & TJTransform.OPT_GRAY) != 0)
|
||||
tsubsamp = TJ.SAMP_GRAY;
|
||||
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
||||
xformOp == TJTransform.OP_TRANSVERSE ||
|
||||
xformOp == TJTransform.OP_ROT90 ||
|
||||
xformOp == TJTransform.OP_ROT270) {
|
||||
if (tsubsamp == TJ.SAMP_422)
|
||||
tsubsamp = TJ.SAMP_440;
|
||||
else if (tsubsamp == TJ.SAMP_440)
|
||||
tsubsamp = TJ.SAMP_422;
|
||||
else if (tsubsamp == TJ.SAMP_411)
|
||||
tsubsamp = TJ.SAMP_441;
|
||||
else if (tsubsamp == TJ.SAMP_441)
|
||||
tsubsamp = TJ.SAMP_411;
|
||||
}
|
||||
|
||||
if (doTile || xformOp != TJTransform.OP_NONE || xformOpt != 0 ||
|
||||
customFilter != null) {
|
||||
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
||||
@@ -641,40 +657,22 @@ final class TJBench {
|
||||
if (xformOp != TJTransform.OP_NONE &&
|
||||
xformOp != TJTransform.OP_TRANSPOSE && subsamp == TJ.SAMP_UNKNOWN)
|
||||
throw new Exception("Could not determine subsampling level of JPEG image");
|
||||
if ((xformOpt & TJTransform.OPT_GRAY) != 0)
|
||||
tsubsamp = TJ.SAMP_GRAY;
|
||||
if (xformOp == TJTransform.OP_HFLIP ||
|
||||
xformOp == TJTransform.OP_TRANSVERSE ||
|
||||
xformOp == TJTransform.OP_ROT90 ||
|
||||
xformOp == TJTransform.OP_ROT180)
|
||||
tw = tw - (tw % TJ.getMCUWidth(tsubsamp));
|
||||
if (xformOp == TJTransform.OP_VFLIP ||
|
||||
xformOp == TJTransform.OP_ROT180)
|
||||
th = th - (th % TJ.getMCUHeight(tsubsamp));
|
||||
if (xformOp == TJTransform.OP_TRANSVERSE ||
|
||||
xformOp == TJTransform.OP_ROT90)
|
||||
tw = tw - (tw % TJ.getMCUHeight(tsubsamp));
|
||||
if (xformOp == TJTransform.OP_TRANSVERSE ||
|
||||
xformOp == TJTransform.OP_TRANSVERSE ||
|
||||
xformOp == TJTransform.OP_ROT180 ||
|
||||
xformOp == TJTransform.OP_ROT270)
|
||||
th = th - (th % TJ.getMCUWidth(tsubsamp));
|
||||
th = th - (th % TJ.getMCUHeight(tsubsamp));
|
||||
tntilesw = (tw + ttilew - 1) / ttilew;
|
||||
tntilesh = (th + ttileh - 1) / ttileh;
|
||||
|
||||
if (xformOp == TJTransform.OP_TRANSPOSE ||
|
||||
xformOp == TJTransform.OP_TRANSVERSE ||
|
||||
xformOp == TJTransform.OP_ROT90 ||
|
||||
xformOp == TJTransform.OP_ROT270) {
|
||||
if (tsubsamp == TJ.SAMP_422)
|
||||
tsubsamp = TJ.SAMP_440;
|
||||
else if (tsubsamp == TJ.SAMP_440)
|
||||
tsubsamp = TJ.SAMP_422;
|
||||
else if (tsubsamp == TJ.SAMP_411)
|
||||
tsubsamp = TJ.SAMP_441;
|
||||
else if (tsubsamp == TJ.SAMP_441)
|
||||
tsubsamp = TJ.SAMP_411;
|
||||
}
|
||||
|
||||
TJTransform[] t = new TJTransform[tntilesw * tntilesh];
|
||||
jpegBufs =
|
||||
new byte[tntilesw * tntilesh][TJ.bufSize(ttilew, ttileh, subsamp)];
|
||||
new byte[tntilesw * tntilesh][TJ.bufSize(ttilew, ttileh, tsubsamp)];
|
||||
|
||||
for (y = 0, tile = 0; y < th; y += ttileh) {
|
||||
for (x = 0; x < tw; x += ttilew, tile++) {
|
||||
@@ -737,7 +735,7 @@ final class TJBench {
|
||||
} else {
|
||||
if (quiet == 1)
|
||||
System.out.print("N/A N/A ");
|
||||
jpegBufs = new byte[1][TJ.bufSize(ttilew, ttileh, subsamp)];
|
||||
jpegBufs = new byte[1][TJ.bufSize(ttilew, ttileh, tsubsamp)];
|
||||
jpegSizes = new int[1];
|
||||
jpegBufs[0] = srcBuf;
|
||||
jpegSizes[0] = srcSize;
|
||||
|
||||
Reference in New Issue
Block a user