ResetDeflate() public method

Reset a codec for another deflation session.
Call this to reset the deflation state. For example if a thread is deflating non-consecutive blocks, you can call Reset() after the Deflate(Sync) of the first block and before the next Deflate(None) of the second block.
public ResetDeflate ( ) : void
return void
        private bool DeflateOneSegment(WorkItem workitem)
        {
            ZlibCodec compressor = workitem.compressor;

            compressor.ResetDeflate();
            compressor.NextIn            = 0;
            compressor.AvailableBytesIn  = workitem.inputBytesAvailable;
            compressor.NextOut           = 0;
            compressor.AvailableBytesOut = workitem.compressed.Length;
            do
            {
                compressor.Deflate(FlushType.None);
            }while (compressor.AvailableBytesIn > 0 || compressor.AvailableBytesOut == 0);
            compressor.Deflate(FlushType.Sync);
            workitem.compressedBytesAvailable = (int)compressor.TotalBytesOut;
            return(true);
        }
Exemplo n.º 2
0
        private bool DeflateOneSegment(WorkItem workitem)
        {
            ZlibCodec zlibCodec = workitem.compressor;
            int       num       = 0;

            zlibCodec.ResetDeflate();
            zlibCodec.NextIn            = 0;
            zlibCodec.AvailableBytesIn  = workitem.inputBytesAvailable;
            zlibCodec.NextOut           = 0;
            zlibCodec.AvailableBytesOut = workitem.compressed.Length;
            do
            {
                zlibCodec.Deflate(FlushType.None);
            }while (zlibCodec.AvailableBytesIn > 0 || zlibCodec.AvailableBytesOut == 0);
            num = zlibCodec.Deflate(FlushType.Sync);
            workitem.compressedBytesAvailable = (int)zlibCodec.TotalBytesOut;
            return(true);
        }
Exemplo n.º 3
0
        private static int DeflateOneSegment(WorkItem workitem)
        {
            ZlibCodec compressor = workitem.compressor;

            compressor.ResetDeflate();
            compressor.NextIn = 0;

            compressor.AvailableBytesIn = workitem.inputBytesAvailable;

            // step 1: deflate the buffer
            compressor.NextOut           = 0;
            compressor.AvailableBytesOut = workitem.compressed.Length;
            do
            {
                compressor.Deflate(FlushType.None);
            }while (compressor.AvailableBytesIn > 0 || compressor.AvailableBytesOut == 0);

            // step 2: flush (sync)
            int rc = compressor.Deflate(FlushType.Sync);

            workitem.compressedBytesAvailable = (int)compressor.TotalBytesOut;
            return(rc);
        }