📄 mc.cpp
字号:
((pmvRef[0].m_vctTrueHalfPel.y * (iTempRefB - iTempRefD)) / iTempRefD); // This check is redundant since the below condition was already checked above. // *************************************************************************** if (m_volmd.bQuarterSample) { printf("\nCheck me--Cannot enter this if loop, CVideoObject::motionCompDirectMode!!"); exit(0); // mod 991201 mwi for (Int iBlk = 0; iBlk < 4; iBlk++) { motionCompQuarterSample(m_ppxlcPredMBY + iMBOffset[iBlk], m_pvopcRefQ0->pixelsY(), BLOCK_SIZE, x * 4 + iBlkXOffset[iBlk] * 2 + vctFwd.x, y * 4 + iBlkYOffset[iBlk] * 2 + vctFwd.y, m_vopmd.iRoundingControl, prctMVLimitFwd); motionCompQuarterSample(m_ppxlcPredMBBackY + iMBOffset[iBlk] , m_pvopcRefQ1->pixelsY(), BLOCK_SIZE, x * 4 + iBlkXOffset[iBlk] * 2 + vctBak.x, y * 4 + iBlkYOffset[iBlk] * 2 + vctBak.y, m_vopmd.iRoundingControl, prctMVLimitBak); } // ~mod 991201 mwi } // This is a 16x16 Bi-Directional case // *********************************** else { // Y MVs iMVX = vctFwd.x; iMVY = vctFwd.y; g_pMV[0] = g_pMV[1] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // Y MVs iMVX = vctBak.x; iMVY = vctBak.y; g_pMV[2] = g_pMV[2] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); } if (m_volmd.bQuarterSample) { iChromaFwdX = vctFwd.x/2; iChromaFwdY = vctFwd.y/2; iChromaBakX = vctBak.x/2; iChromaBakY = vctBak.y/2; } else { iChromaFwdX = vctFwd.x; iChromaFwdY = vctFwd.y; iChromaBakX = vctBak.x; iChromaBakY = vctBak.y; } xRefUVF = sign (iChromaFwdX) * (grgiMvRound4 [abs (iChromaFwdX) % 4] + (abs (iChromaFwdX) / 4) * 2); yRefUVF = sign (iChromaFwdY) * (grgiMvRound4 [abs (iChromaFwdY) % 4] + (abs (iChromaFwdY) / 4) * 2); xRefUVB = sign (iChromaBakX) * (grgiMvRound4 [abs (iChromaBakX) % 4] + (abs (iChromaBakX) / 4) * 2); yRefUVB = sign (iChromaBakY) * (grgiMvRound4 [abs (iChromaBakY) % 4] + (abs (iChromaBakY) / 4) * 2); } } // begin of new changes 10/21/98 else { // This case will be entered when the MB X & Y positions are not within the range // which is 0 to the maximum number of the X & Y MBs. The only possible path could be // when RRV is enabled (where in the number of MBs will reduce). // *********************************************************************************** printf("\nCheck me--Unhandled case (X & Y pos of MB not in range??), CVideoObject::motionCompDirectMode!!"); exit(0); vctFwd = pmbmd->m_vctDirectDeltaMV; vctBak.x = pmbmd->m_vctDirectDeltaMV.x ? vctFwd.x :0; vctBak.y = pmbmd->m_vctDirectDeltaMV.y ? vctFwd.y :0; if (m_volmd.bQuarterSample) { // Quarter Sample, mwi // mod 991201 mwi for (Int iBlk = 0; iBlk < 4; iBlk++) { motionCompQuarterSample(m_ppxlcPredMBY + iMBOffset[iBlk], m_pvopcRefQ0->pixelsY(), BLOCK_SIZE, x * 4 + iBlkXOffset[iBlk] * 2 + vctFwd.x, y * 4 + iBlkYOffset[iBlk] * 2 + vctFwd.y, m_vopmd.iRoundingControl, prctMVLimitFwd); motionCompQuarterSample(m_ppxlcPredMBBackY + iMBOffset[iBlk], m_pvopcRefQ1->pixelsY(), BLOCK_SIZE, x * 4 + iBlkXOffset[iBlk] * 2 + vctBak.x, y * 4 + iBlkYOffset[iBlk] * 2 + vctBak.y, m_vopmd.iRoundingControl, prctMVLimitBak); } // ~mod 991201 mwi } else { motionComp(m_ppxlcPredMBY, m_pvopcRefQ0->pixelsY(), MB_SIZE, x * 2 + vctFwd.x, y * 2 + vctFwd.y, m_vopmd.iRoundingControl, prctMVLimitFwd); motionComp(m_ppxlcPredMBBackY , m_pvopcRefQ1->pixelsY(), MB_SIZE, x * 2 + vctBak.x, y * 2 + vctBak.y, m_vopmd.iRoundingControl, prctMVLimitBak); } if (m_volmd.bQuarterSample) { // Quarter Sample, mwi iChromaFwdX = vctFwd.x/2; iChromaFwdY = vctFwd.y/2; iChromaBakX = vctBak.x/2; iChromaBakY = vctBak.y/2; } else { iChromaFwdX = vctFwd.x; iChromaFwdY = vctFwd.y; iChromaBakX = vctBak.x; iChromaBakY = vctBak.y; } xRefUVF = sign (iChromaFwdX) * (grgiMvRound4 [abs (iChromaFwdX) % 4] + (abs (iChromaFwdX) / 4) * 2); yRefUVF = sign (iChromaFwdY) * (grgiMvRound4 [abs (iChromaFwdY) % 4] + (abs (iChromaFwdY) / 4) * 2); xRefUVB = sign (iChromaBakX) * (grgiMvRound4 [abs (iChromaBakX) % 4] + (abs (iChromaBakX) / 4) * 2); yRefUVB = sign (iChromaBakY) * (grgiMvRound4 [abs (iChromaBakY) % 4] + (abs (iChromaBakY) / 4) * 2); } // end of new changes 10/21/98 // UV Handling // FWD UV MVs iMVX = xRefUVF; iMVY = yRefUVF; g_pMV[g_UVMVId++] = (iMVX << 16) | (iMVY & 0x0000FFFF); // BWD UV MVs iMVX = xRefUVB; iMVY = yRefUVB; g_pMV[g_UVMVId++] = (iMVX << 16) | (iMVY & 0x0000FFFF); }}Void CVideoObject::motionCompOneBVOPReference( CVOPU8YUVBA *pvopcPred, MBType type, CoordI x, CoordI y, const CMBMode *pmbmd, const CMotionVector *pmv, CRct *prctMVLimit ){ CVOPU8YUVBA *pvopcRef; Int topRef, botRef; CoordI iMVX, iMVY; CoordI iUVMVX, iUVMVY;// HV For Travis PixelC *m_RefY;// ~HV For Travis if (type == BACKWARD) { pvopcRef = m_pvopcRefQ1;// HV For Travis#ifdef ENABLE_INTERLACING if (nFlipToRef == FLIP_TO_REF) { m_RefY = m_OOFFlipQ1_Y; m_ActiveRef = BACKWARD_REFERENCES; } else#endif { m_RefY = (PixelC*) m_pvopcRefQ1->pixelsY(); }// ~HV For Travis topRef = (Int)pmbmd->m_bBackwardTop; botRef = (Int)pmbmd->m_bBackwardBottom; } else { pvopcRef = m_pvopcRefQ0;// HV For Travis#ifdef ENABLE_INTERLACING if (nFlipToRef == FLIP_TO_REF) { m_RefY = m_OOFFlipQ0_Y; m_ActiveRef = FORWARD_REFERENCES; } else#endif { m_RefY = (PixelC*) m_pvopcRefQ0->pixelsY(); }// ~HV For Travis topRef = (Int)pmbmd->m_bForwardTop; botRef = (Int)pmbmd->m_bForwardBottom; } if (pmbmd->m_bFieldMV) { const CMotionVector *pmvTop = pmv + 1 + topRef; const CMotionVector *pmvBot = pmv + 3 + botRef; assert((topRef & ~1) == 0); assert((botRef & ~1) == 0); // Upper Y MVs iMVX = pmvTop->m_vctTrueHalfPel.x; iMVY = pmvTop->m_vctTrueHalfPel.y; // Upper UV MVs iUVMVX = (iMVX & 3) ? ((iMVX >> 1) | 1) : (iMVX >> 1); iUVMVY = (iMVY & 6) ? ((iMVY >> 1) | 2) : (iMVY >> 1); if (g_pHeader2->mbmode == MBMODE_BID_ALL_420) { if (type == FORWARD) { // Y g_pMV[0] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } else if (type == BACKWARD) { // Y g_pMV[2] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } } else // MBM_FORWARD & MBM_BACKWARD cases { // Y g_pMV[0] = g_pMV[1] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } // Upper Y MVs iMVX = pmvBot->m_vctTrueHalfPel.x; iMVY = pmvBot->m_vctTrueHalfPel.y; // Upper UV MVs iUVMVX = (iMVX & 3) ? ((iMVX >> 1) | 1) : (iMVX >> 1); iUVMVY = (iMVY & 6) ? ((iMVY >> 1) | 2) : (iMVY >> 1); if (g_pHeader2->mbmode == MBMODE_BID_ALL_420) { if (type == FORWARD) { // Y g_pMV[1] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } else if (type == BACKWARD) { // Y g_pMV[3] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } } else // MBM_FORWARD & MBM_BACKWARD cases { // Y g_pMV[2] = g_pMV[3] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } } else { // Non-Interlaced MB in an Interlaced frame (m_vopmd.bInterlace is TRUE) but not 16x8 // MBType (since pmbmd->m_bFieldMV is FALSE). So, this should be a 16x6 or 8x8 case // ********************************************************************************** // Y MVs iMVX = TRUEMVHALFPEL_X(pmv); iMVY = TRUEMVHALFPEL_Y(pmv); // Upper UV MVs if (m_volmd.bQuarterSample) { iUVMVX = (pmv->iMVX & 3) ? ((pmv->iMVX >> 1) | 1) : (pmv->iMVX >> 1); iUVMVY = (pmv->iMVY & 3) ? ((pmv->iMVY >> 1) | 1) : (pmv->iMVY >> 1); } else { iUVMVX = (pmv->m_vctTrueHalfPel.x & 3) ? ((pmv->m_vctTrueHalfPel.x >> 1) | 1) : (pmv->m_vctTrueHalfPel.x >> 1); iUVMVY = (pmv->m_vctTrueHalfPel.y & 3) ? ((pmv->m_vctTrueHalfPel.y >> 1) | 1) : (pmv->m_vctTrueHalfPel.y >> 1); } // Handle all 16x16 FWD, BWD & BI cases here if (g_pHeader3->mbtype == MBT_16x16) { if (g_pHeader2->mbmode == MBMODE_BID_ALL_420) { if (type == FORWARD) { // Y g_pMV[0] = g_pMV[1] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } else { // Y g_pMV[2] = g_pMV[2] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } } else { // Y g_pMV[0] = g_pMV[1] = g_pMV[2] = g_pMV[3] = ((iMVX << 16) | (iMVY & 0x0000FFFF)); // UV g_pMV[g_UVMVId++] = (iUVMVX << 16) | (iUVMVY & 0x0000FFFF); } } else { printf("\nOOPS!! Handle me 8x8 MC--CVideoObject::motionCompOneBVOPReference!!"); exit(0); } }}Void CVideoObject::copyFromRefToCurrQ ( const CVOPU8YUVBA* pvopcRef, // reference VOP CoordI x, CoordI y, CRct *prctMVLimit ){ // needs limiting to reference area bounding box LIMITMVRANGETOEXTENDEDBBFULLPEL(&x,&y,prctMVLimit,MB_SIZE); g_pHeader2->mbmode = MBMODE_FWD_ALL_420; g_pHeader3->mbtype = MBT_16x16;}#ifdef ENABLE_INTERLACINGVoid CVideoObject::motionCompYField ( PixelC* ppxlcPred, // can be either Y or A const PixelC* ppxlcRefLeftTop, // point to left-top of the frame CoordI xRef, CoordI yRef, // current coordinate system CRct *prctMVLimit, // added by Y.Suzuki for the extended bounding box support int nMBType, int nBlockNum, const CMotionVector* pmv, int nSkip){ CoordI ix, iy; LIMITMVRANGETOEXTENDEDBBHALFPEL(&xRef, &yRef, prctMVLimit, MB_SIZE); // added by Y.Suzuki for the extended bounding box support const PixelC* ppxlcRef = ppxlcRefLeftTop + (((yRef >> 1) & ~1) + EXPANDY_REF_FRAME) * m_iFrameWidthY + (xRef >> 1) + EXPANDY_REF_FRAME; Int iRound = 1 - m_vopmd.iRoundingControl; Int iFieldStep = 2 * m_iFrameWidthY; const PixelC* ActualRefFrame = ppxlcRef; if (!(yRef & 2)) { if (!(xRef & 1)) { //!bXSubPxl && !bYSubPxl for (iy = 0; iy < MB_SIZE; iy+=2) { memcpy (ppxlcPred, ppxlcRef, MB_SIZE*sizeof(PixelC)); ppxlcRef += iFieldStep; ppxlcPred += MB_SIZE*2; } } else { //bXSubPxl && !bYSubPxl for (iy = 0; iy < MB_SIZE; iy+=2) { for (ix = 0; ix < MB_SIZE; ix++) ppxlcPred [ix] = (ppxlcRef [ix] + ppxlcRef [ix + 1] + iRound) >> 1; ppxlcRef += iFieldStep; ppxlcPred += MB_SIZE*2; } } } else { const PixelC* ppxlcRefBot; // The reference block for the bottom fields // The folllowing commented out by JPE. Appears to hose up RefBlocksMVPn.ref. // *************************************************************************** // ActualRefFrame = ppxlcRef + iFieldStep; if (!(xRef & 1)) { //!bXSubPxl&& bYSubPxl for (iy = 0; iy < MB_SIZE; iy+=2) { ppxlcRefBot = ppxlcRef + iFieldStep; //UPln -> pixels (xInt,yInt+1); for (ix = 0; ix < MB_SIZE; ix++) ppxlcPred [ix] = (ppxlcRef [ix] + ppxlcRefBot [ix] + iRound) >> 1; ppxlcRef = ppxlcRefBot; ppxlcPred += MB_SIZE*2; } } else { // bXSubPxl && bYSubPxl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -