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

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

?? huffcompress.c

?? VC++網(wǎng)絡(luò)通信編程實(shí)例案例精選》源代碼 第三部分
?? C
?? 第 1 頁 / 共 2 頁
字號:
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "HuffCompress.h"
#include "Client.h"

DWORD	dwWeight[256];
DWORD	dwCounts[256];
DWORD	dwByte[256];
DWORD	dwCodes[512];
DWORD	dwSymbols[256];
DWORD	dwMapping[256];
DWORD	dwByteTree[765];
WORD	wByteTree[765];
char	dwBitTree[765];
DWORD	dwRootIndex,dwCodeCount,dwStorage;
WORD	wTreeSize;

int		iElements,iTotalElements;

void HuffmanInitArrays()
{
	__asm
	{
		MOV		EDI,OFFSET dwWeight[0]
		MOV		ECX,256
		_InitWeight:
		MOV		DWORD PTR [EDI],0
		ADD		EDI,4
		DEC		ECX
		JNZ		_InitWeight
	}

	__asm
	{
		MOV		EDI,OFFSET dwBitTree[0]
		MOV		EAX,0
		MOV		ECX,255
		_InitBitTree:
		MOV		char PTR [EDI + EAX],2
		ADD		EAX,3
		DEC		ECX
		JNZ		_InitBitTree
	}
}

void HuffmanBuildArrays()
{
	__asm
	{
		MOV		ESI,OFFSET dwWeight[0]
		MOV		EDI,OFFSET dwByte[0]

		MOV		ECX,256
		_BuildByte:

		LODSD
		CMP		EAX,0
		JZ		_SkipByte
		MOV		EAX,256
		SUB		EAX,ECX
		STOSD
		_SkipByte:
		DEC		ECX
		JNZ		_BuildByte
		MOV		ESI,OFFSET dwWeight[0]
		MOV		ECX,256
		MOV		EDI,OFFSET dwCounts[0]

		_BuildCount:

		LODSD

		CMP		EAX,0

		JZ		_SkipCount

		STOSD

		_SkipCount:
		DEC		ECX
		JNZ		_BuildCount

		MOV		ESI,OFFSET dwCounts[0]
		// Use the Pointers to get the Number of Elements
		SUB		EDI,ESI
		MOV		ECX,EDI
		SHR		ECX,2

		// Check for only 1 Element in the Byte Array
		CMP		ECX,1
		JNE		_Exit

		// Point to the Byte Array
		MOV		EDI,OFFSET dwByte[0]

		// Add the Dummy Byte (256 Can't Exist, so it is Fine)
		MOV		EAX,256
		MOV		[EDI + ECX * 4],EAX

		// Point to the Counts Array
		MOV		EDI,OFFSET dwCounts[0]

		// Add the Dummy Count of 1
		MOV		[EDI + ECX * 4],DWORD PTR 1

		// Increment the Number of Elements
		INC		ECX

		// Finished Building the Arrays
		_Exit:

		// Update the Number of Elements
		MOV		iElements,ECX
		MOV		iTotalElements,ECX
	}
}

// Build the Byte Tree
void HuffmanBuildByteTree()
{
	DWORD	dwParentWeight,dwParentDesc;
	int		iStartPos = -3;
	BOOL	fInsert = TRUE;

	// Arbitrary Value of the First Parent Combined Parent Description
	dwParentDesc = 1000;

	// While we don't have a Root Node
	while (iElements > 1)
	{
		// Quick Sort the Array
		HuffmanQuickSortD(&dwCounts[0],&dwByte[0],0,iElements - 1);

		// Build the Huffman Tree
		__asm
		{
			/* Step 1: Create a Parent for the Children with the
			           two lowest Weights and a Descriptor for
					   the Parent from the Children Bytes */

			// Point to the Count Array
			MOV		ESI,OFFSET dwCounts[0]

			// Compute the New End of Array
			MOV		EBX,iElements
			DEC		EBX

			// Update the Number of Elements
			MOV		iElements,EBX

			// Index the two Lowest Weights
			MOV		EAX,EBX
			DEC		EAX

			// Create a Parent from the Two Lowest Weights
			MOV		EDX,[ESI + EAX * 4]
			ADD		EDX,[ESI + EBX * 4]

			// Save the Parent
			MOV		dwParentWeight,EDX

			// Compute the Start Position in the Tree
			MOV		ECX,iStartPos
			ADD		ECX,3

			// Update the Start Position in the Tree
			MOV		iStartPos,ECX

			/* Step 3: Add to the Byte Conversion Tree */

			// Point to the Byte Array
			MOV		ESI,OFFSET dwByte[0]

			// Point to the Byte Table Conversion Tree
			MOV		EDI,OFFSET dwByteTree[0]

			// Move the New Parent Descriptor to the First Spot in Tree
			MOV		EDX,dwParentDesc
			MOV		[EDI + ECX * 4],EDX

			// Move the First Child Byte to the Second Spot in Tree
			MOV		EDX,[ESI + EAX * 4]
			MOV		[EDI + ECX * 4 + 4],EDX
			// Move the Second Child Byte to the Third Spot in Tree
			MOV		EDX,[ESI + EBX * 4]
			MOV		[EDI + ECX * 4 + 8],EDX

			/* Step 4: Update the Counts Array, Removing the Children
			           and Adding the Parent */

			// Point to the Count Array
			MOV		ESI,OFFSET dwCounts[0]

			// Restore the New Weight Value of the Parent
			MOV		EDX,dwParentWeight

			// Insert the Parent to the Counts Array
			MOV		[ESI + EAX * 4],EDX

			// Point to the Byte Array
			MOV		ESI,OFFSET dwByte[0]

			// Restore the New Weight Value of the Parent
			MOV		EDX,dwParentDesc

			// Insert the Combined Parent to the End of the Byte Array
			MOV		[ESI + EAX * 4],EDX

			// Update the Parent Descriptor for the Next New Parent
			INC		dwParentDesc
		}
	}

	// Get the Index to the Root in the Tree
	__asm
	{
		MOV		ECX,iStartPos
		MOV		dwRootIndex,ECX
		ADD		ECX,3
		MOV		wTreeSize,CX
	}
}

// Quick Sort the Array in Ascending Order
void HuffmanQuickSortA(DWORD *pArray1,DWORD *pArray2,int iBegin,int iEnd)
{
	int		iLow,iHigh,iTemp;

	__asm
	{
		// Set the Low and High Elements
		MOV		EAX,iBegin
		MOV		EBX,iEnd

		// Point the Input Array
		MOV		ESI,pArray1

		// Get the List Separator
		MOV		ECX,EAX
		ADD		ECX,EBX
		SHR		ECX,1
		MOV		EDX,[ESI + ECX * 4]

		// The Main Loop
		_DoLoop:

		// Point the Input Array
		MOV		ESI,pArray1

		// Order the Low Elements
		_OrderLow:
		MOV		EDI,EAX
		INC		EAX
		CMP		[ESI + EDI * 4],EDX
		JB		_OrderLow
		MOV		EAX,EDI

		// Order the High Elements
		_OrderHigh:
		MOV		EDI,EBX
		DEC		EBX
		CMP		[ESI + EDI * 4],EDX
		JA		_OrderHigh
		MOV		EBX,EDI

		// Check for Swapping Array[Low] with Array[High]
		CMP		EAX,EBX
		JG		_NoSwap

		// Swap dwCounts[Low] with dwCounts[High]
		MOV		ECX,[ESI + EAX * 4]
		MOV		EDI,[ESI + EBX * 4]
		MOV		[ESI + EAX * 4],EDI
		MOV		[ESI + EBX * 4],ECX

		// Swap the Byte Array
		MOV		ESI,pArray2
		MOV		ECX,[ESI + EAX * 4]
		MOV		EDI,[ESI + EBX * 4]
		MOV		[ESI + EAX * 4],EDI
		MOV		[ESI + EBX * 4],ECX

		// Update the Low and High Indexes
		INC		EAX
		DEC		EBX

		// Test for Looping Back
		_NoSwap:
		MOV		iTemp,EBX
		CMP		EAX,iTemp
		JLE		_DoLoop

		// Update the Low and High Values
		MOV		iLow,EAX
		MOV		iHigh,EBX
	}

	// Check for Sorting Elements between Begin and High (New Lower Range)
	if (iBegin < iHigh)
		HuffmanQuickSortA(pArray1,pArray2,iBegin,iHigh);

	// Check for Sorting Elements between Low and End (New Upper Range)
	if (iLow < iEnd)
		HuffmanQuickSortA(pArray1,pArray2,iLow,iEnd);
}

// Quick Sort the Array in Descending Order
void HuffmanQuickSortD(DWORD *pArray1,DWORD *pArray2,int iBegin,int iEnd)
{
	int		iLow,iHigh,iTemp;

	__asm
	{
		// Set the Low and High Elements
		MOV		EAX,iBegin
		MOV		EBX,iEnd

		// Point the Input Array
		MOV		ESI,pArray1

		// Get the List Separator
		MOV		ECX,EAX
		ADD		ECX,EBX
		SHR		ECX,1
		MOV		EDX,[ESI + ECX * 4]

		// The Main Loop
		_DoLoop:

		// Point the Input Array
		MOV		ESI,pArray1

		// Order the Low Elements
		_OrderLow:
		MOV		EDI,EAX
		INC		EAX
		CMP		[ESI + EDI * 4],EDX
		JA		_OrderLow
		MOV		EAX,EDI

		// Order the High Elements
		_OrderHigh:
		MOV		EDI,EBX
		DEC		EBX
		CMP		[ESI + EDI * 4],EDX
		JB		_OrderHigh
		MOV		EBX,EDI

		// Check for Swapping Array[Low] with Array[High]
		CMP		EAX,EBX
		JG		_NoSwap

		// Swap dwCounts[Low] with dwCounts[High]
		MOV		ECX,[ESI + EAX * 4]
		MOV		EDI,[ESI + EBX * 4]
		MOV		[ESI + EAX * 4],EDI
		MOV		[ESI + EBX * 4],ECX

		// Swap the Byte Array
		MOV		ESI,pArray2
		MOV		ECX,[ESI + EAX * 4]
		MOV		EDI,[ESI + EBX * 4]
		MOV		[ESI + EAX * 4],EDI
		MOV		[ESI + EBX * 4],ECX

		// Update the Low and High Indexes
		INC		EAX
		DEC		EBX

		// Test for Looping Back
		_NoSwap:
		MOV		iTemp,EBX
		CMP		EAX,iTemp
		JLE		_DoLoop

		// Update the Low and High Values
		MOV		iLow,EAX
		MOV		iHigh,EBX
	}

	// Check for Sorting Elements between Begin and High (New Lower Range)
	if (iBegin < iHigh)
		HuffmanQuickSortD(pArray1,pArray2,iBegin,iHigh);

	// Check for Sorting Elements between Low and End (New Upper Range)
	if (iLow < iEnd)
		HuffmanQuickSortD(pArray1,pArray2,iLow,iEnd);
}

// Navigate the Binary Tree
void HuffmanBuildCodes()
{
	DWORD	dwCodeBits;
	DWORD	dwLeafNode;

	__asm
	{
		// Initialize the Count of Codes
		MOV		dwCodeCount,0;

		// Initialize the Bit Code
		MOV		ECX,0

		// Initialize the Index
		MOV		EDX,dwRootIndex

		// Point to the Bit and Byte Tree Arrays
		MOV		ESI,OFFSET dwBitTree[0]
		MOV		EDI,OFFSET dwByteTree[0]

		// Initialize the Number of Bits in the Code
		MOV		dwCodeBits,0

		// While We Still Have Children for the Parent
		_WhileLoop:

		// Get the Number of Children
		MOV		EAX,0
		MOV		AL,[ESI + EDX]

		// Decrement the Parents Number of Children
		DEC		[ESI + EDX]

		// Check for Children
		CMP		EAX,0
		JE		_FindParent

		// Get the Last Child of the Current Parent
		ADD		EDX,EAX
		MOV		EBX,[EDI + EDX * 4]
		SUB		EDX,EAX

		// Increment the Code Bits
		ADD		ECX,ECX

		// For a Move to the Right in the Tree Add a 1 to the Code
		CMP		EAX,2
		JNE		_SkipOr
		OR		ECX,1
		_SkipOr:

		// Increment the Number of Bits in the Code
		INC		dwCodeBits

		// Check for a Leaf Node
		CMP		EBX,256
		JLE		_LeafNode

 		// Get the Parent Index of the Child Node Starting 
		// with the Previous Parent of the Current Parent
		_SubIndex:
		SUB		EDX,3
		CMP		EBX,[EDI + EDX * 4]
		JNE		_SubIndex

		// Loop Back for Another Node
		JMP		_WhileLoop

		// Process a Leaf Node
		_LeafNode:

		// Save the Index
		PUSH	EDX

		// Point to the Codes Array
		MOV		EAX,OFFSET dwCodes[0]

		// Set the Bit Count of the Symbol to the Code Array
		MOV		EDX,dwCodeBits
		MOV		[EAX + 1024 + EBX * 4],EDX

		// Set the Symbol to the Code Array
		MOV		[EAX + EBX * 4],ECX

		// Save the Leaf Node
		PUSH	ECX
		MOV		ECX,EBX
		MOV		dwLeafNode,ECX

		// Get the Current Index to the Codes Array
		MOV		EBX,dwCodeCount

		// Point to the Symbol Mapping Array
		MOV		EAX,OFFSET dwMapping[0]

		// Set the Mapping of the Symbol to the Code Array
		MOV		[EAX + EBX * 4],ECX

		// Restore the Leaf Node
		POP		ECX

		// Point to the Code Symbol Array
		MOV		EAX,OFFSET dwSymbols[0]

		// Set the Symbol to the Code Array
		MOV		[EAX + EBX * 4],ECX

		// Increment the Code Count
		INC		EBX
		MOV		dwCodeCount,EBX

		// Restore the Leaf Node
		MOV		EBX,dwLeafNode

		// Restore the Index
		POP		EDX

		// Decrement the Number of Bits in the Code
		DEC		dwCodeBits

		// Decrement the Bits
		SHR		ECX,1

		// Loop Back for Another Node
		JMP		_WhileLoop

		// Find the Parent Index of the Parent
		_FindParent:

		// Get the Current Parent
		MOV		EAX,dwRootIndex
		MOV		EBX,[EDI + EDX * 4]

		// Check the Children of the Parent for a Match
		_AddIndex:

		ADD		EDX,3
		// Check for Completion
		CMP		EDX,EAX
		JG		_Exit
		CMP		EBX,[EDI + (EDX + 4) * 4]
		JE		_SkipAdd
		CMP		EBX,[EDI + (EDX + 8) * 4]
		JNE		_AddIndex

		// Found the Index
		_SkipAdd:

		// Decrement the Number of Bits in the Code
		DEC		dwCodeBits

		// Decrement the Bits
		SHR		ECX,1

		// Go back for Another Node
		JMP		_WhileLoop
		_Exit:
	}
}

// Build the Byte Tree and Codes Table and Return the Tree Size
WORD HuffmanDictionary(BYTE *pInput,DWORD dwCount,DWORD *pByteTree,DWORD *pCodes)
{
	// Byte Tree Storage Requirement
	DWORD	dwStorage;

	// Initialize the Weights Array
	HuffmanInitArrays();

	// Sum the Occurences of the Data to the Weights Array
	__asm
	{
		// Point to the Source Data
		MOV		ESI,pInput

		// Point to the Destination Data
		MOV		EDI,OFFSET dwWeight[0]

		// Set the Loop Count
		MOV		ECX,dwCount
		MOV		EAX,0

		// Increment Each Occurence of the Byte
		_SumOccurences:
		LODSB

		// The Byte is an Index to the Weight Array
		INC		DWORD PTR [EDI + EAX * 4]
		DEC		ECX
		JNZ		_SumOccurences
	}

	// Build the Byte and Count Arrays
	HuffmanBuildArrays();

	// Build the Byte Tree
	HuffmanBuildByteTree();

	// Compute the Byte Tree Storage Requirements
	__asm
	{
		// Multiply the Tree Size by 4, for DWORD Access to the Byte Tree Array
		MOV		EDX,0

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人黄色a**站在线观看| 欧美成人欧美edvon| 91精品国产综合久久小美女| 久久色在线观看| 亚洲午夜激情av| 成人免费视频一区| 欧美精品色一区二区三区| 国产精品视频一二三| 久久99精品久久只有精品| 一本久久综合亚洲鲁鲁五月天| 日韩精品一区二区三区老鸭窝| 亚洲综合色在线| 成人天堂资源www在线| 精品日产卡一卡二卡麻豆| 亚洲电影中文字幕在线观看| 99久久精品久久久久久清纯| 久久久精品蜜桃| 美女一区二区三区| 91.成人天堂一区| 一区二区三区资源| 99久久精品久久久久久清纯| 国产精品久久久久天堂| 国产毛片精品一区| 精品福利av导航| 久久精品国产77777蜜臀| 正在播放亚洲一区| 午夜a成v人精品| 欧美日韩免费高清一区色橹橹| 亚洲精品国产无天堂网2021| av亚洲精华国产精华| 中文字幕在线视频一区| 国产成人亚洲综合a∨婷婷| wwww国产精品欧美| 亚洲成人激情av| 色婷婷综合久久久| 亚洲资源在线观看| 欧美优质美女网站| 日韩精品一二三四| 日韩三级伦理片妻子的秘密按摩| 日韩高清在线观看| 精品国产乱码久久久久久老虎| 青青草原综合久久大伊人精品优势| 欧美日韩亚洲国产综合| 偷拍一区二区三区| 精品国产1区2区3区| 激情小说亚洲一区| 中文字幕免费观看一区| 99国产欧美久久久精品| 有码一区二区三区| 欧美电影一区二区| 韩国精品久久久| 国产精品色噜噜| 在线精品观看国产| 美女一区二区视频| 日本一区二区成人在线| 91久久精品一区二区三| 日韩在线一区二区| 中文字幕av一区 二区| 色一情一伦一子一伦一区| 天堂一区二区在线免费观看| 欧美成人女星排名| 99国产精品一区| 日本欧美大码aⅴ在线播放| 亚洲精品一区二区三区精华液| 不卡视频一二三四| 亚洲成av人片一区二区梦乃| 国产日韩欧美亚洲| 在线欧美日韩精品| 久草在线在线精品观看| 中文字幕中文乱码欧美一区二区| 欧美日韩三级在线| 粉嫩av亚洲一区二区图片| 午夜视频一区二区| 国产视频一区不卡| 欧美精品色综合| 懂色一区二区三区免费观看| 视频一区视频二区在线观看| 国产精品欧美一区喷水| 欧美一级电影网站| 色哟哟在线观看一区二区三区| 麻豆国产欧美一区二区三区| 亚洲欧美日韩精品久久久久| 精品欧美久久久| 欧美午夜一区二区三区| 国产91精品一区二区麻豆网站| 日韩精品久久理论片| 亚洲女厕所小便bbb| 国产丝袜在线精品| 日韩一区二区免费高清| 色狠狠av一区二区三区| 从欧美一区二区三区| 久久99九九99精品| 亚洲成人1区2区| 亚洲欧美视频在线观看视频| 久久精品在线观看| 精品少妇一区二区三区日产乱码 | 成人免费视频caoporn| 日韩avvvv在线播放| 亚洲成a人片在线不卡一二三区| 国产精品乱子久久久久| 久久久美女毛片| 精品国偷自产国产一区| 欧美日本韩国一区| 欧美精品一区二区三| 日韩一区二区在线观看视频| 欧美日韩国产另类不卡| 91久久线看在观草草青青| 成人免费毛片app| 从欧美一区二区三区| 国产成人综合网站| 国产经典欧美精品| 国产九色sp调教91| 国产美女av一区二区三区| 国产主播一区二区| 激情综合色丁香一区二区| 日本不卡一区二区三区高清视频| 亚洲国产日韩一级| 亚洲国产视频在线| 日韩黄色一级片| 欧美96一区二区免费视频| 久久国产免费看| 国内精品自线一区二区三区视频| 国产一区二区三区在线看麻豆| 国产精一区二区三区| 大尺度一区二区| 色偷偷88欧美精品久久久| 日本韩国一区二区三区| 欧美日韩成人一区二区| 欧美一区二区久久久| 2023国产一二三区日本精品2022| 国产婷婷一区二区| 亚洲三级视频在线观看| 香蕉影视欧美成人| 美女视频免费一区| 国产91精品露脸国语对白| a亚洲天堂av| 欧美日韩日日骚| 久久综合久久鬼色中文字| 国产精品日产欧美久久久久| 亚洲精品乱码久久久久久黑人| 亚洲成人激情av| 国产美女娇喘av呻吟久久| av不卡免费电影| 9191成人精品久久| 国产欧美一区二区精品仙草咪| 亚洲欧美电影一区二区| 日日骚欧美日韩| 国产成人啪午夜精品网站男同| 色综合中文字幕| 精品日韩欧美在线| 亚洲人成网站影音先锋播放| 青娱乐精品视频在线| 成人动漫av在线| 在线播放国产精品二区一二区四区| 久久中文娱乐网| 亚洲一区二区不卡免费| 乱中年女人伦av一区二区| 成人黄色小视频在线观看| 欧美伦理电影网| 国产精品国产三级国产aⅴ无密码| 丝袜亚洲另类丝袜在线| 成人av在线电影| 精品国产精品一区二区夜夜嗨| 中文字幕一区在线| 久久99精品国产91久久来源| 91国模大尺度私拍在线视频| 久久综合九色欧美综合狠狠| 亚洲国产日韩一区二区| 成人精品视频一区二区三区尤物| 91精品国产手机| 亚洲伦理在线免费看| 国产经典欧美精品| 日韩欧美综合在线| 艳妇臀荡乳欲伦亚洲一区| 国产凹凸在线观看一区二区| 欧美精品久久久久久久久老牛影院| 国产精品久久久久婷婷二区次| 精品一区二区三区免费视频| 欧美日韩国产高清一区| 亚洲欧美另类图片小说| 国产成人午夜精品5599| 日韩一区二区三区电影 | 久久久综合网站| 日韩电影在线一区二区三区| 91小视频在线免费看| 国产精品免费视频观看| 国产精品一区二区在线观看不卡 | 日韩精品一区二区三区视频播放 | 免费观看30秒视频久久| 欧美在线一二三四区| 亚洲欧美日本在线| 99精品在线观看视频| 中文字幕不卡在线播放| 国产激情视频一区二区三区欧美| 精品国产一区二区三区不卡| 免费成人美女在线观看.| 91精品蜜臀在线一区尤物| 性欧美疯狂xxxxbbbb| 欧美男生操女生| 久久av中文字幕片|