示例#1
0
/* *** Die Laderoutine *** */
int LoadImg(char *Filename, MFDB *raster)
{
 IMGHEAD *img;
 long Length;
 int fhndl;

 fhndl=Fopen(Filename, 0);
 if(fhndl<0) return(fhndl);
 Length=Fseek(0L, fhndl, 2);
 Fseek(0L, fhndl, 0);
 img=(void *)Mxalloc(Length, 0);
 if( ((signed long)img)==-32L )  img=(void *)Malloc(Length);
 if( (signed long)img<=0L) { Fclose(fhndl); return((int)img); }
 Fread(fhndl, Length, img);		/* IMG einlesen */
 Fclose(fhndl);

 raster->fd_w = img->LineWidth;
 raster->fd_h = img->Lines;
 raster->fd_wdwidth = (raster->fd_w + 15) / 16;
 raster->fd_stand = 1;
 raster->fd_nplanes = img->Planes;

 Length=(long)raster->fd_wdwidth * 2L * raster->fd_h * raster->fd_nplanes;
 raster->fd_addr=(void *)Mxalloc(Length, 0);
 if( ((signed long)raster->fd_addr)==-32L )
   raster->fd_addr=(void *)Malloc(Length);
 if( (signed long)raster->fd_addr<=0L )  return((int)raster->fd_addr);

 Decompress(img, raster->fd_addr);

 Mfree(img);
 return(0);
}
示例#2
0
void CZlib::DecompressFile(CArcFile* archive)
{
	SFileInfo* file_info = archive->GetOpenFileInfo();

	// Ensure buffer
	std::vector<u8> z_buf(file_info->sizeCmp);
	std::vector<u8> buf(file_info->sizeOrg);

	// zlib Decompression
	archive->Read(z_buf.data(), z_buf.size());
	Decompress(buf.data(), &file_info->sizeOrg, z_buf.data(), z_buf.size());

	if (lstrcmp(PathFindExtension(file_info->name), _T(".bmp")) == 0)
	{
		CImage image;
		image.Init(archive, buf.data());
		image.Write(file_info->sizeOrg);
	}
	else
	{
		// Output
		archive->OpenFile();
		archive->WriteFile(buf.data(), file_info->sizeOrg);
	}
}
示例#3
0
void CSoundStream::Play	( BOOL loop, int cnt )
{
	VERIFY(Sound);

	if (isPause) { Pause(); return; }
	if (dwStatus & DSBSTATUS_PLAYING) return;
    dwDecPos		= 0;
	isPresentData	= true;
//----------------
	if (hAcmStream){
		CHK_DX(acmStreamClose(hAcmStream,0));
	}
	CHK_DX(acmStreamOpen(&hAcmStream,0,psrc,pwfx,0,NULL,0,0));
	CHK_DX(acmStreamSize(hAcmStream,dwDestBufSize,LPDWORD(&dwSrcBufSize),ACM_STREAMSIZEF_DESTINATION));
	// alloc source data buffer
	VERIFY(dwSrcBufSize);
	xr_free(WaveSource);
	WaveSource = (unsigned char *)xr_malloc(dwSrcBufSize);

	// seek to data start
	hf->seek	(DataPos);
	writepos	= 0;
	Decompress	(WaveDest);
	writepos	=stream.cbDstLengthUsed;
//-------
	iLoopCountRested= cnt;
	bMustLoop		= loop;
	bMustPlay		= true;
}
示例#4
0
//**********************************************************************************
bool CJpegHandler::Decompress(
//Load a JPEG from disk and uncompress it into a byte buffer.
//
//Returns: true if successful
//
//Params:
	const WCHAR *wszName,   //(in)   Full path+name to the JPEG image
	BYTE* &imageBuffer, UINT &wWidth, UINT &wHeight)   //(out) image data
{
/*
	DECOMPRESSION Outline:
	Allocate and initialize a JPEG decompression object
	Specify the source of the compressed data (eg, a file)
	Call jpeg_read_header() to obtain image info
	Set parameters for decompression
	jpeg_start_decompress(...);
	while (scan lines remain to be read)
		jpeg_read_scanlines(...);
	jpeg_finish_decompress(...);
	Release the JPEG decompression object
*/
	//Reading the JPEG file into a buffer and decompressing it there will result
	//in many fewer disk I/O accesses, so we'll do it that way.
	CFiles f;
	CStretchyBuffer buffer;
	if (!f.ReadFileIntoBuffer(wszName, buffer,true))
		return false;
	return Decompress((BYTE*)buffer, buffer.Size(), imageBuffer, wWidth, wHeight);
}
示例#5
0
TStringVector TMessageStorage::GetMessages(const string& login,
                                           TDuration from,
                                           TDuration to)
{
    NKwStorage::TKwIterator it = Storage->Iterator();
    string fromStr = login + ToString(from.MicroSeconds());
    string toStr = login + ToString(to.MicroSeconds());
    vector<string> messages;
    it->Seek(fromStr);
    while (!it->End()) {
        pair<string, string> value = it->Get();
        if (value.first > toStr) {
            break;
        }

        TMessageData data;
        if (!data.ParseFromString(Decompress(value.second))) {
            throw UException("failed to parse message");
        }
        messages.push_back(data.encryptedmessage());
        it->Next();
        if (it->End()) {
            break;
        }
    }
    return messages;
}
示例#6
0
boost::optional<TClientInfo> TClientInfoStorage::Get(const std::string& login) {
    boost::optional<string> strData = Storage->Get(login);
    if (!strData.is_initialized()) {
        return boost::optional<TClientInfo>();
    }
    TClientInfoData data;
    if (!data.ParseFromString(Decompress(*strData))) {
        throw UException("failed to parse storage data");
    }
    TClientInfo result;
    result.Login = data.login();
    result.EncryptedPrivateKey = data.encryptedprivatekey();
    result.LoginPasswordHash = data.loginpasswordhash();
    result.PublicKey = data.publickey();
    for (size_t i = 0; i < data.friends_size(); ++i) {
        const TFriendInfoData& frnd = data.friends(i);
        TFriendInfo& friendInfo = result.Friends[frnd.login()];
        friendInfo.Login = frnd.login();
        friendInfo.EncryptedKey = frnd.encryptedkey();
        friendInfo.Type = frnd.type();
        friendInfo.AuthStatus = (EAuthStatus)frnd.authstatus();
        friendInfo.PublicKey = frnd.publickey();
        friendInfo.ServerPublicKey = frnd.serverpublickey();
        if (frnd.has_offlinekey()) {
            assert(frnd.has_offlinekeysignature());
            friendInfo.OfflineKey = frnd.offlinekey();
            friendInfo.OfflineKeySignature = frnd.offlinekeysignature();
        }
    }
    return result;
}
示例#7
0
文件: a-lib.c 项目: MannyZhong/r3
*/	RL_API int RL_Start(REBYTE *bin, REBINT len, REBCNT flags)
/*
**	Evaluate the default boot function.
**
**	Returns:
**		Zero on success, otherwise indicates an error occurred.
**	Arguments:
**		bin - optional startup code (compressed), can be null
**		len - length of above bin
**		flags - special flags
**	Notes:
**		This function completes the startup sequence by calling
**		the sys/start function.
**
***********************************************************************/
{
	REBVAL *val;
	REBSER spec = {0};
	REBSER *ser;

	if (bin) {
		spec.data = bin;
		spec.tail = len;
		ser = Decompress(&spec, 0, -1, 10000000, 0);
		if (!ser) return 1;

		val = BLK_SKIP(Sys_Context, SYS_CTX_BOOT_HOST);
		Set_Binary(val, ser);
	}

	return Init_Mezz(0);
}
示例#8
0
文件: a-lib.c 项目: kjanz1899/ren-c
//
//  RL_Do_Binary: C
// 
// Evaluate an encoded binary script such as compressed text.
// 
// Returns:
//     The datatype of the result or zero if error in the encoding.
// Arguments:
//     bin - by default, a REBOL compressed UTF-8 (or ASCII) script.
//     length - the length of the data.
//     flags - special flags (set to zero at this time).
//     key - encoding, encryption, or signature key.
//     result - value returned from evaluation.
// Notes:
//     As of A104, only compressed scripts are supported, however,
//     rebin, cloaked, signed, and encrypted formats will be supported.
//
RL_API int RL_Do_Binary(
    int *exit_status,
    const REBYTE *bin,
    REBINT length,
    REBCNT flags,
    REBCNT key,
    RXIARG *out
) {
    REBSER *text;
#ifdef DUMP_INIT_SCRIPT
    int f;
#endif
    int maybe_rxt; // could be REBRXT, or negative number for error :-/

    text = Decompress(bin, length, -1, FALSE, FALSE);
    if (!text) return 0;
    Append_Codepoint_Raw(text, 0);

#ifdef DUMP_INIT_SCRIPT
    f = _open("host-boot.r", _O_CREAT | _O_RDWR, _S_IREAD | _S_IWRITE );
    _write(f, BIN_HEAD(text), LEN_BYTES(BIN_HEAD(text)));
    _close(f);
#endif

    PUSH_GUARD_SERIES(text);
    maybe_rxt = RL_Do_String(exit_status, BIN_HEAD(text), flags, out);
    DROP_GUARD_SERIES(text);

    Free_Series(text);
    return maybe_rxt;
}
char *GetFileDataByIdx(SimpleArchive *archive, int idx, Allocator *allocator)
{
    if (idx >= archive->filesCount)
        return NULL;

    FileInfo *fi = &archive->files[idx];

    char *uncompressed = (char *)Allocator::Alloc(allocator, fi->uncompressedSize);
    if (!uncompressed)
        return NULL;

    bool ok = Decompress(fi->compressedData, fi->compressedSize, uncompressed, fi->uncompressedSize, allocator);
    if (!ok) {
        Allocator::Free(allocator, uncompressed);
        return NULL;
    }

    uint32_t realCrc = crc32(0, (const uint8_t *)uncompressed, fi->uncompressedSize);
    if (realCrc != fi->uncompressedCrc32) {
        Allocator::Free(allocator, uncompressed);
        return NULL;
    }

    return uncompressed;
}
示例#10
0
文件: Mesh.cpp 项目: liy3/GPGPU
bool Mesh::load(const std::string& filename) {
    std::shared_ptr<ObjMesh> mesh = nullptr;

    if ( !LoadObjMesh(filename, mesh) ) return false;

    if ( mesh->faces.size() > 0 ) {
        if ( mesh->faces[0].type != TRIANGLE ) {
            std::cerr << "[Mesh:load] Error: Only triangle-face Obj files supported." << std::endl;
            return false;
        }
    }

    this->name = mesh->name;
    std::vector<Vector3f> normals;
    std::vector<Vector4f> tangents;
    std::vector<unsigned int> indices;
    std::vector<unsigned int> textureIndices;
    std::vector<unsigned int> normalIndices;

    //--------------------------------------------------------------------------
    // Copy the face indices from the *.obj file to this mesh.
    //--------------------------------------------------------------------------
    indices.resize(mesh->faces.size() * TRIANGLE_EDGE_COUNT);
    normalIndices.resize(mesh->faces.size() * TRIANGLE_EDGE_COUNT);
    textureIndices.resize(mesh->faces.size() * TRIANGLE_EDGE_COUNT);
    unsigned int index = 0;
    for ( unsigned int i = 0; i < mesh->faces.size(); i++ ) {
        indices[index] = static_cast<unsigned int>(mesh->faces[i].vertexIndices[A]);
        indices[index + 1] = static_cast<unsigned int>(mesh->faces[i].vertexIndices[B]);
        indices[index + 2] = static_cast<unsigned int>(mesh->faces[i].vertexIndices[C]);

        normalIndices[index] = static_cast<unsigned int>(mesh->faces[i].normalIndices[A]);
        normalIndices[index + 1] = static_cast<unsigned int>(mesh->faces[i].normalIndices[B]);
        normalIndices[index + 2] = static_cast<unsigned int>(mesh->faces[i].normalIndices[C]);

        textureIndices[index] = static_cast<unsigned int>(mesh->faces[i].textureIndices[A]);
        textureIndices[index + 1] = static_cast<unsigned int>(mesh->faces[i].textureIndices[B]);
        textureIndices[index + 2] = static_cast<unsigned int>(mesh->faces[i].textureIndices[C]);

        index += TRIANGLE_EDGE_COUNT;
    }

    //--------------------------------------------------------------------------
    // Calcualte the vertex normals, tangents, and face normals.
    //--------------------------------------------------------------------------
    //CalculateNormals(indices, mesh->vertices, normals);
    normals.resize(mesh->normals.size());
    for ( unsigned int i = 0; i < mesh->normals.size(); i++ ) {
        normals[i] = mesh->normals[i];
    }
    Decompress(indices, normalIndices, textureIndices, mesh->vertices, normals, mesh->textureCoordinates, tangents, this->vertices, this->faces);
    CalculateTangents(this->vertices, this->faces);
    this->constructOnGPU();
    return true;
}
示例#11
0
INT
PAL_MKFDecompressChunk(
   LPBYTE          lpBuffer,
   UINT            uiBufferSize,
   UINT            uiChunkNum,
   FILE           *fp
)
/*++
  Purpose:

    Decompress a compressed chunk from an MKF archive into lpBuffer.

  Parameters:

    [OUT] lpBuffer - pointer to the destination buffer.

    [IN]  uiBufferSize - size of the destination buffer.

    [IN]  uiChunkNum - the number of the chunk in the MKF archive to read.

    [IN]  fp - pointer to the fopen'ed MKF file.

  Return value:

    Integer value which indicates the size of the chunk.
    -1 if there are error in parameters, or buffer size is not enough.
    -3 if cannot allocate memory for decompression.

--*/
{
   LPBYTE          buf;
   int             len;

   len = PAL_MKFGetChunkSize(uiChunkNum, fp);

   if (len <= 0)
   {
      return len;
   }

   buf = (LPBYTE)malloc(len);
   if (buf == NULL)
   {
      return -3;
   }

   PAL_MKFReadChunk(buf, len, uiChunkNum, fp);

   len = Decompress(buf, lpBuffer, uiBufferSize);
   free(buf);

   return len;
}
示例#12
0
void CAhx::Decode(CArcFile* pclArc, LPBYTE ahx_buf, DWORD ahx_buf_len)
{
	// Convert AHX to WAV
	DWORD wav_buf_len = pclArc->ConvEndian(*(LPDWORD)&ahx_buf[12]) * 2;
	YCMemory<BYTE> wav_buf(wav_buf_len + 1152 * 16); // Advance //+ 1152 * 2); // margen = layer-2 frame size
	wav_buf_len = Decompress(&wav_buf[0], ahx_buf, ahx_buf_len);

	// Output
	CWav wav;
	wav.Init(pclArc, wav_buf_len, pclArc->ConvEndian(*(LPDWORD)&ahx_buf[8]), ahx_buf[7], 16);
	wav.Write(&wav_buf[0]);
}
示例#13
0
void DecompressImage( u8* rgba, int width, int height, void const* blocks, int flags )
{
	// fix any bad flags
	flags = FixFlags( flags );

	// initialise the block input
	u8 const* sourceBlock = reinterpret_cast< u8 const* >( blocks );
	int bytesPerBlock = ( ( flags & kDxt1 ) != 0 ) ? 8 : 16;

	// loop over blocks
	for( int y = 0; y < height; y += 4 )
	{
		for( int x = 0; x < width; x += 4 )
		{
			// decompress the block
			u8 targetRgba[4*16];
			Decompress( targetRgba, sourceBlock, flags );
			
			// write the decompressed pixels to the correct image locations
			u8 const* sourcePixel = targetRgba;
			for( int py = 0; py < 4; ++py )
			{
				for( int px = 0; px < 4; ++px )
				{
					// get the target location
					int sx = x + px;
					int sy = y + py;
					if( sx < width && sy < height )
					{
						u8* targetPixel = rgba + 4*( width*sy + sx );
						
						targetPixel[0] = sourcePixel[0];
						targetPixel[1] = sourcePixel[1];
						targetPixel[2] = sourcePixel[2];
						targetPixel[3] = sourcePixel[3];

						targetPixel+=4;
						sourcePixel+=4;

					}
					else
					{
						// skip this pixel as its outside the image
						sourcePixel += 4;
					}
				}
			}
			
			// advance
			sourceBlock += bytesPerBlock;
		}
	}
}
void main(int argc, char *argv[])
{

   SetConsoleTitle("Decompress - Lunar Compress DLL Example");

   printf("Data Decompression Program Example Version 1.03\n");
   printf("Programmed by FuSoYa, Defender of Relm\n");
   printf("FuSoYa's Niche - http://fusoya.eludevisibility.org\n\n");

   Decompress(argc,argv);

   WaitForTerminate();

}
示例#15
0
文件: a-lib.c 项目: MannyZhong/r3
*/	RL_API int RL_Do_Binary(REBYTE *bin, REBINT length, REBCNT flags, REBCNT key, RXIARG *result)
/*
**	Evaluate an encoded binary script such as compressed text.
**
**	Returns:
**		The datatype of the result or zero if error in the encoding.
**	Arguments:
**		bin - by default, a REBOL compressed UTF-8 (or ASCII) script.
**		length - the length of the data.
**		flags - special flags (set to zero at this time).
**		key - encoding, encryption, or signature key.
**		result - value returned from evaluation.
**	Notes:
**		As of A104, only compressed scripts are supported, however,
**		rebin, cloaked, signed, and encrypted formats will be supported.
**
***********************************************************************/
{
	REBSER spec = {0};
	REBSER *text;
	REBVAL *val;
#ifdef DUMP_INIT_SCRIPT
	int f;
#endif

	//Cloak(TRUE, code, NAT_SPEC_SIZE, &key[0], 20, TRUE);
	spec.data = bin;
	spec.tail = length;
	text = Decompress(&spec, 0, -1, 10000000, 0);
	if (!text) return FALSE;
	Append_Byte(text, 0);

#ifdef DUMP_INIT_SCRIPT
	f = _open("host-boot.r", _O_CREAT | _O_RDWR, _S_IREAD | _S_IWRITE );
	_write(f, STR_HEAD(text), LEN_BYTES(STR_HEAD(text)));
	_close(f);
#endif

	SAVE_SERIES(text);
	val = Do_String(text->data, flags);
	UNSAVE_SERIES(text);
	if (IS_ERROR(val)) // && (VAL_ERR_NUM(val) != RE_QUIT)) {
		Print_Value(val, 1000, FALSE);

	if (result) {
		*result = Value_To_RXI(val);
		return Reb_To_RXT[VAL_TYPE(val)];
	}
	return 0;
}
示例#16
0
void Steps::GetNoteData( NoteData& noteDataOut ) const
{
	Decompress();

	if( m_bNoteDataIsFilled )
	{
		noteDataOut = *m_pNoteData;
	}
	else
	{
		noteDataOut.ClearAll();
		noteDataOut.SetNumTracks( GAMEMAN->GetStepsTypeInfo(m_StepsType).iNumTracks );
	}
}
示例#17
0
		CChunkFileReader::Error Restore()
		{
			// No valid states left.
			if (Empty())
				return CChunkFileReader::ERROR_BAD_FILE;

			int n = (--next_ + size_) % size_;
			if (states_[n].empty())
				return CChunkFileReader::ERROR_BAD_FILE;

			static std::vector<u8> buffer;
			Decompress(buffer, states_[n], bases_[baseMapping_[n]]);
			return LoadFromRam(buffer);
		}
示例#18
0
void 
Decode(config * conf){
#ifdef ENABLE_PARSEC_HOOKS
    __parsec_roi_begin();
#endif
  RecvBlock(conf);
  Decompress(NULL);
  CheckCache(NULL);
  if (strcmp(conf->outfile, "") == 0)
    Reassemble(NULL);
  else Reassemble(conf->outfile);
#ifdef ENABLE_PARSEC_HOOKS
    __parsec_roi_end();
#endif
}
示例#19
0
void GSDumpLzma::Read(void* ptr, size_t size) {
	size_t off = 0;
	uint8_t* dst = (uint8_t*)ptr;
	while (size) {
		if (m_avail == 0) {
			Decompress();
		}

		size_t l = min(size, m_avail);
		memcpy(dst + off, m_area+m_start, l);
		m_avail -= l;
		size    -= l;
		m_start += l;
		off     += l;
	}
}
示例#20
0
void XMp3Decomp::Setup(XSound* snd, XBOOL reset)
{
	if (snd->dataLen == 0)
		return;
	if (!isInitMad())
		initMad();

	src = (XU8 *) snd->samples;
    bufLength = 0;      // number of bytes last filled with
    bufIndex = 0;       // index into the out buffer
    srcIndex = 0;
    this->snd = snd;

    // skip past the mp3 compression delay
    Decompress(0, snd->delay);
}
示例#21
0
bool UPKReader::ReadCompressedHeader()
{
    LogDebug("Reading compressed header...");
    ReadError = UPKReadErrors::NoErrors;
    Compressed = false;
    CompressedChunk = false;
    LastAccessedExportObjIdx = 0;
    UPKStream.seekg(0, std::ios::end);
    size_t Size = UPKStream.tellg();
    UPKStream.seekg(0);
    UPKStream.read(reinterpret_cast<char*>(&CompressedHeader.Signature), 4);
    if (CompressedHeader.Signature != 0x9E2A83C1)
    {
        LogErrorState(UPKReadErrors::BadSignature);
        return false;
    }
    UPKStream.read(reinterpret_cast<char*>(&CompressedHeader.BlockSize), 4);
    UPKStream.read(reinterpret_cast<char*>(&CompressedHeader.CompressedSize), 4);
    UPKStream.read(reinterpret_cast<char*>(&CompressedHeader.UncompressedSize), 4);
    CompressedHeader.NumBlocks = (CompressedHeader.UncompressedSize + CompressedHeader.BlockSize - 1) / CompressedHeader.BlockSize; // Gildor
    uint32_t CompHeadSize = 16 + CompressedHeader.NumBlocks * 8;
    Size -= CompHeadSize; /// actual compressed file size
    if (CompressedHeader.CompressedSize != Size ||
        CompressedHeader.UncompressedSize < Size ||
        CompressedHeader.UncompressedSize < CompressedHeader.CompressedSize)
    {
        LogErrorState(UPKReadErrors::BadVersion);
        return false;
    }
    CompressedHeader.Blocks.clear();
    for (unsigned i = 0; i < CompressedHeader.NumBlocks; ++i)
    {
        FCompressedChunkBlock Block;
        UPKStream.read(reinterpret_cast<char*>(&Block.CompressedSize), 4);
        UPKStream.read(reinterpret_cast<char*>(&Block.UncompressedSize), 4);
        CompressedHeader.Blocks.push_back(Block);
    }
    Compressed = true;
    CompressedChunk = true;
    LogDebug("Package is fully compressed, decompressing...");
    if (!Decompress())
    {
        LogErrorState(UPKReadErrors::IsCompressed);
        return false;
    }
    return true;
}
示例#22
0
//=================================
//ファイルを分割します。
//=================================
HRESULT CompressData::Split(char *inFileName)
{
	Clear();
	strcpy(m_fileName,inFileName);
	FILE *fin = fopen(m_fileName,"rb");
	if(fin == NULL)
	{
		assert(!"分割する元のファイルがないですよ");
		return E_FAIL;
	}

	//============================
	//ファイルヘッダーの読み込み
	//============================
	ReadHeader(fin);	
	puts("結合ファイルの読み込み成功");
	
	std::map<std::string,FileInfo>::iterator p = m_mapFile.begin();
	for(DWORD i = 0; i < m_dwFileNum; i++)
	{
		FileInfo &fd = p->second;
		char *fileName = (char *)p->first.c_str();
		DirectoryName(fileName);	//ファイルを作成する前にディレクトリの作成
		FILE *fout = fopen(fileName,"wb");
		if(fout == NULL)
		{
			assert(!"引数の設定がおかしいです");
			return E_FAIL;
		}
		fseek(fin,fd.startAdress,SEEK_SET);
		
		
		Decompress(fin,fout);
		
		fclose(fout);

		p++;
		printf("%sの書き込み成功\n",fileName);
	}

	puts("書き込み成功");
	fclose(fin);

	return S_OK;
}
char *GetFileDataByIdx(SimpleArchive *archive, int idx, Allocator *allocator)
{
    size_t uncompressedSize;

    FileInfo *fi = &archive->files[idx];
    if (!IsFileCrcValid(fi))
        return NULL;

    char *uncompressed = Decompress(fi->compressedData, fi->compressedSize, &uncompressedSize, allocator);
    if (!uncompressed)
        return NULL;

    if (uncompressedSize != fi->uncompressedSize) {
        Allocator::Free(allocator, uncompressed);
        return NULL;
    }
    return uncompressed;
}
示例#24
0
//================================================================================
//ファイルデータを取得します。ただしoutDataはメモリが確保されてなくてはなりません
//================================================================================
HRESULT CompressData::GetFileData(char *fileName,char *outData)
{	
	FileInfo *fi;
	if(GetFileInfo(fileName,&fi) == E_FAIL)
	{
		assert(!"ファイルがないですよ");
		return E_FAIL;
	}
	

	FILE *fp = fopen(m_fileName,"rb");
	fseek(fp,fi->startAdress,SEEK_SET);
	Decompress(fp,outData,fi->size);

	fclose(fp);
	
	return S_OK;
}
示例#25
0
/* Copy our parent's data.  This is done when we're being changed from autogen
 * to normal. (needed?) */
void Steps::DeAutogen( bool bCopyNoteData )
{
    if( !parent )
        return; /* OK */

    if( bCopyNoteData )
        Decompress();	// fills in m_pNoteData with sliding window transform

    m_sDescription		= Real()->m_sDescription;
    m_Difficulty		= Real()->m_Difficulty;
    m_iMeter		= Real()->m_iMeter;
    copy( Real()->m_CachedRadarValues, Real()->m_CachedRadarValues + NUM_PLAYERS, m_CachedRadarValues );

    parent = NULL;

    if( bCopyNoteData )
        Compress();
}
示例#26
0
void CSoundStream::OnMove		( )
{
	VERIFY			( pBuffer );

	pBuffer->GetStatus( LPDWORD(&dwStatus) );

	if (isPause)	return;

	u32			currpos;
    u32			delta;

	if (dwStatus & DSBSTATUS_PLAYING){
		Update		();
		pBuffer->GetCurrentPosition(LPDWORD(&currpos),0);
		if (writepos<currpos) delta=currpos-writepos; else delta=dsBufferSize-(writepos-currpos);
		if(isPresentData && (delta>stream.cbDstLengthUsed)) {
			isPresentData = Decompress	(WaveDest);
			writepos+=stream.cbDstLengthUsed;
		}else{
			if (!isPresentData && (currpos<writepos)){
				Stop ( );
				if (bMustLoop&&!iLoopCountRested){
					Play(bMustLoop, iLoopCountRested);
				}else{
					if (bMustLoop){
						if (iLoopCountRested) iLoopCountRested--;
						if (!iLoopCountRested){ bMustLoop = false;
						}else{
							Play(bMustLoop, iLoopCountRested);
						}
					}
				}
			}
		}
		if (writepos>dsBufferSize) writepos-=dsBufferSize;
	} else {
		if (bMustPlay) {
			bMustPlay	= false;
			Update		( );
			pBuffer->Play	( 0, 0, DSBPLAY_LOOPING );
			dwStatus	|= DSBSTATUS_PLAYING;
		}
	}
}
示例#27
0
文件: a-lib.c 项目: asampal/ren-c
*/	RL_API int RL_Do_Binary(int *exit_status, const REBYTE *bin, REBINT length, REBCNT flags, REBCNT key, RXIARG *result)
/*
**	Evaluate an encoded binary script such as compressed text.
**
**	Returns:
**		The datatype of the result or zero if error in the encoding.
**	Arguments:
**		bin - by default, a REBOL compressed UTF-8 (or ASCII) script.
**		length - the length of the data.
**		flags - special flags (set to zero at this time).
**		key - encoding, encryption, or signature key.
**		result - value returned from evaluation.
**	Notes:
**		As of A104, only compressed scripts are supported, however,
**		rebin, cloaked, signed, and encrypted formats will be supported.
**
***********************************************************************/
{
	REBSER *text;
#ifdef DUMP_INIT_SCRIPT
	int f;
#endif
	int do_result;

	text = Decompress(bin, length, -1, FALSE, FALSE);
	if (!text) return FALSE;
	Append_Codepoint_Raw(text, 0);

#ifdef DUMP_INIT_SCRIPT
	f = _open("host-boot.r", _O_CREAT | _O_RDWR, _S_IREAD | _S_IWRITE );
	_write(f, STR_HEAD(text), LEN_BYTES(STR_HEAD(text)));
	_close(f);
#endif

	PUSH_GUARD_SERIES(text);
	do_result = RL_Do_String(exit_status, text->data, flags, result);
	DROP_GUARD_SERIES(text);

	Free_Series(text);
	return do_result;
}
示例#28
0
int main(int argc, char const *argv[])
{
    const char * inputFile ="../test_data/compress_test.log";
    const char * outputFile ="../test_data/compress_test.log.lzma";
    const char * outputFile2 ="../test_data/compress_test.log.decmp";
    char errMsg[800] ={0};

    int rt =Compress(inputFile, outputFile, errMsg);
    printf("Compress result code is %d \n", rt);
    if (0!=rt)
    {
        printf("Compress errMsg=%s \n", errMsg);
    }

    rt =Decompress(outputFile, outputFile2, errMsg);
    printf("Decompress result code is %d \n", rt);
    if (0!=rt)
    {
        printf("Decompress errMsg=%s \n", errMsg);
    }
    return 0;
}
示例#29
0
bool GSDumpLzma::Read(void* ptr, size_t size) {
	size_t off = 0;
	uint8_t* dst = (uint8_t*)ptr;
	size_t full_size = size;
	while (size && !IsEof()) {
		if (m_avail == 0) {
			Decompress();
		}

		size_t l = std::min(size, m_avail);
		memcpy(dst + off, m_area+m_start, l);
		m_avail -= l;
		size    -= l;
		m_start += l;
		off     += l;
	}

	if (size == 0) {
		Repack(ptr, full_size);
		return true;
	}

	return false;
}
示例#30
0
int main(int argc, char** argv) {
  char *input_path = 0;
  char *output_path = 0;
  char *dictionary_path = 0;
  int force = 0;
  int quality = 11;
  int decompress = 0;
  int repeat = 1;
  int verbose = 0;
  int lgwin = 0;
  clock_t clock_start;
  int i;
  ParseArgv(argc, argv, &input_path, &output_path, &dictionary_path, &force,
            &quality, &decompress, &repeat, &verbose, &lgwin);
  clock_start = clock();
  for (i = 0; i < repeat; ++i) {
    FILE* fin = OpenInputFile(input_path);
    FILE* fout = OpenOutputFile(output_path, force || repeat);
    int is_ok = 0;
    if (decompress) {
      is_ok = Decompress(fin, fout, dictionary_path);
    } else {
      is_ok = Compress(quality, lgwin, fin, fout, dictionary_path);
    }
    if (!is_ok) {
      unlink(output_path);
      exit(1);
    }
    if (fclose(fin) != 0) {
      perror("fclose");
      exit(1);
    }
    if (fclose(fout) != 0) {
      perror("fclose");
      exit(1);
    }
  }
  if (verbose) {
    clock_t clock_end = clock();
    double duration = (double)(clock_end - clock_start) / CLOCKS_PER_SEC;
    int64_t uncompressed_size;
    double uncompressed_bytes_in_MB;
    if (duration < 1e-9) {
      duration = 1e-9;
    }
    uncompressed_size = FileSize(decompress ? output_path : input_path);
    if (uncompressed_size == -1) {
      fprintf(stderr, "failed to determine uncompressed file size\n");
      exit(1);
    }
    uncompressed_bytes_in_MB =
        (double)(repeat * uncompressed_size) / (1024.0 * 1024.0);
    if (decompress) {
      printf("Brotli decompression speed: ");
    } else {
      printf("Brotli compression speed: ");
    }
    printf("%g MB/s\n", uncompressed_bytes_in_MB / duration);
  }
  return 0;
}