【数据压缩】Huffman编码

1.Huffman编码过程,程序   点击打开链接

http://zh.wikipedia.org/wiki/%E9%9C%8D%E5%A4%AB%E6%9B%BC%E7%BC%96%E7%A0%81

2.自适应Huffman编码过程

Quake3 自适应Huffman 编码   点击打开链接

http://wenku.baidu.com/view/8edaa04cf7ec4afe04a1df1b.html

http://zh.wikipedia.org/wiki/%E9%81%A9%E6%87%89%E6%80%A7%E9%9C%8D%E5%A4%AB%E6%9B%BC%E7%B7%A8%E7%A2%BC    点击打开链接

对于自适应的Huffman编码有多种实现:如FGK和Vitter

(Vitter过程)https://en.wikipedia.org/wiki/Adaptive_Huffman_coding   点击打开链接

自适应霍夫曼编码的C++版本简单实现 class AdaptiveTree { public: AdaptiveTree(int rootNum); AdaptiveTree(int rootNum, string str); void swap(int first, int second); // swap two nodes of the tree void initalCode(); // initializing the data string char2code(unsigned char letter); // locate the character in the tree with its corresponding binary string and return the string string char2binary(unsigned char letter); // translating the character to the 8-bit binary string unsigned char binary2char(string bin); // translating the binary string: bin to the corresponding character int spawn(unsigned char letter); // add a new character to the original tree void updateTree(unsigned char newchar); // update the tree int highestInBlock(int count); // return the highest node to be exchanged void setString(string str); // string decodingStr() const; void encoding(); string decoding(); unsigned char code2char(string bincode); static int size(); string binStr() const; // return the binary string of string: tempString private: void run(); int findchar(unsigned char letter ); // locate the letter in the tree string tempString; //temp string to be encoded needed to be stored here string deStr;// used for storing the decoding string string bin; // used for storing the result of encoding process /* Adaptive Tree data members */ HuffmanTree *tree; int root; /* Adaptive Tree constants */ static int ALPH_SIZE; // size of the alphabet static unsigned char none; // not a unsigned character static unsigned char NYT; // Not Yet transmitted code };
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值