Skip to content

Commit 7f69b79

Browse files
committed
New XpressHuffman implements IBlockDecompressor
1 parent c4782a3 commit 7f69b79

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

Library/DiscUtils.Core/Compression/XpressHuffman.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ namespace DiscUtils.Compression;
77
/// <summary>
88
/// XPRESS Huffman decompressor that operates directly on spans.
99
/// </summary>
10-
public static class XpressHuffman
10+
public class XpressHuffman : IBlockDecompressor
1111
{
1212
private const int SymbolCount = 512;
1313
private const int MaxCodeLength = 15;
1414
private const int FastBits = 10;
1515

16+
public static XpressHuffman Default => field ??= new();
17+
18+
int IBlockDecompressor.BlockSize { get; set; }
19+
1620
/// <summary>
1721
/// Decompresses an XPRESS Huffman block into a caller-provided destination buffer.
1822
/// </summary>
@@ -362,6 +366,9 @@ private static bool CopyMatch(Span<byte> destination, ref int dstPos, int distan
362366
return true;
363367
}
364368

369+
bool IBlockDecompressor.TryDecompress(ReadOnlySpan<byte> source, Span<byte> decompressed, out int decompressedSize)
370+
=> TryDecompress(source, decompressed, out _, out decompressedSize);
371+
365372
private ref struct XpressBitReader
366373
{
367374
private readonly ReadOnlySpan<byte> _source;

Library/DiscUtils.Core/Compression/XpressLz77.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace DiscUtils.Compression;
66

77
public sealed class XpressLz77 : IBlockDecompressor
88
{
9-
public static XpressLz77 Default { get; } = new();
9+
public static XpressLz77 Default => field ??= new();
1010

1111
int IBlockDecompressor.BlockSize { get; set; }
1212

0 commit comments

Comments
 (0)