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

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

?? coder.c

?? VC小波算法2,高效率VC小波算法2
?? 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一区二区三区免费野_久草精品视频
中文字幕永久在线不卡| 精久久久久久久久久久| 中文字幕一区二区三区视频| 国产视频一区在线观看| 久久亚洲二区三区| 国产日本欧美一区二区| 国产人成亚洲第一网站在线播放| 久久久久国产免费免费| 欧美高清在线精品一区| 国产精品乱码一区二三区小蝌蚪| 国产精品入口麻豆九色| 国产精品看片你懂得| 日韩一区日韩二区| 亚洲欧美日韩在线| 亚洲已满18点击进入久久| 亚洲一区二区在线免费观看视频| 亚洲成人av一区| 视频一区二区国产| 久久精品国产99| 国产永久精品大片wwwapp| 国产不卡视频一区| 色婷婷综合久久| 欧美久久久一区| 精品国产乱码久久久久久1区2区| 精品国产免费视频| 国产精品毛片久久久久久| 一区二区三区日本| 日韩av网站在线观看| 国产精品一区二区无线| 99re6这里只有精品视频在线观看| 在线一区二区三区四区五区| 欧美电影一区二区| 精品久久人人做人人爽| 国产精品久久久久久久久图文区| 亚洲线精品一区二区三区| 蜜桃免费网站一区二区三区| 国产成人在线电影| 91久久精品一区二区三区| 91精品国产乱码久久蜜臀| 国产亚洲欧洲一区高清在线观看| 日韩理论电影院| 日本va欧美va瓶| 不卡一区二区三区四区| 欧美精品18+| 欧美激情在线一区二区三区| 亚洲电影一区二区| 国产乱码一区二区三区| 欧洲精品在线观看| 久久这里只精品最新地址| 亚洲美腿欧美偷拍| 精品一区二区久久| 色婷婷av一区二区三区大白胸| 日韩一区二区免费在线电影| 中文字幕色av一区二区三区| 美女诱惑一区二区| 91香蕉视频黄| 欧美白人最猛性xxxxx69交| 亚洲乱码国产乱码精品精的特点 | 久久精品国产999大香线蕉| 成人免费高清视频| 欧美一级一区二区| 亚洲欧美一区二区不卡| 狠狠狠色丁香婷婷综合激情| 91丨九色porny丨蝌蚪| 日韩视频免费观看高清完整版在线观看 | 天堂久久一区二区三区| 成人午夜在线视频| 日韩免费观看高清完整版| 一级女性全黄久久生活片免费| 国产一区二区毛片| 欧美日韩国产精品成人| 国产精品国产精品国产专区不片| 青青草国产成人av片免费| 91国产免费看| 国产欧美日韩在线视频| 久久99国产精品免费网站| 欧美日韩视频不卡| 亚洲视频免费在线| 国产成人自拍网| 精品美女在线播放| 日韩av一区二区在线影视| 欧美午夜一区二区三区| 国产精品免费丝袜| 国产精品一区二区你懂的| 欧美一区永久视频免费观看| 亚洲男人都懂的| 99久久久久久| 国产精品卡一卡二卡三| 国产经典欧美精品| 精品少妇一区二区三区免费观看 | 亚洲三级小视频| 国产91精品一区二区麻豆网站| 日韩精品一区二区三区视频播放| 亚洲一级二级三级在线免费观看| av不卡一区二区三区| 国产精品三级av在线播放| 国产成人精品亚洲午夜麻豆| 亚洲精品在线观看视频| 人妖欧美一区二区| 91精品综合久久久久久| 午夜精品123| 欧美裸体bbwbbwbbw| 亚洲午夜成aⅴ人片| 欧美午夜免费电影| 亚洲成人1区2区| 欧美肥妇毛茸茸| 日韩国产欧美三级| 日韩欧美一区二区三区在线| 麻豆一区二区三| 久久久久久久久久电影| 国产成人综合亚洲网站| 中文av一区特黄| 成人黄色小视频| 国产精品久久三区| 91丨porny丨首页| 亚洲桃色在线一区| 欧美性猛片xxxx免费看久爱| 无码av免费一区二区三区试看| 6080午夜不卡| 久久电影国产免费久久电影| 久久精品网站免费观看| 成人午夜精品在线| 亚洲日本护士毛茸茸| 欧美亚洲动漫精品| 日韩av中文在线观看| 日韩精品一区二| 国产乱码精品一品二品| 国产精品美女一区二区在线观看| av在线播放不卡| 亚洲国产综合视频在线观看| 欧美一区二区啪啪| 国产成人免费在线观看不卡| 亚洲男人天堂一区| 欧美人妖巨大在线| 国产精品中文欧美| 亚洲丝袜美腿综合| 欧美一区二区在线免费播放| 国产一级精品在线| 亚洲视频每日更新| 欧美一区二区三区啪啪| 成人性生交大片免费看中文| 亚洲欧美一区二区三区孕妇| 欧美一区二区三区视频在线观看| 国产在线精品国自产拍免费| 中文字幕一区日韩精品欧美| 欧美日韩免费视频| 国产成人在线视频网站| 亚洲一级在线观看| 久久蜜臀精品av| 欧美在线观看一区| 国产精品一区二区91| 一区二区三区在线观看网站| 精品国产免费视频| 色诱视频网站一区| 国产综合久久久久影院| 一区二区在线免费| 久久久蜜桃精品| 欧美日韩精品综合在线| 成人污视频在线观看| 日本v片在线高清不卡在线观看| 国产精品久久久久久一区二区三区 | 亚洲高清在线视频| 久久久精品国产免大香伊| 欧美日韩在线播放一区| 丁香天五香天堂综合| 日韩1区2区3区| 亚洲激情图片小说视频| 国产欧美一区二区精品性色超碰| 欧美日韩大陆一区二区| 9l国产精品久久久久麻豆| 狠狠色丁香婷婷综合| 亚洲国产精品久久一线不卡| 国产精品毛片大码女人| 精品国产精品网麻豆系列| 欧美午夜片在线观看| 不卡av免费在线观看| 国产一区二区在线电影| 偷拍日韩校园综合在线| 亚洲美女视频在线| 中文字幕免费不卡| 久久综合五月天婷婷伊人| 正在播放一区二区| 在线观看91精品国产入口| 成人午夜电影小说| 国产一区二区在线免费观看| 免费成人你懂的| 午夜精品久久久久久不卡8050| 亚洲视频在线一区观看| 欧美国产日韩精品免费观看| www成人在线观看| 日韩精品一区二区三区四区视频 | 国产精品毛片无遮挡高清| 久久综合九色综合欧美98| 91精品国产综合久久精品图片| 91麻豆国产自产在线观看| av一区二区三区在线| 丰满亚洲少妇av| 国产成人啪免费观看软件| 国产高清一区日本| 狠狠色狠狠色综合日日91app|