IFF: support for ZIP compressed RGFX

This commit is contained in:
Mirco Miranda
2026-07-10 11:20:36 +02:00
parent 215305fa4b
commit 7e14d5616f
17 changed files with 51 additions and 1 deletions

View File

@@ -3501,6 +3501,17 @@ QByteArray RBODChunk::strideRead(QIODevice *d, qint32 y, const RGHDChunk *header
for (auto nextPos = nextChunkPos(); !d->atEnd() && d->pos() < nextPos && planes.size() < readSize;) {
if (header->compression() == RGHDChunk::Compression::Uncompressed) {
planes = d->read(readSize);
} else if (header->compression() == RGHDChunk::Compression::Zip) {
if (_readBuffer.isEmpty()) {
auto size = nextPos - d->pos();
if (size < kMaxQVectorSize) {
// I have no control over qUncompress() so, I have to decompress the whole chunk
_readBuffer = qUncompress(deviceRead(d, size));
// Reset the position to avoid falling into the `d->pos() < nextPos` check
seek(d, 0);
}
}
planes = _readBuffer.mid(y * readSize, readSize);
} else {
qCDebug(LOG_IFFPLUGIN) << "RBODChunk::strideRead(): unknown compression" << header->compression();
}
@@ -3514,6 +3525,7 @@ QByteArray RBODChunk::strideRead(QIODevice *d, qint32 y, const RGHDChunk *header
bool RBODChunk::resetStrideRead(QIODevice *d) const
{
_readBuffer.clear();
return seek(d);
}

View File

@@ -1964,6 +1964,9 @@ private:
QByteArray deinterleave(const QByteArray &planes, qint32 y, const RGHDChunk *header, const RSCMChunk *rcsm = nullptr, const RCOLChunk *rcol = nullptr) const;
quint32 strideSize(const RGHDChunk *header) const;
private:
mutable QByteArray _readBuffer;
};