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

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

?? coder.c

?? 好東西呢
?? C
字號:

/**

<> todo : if (!coder->encodeBand)
	provide a generic stub which calls encodeBandBP several times
	(same for BandZT)
	this is a pain in the ass, and perhaps obsolete; the calls to encodeBand
		should probably all go through encodeImage, which is the master.

***/

#define CHECK_EOF

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <crblib/inc.h>
#include <crblib/arithc.h>
#include <crblib/codeutil.h>

#include "coder.h"
#include "image.h"
#include "subbands.h"

int tune_param = 0;

extern coder coderNone, coderOzero, coderOone, coderSigMap,coderSM2,coderSMo0 ,
	coderBitPlane,coderBP,coderBPsorted,coderBPbin,coderBPB2,coderBPBF, coderVQ, coderFrac, coderO1_1,coderO2, coderO1_SB,
	coderSH_O1,coderSH_O1SB,coderZF,coderBPZT,coderBPZT2,coderBPBFZT,coderNOP;

const num_coders = 24;	// (sizeof(coder_list)/sizeofpointer)-1
const coder * coder_list[] = {
		&coderBP,
		&coderNOP,
		&coderBPsorted,
		&coderBitPlane,
		&coderBPZT,
		&coderBPZT2,
		&coderBPBF,
		&coderBPBFZT,
		&coderBPbin,
		&coderBPB2,
		&coderZF,
		&coderSigMap,
		&coderSM2,
		&coderSMo0,
		&coderO1_1,
		&coderO1_SB,
		&coderO2,
		&coderOone,
		&coderOzero,
		&coderVQ,
		&coderFrac,
		&coderNone,
		&coderSH_O1,
		&coderSH_O1SB,
		NULL
};

#define SAFE_PAD (1<<16)

extern wavelet * newWavelet(const image *im,int levels)
{
wavelet *w;
	if ( (w = new(wavelet)) == NULL ) return NULL;
	w->width = im->width;
	w->height = im->height;
	w->planes = im->planes;
	w->levels = levels;
	w->complen = im->tot_bytes;
	if ( (w->comp = malloc(w->complen)) == NULL ) {
		freeWavelet(w); return NULL;
	}

	w->stopline = -1;
	w->im = (image *)im;

return w;
}
extern void freeWavelet(wavelet *w)
{
	if ( w ) {
		freeSubbands(w->subband_root);
		smartfree(w->qi);
		smartfree(w->comp);
		free(w);
	}
}


coder * coder_create_read(wavelet *w)
{
coder *ret;

	if ( (ret = new(coder)) == NULL ) return NULL;
	if ( w->coder_template ) memcpy(ret,w->coder_template,sizeof(coder));

	ret->w = w;

	w->stoplen = min(w->complen,w->stoplen);
	
	if ( (ret->arith = arithInit()) == NULL ){
		coder_destroy(ret); return NULL;
	}
	arithDecodeInit(ret->arith,ret->w->comp);

return ret;
}

coder * coder_create_write(const coder *template,wavelet *w,int stoplen)
{
coder *ret;

	if ( (ret = new(coder)) == NULL ) return NULL;
	if ( template ) memcpy(ret,template,sizeof(coder));

	w->coder_template = template;
 
	ret->w = w;

	w->stoplen = stoplen;

	if ( (ret->arith = arithInit()) == NULL ){
		coder_destroy(ret); return NULL;
	}
	arithEncodeInit(ret->arith,ret->w->comp);

return ret;
}

void coder_flush_read(coder *c)
{
#ifdef CHECK_EOF
int got;
got = arithGet(c->arith,79);
if ( got == 43 ) arithDecode(c->arith,43,44,79);
else errputs("warning : didn't get EOF");
#endif // EOF

arithDecodeDone(c->arith);
}
void coder_flush_write(coder *c)
{
#ifdef CHECK_EOF
arithEncode(c->arith,43,44,79);
#endif //EOF

c->w->complen = arithEncodeDone(c->arith);
}

void coder_destroy(coder *c)
{
	if ( c ) {
		if ( c->arith ) arithFree(c->arith);
		free(c);
	}
}

/************* routines for DPCM coding the top plane 

as of v1.5 this coder is quite bad-ass , even beats things like CALIC on your teeny
images (because context coders take too long to rev up) :

we do something cheezy like all the standard image coders.  Since the LL band
is so small, we don't have time to adapt a context coder.  Also, the different LL
bands of images have widely varying statistics, so we can't just use the plain
order -1 coder.

instead we try to make a local estimate of the mean prediction error (MPE).  We then
code using a static coder :

	0  		+ (1 < MPE)
	01 		+ (MPE < 3*MPE )
	001 	+ (3*MPE < 7*MPE )
	0001	+ (7*MPE < 15 * MPE)
	...

it would make more sense to use a Guassian probability distribution
sent to the arithcoder, with MPE as the standard dev, but the cumprobs
for a gaussian are the error function.  you would think we could
handle that by tabulation, but there are intricacies with coding
(sym/mpe) as a real number vs. an integer. (eg. hard to define the
"next" and "prev" symbols to get the neighboring cumprobs)

------

our sign coder is even cheezier.  We build the N+W sign neighbors context.
if N == W we have confidence, and use a binary adaptive coder on (sign == neighbor)
else we just send sign raw

***************/

#define EST_ERROR_SHIFT			3
#define EST_ERROR_PAD			0
#define EST_ERROR(grad,prev)	(((grad + grad + prev)>>EST_ERROR_SHIFT) + 2 + EST_ERROR_PAD)
#define ERROR_CODER_MULT		2		// tunes to 1 !!! almost an 0.2 b gain (on the LL)

#define INC 5

#define bitModel(bit,P0,PT)		do { PT += INC; if (!(bit)) P0 += INC;  if ( PT > 1000 ) { PT >>= 1; P0 >>= 1; P0++; PT += 2; } } while(0)
#define bitEnc(bit,ari,P0,PT)	do { arithEncBit(ari,P0,PT,bit);	bitModel(bit,P0,PT); } while(0)
#define bitDec(bit,ari,P0,PT)	do { bit = arithDecBit(ari,P0,PT);	bitModel(bit,P0,PT); } while(0)

static int signs_p0,signs_pt;

void coder_encodesign(arithInfo *ari,bool sign,bool W,bool N)
{
	if ( N == W ) {
		if ( ! N ) sign = !sign;
		bitEnc(sign,ari,signs_p0,signs_pt);
	} else {
		arithEncBitRaw(ari,sign);
	}
}
bool coder_decodesign(arithInfo *ari,bool W,bool N)
{
	if ( N == W ) {
		bool sign;
		bitDec(sign,ari,signs_p0,signs_pt);
		return sign ? N : !N;
	} else {
		return arithDecBitRaw(ari);
	}
}

void coder_encodeDPCM(coder *c,int *plane,int width,int height,int rowpad)
{
int x,y,pred,grad,val,sign,prev_err,est,fullw;
arithInfo * ari = c->arith;
int *ptr,*pline;

	fullw = width + rowpad;
	signs_p0 = 10; signs_pt = 20;
	ptr = plane; prev_err = 99;
	for(y=0;y<height;y++) {
		for(x=0;x<width;x++) {
			pline = ptr - fullw;
			if ( y == 0 ) { 
				if ( x == 0 ) { pred = 0; grad = 99; }
				else if ( x == 1 ) { pred = ptr[-1]; grad = 99; }
				else { pred = (ptr[-1] + ptr[-2])>>1; grad = abs(ptr[-1] - ptr[-2]); }
			} else if ( x == 0 ) { pred = (pline[0] + pline[1])>>1; grad = abs(pline[0] - pline[1]); 
			} else if ( x == width-1 ) {
				pred = (ptr[-1] + pline[0])>>1;
				grad = abs(ptr[-1] - pline[0]);
			} else {
				pred = (ptr[-1]*3 + pline[0]*3 + ptr[-1] + pline[1])>>3;
				grad = max( abs(ptr[-1] - ptr[-1]) , abs( pline[0] - pline[1]) );
			}

			val = (*ptr) - pred;

			if ( val < 0 ) { sign = 1; val = -val; }
			else sign = 0;
	
			est = EST_ERROR(grad,prev_err);
			cu_putMulting_ari(val,ari,est,ERROR_CODER_MULT);

			if ( val > 0 ) {
				if ( x == 0 || y == 0 ) {
					arithEncBitRaw(ari,sign);
				} else {
					coder_encodesign(ari,sign,isneg(ptr[-1]),isneg(pline[0]));
				}
			}

			ptr++;
			prev_err = val;
		}
		ptr += rowpad;
	}
}

void coder_decodeDPCM(coder *c,int *plane,int width,int height,int rowpad)
{
int x,y,pred,grad,val,prev_err,est,fullw;
arithInfo * ari = c->arith;
int *ptr,*pline;

	fullw = width + rowpad;
	signs_p0 = 10; signs_pt = 20;
	ptr = plane; prev_err = 99;
	for(y=0;y<height;y++) {
		for(x=0;x<width;x++) {
			pline = ptr - fullw;
			if ( y == 0 ) { 
				if ( x == 0 ) { pred = 0; grad = 99; }
				else if ( x == 1 ) { pred = ptr[-1]; grad = 99; }
				else { pred = (ptr[-1] + ptr[-2])>>1; grad = abs(ptr[-1] - ptr[-2]); }
			} else if ( x == 0 ) { pred = (pline[0] + pline[1])>>1; grad = abs(pline[0] - pline[1]); 
			} else if ( x == width-1 ) {
				pred = (ptr[-1] + pline[0])>>1;
				grad = abs(ptr[-1] - pline[0]);
			} else {
				pred = (ptr[-1]*3 + pline[0]*3 + ptr[-1] + pline[1])>>3;
				grad = max( abs(ptr[-1] - ptr[-1]) , abs( pline[0] - pline[1]) );
			}

			est = EST_ERROR(grad,prev_err);
			val = cu_getMulting_ari(ari,est,ERROR_CODER_MULT);

			prev_err = val;

			if ( val > 0 ) {
				if ( x == 0 || y == 0 ) {
					if ( arithDecBitRaw(ari) ) val = -val;
				} else {
					if ( coder_decodesign(ari,isneg(ptr[-1]),isneg(pline[0])) )
						val = -val;
				}
			}

			*ptr++ = val + pred;
		}
		ptr += rowpad;
	}
}

/*****

the LL DPCM no longer uses the _m1 routines , but some of
the coders use them to do order (-1) coding.

******/

#define M1_THRESH_1 3
#define M1_THRESH_2 8
#define M1_THRESH_3 30
#define M1_THRESH_4 128

void encode_m1(arithInfo * ari,int sym)
{
	if ( sym < M1_THRESH_1 ) {
		arithBit(ari,0);
		arithEncode(ari,sym,sym+1,M1_THRESH_1);
	} else {
		arithBit(ari,1); sym -= M1_THRESH_1;
		if ( sym < M1_THRESH_2 ) {
			arithBit(ari,0);
			arithEncode(ari,sym,sym+1,M1_THRESH_2);
		} else {
			arithBit(ari,1); sym -= M1_THRESH_2;
			if ( sym < M1_THRESH_3 ) {
				arithBit(ari,0);
				arithEncode(ari,sym,sym+1,M1_THRESH_3);
			} else {
				int escape = M1_THRESH_4;

				arithBit(ari,1); sym -= M1_THRESH_3;

				while( sym >= escape ) {
					arithEncode(ari,escape,escape+1,escape+1);
					sym -= escape;	escape += escape;
					if ( escape > ari->safeProbMax ) escape = ari->safeProbMax;
				}
				arithEncode(ari,sym,sym+1,escape+1);
			}
		}
	}
}

int decode_m1(arithInfo *ari)
{
int sym,cur;
sym=0;
	if ( arithGetBit(ari) == 0 ) {
		cur = arithGet(ari,M1_THRESH_1);
		arithDecode(ari,cur,cur+1,M1_THRESH_1);
		sym+=cur;
	} else {
		sym += M1_THRESH_1;
		if ( arithGetBit(ari) == 0 ) {
			cur = arithGet(ari,M1_THRESH_2);
			arithDecode(ari,cur,cur+1,M1_THRESH_2);
			sym+=cur;
		} else {
			sym += M1_THRESH_2;
			if ( arithGetBit(ari) == 0 ) {
				cur = arithGet(ari,M1_THRESH_3);
				arithDecode(ari,cur,cur+1,M1_THRESH_3);
				sym+=cur;
			} else {
				int escape = M1_THRESH_4>>1;

				sym += M1_THRESH_3;
				do {
					escape += escape;
					if ( escape > ari->safeProbMax ) escape = ari->safeProbMax;
					cur = arithGet(ari,escape+1);
					arithDecode(ari,cur,cur+1,escape+1);
					sym += cur;
				} while( cur == escape );
			}
		}
	}
return sym;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久av资源站| 色综合久久99| 欧美另类一区二区三区| 成人免费一区二区三区视频 | 日韩一区日韩二区| 成人网页在线观看| 亚洲国产成人午夜在线一区| 久久国产精品一区二区| 精品成人在线观看| 国产又粗又猛又爽又黄91精品| 日韩一级高清毛片| 日韩av二区在线播放| 精品国产三级电影在线观看| 国产在线精品不卡| 亚洲精品国产视频| 欧美成人艳星乳罩| 91同城在线观看| 亚洲综合久久久| 91精品啪在线观看国产60岁| 成人av第一页| 人禽交欧美网站| 一区二区三区电影在线播| 欧美精品亚洲二区| 日本久久电影网| 亚洲成av人**亚洲成av**| 亚洲人妖av一区二区| a级高清视频欧美日韩| 性欧美大战久久久久久久久| 精品捆绑美女sm三区| 色综合久久88色综合天天6| 国内精品自线一区二区三区视频| 欧美三级日韩三级| 美国十次综合导航| 中文字幕在线观看一区| 91精品国产综合久久福利软件| 不卡免费追剧大全电视剧网站| 美女精品自拍一二三四| 亚洲电影一级片| 亚洲人成亚洲人成在线观看图片| 久久久综合视频| 日韩三级在线免费观看| 欧美高清视频www夜色资源网| 色94色欧美sute亚洲线路一ni| 国产v日产∨综合v精品视频| 麻豆一区二区三区| 五月激情综合婷婷| 视频一区二区中文字幕| 婷婷国产在线综合| 青青草97国产精品免费观看无弹窗版| 亚洲欧美视频一区| 中文字幕一区二区三区蜜月| 亚洲欧洲日韩综合一区二区| 亚洲人一二三区| 亚洲一区二区三区三| 五月综合激情网| 狠狠色狠狠色综合| 国产精品一区一区三区| 不卡一区二区在线| 在线免费观看不卡av| 91精品国产综合久久香蕉麻豆 | 欧美一二三四区在线| 亚洲精品在线免费观看视频| 精品少妇一区二区三区免费观看 | 国产不卡视频在线播放| 在线免费观看一区| 日韩欧美一区二区视频| 亚洲欧美在线视频观看| 国产网站一区二区| 中文字幕精品在线不卡| 樱花影视一区二区| 免费高清在线视频一区·| 成人污污视频在线观看| 91精品久久久久久久91蜜桃| 国产精品国产精品国产专区不片| 亚洲自拍欧美精品| 国产剧情在线观看一区二区| 欧美日韩中文另类| 久久久影院官网| 亚洲成人免费在线| 国产成人综合在线观看| 91精品久久久久久久91蜜桃| 亚洲影视在线播放| 国产99久久久精品| 欧美不卡视频一区| 日日夜夜精品视频天天综合网| 波多野结衣视频一区| 亚洲国产精华液网站w| 九一久久久久久| 91久久精品一区二区| 欧美精品123区| 亚洲午夜激情av| 在线观看免费成人| 亚洲码国产岛国毛片在线| 成人97人人超碰人人99| 亚洲欧美日韩综合aⅴ视频| www.久久精品| 国产精品国产三级国产aⅴ入口| 久久精品国产澳门| 欧美videos中文字幕| 国产一区视频在线看| 久久精品人人做| 丁香激情综合国产| 国产精品久久久久天堂| 色综合天天综合网天天狠天天| 一区二区三区91| 51精品久久久久久久蜜臀| 久久精品国产99国产| 中文字幕av免费专区久久| 99re免费视频精品全部| 亚洲国产成人tv| 久久婷婷一区二区三区| www.在线成人| 婷婷综合在线观看| 日韩一区二区三区四区| 91麻豆成人久久精品二区三区| 中文字幕乱码日本亚洲一区二区| 国产精品影视网| 亚洲精品视频在线观看网站| 欧美卡1卡2卡| av不卡免费在线观看| 日韩激情中文字幕| 国产精品久久久久久久久免费桃花| 欧美三级电影在线看| 国产精华液一区二区三区| 亚洲曰韩产成在线| 国产欧美精品一区aⅴ影院| 91精品欧美久久久久久动漫 | 欧美精品在线观看一区二区| 国内精品免费在线观看| 亚洲精品视频在线观看网站| 久久亚洲精品国产精品紫薇| 国产高清成人在线| 国产精品国产三级国产a| 日韩视频永久免费| 日本道色综合久久| av不卡免费在线观看| 青青草国产精品亚洲专区无| 一区二区三区在线观看视频 | 欧美精品一区二区三区视频| 欧美日韩大陆在线| 欧美日韩在线三区| 日本乱码高清不卡字幕| www.一区二区| 色综合久久综合中文综合网| 菠萝蜜视频在线观看一区| 国产精品综合在线视频| 国产一区二区三区四区在线观看| 奇米影视一区二区三区| 五月天婷婷综合| 精品一区二区成人精品| 欧美96一区二区免费视频| 青青草国产精品97视觉盛宴 | 国产呦萝稀缺另类资源| 成人小视频在线| 91色乱码一区二区三区| 欧美色图天堂网| 日韩一区二区麻豆国产| 久久久亚洲欧洲日产国码αv| 国产婷婷色一区二区三区四区 | 国产成人鲁色资源国产91色综| 亚洲一区视频在线| 午夜精品久久久久久久久| 免费欧美在线视频| 成人一区二区三区视频在线观看| 99九九99九九九视频精品| 欧美欧美午夜aⅴ在线观看| 久久精品视频网| 亚洲成在人线免费| 成人精品视频一区二区三区| 欧美日韩在线播放三区四区| 欧美精品粉嫩高潮一区二区| 欧美激情资源网| 极品瑜伽女神91| 欧美日韩午夜精品| 国产精品女同互慰在线看 | 欧美国产综合色视频| 亚洲一区二区三区在线播放| 亚洲成人免费在线观看| 99热精品国产| 国产精品丝袜黑色高跟| 麻豆精品国产91久久久久久| 在线亚洲+欧美+日本专区| 国产精品国产a级| 国产激情一区二区三区| 91精品国产综合久久久久久漫画| 一区二区三区四区不卡在线| 成人丝袜18视频在线观看| 26uuu欧美| 国产精品夜夜爽| 欧美不卡激情三级在线观看| 免费高清不卡av| 日韩精品一区国产麻豆| 蜜桃一区二区三区在线观看| 一本高清dvd不卡在线观看| 中文字幕亚洲不卡| 成人av小说网| 曰韩精品一区二区| 日本高清不卡aⅴ免费网站| 一区二区欧美视频| zzijzzij亚洲日本少妇熟睡|