mirror of
https://github.com/SabreTools/SabreTools.IO.git
synced 2026-05-07 21:14:05 +00:00
This change looks dramatic, but it's just separating out the already-split namespaces into separate top-level folders. In theory, every single one could be built into their own Nuget package. `SabreTools.IO.Meta` builds the normal Nuget package that is used by all other projects and includes all namespaces. `SabreTools.IO` builds to `SabreTools.IO.Common` to avoid overwriting issues on publish.
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
//#define Trace
|
|
|
|
// ParallelDeflateOutputStream.cs
|
|
// ------------------------------------------------------------------
|
|
//
|
|
// A DeflateStream that does compression only, it uses a
|
|
// divide-and-conquer approach with multiple threads to exploit multiple
|
|
// CPUs for the DEFLATE computation.
|
|
//
|
|
// last saved: <2011-July-31 14:49:40>
|
|
//
|
|
// ------------------------------------------------------------------
|
|
//
|
|
// Copyright (c) 2009-2011 by Dino Chiesa
|
|
// All rights reserved!
|
|
//
|
|
// This code module is part of DotNetZip, a zipfile class library.
|
|
//
|
|
// ------------------------------------------------------------------
|
|
//
|
|
// This code is licensed under the Microsoft Public License.
|
|
// See the file License.txt for the license details.
|
|
// More info on: http://dotnetzip.codeplex.com
|
|
//
|
|
// ------------------------------------------------------------------
|
|
|
|
#nullable disable
|
|
#pragma warning disable CS0649
|
|
namespace SabreTools.IO.Compression.Deflate
|
|
{
|
|
#pragma warning disable IDE0001
|
|
#pragma warning disable IDE0048
|
|
#pragma warning disable IDE2000
|
|
#pragma warning disable IDE2002
|
|
internal class WorkItem
|
|
{
|
|
public byte[] buffer;
|
|
public byte[] compressed;
|
|
public int crc;
|
|
public int index;
|
|
public int ordinal;
|
|
public int inputBytesAvailable;
|
|
public int compressedBytesAvailable;
|
|
public ZlibCodec compressor;
|
|
|
|
public WorkItem(int size,
|
|
SabreTools.IO.Compression.Deflate.CompressionLevel compressLevel,
|
|
CompressionStrategy strategy,
|
|
int ix)
|
|
{
|
|
this.buffer = new byte[size];
|
|
// alloc 5 bytes overhead for every block (margin of safety= 2)
|
|
int n = size + ((size / 32768) + 1) * 5 * 2;
|
|
this.compressed = new byte[n];
|
|
this.compressor = new ZlibCodec();
|
|
this.compressor.InitializeDeflate(compressLevel, false);
|
|
this.compressor.OutputBuffer = this.compressed;
|
|
this.compressor.InputBuffer = this.buffer;
|
|
this.index = ix;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|