⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stdafx.h

📁 this is hupffman code.you can compress file with this application
💻 H
字号:
// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__CDEAAB7A_88EF_4A65_87D4_7C8BA624420E__INCLUDED_)
#define AFX_STDAFX_H__CDEAAB7A_88EF_4A65_87D4_7C8BA624420E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000


// TODO: reference additional headers your program requires here
#include "stdafx.h"
#include "direct.h"
#include "vector"
#include "conio.h"
#include "windows.h"
#include "stdlib.h"

using namespace std;

struct huffheader
{
	char huff[4];           //ki hieu 'HUFF'
	char TenFile[255];
	int SoLuongKyTu;              
	int Size_ChuaNen;           
	int Size_DaNen;             
};
typedef struct huffheader *HUFFHDR;

struct fileheader
{
	char file[6];
	int N;
	int UnCompressSize[20];
	int CompressSize[20];
};
typedef struct fileheader *FHDR;

struct hufftree
{
	unsigned long freq;							//trong so
	unsigned char s1;						    //left symb in a node
	unsigned char s2;                           //right symb in a node
	hufftree* pleft;         
	hufftree* pright;        
	hufftree* parent;        //parent node
};
typedef struct hufftree *HTREE;

struct huffsymbol
{
	unsigned int size;    
	__int64 symb;            //nhieu nhat la 256bit
};
typedef struct huffsymbol *SYMB;

/*       huffman file headers            */

struct symbheader
{
	unsigned int freq;       //trong so
	unsigned char symb;      //ki tu
};
typedef struct symbheader *SYMBHDR;




class Huffman
{
public:
	Huffman(){};
	char TenFile[255];
	HUFFHDR pheader;
	FHDR pfheader;
	int filesize;
	void header(int  stt,int NN);
	void encode(unsigned char *dest, int &csize, unsigned char *sour, int usize);
	void decode(unsigned char *dest, int &usize, unsigned char *sour);

	inline int get_uncompressed_size(unsigned char *sour)
	{
		pheader = (HUFFHDR)sour;
		return pheader->Size_ChuaNen;
	}

private:
	Huffman(const Huffman& huffman);
	const Huffman& operator=(const Huffman& huffman);

	HTREE temptree;								// cay huff  tam
	HTREE htree;								// huff tree
	SYMB hsymbol;							

	/*				khoi tao			*/
	unsigned char tmass1[256*sizeof(hufftree)];             
	unsigned char tmass2[256*sizeof(hufftree)];             
	unsigned char smass[256*sizeof(huffsymbol)];            

	unsigned char *psour;                                  //con tro nguon 
	unsigned char *pdest;                                  //con tro dich

	SYMBHDR psheader;								

	// kich thuoc tap tin chua nen					
	int SoLuongKyTu;										
	int bitslast;	

	static int __cdecl compare(const void *a, const void *b);    //dung cho phuong thuc qsort()

	void inittree();                       //khoi tao cay
	void taocay(void);                          
	void buildtable(void);                     // tao bang ma 
	void writesymb(int c);                     // buoc cuoitrong thuat toan encoding   

	void readtree(void);                          //duoc header va tim trong so
	unsigned char readsymb();                    
	inline int getnextbit();                      

};
int get_file_size(FILE *fp);
void CreateFileName (char *oldname);
void CreateFileDirectory (char*file, char* directory);
void FileNameFromPath(char *Path);
int IsFolder(char *Folder, char Files[20][255]);
int GetFileName(char *Arg, char filename[100][255]);
int IsFileDecoding(char *file, char filename[100][255],int soluong_file);

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__CDEAAB7A_88EF_4A65_87D4_7C8BA624420E__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -