LzwConstants.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. namespace ICSharpCode.SharpZipLib.Lzw
  2. {
  3. /// <summary>
  4. /// This class contains constants used for LZW
  5. /// </summary>
  6. sealed public class LzwConstants
  7. {
  8. /// <summary>
  9. /// Magic number found at start of LZW header: 0x1f 0x9d
  10. /// </summary>
  11. public const int MAGIC = 0x1f9d;
  12. /// <summary>
  13. /// Maximum number of bits per code
  14. /// </summary>
  15. public const int MAX_BITS = 16;
  16. /* 3rd header byte:
  17. * bit 0..4 Number of compression bits
  18. * bit 5 Extended header
  19. * bit 6 Free
  20. * bit 7 Block mode
  21. */
  22. /// <summary>
  23. /// Mask for 'number of compression bits'
  24. /// </summary>
  25. public const int BIT_MASK = 0x1f;
  26. /// <summary>
  27. /// Indicates the presence of a fourth header byte
  28. /// </summary>
  29. public const int EXTENDED_MASK = 0x20;
  30. //public const int FREE_MASK = 0x40;
  31. /// <summary>
  32. /// Reserved bits
  33. /// </summary>
  34. public const int RESERVED_MASK = 0x60;
  35. /// <summary>
  36. /// Block compression: if table is full and compression rate is dropping,
  37. /// clear the dictionary.
  38. /// </summary>
  39. public const int BLOCK_MODE_MASK = 0x80;
  40. /// <summary>
  41. /// LZW file header size (in bytes)
  42. /// </summary>
  43. public const int HDR_SIZE = 3;
  44. /// <summary>
  45. /// Initial number of bits per code
  46. /// </summary>
  47. public const int INIT_BITS = 9;
  48. LzwConstants()
  49. {
  50. }
  51. }
  52. }