📄 basesurf.cpp
字号:
Y[1] = ::atoi((char*) pBuffer->GetBuffer()); HX_RELEASE(pBuffer); } if (pPreferences->ReadPref("VideoBoost\\Cb", pBuffer) == HXR_OK) { Cb = ::atoi((char*) pBuffer->GetBuffer()); HX_RELEASE(pBuffer); } if (pPreferences->ReadPref("VideoBoost\\Cr", pBuffer) == HXR_OK) { Cr = ::atoi((char*) pBuffer->GetBuffer()); HX_RELEASE(pBuffer); } HX_RELEASE(pPreferences); } UCHAR* pTemp = pY; for (int i=0; i<nImageHeight; i++) { // Draw a line of y for each column for (int j=0; j<COLS; j++) { memset(pTemp, Y[j%2], nColWidth); pTemp += nColWidth; } // Move y pointer to next row pTemp = pY + nYPitch*(i+1); // Swap y colors at each new row if (i%nRowWidth == 0) { int nTemp = Y[0]; Y[0] = Y[1]; Y[1] = nTemp; } } // Draw the Cr and Cb planes memset(pU, Cb, nImageWidth*nImageHeight/4); memset(pV, Cr, nImageWidth*nImageHeight/4);}#endif //0HXREGION* CBaseSurface::_DetermineBestRegion(){ HXRECTANGLE rect; ImageBlock* pBlock = NULL; //Create a region from out image block list. HXREGION* pRetReg = HXCreateRegion(); CHXSimpleList::Iterator j = m_imageBlocks.Begin(); while(j != m_imageBlocks.End()) { pBlock = (ImageBlock*)*j; rect.x = (short)pBlock->rect.left; rect.y = (short)pBlock->rect.top; rect.width = (short)(pBlock->rect.right-pBlock->rect.left); rect.height = (short)(pBlock->rect.bottom-pBlock->rect.top); HXUnionRectWithRegion( &rect, pRetReg, pRetReg ); ++j; } return pRetReg;}void CBaseSurface::_RemoveYUVImageLists(){ m_pSite->_TLSLock(); CHXSimpleList::Iterator jj = m_imageBlocks.Begin(); while(jj != m_imageBlocks.End()) { ImageBlock* pXBlock = (ImageBlock*)*jj; Image* pXTmp = pXBlock->pImage; HX_FREE(pXTmp->pucImage); HX_DELETE(pXTmp); HX_DELETE(pXBlock); ++jj; } m_imageBlocks.RemoveAll(); m_bImageBlocksGood = FALSE; CHXMapPtrToPtr::Iterator i = m_YUVAImageList.Begin(); while(i != m_YUVAImageList.End()) { Image* pImage = (Image*)*i; HX_DELETE(pImage->pucImage); HX_DELETE(pImage); ++i; } m_YUVAImageList.RemoveAll(); m_pSite->_TLSUnlock();}CHXBaseSite* CBaseSurface::_SearchForYUV(CHXBaseSite* pTopSite){ HX_ASSERT( pTopSite ); CHXBaseSite* pRetSite = NULL; CHXMapPtrToPtr::Iterator i; CBaseSurface* pSurf = pTopSite->m_pVideoSurface; if( pSurf ) { int nCID2 = GETBITMAPCOLOR(&(pSurf->m_bmiLastBlt)); if( IsYUV(nCID2) && pSurf->_IsDisplaySurfaceYuv()) { pRetSite = pTopSite; } } if( !pRetSite ) { //If the one passed in isn't any good, we need to go through its //lists of alphablend sites and so on. for( i=pTopSite->m_AlphaBlendSites.Begin() ; i!=pTopSite->m_AlphaBlendSites.End() && !pRetSite ; ++i) { CHXBaseSite* pSite = (CHXBaseSite*) i.get_key(); pRetSite = _SearchForYUV( pSite ); } } return pRetSite;}BOOL CBaseSurface::_BlendYUVRects( AlphaStruct* pList, int nCount, UINT32 ulDestFourCC){ BOOL bBlend = TRUE; //These rects in pList *must* match the ones in m_imageBlocks. //If they don't, time for recompute clip again. CHXSimpleList::Iterator g = m_imageBlocks.Begin(); int i=0; while(g != m_imageBlocks.End() ) { ImageBlock* pBlockOut = (ImageBlock*)*g; Image* pImageOut = pBlockOut->pImage; CHXBaseSite* pSite = pBlockOut->pSrcSite; Image* pImage = NULL; //Find ourselves in that site's YUV list. CHXBaseSite* pTmp = NULL; CHXMapPtrToPtr::Iterator j = pSite->m_pVideoSurface->m_YUVAImageList.Begin(); while( j!=pSite->m_pVideoSurface->m_YUVAImageList.End() ) { pTmp = (CHXBaseSite*)j.get_key(); if( pTmp == m_pSite ) { pImage = (Image*)*j; break; } ++j; } //HX_ASSERT( pImage ); if( pImage) { //Blend pList[i] under AYUV and put in pTmp int nSizeX = pBlockOut->rect.right-pBlockOut->rect.left; int nSizeY = pBlockOut->rect.bottom-pBlockOut->rect.top; //int nPImageDataPitch = GETBITMAPPITCH(pList[i].lPitch); int nPImageOutPitch = GETBITMAPPITCH(&pImageOut->bmiImage); int nPImagePitch = GETBITMAPPITCH(&pImage->bmiImage); // These rects should match...might crash if they don't if( nSizeX > pImage->bmiImage.biWidth || nSizeX > pImageOut->bmiImage.biWidth || nSizeX > HXxRECT_WIDTH(pList[i].rcImageRect) ) { bBlend = FALSE; } if( nSizeY > pImage->bmiImage.biHeight || nSizeY > pImageOut->bmiImage.biHeight || nSizeY > HXxRECT_HEIGHT(pList[i].rcImageRect) ) { bBlend = FALSE; } if( pBlockOut->startX<0 || pBlockOut->startY<0 ) { bBlend = FALSE; } if (bBlend) { HX_RESULT hr = zm_pColorAcc->I420andYUVA( pList[i].pBuffer, pList[i].ulImageWidth, pList[i].ulImageHeight, pList[i].lPitch, pList[i].rcImageRect.left, pList[i].rcImageRect.top, //pBlockOut->rect.left, pBlockOut->rect.top, pImage->pucImage, pImage->bmiImage.biWidth, pImage->bmiImage.biHeight, nPImagePitch, pBlockOut->startX, pBlockOut->startY, pImageOut->pucImage, pImageOut->bmiImage.biWidth, pImageOut->bmiImage.biHeight, nPImageOutPitch, 0, 0, nSizeX, nSizeY, MapFourCCtoCID(ulDestFourCC) ); bBlend = hr==HXR_OK; //Now keep drawing up the line through all //overlapping ARGB images. pSite->m_pVideoSurface->_RecursiveYUVBlend( pImageOut, pBlockOut->rect, this, 0, 0); } i++; } ++g; } return bBlend;}BOOL CBaseSurface::_DoYUVRectsIntersect(){ BOOL bBlend = FALSE; CHXMapPtrToPtr::Iterator i; while( i != m_pSite->m_AlphaBlendNotifiers.End() && !bBlend ) { CHXBaseSite* pSite = (CHXBaseSite*)*i; if( pSite->m_AlphaBlendNotifiers.GetCount() ) { bBlend = TRUE; } } return bBlend;}BOOL CBaseSurface::_RecursiveYUVBlend( Image* pImageOut, HXxRect boundingRect, CBaseSurface* pSurface, INT32 lXOffset, INT32 lYOffset){ BOOL bRetVal = FALSE; CHXMapPtrToPtr::Iterator i; if( m_pSite->m_AlphaBlendNotifiers.GetCount()==0 ) { return bRetVal; } for( i=m_pSite->m_AlphaBlendNotifiers.Begin() ; i!=m_pSite->m_AlphaBlendNotifiers.End() ; ++i) { CHXBaseSite* pSite = (CHXBaseSite*)*i; HXREGION* pReg = NULL; //Find the region we need to blend with. CHXMapPtrToPtr::Iterator j = pSite->m_AlphaBlendSites.Begin(); CHXBaseSite* pTmp = NULL; while( j != pSite->m_AlphaBlendSites.End() && pTmp != m_pSite ) { pTmp = (CHXBaseSite*)j.get_key(); if( pTmp == m_pSite ) { pReg = (HXREGION*)*j; break; } ++j; } //Hmmmm, something is probably wrong here... if( HXEmptyRegion(pReg) ) { HX_ASSERT("oops"==NULL); break; } //Find the YUVA buffer we need to blend against.... Image* pImage = NULL; j = pSite->m_pVideoSurface->m_YUVAImageList.Begin(); pTmp = NULL; while( j!=pSite->m_pVideoSurface->m_YUVAImageList.End() ) { pTmp = (CHXBaseSite*)j.get_key(); if( pTmp == m_pSite ) { pImage = (Image*)*j; break; } ++j; } //Now blend with this image.... if( pReg && pImage ) { bRetVal = TRUE; //blend by extents, blt by rects, and save for Blt(). for(int nIdx=0 ; nIdx<pReg->numRects ; nIdx++ ) { HXxRect BlockOut; BlockOut.left = pReg->rects[nIdx].x1; BlockOut.top = pReg->rects[nIdx].y1; BlockOut.right = pReg->rects[nIdx].x2; BlockOut.bottom = pReg->rects[nIdx].y2; //Downscale all rects.... double scaleX = 1; double scaleY = 1; scaleX = pSurface->m_scaleFactorX/pSite->m_pVideoSurface->m_scaleFactorX; scaleY = pSurface->m_scaleFactorY/pSite->m_pVideoSurface->m_scaleFactorY; //We must restrict this region to just the part that //overlaps the actuall YUV surface... int tlx = (int)((double)(m_pSite->m_topleft.x)/scaleX+.5); int tly = (int)((double)(m_pSite->m_topleft.y)/scaleY+.5); int xx = tlx - boundingRect.left; int yy = tly - boundingRect.top; if( (int)(BlockOut.left/scaleX+.5) < boundingRect.left ) BlockOut.left = (INT32)(boundingRect.left*scaleX+.5); if( (int)(BlockOut.top/scaleY+.5) < boundingRect.top ) BlockOut.top = (INT32)(boundingRect.top*scaleY+.5); if( (int)(BlockOut.right/scaleX+.5) > boundingRect.right ) BlockOut.right = (INT32)(boundingRect.right*scaleX+.5); if( (int)(BlockOut.bottom/scaleY+.5) > boundingRect.bottom ) BlockOut.bottom = (INT32)(boundingRect.bottom*scaleY+.5); BlockOut.left = (int)((double)(BlockOut.left-m_pSite->m_topleft.x)/scaleX+.5); BlockOut.top = (int)((double)(BlockOut.top-m_pSite->m_topleft.y)/scaleY+.5); BlockOut.right = (int)((double)(BlockOut.right-m_pSite->m_topleft.x)/scaleX+.5); BlockOut.bottom = (int)((double)(BlockOut.bottom-m_pSite->m_topleft.y)/scaleY+.5); // Ensure we start on even pixels (for yuv blending/conversion) BlockOut.left &= ~1; BlockOut.top &= ~1; if( (BlockOut.right-BlockOut.left) & 1 ) { BlockOut.right &= ~1; } if( (BlockOut.bottom-BlockOut.top) & 1 ) { BlockOut.bottom &= ~1; } int nSizeX = BlockOut.right-BlockOut.left; int nSizeY = BlockOut.bottom-BlockOut.top;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -