?? compress.h
字號(hào):
// Compress.h: interface for the CCompress class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_COMPRESS_H__1F79EC27_7E32_4268_A8C6_09D822F13D12__INCLUDED_)
#define AFX_COMPRESS_H__1F79EC27_7E32_4268_A8C6_09D822F13D12__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define INIT_BITS 9 //初始編碼大小
#define MAX_BITS 14 //最大編碼大小
#define HASHING_SHIFT MAX_BITS - 8 //哈希位移
#if MAX_BITS == 14
#define TABLE_SIZE 18041 /* 編碼表大小. 必須是一個(gè)大于2^MAX_S的素?cái)?shù)*/
#elif MAX_BITS == 13
#define TABLE_SIZE 9029
#else
#define TABLE_SIZE 5021
#endif
#define CLEAR_TABLE 256 /* 表滿刷新標(biāo)志 */
#define TERMINATOR 257 /* 解碼結(jié)束標(biāo)志 */
#define FIRST_CODE 258 /* 編碼表中第一個(gè)有效編碼 */
#define CHECK_TIME 500 /* Check comp ratio every CHECK_TIME chars input */
#define MAXVAL(n) (( 1 <<( n )) -1) /* max_value formula macro */
class CCompress
{
private:
int *code_value; /* This is the code value array */
unsigned int *prefix_code; /* This array holds the prefix codes */
unsigned char *append_character; /* This array holds the appended chars */
unsigned char *decode_stack; /* This array holds the decoded string */
int num_bits; /* Starting with 9 bit codes */
unsigned long bytes_in,bytes_out; /* Used to monitor compression ratio */
unsigned int max_code; /* old MAX_CODE */
unsigned long checkpoint; /* For compression ratio monitoring */
unsigned long incounts;
unsigned long outcounts;
unsigned long counts;
unsigned char *input,*output;
int input_bit_count;
unsigned long input_bit_buffer;
int output_bit_count;
unsigned long output_bit_buffer;
bool bFlagAlloc;
public:
void compress();
void uncompress();
bool init(unsigned char *inputs,unsigned long lens,unsigned char *outputs);
private:
int find_match(unsigned int hash_prefix, unsigned int hash_character);
void output_code(unsigned int code);
unsigned input_code();
unsigned char *decode_string(unsigned char *buffer, unsigned int code);
public:
void FreeTables();
bool AllocTables(void);
unsigned long GetInBytes();
unsigned long GetOutBytes();
CCompress();
virtual ~CCompress();
};
#endif // !defined(AFX_COMPRESS_H__1F79EC27_7E32_4268_A8C6_09D822F13D12__INCLUDED_)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -