Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some improvements to OME-TIFF write performance #4242

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public void close() throws IOException {
long nextPointer = index < allOffsets.length ? allOffsets[index] : 0;

saver.overwriteIFDOffset(in, allOffsets[mainIFDIndex], nextPointer);
saver.overwriteIFDValue(in, currentFullResolution, IFD.SUB_IFD, subIFDOffsets);
sbesson marked this conversation as resolved.
Show resolved Hide resolved
saver.overwriteIFDValue(in, allOffsets[mainIFDIndex], IFD.SUB_IFD, subIFDOffsets, true);
}

mainIFDIndex++;
Expand Down
12 changes: 7 additions & 5 deletions components/formats-bsd/src/loci/formats/tiff/TiffSaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -1176,15 +1176,13 @@ else if (isTiled) {
// return to original position
out.seek(stripStartPos);

ByteArrayOutputStream stripBuffer = new ByteArrayOutputStream();
long stripOffset = 0;
for (int i=0; i<strips.length; i++) {
out.seek(stripStartPos + stripOffset);
stripOffset += strips[i].length;
int index = interleaved ? i : (i / nChannels) * nChannels;
int c = interleaved ? 0 : i % nChannels;
int thisOffset = firstOffset + index + (c * tileCount);
offsets[thisOffset] = out.getFilePointer();
// byteCounts.set(thisOffset, new Long(strips[i].length));
offsets[thisOffset] = stripStartPos + stripOffset;
byteCounts[thisOffset] = strips[i].length;
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(String.format(
Expand All @@ -1193,8 +1191,12 @@ else if (isTiled) {
thisOffset + 1, totalTiles, byteCounts[thisOffset],
offsets[thisOffset]));
}
out.write(strips[i]);
stripBuffer.write(strips[i]);
stripOffset += strips[i].length;
}
stripBuffer.writeTo(out);
stripBuffer.close();
stripBuffer = null;
if (isTiled) {
ifd.putIFDValue(IFD.TILE_BYTE_COUNTS, byteCounts);
ifd.putIFDValue(IFD.TILE_OFFSETS, offsets);
Expand Down