📄 spt.cpp
字号:
Bool CVideoObject::SptUpdateMB_NOT_HOLE(Int iMBXoffset, Int iMBYoffset, CMBMode* pmbmd)// In a given Sprite update piece, Check whether current macroblock is not a hole and should be coded ?{ Int iMBX = iMBXoffset + m_iPieceXoffset; Int iMBY = iMBYoffset + m_iPieceYoffset; Int iMBX1 = iMBX -1; if ( (iMBXoffset >0 ) && ( m_ppUpdateMBstatus[iMBY][iMBX1] == NOT_DONE)) m_ppUpdateMBstatus[iMBY][iMBX1] = UPDATE_DONE; *pmbmd = CMBMode (m_rgmbmdSpt[iMBY][iMBX]); return ( m_ppUpdateMBstatus[iMBY][iMBX] == NOT_DONE) ;} Void CVideoObject::SaveMBmCurrRow (Int iMBYoffset, MacroBlockMemory** rgpmbmCurr){ Int iMBX; Int iMBY = iMBYoffset + m_iPieceYoffset; Int iMB, iBlk; Int nBlk = (m_volmd.fAUsage == EIGHT_BIT) ? 10 : 6; Int *Dest; Int *Src; for (iMB = 0; iMB < m_iNumMBX; iMB++) { iMBX = iMB + m_iPieceXoffset; for (iBlk = 0; iBlk < nBlk; iBlk++) { Dest = (m_rgpmbmCurr_Spt[iMBY][iMBX]->rgblkm) [iBlk]; Src = (rgpmbmCurr[iMB]->rgblkm) [iBlk]; memcpy (Dest, Src, ((BLOCK_SIZE << 1) - 1) * sizeof (Int)); } }} Void CVideoObject::RestoreMBmCurrRow (Int iMBYoffset, MacroBlockMemory** rgpmbmCurr){ Int iMBX; Int iMBY = iMBYoffset + m_iPieceYoffset; Int iMB, iBlk; Int nBlk = (m_volmd.fAUsage == EIGHT_BIT) ? 10 : 6; Int *Dest, *Src; for (iMB = 0; iMB < m_iNumMBX; iMB++) { iMBX = iMB + m_iPieceXoffset; for (iBlk = 0; iBlk < nBlk; iBlk++) { Src = (m_rgpmbmCurr_Spt[iMBY][iMBX]->rgblkm) [iBlk]; Dest = (rgpmbmCurr[iMB]->rgblkm) [iBlk]; memcpy (Dest, Src, ((BLOCK_SIZE << 1) - 1) * sizeof (Int)); } }}Void CVideoObject::CopyCurrQToPred ( PixelC* ppxlcQMBY, PixelC* ppxlcQMBU, PixelC* ppxlcQMBV){ CoordI ix, iy, ic = 0; for (iy = 0; iy < MB_SIZE; iy++) { for (ix = 0; ix < MB_SIZE; ix++, ic++) { m_ppxlcPredMBY [ic] = ppxlcQMBY [ix] ; } ppxlcQMBY += m_iFrameWidthY; } ic = 0; for (iy = 0; iy < BLOCK_SIZE; iy++) { for (ix = 0; ix < BLOCK_SIZE; ix++, ic++) { m_ppxlcPredMBU [ic] = ppxlcQMBU [ix]; m_ppxlcPredMBV [ic] = ppxlcQMBV [ix]; } ppxlcQMBU += m_iFrameWidthUV; ppxlcQMBV += m_iFrameWidthUV; }}//low latency sprite stuffVoid CVideoObject::VOPOverlay (CVOPU8YUVBA& pvopc1, CVOPU8YUVBA& pvopc2, Int iscale){ float fscaleY = (float) ((iscale == 0) ? 0.0 : 1.0); // check whether there is a EXPANDY_REF_FRAME float fscaleUV = (float) ((iscale == 0) ? 0.0 : 0.5); CU8Image* uci1 = const_cast<CU8Image*> (pvopc1.getPlane (Y_PLANE)); CU8Image* uci2 = const_cast<CU8Image*> (pvopc2.getPlane (Y_PLANE)); Overlay (*uci1, *uci2, fscaleY) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (U_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (U_PLANE)); Overlay (*uci1, *uci2, fscaleUV) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (V_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (V_PLANE)); Overlay (*uci1, *uci2, fscaleUV) ; if (m_volmd.fAUsage != RECTANGLE) { uci1 = const_cast<CU8Image*> (pvopc1.getPlane (BY_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (BY_PLANE)); Overlay (*uci1, *uci2, fscaleY) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (BUV_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (BUV_PLANE)); Overlay (*uci1, *uci2, fscaleUV) ; if (m_volmd.fAUsage == EIGHT_BIT) { uci1 = const_cast<CU8Image*> (pvopc1.getPlane (A_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (A_PLANE)); Overlay (*uci1, *uci2, fscaleY) ; } }}Void CVideoObject::Overlay (CU8Image& uci1, CU8Image& uci2, float fscale){ CRct r1 = uci1.where (); CRct r2 = uci2.where (); CoordI x = r1.left + (CoordI) (EXPANDY_REF_FRAME * fscale); // copy pixels, skip the guard band CoordI y = r1.top + (CoordI) (EXPANDY_REF_FRAME * fscale); Int cbLine = (r1.width- 2 * (Int) (EXPANDY_REF_FRAME * fscale)) * sizeof (PixelC); PixelC* ppxl = (PixelC*) uci2.pixels (x, y); const PixelC* ppxlFi = uci1.pixels (x, y); Int widthCurr = r2.width; Int widthFi = r1.width; for (CoordI yi = y; yi < (r1.bottom - EXPANDY_REF_FRAME * fscale); yi++) { memcpy (ppxl, ppxlFi, cbLine); ppxl += widthCurr; ppxlFi += widthFi; }}// dshu: begin of modification // get from pvopc2 at (rctPieceY.left,rctPieceY.right)Void CVideoObject::PieceGet (CVOPU8YUVBA& pvopc1, CVOPU8YUVBA& pvopc2, CRct rctPieceY){ CRct rctPieceUV = rctPieceY.downSampleBy2 (); CU8Image* uci1 = const_cast<CU8Image*> (pvopc1.getPlane (Y_PLANE)); CU8Image* uci2 = const_cast<CU8Image*> (pvopc2.getPlane (Y_PLANE)); U8iGet(*uci1, *uci2, rctPieceY) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (U_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (U_PLANE)); U8iGet(*uci1, *uci2, rctPieceUV) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (V_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (V_PLANE)); U8iGet(*uci1, *uci2, rctPieceUV) ; if (m_volmd.fAUsage != RECTANGLE) { uci1 = const_cast<CU8Image*> (pvopc1.getPlane (BY_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (BY_PLANE)); U8iGet(*uci1, *uci2, rctPieceY) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (BUV_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (BUV_PLANE)); U8iGet(*uci1, *uci2, rctPieceUV) ; if (m_volmd.fAUsage == EIGHT_BIT) { uci1 = const_cast<CU8Image*> (pvopc1.getPlane (A_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (A_PLANE)); U8iGet(*uci1, *uci2, rctPieceY) ; } }} Void CVideoObject::U8iGet(CU8Image& uci1, CU8Image& uci2, CRct rctPiece){ CRct r1 = uci1.where (); CRct r2 = uci2.where (); CoordI x = rctPiece.left ; CoordI y = rctPiece.top ; Int cbLine = (rctPiece.width) * sizeof (PixelC); PixelC* ppxl = (PixelC*) uci1.pixels (0, 0); const PixelC* ppxlFi = uci2.pixels (x, y); Int widthCurr = r2.width; Int widthFi = r1.width; for (CoordI yi = y; yi < rctPiece.bottom; yi++) { memcpy (ppxl, ppxlFi, cbLine); ppxl += widthCurr; ppxlFi += widthFi; }}// put into pvopc2 at (rctPieceY.left,rctPieceY.right)Void CVideoObject::PiecePut (CVOPU8YUVBA& pvopc1, CVOPU8YUVBA& pvopc2, CRct rctPieceY){ CRct rctPieceUV = rctPieceY.downSampleBy2 (); CU8Image* uci1 = const_cast<CU8Image*> (pvopc1.getPlane (Y_PLANE)); CU8Image* uci2 = const_cast<CU8Image*> (pvopc2.getPlane (Y_PLANE)); U8iPut(*uci1, *uci2, rctPieceY) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (U_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (U_PLANE)); U8iPut(*uci1, *uci2, rctPieceUV) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (V_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (V_PLANE)); U8iPut(*uci1, *uci2, rctPieceUV) ; if (m_volmd.fAUsage != RECTANGLE) { uci1 = const_cast<CU8Image*> (pvopc1.getPlane (BY_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (BY_PLANE)); U8iPut(*uci1, *uci2, rctPieceY) ; uci1 = const_cast<CU8Image*> (pvopc1.getPlane (BUV_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (BUV_PLANE)); U8iPut(*uci1, *uci2, rctPieceUV) ; if (m_volmd.fAUsage == EIGHT_BIT) { uci1 = const_cast<CU8Image*> (pvopc1.getPlane (A_PLANE)); uci2 = const_cast<CU8Image*> (pvopc2.getPlane (A_PLANE)); U8iPut(*uci1, *uci2, rctPieceY) ; } }} Void CVideoObject::U8iPut(CU8Image& uci1, CU8Image& uci2, CRct rctPiece){ CRct r1 = uci1.where (); CRct r2 = uci2.where (); CoordI x = rctPiece.left ; CoordI y = rctPiece.top ; Int cbLine = (rctPiece.width) * sizeof (PixelC); PixelC* ppxl = (PixelC*) uci2.pixels (x, y); const PixelC* ppxlFi = uci1.pixels (0, 0); Int widthCurr = r2.width; Int widthFi = r1.width; for (CoordI yi = y; yi < rctPiece.bottom; yi++) { memcpy (ppxl, ppxlFi, cbLine); ppxl += widthCurr; ppxlFi += widthFi; }} // dshu: end of modification// dshu: [v071] Begin of modification Void CVideoObject::padSprite(){ m_iNumMBX = m_rctSptQ.width / MB_SIZE; m_iNumMBY = m_rctSptQ.height () / MB_SIZE; Int iMBXleft, iMBXright; Int iMBYup, iMBYdown; CMBMode* pmbmd = m_rgmbmdSprite; PixelC* ppxlcRefY = (PixelC*) m_pvopcSptQ->pixelsY () + m_iStartInRefToCurrRctY; PixelC* ppxlcRefU = (PixelC*) m_pvopcSptQ->pixelsU () + m_iStartInRefToCurrRctUV; PixelC* ppxlcRefV = (PixelC*) m_pvopcSptQ->pixelsV () + m_iStartInRefToCurrRctUV; PixelC* ppxlcRefBY = (PixelC*) m_pvopcSptQ->pixelsBY () + m_iStartInRefToCurrRctY; PixelC* ppxlcRefA = (PixelC*) m_pvopcSptQ->pixelsA () + m_iStartInRefToCurrRctY; PixelC* ppxlcRefBUV = (PixelC*) m_pvopcSptQ->pixelsBUV () + m_iStartInRefToCurrRctUV; for (Int iMBY = 0; iMBY < m_iNumMBY; iMBY++){ PixelC* ppxlcRefMBY = ppxlcRefY; PixelC* ppxlcRefMBU = ppxlcRefU; PixelC* ppxlcRefMBV = ppxlcRefV; PixelC* ppxlcRefMBBY = ppxlcRefBY; PixelC* ppxlcRefMBBUV = ppxlcRefBUV; PixelC* ppxlcRefMBA = ppxlcRefA; iMBYup = iMBY -1; iMBYdown = iMBY +1; for (Int iMBX = 0; iMBX < m_iNumMBX; iMBX++) { iMBXleft = iMBX -1 ; iMBXright = iMBX +1 ; if((m_volmd.bShapeOnly==FALSE) && (m_ppPieceMBstatus[iMBY][iMBX] == PIECE_DONE)) { pmbmd->m_bPadded=FALSE; copySptQShapeYToMb (m_ppxlcCurrMBBY, ppxlcRefMBBY); downSampleBY (m_ppxlcCurrMBBY, m_ppxlcCurrMBBUV); // downsample original BY now for LPE padding (using original shape) if (pmbmd->m_rgTranspStatus [0] != ALL) { // MC padding if (pmbmd -> m_rgTranspStatus [0] == PARTIAL) mcPadCurrMB (ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA); padNeighborTranspMBs ( iMBX, iMBY, pmbmd, ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA ); } else { if (iMBX > 0) { if ((pmbmd - 1)->m_rgTranspStatus [0] != ALL && m_ppPieceMBstatus[iMBY][iMBX-1] == PIECE_DONE) { mcPadCurrMBFromLeft (ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA); pmbmd->m_bPadded = TRUE; } } if (iMBY > 0) { if ((pmbmd - m_iNumMBX)->m_rgTranspStatus [0] != ALL && m_ppPieceMBstatus[iMBY-1][iMBX] == PIECE_DONE) { if (!(pmbmd->m_bPadded)) { mcPadCurrMBFromTop (ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA); pmbmd->m_bPadded = TRUE; } } else if (!(pmbmd - m_iNumMBX)->m_bPadded) mcSetTopMBGray (ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA); } if(iMBY == m_iNumMBY-1) { if(iMBX > 0 && (pmbmd-1)->m_rgTranspStatus [0] == ALL && !((pmbmd-1)->m_bPadded)) mcSetLeftMBGray(ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA); if(iMBX == m_iNumMBX-1 && !(pmbmd->m_bPadded)) mcSetCurrMBGray(ppxlcRefMBY, ppxlcRefMBU, ppxlcRefMBV, ppxlcRefMBA); } } } ppxlcRefMBA += MB_SIZE; ppxlcRefMBBY += MB_SIZE; ppxlcRefMBBUV += BLOCK_SIZE; pmbmd++; ppxlcRefMBY += MB_SIZE; ppxlcRefMBU += BLOCK_SIZE; ppxlcRefMBV += BLOCK_SIZE; } ppxlcRefY += m_iFrameWidthYxMBSize; ppxlcRefU += m_iFrameWidthUVxBlkSize; ppxlcRefV += m_iFrameWidthUVxBlkSize; ppxlcRefBY += m_iFrameWidthYxMBSize; ppxlcRefA += m_iFrameWidthYxMBSize; ppxlcRefBUV += m_iFrameWidthUVxBlkSize; } m_rctPrevNoExpandY = m_rctSptQ; m_rctPrevNoExpandUV = m_rctPrevNoExpandY.downSampleBy2 (); repeatPadYOrA ((PixelC*) m_pvopcSptQ->pixelsY () + m_iOffsetForPadY, m_pvopcSptQ); repeatPadUV (m_pvopcSptQ); //reset by in RefQ1 so that no left-over from last frame if (m_volmd.fAUsage != RECTANGLE) { if (m_volmd.fAUsage == EIGHT_BIT) repeatPadYOrA ((PixelC*) m_pvopcSptQ->pixelsA () + m_iOffsetForPadY, m_pvopcSptQ); }}Void CVideoObject::copySptQShapeYToMb ( PixelC* ppxlcDstMB, const PixelC* ppxlcSrc){ for (Int i = 0; i < MB_SIZE; i++) { memcpy (ppxlcDstMB, ppxlcSrc, MB_SIZE*sizeof(PixelC)); ppxlcSrc += m_iFrameWidthY; ppxlcDstMB += MB_SIZE; }}// dshu: [v071] end of modification
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -