Skip to content

Commit 7b8c16c

Browse files
author
Aaron Boxer
committed
T2: improved packet cache integration
1 parent a442dc5 commit 7b8c16c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/lib/jp2/t2/T2Decompress.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ bool T2Decompress::processPacket(TileCodingParams *tcp,
5252
auto cp = tileProcessor->m_cp;
5353
auto tilec = tileProcessor->tile->comps + currPi->compno;
5454
auto tilecBuffer = tilec->getBuffer();
55-
auto packetLengths = tileProcessor->pltMarkers;
56-
// we don't currently support PLM markers,
57-
// so we disable packet length markers if we have both PLT and PLM
58-
bool usePlt = packetLengths && !cp->plm_markers;
59-
uint32_t pltMarkerLen = 0;
60-
if (usePlt)
61-
pltMarkerLen = packetLengths->getNext();
6255
auto packetInfo = tileProcessor->packetInfoCache.get();
56+
if (!packetInfo->packetLength) {
57+
// we don't currently support PLM markers,
58+
// so we disable packet length markers if we have both PLT and PLM
59+
auto packetLengths = tileProcessor->pltMarkers;
60+
bool usePlt = packetLengths && !cp->plm_markers;
61+
if (usePlt)
62+
packetInfo->packetLength = packetLengths->getNext();
63+
}
6364
auto res = tilec->tileCompResolution + currPi->resno;
6465
auto skipPacket = currPi->layno >= tcp->num_layers_to_decompress
6566
|| currPi->resno >= tilec->resolutions_to_decompress;
@@ -82,7 +83,7 @@ bool T2Decompress::processPacket(TileCodingParams *tcp,
8283
}
8384
}
8485
}
85-
if (!skipPacket || !usePlt) {
86+
if (!skipPacket || !packetInfo->packetLength) {
8687
for (uint32_t bandIndex = 0; bandIndex < res->numTileBandWindows; ++bandIndex) {
8788
auto band = res->tileBand + bandIndex;
8889
if (band->isEmpty())
@@ -102,13 +103,11 @@ bool T2Decompress::processPacket(TileCodingParams *tcp,
102103
tilec->resolutions_decompressed = std::max<uint8_t>(currPi->resno,tilec->resolutions_decompressed);
103104
tileProcessor->tile->numDecompressedPackets++;
104105
} else {
105-
if (pltMarkerLen) {
106-
srcBuf->incrementCurrentChunkOffset(pltMarkerLen);
107-
packetInfo->packetLength = pltMarkerLen;
108-
} else {
106+
if (packetInfo->packetLength)
107+
srcBuf->incrementCurrentChunkOffset(packetInfo->packetLength);
108+
else
109109
if (!decompressPacket(tcp, currPi, srcBuf,packetInfo,true))
110110
return false;
111-
}
112111
}
113112
tileProcessor->tile->numProcessedPackets++;
114113
return true;

0 commit comments

Comments
 (0)