mirror of
https://github.com/aelurum/AssetStudio.git
synced 2025-05-27 22:00:23 -04:00
reduce memory usage
This commit is contained in:
parent
c8d08b2793
commit
9e195832ef
@ -135,33 +135,35 @@ namespace AssetStudio
|
|||||||
{
|
{
|
||||||
blocksInfoBytes = bundleReader.ReadBytes(compressedSize);
|
blocksInfoBytes = bundleReader.ReadBytes(compressedSize);
|
||||||
}
|
}
|
||||||
MemoryStream blocksInfoStream;
|
var blocksInfoCompressedStream = new MemoryStream(blocksInfoBytes);
|
||||||
|
MemoryStream blocksInfoDecompressedStream;
|
||||||
switch (flag & 0x3F)
|
switch (flag & 0x3F)
|
||||||
{
|
{
|
||||||
default://None
|
default://None
|
||||||
{
|
{
|
||||||
blocksInfoStream = new MemoryStream(blocksInfoBytes);
|
blocksInfoDecompressedStream = blocksInfoCompressedStream;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1://LZMA
|
case 1://LZMA
|
||||||
{
|
{
|
||||||
blocksInfoStream = SevenZipHelper.StreamDecompress(new MemoryStream(blocksInfoBytes));
|
blocksInfoDecompressedStream = SevenZipHelper.StreamDecompress(blocksInfoCompressedStream);
|
||||||
|
blocksInfoCompressedStream.Close();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2://LZ4
|
case 2://LZ4
|
||||||
case 3://LZ4HC
|
case 3://LZ4HC
|
||||||
{
|
{
|
||||||
byte[] uncompressedBytes = new byte[uncompressedSize];
|
byte[] uncompressedBytes = new byte[uncompressedSize];
|
||||||
using (var decoder = new Lz4DecoderStream(new MemoryStream(blocksInfoBytes)))
|
using (var decoder = new Lz4DecoderStream(blocksInfoCompressedStream))
|
||||||
{
|
{
|
||||||
decoder.Read(uncompressedBytes, 0, uncompressedSize);
|
decoder.Read(uncompressedBytes, 0, uncompressedSize);
|
||||||
}
|
}
|
||||||
blocksInfoStream = new MemoryStream(uncompressedBytes);
|
blocksInfoDecompressedStream = new MemoryStream(uncompressedBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
//case 4:LZHAM?
|
//case 4:LZHAM?
|
||||||
}
|
}
|
||||||
using (var blocksInfoReader = new EndianBinaryReader(blocksInfoStream))
|
using (var blocksInfoReader = new EndianBinaryReader(blocksInfoDecompressedStream))
|
||||||
{
|
{
|
||||||
blocksInfoReader.Position = 0x10;
|
blocksInfoReader.Position = 0x10;
|
||||||
int blockcount = blocksInfoReader.ReadInt32();
|
int blockcount = blocksInfoReader.ReadInt32();
|
||||||
@ -185,7 +187,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dataStream = new MemoryStream();
|
dataStream = new MemoryStream((int)uncompressedSizeSum);
|
||||||
}
|
}
|
||||||
foreach (var blockInfo in blockInfos)
|
foreach (var blockInfo in blockInfos)
|
||||||
{
|
{
|
||||||
@ -232,7 +234,7 @@ namespace AssetStudio
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file.stream = new MemoryStream();
|
file.stream = new MemoryStream((int)entryinfo_size);
|
||||||
}
|
}
|
||||||
dataStream.Position = entryinfo_offset;
|
dataStream.Position = entryinfo_offset;
|
||||||
dataStream.CopyTo(file.stream, entryinfo_size);
|
dataStream.CopyTo(file.stream, entryinfo_size);
|
||||||
|
Loading…
Reference in New Issue
Block a user