⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hufftree.h

📁 My (so called) HiP compression algorithm as console mode utility. It s a hybrid of Lempel-Ziv 77 a
💻 H
字号:
#pragma once

#include <windows.h>
#include "DynamicStructChain.h"

//
// constants
//
#define HT_LEFT  0
#define HT_RIGHT 1

//
// structures
//
#include <PshPack1.h> // turn on struct 1-byte-alignment
typedef struct _HT_ITEM
{
	DWORD                    dwId;                         // a unique value
	BOOL                     bLinked;                      // already linked in the tree ?
/*	union
	{
		BYTE                 byData;
		WORD                 wData;
		DWORD                dwData;
	};*/
	DWORD                    dwData;
	DWORD                    dwDadId;                      // 0 == root item
	DWORD                    dwLeftId;
	DWORD                    dwRightId;  
	DWORD                    dwcOccurr;
//	float                    probability;                  // how often the character appears in the input block
	DWORD                    dwSequence;                   // bit signature for the character
	BYTE                     bySequLen;                    // length of the bit signature
} HT_ITEM, *PHT_ITEM;

typedef struct _HT_ITEM_EMIT // shorter version of HT_ITEM which will be emitted to the output
{
	WORD                     Id;
	WORD                     data;
	WORD                     wLeft;
	WORD                     wRight;
} HT_ITEM_EMIT, *PHT_ITEM_EMIT;
#include <PopPack.h>

//
// HuffTree class
//
class HuffTree
{
public:
	UINT      m_iRoot;            // currently only needed in decompression process
	DWORD     m_cbTreeEmitted;    // currently only needed in decompression process

	HuffTree(void);
	~HuffTree(void);
	void Dispose();

	BOOL      AddItem( DWORD dwData, DWORD dwcOccurrence );
	BOOL      AddItem( DWORD Id, DWORD dwData, DWORD dwLeftId, DWORD dwRightId );
	BOOL      Generate();
	DWORD     Emit( BYTE* pBuff, DWORD cbBuff );
	PHT_ITEM  ItemData2Ptr( DWORD dwItemData );

private:
	PDynamicStructChain      m_dscItems;

	void      LinkTreeElements();
	PHT_ITEM  ItemId2Ptr( DWORD id );
	void      GenerateBitSequences();
//	DWORD GetTreePlainCount();
};

typedef HuffTree *PHuffTree;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -