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

📄 sys_encoder_gme_for_iso.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 4 页
字号:
									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;										ddedm[1] = dy * dI1dx;										ddedm[2] = dI1dx;										ddedm[3] = dx * dI1dy;										ddedm[4] = dy * dI1dy;										ddedm[5] = dI1dy;										db[0] += -de*ddedm[0];										db[1] += -de*ddedm[1];										db[2] += -de*ddedm[2];										db[3] += -de*ddedm[3];										db[4] += -de*ddedm[4];										db[5] += -de*ddedm[5];										for(yj=0; yj<6; yj++)											for(xi=0; xi<=yj; xi++)												dA[yj*6+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; 					}				}			}						for(yj=0; yj<5; yj++)				for(xi=yj+1; xi<6; xi++)					dA[yj*6+xi] = dA[xi*6+yj];							icheck = DeltaMP(dA, 6, db, dm);						if(icheck){ 				for(xi=0; xi<6; xi++)					dTM[xi] += dm[xi];								if(fabs(dm[2]) < 0.001 && fabs(dm[5]) < 0.001 && fabs(dm[0]) < 0.00001 &&					fabs(dm[1]) < 0.00001 && fabs(dm[3]) < 0.00001 && 					fabs(dm[4]) < 0.00001 ) break;			}else {				// printf("not up to matrix\n");				break;			}						} // iteration		if(ilevel){			dTM[2] *= 2;			dTM[5] *= 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 = dTM[0];	pparameter -> dp2 = dTM[1];	pparameter -> dp3 = dTM[2];	pparameter -> dp4 = dTM[3];	pparameter -> dp5 = dTM[4];	pparameter -> dp6 = dTM[5];	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::ModifiedThreeStepSearch(PixelC *pref_work, 												  PixelC *pcurr_work, 												  Int icurr_width, Int icurr_height, Int iref_width, Int iref_height,												  Int icurr_left, Int icurr_top, Int icurr_right, Int icurr_bottom,												  Int iref_left, Int iref_top, Int iref_right, Int iref_bottom,												  Int *ibest_locationx, Int *ibest_locationy) {		Int xi,yj, irange, ilocationx, ilocationy, ino_of_pel=0;	Int icurr_pel, iref_pel, iref_x, iref_y;	Int irange_locationx=0, irange_locationy=0;	Double dE1 = 0, dmin_error=300;	Int icurr_offsety;		icurr_offsety = icurr_width - icurr_right + icurr_left;		for (irange = 4; irange >=1 ; irange/=2) {		irange_locationx=*ibest_locationx;		irange_locationy=*ibest_locationy;		for (ilocationy = irange_locationy-irange; ilocationy <= irange_locationy+irange; 		ilocationy += irange) {			for (ilocationx = irange_locationx-irange; ilocationx <= irange_locationx+irange; 			ilocationx += irange) {				dE1 = 0.0;				ino_of_pel = 0;				icurr_pel = icurr_left + icurr_top*icurr_width;				for (yj = icurr_top; yj< icurr_bottom ; yj++) {					for (xi = icurr_left; xi< icurr_right ; xi++, icurr_pel++) {												iref_x = ilocationx + xi;						iref_y = ilocationy + yj;						iref_pel = iref_y * iref_width + iref_x;												if ((iref_x >=  iref_left) && (iref_x < iref_right) &&							(iref_y >=  iref_top) && (iref_y < iref_bottom)){ 														dE1 += Double(abs((Int)pcurr_work[icurr_pel] - (Int)pref_work[iref_pel]));							ino_of_pel ++;													} // limit of ref value					} // i					icurr_pel += icurr_offsety;				} // j								if (ino_of_pel > 0)					dE1 = dE1 / ino_of_pel;				else					dE1 = dmin_error;				if ((dE1 < dmin_error) || (dE1 == dmin_error && (abs(*ibest_locationx) + 					abs(*ibest_locationy)) > (abs(ilocationx) + abs(ilocationy)))) {					dmin_error = dE1;					*ibest_locationx = ilocationx;					*ibest_locationy = ilocationy;				}							} // locationx		} // locationy	} // range	}Void CVideoObjectEncoder::ModifiedThreeStepSearch_WithShape(PixelC *pref_work, 															PixelC *pcurr_work, 															PixelC *pref_alpha_work, PixelC *pcurr_alpha_work,															Int icurr_width, Int icurr_height, Int iref_width, Int iref_height,															Int icurr_left, Int icurr_top, Int icurr_right, Int icurr_bottom,															Int iref_left, Int iref_top, Int iref_right, Int iref_bottom,															Int *ibest_locationx, Int *ibest_locationy) {		Int xi,yj, irange, ilocationx, ilocationy, ino_of_pel=0;	Int icurr_pel, iref_pel, iref_x, iref_y;	Int irange_locationx=0, irange_locationy=0;	Double dE1 = 0, dmin_error=300;	Int icurr_offsety;		icurr_offsety = icurr_width - icurr_right + icurr_left;		for (irange = 4; irange >=1 ; irange/=2) {		irange_locationx=*ibest_locationx;		irange_locationy=*ibest_locationy;		for (ilocationy = irange_locationy-irange; ilocationy <= irange_locationy+irange; 		ilocationy += irange) {			for (ilocationx = irange_locationx-irange; ilocationx <= irange_locationx+irange; 			ilocationx += irange) {				dE1 = 0.0;				ino_of_pel = 0;				icurr_pel = icurr_left + icurr_top*icurr_width;				for (yj = icurr_top; yj< icurr_bottom ; yj++) {					for (xi = icurr_left; xi< icurr_right ; xi++, icurr_pel++) {												if (pcurr_alpha_work[icurr_pel]) {  														iref_x = ilocationx + xi;							iref_y = ilocationy + yj;							iref_pel = iref_y * iref_width + iref_x;														if ((iref_x >=  iref_left) && (iref_x < iref_right) &&								(iref_y >=  iref_top) && (iref_y < iref_bottom) &&								pref_alpha_work[iref_pel]) {																dE1 += Double(abs((Int)pcurr_work[icurr_pel] - (Int)pref_work[iref_pel]));								ino_of_pel ++;															} // limit of ref area						} // limit of curr_alpha value					} // i					icurr_pel += icurr_offsety;				} // j								if (ino_of_pel > 0)					dE1 = dE1 / ino_of_pel;				else					dE1 = dmin_error;				if ((dE1 < dmin_error) || (dE1 == dmin_error && (abs(*ibest_locationx) + 					abs(*ibest_locationy)) > (abs(ilocationx) + abs(ilocationy)))) {					dmin_error = dE1;					*ibest_locationx = ilocationx;					*ibest_locationy = ilocationy;				}							} // locationx		} // locationy/	} // range	}Void CVideoObjectEncoder::ThreeTapFilter(PixelC *pLow, PixelC *pHight, Int iwidth,										 Int iheight){	Int xi, yj, ihwidth = iwidth/2, iwwidth = iwidth*2, iwidth2 = iwidth+2;	PixelC *plt, *pct, *prt,		*plc, *pcc, *prc,		*plb, *pcb, *prb, *pp;		pp=pLow; plt=pHight; pct=pHight; prt=pHight+1;	plc=pHight; pcc=pHight; prc=pHight+1;	plb=plc+iwidth; pcb=pcc+iwidth; prb=prc+iwidth;	*pp = (PixelC)(((UInt)(*plt) + (((UInt)(*pct))<<1) + (UInt)(*prt) +		(((UInt)(*plc))<<1) + (((UInt)(*pcc))<<2) + (((UInt)(*prc))<<1) +		(UInt)(*plb) + (((UInt)(*pcb))<<1) + (UInt)(*prb) + 8) >> 4);		pp=pLow+1; plt=pHight+1; pct=pHight+2; prt=pHight+3;	plc=pHight+1; pcc=pHight+2; prc=pHight+3;	plb=plc+iwidth; pcb=pcc+iwidth; prb=prc+iwidth;	for(xi=1; xi<iwidth/2-1; xi++, pp++, plt+=2, pct+=2, prt+=2,		plc+=2, pcc+=2, prc+=2,		plb+=2, pcb+=2, prb+=2)		*pp = (PixelC)(((UInt)(*plt) + (((UInt)(*pct))<<1) + (UInt)(*prt) +		(((UInt)(*plc))<<1) + (((UInt)(*pcc))<<2) + (((UInt)(*prc))<<1) +		(UInt)(*plb) + (((UInt)(*pcb))<<1) + (UInt)(*prb) + 8) >> 4);		pp=pLow+ihwidth; plt=pHight+iwidth; pct=pHight+iwidth; prt=pHight+iwidth+1;	plc=plt+iwidth; pcc=pct+iwidth; prc=prt+iwidth;	plb=plc+iwidth; pcb=pcc+iwidth; prb=prc+iwidth;	for(xi=1; xi<iheight/2-1; xi++, pp+=ihwidth, plt+=iwwidth, pct+=iwwidth, prt+=iwwidth,		plc+=iwwidth, pcc+=iwwidth, prc+=iwwidth,		plb+=iwwidth, pcb+=iwwidth, prb+=iwwidth)		*pp = (PixelC)(((UInt)(*plt) + (((UInt)(*pct))<<1) + (UInt)(*prt) +		(((UInt)(*plc))<<1) + (((UInt)(*pcc))<<2) + (((UInt)(*prc))<<1) +		(UInt)(*plb) + (((UInt)(*pcb))<<1) + (UInt)(*prb) + 8) >> 4);		pp=pLow+ihwidth+1; plt=pHight+1; pct=pHight+2; prt=pHight+3;	plc=plt+iwidth; pcc=pct+iwidth; prc=prt+iwidth;	plb=plc+iwidth; pcb=pcc+iwidth; prb=prc+iwidth;	for(yj=1; yj<iheight/2-2; yj++, pp++, plt+=iwidth2, pct+=iwidth2, prt+=iwidth2,		plc+=iwidth2, pcc+=iwidth2, prc+=iwidth2,		plb+=iwidth2, pcb+=iwidth2, prb+=iwidth2)		for(xi=1; xi<ihwidth; xi++, pp++, plt+=2, pct+=2, prt+=2,			plc+=2, pcc+=2, prc+=2,			plb+=2, pcb+=2, prb+=2)		{			*pp = (PixelC)(((UInt)(*plt) + (((UInt)(*pct))<<1) + (UInt)(*prt) +				(((UInt)(*plc))<<1) + (((UInt)(*pcc))<<2) + (((UInt)(*prc))<<1) +				(UInt)(*plb) + (((UInt)(*pcb))<<1) + (UInt)(*prb) + 8) >> 4);		}		}Int CVideoObjectEncoder::DeltaMP(Double *dA, Int in, Double *db, Double *dm){	int xi, yj, xi2, in2=in*2, ik, i_pivot;	Double *dAi = new Double [in * in * 2];	Double dpivot, dtmp;		dpivot = *dA;	for(yj = 0; yj < in; yj++)		for(xi = 0; xi < in; xi++)			if(fabs(*(dA + yj * in + xi)) > fabs(dpivot))				dpivot = *(dA + yj * in + xi);				if(fabs(dpivot) < 0.000000001) {		delete [] dAi; dAi= NULL;		return(0);	}	dpivot = 1.0 / dpivot; 		for(yj = 0; yj < in; yj++)		for(xi = 0, xi2 = in; xi < in; xi++, xi2++){			*(dAi + yj * in2 + xi) = (*(dA + yj * in + xi))*dpivot;			if(xi == yj)				*(dAi + yj * in2 + xi2) = dpivot;			else				*(dAi + yj * in2 + xi2) = 0.0;		}			for(xi = 0; xi < in; xi++) {				i_pivot = xi;		dpivot = *(dAi + xi * in2 + xi);		for(yj = xi; yj < in; yj++)			if(fabs(*(dAi + yj * in2 + xi)) > fabs(dpivot))			{				i_pivot = yj;				dpivot = *(dAi + yj * in2 + xi);			}			if(fabs(dpivot) < 0.000000001) {				delete [] dAi; dAi = NULL;				return(0);			}			if(i_pivot!=xi)				for(ik = 0; ik < in2; ik++) {					dtmp = *(dAi + xi * in2 + ik);					*(dAi + xi * in2 + ik) = *(dAi + i_pivot * in2 + ik);					*(dAi + i_pivot * in2 + ik) = dtmp;				}								for(yj = 0; yj < in; yj++) {					if(yj != xi)					{						dpivot = *(dAi + yj * in2 + xi) / *(dAi + xi * in2 + xi);						for(ik = xi+1; ik < in2; ik++)							*(dAi + yj * in2 + ik) -=							dpivot*(*(dAi + xi * in2 + ik));					}				}					}		for(yj = 0; yj < in; yj++)		for(xi = 0, xi2 = in; xi < in; xi++, xi2++)			*(dAi + yj * in2 + xi2) /= *(dAi + yj * in2 + yj);			for(xi = 0; xi < in; xi++)		*(dm + xi) = 0.0;		for(yj = 0; yj < in; yj++)		for(xi = 0, xi2 = in; xi < in; xi++, xi2++)			*(dm + yj) += (*(dAi + yj * in2 +xi2))*(*(db + xi));			delete [] dAi; dAi = NULL;	return(1);}

⌨️ 快捷键说明

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