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

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

?? optfmtch.c

?? windows gzip source code
?? C
字號:
/*
 * optfmtch.c
 *
 * Match finder for the optimal parser
 */
#include <string.h>
#include <stdio.h>
#include <crtdbg.h>
#include "deflate.h"


#define VERIFY_SEARCH_CODE(routine_name) \
{ \
	int debug_search; \
	for (debug_search = 0; debug_search < clen; debug_search++) \
	{ \
		if (window[ptr+debug_search] != window[BufPos+debug_search]) \
		{ \
			_RPT2( \
				_CRT_WARN, \
				routine_name \
				" char mismatch @%3d (clen=%d)\n", \
				debug_search, clen); \
			\
			_RPT3( \
				_CRT_WARN, \
				" ptr=%8d, bufpos=%8d, end_pos=%8d\n\n", \
				ptr, BufPos, end_pos); \
			_ASSERT(0); \
		} \
	} \
}


#define VERIFY_MULTI_TREE_SEARCH_CODE(routine_name) \
	_ASSERT(window[BufPos] == window[ptr]); \
	_ASSERT(window[BufPos+1] == window[ptr+1]);


/*
 * Finds the closest matches of all possible lengths, MIN_MATCH <= x <= MAX_MATCH,
 * at position BufPos.
 *
 * The positions of each match location are stored in context->matchpos_table[]
 *
 * Returns the longest such match length found, or zero if no matches found.
 */
int optimal_find_match(t_encoder_context *context, long BufPos)
{
	ULONG		ptr;
	ULONG       a, b;
	t_search_node *small_ptr, *big_ptr;
	t_search_node *left = context->optimal_encoder->search_left;
	t_search_node *right = context->optimal_encoder->search_right;
	t_match_pos *matchpos_table = context->optimal_encoder->matchpos_table;
	BYTE *window = context->optimal_encoder->window;
	ULONG       end_pos;
	int         val; /* must be signed */
	int         clen;
	int         same;
	int         match_length;
	int         small_len, big_len;
	USHORT      tree_to_use;

	/*
	 * Retrieve root node of tree to search, and insert current node at
	 * the root.
	 */
	tree_to_use = *((USHORT UNALIGNED *) &window[BufPos]);
	
	ptr        = context->optimal_encoder->search_tree_root[tree_to_use];
	context->optimal_encoder->search_tree_root[tree_to_use] = (t_search_node) BufPos;

	/*
	 * end_pos is the furthest location back we will search for matches 
	 *
	 * Remember that our window size is reduced by 3 bytes because of
	 * our repeated offset codes.
	 *
	 * Since BufPos starts at WINDOW_SIZE when compression begins,
	 * end_pos will never become negative.  
	 */
	end_pos = BufPos - (WINDOW_SIZE-4);

	/*
	 * Root node is either NULL, or points to a really distant position.
	 */
	if (ptr <= end_pos)
	{
		left[BufPos] = right[BufPos] = 0;
		return 0;
	}

	/*
	 * confirmed length (no need to check the first clen chars in a search)
	 *
	 * note: clen is always equal to min(small_len, big_len)
	 */
	clen            = 2;

	/*
	 * current best match length
	 */
	match_length    = 2;

	/*
	 * longest match which is < our string
	 */
	small_len       = 2;

	/*
	 * longest match which is > our string
	 */
	big_len         = 2;

#ifdef _DEBUG
	VERIFY_MULTI_TREE_SEARCH_CODE("binary_search_findmatch()");
#endif

	/*
	 * pointers to nodes to check
	 */
	small_ptr             = &left[BufPos];
	big_ptr               = &right[BufPos];

	do
	{
		/* compare bytes at current node */
		same = clen;

#ifdef _DEBUG
		VERIFY_SEARCH_CODE("optimal_findmatch()")
#endif

		/* don't need to check first clen characters */
		a    = ptr + clen;
		b    = BufPos + clen;

		while ((val = ((int) window[a++]) - ((int) window[b++])) == 0)
		{
			/* don't exceed MAX_MATCH */
			if (++same >= MAX_MATCH)
				goto long_match;
		}

		if (val < 0)
		{
			if (same > big_len)
			{
				if (same > match_length)
				{
long_match:
					do
					{
						matchpos_table[++match_length] = BufPos-ptr-1;
					} while (match_length < same);

					if (same >= BREAK_LENGTH)
					{
						*small_ptr = left[ptr];
						*big_ptr   = right[ptr];
						goto end_bsearch;
					}
				}

				big_len = same;
				clen = min(small_len, big_len);
			}

			*big_ptr = (t_search_node) ptr;
			big_ptr  = &left[ptr];
			ptr      = *big_ptr;
		}
		else
		{
			if (same > small_len)
			{
				if (same > match_length)
				{
					do
					{
						matchpos_table[++match_length] = BufPos-ptr-1;
					} while (match_length < same);

					if (same >= BREAK_LENGTH)
					{
						*small_ptr = left[ptr];
						*big_ptr   = right[ptr];
						goto end_bsearch;
					}
				}

				small_len = same;
				clen = min(small_len, big_len);
			}
		
			*small_ptr = (t_search_node) ptr;
			small_ptr  = &right[ptr];
			ptr        = *small_ptr;
		}
	} while (ptr > end_pos); /* while we don't go too far backwards */

	*small_ptr = 0;
	*big_ptr   = 0;


end_bsearch:

	/*
	 * If we have multiple search trees, we are already guaranteed
	 * a minimum match length of 2 when we reach here.
	 *
	 * If we only have one tree, then we're not guaranteed anything.
	 */
    if (match_length < MIN_MATCH)
        return 0;
    else
	    return (long) match_length;
}


/*
 * Inserts the string at the current BufPos into the tree.
 *
 * Does not record all the best match lengths or otherwise attempt
 * to search for matches
 *
 * Similar to the above function.
 */
void optimal_insert(t_encoder_context *context, long BufPos, long end_pos)
{
	long        ptr;
	ULONG       a,b;
	t_search_node *small_ptr, *big_ptr;
	t_search_node *left = context->optimal_encoder->search_left;
	t_search_node *right = context->optimal_encoder->search_right;
	BYTE *window = context->optimal_encoder->window;
	int         val;
	int         small_len, big_len;
	int         same;
	int         clen;
	USHORT      tree_to_use;

	tree_to_use = *((USHORT UNALIGNED *) &window[BufPos]);
	ptr        = context->optimal_encoder->search_tree_root[tree_to_use];
	context->optimal_encoder->search_tree_root[tree_to_use] = (t_search_node) BufPos;

	if (ptr <= end_pos)
	{
		left[BufPos] = right[BufPos] = 0;
		return;
	}

	clen            = 2;
	small_len       = 2;
	big_len         = 2;

#ifdef _DEBUG
	VERIFY_MULTI_TREE_SEARCH_CODE("quick_insert_bsearch_findmatch()");
#endif

	small_ptr       = &left[BufPos];
	big_ptr         = &right[BufPos];

	do
	{
		same = clen;

		a    = ptr+clen;
		b    = BufPos+clen;

#ifdef _DEBUG
		VERIFY_SEARCH_CODE("quick_insert_bsearch_findmatch()")
#endif

		while ((val = ((int) window[a++]) - ((int) window[b++])) == 0)
		{
			/*
			 * Here we break on BREAK_LENGTH, not MAX_MATCH
			 */
			if (++same >= BREAK_LENGTH) 
				break;
		}

		if (val < 0)
		{
			if (same > big_len)
			{
				if (same >= BREAK_LENGTH)
				{
					*small_ptr = left[ptr];
					*big_ptr = right[ptr];
					return;
				}

				big_len = same;
				clen = min(small_len, big_len);
			}
			
			*big_ptr = (t_search_node) ptr;
			big_ptr  = &left[ptr];
			ptr      = *big_ptr;
		}
		else
		{
			if (same > small_len)
			{
				if (same >= BREAK_LENGTH)
				{
					*small_ptr = left[ptr];
					*big_ptr = right[ptr];
					return;
				}

				small_len = same;
				clen = min(small_len, big_len);
			}

			*small_ptr = (t_search_node) ptr;
			small_ptr  = &right[ptr];
			ptr        = *small_ptr;
		}
   } while (ptr > end_pos);

	*small_ptr = 0;
	*big_ptr   = 0;
}


/*
 * Remove a node from the search tree; this is ONLY done for the last
 * BREAK_LENGTH symbols (see optenc.c).  This is because we will have
 * inserted strings that contain undefined data (e.g. we're at the 4th
 * last byte from the file and binary_search_findmatch() a string into
 * the tree - everything from the 4th symbol onwards is invalid, and
 * would cause problems if it remained in the tree, so we have to
 * remove it).
 */
void optimal_remove_node(t_encoder_context *context, long BufPos, ULONG end_pos)
{
	ULONG   ptr;
	ULONG   left_node_pos;
	ULONG   right_node_pos;
	USHORT  tree_to_use;
	t_search_node *link;
	t_search_node *left = context->optimal_encoder->search_left;
	t_search_node *right = context->optimal_encoder->search_right;
	BYTE *window = context->optimal_encoder->window;

	/*
	 * The root node of tree_to_use should equal BufPos, since that is
	 * the most recent insertion into that tree - but if we never
	 * inserted this string (because it was a near match or a long
	 * string of zeroes), then we can't remove it.
	 */
	tree_to_use = *((USHORT UNALIGNED *) &window[BufPos]);


	/*
	 * If we never inserted this string, do not attempt to remove it
	 */

	if (context->optimal_encoder->search_tree_root[tree_to_use] != BufPos)
		return;

	link = &context->optimal_encoder->search_tree_root[tree_to_use];

	/*
	 * If the last occurence was too far away
	 */
	if (*link <= end_pos)
	{
		*link = 0;
		left[BufPos] = right[BufPos] = 0;
		return;
	}

	/*
	 * Most recent location of these chars
	 */
	ptr             = BufPos;

	/*
	 * Most recent location of a string which is "less than" it
	 */
	left_node_pos   = left[ptr];

	if (left_node_pos <= end_pos)
		left_node_pos = left[ptr] = 0;

	/*
	 * Most recent location of a string which is "greater than" it
	 */
	right_node_pos  = right[ptr];

	if (right_node_pos <= end_pos)
		right_node_pos = right[ptr] = 0;

	while (1)
	{
		/*
		 * If left node position is greater than right node position
		 * then follow the left node, since that is the more recent
		 * insertion into the tree.  Otherwise follow the right node.
		 */
		if (left_node_pos > right_node_pos)
		{
			/*
			 * If it's too far away, then store that it never happened
			 */
			if (left_node_pos <= end_pos)
				left_node_pos = 0;

			ptr = *link = (t_search_node) left_node_pos;

			if (!ptr)
				break;

			left_node_pos   = right[ptr];
			link            = &right[ptr];
		}
		else
		{
			/*
			 * If it's too far away, then store that it never happened
			 */
			if (right_node_pos <= end_pos)
				right_node_pos = 0;

			ptr = *link = (t_search_node) right_node_pos;

			if (!ptr) 
				break;

			right_node_pos  = left[ptr];
			link            = &left[ptr];
		}
	}
}


void removeNodes(t_encoder_context *context)
{
	long i;

	// remove the most recent insertions into the hash table, since we had invalid data 
	// sitting at the end of the window
	for (i = 0; i <= BREAK_LENGTH; i++)
	{
		if (context->bufpos-i-1 < WINDOW_SIZE)
			break;

		optimal_remove_node(context, context->bufpos-i-1, context->bufpos-WINDOW_SIZE+BREAK_LENGTH);
	}
}


//
// Reinsert the tree nodes we removed previously
//
void reinsertRemovedNodes(t_encoder_context *context)
{
	long j;

	for (j = BREAK_LENGTH; j > 0; j--)
	{
		if (context->bufpos - j > WINDOW_SIZE)
		{
			optimal_insert(
				context,
	            context->bufpos - j,
		        context->bufpos - j - WINDOW_SIZE + 4
			);
		}
	}
}


?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美三电影在线| 在线一区二区视频| 欧美第一区第二区| 秋霞午夜av一区二区三区| 在线观看亚洲一区| 性久久久久久久久久久久| 欧美性做爰猛烈叫床潮| 亚洲国产欧美在线人成| 欧美三级电影在线看| 亚洲丰满少妇videoshd| 91精品国产色综合久久久蜜香臀| 亚洲1区2区3区4区| 日韩一区二区免费在线电影| 六月婷婷色综合| 国产丝袜美腿一区二区三区| 成人免费高清在线观看| 亚洲女同一区二区| 欧美日韩国产区一| 美女视频第一区二区三区免费观看网站| 91精品国产综合久久精品麻豆 | 高清成人在线观看| 国产精品久线在线观看| 91精品福利视频| 夜色激情一区二区| 图片区日韩欧美亚洲| 日韩欧美国产系列| 成人av网站大全| 亚洲国产你懂的| 欧美电影免费观看高清完整版在线观看| 国产乱码精品一区二区三区忘忧草| 国产欧美在线观看一区| 色噜噜狠狠成人中文综合| 日本怡春院一区二区| 国产欧美精品国产国产专区| 在线观看亚洲精品| 国产一区二区视频在线播放| 亚洲美女在线一区| 日韩女优视频免费观看| 日本一区二区综合亚洲| 国产精品日日摸夜夜摸av| 成人激情开心网| 日韩精品免费专区| 欧美国产视频在线| 欧美日韩一级大片网址| 国产99精品视频| 天天色图综合网| 亚洲高清免费在线| 日韩亚洲欧美在线观看| 欧美一级日韩免费不卡| 91福利视频网站| 国产美女娇喘av呻吟久久| 欧美精品一区二区三区四区| 亚洲一区二区三区在线播放| 精品久久久久香蕉网| 成人免费黄色在线| 日韩精品午夜视频| 1024亚洲合集| 久久精品一区二区三区不卡牛牛| 91福利在线播放| 国产激情精品久久久第一区二区 | 日韩视频免费观看高清完整版| 国产在线观看一区二区| 亚洲自拍偷拍九九九| 2欧美一区二区三区在线观看视频| av在线播放成人| 蜜桃精品在线观看| 亚洲精品久久7777| 久久亚洲二区三区| 欧美日韩高清一区二区三区| 国产成人啪免费观看软件| 午夜婷婷国产麻豆精品| 日韩精品一区二区三区蜜臀 | 成人动漫在线一区| 日韩高清电影一区| 国产精品家庭影院| 日韩欧美你懂的| 91国产免费看| av中文字幕不卡| 国产精品18久久久| 日本vs亚洲vs韩国一区三区| 国产色一区二区| 日韩一区二区三区视频在线观看| 色综合天天综合狠狠| 福利视频网站一区二区三区| 日韩国产欧美在线视频| 亚洲精品va在线观看| 国产精品久久久久久久久动漫| 欧美高清性hdvideosex| 一区二区三区自拍| 中文字幕中文字幕在线一区| 在线不卡的av| 在线不卡a资源高清| 欧美巨大另类极品videosbest| 91丨九色porny丨蝌蚪| 国产iv一区二区三区| 国产一区视频导航| 国产一区美女在线| 激情都市一区二区| 精品一区二区在线观看| 午夜欧美2019年伦理| 亚洲免费观看高清完整版在线观看熊 | 在线观看一区二区精品视频| 色吧成人激情小说| 日本精品一级二级| 色8久久人人97超碰香蕉987| 欧美精品一卡二卡| 国产综合久久久久影院| 久久国产麻豆精品| 极品瑜伽女神91| 视频一区二区不卡| 精品一区二区三区影院在线午夜| 麻豆中文一区二区| 国产综合色产在线精品| 岛国精品在线观看| 91麻豆国产福利精品| 欧美在线一二三四区| 欧美一级久久久| 欧美成人国产一区二区| 69久久99精品久久久久婷婷| 欧美日韩成人综合天天影院| 91精品一区二区三区久久久久久| 日韩欧美一区二区久久婷婷| 精品久久久久久久一区二区蜜臀| 国产高清亚洲一区| 99久久精品国产网站| 色诱亚洲精品久久久久久| 欧美亚洲动漫精品| 日韩欧美一二区| 日韩三级免费观看| 久久久www成人免费无遮挡大片| 国产精品乱码一区二区三区软件 | bt欧美亚洲午夜电影天堂| 日本韩国视频一区二区| 欧美电影影音先锋| 欧美精品一区二区不卡| 日韩毛片高清在线播放| 天天综合网 天天综合色| 亚洲成av人片| 丰满少妇久久久久久久| 欧洲一区在线电影| 久久色.com| 亚洲视频狠狠干| 奇米色一区二区三区四区| 国产精品一品二品| 欧美视频三区在线播放| 精品久久久久久久久久久久包黑料| 欧美videossexotv100| 亚洲自拍偷拍av| 国产黄色91视频| 欧美日韩精品二区第二页| 国产偷国产偷精品高清尤物| 亚洲国产精品久久久久秋霞影院| 国内外成人在线| 欧美三级电影网站| 久久精品视频免费| 亚洲精品写真福利| 国产综合色产在线精品| 欧美精品少妇一区二区三区| 国产精品久久久久久久久晋中| 亚洲一区二区在线视频| 日本午夜一区二区| 91精品福利在线| 国产精品久久久久久久蜜臀| 免费的成人av| 91久久精品网| 亚洲欧洲精品成人久久奇米网| 五月婷婷色综合| 亚洲精品免费一二三区| 九色综合狠狠综合久久| 欧美婷婷六月丁香综合色| 自拍偷拍国产精品| 国产1区2区3区精品美女| 精品少妇一区二区三区在线视频| 一个色综合av| 一本一道久久a久久精品| 欧美人妇做爰xxxⅹ性高电影| 亚洲最新视频在线播放| www.色综合.com| 欧美激情中文字幕一区二区| 久久国内精品自在自线400部| 欧美日韩日日骚| 一区二区三区 在线观看视频| av午夜一区麻豆| **欧美大码日韩| 国产精品一区二区三区乱码| 91精选在线观看| 极品少妇xxxx精品少妇偷拍| 日韩欧美国产午夜精品| 久久精品国产一区二区三 | 91福利精品第一导航| 亚洲激情图片qvod| 欧美综合亚洲图片综合区| 亚洲一区二区三区不卡国产欧美 | 国产视频在线观看一区二区三区| 精品亚洲aⅴ乱码一区二区三区| 欧美日韩国产高清一区二区三区 | 日韩欧美色电影| 日韩精品国产精品| 欧美精品视频www在线观看| 日产国产欧美视频一区精品|