亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? compressarithmetic.cpp

?? 很好用的壓縮和解壓縮程序
?? CPP
字號:
// CompressArithmetic.cpp: implementation of the CCompressArithmetic class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Compress.h"
#include "CompressArithmetic.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCompressArithmetic::CCompressArithmetic()
{
	code_value=NULL;			/* This is the code value array */
	prefix_code=NULL;			/* This array holds the prefix codes */
	append_character=NULL;		/* This array holds the appended chars */
	decode_stack=NULL;			/* This array holds the decoded string */
	num_bits=INIT_BITS;			/* Starting with 9 bit codes */
	bytes_in=0,bytes_out=0;		/* Used to monitor compression ratio */
	input_bit_count=0;
	input_bit_buffer=0L;
	output_bit_count=0;
	output_bit_buffer=0L;
	checkpoint=CHECK_TIME;		/* For compression ratio monitoring */
	incounts=0;					/* Input Bytes */
	outcounts=0;				/* Output Bytes */
	counts=0;					/* Statistic */
	bFlagAlloc=false;
}

CCompressArithmetic::~CCompressArithmetic()
{
	/*掃尾*/
	if(code_value)
		code_value=(int*)GlobalFree(code_value);
	if(prefix_code)
		prefix_code=(unsigned int*)GlobalFree(prefix_code);
	if(append_character)
		append_character=(unsigned char*)GlobalFree(append_character);
	if(decode_stack)
		decode_stack=(unsigned char*)GlobalFree(decode_stack);
	bFlagAlloc=false;
}
/* MODIFIED This is the new compression routine. The first two 9-bit codes 
 * have been reserved for communication between the compressor and expander.
 */
void CCompressArithmetic::compress()
{
	unsigned int next_code=FIRST_CODE;
	unsigned int character;
	unsigned int string_code;
	unsigned int index;
	int i,				/* All purpose integer */
	ratio_new,			/* New compression ratio as a percentage */
	ratio_old=100;		/* Original ratio at 100% */

	num_bits=INIT_BITS;				/* Re-initialize for expansion */
	max_code = MAXVAL(num_bits);

	for (i=0;i<TABLE_SIZE;i++){		/* Initialize the string table first */
		code_value[i]=-1;
	}
	string_code=*input++;			/* Get the first code */
	incounts++;					
 /* This is the main compression loop. Notice when the table is full we try
  * to increment the code size. Only when num_bits == MAX_BITS and the code
  * value table is full do we start to monitor the compression ratio.
  */
	while(incounts<counts ) {
		character=*input++;
		incounts++;
		++bytes_in;
		index=find_match(string_code,character);
		if (code_value[index] != -1)
			string_code=code_value[index];
		else {
			if (next_code <= max_code ) {
				code_value[index]=next_code++;
				prefix_code[index]=string_code;
				append_character[index]=character;
			}
			output_code(string_code);		/* Send out current code */
			string_code=character;
			if (next_code > max_code) {			/* Is table Full? */
				if ( num_bits < MAX_BITS) {			/* Any more bits? */
					max_code = MAXVAL(++num_bits);			/* Increment code size then */
				}
				else if (bytes_in > checkpoint) {			/* At checkpoint? */
					if (num_bits == MAX_BITS ) {
						ratio_new = bytes_out*100/bytes_in;		/* New compression ratio */
						if (ratio_new > ratio_old) {			/* Has ratio degraded? */
							output_code(CLEAR_TABLE);			/* YES,flush string table */
							num_bits=INIT_BITS;
							next_code=FIRST_CODE;				/* Reset to FIRST_CODE */
							max_code = MAXVAL(num_bits);		/* Re-Initialize this stuff */
							bytes_in = bytes_out = 0;
							ratio_old=100;						/* Reset compression ratio */
							for (i=0;i<TABLE_SIZE;i++)			/* Reset code value array */
								code_value[i]=-1;
						}
						else									/* NO, then save new */
							ratio_old = ratio_new;				/* compression ratio */
					}
					checkpoint = bytes_in + CHECK_TIME;			/* Set new checkpoint */
				}
			}
		}
	}
	output_code(string_code);			/* Output the last code */
	if (next_code == max_code) {		/* Handles special case for bit */
		++num_bits;						/* increment on EOF */
	}
	output_code(TERMINATOR);			/* Output the end of buffer code */
	output_code(0);						/* Flush the output buffer */
	output_code(0);
	output_code(0);
}
/* MODIFIED This is the modified expansion routine. It must now check for the
 * CLEAR_TABLE code and know when to increment the code size.
 */
void CCompressArithmetic::uncompress()
{
	unsigned int next_code=FIRST_CODE;
	unsigned int new_code;
	unsigned int old_code;
	int character,
	counter=0,
	clear_flag=1;          /* Need to clear the code value array */
	unsigned char *string;
	num_bits=INIT_BITS;                  /* Re-initialize for expansion */
	max_code = MAXVAL(num_bits);
	while((new_code=input_code()) != TERMINATOR) {
	  if (clear_flag) {       /* Initialize or Re-Initialize */
		  clear_flag=0;
		  old_code=new_code;   /* The next three lines have been moved */
		  character=old_code;  /* from the original */
		  *output++=(unsigned char)old_code;
		  outcounts++;
		  continue;
	  }
	  if (new_code == CLEAR_TABLE) {     /* Clear string table */
		  clear_flag=1;
		  num_bits=INIT_BITS;
		  next_code=FIRST_CODE;
		  max_code = MAXVAL(num_bits);
		  continue;
	  }
	  if (++counter == 1000) {           /* Pacifier */
		  counter=0;
	  }
	  if (new_code >= next_code) {       /* Check for string+char+string */
		  *decode_stack=character;
		  string=decode_string(decode_stack+1,old_code);
	  }
	  else
		  string=decode_string(decode_stack,new_code);

	  character = *string;              /* Output decoded string in reverse */
	  while (string >= decode_stack){
		  *output++=*string--;
		  outcounts++;
	  }

	  if (next_code <= max_code) {      /* Add to string table if not full */
		  prefix_code[next_code]=old_code;
		  append_character[next_code++]=character;
		  if (next_code == max_code && num_bits < MAX_BITS) {
			  max_code = MAXVAL(++num_bits);
		  }
	  }
	  old_code=new_code;
	}
}

/* UNCHANGED from original
 * This is the hashing routine.
 */
int CCompressArithmetic::find_match(unsigned int hash_prefix, unsigned int hash_character)
{
	int index, offset;
	index = (hash_character << HASHING_SHIFT ) ^ hash_prefix;
	if (index == 0 )
		offset=1;
	else
		offset = TABLE_SIZE - index;
	while(1) {
		if (code_value[index] == -1 )
			return(index);
		if (prefix_code[index] == hash_prefix && 
									 append_character[index] == hash_character)
			return(index);
		index -= offset;
		if (index < 0)
			index += TABLE_SIZE;
	}
}

/* UNCHANGED from original
 * Decode a string from the string table, storing it in a buffer.
 * The buffer can then be output in reverse order by the expansion
 * program.
 */
unsigned char *CCompressArithmetic::decode_string(unsigned char *buffer, unsigned int code)
{
   int i=0;
   while(code > 255 ) {
	   *buffer++ = append_character[code];
	   code=prefix_code[code];
	   if (i++ >= 4000 ) {
			/*一般不會錯*/
		   ;
	   }
   }
   *buffer=code;
   return(buffer);
}

/* UNCHANGED from original
 * Input a variable length code.
 */
unsigned CCompressArithmetic::input_code()
{
	unsigned int return_value;
//	static int input_bit_count=0;
//	static unsigned long input_bit_buffer=0L;

	while (input_bit_count <= 24 ) {
		input_bit_buffer |= (unsigned long) (*input++) << (24 - input_bit_count);
		incounts++;
		input_bit_count += 8;
	}
	return_value=input_bit_buffer >> (32-num_bits);
	input_bit_buffer <<= num_bits;
	input_bit_count -= num_bits;
	return(return_value);
}
/* MODIFIED Output a variable length code.
 */
void CCompressArithmetic::output_code(unsigned int code)
{
//	static int output_bit_count=0;
//	static unsigned long output_bit_buffer=0L;
	output_bit_buffer |= (unsigned long) code << (32 - num_bits - 
															 output_bit_count);
	output_bit_count += num_bits;
	while (output_bit_count >= 8) {
		*output++=(unsigned char)(output_bit_buffer >> 24);
		output_bit_buffer <<= 8;
		output_bit_count -= 8;
		bytes_out++;                    /* ADDED for compression monitoring */
		outcounts++;
	}
}

bool CCompressArithmetic::AllocTables()
{
	bool flag=true;
	__try{
	code_value=(int*)GlobalAlloc(GPTR,TABLE_SIZE*sizeof(unsigned int));
	prefix_code=(unsigned int *)GlobalAlloc(GPTR,TABLE_SIZE*sizeof(unsigned int));
	append_character=(unsigned char*)GlobalAlloc(GPTR,TABLE_SIZE*sizeof(unsigned char));
	decode_stack=(unsigned char*)GlobalAlloc(GPTR,4000);
	bFlagAlloc=true;
	}
	__except(1){
		if(code_value)
			code_value=(int*)GlobalFree(code_value);
		if(prefix_code)
			prefix_code=(unsigned int*)GlobalFree(prefix_code);
		if(append_character)
			append_character=(unsigned char*)GlobalFree(append_character);
		if(decode_stack)
			decode_stack=(unsigned char*)GlobalFree(decode_stack);
			flag=false;
			bFlagAlloc=false;
		}
	return flag;
}

void CCompressArithmetic::FreeTables()
{
	if(code_value)
		code_value=(int*)GlobalFree(code_value);
	if(prefix_code)
		prefix_code=(unsigned int*)GlobalFree(prefix_code);
	if(append_character)
		append_character=(unsigned char*)GlobalFree(append_character);
	if(decode_stack)
		decode_stack=(unsigned char*)GlobalFree(decode_stack);
	bFlagAlloc=false;
}

bool CCompressArithmetic::init(unsigned char *inputs,unsigned long lens,unsigned char *outputs)
{
	if(!bFlagAlloc)
		return false;
	input=inputs;
	output=outputs;
	counts=lens;
	num_bits=INIT_BITS;               /* Starting with 9 bit codes */
	max_code = MAXVAL(num_bits);
	bytes_in=0,bytes_out=0; /* Used to monitor compression ratio */
	input_bit_count=0;
	input_bit_buffer=0L;
	output_bit_count=0;
	output_bit_buffer=0L;
	checkpoint=CHECK_TIME;  /* For compression ratio monitoring */
	incounts=0;
	outcounts=0;
	return true;
	
}

unsigned long CCompressArithmetic::GetOutBytes()
{
	return outcounts;
}

unsigned long CCompressArithmetic::GetInBytes()
{
	return incounts;
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产视频一区在线播放| 中文字幕av不卡| 91在线观看视频| 日韩高清一区在线| 一色桃子久久精品亚洲| 久久一区二区三区国产精品| 在线视频一区二区三| 国产精品综合在线视频| 亚洲国产日产av| 中文字幕不卡在线播放| 日韩欧美国产不卡| 在线观看91视频| jiyouzz国产精品久久| 韩国精品主播一区二区在线观看 | 国产成人免费视频| 日韩和的一区二区| 亚洲精品国产成人久久av盗摄 | 亚洲午夜精品17c| 国产精品色婷婷久久58| 2024国产精品| 欧美成人精品福利| 7777女厕盗摄久久久| 在线观看网站黄不卡| av中文字幕一区| 高清国产午夜精品久久久久久| 蜜桃视频第一区免费观看| 亚洲bt欧美bt精品| 亚洲午夜在线视频| 亚洲夂夂婷婷色拍ww47| 亚洲精品视频在线看| 中文字幕一区二区三区四区 | 国产精品久久久久一区| 国产日韩影视精品| 国产欧美日韩综合| 国产亚洲人成网站| 国产精品视频一区二区三区不卡 | 亚洲一区二区视频在线| 亚洲美女一区二区三区| 亚洲人成伊人成综合网小说| 中文字幕中文字幕一区二区| 国产精品二三区| 国产精品超碰97尤物18| 亚洲色欲色欲www| 亚洲欧美一区二区久久| 中文字幕综合网| 一区二区三区资源| 午夜一区二区三区视频| 日本成人在线视频网站| 极品少妇xxxx偷拍精品少妇| 国内偷窥港台综合视频在线播放| 久久精品噜噜噜成人88aⅴ| 国产中文字幕精品| 丁香网亚洲国际| 99精品久久只有精品| 91视频一区二区| 欧美性感一区二区三区| 欧美日韩精品欧美日韩精品| 91精品国产一区二区三区蜜臀| 精品少妇一区二区三区日产乱码 | 日韩午夜av一区| 久久色.com| 国产精品国产三级国产aⅴ入口| 亚洲最新视频在线播放| 亚洲444eee在线观看| 麻豆高清免费国产一区| 国产精品一区二区x88av| 99r国产精品| 3751色影院一区二区三区| 久久久777精品电影网影网 | 欧美日韩午夜精品| 欧美一激情一区二区三区| 久久麻豆一区二区| 亚洲激情图片小说视频| 日本一道高清亚洲日美韩| 国产精品资源网| 色综合久久综合网97色综合| 欧美一区二区三区影视| 国产喂奶挤奶一区二区三区| 亚洲国产精品一区二区久久| 韩国精品主播一区二区在线观看| 99国内精品久久| 日韩女优毛片在线| 亚洲精选视频在线| 国产在线播精品第三| 在线观看免费亚洲| 欧美精品一区二区三区四区| 一区二区久久久久久| 九九九精品视频| 色天使色偷偷av一区二区| 精品入口麻豆88视频| 亚洲人吸女人奶水| 国产一区二区导航在线播放| 欧美在线你懂的| 久久婷婷成人综合色| 亚洲一区二区中文在线| 国产成人av电影| 欧美日本免费一区二区三区| 国产亚洲精品bt天堂精选| 午夜精品久久久久久久久久久| 成人免费视频一区| 欧美大胆一级视频| 亚洲一区在线观看免费| 东方aⅴ免费观看久久av| 欧美一区二区在线观看| 亚洲激情第一区| 国产成人免费9x9x人网站视频| 欧美一区二区三区在线| 亚洲激情男女视频| av在线不卡免费看| 久久久久久9999| 久久国产精品无码网站| 欧美剧在线免费观看网站 | 精品播放一区二区| 亚洲高清三级视频| 日本精品免费观看高清观看| 国产精品久久久久久久裸模 | 激情五月婷婷综合网| 欧美美女黄视频| 亚洲一区二区三区美女| 波多野结衣的一区二区三区| 精品国产污污免费网站入口| 三级在线观看一区二区| 欧美色精品天天在线观看视频| 亚洲男人都懂的| 91啪九色porn原创视频在线观看| 国产免费观看久久| 国产尤物一区二区在线| 精品日韩99亚洲| 老司机免费视频一区二区三区| 欧美一区在线视频| 蜜臀精品久久久久久蜜臀| 欧美精品日日鲁夜夜添| 亚洲福利一二三区| 欧美日本免费一区二区三区| 午夜精品久久久久久久久久久| 欧美日韩成人综合| 日韩电影在线观看网站| 9191国产精品| 麻豆一区二区三区| 日韩视频在线你懂得| 久久精品国产一区二区| 久久综合一区二区| 国产乱色国产精品免费视频| 久久九九全国免费| 成人黄色大片在线观看| 18欧美亚洲精品| 欧美影片第一页| 日欧美一区二区| 日韩精品一区在线| 国模冰冰炮一区二区| 国产精品嫩草久久久久| 一本在线高清不卡dvd| 亚洲国产精品麻豆| 欧美一区二区三区公司| 精品亚洲成a人| 国产精品网站一区| 在线看国产日韩| 丝袜美腿亚洲色图| 久久无码av三级| 91丝袜美腿高跟国产极品老师 | 国产日韩欧美不卡| 91免费视频观看| 亚洲超碰97人人做人人爱| 日韩一区二区精品葵司在线| 国产精品一区三区| 亚洲免费观看视频| 欧美一级片免费看| 成人午夜视频在线观看| 一区二区三区日韩在线观看| 在线播放视频一区| 国产成人综合在线观看| 一个色妞综合视频在线观看| 欧美一级免费大片| 99久久免费国产| 日韩精彩视频在线观看| 国产欧美日韩三级| 欧美精品v日韩精品v韩国精品v| 黑人精品欧美一区二区蜜桃| 日韩理论片一区二区| 欧美一区二区三区不卡| 成人性视频免费网站| 亚洲成人激情自拍| 国产三区在线成人av| 欧美另类久久久品| eeuss国产一区二区三区| 免费xxxx性欧美18vr| 亚洲少妇30p| 精品国产91洋老外米糕| 色综合天天视频在线观看| 久久66热re国产| 亚洲一区二区三区小说| 国产欧美一区二区在线| 3d成人动漫网站| 日本福利一区二区| 国产毛片精品视频| 偷拍与自拍一区| 日韩美女久久久| 久久精品男人天堂av| 欧美精品自拍偷拍动漫精品| 97精品久久久午夜一区二区三区 |