LzmaEnc.h 3.0 KB

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