• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ LzmaDecode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中LzmaDecode函数的典型用法代码示例。如果您正苦于以下问题:C++ LzmaDecode函数的具体用法?C++ LzmaDecode怎么用?C++ LzmaDecode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了LzmaDecode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: decompress_data

static int decompress_data(CLzmaDecoderState *vs, unsigned char *outStream,
			SizeT outSize)
{
	SizeT ip, op;

	return LzmaDecode(vs, data, datalen, &ip, outStream, outSize, &op);
}
开发者ID:Marko298,项目名称:SDK.UBNT.v5.3.3,代码行数:7,代码来源:decompress.c


示例2: ulzma

unsigned long ulzma(u8 *src, u8 *dst)
{
	unsigned char properties[LZMA_PROPERTIES_SIZE];
	UInt32 outSize;
	SizeT inProcessed;
	SizeT outProcessed;
	int res;
	CLzmaDecoderState state;
	SizeT mallocneeds;
	unsigned char scratchpad[15980];

	memcpy(properties, src, LZMA_PROPERTIES_SIZE);
	outSize = *(UInt32 *)(src + LZMA_PROPERTIES_SIZE);
	if (LzmaDecodeProperties(&state.Properties, properties, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK) {
		printf("Incorrect stream properties\n");
	}
	mallocneeds = (LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
	if (mallocneeds > 15980) {
		printf("Decoder scratchpad too small!\n");
	}
	state.Probs = (CProb *)scratchpad;
	res = LzmaDecode(&state, src + LZMA_PROPERTIES_SIZE + 8, (SizeT)0xffffffff, &inProcessed,
		dst, outSize, &outProcessed);
	if (res != 0) {
		printf("Decoding error = %d\n", res);
	}
	return outSize;
}
开发者ID:MattDevo,项目名称:coreboot,代码行数:28,代码来源:lzma.c


示例3: sizeof

bool CCCrypto::uncompressData( char* pInData, unsigned int nInSize, unsigned char** pOutData, SizeT& nOutSize )
{
	if (nInSize<sizeof(stHead))
		return false;
	stHead* phead = (stHead*)pInData;
	if ( phead->m_sign!='@Fml' )
		return false;
	nOutSize = phead->m_OriginalSize;
	nOutSize ^= 1002;
	*pOutData = (unsigned char*)malloc(nOutSize+1);
	(*pOutData)[nOutSize] = 0;

	SizeT srcLen = nInSize - sizeof(stHead);
	ELzmaStatus status;
	Byte prop[LZMA_PROPS_SIZE];
	for ( int i = 0; i < LZMA_PROPS_SIZE; i ++ )
		prop[i] = phead->m_szPorp[i];
	prop[3] ^= 5;
	for ( unsigned i = 0; i < 16 && i < nOutSize; i ++ )
	{
		pInData[sizeof(stHead)+i] ^= 6636;
	}

	SRes res = LzmaDecode( *pOutData, (SizeT*)&nOutSize, (const Byte*)&pInData[sizeof(stHead)], (SizeT*)&srcLen, prop, LZMA_PROPS_SIZE, LZMA_FINISH_END, &status, &SzAllocForLzma ); // LZMA_FINISH_ANY
	if ( res == SZ_OK )
		return true;

	free( *pOutData );
	*pOutData = NULL;
	nOutSize = 0;
	return false;
}
开发者ID:keith1020,项目名称:cocos.github.io,代码行数:32,代码来源:CCCrypto.cpp


示例4: Lzma86_Decode

SRes Lzma86_Decode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen)
{
  SRes res;
  int useFilter;
  SizeT inSizePure;
  ELzmaStatus status;

  if (*srcLen < LZMA86_HEADER_SIZE)
    return SZ_ERROR_INPUT_EOF;

  useFilter = src[0];

  if (useFilter > 1)
  {
    *destLen = 0;
    return SZ_ERROR_UNSUPPORTED;
  }

  inSizePure = *srcLen - LZMA86_HEADER_SIZE;
  res = LzmaDecode(dest, destLen, src + LZMA86_HEADER_SIZE, &inSizePure,
      src + 1, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &g_Alloc);
  *srcLen = inSizePure + LZMA86_HEADER_SIZE;
  if (res != SZ_OK)
    return res;
  if (useFilter == 1)
  {
    UInt32 x86State;
    x86_Convert_Init(x86State);
    x86_Convert(dest, *destLen, 0, &x86State, 0);
  }
  return SZ_OK;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:32,代码来源:Lzma86Dec.c


示例5: squashfs_uncompress_block

int squashfs_uncompress_block (void *dst, int dstlen, void *src, int srclen)
{
	int err;
#ifdef CONFIG_SQUASHFS_LZMA
		SizeT InProcessed;
		int bytes;
		if((err = LzmaDecode(&state,
				src, srclen, &InProcessed,
				dst, dstlen, &bytes)) != LZMA_RESULT_OK) {
			printf("lzma_fs returned unexpected result 0x%x\n", err);
			return 0;
		}
		return bytes;
#else

	inflateReset (&stream);

	stream.next_in = src;
	stream.avail_in = srclen;

	stream.next_out = dst;
	stream.avail_out = dstlen;

	err = inflate (&stream, Z_FINISH);
	if ((err==Z_OK)||(err==Z_STREAM_END))
		return dstlen-stream.avail_out;
	else
		return 0;
#endif
}
开发者ID:cidermole,项目名称:wndr3800-uboot,代码行数:30,代码来源:uncompress.c


示例6: lzmaUncompress

void lzmaUncompress(
    unsigned char* destBuf,
    int destSize,
    unsigned char *srcBuf,
    int srcSize
)
{
    SizeT lzmaDestSize = (SizeT)destSize;
    SizeT lzmaSrcSize = (SizeT)srcSize - LZMA_PROPS_SIZE;

    cout << "DECOMPRESSING " << srcSize << endl;

    ELzmaStatus finishStatus;
    int res = LzmaDecode(
                  destBuf, &lzmaDestSize,
                  srcBuf+LZMA_PROPS_SIZE, &lzmaSrcSize,
                  srcBuf, LZMA_PROPS_SIZE, LZMA_FINISH_END,
                  &finishStatus, &SzAllocForLzma);

    cout << "DECOMPRESSED " << srcSize << " BYTES DOWN TO " << lzmaDestSize << endl;

    if(res != SZ_OK || finishStatus != LZMA_STATUS_FINISHED_WITH_MARK)
    {
        cout << "ERROR DECOMPRESSING DATA\n";
        cout << res << ',' << finishStatus << endl;
        exit(1);
    }
}
开发者ID:lidibupa,项目名称:ClientServerMAME,代码行数:28,代码来源:NSM_Common.c


示例7: LzmaDecompress

/*
Decompresses a Lzma compressed source buffer.

Extracts decompressed data to its original form.
If the compressed source data specified by Source is successfully decompressed
into Destination, then RETURN_SUCCESS is returned.  If the compressed source data
specified by Source is not a valid compressed data format,
then RETURN_INVALID_PARAMETER is returned.

@param  Source      The source buffer containing the compressed data.
@param  SourceSize  The size of source buffer.
@param  Destination The destination buffer to store the decompressed data

@retval  EFI_SUCCESS Decompression completed successfully, and
the uncompressed buffer is returned Destination.
@retval  EFI_INVALID_PARAMETER
The source buffer specified by Source is corrupted
(not a valid compressed format).
*/
INT32
EFIAPI
LzmaDecompress(
CONST VOID  *Source,
UINT32       SourceSize,
VOID    *Destination
)
{
    SRes              LzmaResult;
    ELzmaStatus       Status;
    SizeT             DecodedBufSize;
    SizeT             EncodedDataSize;

    DecodedBufSize = (SizeT)GetDecodedSizeOfBuf((UINT8*)Source);
    EncodedDataSize = (SizeT)(SourceSize - LZMA_HEADER_SIZE);

    LzmaResult = LzmaDecode(
        (Byte*)Destination,
        &DecodedBufSize,
        (Byte*)((UINT8*)Source + LZMA_HEADER_SIZE),
        &EncodedDataSize,
        (CONST Byte*) Source,
        LZMA_PROPS_SIZE,
        LZMA_FINISH_END,
        &Status,
        &SzAllocForLzma
        );

    if (LzmaResult == SZ_OK) {
        return ERR_SUCCESS;
    }
    else {
        return ERR_INVALID_PARAMETER;
    }
}
开发者ID:Zhangqq,项目名称:UEFITool,代码行数:54,代码来源:LzmaDecompress.c


示例8: cli_LzmaDecode

int cli_LzmaDecode(CLI_LZMA **Lp, struct stream_state* state) {
  int res;
  SizeT processed_in, processed_out;
  CLI_LZMA* L = *Lp;

  if(L) {
	  L->avail_in = state->avail_in;
	  L->next_in = state->next_in;
	  L->avail_out = state->avail_out;
	  L->next_out = state->next_out;
  }

  if (!L || !L->initted) {
	  if(cli_LzmaInit(Lp, 0) != LZMA_RESULT_OK)
		  return LZMA_RESULT_DATA_ERROR;
	  L = *Lp;
  }


  res = LzmaDecode(&L->state, L->next_in, L->avail_in, &processed_in, L->next_out, L->avail_out, &processed_out, (L->avail_in==0));

  L->next_in += processed_in;
  L->avail_in -= processed_in;
  L->next_out += processed_out;
  L->avail_out -= processed_out;

  state->avail_in = L->avail_in;
  state->next_in = L->next_in;
  state->avail_out = L->avail_out;
  state->next_out = L->next_out;

  return res;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:33,代码来源:lzma_iface.c


示例9: entry

/* should be the first function */
void entry(unsigned long icache_size, unsigned long icache_lsize, 
	unsigned long dcache_size, unsigned long dcache_lsize)
{

	/* clear the bss */
	long *bssp;
	/* clear the bss */
	for (bssp = bss_start; bssp != bss_end; bssp++)
		*bssp = 0;
	unsigned int i;  /* temp value */
	unsigned int osize; /* uncompressed size */
	    
	ILzmaInCallback callback;
	CLzmaDecoderState vs;
	callback.Read = read_byte;
        puts("Atheros WiSOC DD-WRT LZMA Kernel Loader (");
	puts(__DATE__);
	puts(")\n");
        puts("decompressing");

	data = lzma_start;

	/* lzma args */
	i = get_byte();
	vs.Properties.lc = i % 9, i = i / 9;
	vs.Properties.lp = i % 5, vs.Properties.pb = i / 5;

	vs.Probs = (CProb *)buffer;

	/* skip rest of the LZMA coder property */
	for (i = 0; i < 4; i++)
		get_byte();

	/* read the lower half of uncompressed size in the header */
	osize = ((unsigned int)get_byte()) +
		((unsigned int)get_byte() << 8) +
		((unsigned int)get_byte() << 16) +
		((unsigned int)get_byte() << 24);

	/* skip rest of the header (upper half of uncompressed size) */
	for (i = 0; i < 4; i++) 
		get_byte();

	/* decompress kernel */
	if ((i = LzmaDecode(&vs, &callback,
	(unsigned char*)KERNEL_ENTRY, osize, &osize)) == LZMA_RESULT_OK)
	{
    		puts("\ndone.\njump to kernel...\n");
		blast_dcache(dcache_size, dcache_lsize);
		blast_icache(icache_size, icache_lsize);

		/* Jump to load address */
         	((void (*)(unsigned long, unsigned long, unsigned long)) KERNEL_ENTRY)
		(linux_args[0], linux_args[1], linux_args[2]);
	}
        puts("Fatal error while decompressing!\n");
}
开发者ID:ebichu,项目名称:dd-wrt,代码行数:58,代码来源:decompress.c


示例10: hc_lzma1_decompress

int hc_lzma1_decompress (const unsigned char *in, SizeT *in_len, unsigned char *out, SizeT *out_len, const char *props)
{
  ISzAlloc hc_lzma_mem_alloc = {hc_lzma_alloc, hc_lzma_free};

  ELzmaStatus status;

  // parameters to LzmaDecode (): unsigned char *dest, size_t *destLen, const unsigned char *src,
  // size_t *srcLen, const unsigned char *props, size_t propsSize, ELzmaFinishMode finishMode, ELzmaStatus status, ISzAlloc *alloc

  return LzmaDecode (out, out_len, in, in_len, (const Byte *) props, LZMA_PROPS_SIZE, LZMA_FINISH_ANY, &status, &hc_lzma_mem_alloc);
}
开发者ID:philsmd,项目名称:hashcat,代码行数:11,代码来源:ext_lzma.c


示例11: entry

/* should be the first function */
void entry(unsigned long icache_size, unsigned long icache_lsize, 
	unsigned long dcache_size, unsigned long dcache_lsize)
{
	unsigned int i;  /* temp value */
	unsigned int lc; /* literal context bits */
	unsigned int lp; /* literal pos state bits */
	unsigned int pb; /* pos state bits */
	unsigned int osize; /* uncompressed size */

	ILzmaInCallback callback;
	callback.Read = read_byte;

	/* look for trx header, 32-bit data access */
	for (data = ((unsigned char *) KSEG1ADDR(BCM4710_FLASH));
		((struct trx_header *)data)->magic != TRX_MAGIC; data += 65536);

	/* compressed kernel is in the partition 0 or 1 */
	if (((struct trx_header *)data)->offsets[1] > 65536) 
		data += ((struct trx_header *)data)->offsets[0];
	else
		data += ((struct trx_header *)data)->offsets[1];

	offset = 0;

	/* lzma args */
	i = get_byte();
	lc = i % 9, i = i / 9;
	lp = i % 5, pb = i / 5;

	/* skip rest of the LZMA coder property */
	for (i = 0; i < 4; i++)
		get_byte();

	/* read the lower half of uncompressed size in the header */
	osize = ((unsigned int)get_byte()) +
		((unsigned int)get_byte() << 8) +
		((unsigned int)get_byte() << 16) +
		((unsigned int)get_byte() << 24);

	/* skip rest of the header (upper half of uncompressed size) */
	for (i = 0; i < 4; i++) 
		get_byte();

	/* decompress kernel */
	if (LzmaDecode(workspace, ~0, lc, lp, pb, &callback,
		(unsigned char*)LOADADDR, osize, &i) == LZMA_RESULT_OK)
	{
		blast_dcache(dcache_size, dcache_lsize);
		blast_icache(icache_size, icache_lsize);

		/* Jump to load address */
		((void (*)(void)) LOADADDR)();
	}
}
开发者ID:4pao,项目名称:openwrt,代码行数:55,代码来源:decompress.c


示例12: entry

/* should be the first function */
void entry(unsigned long icache_size, unsigned long icache_lsize, 
	unsigned long dcache_size, unsigned long dcache_lsize,
	unsigned long fw_arg0, unsigned long fw_arg1,
	unsigned long fw_arg2, unsigned long fw_arg3)
{
	unsigned int i;  /* temp value */
	unsigned int osize; /* uncompressed size */

	CLzmaDecoderState vs;
	ILzmaInCallback callback;
	callback.Read = read_byte;

	/* look for trx header, 32-bit data access */
	for (data = ((unsigned char *) KSEG1ADDR(BCM4710_FLASH));
		((struct trx_header *)data)->magic != TRX_MAGIC; data += 65536);
	
	/* compressed kernel is in the partition 1 */
	data += ((struct trx_header *)data)->offsets[1];
	offset = 0;

	/* lzma args */
	i = get_byte();
	vs.Properties.lc = i % 9, i = i / 9;
	vs.Properties.lp = i % 5, vs.Properties.pb = i / 5;
	vs.Probs = (CProb *)workspace;

	/* skip rest of the LZMA coder property */
	for (i = 0; i < 4; i++)
		get_byte();

	/* read the lower half of uncompressed size in the header */
	osize = ((unsigned int)get_byte()) +
		((unsigned int)get_byte() << 8) +
		((unsigned int)get_byte() << 16) +
		((unsigned int)get_byte() << 24);

	/* skip rest of the header (upper half of uncompressed size) */
	for (i = 0; i < 4; i++) 
		get_byte();

	/* decompress kernel */
	if (LzmaDecode(&vs, &callback,
		(unsigned char*)LOADADDR, osize, &i) == LZMA_RESULT_OK)
	{
		blast_dcache(dcache_size, dcache_lsize);
		blast_icache(icache_size, icache_lsize);

		/* Jump to load address */
		((void (*)(unsigned long, unsigned long, unsigned long,
			    unsigned long)) LOADADDR)(fw_arg0, fw_arg1, fw_arg2,
			    fw_arg3);
	}
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:54,代码来源:decompress.c


示例13: expand

 size32_t expand(const void* input, size32_t inlength, void* output, size32_t maxout)
 {
     SizeT reslen = maxout;
     SizeT propsize = *(size32_t *)input;
     SizeT inlen = inlength -= sizeof(size32_t)+propsize;
     ELzmaStatus status;
     SRes res = LzmaDecode((byte *)output, &reslen, (const byte *)input+sizeof(size32_t)+propsize, &inlen, 
         (byte *)input+sizeof(size32_t), propsize, LZMA_FINISH_END, &status, &g_Alloc);
     if (res!=SZ_OK)
         throw MakeStringException(-1,"LzmaDecode failed(%d)",(int)res);
     return reslen;
 }
开发者ID:Josh-Googler,项目名称:HPCC-Platform,代码行数:12,代码来源:jlzma.cpp


示例14: LzmaRamDecompress

int LzmaRamDecompress(
    unsigned char *inBuffer, 
    size_t inSize,
    unsigned char *outBuffer,
    size_t outSize,
    size_t *outSizeProcessed,
    void * (*allocFunc)(size_t size), 
    void (*freeFunc)(void *))
{
  int lc, lp, pb;
  size_t lzmaInternalSize;
  void *lzmaInternalData;
  int result;
  UInt32 outSizeProcessedLoc;
  
  int useFilter = inBuffer[0];

  *outSizeProcessed = 0;
  if (useFilter > 1)
    return 1;

  if (inSize < LZMA_PROPS_SIZE)
    return 1;
  lc = inBuffer[1];
  if (lc >= (9 * 5 * 5))
    return 1;
  for (pb = 0; lc >= (9 * 5); pb++, lc -= (9 * 5));
  for (lp = 0; lc >= 9; lp++, lc -= 9);
  
  lzmaInternalSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp))) * sizeof(CProb);
  lzmaInternalData = allocFunc(lzmaInternalSize);
  if (lzmaInternalData == 0)
    return SZE_OUTOFMEMORY;
  
  result = LzmaDecode((unsigned char *)lzmaInternalData, (UInt32)lzmaInternalSize,
    lc, lp, pb,
    inBuffer + LZMA_PROPS_SIZE, (UInt32)inSize - LZMA_PROPS_SIZE,
    outBuffer, (UInt32)outSize, 
    &outSizeProcessedLoc);
  freeFunc(lzmaInternalData);
  if (result != LZMA_RESULT_OK)
    return 1;
  *outSizeProcessed = (size_t)outSizeProcessedLoc;
  if (useFilter == 1)
  {
    UInt32 _prevMask;
    UInt32 _prevPos;
    x86_Convert_Init(_prevMask, _prevPos);
    x86_Convert(outBuffer, (UInt32)outSizeProcessedLoc, 0, &_prevMask, &_prevPos, 0);
  }
  return 0;
}
开发者ID:ZRouter,项目名称:ZRouter,代码行数:52,代码来源:LzmaRamDecode.c


示例15: lzbench_lzma_decompress

int64_t lzbench_lzma_decompress(char *inbuf, size_t insize, char *outbuf, size_t outsize, size_t, size_t, char*)
{
	int res;
	SizeT out_len = outsize;
	SizeT src_len = insize - LZMA_PROPS_SIZE;
	ELzmaStatus status;
	
//	SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc)
	res = LzmaDecode((uint8_t*)outbuf, &out_len, (uint8_t*)inbuf+LZMA_PROPS_SIZE, &src_len, (uint8_t*)inbuf, LZMA_PROPS_SIZE, LZMA_FINISH_END, &status, &g_Alloc);
	if (res != SZ_OK) return 0;
	
//	printf("out_len=%u\n", (int)(out_len + LZMA_PROPS_SIZE));	
    return out_len;
}
开发者ID:TurtleSimos,项目名称:lzbench,代码行数:14,代码来源:compressors.cpp


示例16: main

int main()
{
    uint32_t i;
    int r;
    uint32_t src_len = sizeof(c_data);
    uint32_t dst_len = 131072ul;
    uint32_t src_out = 0;
    uint32_t dst_out = 0;
    const bytep src;
    bytep dst;
    CLzmaDecoderState *s;

    printf("Decompress %lu %lu\n", (long)src_len, (long)dst_len);
    s = (CLzmaDecoderState *) malloc(32768u);
    src = c_data;
    dst = (bytep) acc_halloc(dst_len);
    if (!s || !dst) {
        printf("ERROR: Out of memory!\n");
        return 1;
    }
    for (i = 0; i != dst_len; ++i)
        dst[i] = 255;

    s->Properties.lc = 3; s->Properties.lp = 0; s->Properties.pb = 2;
    r = LzmaDecode(s, src, src_len, &src_out, dst, dst_len, &dst_out);

    if (r != 0 || src_out != src_len || dst_out != dst_len)
    {
        printf("ERROR: Decompression error %d %lu %lu\n", r, (long)src_out, (long)dst_out);
        return 1;
    }

    i = 0;
    if (dst[i] != 1)
        goto data_error;
    while (++i != dst_len - 1)
        if (dst[i] != 0)
            goto data_error;
    if (dst[i] != 2)
        goto data_error;

    printf("Decompression test passed. All done.\n");
    return 0;

data_error:
    printf("ERROR: Decompression data error at offset %lu.\n", (long)i);
    return 1;
}
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:48,代码来源:l_test.c


示例17: jffs2_lzma_decompress

STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out,
				 uint32_t srclen, uint32_t destlen)
{
	int ret;
	SizeT dl = (SizeT)destlen;
	SizeT sl = (SizeT)srclen;
	ELzmaStatus status;
	
	ret = LzmaDecode(cpage_out, &dl, data_in, &sl, propsEncoded,
		propsSize, LZMA_FINISH_ANY, &status, &lzma_alloc);

	if (ret != SZ_OK || status == LZMA_STATUS_NOT_FINISHED || dl != (SizeT)destlen)
		return -1;

	return 0;
}
开发者ID:darcyg,项目名称:ap_project_v2,代码行数:16,代码来源:compr_lzma.c


示例18: LzmaDecode

bool zmodifyer::uncompress( unsigned char * dest, unsigned int & destLen, const unsigned char *src, size_t srcLen)
{
	if( !src || srcLen < 10 || !dest )
		return false;

	if( destLen < *(unsigned int*)(src+6) )
		return false;

	unsigned char sizeProp = *(src+5);
	srcLen -= 10;

	ELzmaStatus status;
	int result = LzmaDecode(dest, &destLen, (src+10), &srcLen, src, sizeProp, LZMA_FINISH_ANY, &status, &alloctator);

	return (result == SZ_OK || result == SZ_ERROR_INPUT_EOF) ? true : false;
}
开发者ID:daoluong,项目名称:zpack-library,代码行数:16,代码来源:zmodifyer.cpp


示例19: LzmaRamDecompress

int LzmaRamDecompress(
    const unsigned char *inBuffer, 
    size_t inSize,
    unsigned char *outBuffer,
    size_t outSize,
    size_t *outSizeProcessed,
    void * (*allocFunc)(size_t size), 
    void (*freeFunc)(void *))
{
  CLzmaDecoderState state;  /* it's about 24 bytes structure, if int is 32-bit */
  int result;
  SizeT outSizeProcessedLoc;
  SizeT inProcessed;
  int useFilter;
  
  if (inSize < LZMA_PROPS_SIZE)
    return 1;
  useFilter = inBuffer[0];

  *outSizeProcessed = 0;
  if (useFilter > 1)
    return 1;

  if (LzmaDecodeProperties(&state.Properties, inBuffer + 1, LZMA_PROPERTIES_SIZE) != LZMA_RESULT_OK)
    return 1;
  state.Probs = (CProb *)allocFunc(LzmaGetNumProbs(&state.Properties) * sizeof(CProb));
  if (state.Probs == 0)
    return SZE_OUTOFMEMORY;
  
  result = LzmaDecode(&state,
    inBuffer + LZMA_PROPS_SIZE, (SizeT)inSize - LZMA_PROPS_SIZE, &inProcessed,
    outBuffer, (SizeT)outSize, &outSizeProcessedLoc);
  freeFunc(state.Probs);
  if (result != LZMA_RESULT_OK)
    return 1;
  *outSizeProcessed = (size_t)outSizeProcessedLoc;
  if (useFilter == 1)
  {
    UInt32 _prevMask;
    UInt32 _prevPos;
    x86_Convert_Init(_prevMask, _prevPos);
    x86_Convert(outBuffer, (UInt32)outSizeProcessedLoc, 0, &_prevMask, &_prevPos, 0);
  }
  return 0;
}
开发者ID:mixxit,项目名称:solinia,代码行数:45,代码来源:LzmaRamDecode.cpp


示例20: plain_lzma_decode

errno_t plain_lzma_decode( void *dest, size_t *dest_len, void *src, size_t *src_len, int logLevel )
{
    Byte 		propData[5];
    ELzmaStatus 	status;

    SRes rc = LzmaDecode( dest, dest_len, src, src_len,
                          propData, sizeof(propData), LZMA_FINISH_END,
                          &status, &alloc);

    switch(rc)
    {
    case SZ_OK: break;

    case SZ_ERROR_DATA:
        SHOW_ERROR0( logLevel, "Broken data" );
        return EFTYPE;

    case SZ_ERROR_MEM:
        SHOW_ERROR0( logLevel, "Out of mem" );
        return ENOMEM;

    case SZ_ERROR_UNSUPPORTED:
        SHOW_ERROR0( logLevel, "Unsupported props" );
        return EINVAL;

    case SZ_ERROR_INPUT_EOF:
        SHOW_ERROR0( logLevel, "Premature data end" );
        return ENOSPC;
    }


    switch(status)
    {
    case LZMA_STATUS_FINISHED_WITH_MARK: break;

    case LZMA_STATUS_NOT_SPECIFIED: // impossible
    case LZMA_STATUS_NEEDS_MORE_INPUT:
    case LZMA_STATUS_NOT_FINISHED:
    case LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK:
        SHOW_ERROR0( logLevel, "Premature data end" );
        return ENOSPC;
    }

    return 0;
}
开发者ID:NoSuchProcess,项目名称:phantomuserland,代码行数:45,代码来源:simpleDecode.c



注:本文中的LzmaDecode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ M函数代码示例发布时间:2022-05-30
下一篇:
C++ LwNtStatusToWin32Error函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap