LzmaEnc.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* LzmaEnc.h -- LZMA Encoder
  2. 2017-07-27 : 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 <= (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. UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
  22. unsigned writeEndMark; /* 0 - do not write EOPM, 1 - write EOPM, default = 0 */
  23. int numThreads; /* 1 or 2, default = 2 */
  24. UInt64 reduceSize; /* estimated size of data that will be compressed. default = (UInt64)(Int64)-1.
  25. Encoder uses this value to reduce dictionary size */
  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. SRes:
  33. SZ_OK - OK
  34. SZ_ERROR_MEM - Memory allocation error
  35. SZ_ERROR_PARAM - Incorrect paramater in props
  36. SZ_ERROR_WRITE - ISeqOutStream write callback error
  37. SZ_ERROR_OUTPUT_EOF - output buffer overflow - version with (Byte *) output
  38. SZ_ERROR_PROGRESS - some break from progress callback
  39. SZ_ERROR_THREAD - error in multithreading functions (only for Mt version)
  40. */
  41. typedef void * CLzmaEncHandle;
  42. CLzmaEncHandle LzmaEnc_Create(ISzAllocPtr alloc);
  43. void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  44. SRes LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
  45. void LzmaEnc_SetDataSize(CLzmaEncHandle p, UInt64 expectedDataSiize);
  46. SRes LzmaEnc_WriteProperties(CLzmaEncHandle p, Byte *properties, SizeT *size);
  47. unsigned LzmaEnc_IsWriteEndMark(CLzmaEncHandle p);
  48. SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
  49. ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  50. SRes LzmaEnc_MemEncode(CLzmaEncHandle p, Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  51. int writeEndMark, ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  52. /* ---------- One Call Interface ---------- */
  53. SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  54. const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
  55. ICompressProgress *progress, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  56. EXTERN_C_END
  57. /* ---------- Streaming Interface ---------- */
  58. SRes LzmaEnc_Prepare(CLzmaEncHandle pp, ISeqOutStream *outStream, ISeqInStream *inStream, ISzAllocPtr alloc, ISzAllocPtr allocBig);
  59. SRes LzmaEnc_CodeOneBlock(CLzmaEncHandle pp, UInt32 maxPackSize, UInt32 maxUnpackSize);
  60. BoolInt LzmaEnc_IsFinished(CLzmaEncHandle pp);
  61. void LzmaEnc_Finish(CLzmaEncHandle pp);
  62. #endif