Add ZSTD support

This commit is contained in:
2025-10-14 11:30:24 +08:00
parent 7692cfdec7
commit 11a00be4ca
3 changed files with 123 additions and 2 deletions

View File

@@ -248,11 +248,22 @@ namespace GameRes.Formats.Circus
}
}
private Stream GetDecompressStream() {
long pos = m_input.Position;
uint header = m_input.ReadUInt32();
m_input.Position = pos;
if (header == 0xFD2FB528) {
var zstd = ZstdReader.Unpack(m_input.AsStream);
return new MemoryStream(zstd);
} else
return new ZLibStream(m_input.AsStream, CompressionMode.Decompress);
}
private void UnpackV2 ()
{
int pixel_size = m_bpp / 8;
int src_stride = m_width * pixel_size;
using (var zlib = new ZLibStream (m_input.AsStream, CompressionMode.Decompress, true))
using (var zlib = GetDecompressStream())
using (var src = new BinaryReader (zlib))
{
if (m_bpp >= 24)