⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spt.cpp

📁 网络MPEG4IP流媒体开发源代码
💻 CPP
📖 第 1 页 / 共 3 页
字号:
         }         VWH = VW * VH;         vwh_pwr = vw_pwr + vh_pwr;         Int x2 = 0;         Int y2 = H;         ex2p = LinearExtrapolation(x0, x2, x0p, x2p, H, VH) + (x0<<4);         ey2p = LinearExtrapolation(y0, y2, y0p, y2p, H, VH) + ((y0+VH)<<4);         if (vw_pwr<=vh_pwr) {            VH /= VW;            VWH /= VW;            VW=1;            vh_pwr -= vw_pwr;            vwh_pwr -= vw_pwr;            vw_pwr=0;         }         else {            VW /= VH;            VWH /= VH;            VH=1;            vw_pwr -= vh_pwr;            vwh_pwr -= vh_pwr;            vh_pwr=0;         }         ex2p -= (sprite_left_edge * 16);         ey2p -= (sprite_top_edge * 16);     }     x0p -= (sprite_left_edge * 16);     y0p -= (sprite_top_edge * 16);     ex1p -= (sprite_left_edge * 16);     ey1p -= (sprite_top_edge * 16);     if (pntNum == 2) {        a = ex1p - x0p ;        b = y0p - ey1p ;        c = x0p * VW;        d = -b ;        e = a ;        f = y0p * VW;        dnm_pwr = r_pwr + vw_pwr;        cxy = c + r*VW/2;        cyy = f + r*VW/2;     } 	 else if (pntNum == 3) {		a = (ex1p - x0p) * VH;		b = (ex2p - x0p) * VW;		c = x0p * VWH;		d = (ey1p - y0p) * VH;		e = (ey2p - y0p) * VW;		f = y0p * VWH;		dnm_pwr = r_pwr + vwh_pwr;		cxy = c + r*VWH/2;		cyy = f + r*VWH/2;     }     Int sprite_width = m_pvopcSptQ -> whereY ().width;     Int sprite_height = m_pvopcSptQ -> whereY ().bottom                       - m_pvopcSptQ -> whereY ().top;     sprite_left_edge *= (1 << accuracy1);     sprite_top_edge *= (1 << accuracy1);     Int cxx_i, cxx_f, cyx_i, cyx_f, cxy_i, cxy_f, cyy_i, cyy_f;     Int a_i, a_f, b_i, b_f, d_i, d_f, e_i, e_f;     FourSlashes(cxy, 1<<dnm_pwr, &cxy_i, &cxy_f);     FourSlashes(cyy, 1<<dnm_pwr, &cyy_i, &cyy_f);     FourSlashes(a, 1<<dnm_pwr, &a_i, &a_f);     FourSlashes(b, 1<<dnm_pwr, &b_i, &b_f);     FourSlashes(d, 1<<dnm_pwr, &d_i, &d_f);     FourSlashes(e, 1<<dnm_pwr, &e_i, &e_f);     Int fracmask = (1 << dnm_pwr) - 1;     Int y,x;     UInt accuracy2 = accuracy1 << 1;#ifdef _FOR_GSSP_     PixelC pxlcWarpedBY;#else     PixelC pxlcWarpedA;#endif     Int rx,ry;     Int addr_offset;     Int warpmask = uiScale -1;     Int bias = 1<<(accuracy2-1);	 for (y = 0; y < height;           cxy_i += b_i, cxy_f += b_f, cyy_i += e_i, cyy_f += e_f, y++) {		cxy_i += cxy_f >> dnm_pwr;		cyy_i += cyy_f >> dnm_pwr;		cxy_f &= fracmask;		cyy_f &= fracmask;		for (x = 0, cxx_i = cxy_i, cxx_f = cxy_f, 				cyx_i = cyy_i, cyx_f = cyy_f;				x < width; cxx_i += a_i, cxx_f += a_f, 				cyx_i += d_i, cyx_f += d_f, x++) {			cxx_i += cxx_f >> dnm_pwr;			cyx_i += cyx_f >> dnm_pwr;			cxx_f &= fracmask;			cyx_f &= fracmask;            if (cxx_i >= EXPANDY_REFVOP && cyx_i >= EXPANDY_REFVOP 					  && cxx_i <= ((sprite_width-1-EXPANDY_REFVOP)<<accuracy1)					  && cyx_i <= ((sprite_height-1-EXPANDY_REFVOP)<<accuracy1)) {				addr_offset = (cyx_i>>accuracy1) * sprite_width + (cxx_i>>accuracy1);				rx = cxx_i & warpmask;				ry = cyx_i & warpmask;#ifdef _FOR_GSSP_				pxlcWarpedBY = CInterpolatePixelValue (	ppxlcSptQBY, #else				pxlcWarpedA = CInterpolatePixelValue (	ppxlcSptQA, #endif														addr_offset,sprite_width, rx, ry,														uiScale, bias, accuracy2);#ifdef _FOR_GSSP_	  	        if (pxlcWarpedBY >= 128) {		 			*ppxlcCurrQBY = MPEG4_OPAQUE;#else	  	        if (pxlcWarpedA >= 128) {		 			*ppxlcCurrQA = MPEG4_OPAQUE;#endif                    *ppxlcCurrQY = CInterpolatePixelValue (	ppxlcSptQY, 															addr_offset, sprite_width, rx, ry,															uiScale, bias, accuracy2);#ifdef _FOR_GSSP_	                        if(m_pvopcSptQ -> fAUsage () == EIGHT_BIT)                    			*ppxlcCurrQA = CInterpolatePixelValue (	ppxlcSptQA, 																addr_offset, sprite_width, rx, ry,																uiScale, bias, accuracy2);#endif				}		    }			ppxlcCurrQY++;	#ifdef _FOR_GSSP_			ppxlcCurrQBY++;	#endif			ppxlcCurrQA++;		}		ppxlcCurrQY += offset;#ifdef _FOR_GSSP_		ppxlcCurrQBY += offset;#endif		ppxlcCurrQA += offset;	 }#ifdef _FOR_GSSP_	ppxlcCurrQBY = (PixelC*) puciCurrBY -> pixels (rctWarpedBound.left, rctWarpedBound.top);	PixelC* ppxlcCurrQBYNextRow = ppxlcCurrQBY + puciCurrBY -> where ().width;#else	ppxlcCurrQA = (PixelC*) puciCurrA -> pixels (rctWarpedBound.left, rctWarpedBound.top);	PixelC* ppxlcCurrQANextRow = ppxlcCurrQA + puciCurrA -> where ().width;#endif	sprite_left_edge /= 2;	sprite_top_edge /= 2;	width /= 2;	height /= 2;	sprite_width /= 2;	sprite_height /= 2;	if (pntNum == 2) {		c = 2 * x0p * VW - 16*VW ;		f = 2 * y0p * VW - 16*VW ;		cxy = a + b + c + 2*r*VW;		cyy = d + e + f + 2*r*VW;	} 	else if (pntNum == 3) {		c = 2 * x0p * VWH - 16*VWH ;		f = 2 * y0p * VWH - 16*VWH ;		cxy = a + b + c + 2*VWH*r;		cyy = d + e + f + 2*VWH*r;	}	a_f *= 4;	b_f *= 4;	d_f *= 4;	e_f *= 4;	dnm_pwr += 2;	FourSlashes(cxy, 1<<dnm_pwr, &cxy_i, &cxy_f);	FourSlashes(cyy, 1<<dnm_pwr, &cyy_i, &cyy_f);	fracmask = (1 << dnm_pwr) - 1;	for (y = 0; y < height; 			cxy_i+=b_i, cxy_f+=b_f, cyy_i+=e_i, cyy_f+=e_f, y++) {		cxy_i += cxy_f >> dnm_pwr;		cyy_i += cyy_f >> dnm_pwr;		cxy_f &= fracmask;		cyy_f &= fracmask;		for (x = 0, cxx_i = cxy_i, cxx_f = cxy_f,                     cyx_i = cyy_i, cyx_f = cyy_f;                    x < width; cxx_i += a_i, cxx_f += a_f,                     cyx_i += d_i, cyx_f += d_f, x++) {			cxx_i += cxx_f >> dnm_pwr;			cyx_i += cyx_f >> dnm_pwr;			cxx_f &= fracmask;			cyx_f &= fracmask;			if ( cxx_i >= EXPANDUV_REFVOP && cyx_i >= EXPANDUV_REFVOP 					  && cxx_i <= ((sprite_width-1-EXPANDUV_REFVOP)<<accuracy1)					  && cyx_i <= ((sprite_height-1-EXPANDUV_REFVOP)<<accuracy1)) {				addr_offset = (cyx_i>>accuracy1) * sprite_width + (cxx_i>>accuracy1);				rx = cxx_i & warpmask;				ry = cyx_i & warpmask;#ifdef _FOR_GSSP_				if (*ppxlcCurrQBY | *(ppxlcCurrQBY + 1) | *ppxlcCurrQBYNextRow | *(ppxlcCurrQBYNextRow+1)) {#else				if (*ppxlcCurrQA | *(ppxlcCurrQA + 1) | *ppxlcCurrQANextRow | *(ppxlcCurrQANextRow+1)) {#endif					*ppxlcCurrQU = CInterpolatePixelValue (	ppxlcSptQU, addr_offset,															sprite_width, rx, ry, uiScale, 															bias, accuracy2); 					*ppxlcCurrQV = CInterpolatePixelValue (	ppxlcSptQV, addr_offset,															sprite_width, rx, ry, uiScale, 															bias, accuracy2); 				}		    }#ifdef _FOR_GSSP_			ppxlcCurrQBY += 2;			ppxlcCurrQBYNextRow += 2;#else			ppxlcCurrQA += 2;			ppxlcCurrQANextRow += 2;#endif			ppxlcCurrQU++;				ppxlcCurrQV++;		}#ifdef _FOR_GSSP_		ppxlcCurrQBY += offsetBY;		ppxlcCurrQBYNextRow += offsetBY;#else		ppxlcCurrQA += offsetBY;		ppxlcCurrQANextRow += offsetBY;#endif		ppxlcCurrQU += offsetUV;		ppxlcCurrQV += offsetUV;	}}PixelC CVideoObject:: CInterpolatePixelValue(PixelC* F, Int pos, Int width,                           Int rx, Int ry, Int wpc, Int bias, Int pow_denom){	PixelC* Fp;	Int rxc, ryc;	Int hstep, vstep;	Fp = F + pos;	rxc = wpc - rx;	ryc = wpc - ry;	hstep = rx ? 1 : 0;	vstep = ry ? width : 0;	return ((PixelC) (((ryc * (rxc * *Fp + rx * *(Fp+hstep))            + ry * (rxc * *(Fp+vstep) + rx * *(Fp+vstep+hstep))) + bias)            >> pow_denom));}Int CVideoObject:: LinearExtrapolation(Int x0, Int x1, Int x0p, Int x1p, Int W, Int VW){	Int quot, res, ressum, extrapolated;	FourSlashes(x0p - (x0 << 4), W, &quot, &res);	extrapolated = quot * (W - VW);	FourSlashes(res * (W - VW), W, &quot, &res);	extrapolated += quot;	ressum = res;	FourSlashes(x1p - (x1 << 4), W, &quot, &res);	extrapolated += quot * VW + res;	FourSlashes(res * (VW - W), W, &quot, &res);	extrapolated += quot;	ressum += res;	FourSlashes(ressum, W, &quot, &res);	extrapolated += quot;	if(extrapolated >= 0) {		if(res >= (W+1) / 2)			extrapolated++;	} 	else		if(res > W / 2)			extrapolated++;	return(extrapolated);}Void CVideoObject::FourSlashes(Int num, Int denom, Int *quot, Int *res){	*quot =  num / denom;	if (*quot * denom == num)		*res = 0;	else 	{		if (num < 0) /* denom is larger than zero */			*quot -= 1;		*res = num - denom * *quot;	}}Void CVideoObject::swapRefQ1toSpt (){	m_pvopcSptQ = m_pvopcRefQ1;	m_pvopcSptQ -> shift (m_rctSpt.left, m_rctSpt.top); #ifdef _FOR_GSSP_	if(m_pvopcSptQ -> fAUsage () == EIGHT_BIT){		CU8Image* puciSptBY = (CU8Image *) m_pvopcSptQ -> getPlane (BY_PLANE);		puciSptBY -> shift (m_rctSpt.left, m_rctSpt.top);	}#endif	m_pvopcRefQ1 = NULL;}Void CVideoObject::changeSizeofCurrQ (CRct rctOrg){	delete m_pvopcCurrQ;	rctOrg.expand (EXPANDY_REF_FRAME);	m_pvopcCurrQ = new CVOPU8YUVBA (m_pvopcSptQ -> fAUsage (), rctOrg);} Bool CVideoObject::SptPieceMB_NOT_HOLE(Int iMBXoffset, Int iMBYoffset, CMBMode* pmbmd) //	  In a given Sprite object piece, Check whether current macroblock is not a hole and should be coded ?{	if (m_tPiece < 0)		return TRUE;	else 	{		CMBMode* pmbmdLeft = pmbmd - 1;		Int iMBX = 	iMBXoffset + m_iPieceXoffset;		Int iMBY = 	iMBYoffset + m_iPieceYoffset;				Int iMBX1 = iMBX -1;// dshu: [v071] begin of modification		Int iMod = m_rctSpt.width % MB_SIZE;		Int iSptWidth = (iMod > 0) ? m_rctSpt.width + MB_SIZE - iMod : m_rctSpt.width;		Int iNumMBX = iSptWidth / MB_SIZE;   // dshu: [v071] end of modification		IntraPredDirection* Spreddir = m_rgmbmdSpt[iMBY][iMBX1].m_preddir;		IntraPredDirection* preddir = (*pmbmdLeft).m_preddir;			if (iMBXoffset >0 ) 			if( m_ppPieceMBstatus[iMBY][iMBX1] == NOT_DONE)			{				m_ppPieceMBstatus[iMBY][iMBX1] = PIECE_DONE;				m_rgmbmdSpt[iMBY][iMBX1] = CMBMode (*pmbmdLeft);				m_rgmbmdSprite[iMBX1 + iNumMBX * iMBY] = CMBMode (*pmbmdLeft);  // dshu: [v071]  added to store mbmd array for sprite				memcpy (Spreddir, preddir, 10  * sizeof (IntraPredDirection));			}			else {				*pmbmdLeft = CMBMode (m_rgmbmdSpt[iMBY][iMBX1]);				memcpy (preddir, Spreddir, 10  * sizeof (IntraPredDirection));			}// dshu: begin of modification		if ( iMBX < (m_rctSptQ.width / MB_SIZE))	  // dshu: end of modification//		if ( iMBX < (m_rctSptExp.width / MB_SIZE))			return ( m_ppPieceMBstatus[iMBY][iMBX] == NOT_DONE)	;	}	return FALSE;} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -