LzmaEnc.h 2.8 KB

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