Blame | Last modification | View Log | RSS feed
/*****************************************************************************HipPack-------This is the root class for the implementation of my hybrid compressionalgorithm which combines Huffman compression and LZ77.by yodaWWW: y0da.cjb.netE-mail: LordPE@gmx.netYou are allowed to use this class in your own projects if you keep thistrademark.*****************************************************************************/#pragma once#include <windows.h>#include "ByteReader.h"#include "macros.h"//// constants//#define HIP_MAJOR_VERSION 0#define HIP_MINOR_VERSION 2#define HP_MIN_MATCH_LEN 2#define HP_LITERAL_PREFIX 0#define HP_PTRSIZE_PREFIX 1/*#define HP_PTRSIZE_SHORTREF 10 - bits#define HP_PTRSIZE_NORMALREF 11 /*/#define HP_SHORTREF_BASE 2 // affects ptr !#define HP_NORMALREF_BASE 3 // affects ptr and size !#define HP_SHORTREF_MAX_SIZE 5#define HP_SHORTREF_PTR_BIT_COUNT 7//#define HP_MAX_MATCH_SIZE_BITS 6#define HP_MIN_LITERALS_IN_BLOCK 14#define HP_INITAL_BASE 8#define HP_BASE1_WIN 48 * 1024#define HP_BASE1 9#define HP_BASE2_WIN 64 * 1024#define HP_BASE2 10#define HP_BASE3_WIN 96 * 1024#define HP_BASE3 11#define HP_NREF_SIZE_DEC_INDEX4 0x18000#define HP_NREF_SIZE_DEC_INDEX3 0x10000#define HP_NREF_SIZE_DEC_INDEX2 0x37FF#define HP_NREF_SIZE_DEC_INDEX1 0x27F#define HIP_HDR_SIGNATURE 0x21506948 // "HiP!"#define HIP_ITERATION_FOR_CALLBACK 98#define HP_HUFF_ADAPT_ITERATION 512//// types//// the user should return TRUE to continue the compression// process and FALSE to abort ittypedef BOOL (__stdcall* hpCompressCallback)( DWORD cbDone, DWORD cbTotal );//// structures//#include <PshPack1.h> // turn on struct 1-byte-alignmenttypedef struct _HP_MATCH{DWORD dwRelOff;WORD wSize;} HP_MATCH, *PHP_MATCH;typedef struct _HIP_HEADER{DWORD Signature; // == HIP_HDR_SIGNATURE if validDWORD cbUncompressed;DWORD CRC; // 0 if unusedWORD MajorVersion;WORD MinorVersion;} HIP_HEADER, *PHIP_HEADER;typedef HP_MATCH HIP_MATCH_HISTORY;typedef HP_MATCH *PHIP_MATCH_HISTORY;#include <PopPack.h>//// HipPack class//class HipPack{public:HipPack( void* pInBuff, DWORD cbInBuff );~HipPack(void);void Dispose();BOOL PerformDecompression( OUT void** ppCompBlock, OUT DWORD* pdwcbBlock );hpCompressCallback SetCallback( hpCompressCallback proc );// void InterruptCompression();private:void* m_pBuff;DWORD m_cbBuff;void* m_pOut;PBYTE m_pbyValidHEntries;PHIP_MATCH_HISTORY m_pHistory;hpCompressCallback m_Callback;BOOL m_bStopRun;void FreeOutBuff();DWORD GammaDecodeDistance( PByteReader reader, DWORD dwcBaseBits );DWORD GammaDecodeLength( PByteReader reader );void MyMemCpy( void* pDest, const void* pSrc, DWORD cb );};typedef HipPack *PHipPack;