当前位置: 首页>>代码示例>>C++>>正文


C++ LzmaDecode函数代码示例

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


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


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