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

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

?? decode.cpp

?? 一種無損圖象壓縮算法,可用于珍貴圖象的保存.
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <string.h>
//Header Files
#include "const.h"
extern void init_bdecoder  ();
extern void init_sdecoder  ();
extern void init_mydecoder ();
extern void stop_mydecoder (); 
extern int bdecode_symbol (int);
extern int decode_symbol (int);
//Constant Definitions
//Options included in the encoder
#define OPTION_NEARLY_LOSSLESS
//Misc. constants
#define N_SEQ     NUM_CONTEXT     /* Number of coding histograms        */
#define N_BSEQ    NUM_BCONTEXT    /* Number of binary coding histograms */
#define UPPER     255             /* Largest possible pixel value       */
#define ERR_SPAN  (UPPER + 1)
//Macro Definitions
#define ABS(X)      (((X) < 0)   ? -(X) : (X))
#define MIN(X,Y)    (((X) < (Y)) ?  (X) : (Y))
#define MAX(X,Y)    (((X) < (Y)) ?  (Y) : (X))
//NEARLY LOSSLESS COMPRESSION
#ifdef OPTION_NEARLY_LOSSLESS
//Variable Definitions
int tolerance = 7;
int mask      = 15;
int QT[8];
int QS[8];
FILE *infile;
FILE *outfile;
#endif
//NEARLY LOSSLESS COMPRESSION

//Misc. operations
//Function : nh
//static int T0 =   5 + 1;
//static int T1 =  15 + 0;
//static int T2 =  25 + 6;
//static int T3 =  42 + 4;
//static int T4 =  60 + 6;
//static int T5 =  85 + 6;
//static int T6 = 140 + 10;
static int T0 =   5 - 1;
static int T1 =  15 - 5;
static int T2 =  25 - 4;
static int T3 =  42;
static int T4 =  60;
static int T5 =  85;
static int T6 = 140;
int nh (int k)
{
	if (k <= T0)      return (0);
	else if (k <= T1) return (1);
	else if (k <= T2) return (2);
	else if (k <= T3) return (3);
	else if (k <= T4) return (4);
	else if (k <= T5) return (5);
	else if (k <= T6) return (6);
	else return (7);
}
//Function : nreremap
int nreremap (int err, int p, int flip)
{
	if (err == 0) return (0);
	//NEARLY LOSSLESS COMPRESSION
	#ifdef OPTION_NEARLY_LOSSLESS
	{
		if (p <= (UPPER/2))
		{
			if (err <= 2*((p + tolerance)/mask))
			{
				if ((err % 2) == 0) err = -err/2;
				else                err = (err + 1)/2;
			}
			else
			{
				if (flip) err = -(err - (p + tolerance)/mask);
				else      err = err - (p + tolerance)/mask;
			}
		}
		else
		{
			if (err <= 2*((UPPER - p + tolerance)/mask))
			{
				if ((err % 2) == 0) err = -err/2;
				else                err = (err + 1)/2; 
			}
			else
			{
				if (flip) err = err - (UPPER - p + tolerance)/mask;
				else      err = -(err - (UPPER - p + tolerance)/mask);
			}
		}
		err = err*mask;
	}
	#else
		if (p <= (UPPER/2))
		{
			if (err <= 2*p)
			{
				if ((err % 2) == 0) err = -err/2;
				else                err = (err + 1)/2;
			}
			else
			{
				if (flip) err = -(err - p);
				else      err = err - p;
			}
		}
		else
		{
			if (err <= 2*(UPPER - p))
			{
				if ((err % 2) == 0) err = -err/2;
				else                err = (err + 1)/2; 
			}
			else
			{
				if (flip) err = err - (UPPER - p);
				else      err = -(err - (UPPER - p));
			}
		}
	#endif
	//NEARLY LOSSLESS COMPRESSION 
    return (err);
}

//Operations for saving images
//Function : create_buffer
void create_buffer (unsigned char **u0, unsigned char **u1, unsigned char **u2, int width)
{
	//Allocate space for the first line of the image.
	if ((*u2 = (unsigned char *) calloc (width + 2, sizeof (unsigned char))) == NULL)
	{
		fprintf (stderr, "ERROR : not enough space for buffer!\n");
		exit    (1);
	}
	//Allocate space for the second line of the image.
	if ((*u1 = (unsigned char *) calloc (width + 2, sizeof (unsigned char))) == NULL)
	{
		fprintf (stderr, "ERROR : not enough space for buffer!\n");
		exit    (1);
	}
	//Allocate space for the third line of the image.
	if ((*u0 = (unsigned char *) calloc (width + 2, sizeof (unsigned char))) == NULL)
	{
		fprintf (stderr, "ERROR : not enough space for buffer!\n");
		exit    (1);
	}
}

//Function : update_buffer
void update_buffer (unsigned char **u0, unsigned char **u1, unsigned char **u2, int width)
{
	unsigned char *temp;
	temp = *u2;
	*u2  = *u1;
	*u1  = *u0;
	*u0  = temp;
	//Save a line to the image.
	if ((fwrite (*u0 + 1, sizeof (unsigned char), width, outfile)) !=(unsigned int)width)
	{
		fprintf (stderr, "ERROR : in writing image!\n");
		exit    (1);
	}
}

//Function : flush_buffer
void flush_buffer (unsigned char *u0, unsigned char *u1, unsigned char *u2, int width)
{
	//Save the last three lines to the image.
	if ((fwrite (u2 + 1, sizeof (unsigned char), width, outfile)) !=(unsigned int)width)
	{
		fprintf (stderr, "ERROR : in writing image!\n");
		exit    (1);
	}
	if ((fwrite (u1 + 1, sizeof (unsigned char), width, outfile)) !=(unsigned int)width)
	{
		fprintf (stderr, "ERROR : in writing image!\n");
		exit    (1);
	}
	if ((fwrite (u0 + 1, sizeof (unsigned char), width, outfile)) !=(unsigned int)width)
	{
		fprintf (stderr, "ERROR : in writing image!\n");
		exit    (1);
	}
}

//Function : destory_buffer
void destory_buffer (unsigned char **u0, unsigned char **u1, unsigned char **u2)
{
	//Free all the buffer space.
	free (*u0);  *u0 = NULL;
	free (*u1);  *u1 = NULL;
	free (*u2);  *u2 = NULL;
}

//Function : decode_buffer
void decode_buffer (unsigned char *u0, unsigned char *u1, unsigned char *u2, int width, int height)
{
	register unsigned short ptn, ptn0, ptn1, ptn2;
	int *N1, *N2; 
	int *S1, *S2;
	int *Dh, *Dv;
	int *Pr;
	int *E0, err, aerr, berr;
	int H[N_SEQ][ERR_SPAN], BH[N_BSEQ][3];
	register int dh, dv, max, min, adjust, temp;
	register int symb1, symb2, bflag;
	register int nnww, nnw, nn, nne, nww, nw, n, ne, nee, www, ww, w, curr;
	register int x, j, k;
	
	//Allocate space ("Gradient")
	if ((Dh = (int *) calloc (width + 2, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for Dh\n");
		exit    (1);
	}
	if ((Dv = (int *) calloc (width + 2, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for Dv\n");
		exit    (1);
	}
	memset (Dh, 0, (width + 2)*sizeof (int));
	memset (Dv, 0, (width + 2)*sizeof (int));
	
	//Allocate space ("Prediction Error")
	if ((E0 = (int *) calloc (width + 2, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for E0\n");
		exit    (1);
	}
	aerr = err = 0;
	memset (E0, 0, (width + 2)*sizeof (int));
	//lw
	if ((Pr = (int *) calloc (width + 2, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for E0\n");
		exit    (1);
	}
	memset (Pr, 0, (width + 2)*sizeof (int));

	//Allocate space ("Context Modeling")
	if ((N1 = (int *) calloc (4096, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for N1\n");
		exit    (1);
	}
	if ((S1 = (int *) calloc (4096, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for S1\n");
		exit    (1);
	}
	if ((N2 = (int *) calloc (4096, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for N2\n");
		exit    (1);
	}
	if ((S2 = (int *) calloc (4096, sizeof (int))) == NULL)
	{
		fprintf (stderr, "ERROR : no enough space for S2\n");
		exit    (1);
	}
	
	ptn = ptn0 = ptn1 = ptn2= 0;
	memset (N1, 0, 4096*sizeof (int));
	memset (S1, 0, 4096*sizeof (int));
	memset (N2, 0, 4096*sizeof (int));
	memset (S2, 0, 4096*sizeof (int));
	
	//Initialize variables
	for (k = 0; k < N_SEQ; ++k)
		for (j = 0; j < ERR_SPAN; ++j) H[k][j] = 0;
	for (k = 0; k < N_BSEQ; ++k) 
		for (j = 0; j < 3; ++j) BH[k][j] = 0;
	//First pixel in the first row
	temp = UPPER/4;
	err  = nreremap (decode_symbol (3), temp, 0);
	aerr = ABS (err);
	curr = temp + err;
	//NEARLY LOSSLESS COMPRESSION 
	#ifdef OPTION_NEARLY_LOSSLESS
	{
		if (curr < 0)     curr = 0;
		if (curr > UPPER) curr = UPPER;
	}
	#endif
	//NEARLY LOSSLESS COMPRESSION
	u2[1] = curr;
	u2[0] = u2[1];        /* Duplicate the first pixel */
   
	//Second pixel in the first row
	w    = u2[1];
	temp = w;
	k = nh (aerr << 2);
	err  = nreremap (decode_symbol (k), temp, 0);
	aerr = ABS (err);
	curr = temp + err;
	//NEARLY LOSSLESS COMPRESSION
	#ifdef OPTION_NEARLY_LOSSLESS
	{
		if (curr < 0)     curr = 0;
		if (curr > UPPER) curr = UPPER;
	}
	#endif
	//NEARLY LOSSLESS COMPRESSION
	u2[2] = curr;
	//Rest of the first row
	for (x = 3; x <= width; ++x)
	{
		ww   = u2[x-2];
		w    = u2[x-1];
		temp = w;
		if (temp > UPPER)  temp = UPPER; 
		else if (temp < 0) temp = 0;
		k = nh ((aerr + ABS (ww - w)) << 2);
		err  = nreremap (decode_symbol (k), temp, 0);
		aerr = ABS (err);
		curr = temp + err;
		//NEARLY LOSSLESS COMPRESSION
		#ifdef OPTION_NEARLY_LOSSLESS
		{
			if (curr < 0)     curr = 0;
			if (curr > UPPER) curr = UPPER;
		}
		#endif
		//NEARLY LOSSLESS COMPRESSION
		u2[x] = curr;
	}
	u2[width+1] = u2[width];    /* Duplicate the last  pixel */
	//Second row first pixel
	n    = u2[1];
	temp = n;
	E0[1] = err = nreremap (decode_symbol (2), temp, 0);
	aerr  = ABS (err);
	curr = temp + err;
	//NEARLY LOSSLESS COMPRESSION
	#ifdef OPTION_NEARLY_LOSSLESS
	{
		if (curr < 0)     curr = 0;
		if (curr > UPPER) curr = UPPER;
	}
	#endif
	//NEARLY LOSSLESS COMPRESSION
	u1[1] = curr;
	u1[0] = u1[1];        /* Duplicate the first pixel */

	//Second row second pixel
	nw   = u2[1];
	n    = u2[2];
	ne   = u2[3];
	w    = u1[1];
	temp = (w + n + 1)/2 + (ne - nw)/4;
	if (temp > UPPER)  temp = UPPER; 
	else if (temp < 0) temp = 0;
	k = nh (aerr + ABS (n - nw) + ABS (n - ne) + 2*ABS (w - nw));
	E0[2] = err = nreremap (decode_symbol (k), temp, 0);
	aerr  = ABS (err);
	curr = temp + err;
	//NEARLY LOSSLESS COMPRESSION
	#ifdef OPTION_NEARLY_LOSSLESS
	{
		if (curr < 0)     curr = 0;
		if (curr > UPPER) curr = UPPER;
	}
	#endif
	//NEARLY LOSSLESS COMPRESSION
	u1[2] = curr;
	Dh[2] = ABS (curr - w);
	Dv[2] = ABS (curr - n);
	//2nd row
	for (x = 3; x <= width - 1; ++x)
	{
		nw   = u2[x-1];
		n    = u2[x];
		ne   = u2[x+1];
		ww   = u1[x-2];
		w    = u1[x-1];
		temp = (w + n + 1)/2 + (ne - nw)/4;
		if (temp > UPPER)  temp = UPPER; 
		else if (temp < 0) temp = 0;
		k = nh (aerr + ABS (ww - w) + ABS (n - nw) + ABS (n - ne) + 2*ABS (w - nw));
		E0[x] = err = nreremap (decode_symbol (k), temp, 0);
		aerr  = ABS (err);
		curr = temp + err;
		//NEARLY LOSSLESS COMPRESSION
		#ifdef OPTION_NEARLY_LOSSLESS
		{
			if (curr < 0)     curr = 0;
			if (curr > UPPER) curr = UPPER;
		}
		#endif
		//NEARLY LOSSLESS COMPRESSION
		u1[x] = curr;
		Dh[x] = ABS (curr - w);
		Dv[x] = ABS (curr - n);
	}
	//Second row last pixel
	nw   = u2[width-1];
	n    = u2[width];
	ww   = u1[width-2];
	w    = u1[width-1];
	temp = (w + n + 1)/2;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品综合| 日韩一区在线看| 国产日韩视频一区二区三区| 一片黄亚洲嫩模| 久久精品国产精品亚洲红杏| 在线视频你懂得一区| 精品久久久久久久久久久久久久久久久| 欧美激情自拍偷拍| 日韩av在线发布| 99久久精品免费看国产| 精品久久久久久最新网址| 亚洲成人av一区二区三区| av福利精品导航| 欧美精品一区二区三区蜜桃| 亚洲成av人综合在线观看| 成人一区二区三区中文字幕| 日韩精品一区二区三区中文精品| 亚洲乱码中文字幕| 风间由美一区二区三区在线观看| 日韩一区二区三区视频| 亚洲第一激情av| 色老综合老女人久久久| 中文子幕无线码一区tr| 国产精品一区二区视频| 欧美白人最猛性xxxxx69交| 亚洲va国产天堂va久久en| 99久久久无码国产精品| 日本一区二区视频在线| 国产一区二区精品久久| www久久久久| 狠狠色综合日日| 26uuu久久天堂性欧美| 免费视频一区二区| 97精品电影院| 色婷婷av一区二区三区gif| 久久久不卡网国产精品二区| 蜜桃av一区二区三区电影| 欧美电影一区二区三区| 亚洲mv在线观看| 欧美狂野另类xxxxoooo| 日韩精品久久久久久| 日韩欧美美女一区二区三区| 蜜臀av一级做a爰片久久| 日韩视频免费观看高清完整版 | 成人av影院在线| 国产精品无遮挡| jlzzjlzz亚洲日本少妇| 尤物在线观看一区| 欧美日韩一二三区| 蜜臀av性久久久久蜜臀aⅴ流畅 | 久久久综合激的五月天| 欧美精品久久久久久久多人混战 | 精品国精品国产| 精品一区二区免费| 欧美成人性福生活免费看| 毛片不卡一区二区| 中文字幕综合网| 成人久久视频在线观看| 尤物av一区二区| 91精品国产全国免费观看| 麻豆成人免费电影| 国产午夜精品美女毛片视频| 91伊人久久大香线蕉| 亚洲va国产天堂va久久en| 日韩欧美一区二区久久婷婷| 成人av免费在线观看| 亚洲成a天堂v人片| 国产亚洲成av人在线观看导航| 一本色道久久综合亚洲精品按摩| 青青草国产精品97视觉盛宴 | 成人欧美一区二区三区视频网页| 一本久久综合亚洲鲁鲁五月天| 午夜国产精品一区| 久久久国产综合精品女国产盗摄| 色婷婷综合视频在线观看| 麻豆国产精品视频| 亚洲欧美日韩中文播放| 精品国产髙清在线看国产毛片| 成人国产亚洲欧美成人综合网| 五月婷婷久久丁香| 亚洲国产精品精华液ab| 日韩一卡二卡三卡| 97se亚洲国产综合在线| 极品少妇一区二区| 一区二区三区在线视频免费观看| 日韩你懂的在线观看| 91论坛在线播放| 国产精品一线二线三线精华| 午夜精品久久久久久久99水蜜桃| 国产精品热久久久久夜色精品三区| 日韩一级在线观看| 91麻豆自制传媒国产之光| 国产美女娇喘av呻吟久久| 亚洲va欧美va人人爽午夜| 欧美国产综合色视频| 欧美成人激情免费网| 欧美性生交片4| 91玉足脚交白嫩脚丫在线播放| 国产精品99久| 韩国精品主播一区二区在线观看| 天涯成人国产亚洲精品一区av| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 日韩免费看网站| 欧美一区二区三区思思人| 欧美日韩中文国产| 欧美吞精做爰啪啪高潮| 色综合久久久久综合体桃花网| 不卡区在线中文字幕| 91成人在线精品| 亚洲成人第一页| 一区二区三区精品在线| 国产亚洲女人久久久久毛片| 久久亚洲二区三区| 日韩午夜在线播放| 欧美一区二区免费视频| 欧美精品乱码久久久久久按摩 | 久久亚洲一级片| 日韩一区二区三区精品视频| 日韩一区二区在线看| 日韩欧美一区电影| 日韩视频免费观看高清完整版在线观看| 欧美日韩色一区| 欧美精品 日韩| 日韩欧美国产高清| 亚洲精品一区二区精华| 国产日韩精品视频一区| 国产精品色一区二区三区| 亚洲欧美另类在线| 亚洲综合一二区| 水野朝阳av一区二区三区| 蜜桃精品视频在线观看| 国产精品白丝av| 99久久精品国产导航| 欧美日韩一区二区三区高清| 日韩午夜激情av| 国产人久久人人人人爽| 亚洲伦理在线精品| 奇米四色…亚洲| 粉嫩在线一区二区三区视频| aaa亚洲精品一二三区| 99精品国产热久久91蜜凸| 成人福利视频在线看| 欧美怡红院视频| 欧美美女一区二区| 欧美一级视频精品观看| 中文字幕高清不卡| 中文字幕免费观看一区| 中文字幕的久久| 亚洲精品日韩专区silk| 久久99国产精品免费| 国产原创一区二区| 国产精品 日产精品 欧美精品| 国产白丝精品91爽爽久久| 亚洲第一精品在线| 蓝色福利精品导航| 国产成人h网站| 国产成人免费视频 | 国产精品免费丝袜| 亚洲第一精品在线| 九九九精品视频| 91浏览器入口在线观看| 一本一道波多野结衣一区二区| 日韩免费高清视频| 国产精品国产自产拍高清av王其 | 国产亚洲精品久| 亚洲一区二区不卡免费| 精品一区二区三区视频在线观看 | 亚洲综合成人在线视频| 国产在线观看一区二区| 97精品久久久午夜一区二区三区 | 中文字幕在线不卡| 亚洲成精国产精品女| 精品在线播放免费| 91成人免费在线视频| 久久综合九色综合97婷婷女人 | 欧美在线观看一区二区| 51精品视频一区二区三区| 欧美韩国日本综合| 日韩不卡手机在线v区| 99久久er热在这里只有精品15| 精品久久一区二区| 一区二区三区高清在线| 精品午夜一区二区三区在线观看| av电影在线观看一区| 久久精品视频一区| 琪琪一区二区三区| 成人黄色av网站在线| 欧美一区二区三区不卡| 亚洲精品亚洲人成人网在线播放| 国产精品996| 欧美性生活一区| 伊人开心综合网| 国产白丝精品91爽爽久久| 日韩欧美国产精品| 蜜桃av一区二区| 欧美日韩国产不卡| 一区二区三区中文字幕精品精品| 丁香婷婷综合激情五月色| 51精品久久久久久久蜜臀| 亚洲免费观看高清|