internal static void WriteMatch(int matchLen, int matchPos, OutputBuffer output) { Debug.Assert(matchLen >= FastEncoderWindow.MinMatch && matchLen <= FastEncoderWindow.MaxMatch, "Illegal currentMatch length!"); // Get the code information for a match code uint codeInfo = FastEncoderStatics.FastEncoderLiteralCodeInfo[(FastEncoderStatics.NumChars + 1 - FastEncoderWindow.MinMatch) + matchLen]; int codeLen = (int)codeInfo & 31; Debug.Assert(codeLen != 0, "Invalid Match Length!"); if (codeLen <= 16) { output.WriteBits(codeLen, codeInfo >> 5); } else { output.WriteBits(16, (codeInfo >> 5) & 65535); output.WriteBits(codeLen - 16, codeInfo >> (5 + 16)); } // Get the code information for a distance code codeInfo = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)]; output.WriteBits((int)(codeInfo & 15), codeInfo >> 8); int extraBits = (int)(codeInfo >> 4) & 15; if (extraBits != 0) { output.WriteBits(extraBits, (uint)matchPos & FastEncoderStatics.BitMask[extraBits]); } }
public void GetBlock(DeflateInput input, OutputBuffer output, bool isFinal) { int count = 0; if (input != null) { count = Math.Min(input.Count, (output.FreeBytes - 5) - output.BitsInBuffer); if (count > 0xfffb) { count = 0xfffb; } } if (isFinal) { output.WriteBits(3, 1); } else { output.WriteBits(3, 0); } output.FlushBits(); this.WriteLenNLen((ushort) count, output); if ((input != null) && (count > 0)) { output.WriteBytes(input.Buffer, input.StartIndex, count); input.ConsumeBytes(count); } }
public void GetBlock(DeflateInput input, OutputBuffer output, bool isFinal) { int count = 0; if (input != null) { count = Math.Min(input.Count, (output.FreeBytes - 5) - output.BitsInBuffer); if (count > 0xfffb) { count = 0xfffb; } } if (isFinal) { output.WriteBits(3, 1); } else { output.WriteBits(3, 0); } output.FlushBits(); this.WriteLenNLen((ushort)count, output); if ((input != null) && (count > 0)) { output.WriteBytes(input.Buffer, input.StartIndex, count); input.ConsumeBytes(count); } }
static internal void WriteMatch(int matchLen, int matchPos, OutputBuffer output) { Debug.Assert(matchLen >= FastEncoderWindow.MinMatch && matchLen <= FastEncoderWindow.MaxMatch, "Illegal currentMatch length!"); Debug.WriteLineIf(CompressionTracingSwitch.Verbose, String.Format(CultureInfo.InvariantCulture, "Match: {0}:{1}", matchLen, matchPos), "Compression"); // Get the code information for a match code uint codeInfo = FastEncoderStatics.FastEncoderLiteralCodeInfo[(FastEncoderStatics.NumChars + 1 - FastEncoderWindow.MinMatch) + matchLen]; int codeLen = (int)codeInfo & 31; Debug.Assert(codeLen != 0, "Invalid Match Length!"); if (codeLen <= 16) { output.WriteBits(codeLen, codeInfo >> 5); } else { output.WriteBits(16, (codeInfo >> 5) & 65535); output.WriteBits(codeLen - 16, codeInfo >> (5 + 16)); } // Get the code information for a distance code codeInfo = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)]; output.WriteBits((int)(codeInfo & 15), codeInfo >> 8); int extraBits = (int)(codeInfo >> 4) & 15; if (extraBits != 0) { output.WriteBits(extraBits, (uint)matchPos & FastEncoderStatics.BitMask[extraBits]); } }
/// <summary> /// null input means write an empty payload with formatting info. This is needed for the final block. /// </summary> public void GetBlock(DeflateInput input, OutputBuffer output, bool isFinal) { Debug.Assert(output != null); Debug.Assert(output.FreeBytes >= PaddingSize); // determine number of bytes to write int count = 0; if (input != null) { // allow space for padding and bits not yet flushed to buffer count = Math.Min(input.Count, output.FreeBytes - PaddingSize - output.BitsInBuffer); // we don't expect the output buffer to ever be this big (currently 4K), but we'll check this // just in case that changes. if (count > MaxUncompressedBlockSize - PaddingSize) { count = MaxUncompressedBlockSize - PaddingSize; } } // write header and flush bits if (isFinal) { output.WriteBits( FastEncoderStatics.BFinalNoCompressionHeaderBitCount, FastEncoderStatics.BFinalNoCompressionHeader); } else { output.WriteBits( FastEncoderStatics.NoCompressionHeaderBitCount, FastEncoderStatics.NoCompressionHeader); } // now we're aligned output.FlushBits(); // write len, nlen WriteLenNLen((ushort)count, output); // write uncompressed bytes if (input != null && count > 0) { output.WriteBytes(input.Buffer, input.StartIndex, count); input.ConsumeBytes(count); } }
private void WriteEndOfBlock(OutputBuffer output) { uint num = FastEncoderStatics.FastEncoderLiteralCodeInfo[0x100]; int n = ((int)num) & 0x1f; output.WriteBits(n, num >> 5); }
// Output the block type and tree structure for our hard-coded trees. // Contains following data: // "final" block flag 1 bit // BLOCKTYPE_DYNAMIC 2 bits // FastEncoderLiteralTreeLength // FastEncoderDistanceTreeLength // static internal void WriteDeflatePreamble(OutputBuffer output) { //Debug.Assert( bitCount == 0, "bitCount must be zero before writing tree bit!"); output.WriteBytes(FastEncoderStatics.FastEncoderTreeStructureData, 0, FastEncoderStatics.FastEncoderTreeStructureData.Length); output.WriteBits(FastEncoderStatics.FastEncoderPostTreeBitCount, FastEncoderStatics.FastEncoderPostTreeBitBuf); }
static internal void WriteChar(byte b, OutputBuffer output) { Debug.WriteLineIf(CompressionTracingSwitch.Verbose, String.Format(CultureInfo.InvariantCulture, "Literal: {0}", b), "Compression"); uint code = FastEncoderStatics.FastEncoderLiteralCodeInfo[b]; output.WriteBits((int)code & 31, code >> 5); }
// null input means write an empty payload with formatting info. This is needed for the final block. public void GetBlock(DeflateInput input, OutputBuffer output, bool isFinal) { Debug.Assert(output != null); Debug.Assert(output.FreeBytes >= PaddingSize); // determine number of bytes to write int count = 0; if (input != null) { // allow space for padding and bits not yet flushed to buffer count = Math.Min(input.Count, output.FreeBytes - PaddingSize - output.BitsInBuffer); // we don't expect the output buffer to ever be this big (currently 4K), but we'll check this // just in case that changes. if (count > MaxUncompressedBlockSize - PaddingSize) { count = MaxUncompressedBlockSize - PaddingSize; } } // write header and flush bits if (isFinal) { output.WriteBits(FastEncoderStatics.BFinalNoCompressionHeaderBitCount, FastEncoderStatics.BFinalNoCompressionHeader); } else { output.WriteBits(FastEncoderStatics.NoCompressionHeaderBitCount, FastEncoderStatics.NoCompressionHeader); } // now we're aligned output.FlushBits(); // write len, nlen WriteLenNLen((ushort)count, output); // write uncompressed bytes if (input != null && count > 0) { output.WriteBytes(input.Buffer, input.StartIndex, count); input.ConsumeBytes(count); } }
private void WriteEndOfBlock(OutputBuffer output) { // The fast encoder outputs one long block, so it just needs to terminate this block const int EndOfBlockCode = 256; uint code_info = FastEncoderStatics.FastEncoderLiteralCodeInfo[EndOfBlockCode]; int code_len = (int)(code_info & 31); output.WriteBits(code_len, code_info >> 5); }
internal static void WriteMatch(int matchLen, int matchPos, OutputBuffer output) { uint num = FastEncoderStatics.FastEncoderLiteralCodeInfo[0xfe + matchLen]; int n = ((int)num) & 0x1f; if (n <= 0x10) { output.WriteBits(n, num >> 5); } else { output.WriteBits(0x10, (num >> 5) & 0xffff); output.WriteBits(n - 0x10, num >> 0x15); } num = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)]; output.WriteBits(((int)num) & 15, num >> 8); int num3 = ((int)(num >> 4)) & 15; if (num3 != 0) { output.WriteBits(num3, ((uint)matchPos) & FastEncoderStatics.BitMask[num3]); } }
internal static void WriteChar(byte b, OutputBuffer output) { uint code = FastEncoderStatics.FastEncoderLiteralCodeInfo[b]; output.WriteBits((int)code & 31, code >> 5); }
static internal void WriteChar(byte b, OutputBuffer output) { Debug.WriteLineIf(CompressionTracingSwitch.Verbose, String.Format(CultureInfo.InvariantCulture, "Literal: {0}", b ), "Compression"); uint code = FastEncoderStatics.FastEncoderLiteralCodeInfo[b]; output.WriteBits((int)code & 31, code >> 5); }
internal static void WriteChar(byte b, OutputBuffer output) { uint num = FastEncoderStatics.FastEncoderLiteralCodeInfo[b]; output.WriteBits(((int)num) & 0x1f, num >> 5); }
private void WriteEndOfBlock(OutputBuffer output) { uint num = FastEncoderStatics.FastEncoderLiteralCodeInfo[0x100]; int n = ((int) num) & 0x1f; output.WriteBits(n, num >> 5); }
internal static void WriteChar(byte b, OutputBuffer output) { uint num = FastEncoderStatics.FastEncoderLiteralCodeInfo[b]; output.WriteBits(((int) num) & 0x1f, num >> 5); }
internal static void WriteDeflatePreamble(OutputBuffer output) { output.WriteBytes(FastEncoderStatics.FastEncoderTreeStructureData, 0, FastEncoderStatics.FastEncoderTreeStructureData.Length); output.WriteBits(9, 0x22); }
static internal void WriteChar(byte b, OutputBuffer output) { uint code = FastEncoderStatics.FastEncoderLiteralCodeInfo[b]; output.WriteBits((int)code & 31, code >> 5); }
internal static void WriteMatch(int matchLen, int matchPos, OutputBuffer output) { uint num = FastEncoderStatics.FastEncoderLiteralCodeInfo[0xfe + matchLen]; int n = ((int) num) & 0x1f; if (n <= 0x10) { output.WriteBits(n, num >> 5); } else { output.WriteBits(0x10, (num >> 5) & 0xffff); output.WriteBits(n - 0x10, num >> 0x15); } num = FastEncoderStatics.FastEncoderDistanceCodeInfo[FastEncoderStatics.GetSlot(matchPos)]; output.WriteBits(((int) num) & 15, num >> 8); int num3 = ((int) (num >> 4)) & 15; if (num3 != 0) { output.WriteBits(num3, ((uint) matchPos) & FastEncoderStatics.BitMask[num3]); } }