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

📄 sys_encoder_gme_for_iso.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 4 页
字号:
									dk = dx1 - x1;									d1mk = 1. - dk;									dl = dy1 - y1;									d1ml = 1. -dl;									dI1x1y1[0] = pref_work[iref_pel];									dI1x1y1[1] = pref_work[iref_pel1];									dI1x1y1[2] = pref_work[iref_pel2];									dI1x1y1[3] = pref_work[iref_pel3];									dI1 = d1mk*d1ml*dI1x1y1[0] + dk*d1ml*dI1x1y1[1] +										d1mk*dl*dI1x1y1[2] + dk*dl*dI1x1y1[3];									de = dI1 - pcurr_work[icurr_pel];									if(iite==0)										iperror_histgram[(Int)(fabs(de))]++;									if(fabs(de) < ithreshold_T) {										dI1dx = (dI1x1y1[1]-dI1x1y1[0])*d1ml + (dI1x1y1[3]-dI1x1y1[2])*dl;										dI1dy = (dI1x1y1[2]-dI1x1y1[0])*d1mk + (dI1x1y1[3]-dI1x1y1[1])*dk;										ddedm[0] = dI1dx;										ddedm[1] = dI1dy;										db[0] += -de*ddedm[0];										db[1] += -de*ddedm[1];										for(yj=0; yj<2; yj++)											for(xi=0; xi<=yj; xi++)												dA[yj*2+xi] += ddedm[yj] * ddedm[xi];											dE2 += de*de;									} // threshold								} // limit of ref_luma area							} // limit of curr_luma area													} // limit of curr_alpha value											} // x					icurr_pel += icurr_offset;				} // y							}						if(iite==0){				istop = istop*90/100;				itmp=0;				for(xi=0;xi<256;xi++){					itmp+=iperror_histgram[xi];					if(itmp > istop){						ithreshold_T = xi-1;						break; 					}				}			}						dA[1] = dA[2];						icheck = DeltaMP(dA, 2, db, dm);						if(icheck){				for(xi=0; xi<2; xi++)					dTM[xi] += dm[xi];				if(fabs(dm[0]) < 0.001 && fabs(dm[1]) < 0.001 ) break; 			}else{				// printf("not up to matrix\n");				break;			}					} // iteration/		if(ilevel){			dTM[0] *= 2;			dTM[1] *= 2;			ifilter_offset = 				icurr_width * (EXPANDY_REF_FRAME>>ilevel) + (EXPANDY_REF_FRAME>>ilevel);			pref_work -= ifilter_offset ;			delete [] pref_work; pref_work = NULL;			pcurr_work -= ifilter_offset ;			delete [] pcurr_work; pcurr_work = NULL;			if(m_volmd.fAUsage != RECTANGLE) {				pref_alpha_work -= ifilter_offset ;				delete [] pref_alpha_work; pref_alpha_work = NULL;				pcurr_alpha_work -= ifilter_offset ;				delete [] pcurr_alpha_work; pcurr_alpha_work = NULL;			}		}		icurr_width *= 2;		icurr_height *= 2;		icurr_left *= 2;		icurr_top *= 2;		icurr_right *= 2;		icurr_bottom *= 2;		iref_width *= 2;		iref_height *= 2;		iref_left *= 2;		iref_top *= 2;		iref_right *= 2;		iref_bottom *= 2;	} // level	pparameter -> dp1 = 1.0;	pparameter -> dp2 = 0.0;	pparameter -> dp3 = dTM[0];	pparameter -> dp4 = 0.0;	pparameter -> dp5 = 1.0;	pparameter -> dp6 = dTM[1];	pparameter -> dp7 = 0.0;	pparameter -> dp8 = 0.0;	delete [] dm; dm=NULL;	delete [] db; db= NULL;	delete [] dA; dA= NULL;	delete [] dTM; dTM= NULL;	delete [] ddedm; ddedm = NULL;	delete [] dI1x1y1; dI1x1y1 = NULL;	delete [] iperror_histgram; iperror_histgram = NULL;}Void CVideoObjectEncoder::IsotropicGME(const CVOPU8YUVBA* pvopcurr,									   const CVOPU8YUVBA* pvopref, const CRct rctframe, const CRct rctcurr,									   const CRct rctref, GME_para *pparameter){	const CU8Image* puciRefY = pvopref -> getPlane (Y_PLANE);	const CU8Image* puciCurrY = pvopcurr -> getPlane (Y_PLANE);	PixelC* pref = (PixelC*) puciRefY -> pixels ();	PixelC* pcurr = (PixelC*) puciCurrY -> pixels ();	const CU8Image* puciRefA = (pvopref -> fAUsage () == EIGHT_BIT)?        pvopref -> getPlaneA (0) :	((m_volmd.fAUsage == RECTANGLE) ? (CU8Image*)NULL:pvopref -> getPlane (BY_PLANE));	const CU8Image* puciCurrA = (pvopcurr -> fAUsage () == EIGHT_BIT)?        pvopcurr -> getPlaneA (0) :	((m_volmd.fAUsage == RECTANGLE) ? (CU8Image*)NULL:pvopcurr -> getPlane (BY_PLANE));	PixelC* pref_alpha = NULL;	PixelC* pcurr_alpha = NULL;		if(m_volmd.fAUsage != RECTANGLE){		pref_alpha = (PixelC*) puciRefA -> pixels ();		pcurr_alpha = (PixelC*) puciCurrA -> pixels ();	}		PixelC *pref_P0=NULL, *pref_P1=NULL, *pref_P2=NULL;	PixelC *pcurr_P0=NULL, *pcurr_P1=NULL, *pcurr_P2=NULL;	PixelC *pref_a_P0=NULL, *pref_a_P1=NULL, *pref_a_P2=NULL;	PixelC *pcurr_a_P0=NULL, *pcurr_a_P1=NULL, *pcurr_a_P2=NULL;	PixelC *pref_work, *pcurr_work, *pcurr_alpha_work = NULL, *pref_alpha_work = NULL;	Int icurr_width, icurr_height, icurr_offset;	Int icurr_left, icurr_top, icurr_right, icurr_bottom;	Int iref_width, iref_height;	Int iref_left, iref_top, iref_right, iref_bottom;		Int xi, yj, itmp, ibest_locationx, ibest_locationy;	Int icurr_pel, iref_pel;	Int iref_pel1, iref_pel2, iref_pel3;	Double *dm = new Double [4];	Double *db = new Double [4];	Double *dA = new Double [16];	Double *dTM = new Double [4];	Double dE2 = 0;	Int istop = 0, ilevel = 2, iite = 0;	Int x, y, x1, y1;	Double dx1, dy1, dx, dy;	Double dt, du, dk, d1mk, dl, d1ml,		dI1, de, dI1dx, dI1dy;	Double *ddedm = new Double [4];	Double *dI1x1y1 = new Double [4];	Int *iperror_histgram = new Int [256];	Int ithreshold_T=0, icheck = 1;		iref_left = (rctref.left+EXPANDY_REFVOP) >> 2;	iref_top = (rctref.top+EXPANDY_REFVOP) >> 2;	iref_right = (rctref.right-EXPANDY_REFVOP) >> 2;	iref_bottom = (rctref.bottom-EXPANDY_REFVOP) >> 2;	iref_width = (rctframe.right - rctframe.left) >> 2;	iref_height = (rctframe.bottom - rctframe.top) >> 2;		icurr_left = (rctcurr.left) >> 2;	icurr_top = (rctcurr.top) >> 2;	icurr_right = (rctcurr.right) >> 2;	icurr_bottom = (rctcurr.bottom) >> 2;	icurr_width = iref_width ;	icurr_height = iref_height ;		pref_P0 = pref;	pcurr_P0 = pcurr;	pref_P1 = new PixelC[iref_width*iref_height*4];	pcurr_P1 = new PixelC[icurr_width*icurr_height*4];	pref_P2 = new PixelC[iref_width*iref_height];	pcurr_P2 = new PixelC[icurr_width*icurr_height];	ThreeTapFilter(pref_P1, pref_P0, iref_width*4, iref_height*4);	ThreeTapFilter(pcurr_P1, pcurr_P0, icurr_width*4, icurr_height*4);	ThreeTapFilter(pref_P2, pref_P1, iref_width*2, iref_height*2);	ThreeTapFilter(pcurr_P2, pcurr_P1, icurr_width*2, icurr_height*2);		if(m_volmd.fAUsage != RECTANGLE){		pref_a_P0 = pref_alpha;		pcurr_a_P0 = pcurr_alpha;		pref_a_P1 = new PixelC[iref_width*iref_height*4];		pcurr_a_P1 = new PixelC[icurr_width*icurr_height*4];		pref_a_P2 = new PixelC[iref_width*iref_height];		pcurr_a_P2 = new PixelC[icurr_width*icurr_height];		ThreeTapFilter(pref_a_P1, pref_a_P0, iref_width*4, iref_height*4);		ThreeTapFilter(pcurr_a_P1, pcurr_a_P0, icurr_width*4, icurr_height*4);		ThreeTapFilter(pref_a_P2, pref_a_P1, iref_width*2, iref_height*2);		ThreeTapFilter(pcurr_a_P2, pcurr_a_P1, icurr_width*2, icurr_height*2);	}		Int ifilter_offset = 		icurr_width * (EXPANDY_REF_FRAME>>2) + (EXPANDY_REF_FRAME>>2);	pcurr_P2 += ifilter_offset;	pref_P2 += ifilter_offset;	if(m_volmd.fAUsage != RECTANGLE){		pcurr_a_P2 += ifilter_offset;		pref_a_P2 += ifilter_offset;	}	ifilter_offset = 		(icurr_width<<1) * (EXPANDY_REF_FRAME>>1) + (EXPANDY_REF_FRAME>>1);	pcurr_P1 += ifilter_offset;	pref_P1 += ifilter_offset;	if(m_volmd.fAUsage != RECTANGLE){		pcurr_a_P1 += ifilter_offset;		pref_a_P1 += ifilter_offset;	}	ifilter_offset = 		(icurr_width<<2) * EXPANDY_REF_FRAME + EXPANDY_REF_FRAME;	pcurr_P0 += ifilter_offset;	pref_P0 += ifilter_offset;	if(m_volmd.fAUsage != RECTANGLE){		pcurr_a_P0 += ifilter_offset;		pref_a_P0 += ifilter_offset;	}		for(xi = 0; xi < 4; xi++)		dm[xi] = 0;	for(xi = 0; xi < 4; xi++)		dTM[xi] = 0;	dTM[0]=1.0;		pref_work = pref_P2;	pcurr_work = pcurr_P2;	if(m_volmd.fAUsage != RECTANGLE){		pref_alpha_work = pref_a_P2;		pcurr_alpha_work = pcurr_a_P2;	}		ibest_locationx = 0;	ibest_locationy = 0;		if(pvopref -> fAUsage () == RECTANGLE){		ModifiedThreeStepSearch(pref_work, pcurr_work, 			icurr_width, icurr_height, iref_width, iref_height,			icurr_left, icurr_top, icurr_right, icurr_bottom,			iref_left, iref_top, iref_right, iref_bottom,			&ibest_locationx, &ibest_locationy); 	}else{		ModifiedThreeStepSearch_WithShape(pref_work, pcurr_work, 			pref_alpha_work, pcurr_alpha_work,			icurr_width, icurr_height, iref_width, iref_height,			icurr_left, icurr_top, icurr_right, icurr_bottom,			iref_left, iref_top, iref_right, iref_bottom,			&ibest_locationx, &ibest_locationy); 	}		dTM[2] = (Double)ibest_locationx;	dTM[3] = (Double)ibest_locationy;	ithreshold_T = 1000000;		for(ilevel = 2; ilevel >= 0; ilevel--){				if(ilevel == 0){			pref_work = pref_P0;			pcurr_work = pcurr_P0;		}else if(ilevel ==1){			pref_work = pref_P1;			pcurr_work = pcurr_P1;		}		if(m_volmd.fAUsage != RECTANGLE){			if(ilevel == 0){				pref_alpha_work = pref_a_P0;				pcurr_alpha_work = pcurr_a_P0;			}else if(ilevel ==1){				pref_alpha_work = pref_a_P1;				pcurr_alpha_work = pcurr_a_P1;			}		}		icurr_offset = icurr_width - icurr_right + icurr_left;				for(xi=0;xi<256;xi++)			iperror_histgram[xi]=0;				for(iite = 0; iite < 32; iite++){						dE2 = 0.;			istop = 0;			icurr_pel = 0;						for(xi = 0; xi < 16; xi++)				dA[xi] = 0;			for(xi = 0; xi < 4; xi++)				db[xi] = 0;						icurr_pel = icurr_width*icurr_top + icurr_left;			if(pvopref -> fAUsage () == RECTANGLE){								for(y=icurr_top; y<icurr_bottom; y++) {					dy = (Double)y;					for(x=icurr_left; x<icurr_right; x++, icurr_pel++) {												dx = (Double)x;												dt = dTM[0] * dx + dTM[1] * dy + dTM[2];						du = -dTM[1] * dx + dTM[0] * dy + dTM[3];						dx1 = dt;						dy1 = du;						x1 = (Int) dx1;						y1 = (Int) dy1;						if(x1>iref_left && (x1+1)<iref_right && y1>iref_top && (y1+1)<iref_bottom) {							iref_pel = x1 + iref_width * y1;							iref_pel1 = x1+1 + iref_width * y1;							iref_pel2 = x1 + iref_width * (y1+1);							iref_pel3 = x1+1 + iref_width * (y1+1);							istop++;							dk = dx1 - x1;							d1mk = 1. - dk;							dl = dy1 - y1;							d1ml = 1. -dl;							dI1x1y1[0] = pref_work[iref_pel];							dI1x1y1[1] = pref_work[iref_pel1];							dI1x1y1[2] = pref_work[iref_pel2];							dI1x1y1[3] = pref_work[iref_pel3];							dI1 = d1mk*d1ml*dI1x1y1[0] + dk*d1ml*dI1x1y1[1] +								d1mk*dl*dI1x1y1[2] + dk*dl*dI1x1y1[3];							de = dI1 - pcurr_work[icurr_pel];							if(iite==0)								iperror_histgram[(Int)(fabs(de))]++;							if(fabs(de) < ithreshold_T) {								dI1dx = (dI1x1y1[1]-dI1x1y1[0])*d1ml + (dI1x1y1[3]-dI1x1y1[2])*dl;								dI1dy = (dI1x1y1[2]-dI1x1y1[0])*d1mk + (dI1x1y1[3]-dI1x1y1[1])*dk;								ddedm[0] = dx * dI1dx + dy * dI1dy;								ddedm[1] = dy * dI1dx - dx * dI1dy;								ddedm[2] = dI1dx;								ddedm[3] = dI1dy;								db[0] += -de*ddedm[0];								db[1] += -de*ddedm[1];								db[2] += -de*ddedm[2];								db[3] += -de*ddedm[3];								for(yj=0; yj<4; yj++)									for(xi=0; xi<=yj; xi++)										dA[yj*4+xi] += ddedm[yj] * ddedm[xi];									dE2 += de*de;							} // threshold						} // limit of ref_luma area											} // x					icurr_pel += icurr_offset;				} // y							}else{								for(y=icurr_top; y<icurr_bottom; y++) {					dy = (Double)y;					for(x=icurr_left; x<icurr_right; x++, icurr_pel++) {												if(pcurr_alpha_work[icurr_pel]) {							dx = (Double)x;														dt = dTM[0] * dx + dTM[1] * dy + dTM[2];							du = -dTM[1] * dx + dTM[0] * dy + dTM[3];							dx1 = dt;							dy1 = du;							x1 = (Int) dx1;							y1 = (Int) dy1;							if(x1>iref_left && (x1+1)<iref_right && y1>iref_top && (y1+1)<iref_bottom) {								iref_pel = x1 + iref_width * y1;								iref_pel1 = x1+1 + iref_width * y1;								iref_pel2 = x1 + iref_width * (y1+1);								iref_pel3 = x1+1 + iref_width * (y1+1);								if(pref_alpha_work[iref_pel] && pref_alpha_work[iref_pel1] &&									pref_alpha_work[iref_pel2] && pref_alpha_work[iref_pel3]) {									istop++;									dk = dx1 - x1;									d1mk = 1. - dk;									dl = dy1 - y1;									d1ml = 1. -dl;									dI1x1y1[0] = pref_work[iref_pel];									dI1x1y1[1] = pref_work[iref_pel1];									dI1x1y1[2] = pref_work[iref_pel2];									dI1x1y1[3] = pref_work[iref_pel3];									dI1 = d1mk*d1ml*dI1x1y1[0] + dk*d1ml*dI1x1y1[1] +

⌨️ 快捷键说明

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