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

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

?? dpcmprocess.cpp

?? 采用DPCM壓縮算法的工程文件
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
// DpcmProcess.cpp: implementation of the CDpcmProcess class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "CDpcmDemo.h"
#include "DpcmProcess.h"
#include ".\dpcmprocess.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CDpcmProcess::CDpcmProcess()
{
	
}

CDpcmProcess::~CDpcmProcess()
{
	
}

/* We use a compact representation with 1 byte per statistics bin,
* thus the numbers directly represent byte sizes.
* This 1 byte per statistics bin contains the meaning of the MPS
* (more probable symbol) in the highest bit (mask 0x80), and the
* index into the probability estimation state machine table
* in the lower bits (mask 0x7F).
*/



/* NOTE: Uncomment the following #define if you want to use the
* given formula for calculating the AC conditioning parameter Kx
* for spectral selection progressive coding in section G.1.3.2
* of the spec (Kx = Kmin + SRL (8 + Se - Kmin) 4).
* Although the spec and P&M authors claim that this "has proven
* to give good results for 8 bit precision samples", I'm not
* convinced yet that this is really beneficial.
* Early tests gave only very marginal compression enhancements
* (a few - around 5 or so - bytes even for very large files),
* which would turn out rather negative if we'd suppress the
* DAC (Define Arithmetic Conditioning) marker segments for
* the default parameters in the future.
* Note that currently the marker writing module emits 12-byte
* DAC segments for a full-component scan in a color image.
* This is not worth worrying about IMHO. However, since the
* spec defines the default values to be used if the tables
* are omitted (unlike Huffman tables, which are required
* anyway), one might optimize this behaviour in the future,
* and then it would be disadvantageous to use custom tables if
* they don't provide sufficient gain to exceed the DAC size.
*
* On the other hand, I'd consider it as a reasonable result
* that the conditioning has no significant influence on the
* compression performance. This means that the basic
* statistical model is already rather stable.
*
* Thus, at the moment, we use the default conditioning values
* anyway, and do not use the custom formula.
*
* IRIGHT_SHIFT is like RIGHT_SHIFT, but works on int rather than INT32.
* We assume that int right shift is unsigned if INT32 right shift is,
* which should be safe.
*/ 

/*
* Finish up at the end of an arithmetic-compressed scan.
*/
void CDpcmProcess::Flush_Bits(j_compress_ptr cinfo)
{
	arith_entropy_ptr e = (arith_entropy_ptr) cinfo->entropy;
	INT32 temp;
	
	/* Section D.1.8: Termination of encoding */
	
	/* Find the e->c in the coding interval with the largest
	* number of trailing zero bits */
	if ((temp = (e->a - 1 + e->c) & 0xFFFF0000L) < e->c)
		e->c = temp + 0x8000L;
	else
		e->c = temp;
	/* Send remaining bytes to output */
	e->c <<= e->ct;
	if (e->c & 0xF8000000L) {
		/* One final overflow has to be handled */
		if (e->buffer >= 0) {
			if (e->zc)
				do Emit_Byte(cinfo,0x00);
				while (--e->zc);
				Emit_Byte(cinfo,e->buffer + 1);
				if (e->buffer + 1 == 0xFF)
					Emit_Byte(cinfo,0x00);
		}
		e->zc += e->sc;  /* carry-over converts stacked 0xFF bytes to 0x00 */
		e->sc = 0;
	} else {
		if (e->buffer == 0)
			++e->zc;
		else if (e->buffer >= 0) {
			if (e->zc)
				do Emit_Byte(cinfo,0x00);
				while (--e->zc);
				Emit_Byte(cinfo,e->buffer);
		}
		if (e->sc) {
			if (e->zc)
				do Emit_Byte(cinfo,0x00);
				while (--e->zc);
				do {
					Emit_Byte(cinfo,0xFF);
					Emit_Byte(cinfo,0x00);
				} while (--e->sc);
		}
	}
	/* Output final bytes only if they are not 0x00 */
	if (e->c & 0x7FFF800L) {
		if (e->zc)  /* output final pending zero bytes */
			do Emit_Byte(cinfo,0x00);
			while (--e->zc);
			Emit_Byte(cinfo,(e->c >> 19) & 0xFF);
			if (((e->c >> 19) & 0xFF) == 0xFF)
				Emit_Byte(cinfo,0x00);
			if (e->c & 0x7F800L) {
				Emit_Byte(cinfo,(e->c >> 11) & 0xFF);
				if (((e->c >> 11) & 0xFF) == 0xFF)
					Emit_Byte(cinfo,0x00);
			}
	}
}

/*
* The core arithmetic encoding routine (common in JPEG and JBIG).
* This needs to go as fast as possible.
* Machine-dependent optimization facilities
* are not utilized in this portable implementation.
* However, this code should be fairly efficient and
* may be a good base for further optimizations anyway.
*
* Parameter 'val' to be encoded may be 0 or 1 (binary decision).
*
* Note: I've added full "Pacman" termination support to the
* byte output routines, which is equivalent to the optional
* Discard_final_zeros procedure (Figure D.15) in the spec.
* Thus, we always produce the shortest possible output
* stream compliant to the spec (no trailing zero bytes,
* except for FF stuffing).
*
* I've also introduced a new scheme for accessing
* the probability estimation state machine table,
* derived from Markus Kuhn's JBIG implementation.
*/

void CDpcmProcess::Arith_Encode(j_compress_ptr cinfo, unsigned char *st, int val)
{
	extern const INT32 jaritab[];
	register arith_entropy_ptr e = cinfo->entropy;
	register unsigned char nl, nm;
	register INT32 qe, temp;
	register int sv;
	
	/* Fetch values from our compact representation of Table D.2:
	* Qe values and probability estimation state machine
	*/
	sv = *st;
	qe = jaritab[sv & 0x7F];	/* => Qe_Value */
	nl = qe & 0xFF; qe >>= 8;	/* Next_Index_LPS + Switch_MPS */
	nm = qe & 0xFF; qe >>= 8;	/* Next_Index_MPS */
	
	/* Encode & estimation procedures per sections D.1.4 & D.1.5 */
	e->a -= qe;
	if (val != ((sv >> 7) & (0x00000001))) {
		/* Encode the less probable symbol */
		if (e->a >= qe) {
		/* If the interval size (qe) for the less probable symbol (LPS)
		* is larger than the interval size for the MPS, then exchange
		* the two symbols for coding efficiency, otherwise code the LPS
			* as usual: */
			e->c += e->a;
			e->a = qe;
		}
		*st = (sv & 0x80) ^ nl;	/* Estimate_after_LPS */
	} else {
		/* Encode the more probable symbol */
		if (e->a >= 0x8000L)
			return;  /* A >= 0x8000 -> ready, no renormalization required */
		if (e->a < qe) {
		/* If the interval size (qe) for the less probable symbol (LPS)
		* is larger than the interval size for the MPS, then exchange
		* the two symbols for coding efficiency: ,it is equal to code 
			* the LPS.*/
			e->c += e->a;
			e->a = qe;
		}
		*st = (sv & 0x80) ^ nm ;	/* Estimate_after_MPS ,no change of the sense of the MPS*/
	}
	
	/* Renormalization & data output per section D.1.6 */
	do {
		e->a <<= 1;
		e->c <<= 1;
		if (--e->ct == 0) {
			/* The followning is the byte_out programe.*/
			/* Another byte is ready for output */
			temp = e->c >> 19;
			if (temp > 0xFF) {
				/*Handle overflow over all stacked 0xFF bytes */
				if (e->buffer >= 0) {
					
					Emit_Byte(cinfo,e->buffer + 1);
					if (e->buffer + 1 == 0xFF)
						Emit_Byte(cinfo,0x00); 
				}
				/*e->zc += e->sc;*/  /* carry-over converts stacked 0xFF bytes to 0x00 and output them*/
				while(e->sc-->0)
					Emit_Byte(cinfo,0X00);
				e->sc = 0;
				/* Note: The 3 spacer bits in the C register guarantee
				* that the new buffer byte can't be 0xFF here
				* (see page 160 in the P&M JPEG book). */
				e->buffer = temp & 0xFF;  /* new output byte, might overflow later */
			} else if (temp == 0xFF) {
				++e->sc;  /* stack 0xFF byte (which might overflow later) */
			} else {
				/* Output all stacked 0xFF bytes, they will not overflow any more */
				
				if (e->buffer >= 0) {
					Emit_Byte(cinfo,e->buffer);
					if (e->sc) {
						while (e->sc--) {
							Emit_Byte(cinfo,0xFF);
							Emit_Byte(cinfo,0x00);
						} 
						e->sc=0;
					}
					
				} 
				e->buffer = temp & 0xFF;  /* new output byte (can still overflow) */
			}
			e->c &= 0x7FFFFL;
			e->ct = 8;
		}
	} while (e->a < 0x8000L);
	
}

void CDpcmProcess::Encode_Row(j_compress_ptr cinfo, JSAMPROW row, int i)
{
	arith_entropy_ptr entropy = (arith_entropy_ptr) cinfo->entropy;
	unsigned char * st;
	unsigned char context_a=0;
	int num;
	int v, v2, m,last_val=0,Rc=0;
	
	
	entropy->context=0;
	/* Encode the MCU data blocks */
	for (num = 0; num < cinfo->image_width; num++) {
		
		/* Sections F.1.4.1 & F.1.4.4.1: Encoding of DC coefficients */
		
		
		/* Table F.4: Point to statistics bin S0 for DC coefficient coding */
		st =entropy->dc_stats + entropy->context*5+entropy->context_b[num];
		
		/*predic_val=last_val+((entropy->val_b[num]-Rc)>>1);*/
		/*predic_val=RIGHT_SHIFT(last_val+entropy->val_b[num],1);*/
		v=Get_Errval(cinfo,last_val,entropy->val_b[num],Rc,entropy->val_b[num+1],row+num);
		/* if (i==0)
		printf("row[%d]:%x  v=%d\n",num,row[num],v);*/
		/*v=row[num]-predic_val;*/
		/* Figure F.4: Encode_DC_DIFF */
		if ((v ) == 0) {
			Arith_Encode(cinfo, st, 0);
			entropy->context = 0;	                /* zero diff category */
			
		} else {
			
			Arith_Encode(cinfo, st, 1);
			/* Figure F.6: Encoding nonzero value v */
			/* Figure F.7: Encoding the sign of v */
			if (v > 0) {
				st +=1;
				Arith_Encode(cinfo, st, 0);	/* Table F.4: SS = S0 + 1 */
				st += 1;			/* Table F.4: SP = S0 + 2 */
				entropy->context = 4;	                /* small positive diff category */
			} else {
				st +=1;
				v = -v;
				Arith_Encode(cinfo, st, 1);	/* Table F.4: SS = S0 + 1 */
				st += 2;			/* Table F.4: SN = S0 + 3 */
				entropy->context = 8;	                /* small negative diff category */
			}
			/* Figure F.8: Encoding the magnitude category of v */
			m = 0;
			if (v -= 1) {
				Arith_Encode(cinfo, st, 1);
				m = 1;
				v2 = v;
				if ( entropy->context_b[num]>8 )
					st=entropy->dc_stats+129;
				else
					st = entropy->dc_stats + 100; /* Table H.3: X1 = X1_context(Db)*/
				/*st=entropy->dc_stats+20;*/
				while (v2 >>= 1) {
					Arith_Encode(cinfo, st, 1);
					m <<= 1;
					st += 1;
				}
			}
			Arith_Encode(cinfo, st, 0);
			
			/* v -=1;
			*m=1;
			*if (v>m){
			*arith_encode(cinfo,st,1);
			*if ( entropy->context_b[num]>8 )
			*  st=entropy->dc_stats+129;
			* else
			*  st = entropy->dc_stats + 100; * Table H.3: X1 = X1_context(Db)*
			*m=2;
			* while (v>=m){
			*  arith_encode (cinfo,st,1);
			* m <<=1;
			*st +=1;
			*}
			*}
			*arith_encode (cinfo,st,0);*/
			
			/* Section F.1.4.4.1.2: Establish dc_context conditioning category */
			if ((m) < (int) (((INT32) 1 << cinfo->arith_dc_L) >> 1))
				entropy->context = 0;	        /* zero diff category */
			else if ((m) > (int) (((INT32) 1 << cinfo->arith_dc_U)>>1 ))
				entropy->context += 8;	        /* large diff category */
			/* Figure F.9: Encoding the magnitude bit pattern of v */
			st += 14;
			while (m >>= 1)
				Arith_Encode(cinfo, st, (m & v) ? 1 : 0);
		}
		entropy->context_b[num]=entropy->context;
		Rc=entropy->val_b[num];
		last_val=entropy->val_b[num]=row[num];
	}
	
}

/*
 * Basic output routines.
 *
 * Note that we do not support suspension while writing a marker.
 * Therefore, an application using suspension must ensure that there is
 * enough buffer space for the initial markers (typ. 600-700 bytes) before
 * calling jpeg_start_compress, and enough space to write the trailing EOI
 * (a few bytes) before calling jpeg_finish_compress.  Multipass compression
 * modes are not supported at all with suspension, so those two are the only
 * points where markers will be written.
 */
 void CDpcmProcess::Empty_Output_Buffer(j_compress_ptr cinfo)
 {
	 jpeg_destination_mgr *dest =  cinfo->dest;
	 
	 if (JFWRITE(cinfo->outputfile, cinfo->outbuffer, OUTPUT_BUF_SIZE) !=
		 (size_t) OUTPUT_BUF_SIZE)
		 exit(0);
	 
	 dest->next_output_byte = cinfo->outbuffer;
	 dest->free_in_buffer = OUTPUT_BUF_SIZE;
	 
 }

 void CDpcmProcess::Emit_Byte(j_compress_ptr cinfo, int val)
 {
	 jpeg_destination_mgr *dest = cinfo->dest;
	 
	 *(dest->next_output_byte)++ = (JOCTET) val;
	 if (--dest->free_in_buffer == 0) 
		 Empty_Output_Buffer (cinfo); 
 }

void CDpcmProcess::Emit_Marker(j_compress_ptr cinfo, JPEG_MARKER mark)
{
	Emit_Byte(cinfo, 0xFF);
	Emit_Byte(cinfo, (int) mark);
}

void CDpcmProcess::Emit_2Bytes(j_compress_ptr cinfo, int value)
{
	Emit_Byte(cinfo, (value >> 8) & 0xFF);
	Emit_Byte(cinfo, value & 0xFF);
}

/*
 * Write datastream header.
 * This consists of an SOI and optional APPn markers.
 * We recommend use of the JFIF marker, but not the Adobe marker,
 * when using YCbCr or grayscale data.  The JFIF marker should NOT
 * be used for any other JPEG colorspace.  The Adobe marker is helpful
 * to distinguish RGB, CMYK, and YCCK colorspaces.
 * Note that an application can write additional header markers after
 * jpeg_start_compress returns.
 */


void CDpcmProcess::Write_File_Header(j_compress_ptr cinfo)
{
	Emit_Marker(cinfo, M_SOI);	/* first the SOI */
	Emit_2Bytes(cinfo,cinfo->image_width);
	Emit_2Bytes(cinfo,cinfo->image_height);
}

void CDpcmProcess::Write_File_Trailer(j_compress_ptr cinfo)
{
	Emit_Marker(cinfo, M_EOI);
}

int CDpcmProcess::Find_Bin(UNI_TYPE Q1, UNI_TYPE Q2, UNI_TYPE Q3, UNI_TYPE *sign_ptr)
{
	int position=0;
	
	if (Q1 != 0) {
		PO_OR_NE(Q1);
		MAKE_FIRST_POSITIVE(Q1,Q2,Q3);

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
《视频一区视频二区| 亚洲综合色婷婷| 欧美三级电影网站| 国产伦精品一区二区三区视频青涩 | 色婷婷精品久久二区二区蜜臂av| 日韩福利电影在线| 亚洲特黄一级片| 精品国产成人系列| 91精选在线观看| 色激情天天射综合网| 粉嫩av亚洲一区二区图片| 蜜桃视频一区二区| 亚洲成av人片观看| 综合av第一页| 国产三级精品三级在线专区| 日韩视频免费直播| 欧美日韩国产首页在线观看| 色老综合老女人久久久| 成人免费看黄yyy456| 激情国产一区二区| 麻豆精品视频在线观看视频| 亚洲国产精品一区二区久久| 亚洲欧美一区二区视频| 国产日韩精品一区二区浪潮av| 日韩免费成人网| 7777精品伊人久久久大香线蕉经典版下载 | 波多野结衣一区二区三区| 天天综合日日夜夜精品| 欧美丰满嫩嫩电影| 日韩美女视频一区| 中文字幕一区不卡| 成人免费视频播放| 国产精品综合在线视频| 美女国产一区二区| 蜜桃视频在线一区| 久久激情综合网| 日韩高清电影一区| 日韩成人午夜精品| 奇米影视7777精品一区二区| 香蕉久久夜色精品国产使用方法 | 99久久伊人久久99| 粉嫩av一区二区三区| 国产91色综合久久免费分享| 粉嫩欧美一区二区三区高清影视| 国产精品白丝av| 成人美女在线观看| 99久久综合色| 欧美性大战久久久| 欧美二区三区91| 日韩视频免费观看高清完整版在线观看| 欧美日韩一级片在线观看| 欧美日韩视频不卡| 欧美一区二区三区啪啪| 欧美大片一区二区| 久久久久久亚洲综合| 国产精品免费久久久久| 亚洲免费在线观看| 亚洲精品国产第一综合99久久| 亚洲欧美日韩国产成人精品影院 | 日韩不卡在线观看日韩不卡视频| 视频一区二区欧美| 久久99精品国产91久久来源| 国产黄人亚洲片| 色综合色综合色综合| 91蜜桃免费观看视频| 69精品人人人人| 久久久久久亚洲综合影院红桃| 国产精品女同互慰在线看| 一区二区三区蜜桃网| 免费高清在线一区| 国产东北露脸精品视频| 色琪琪一区二区三区亚洲区| 777xxx欧美| 国产日韩欧美a| 亚洲一区二区三区免费视频| 麻豆国产精品官网| 99这里都是精品| 欧美一区二区二区| 国产精品久久久久久久久晋中 | 国产麻豆精品在线| 91性感美女视频| 日韩一级二级三级精品视频| 国产欧美1区2区3区| 午夜伦理一区二区| 国产成人精品1024| 69精品人人人人| 中文字幕在线不卡一区二区三区| 日韩精品亚洲专区| 91一区一区三区| 精品国产亚洲一区二区三区在线观看 | 在线视频一区二区免费| 久久综合色鬼综合色| 免费观看在线色综合| 不卡的av在线播放| 日韩免费成人网| 亚洲夂夂婷婷色拍ww47| 成人午夜在线免费| 日韩欧美国产1| 亚洲综合色丁香婷婷六月图片| 国产综合久久久久久久久久久久| 在线亚洲一区二区| 国产欧美一区二区三区网站| 婷婷开心激情综合| 色久综合一二码| 国产欧美日韩亚州综合| 日韩电影在线免费看| 日本电影亚洲天堂一区| 中文欧美字幕免费| 狠狠色综合日日| 欧美一区二区三区视频免费| 亚洲免费资源在线播放| 成人高清免费观看| 久久先锋资源网| 免费一级欧美片在线观看| 在线视频中文字幕一区二区| 国产精品国产三级国产a| 国产精品99久久久久久有的能看| 欧美一区二区三区不卡| 亚洲国产精品久久人人爱蜜臀| 成人av小说网| 日本一区二区不卡视频| 国产精品一二三区在线| 精品国产电影一区二区| 久久精品72免费观看| 日韩一区二区三| 日韩和欧美的一区| 欧美乱熟臀69xxxxxx| 夜夜嗨av一区二区三区网页| 色狠狠色狠狠综合| 亚洲卡通动漫在线| 99riav久久精品riav| 中文字幕五月欧美| 99麻豆久久久国产精品免费优播| 国产精品久久777777| 成人午夜精品在线| 国产精品视频免费看| 成人高清免费在线播放| 国产精品久99| 色悠久久久久综合欧美99| 一区二区三区在线免费| 欧美日韩在线播放三区四区| 午夜a成v人精品| 日韩一区二区麻豆国产| 美女爽到高潮91| 精品国产凹凸成av人网站| 国产一区二区三区在线观看免费视频| 337p粉嫩大胆噜噜噜噜噜91av| 精品一区二区三区在线观看| 久久一区二区三区国产精品| 国产老妇另类xxxxx| 国产精品每日更新| 色哟哟欧美精品| 五月开心婷婷久久| 精品理论电影在线观看| 丁香婷婷综合五月| 一区二区三区中文免费| 精品国免费一区二区三区| 国产成人亚洲精品狼色在线| 国产精品久久久久久久久图文区| 一本久久a久久免费精品不卡| 午夜精品一区二区三区三上悠亚| 日韩一区二区三区av| 国产成人精品www牛牛影视| 亚洲欧美日韩在线| 在线综合亚洲欧美在线视频| 国内精品在线播放| 亚洲欧美日韩系列| 欧美精品在线一区二区| 国模一区二区三区白浆| 中文字幕中文字幕在线一区 | 91精品婷婷国产综合久久性色| 青青草国产成人99久久| 国产三级欧美三级| 日本韩国一区二区三区视频| 日韩精品一区第一页| 国产欧美精品一区| 欧美日韩三级视频| 国产自产高清不卡| 一区二区三区av电影| 日韩精品中午字幕| 成人18视频日本| 午夜精品一区在线观看| 国产欧美一区二区三区在线老狼| 欧美午夜精品一区二区三区 | 国产999精品久久| 夜夜嗨av一区二区三区中文字幕 | 亚洲国产成人在线| 欧美日本一区二区在线观看| 国产精品自拍三区| 亚洲成人久久影院| 国产欧美日产一区| 91精品国产高清一区二区三区 | 99久久亚洲一区二区三区青草 | 色域天天综合网| 韩国在线一区二区| 午夜视频在线观看一区二区三区 | 中文字幕在线不卡一区 | 日韩一区二区在线观看视频| 99国产一区二区三精品乱码| 国产中文字幕精品|