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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? arith-n.cpp

?? 算術編碼c程序實現
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
				table->links = (LINKS*)calloc(new_size, 1);
			else
				table->links = (LINKS*)realloc((char*)table->links, new_size);
			if (table->links == NULL)
				fatal_error("Error #9: reallocating table space!");
			table->links[index].next = NULL;
		}
		new_size = sizeof(STATS);
		new_size *= table->max_index + 1;
		if (table->max_index == 0)
			table->stats = (STATS*)calloc(new_size, 1);
		else
			table->stats = (STATS*)realloc((char*)table->stats, new_size);
		if (table->stats == NULL)
			fatal_error("Error #10: reallocating table space!");
		table->stats[index].symbol = (unsigned char)symbol;
		table->stats[index].counts = 0;
	}
	// now I move the symbol to the front of its list
	i = index;
	while (i > 0 && table->stats[index].counts == table->stats[i - 1].counts)
		i--;
	if (i != index)
	{
		temp = table->stats[index].symbol;
		table->stats[index].symbol = table->stats[i].symbol;
		table->stats[i].symbol = temp;
		if (table->links != NULL)
		{
			temp_ptr = table->links[index].next;
			table->links[index].next = table->links[i].next;
			table->links[i].next = temp_ptr;
		}
		index = i;
	}
	// the switch has been performed. now I can update the counts
	table->stats[index].counts++;
	if (table->stats[index].counts == 255)
		rescale_table(table);
}

int convert_int_to_symbol(int c, SYMBOL* s)
{
	int i;
	CONTEXT* table;

	table = contexts[current_order];
	totalize_table(table);
	s->scale = totals[0];
	if (current_order == -2)
		c = -c;
	for ( i = 0; i <= table->max_index; i++ )
	{
		if (c == (int)table->stats[i].symbol)
		{
			if (table->stats[i].counts == 0)
				break;
			s->low_count = totals[i+2];
			s->high_count = totals[i+1];
			return (0);
		}
	}
	s->low_count = totals[1];
	s->high_count = totals[0];
	current_order--;
	return (1);
}

void get_symbol_scale( SYMBOL* s )
{
	CONTEXT* table;

	table = contexts[current_order];
	totalize_table(table);
	s->scale = totals[0];
}

int convert_symbol_to_int(int count, SYMBOL* s)
{
	int c;
	CONTEXT* table;
	
	table = contexts[current_order];
	for ( c = 0; count < totals[c]; c++ )
		;
	s->high_count = totals[c - 1];
	s->low_count = totals[c];
	if (c == 1)
	{
		current_order--;
		return (ESCAPE);
	}
	if (current_order < -1)
		return ((int) -table->stats[c - 2].symbol);
	else
		return (table->stats[c - 2].symbol);
}

void add_character_to_model( int c )
{
	int i;
	if (max_order < 0 || c < 0)
		return;
	contexts[max_order] = 
		shift_to_next_context(contexts[max_order], c, max_order);
	for (i = max_order - 1; i > 0; i--)
		contexts[i] = contexts[i + 1]->lesser_context;
}

CONTEXT* shift_to_next_context(CONTEXT* table, int c, int order)
{
	int i;
	CONTEXT* new_lesser;

	// first, try to find the new context by backing up the lesser
	// context and searching its link table. if I find the link, we take
	// a quick and easy exit, returning the link. note that their is a 
	// special Kludge for context order 0. we hnow for a fact that 
	// that lesser context pointer at order 0 points to the null table.
	// order -1, and we know that the -1 table only has a single link
	// pointer. which points back to the order 0 table.
	table = table->lesser_context;
	if (order == 0)
		return (table->links[0].next);
	for (i = 0; i <= table->max_index; i++)
		if ( table->stats[i].symbol == (unsigned char)c )
			if ( table->links[i].next != NULL)
				return (table->links[i].next);
			else
				break;

	// if I get here, it means the new context did not exist. I have to 
	// create the new context, add a link to it here, and add the backwards
	// link to *his* previous context. Creating the table and adding it to
	// this table is pretty easy. but adding the back pointer isn't. Since
	// creating the new back pointer isn't easy, I duck my responsibility
	// and recurse to myself in order to pick it up.
	new_lesser = shift_to_next_context(table, c, order - 1);

	// Now that I have the back pointer for this table, I can make a call
	// to a utility to allocate the new table
	table = allocate_next_order_table(table, c, new_lesser);
	return (table);
}

// rexdaling the table needs to be done for one of three reasons.
// first, if the maximum count for the table has exceeded 16383, it 
// means that arithmetic coding using 16 and 32 bit registers might
// no longer work. secondly, if an individual symbol count has
// reached 255, it will no longer fit in a byte. third, if the
// current model isn't compressing well, the compressor program may 
// want to rescale all tables in order to give more weight to newer
// statistics.
// all this routine does is divide each count by 2. if any counts
// drop to 0, the counters can be removed from the stats table, but 
// only if this is a leaf context. Otherwise, we might cut a link to 
// a higher order table.
void rescale_table(CONTEXT* table)
{
	int i;

	if ( table->max_index == -1)
		return;
	for( i = 0; i <= table->max_index; i++)
		table->stats[i].counts /= 2;
	if (table->stats[table->max_index].counts == 0 &&
			table->links == NULL)
	{
		while ( table->stats[table->max_index].counts == 0 &&
				table->max_index >= 0)
			table->max_index--;
		if (table->max_index == -1)
		{
			free( (char*) table->stats );
			table->stats = NULL;
		}
		else
		{
			table->stats = (STATS*)realloc((char*)table->stats, 
				sizeof(STATS) * (table->max_index + 1));
			if (table->stats == NULL)
				fatal_error("Error #11: reallocating stats space!");
		}
	}
}


// this routine has the job of creating a cumulative totals table for
// a given context. the cumulative low and high for symbol c are going to 
// be shored in totals[c + 2] and totals[c + 1]. Locations 0 and 1 are 
// reserved for the special ESCAPE symbol.
void totalize_table(CONTEXT* table)
{
	int i;
	unsigned char max;

	for(;;)
	{
		max = 0;
		i = table->max_index + 2;
		totals[i] = 0;
		for (; i > 1; i--)
		{
			totals[i - 1] = totals[i];
			if (table->stats[i - 2].counts)
				if ((current_order == -2) || 
						scoreboard[table->stats[i - 2].symbol] == 0)
					totals[i - 1] += table->stats[i - 2].counts;
			if (table->stats[i - 2].counts > max)
				max = table->stats[i - 2].counts;
		}

		// here is where the escape calulation needs to take place.
		if  (max == 0)
			totals[0] = 1;
		else
		{
			totals[0] = (short int)(256 - table->max_index);
			totals[0] *= table->max_index;
			totals[0] /= 256;
			totals[0] /= max;
			totals[0]++;
			totals[0] += totals[1];
		}
		if (totals[0] < MAXIMUM_SCALE)
			break;
		rescale_table(table);
	}
	for(i = 0; i < table->max_index; i++)
		if (table->stats[i].counts != 0)
			scoreboard[table->stats[i].symbol] = 1;
}

void recursive_flush( CONTEXT* table )
{
	int i;
	if (table->links != NULL)
		for ( i = 0; i <= table->max_index; i++)
			if (table->links[i].next != NULL)
				recursive_flush(table->links[i].next);
	rescale_table(table);
}

void flush_model()
{
	putc('F', stdout);
	recursive_flush(contexts[0]);
}


//---------------------------------------------------------------
// everything from here down define the arithmetic coder section
// of the program

static unsigned short int code;		// the present input code value
static unsigned short int low;		// start of the current code range
static unsigned short int high;		// end of the current code range
long underflow_bits;				// number of underflow bits pending

void initialize_arithmetic_encoder()
{
	low = 0;
	high = 0xffff;
	underflow_bits = 0;
}

void flush_arithmetic_encoder( BIT_FILE* stream )
{
	OutputBit( stream, low & 0x4000 );
	underflow_bits++;
	while( underflow_bits-- > 0 )
		OutputBit( stream, ~low & 0x4000 );
	OutputBits( stream, 0L, 16 );
}

void encode_symbol( BIT_FILE* stream, SYMBOL* s )
{
	long range; 

	// these three lines rescale high and low for the new symbol.
	range = (long)(high - low) + 1;
	high = low + (unsigned short int)
			((range * s->high_count) / s->scale - 1);
	low = low + (unsigned short int)
			((range * s->low_count) / s->scale);

	// this loop turns out new bits until high and low are far enough
	// apart to have stabilized.
	for (;;)
	{
		// if this test passer, it means that the MSDigits match, and can
		// be sent to the output stream.
		if ((high & 0x8000) == (low & 0x8000))
		{
			OutputBit( stream, high & 0x8000 );
			while ( underflow_bits > 0 )
			{
				OutputBit( stream, ~high & 0x8000);
				underflow_bits--;
			}
		}
		// if this test passes, the numbers are in danger of underflow, because
		// the MSDigits don't match, and the 2nd digits are just one apart.
		else if ((low & 0x4000) && !(high & 0x4000))
		{
			underflow_bits += 1;
			low &= 0x3fff;
			high |= 0x4000;
		}
		else
			return;
		low <<= 1;
		high <<= 1;
		high |= 1;
	}
}

short int get_current_count( SYMBOL* s )
{
	long range;
	short int count;

	range = (long)(high - low) + 1;
	count = (short int)
			((((long) ( code - low ) + 1) * s->scale - 1) / range);
	return (count);
}

void initialize_arithmetic_decoder( BIT_FILE* stream )
{
	int i;
	code = 0;
	for (i = 0; i < 16; i++)
	{
		code <<= 1;
		code += InputBit(stream);
	}
	low = 0;
	high = 0xffff;
}

void remove_symbol_from_stream( BIT_FILE* stream, SYMBOL* s )
{
	long range;

	// first, the range is expanded to account for the symbol removal
	range = (long)(high - low) + 1;
	high = low + (unsigned short int)
			((range * s->high_count) / s->scale - 1);
	low = low + (unsigned short int)
			((range * s->low_count) / s->scale);
	// next, any possible bits are shipped out
	for (;;)
	{
		// if the MSDigits match, the ibts will be shifted out.
		if ((high & 0x8000) == (low & 0x8000))
		{
		}
		// else, if underflow is threatening, shift out the 2nd MSDigit.
		else if ((low & 0x4000) == 0x4000 && (high & 0x4000) == 0)
		{
			code ^= 0x4000;
			low &= 0x3fff;
			high |= 0x4000;
		}
		// otherwise, nothing can be shifted out, so I return.
		else
			return;
		low <<= 1;
		high <<= 1;
		high |= 1;
		code <<= 1;		
		code += InputBit(stream);
	}
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
香蕉影视欧美成人| 51精品国自产在线| 成人av在线播放网站| 久久99精品国产.久久久久| 日本成人超碰在线观看| 麻豆精品久久精品色综合| 日韩av网站在线观看| 免费久久精品视频| 精品一区二区日韩| 国产成人在线视频播放| 国产成人综合在线播放| av男人天堂一区| 色琪琪一区二区三区亚洲区| 欧美中文一区二区三区| 欧美日免费三级在线| 欧美精品乱人伦久久久久久| 欧美大片国产精品| 久久久久久久电影| 国产精品入口麻豆原神| 亚洲激情校园春色| 天涯成人国产亚洲精品一区av| 免费看日韩a级影片| 国内精品国产成人| 91免费看片在线观看| 欧美性生活久久| 欧美成人乱码一区二区三区| 欧美国产视频在线| 亚洲一区二区三区免费视频| 免费看欧美女人艹b| 国产ts人妖一区二区| 色噜噜狠狠成人中文综合| 欧美裸体bbwbbwbbw| 精品免费视频.| 国产精品久久久久久久久免费樱桃| 亚洲精品写真福利| 免费成人深夜小野草| 国产成人综合亚洲91猫咪| 91麻豆6部合集magnet| 日韩一级黄色片| 国产精品久久久久久亚洲伦 | 久久久蜜桃精品| 中文字幕在线观看不卡| 亚洲国产另类精品专区| 国产在线一区二区综合免费视频| av成人免费在线观看| 日韩视频免费观看高清完整版 | 日韩精品高清不卡| 粉嫩蜜臀av国产精品网站| 欧美视频中文一区二区三区在线观看 | 懂色av噜噜一区二区三区av| 欧美在线视频日韩| 国产色产综合产在线视频| 亚洲一二三级电影| 国产一区二区不卡| 欧美日韩综合在线免费观看| 欧美国产一区二区| 免费人成精品欧美精品| 色婷婷精品大在线视频| 久久精品亚洲乱码伦伦中文| 亚洲成av人片观看| jlzzjlzz亚洲女人18| 337p日本欧洲亚洲大胆精品| 亚洲精品成人少妇| 成人午夜视频网站| 欧美成人猛片aaaaaaa| 亚洲一区二区三区中文字幕在线| 国产美女在线精品| 制服丝袜亚洲精品中文字幕| 亚洲人妖av一区二区| 国产综合色在线视频区| 欧美日韩国产欧美日美国产精品| 国产精品美女久久久久av爽李琼| 免费精品视频在线| 欧美日本一区二区| 亚洲乱码中文字幕综合| 福利一区二区在线| 欧美精品一区二区三区蜜臀| 亚洲成人一区在线| 色综合久久66| 国产精品久久网站| 国产成人丝袜美腿| 欧美mv和日韩mv的网站| 日韩电影免费一区| 欧美片在线播放| 一区二区高清视频在线观看| www.亚洲在线| 中文字幕精品在线不卡| 国产精品亚洲成人| 久久老女人爱爱| 国产一区二区三区黄视频| 精品国产乱码久久久久久牛牛| 免费亚洲电影在线| 日韩免费在线观看| 日产国产欧美视频一区精品| 69久久夜色精品国产69蝌蚪网| 亚洲一区二区在线免费看| 色噜噜久久综合| 亚洲人成人一区二区在线观看| www.亚洲免费av| 国产精品欧美久久久久无广告 | 一本色道久久综合亚洲91| 自拍视频在线观看一区二区| 成人av免费观看| 国产精品免费aⅴ片在线观看| 成人激情综合网站| 中文字幕一区二区在线观看| 不卡欧美aaaaa| 自拍偷拍亚洲综合| 色94色欧美sute亚洲13| 曰韩精品一区二区| 欧美色视频一区| 五月天精品一区二区三区| 欧美日本在线观看| 蜜桃av一区二区三区电影| 欧美一区二区三区人| 精一区二区三区| 国产欧美精品国产国产专区| 成人久久18免费网站麻豆| 亚洲色图制服诱惑| 欧美伊人久久久久久久久影院 | 91丨九色丨尤物| 一区二区三区免费在线观看| 欧美色图天堂网| 日韩成人精品在线| 久久天堂av综合合色蜜桃网| 国产suv精品一区二区6| 亚洲欧美二区三区| 欧美日韩精品欧美日韩精品| 久久不见久久见免费视频7| 日本一区二区成人在线| 色综合久久中文字幕| 日本欧美韩国一区三区| 国产日产欧美一区| 色婷婷久久久久swag精品| 视频一区在线视频| 国产亚洲欧美一区在线观看| 91亚洲国产成人精品一区二三| 亚洲成人动漫精品| 久久久久国产精品厨房| 91在线丨porny丨国产| 日韩精品国产精品| 国产精品网站在线| 4438x成人网最大色成网站| 国产一区中文字幕| 伊人开心综合网| 欧美成人精品高清在线播放| www.av亚洲| 久久超级碰视频| 亚洲欧美日韩在线播放| 欧美电视剧免费观看| 99国内精品久久| 黄色日韩网站视频| 亚洲最大成人综合| 久久久国际精品| 欧美三级在线播放| 成人丝袜高跟foot| 日本欧美在线观看| 亚洲美女区一区| 久久久青草青青国产亚洲免观| 欧美亚洲综合色| 成人精品一区二区三区中文字幕| 五月综合激情婷婷六月色窝| 欧美国产日韩在线观看| 666欧美在线视频| 91蜜桃网址入口| 国产精品一区免费在线观看| 亚洲电影你懂得| 国产精品久久久久9999吃药| 精品区一区二区| 欧美精品高清视频| 91美女福利视频| 国产a精品视频| 久久黄色级2电影| 亚洲成人先锋电影| 亚洲色图欧美在线| 欧美激情中文字幕一区二区| 日韩欧美在线一区二区三区| 欧美在线观看一区| 成人h动漫精品一区二| 国产一区二区中文字幕| 日韩电影网1区2区| 亚洲国产日日夜夜| 亚洲免费看黄网站| 久久精品久久久精品美女| 欧美天堂亚洲电影院在线播放| 91麻豆精品国产自产在线观看一区| 成人av电影免费观看| 国产一区二区三区香蕉| 日韩高清一级片| 亚洲成国产人片在线观看| 国产精品国产成人国产三级 | 国产亚洲欧美日韩俺去了| 欧美一区二区三区日韩视频| 欧美吞精做爰啪啪高潮| 91麻豆自制传媒国产之光| 91免费视频大全| 91在线小视频| 一本一道综合狠狠老| 91视频com| 日本高清免费不卡视频|