LzmaEnc.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* LzmaEnc.h -- LZMA Encoder
  2. : Igor Pavlov : Public domain */
  3. #ifndef ZIP7_INC_LZMA_ENC_H
  4. #define ZIP7_INC_LZMA_ENC_H
  5. #include "7zTypes.h"
  6. EXTERN_C_BEGIN
  7. #define LZMA_PROPS_SIZE 5
  8. typedef struct
  9. {
  10. int level; /* 0 <= level <= 9 */
  11. UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
  12. (1 << 12) <= dictSize <= (3 << 29) for 64-bit version
  13. default = (1 << 24) */
  14. int lc; /* 0 <= lc <= 8, default = 3 */
  15. int lp; /* 0 <= lp <= 4, default = 0 */
  16. int pb; /* 0 <= pb <= 4, default = 2 */
  17. int algo; /* 0 - fast, 1 - normal, default = 1 */
  18. int fb; /* 5 <= fb <= 273, default = 32 */
  19. int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
  20. int numHashBytes; /* 2, 3 or 4, default = 4 */
  21. unsigned numHashOutBits; /* default = ? */
  22. UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
  23. unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
  24. int numThreads; /* 1 or 2, default = 2 */
  25. // int _pad;
  26. Int32 affinityGroup;
  27. UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1.
  28. Encoder uses this value to reduce dictionary size */
  29. UInt64 affinity;
  30. UInt64 affinityInGroup;
  31. } CLzmaEncProps;
  32. void LzmaEncProps_Init(CLzmaEncProps *p);
  33. void LzmaEncProps_Normalize(CLzmaEncProps *p);
  34. UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
  35. /* ---------- CLzmaEncHandle Interface ---------- */
  36. /* LzmaEnc* functions can return the following exit codes:
  37. SRes:
  38. SZ_OK - OK
  39. SZ_ERROR_MEM - Memory allocation error
  40. SZ_ERROR_PARAM - Incorrect paramater in props
  41. SZ_ERROR_WRITE - ISeqOutStream write callback error
  42. SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
  43. SZ_ERROR_PROGRESS - some break from progress callback
  44. SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
  45. */
  46. typedef struct CLzmaEnc CLzmaEnc;
  47. typedef CLzmaEnc * CLzmaEncHandle;
  48. // Z7_DECLARE_HANDLE(CLzmaEncHandle)
  49. CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
  50. void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  51. SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
  52. void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize);
  53. SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
  54. unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
  55. SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStreamPtr outStream, ISeqInStreamPtr inStream,
  56. ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  57. SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  58. int writeEndMark, ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  59. /* ---------- One Call Interface ---------- */
  60. SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  61. const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
  62. ICompressProgressPtr progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  63. EXTERN_C_END
  64. #endif