TallyLit() public method

Add literal to buffer
public TallyLit ( int literal ) : bool
literal int Literal value to add to buffer.
return bool
        /// <summary>
        /// Set the deflate level (0-9)
        /// </summary>
        /// <param name="level">The value to set the level to.</param>
        public void SetLevel(int level)
        {
            if ((level < 0) || (level > 9))
            {
                throw new ArgumentOutOfRangeException("level");
            }

            goodLength = DeflaterConstants.GOOD_LENGTH[level];
            max_lazy   = DeflaterConstants.MAX_LAZY[level];
            niceLength = DeflaterConstants.NICE_LENGTH[level];
            max_chain  = DeflaterConstants.MAX_CHAIN[level];

            if (DeflaterConstants.COMPR_FUNC[level] != compressionFunction)
            {
            #if DebugDeflation
                if (DeflaterConstants.DEBUGGING)
                {
                    Console.WriteLine("Change from " + compressionFunction + " to "
                                      + DeflaterConstants.COMPR_FUNC[level]);
                }
            #endif
                switch (compressionFunction)
                {
                case DEFLATE_STORED:
                    if (strstart > blockStart)
                    {
                        huffman.FlushStoredBlock(window, blockStart,
                                                 strstart - blockStart, false);
                        blockStart = strstart;
                    }
                    UpdateHash();
                    break;

                case DEFLATE_FAST:
                    if (strstart > blockStart)
                    {
                        huffman.FlushBlock(window, blockStart, strstart - blockStart,
                                           false);
                        blockStart = strstart;
                    }
                    break;

                case DEFLATE_SLOW:
                    if (prevAvailable)
                    {
                        huffman.TallyLit(window[strstart - 1] & 0xff);
                    }
                    if (strstart > blockStart)
                    {
                        huffman.FlushBlock(window, blockStart, strstart - blockStart, false);
                        blockStart = strstart;
                    }
                    prevAvailable = false;
                    matchLen      = MIN_MATCH - 1;
                    break;
                }
                compressionFunction = COMPR_FUNC[level];
            }
        }
Beispiel #2
0
        /// <summary>
        /// Set the deflate level (0-9)
        /// </summary>
        public void SetLevel(int lvl)
        {
            goodLength = GOOD_LENGTH[lvl];
            max_lazy   = MAX_LAZY[lvl];
            niceLength = NICE_LENGTH[lvl];
            max_chain  = MAX_CHAIN[lvl];

            if (COMPR_FUNC[lvl] != comprFunc)
            {
/*
 *                              if (DeflaterConstants.DEBUGGING) {
 *                                 Console.WriteLine("Change from " + comprFunc + " to "
 + DeflaterConstants.COMPR_FUNC[lvl]);
 +                              }
 */
                switch (comprFunc)
                {
                case DEFLATE_STORED:
                    if (strstart > blockStart)
                    {
                        huffman.FlushStoredBlock(window, blockStart,
                                                 strstart - blockStart, false);
                        blockStart = strstart;
                    }
                    UpdateHash();
                    break;

                case DEFLATE_FAST:
                    if (strstart > blockStart)
                    {
                        huffman.FlushBlock(window, blockStart, strstart - blockStart,
                                           false);
                        blockStart = strstart;
                    }
                    break;

                case DEFLATE_SLOW:
                    if (prevAvailable)
                    {
                        huffman.TallyLit(window[strstart - 1] & 0xff);
                    }
                    if (strstart > blockStart)
                    {
                        huffman.FlushBlock(window, blockStart, strstart - blockStart, false);
                        blockStart = strstart;
                    }
                    prevAvailable = false;
                    matchLen      = MIN_MATCH - 1;
                    break;
                }
                comprFunc = COMPR_FUNC[lvl];
            }
        }
Beispiel #3
0
        public void SetLevel(int level)
        {
            //IL_000e: Unknown result type (might be due to invalid IL or missing references)
            if (level < 0 || level > 9)
            {
                throw new ArgumentOutOfRangeException("level");
            }
            goodLength = DeflaterConstants.GOOD_LENGTH[level];
            max_lazy   = DeflaterConstants.MAX_LAZY[level];
            niceLength = DeflaterConstants.NICE_LENGTH[level];
            max_chain  = DeflaterConstants.MAX_CHAIN[level];
            if (DeflaterConstants.COMPR_FUNC[level] == compressionFunction)
            {
                return;
            }
            switch (compressionFunction)
            {
            case 0:
                if (strstart > blockStart)
                {
                    huffman.FlushStoredBlock(window, blockStart, strstart - blockStart, lastBlock: false);
                    blockStart = strstart;
                }
                UpdateHash();
                break;

            case 1:
                if (strstart > blockStart)
                {
                    huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock: false);
                    blockStart = strstart;
                }
                break;

            case 2:
                if (prevAvailable)
                {
                    huffman.TallyLit(window[strstart - 1] & 0xFF);
                }
                if (strstart > blockStart)
                {
                    huffman.FlushBlock(window, blockStart, strstart - blockStart, lastBlock: false);
                    blockStart = strstart;
                }
                prevAvailable = false;
                matchLen      = 2;
                break;
            }
            compressionFunction = DeflaterConstants.COMPR_FUNC[level];
        }