Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.1 KiB

  1. /* Lzma86.h -- LZMA + x86 (BCJ) Filter
  2. 2013-01-18 : Igor Pavlov : Public domain */
  3. #ifndef __LZMA86_H
  4. #define __LZMA86_H
  5. #include "7zTypes.h"
  6. EXTERN_C_BEGIN
  7. #define LZMA86_SIZE_OFFSET (1 + 5)
  8. #define LZMA86_HEADER_SIZE (LZMA86_SIZE_OFFSET + 8)
  9. /*
  10. It's an example for LZMA + x86 Filter use.
  11. You can use .lzma86 extension, if you write that stream to file.
  12. .lzma86 header adds one additional byte to standard .lzma header.
  13. .lzma86 header (14 bytes):
  14. Offset Size Description
  15. 0 1 = 0 - no filter, pure LZMA
  16. = 1 - x86 filter + LZMA
  17. 1 1 lc, lp and pb in encoded form
  18. 2 4 dictSize (little endian)
  19. 6 8 uncompressed size (little endian)
  20. Lzma86_Encode
  21. -------------
  22. level - compression level: 0 <= level <= 9, the default value for "level" is 5.
  23. dictSize - The dictionary size in bytes. The maximum value is
  24. 128 MB = (1 << 27) bytes for 32-bit version
  25. 1 GB = (1 << 30) bytes for 64-bit version
  26. The default value is 16 MB = (1 << 24) bytes, for level = 5.
  27. It's recommended to use the dictionary that is larger than 4 KB and
  28. that can be calculated as (1 << N) or (3 << N) sizes.
  29. For better compression ratio dictSize must be >= inSize.
  30. filterMode:
  31. SZ_FILTER_NO - no Filter
  32. SZ_FILTER_YES - x86 Filter
  33. SZ_FILTER_AUTO - it tries both alternatives to select best.
  34. Encoder will use 2 or 3 passes:
  35. 2 passes when FILTER_NO provides better compression.
  36. 3 passes when FILTER_YES provides better compression.
  37. Lzma86Encode allocates Data with MyAlloc functions.
  38. RAM Requirements for compressing:
  39. RamSize = dictionarySize * 11.5 + 6MB + FilterBlockSize
  40. filterMode FilterBlockSize
  41. SZ_FILTER_NO 0
  42. SZ_FILTER_YES inSize
  43. SZ_FILTER_AUTO inSize
  44. Return code:
  45. SZ_OK - OK
  46. SZ_ERROR_MEM - Memory allocation error
  47. SZ_ERROR_PARAM - Incorrect paramater
  48. SZ_ERROR_OUTPUT_EOF - output buffer overflow
  49. SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
  50. */
  51. enum ESzFilterMode
  52. {
  53. SZ_FILTER_NO,
  54. SZ_FILTER_YES,
  55. SZ_FILTER_AUTO
  56. };
  57. SRes Lzma86_Encode(Byte *dest, size_t *destLen, const Byte *src, size_t srcLen,
  58. int level, UInt32 dictSize, int filterMode);
  59. /*
  60. Lzma86_GetUnpackSize:
  61. In:
  62. src - input data
  63. srcLen - input data size
  64. Out:
  65. unpackSize - size of uncompressed stream
  66. Return code:
  67. SZ_OK - OK
  68. SZ_ERROR_INPUT_EOF - Error in headers
  69. */
  70. SRes Lzma86_GetUnpackSize(const Byte *src, SizeT srcLen, UInt64 *unpackSize);
  71. /*
  72. Lzma86_Decode:
  73. In:
  74. dest - output data
  75. destLen - output data size
  76. src - input data
  77. srcLen - input data size
  78. Out:
  79. destLen - processed output size
  80. srcLen - processed input size
  81. Return code:
  82. SZ_OK - OK
  83. SZ_ERROR_DATA - Data error
  84. SZ_ERROR_MEM - Memory allocation error
  85. SZ_ERROR_UNSUPPORTED - unsupported file
  86. SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer
  87. */
  88. SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen);
  89. EXTERN_C_END
  90. #endif