示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DeflaterEngine"/> class.
        /// </summary>
        /// <param name="memoryAllocator">The memory allocator to use for buffer allocations.</param>
        /// <param name="strategy">The deflate strategy to use.</param>
        public DeflaterEngine(MemoryAllocator memoryAllocator, DeflateStrategy strategy)
        {
            this.huffman  = new DeflaterHuffman(memoryAllocator);
            this.Pending  = this.huffman.Pending;
            this.strategy = strategy;

            // Create pinned pointers to the various buffers to allow indexing
            // without bounds checks.
            this.windowMemoryOwner   = memoryAllocator.Allocate <byte>(2 * DeflaterConstants.WSIZE);
            this.window              = this.windowMemoryOwner.Memory;
            this.windowMemoryHandle  = this.window.Pin();
            this.pinnedWindowPointer = (byte *)this.windowMemoryHandle.Pointer;

            this.headMemoryOwner   = memoryAllocator.Allocate <short>(DeflaterConstants.HASH_SIZE);
            this.head              = this.headMemoryOwner.Memory;
            this.headMemoryHandle  = this.head.Pin();
            this.pinnedHeadPointer = (short *)this.headMemoryHandle.Pointer;

            this.prevMemoryOwner   = memoryAllocator.Allocate <short>(DeflaterConstants.WSIZE);
            this.prev              = this.prevMemoryOwner.Memory;
            this.prevMemoryHandle  = this.prev.Pin();
            this.pinnedPrevPointer = (short *)this.prevMemoryHandle.Pointer;

            // We start at index 1, to avoid an implementation deficiency, that
            // we cannot build a repeat pattern at index 0.
            this.blockStart = this.strstart = 1;
        }
示例#2
0
        public void setStrat(EDeflateCompressStrategy strat)
        {
            DeflateStrategy newDeflateStrategy = DeflateStrategy.Default;

            if (strat == EDeflateCompressStrategy.Filtered)
            {
                newDeflateStrategy = DeflateStrategy.Filtered;
            }
            else if (strat == EDeflateCompressStrategy.Huffman)
            {
                newDeflateStrategy = DeflateStrategy.HuffmanOnly;
            }
            else
            {
                newDeflateStrategy = DeflateStrategy.Default;
            }

            deflater.SetStrategy(newDeflateStrategy);
        }
示例#3
0
 /// <summary>
 /// Sets the compression strategy. Strategy is one of
 /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED.  For the exact
 /// position where the strategy is changed, the same as for
 /// SetLevel() applies.
 /// </summary>
 /// <param name="strategy">
 /// The new compression strategy.
 /// </param>
 public void SetStrategy(DeflateStrategy strategy)
 {
     engine.Strategy = strategy;
 }
 /// <summary>
 /// Sets the compression strategy. Strategy is one of
 /// DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED.  For the exact
 /// position where the strategy is changed, the same as for
 /// SetLevel() applies.
 /// </summary>
 /// <param name="strategy">
 /// The new compression strategy.
 /// </param>
 public void SetStrategy(DeflateStrategy strategy)
 {
     engine.Strategy = strategy;
 }
示例#5
0
 public void SetStrategy(DeflateStrategy stgy)
 {
     this.engine.Strategy = stgy;
 }