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

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

?? ezdct.c

?? easy discrete time transform implemented in C
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):

/*********

inefficiencies? / tried & didn't help :

	0. EZW uses contexts to code down to the MSB, then uses only order0
		on the bits below MSB  (this is "if (A&donemask)" for us).
		use binary alphabet? (would allow more proper use of top quartet)
	  tried it; compression *almost* reaches my level, but speed is hurt.
		saved in bak5\ezdct.bitwise

	1. use one bit of 'b' in the context?  -> nope!

	2. top-level (b==0) quartet has no parent; we still use the same code
		structure.  "ezdct2" separates out the first byte for DPCM coding,
		but this actually *hurt*.  Something is still imperfect here.

	3. grey or "blue" coding to make the bitplanes more reflective
			of values?  -> hurt

	4. "blocks then bits" hurt

	5. decode to midoints ? good idea, but never used!

	6.	only using 8 context buckets now; I don't
			think we're doing much more than order0
			coding of bits! (found to be better than 16 or 32)
		in particular, the information of whether the current
			pixels history is On or Off seems to be irrelevant,
				(using only one bit for history hurts 0.002 ,
				 not using it at all hurts 0.06)
			only the parent bit really matters (means the tree structuring *is* good).
		for example, we use "nextmask" on parent now;
			using bitmask or donemask on parent hurts quite a bit (0.02)

*********/

#define DECODE_MIDPOINTS	/** almost irrelevant; even at very low rate,
							 * 	 coding gets down to the lowest bit plane
							***/

#define BITPLANE_ADAPT	// halve contexts after each plane, helps 0.004

#define DPCM_TRANSFORM	// major!

//#define NO_CODING

#define VERBOSE
//#define DEBUG
//#define DO_LOG
//#define MAKE_OUT_RAW
//#define REPORT_PLANES

//#define CODE_SIGNS //hurts on small files, helps a teeny on big ones

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <crbinc/inc.h>
#include <crbinc/fileutil.h>
#include <crbinc/cindcatr.h>
#include <crbinc/timer.h>
#include <crbinc/bbitio.h>
#include <crbinc/arithc.h>
#include <crbinc/scontext.h>
#include <crbinc/context.h>

void dbf(void) { errputs("dbf"); }

#include "dct.h"
#include "quantize.h"

/** tree-structures index **/

static int zag_x[] = {
 0,  1,  1,  0,  2,  3,  3,  2,  0,  1,  1,  0,  2,  3,  3,  2, 
 4,  5,  5,  4,  6,  7,  7,  6,  4,  5,  5,  4,  6,  7,  7,  6, 
 0,  1,  1,  0,  2,  3,  3,  2,  0,  1,  1,  0,  2,  3,  3,  2, 
 4,  5,  5,  4,  6,  7,  7,  6,  4,  5,  5,  4,  6,  7,  7,  6 };
static int zag_y[] = {
 0,  0,  1,  1,  0,  0,  1,  1,  2,  2,  3,  3,  2,  2,  3,  3, 
 0,  0,  1,  1,  0,  0,  1,  1,  2,  2,  3,  3,  2,  2,  3,  3, 
 4,  4,  5,  5,  4,  4,  5,  5,  6,  6,  7,  7,  6,  6,  7,  7, 
 4,  4,  5,  5,  4,  4,  5,  5,  6,  6,  7,  7,  6,  6,  7,  7 };

#define ZAG_INDEX(lptr,x,z) (lptr[zag_x[(z)] + (x) + zag_y[(z)]])

#define cleanup(str) if ( 0 ) ; else { errputs(str); exit(10); }

#ifdef DO_LOG
#define LOG(x)	if (0) ; else { x }
#else
#define LOG(x)	if (1) ; else { x }
#endif

#define TRANS_MAX			(0xFFF)
#define TRANS_MAX_BPN		(11)
#define TRANS_MAX_EV		(0xFFE)
#define TRANS_TOPBIT		(0x800)
#define TRANS_TOPBIT_BPN	(10)
#define TRANS_LOWBIT		(0x002)	// since 001 is the sign
#define VAL_MAX 			(TRANS_TOPBIT)

#define data_trans(val) ( ((val) < 0 ) ? ( 1+min(TRANS_MAX_EV,(-val-val))) : (min(TRANS_MAX_EV,(val+val))) )
#define trans_data(val) ( ((val) & 1 ) ? (-((val)>>1)) : (((val)>>1)) )

/** the value "1" is *never* used in trans values.  The bottom bit is only
		on if one of the higher bits is on **/

int log_nothing;
#define RESET_LOG() if ( 0 ) ; else { log_nothing=0; };

#define CODE_CONTEXTS		8	// 8 isn't much worse, and is a bit faster

#define MAKE_CONTEXT(context,parent,a,b,c,d) if ( 0 ) ; else {	\
	context = a+b+c+d; if ( context == 4 ) context = 3;	if ( parent ) context += 4;	\
}

#define CODE_ALPHABET		16	// 4 bits

#define ORDER1_TOTMAX		10000
#define ORDER1_INC			25

#ifdef CODE_SIGNS
#define SIGN_CONTEXTS		3
#define SIGNORDER0_TOTMAX	1000
#define SIGNORDER0_INC		5
#endif

#define PSNR_MAX 	(48.165)	//(10*log10(256^2))

int tune_param = 1;

ubyte **raw = NULL,**rawout = NULL;
uword **trans = NULL,**transout = NULL;
ubyte *comp = NULL;
FILE *rawF = NULL;
struct FAI * FAI = NULL;
struct BitIOInfo * BII = NULL;
#ifdef CODE_SIGNS
scontext **signorder0 = NULL;
#endif
scontext **order1 = NULL;

int width,height,rawsize,complen,totsize,num_planes; /** globals **/

void ExitFunc(void);
void coder_adapt(void);
void encode(int sym,int context);
void encodeSign(bool sym,int prev);
int decode(int context);
bool decodeSign(int prev);

int code_image(ubyte **raw,ubyte **rawout,int width,int height,int num_planes,
	int * qtable,int req_len);

void dct_image(ubyte **raw,uword **trans,int width,int height,int num_planes,
		int * quant_table);
void idct_image(ubyte **rawout,uword **trans,int width,int height,int num_planes,
		int * quant_table);

void TheImageAnalyzer(ubyte **original,ubyte **vs,
					int num_planes,int width,int height,
					float ratio,FILE *sio);

int mse_image(ubyte **original,ubyte **vs,int width,int height,int num_planes);

void init_allocs(void);
void init_coders(void);
void init_coders_write(void);
void init_coders_read(void);
int done_coders(void);
void free_coders(void);

int main(int argc,char *argv[])
{
char *t1,*t2;
int comp_tot_len,req_len,i;
clock_t startclock,stopclock;
int quantizer,bitrate;
int qtable[DCTBLOCK];

	errputs("ezdct v0.5, (c) 1998 by Charles Bloom");

	if ( argc <= 3 ) {
		errputs("ezdct <raw file> <width> <height> [planes] [quantizer] [bitrate*100] [tune param]");
		errputs(" use quantizer == 0 to let the program optimally choose a quantizer ");
		exit(10);
	}

	if ( atexit(ExitFunc) )
	  cleanup("Couldn't install exit trap!");

	if ( ( rawF = fopen(argv[1],"rb") ) == NULL )
		cleanup("open raw failed");

	width = atol(argv[2]);
	height = atol(argv[3]);

	if ( ((width/DCTLINE)*DCTLINE) != width )
		cleanup("size must be divable by 8");
	if ( ((height/DCTLINE)*DCTLINE) != height )
		cleanup("size must be divable by 8");

	if ( argc > 4 )	num_planes = atol(argv[4]);
	else			num_planes = 1;

	if ( argc > 5 )	quantizer = min(max(0,atol(argv[5])),100);
	else			quantizer = 0;

	if ( argc > 6 )	bitrate = min(max(1,atol(argv[6])),1000);
	else			bitrate = 100;

	if ( argc > 7 )	tune_param = atol(argv[7]);
	else			tune_param = 1;

	rawsize = width * height;
	totsize = rawsize*num_planes;
	req_len = (bitrate*totsize)/800;
	complen = req_len + (rawsize/8);

	init_allocs();

	for(i=0;i<num_planes;i++) {
		if ( !FReadOk(rawF,raw[i],rawsize) )
			errputs("fread short! continuing..");
	}
	fclose(rawF); rawF = NULL;

	for(i=0;i<DCTBLOCK;i++) zag_y[i] *= width;

#define qtable_frac qtable_none
	/** we use uniform quantizers ; you may scale them up by a table of
		fractions, but that won't help PSNR ratings **/

	if ( quantizer == 0 ) {
		int step,out,err,out2,err2,out3,err3;

		quantizer = 8; 
			/** small for faster convergence, 
			 * 		but may be too small for extremely low bitrate
			 * 	(maximum is this*2)
			***/

		for(i=0;i<DCTBLOCK;i++) {
			qtable[i] = quantizer*qtable_frac[i];
			if ( qtable[i] < 1 ) qtable[i] = 1;
		}
		out = code_image(raw,rawout,width,height,num_planes,qtable,req_len);
		err = mse_image(raw,rawout,width,height,num_planes);

		for(step = (quantizer>>1);step>0;step>>=1) {
#ifdef VERBOSE
			printf("out = %d, err = %d, quantizer = %d, step = %d\n",out,err,quantizer,step);
#endif

			for(i=0;i<DCTBLOCK;i++) {
				qtable[i] = (quantizer+step)*qtable_frac[i];
				if ( qtable[i] < 1 ) qtable[i] = 1;
			}
			out2 = code_image(raw,rawout,width,height,num_planes,qtable,req_len);
			err2 = mse_image(raw,rawout,width,height,num_planes);

			for(i=0;i<DCTBLOCK;i++) {
				qtable[i] = (quantizer-step)*qtable_frac[i];
				if ( qtable[i] < 1 ) qtable[i] = 1;
			}
			out3 = code_image(raw,rawout,width,height,num_planes,qtable,req_len);
			err3 = mse_image(raw,rawout,width,height,num_planes);

			if ( err2 < err && err2 < err3 ) {
				quantizer += step;
				out = out2; err= err2;
			} else if ( err3 < err ) {
				quantizer -= step;
				out = out3; err= err3;
			} else if ( err2 == err && err3 == err ) {
				if ( out2 < out && out2 < out3 ) {
					quantizer += step;
					out = out2; err= err2;
				} else if ( out3 < out ) {
					quantizer -= step;
					out = out3; err= err3;
				}
			}
		}

#ifdef VERBOSE
		printf("chose quantizer = %d\n",quantizer);
#endif

	} else {

		for(i=0;i<DCTBLOCK;i++) {
			qtable[i] = quantizer*qtable_frac[i];
			if ( qtable[i] < 1 ) qtable[i] = 1;
		}
	}

	RESET_LOG();

	startclock = clock();

	comp_tot_len = code_image(raw,rawout,width,height,num_planes,qtable,req_len);

	stopclock = clock();

	printf("%-13s :",FilePart(argv[1]));
	TheCompressionIndicator(totsize,comp_tot_len,stdout);
#ifdef VERBOSE
	printf(", %6ld byps\n",NumPerSec(totsize*2,stopclock-startclock));
#endif
	TheImageAnalyzer(raw,rawout,num_planes,width,height,((float)totsize/comp_tot_len),stdout);

#ifdef MAKE_OUT_RAW
	if ( ( rawF = fopen("out.raw","wb") ) == NULL )
		cleanup("open rawout failed");
	for(i=0;i<num_planes;i++) {
		if ( !FWriteOk(rawF,rawout[i],rawsize) )
			errputs("fwrote short! continuing..");
	}
	fclose(rawF); rawF = NULL;
#endif //MAKE_OUT_RAW

return 0;
}

int code_image(ubyte **raw,ubyte **rawout,int width,int height,int num_planes,
	int * qtable,int req_len)
{
int coded_len=0;
int temp,pnum;

	dct_image(raw,trans,width,height,num_planes,qtable);

#ifdef NO_CODING /*{*/
	/*#*/ {
	uword *tptr,*toptr;
	int r,rawsize=width*height;

	for(pnum=0;pnum<num_planes;pnum++) {
		tptr = trans[pnum];
		toptr = transout[pnum];
		for(r=rawsize;r--;)
			*toptr++ = *tptr++;
	}
	/*#*/ }

#else /*}{*/

	init_coders_write();

	/* encode */
	/*#*/ {
	uword *transline,*transplane;
	int x,y,b;
	int context,block,parent,parent_sign;
	int bitpn,bitmask,donemask,nextmask,A,B,C,D;
	int trans_top,top_bitpn;
#ifdef REPORT_PLANES
	int last_comp_len=0,cur_comp_len;
#endif

#ifdef DPCM_TRANSFORM	/** this is a lossless transform, not coding **/
	/*#*/ {
	int val,pred; uword *prevline;
	for(pnum=0;pnum<num_planes;pnum++) {
		transplane = trans[pnum];
		for(y=(height-DCTLINE);y>=0;y -= DCTLINE) {
			transline = transplane + y*width;
			prevline  = transline - DCTLINE*width;
			for(x=(width-DCTLINE);x>=0;x -= DCTLINE) {
				val = trans_data(transline[x]);

				if ( x == 0 && y == 0 ) {	pred = 0;
				} else if ( y == 0 ) {		pred = trans_data(transline[x-DCTLINE]);
				} else if ( x == 0 ) {		pred = trans_data(prevline[x]);
				} else { int a,b;
					a = trans_data(transline[x-DCTLINE]);
					b = trans_data(prevline[x]);
					pred = (a + b)>>1;
				}

				val -= pred;

				/** warning : val can now be up to 2* max[dct_output] **/
#ifdef DEBUG
				if ( abs(val) > VAL_MAX ) errputs("capped");
#endif

				transline[x] = data_trans(val);
			}
		}
	}
	/*#*/ }
#endif //DPCM_TRANSFORM


	trans_top=0;
	for(pnum=0;pnum<num_planes;pnum++) { transline = trans[pnum];
		for(x=rawsize;x--;) {
			A = *transline++;
			if ( A > trans_top ) trans_top = A;
		}
	}
	
	for(top_bitpn=0;(1<<(top_bitpn+1))<trans_top;top_bitpn++) ;
	arithEncode(FAI,top_bitpn,top_bitpn+1,TRANS_MAX_BPN);
	trans_top = 1<<top_bitpn;

	nextmask=0; bitpn = top_bitpn;
	for(bitmask = trans_top;bitmask>=TRANS_LOWBIT;bitmask>>=1) {
		donemask = nextmask; bitpn--;
		nextmask = donemask + bitmask;
		for(b=0;b<16;b++) { /** 16 4x4 blocks **/

			for(pnum=0;pnum<num_planes;pnum++) {
				transplane = trans[pnum];
				for(y=0;y<height;y += DCTLINE) {
					transline = transplane + y*width;
					for(x=0;x<width;x += DCTLINE) {

						/** we scan through all spacial locations of
							a certain frequency (so arithcoders adapt)
							but use the previous zigzag as context **/

						// b is the parent, in scan index
						// the children are (b*4)+0,1,2,3

						A = ZAG_INDEX(transline,x, (b<<2)+0 );
						B = ZAG_INDEX(transline,x, (b<<2)+1 );
						C = ZAG_INDEX(transline,x, (b<<2)+2 );
						D = ZAG_INDEX(transline,x, (b<<2)+3 );

						if ( b == 0 ) {
							/* 0th block has no parent, and A is the DC */
							parent = TRANS_MAX;
						} else {
							parent = ZAG_INDEX(transline,x,b);
						}

						MAKE_CONTEXT(context,(parent&nextmask),((A & donemask)?1:0),((B & donemask)?1:0),((C & donemask)?1:0),((D & donemask)?1:0));
						
						block = 0; // 4 bits
						if ( A & bitmask ) block += 1;
						if ( B & bitmask ) block += 2;
						if ( C & bitmask ) block += 4;
						if ( D & bitmask ) block += 8;

						encode(block,context);

						/** dependencies of B on C, etc. are implicitly used in the blocking **/

						 // only code from parent's sign if it has been sent
						if ( parent & nextmask )	parent_sign = parent & 1;
						else						parent_sign = 2;

						if ( (A & bitmask) && !(A & donemask) ) encodeSign(A&1,parent_sign);
						if ( (B & bitmask) && !(B & donemask) ) encodeSign(B&1,parent_sign);
						if ( (C & bitmask) && !(C & donemask) ) encodeSign(C&1,parent_sign);
						if ( (D & bitmask) && !(D & donemask) ) encodeSign(D&1,parent_sign);
					}

				if ( (BitIO_GetPos(BII)) > req_len )
					goto break_encoding;
				}
			}
		}

#ifdef REPORT_PLANES
		cur_comp_len = BitIO_GetPos(BII) - 2;
		printf("bp %-10d :",bitpn);	TheCompressionIndicator(((width*height)>>3),(cur_comp_len - last_comp_len),stdout); puts("");
		last_comp_len = cur_comp_len;
#endif // REPORT_PLANES

#ifdef BITPLANE_ADAPT
		coder_adapt();
#endif

	}

		break_encoding:
			donemask=0; //** dummy for goto

	/*#*/ }

	coded_len = done_coders();

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品国产精品国产专区不蜜| 久久99久久久欧美国产| 不卡一区中文字幕| 国产精品免费av| 91在线观看视频| 丝瓜av网站精品一区二区| 日韩视频不卡中文| 国产精品夜夜爽| 亚洲码国产岛国毛片在线| 欧洲精品视频在线观看| 免费不卡在线观看| 国产欧美一区二区精品婷婷| 不卡视频在线看| 五月天丁香久久| 久久青草欧美一区二区三区| 成人福利在线看| 亚洲成人一二三| 精品久久久久久综合日本欧美| 国产不卡视频在线播放| 亚洲午夜av在线| 国产欧美一区二区精品久导航| 欧美综合色免费| 国产一区91精品张津瑜| 久久激五月天综合精品| 国产精品卡一卡二| 欧美一区二区三区在线电影| 国产精品自在在线| 亚洲午夜影视影院在线观看| 2021久久国产精品不只是精品| 91在线免费看| 蜜臀国产一区二区三区在线播放| 国产精品天天摸av网| 欧美日本不卡视频| 国产91在线观看| 日本vs亚洲vs韩国一区三区 | 在线观看日韩国产| 久草中文综合在线| 一区二区在线观看免费| 国产日产亚洲精品系列| 欧美精品日韩精品| 91一区二区在线观看| 久久成人久久鬼色| 亚洲第一主播视频| 最新成人av在线| 26uuu欧美| 欧美一级二级在线观看| 在线日韩国产精品| 国产成人亚洲综合a∨猫咪| 青娱乐精品视频| 夜夜嗨av一区二区三区| 欧美国产日本视频| 精品少妇一区二区三区日产乱码 | 大胆欧美人体老妇| 日本韩国一区二区| 韩国欧美一区二区| 日本伊人色综合网| 亚洲一区二区美女| 中文字幕欧美一区| 日本一区二区在线不卡| 日韩精品一区二区三区老鸭窝 | 91在线你懂得| 99精品国产91久久久久久 | 中文字幕一区二区三区色视频| 久久一二三国产| 久久婷婷国产综合精品青草| 日韩手机在线导航| 欧美一区二区性放荡片| 欧美电影在线免费观看| 欧美日韩夫妻久久| 欧美日韩激情一区二区三区| 在线免费不卡视频| 在线免费观看日韩欧美| 欧日韩精品视频| 欧美日本在线看| 欧美日韩成人激情| 欧美一区二区三区四区久久| 69堂国产成人免费视频| 日韩色在线观看| 久久久国产一区二区三区四区小说 | 91精品国产综合久久精品app| 欧美伊人久久大香线蕉综合69| 一本一本大道香蕉久在线精品| 一本色道**综合亚洲精品蜜桃冫| 色综合久久久久| 精品视频一区 二区 三区| 欧美日韩成人综合天天影院| 欧美人牲a欧美精品| 日韩欧美一区二区久久婷婷| 久久影音资源网| 中文一区在线播放| 亚洲三级在线免费| 天堂影院一区二区| 激情综合色播五月| 粉嫩高潮美女一区二区三区 | 久久精品一区二区三区av| 久久久精品人体av艺术| 亚洲婷婷综合久久一本伊一区| 一区二区三区精品在线| 午夜亚洲福利老司机| 久久电影网电视剧免费观看| 国产成a人亚洲精品| 91福利国产成人精品照片| 91精品久久久久久久91蜜桃| 亚洲精品一区在线观看| 中文字幕一区二区三区不卡在线| 亚洲一区二区三区不卡国产欧美| 日韩av一区二区在线影视| 国产一区久久久| 日本精品免费观看高清观看| 日韩欧美中文一区二区| 国产精品午夜在线| 香蕉影视欧美成人| 国产成人午夜精品5599| 在线免费观看一区| 久久久久一区二区三区四区| 亚洲女与黑人做爰| 麻豆精品视频在线观看视频| 国产高清不卡一区| 欧美日韩久久一区二区| 国产三级欧美三级日产三级99| 一区二区三区高清不卡| 国产一区二区三区在线观看免费| 91免费在线播放| 精品成人在线观看| 亚洲动漫第一页| 成人污视频在线观看| 色视频成人在线观看免| 久久亚洲精精品中文字幕早川悠里| 中文字幕日本乱码精品影院| 狠狠色狠狠色综合| 欧美日韩国产123区| 国产色产综合色产在线视频| 婷婷综合另类小说色区| 91麻豆6部合集magnet| 日韩欧美一二三区| 亚洲成人在线免费| 一本到不卡免费一区二区| 欧美sm美女调教| 日韩电影在线观看一区| 色诱视频网站一区| 中文字幕乱码一区二区免费| 麻豆成人免费电影| 色拍拍在线精品视频8848| 欧美精品一区二区三区久久久| 亚洲成av人片观看| 色综合久久久久网| 国产精品不卡在线观看| 国产二区国产一区在线观看| 日韩欧美区一区二| 免费三级欧美电影| 欧美美女一区二区在线观看| 亚洲欧美日韩国产另类专区 | 国产一区日韩二区欧美三区| 欧美一二三四区在线| 性久久久久久久| 欧美性生交片4| 亚洲一区在线免费观看| 91麻豆自制传媒国产之光| 国产精品乱码一区二区三区软件 | 久久久国产精品麻豆| 蜜臀精品一区二区三区在线观看| 欧美顶级少妇做爰| 婷婷久久综合九色综合伊人色| 欧美男男青年gay1069videost| 一区二区在线观看不卡| 欧美性猛片aaaaaaa做受| 亚洲欧美偷拍另类a∨色屁股| 成人短视频下载| 国产精品久久久99| 成人精品鲁一区一区二区| 国产精品二三区| 色乱码一区二区三区88| 一区二区三区四区蜜桃| 欧美日韩一卡二卡三卡| 偷拍一区二区三区四区| 91精品欧美一区二区三区综合在 | 五月天婷婷综合| 日韩欧美在线网站| 国产成人精品免费一区二区| 欧美极品另类videosde| 色综合一区二区| 亚洲bdsm女犯bdsm网站| 欧美一区二区三区播放老司机| 日本91福利区| 久久久亚洲午夜电影| 岛国av在线一区| 亚洲人妖av一区二区| 欧美日韩一卡二卡| 久色婷婷小香蕉久久| 中文字幕不卡三区| 欧美三级在线视频| 狠狠久久亚洲欧美| 国产精品久久看| 欧美日韩在线播放| 国产一区三区三区| 一区二区三区美女| 精品粉嫩超白一线天av| 91在线观看地址| 久久精品免费看| 自拍偷在线精品自拍偷无码专区|