首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

熟悉LZMA SDK开发的请进,该如何处理

2012-04-23 
熟悉LZMA SDK开发的请进我想用里面的内存压缩和解压部分,请问谁有这部分相关的例子吗?我的SDK是LZMA SDK 9

熟悉LZMA SDK开发的请进
我想用里面的内存压缩和解压部分,请问谁有这部分相关的例子吗?我的SDK是LZMA SDK 9.20。里面没有内存压缩的例子。主要是关于LzmaEncode函数各个参数怎么。我试了很多次都感觉不怎么对。函数原型如下
SRes LzmaEncode(Byte *dest, SizeT *destLen, const Byte *src, SizeT srcLen,
  const CLzmaEncProps *props, Byte *propsEncoded, SizeT *propsSize, int writeEndMark,
  ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig)
props,propsEncoded,propsSize这3个参数到底是啥?程序没任何说明

[解决办法]
Interface:
int LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen,
const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, 
ELzmaStatus *status, ISzAlloc *alloc);
In: 
dest - output data
destLen - output data size
src - input data
srcLen - input data size
propData - LZMA properties (5 bytes)
propSize - size of propData buffer (5 bytes)
finishMode - It has meaning only if the decoding reaches output limit (*destLen).
LZMA_FINISH_ANY - Decode just destLen bytes.
LZMA_FINISH_END - Stream must be finished after (*destLen).
You can use LZMA_FINISH_END, when you know that 
current output buffer covers last bytes of stream. 
alloc - Memory allocator.

Out: 
destLen - processed output size 
srcLen - processed input size 

Output:
SZ_OK
status:
LZMA_STATUS_FINISHED_WITH_MARK
LZMA_STATUS_NOT_FINISHED 
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
SZ_ERROR_DATA - Data error
SZ_ERROR_MEM - Memory allocation error
SZ_ERROR_UNSUPPORTED - Unsupported properties
SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src).

If LZMA decoder sees end_marker before reaching output limit, it returns OK result,
and output value of destLen will be less than output buffer size limit.

You can use multiple checks to test data integrity after full decompression:
1) Check Result and "status" variable.
2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
3) Check that output(srcLen) = compressedSize, if you know real compressedSize. 
You must use correct finish mode in that case. */ 

或者你参考下http://hi.baidu.com/%B4%F3%D5%AC%C0%C7/blog/item/fb0b7d2e791bcd311f3089f0.html

热点排行