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

📄 errenc.cpp

📁 完整的RTP RTSP代码库
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	Int iQPPrev = m_vopmd.intStepI;	//initialization	PixelC* ppxlcRefY  = (PixelC*) m_pvopcRefQ1->pixelsY () + m_iStartInRefToCurrRctY;	PixelC* ppxlcRefU  = (PixelC*) m_pvopcRefQ1->pixelsU () + m_iStartInRefToCurrRctUV;	PixelC* ppxlcRefV  = (PixelC*) m_pvopcRefQ1->pixelsV () + m_iStartInRefToCurrRctUV;		PixelC* ppxlcOrigY = (PixelC*) m_pvopcOrig->pixelsBoundY ();	PixelC* ppxlcOrigU = (PixelC*) m_pvopcOrig->pixelsBoundU ();	PixelC* ppxlcOrigV = (PixelC*) m_pvopcOrig->pixelsBoundV ();	Int iMBX, iMBY, iMB = 0;    Int iCurrMBPos;	Int iVideoPacketNumber	= 0;	Int iVPCounter = m_statsVOP.total();	Int iVPtotal;	m_iVPMBnum = 0;	CStatistics m_statsVP(0);	// DCT coefficient buffer for Data Partitioning mode	Int*** iCoefQ_DP = new Int** [m_iNumMB];	// Set not to output but count bitstream	m_pbitstrmOut->SetDontSendBits(TRUE);	Bool bRestartDelayedQP = TRUE;	for (iMBY = 0; iMBY < m_iNumMBY; iMBY++) {		PixelC* ppxlcRefMBY  = ppxlcRefY;		PixelC* ppxlcRefMBU  = ppxlcRefU;		PixelC* ppxlcRefMBV  = ppxlcRefV;		PixelC* ppxlcOrigMBY = ppxlcOrigY;		PixelC* ppxlcOrigMBU = ppxlcOrigU;		PixelC* ppxlcOrigMBV = ppxlcOrigV;		for (iMBX = 0; iMBX < m_iNumMBX; iMBX++, iMB++) {#ifdef __TRACE_AND_STATS_			m_pbitstrmOut->trace (CSite (iMBX, iMBY), "MB_X_Y");#endif // __TRACE_AND_STATS_			m_statsMB.reset ();			pmbmd->m_bFieldMV = 0;			pmbmd->m_dctMd = INTRA;			pmbmd->m_bSkip = FALSE;			//reset for direct mode			pmbmd->m_bMCSEL = FALSE;			//reset for direct mode			pmbmd->m_iVideoPacketNumber	= iVideoPacketNumber;			copyToCurrBuff (ppxlcOrigMBY, ppxlcOrigMBU, ppxlcOrigMBV, m_iFrameWidthY, m_iFrameWidthUV); 			if(m_vopmd.RRVmode.iRRVOnOff == 1)			{				DownSamplingTextureForRRV(m_ppxlcCurrMBY,										  m_ppxlcCurrMBY,										  (MB_SIZE *m_iRRVScale),										  (MB_SIZE *m_iRRVScale));			    DownSamplingTextureForRRV(m_ppxlcCurrMBU,										  m_ppxlcCurrMBU,										  (BLOCK_SIZE* m_iRRVScale),										  (BLOCK_SIZE* m_iRRVScale));			    DownSamplingTextureForRRV(m_ppxlcCurrMBV,										  m_ppxlcCurrMBV,										  (BLOCK_SIZE* m_iRRVScale),										  (BLOCK_SIZE* m_iRRVScale));			}			// MB level rate control section			// here is where we calculate the delta QP			if (m_uiRateControl>=RC_TM5) {				// TM5 rate control				updateQP(pmbmd, iQPPrev, m_tm5rc.tm5rc_calc_mquant(iMB, m_statsVOP.total())	);			}			else			{#ifdef _MBQP_CHANGE_				Int iDQuant = (rand() % 5) - 2;				updateQP(pmbmd, iQPPrev, iQPPrev + iDQuant);#else				// no change in step size, but still need to call...				updateQP(pmbmd, iQPPrev, iQPPrev);#endif //_MBQP_CHANGE_			}			// call this since we know new qp for certain			setDCVLCMode(pmbmd, &bRestartDelayedQP);			quantizeTextureIntraMB (iMBX, iMBY, pmbmd, ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, NULL);			if(m_vopmd.RRVmode.iRRVOnOff == 1)			{			    UpSamplingTextureForRRV(ppxlcRefMBY, ppxlcRefMBY,										MB_SIZE, MB_SIZE,										m_iFrameWidthY);			    UpSamplingTextureForRRV(ppxlcRefMBU, ppxlcRefMBU,										BLOCK_SIZE, BLOCK_SIZE,										m_iFrameWidthUV);			    UpSamplingTextureForRRV(ppxlcRefMBV, ppxlcRefMBV,										BLOCK_SIZE, BLOCK_SIZE,										m_iFrameWidthUV);			}			codeMBTextureHeadOfIVOP (pmbmd);			sendDCTCoefOfIntraMBTexture (pmbmd);			Int iVPlastMBnum = iMBY * m_iNumMBX + iMBX;			// copy DCT coefficient to buffer			iCoefQ_DP[iVPlastMBnum] = new Int* [6];			Int iBlk;			for (iBlk = 0; iBlk < 6; iBlk++) {				iCoefQ_DP [iVPlastMBnum] [iBlk] = new Int [BLOCK_SQUARE_SIZE];				for( Int t = 0; t < BLOCK_SQUARE_SIZE; t++ )					iCoefQ_DP[iVPlastMBnum][iBlk][t] = m_rgpiCoefQ[iBlk][t];			}			// update qp			iQPPrev = pmbmd->m_stepSize;			pmbmd++;#ifdef __TRACE_AND_STATS_			m_statsVOP   += m_statsMB;#endif // __TRACE_AND_STATS_			ppxlcRefMBY  += (MB_SIZE *m_iRRVScale);			ppxlcRefMBU  += (BLOCK_SIZE *m_iRRVScale);			ppxlcRefMBV  += (BLOCK_SIZE *m_iRRVScale);			ppxlcOrigMBY += (MB_SIZE *m_iRRVScale);			ppxlcOrigMBU += (BLOCK_SIZE *m_iRRVScale);			ppxlcOrigMBV += (BLOCK_SIZE *m_iRRVScale);			iVPtotal = (int) m_statsVOP.total() - iVPCounter;			iCurrMBPos	= (m_iRRVScale == 2) ? (2 *iMBX +1 +(2 *iMBY +1) *(2 *m_iNumMBX)) : ((iMBY *m_iNumMBX) +iMBX);			if( (m_volmd.bNewpredEnable && m_volmd.bNewpredSegmentType == 0) ?				( iCurrMBPos == g_pNewPredEnc->SliceTailMBA((iMBX*m_iRRVScale), (iMBY*m_iRRVScale)) )				: ( iVPtotal > m_volmd.bVPBitTh || iVPlastMBnum == m_iNumMB-1) )			{				// Set to output bitstream				m_pbitstrmOut->SetDontSendBits(FALSE);				// encode video packet				iVPCounter = m_statsVOP.total();				m_statsVP.reset();// RRV_2 insertion				iVideoPacketNumber ++;// ~RRV_2				if( m_iVPMBnum > 0 )				{					m_statsVP.nBitsHead 						= codeVideoPacketHeader (m_rgmbmd[m_iVPMBnum].m_stepSize - m_rgmbmd[m_iVPMBnum].m_intStepDelta);					//printf("VP");				}				// needs to be set even if we dont code the first vp because we are currently				// encoding after the second vp				bRestartDelayedQP = TRUE;				DataPartitioningMotionCoding(m_iVPMBnum, iVPlastMBnum, &m_statsVP, iCoefQ_DP);				m_pbitstrmOut -> putBits (DC_MARKER, NUMBITS_DP_DC_MARKER, "DC_marker");				m_statsVP.nBitsHead += NUMBITS_DP_DC_MARKER;				DataPartitioningTextureCoding(m_iVPMBnum, iVPlastMBnum, &m_statsVP, iCoefQ_DP);				//assert( iVPtotal + m_statsVP.nBitsHead == (int) m_statsVP.total() );				m_iVPMBnum = iVPlastMBnum + 1;				// Set not to output but count bitstream				m_pbitstrmOut->SetDontSendBits(TRUE);			}		}				MacroBlockMemory** ppmbmTemp = m_rgpmbmAbove;		m_rgpmbmAbove = m_rgpmbmCurr;		m_rgpmbmCurr  = ppmbmTemp;		ppxlcRefY  += m_iFrameWidthYxMBSize;		ppxlcRefU  += m_iFrameWidthUVxBlkSize;		ppxlcRefV  += m_iFrameWidthUVxBlkSize;				ppxlcOrigY += m_iFrameWidthYxMBSize;		ppxlcOrigU += m_iFrameWidthUVxBlkSize;		ppxlcOrigV += m_iFrameWidthUVxBlkSize;	}// RRV insertion	if(m_vopmd.RRVmode.iRRVOnOff == 1)	{          ppxlcRefY	= (PixelC*) m_pvopcRefQ1->pixelsY () 			  + m_iStartInRefToCurrRctY;          ppxlcRefU = (PixelC*) m_pvopcRefQ1->pixelsU ()			  + m_iStartInRefToCurrRctUV;          ppxlcRefV = (PixelC*) m_pvopcRefQ1->pixelsV ()			  + m_iStartInRefToCurrRctUV;          filterCodedPictureForRRV(ppxlcRefY, ppxlcRefU, ppxlcRefV,								   m_ivolWidth, m_ivolHeight,								   m_iNumMBX,								   m_iNumMBY,								   m_iFrameWidthY, m_iFrameWidthUV);      }// ~RRV	// delete CoefQ_DP	for(iMB = 0; iMB < m_iNumMB; iMB++ )  {		for (Int iBlk = 0; iBlk < 6; iBlk++) {			delete [] iCoefQ_DP [iMB] [iBlk];		}		delete [] iCoefQ_DP[iMB];	}	delete [] iCoefQ_DP;	// Set to output bitstream	m_pbitstrmOut->SetDontSendBits(FALSE);}Void CVideoObjectEncoder::encodeNSForPVOP_DP ()	{	assert( m_volmd.bDataPartitioning );	assert( m_vopmd.vopPredType==PVOP || (m_uiSprite == 2 && m_vopmd.vopPredType==SPRITE) ); // GMC	//assert(m_volmd.nBits==8);// RRV insertion//	CMotionVector pmv_RRV[m_iNumMB *PVOP_MV_PER_REF_PER_MB];	CMotionVector *pmv_RRV	= new CMotionVector[m_iNumMB *PVOP_MV_PER_REF_PER_MB];// ~RRV	if (m_uiSprite == 0 || m_uiSprite == 2) // GMC			motionEstPVOP ();// RRV insertion	if(m_vopmd.RRVmode.iRRVOnOff == 1)	{		for(Int i = 0; i < (m_iNumMB *PVOP_MV_PER_REF_PER_MB); i ++)		{			pmv_RRV[i]	= m_rgmv[i];		}		MotionVectorScalingUp(pmv_RRV, m_iNumMB, PVOP_MV_PER_REF_PER_MB);		for(Int j = 0; j < (m_iNumMB *PVOP_MV_PER_REF_PER_MB); j ++)		{			m_rgmv[j].m_vctTrueHalfPel_x2.x	= pmv_RRV[j].m_vctTrueHalfPel.x;			m_rgmv[j].m_vctTrueHalfPel_x2.y = pmv_RRV[j].m_vctTrueHalfPel.y;			pmv_RRV[j].m_vctTrueHalfPel_x2.x= pmv_RRV[j].m_vctTrueHalfPel.x;			pmv_RRV[j].m_vctTrueHalfPel_x2.y= pmv_RRV[j].m_vctTrueHalfPel.y;		}	}// ~RRV// RRV_2 insertion	Int iVideoPacketNumber	= 0;// ~RRV_2		UInt newQStep = m_vopmd.intStep; // for frame based rate control	// vopmd.intStep is updated at bottom of this function	// Rate Control	if (m_uiRateControl==RC_MPEG4) {		Double Ec = m_iMAD / (Double) (m_iNumMBY * m_iNumMBX * 16 * 16 * m_iRRVScale *m_iRRVScale);		m_statRC.setMad (Ec);		// calculate for next frame (should be this frame, but its too late to send vop qp!)		newQStep = m_statRC.updateQuanStepsize (m_vopmd.intStep);		// this is not the correct way to use rate control		m_statRC.setQc (m_vopmd.intStep);	}	Int iMBX, iMBY;// RRV insertion    Int iCurrMBPos;// ~RRV		CoordI y = 0; 	CMBMode* pmbmd = m_rgmbmd;	Int iQPPrev = m_vopmd.intStep;	CMotionVector* pmv = m_rgmv;// RRV insertion	CMotionVector* plmv_RRV = pmv_RRV;// ~RRV	PixelC* ppxlcRefY = (PixelC*) m_pvopcRefQ1->pixelsY () + m_iStartInRefToCurrRctY;	PixelC* ppxlcRefU = (PixelC*) m_pvopcRefQ1->pixelsU () + m_iStartInRefToCurrRctUV;	PixelC* ppxlcRefV = (PixelC*) m_pvopcRefQ1->pixelsV () + m_iStartInRefToCurrRctUV;		PixelC* ppxlcOrigY = (PixelC*) m_pvopcOrig->pixelsBoundY ();	PixelC* ppxlcOrigU = (PixelC*) m_pvopcOrig->pixelsBoundU ();	PixelC* ppxlcOrigV = (PixelC*) m_pvopcOrig->pixelsBoundV ();		// NEWPRED	const PixelC* RefbufY = (PixelC*)m_pvopcRefQ0-> pixelsY ();	const PixelC* RefbufU = (PixelC*)m_pvopcRefQ0-> pixelsU ();	const PixelC* RefbufV = (PixelC*)m_pvopcRefQ0-> pixelsV ();	if (m_volmd.bNewpredEnable) {		g_pNewPredEnc->CopyReftoBuf(RefbufY, RefbufU, RefbufV, m_rctRefFrameY, m_rctRefFrameUV);		for (iMBY = 0; iMBY < m_iNumMBY; iMBY++) {			for (iMBX = 0; iMBX < m_iNumMBX; iMBX++)	{// RRV modification				(pmbmd + iMBX + m_iNumMBX*iMBY) -> m_iNPSegmentNumber = g_pNewPredEnc->GetSliceNum((iMBX *m_iRRVScale),(iMBY *m_iRRVScale));//				(pmbmd + iMBX + m_iNumMBX*iMBY) -> m_iNPSegmentNumber = g_pNewPredEnc->GetSliceNum(iMBX,iMBY);// ~RRV			}		}	}// ~NEWPRED		Int iVPCounter = m_statsVOP.total();	Int iVPtotal;	m_iVPMBnum = 0;	CStatistics m_statsVP(0);	// DCT coefficient buffer for Data Partitioning mode	Int*** iCoefQ_DP = new Int** [m_iNumMB];	// Set not to output but count bitstream	m_pbitstrmOut->SetDontSendBits(TRUE);	Bool bRestartDelayedQP = TRUE;	Int iMB = 0;// RRV modification	for (iMBY = 0; iMBY < m_iNumMBY; iMBY++, y += (MB_SIZE *m_iRRVScale)) {//	for (iMBY = 0; iMBY < m_iNumMBY; iMBY++, y += MB_SIZE) {// ~RRV		PixelC* ppxlcRefMBY = ppxlcRefY;		PixelC* ppxlcRefMBU = ppxlcRefU;		PixelC* ppxlcRefMBV = ppxlcRefV;		PixelC* ppxlcOrigMBY = ppxlcOrigY;		PixelC* ppxlcOrigMBU = ppxlcOrigU;		PixelC* ppxlcOrigMBV = ppxlcOrigV;		CoordI x = 0; 		for (iMBX = 0; iMBX < m_iNumMBX; iMBX++, x += (MB_SIZE *m_iRRVScale), iMB++)		{			if((m_volmd.bNewpredEnable) && g_pNewPredEnc->CheckSlice((iMBX *m_iRRVScale),(iMBY *m_iRRVScale))){				PixelC* RefpointY = (PixelC*) m_pvopcRefQ0->pixelsY () + m_iStartInRefToCurrRctY + iMBY * (MB_SIZE *m_iRRVScale) * m_rctRefFrameY.width;				PixelC* RefpointU = (PixelC*) m_pvopcRefQ0->pixelsU () + m_iStartInRefToCurrRctUV + iMBY * (BLOCK_SIZE *m_iRRVScale) * m_rctRefFrameUV.width;				PixelC* RefpointV = (PixelC*) m_pvopcRefQ0->pixelsV () + m_iStartInRefToCurrRctUV + iMBY * (BLOCK_SIZE *m_iRRVScale) * m_rctRefFrameUV.width;				g_pNewPredEnc->ChangeRefOfSlice((const PixelC* )RefpointY, RefbufY,(const PixelC* ) RefpointU, RefbufU,					(const PixelC* )RefpointV, RefbufV, (iMBX *m_iRRVScale), (iMBY *m_iRRVScale),m_rctRefFrameY, m_rctRefFrameUV);				m_rctRefVOPZoom0 = m_rctRefVOPY0.upSampleBy2 ();				biInterpolateY (m_pvopcRefQ0, m_rctRefVOPY0, m_puciRefQZoom0, m_rctRefVOPZoom0, m_vopmd.iRoundingControl);			}			m_statsMB.reset ();			pmbmd->m_iVideoPacketNumber	= iVideoPacketNumber;			// MB level rate control section			// here is where we calculate the delta QP			if (m_uiRateControl>=RC_TM5) {				// TM5 rate control				updateQP(pmbmd, iQPPrev, m_tm5rc.tm5rc_calc_mquant(iMB, m_statsVOP.total())	);			}			else			{#ifdef _MBQP_CHANGE_				Int iDQuant = (rand() % 5) - 2;				updateQP(pmbmd, iQPPrev, iQPPrev + iDQuant);#else				// no change in step size, but still need to call...				updateQP(pmbmd, iQPPrev, iQPPrev);#endif //_MBQP_CHANGE_			}						copyToCurrBuff (ppxlcOrigMBY, ppxlcOrigMBU, ppxlcOrigMBV, m_iFrameWidthY, m_iFrameWidthUV); 			encodePVOPMB (				ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV,				pmbmd, pmv, plmv_RRV, 				iMBX, iMBY,				x, y, &bRestartDelayedQP			);			Int iVPlastMBnum = iMBY * m_iNumMBX + iMBX;			// copy DCT coefficient to buffer			iCoefQ_DP[iVPlastMBnum] = new Int* [6];			Int iBlk;			for (iBlk = 0; iBlk < 6; iBlk++) {				iCoefQ_DP [iVPlastMBnum] [iBlk] = new Int [BLOCK_SQUARE_SIZE];				for( Int t = 0; t < BLOCK_SQUARE_SIZE; t++ )					iCoefQ_DP[iVPlastMBnum][iBlk][t] = m_rgpiCoefQ[iBlk][t];			}			iQPPrev = pmbmd->m_stepSize;			pmbmd++;			pmv += PVOP_MV_PER_REF_PER_MB;			if (m_vopmd.RRVmode.iRRVOnOff == 1)			{				plmv_RRV	+= PVOP_MV_PER_REF_PER_MB;			}#ifdef __TRACE_AND_STATS_			m_statsVOP += m_statsMB;

⌨️ 快捷键说明

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