📄 ddipu_sdc_overlay.cpp
字号:
LeaveCriticalSection(&m_csOverlayShutdown);
physAddr.QuadPart = (UINT32) ppData.bufs.outputBuf; //m_nLAWPhysical + ppOutputSurf->OffsetInVideoMemory();
ForegroundWindowSetSrcBuffer(&physAddr);
// Enable Foreground...if it is already enabled,
// this call will just return.
ForegroundWindowEnable();
}
}
//------------------------------------------------------------------------------
//
// Function: ConfigPPForOverlay
//
// This function configure the Post-processor to perform rotation,
// color space conversion, and resizing for the video overlay.
//
// Parameters:
// pOverlaySurf
// [in] Overlay surface.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void DDIPU_SDC::SetPPConfigForOverlay(DDGPESurf *pSurf)
{
EDDGPEPixelFormat inputPixFormat;
inputPixFormat = pSurf->PixelFormat();
// Set up post-processing configuration data
// Set up input format and data width
if (inputPixFormat == ddgpePixelFormat_YV12)
{
m_ppData_Overlay.inputFormat = ppFormat_YUV420;
m_ppData_Overlay.inputDataWidth = ppDataWidth_8BPP;
}
else
{
m_ppData_Overlay.inputFormat = EDDGPEFormatToPpFormat[inputPixFormat];
m_ppData_Overlay.inputDataWidth = EDDGPEFormatToDataWidth[inputPixFormat];
}
if (m_ppData_Overlay.inputFormat == ppFormat_RGB)
{
switch(m_ppData_Overlay.inputDataWidth)
{
case ppDataWidth_32BPP:
m_ppData_Overlay.inputRGBPixelFormat.component0_offset = 8;
m_ppData_Overlay.inputRGBPixelFormat.component1_offset = 16;
m_ppData_Overlay.inputRGBPixelFormat.component2_offset = 24;
m_ppData_Overlay.inputRGBPixelFormat.component3_offset = 0;
m_ppData_Overlay.inputRGBPixelFormat.component0_width = 8;
m_ppData_Overlay.inputRGBPixelFormat.component1_width = 8;
m_ppData_Overlay.inputRGBPixelFormat.component2_width = 8;
m_ppData_Overlay.inputRGBPixelFormat.component3_width = 8;
break;
case ppDataWidth_24BPP:
m_ppData_Overlay.inputRGBPixelFormat.component0_offset = 0;
m_ppData_Overlay.inputRGBPixelFormat.component1_offset = 8;
m_ppData_Overlay.inputRGBPixelFormat.component2_offset = 16;
m_ppData_Overlay.inputRGBPixelFormat.component0_width = 8;
m_ppData_Overlay.inputRGBPixelFormat.component1_width = 8;
m_ppData_Overlay.inputRGBPixelFormat.component2_width = 8;
break;
case ppDataWidth_16BPP:
m_ppData_Overlay.inputRGBPixelFormat.component0_offset = 0;
m_ppData_Overlay.inputRGBPixelFormat.component1_offset = 5;
m_ppData_Overlay.inputRGBPixelFormat.component2_offset = 11;
m_ppData_Overlay.inputRGBPixelFormat.component0_width = 5;
m_ppData_Overlay.inputRGBPixelFormat.component1_width = 6;
m_ppData_Overlay.inputRGBPixelFormat.component2_width = 5;
break;
default:
DEBUGMSG(GPE_ZONE_ERROR, (TEXT("%s: Source data format is invalid.\r\n"), __WFUNCTION__));
break;
}
}
// Set up output format and data width
m_ppData_Overlay.outputFormat = ppFormat_RGB;
switch(m_nScreenBpp)
{
case 24:
m_ppData_Overlay.outputDataWidth = ppDataWidth_24BPP;
m_ppData_Overlay.outputRGBPixelFormat.component0_offset = 0;
m_ppData_Overlay.outputRGBPixelFormat.component1_offset = 8;
m_ppData_Overlay.outputRGBPixelFormat.component2_offset = 16;
m_ppData_Overlay.outputRGBPixelFormat.component0_width = 8;
m_ppData_Overlay.outputRGBPixelFormat.component1_width = 8;
m_ppData_Overlay.outputRGBPixelFormat.component2_width = 8;
break;
case 16:
m_ppData_Overlay.outputDataWidth = ppDataWidth_16BPP;
m_ppData_Overlay.outputRGBPixelFormat.component0_offset = 0;
m_ppData_Overlay.outputRGBPixelFormat.component1_offset = 5;
m_ppData_Overlay.outputRGBPixelFormat.component2_offset = 11;
m_ppData_Overlay.outputRGBPixelFormat.component0_width = 5;
m_ppData_Overlay.outputRGBPixelFormat.component1_width = 6;
m_ppData_Overlay.outputRGBPixelFormat.component2_width = 5;
break;
default:
DEBUGMSG(GPE_ZONE_ERROR, (TEXT("%s: Display output BPP invalid\r\n"), __WFUNCTION__));
break;
}
// Set up post-processing channel CSC parameters
// based on input and output
switch(m_ppData_Overlay.outputFormat)
{
case ppFormat_YUV444:
case ppFormat_YUV422:
case ppFormat_YUV420:
case ppFormat_YUV444IL:
case ppFormat_YUYV422:
case ppFormat_YVYU422:
case ppFormat_UYVY422:
case ppFormat_VYUY422:
if ((m_ppData_Overlay.inputFormat == ppFormat_RGB) |
(m_ppData_Overlay.inputFormat == ppFormat_RGBA))
m_ppData_Overlay.CSCEquation = ppCSCR2Y_A1;
else
m_ppData_Overlay.CSCEquation = ppCSCNoOp;
break;
case ppFormat_RGB:
case ppFormat_RGBA:
if ((m_ppData_Overlay.inputFormat == ppFormat_YUV444IL) |
(m_ppData_Overlay.inputFormat == ppFormat_YUV444) |
(m_ppData_Overlay.inputFormat == ppFormat_YUV422) |
(m_ppData_Overlay.inputFormat == ppFormat_YUV420) |
(m_ppData_Overlay.inputFormat == ppFormat_YUYV422) |
(m_ppData_Overlay.inputFormat == ppFormat_YVYU422) |
(m_ppData_Overlay.inputFormat == ppFormat_UYVY422) |
(m_ppData_Overlay.inputFormat == ppFormat_VYUY422))
m_ppData_Overlay.CSCEquation = ppCSCY2R_A1;
else
m_ppData_Overlay.CSCEquation = ppCSCNoOp;
break;
}
m_ppData_Overlay.inputSize.height = (UINT16) (m_pOverlaySurfaceOp->SrcRect.bottom - m_pOverlaySurfaceOp->SrcRect.top);
m_ppData_Overlay.inputSize.width = (UINT16) (m_pOverlaySurfaceOp->SrcRect.right - m_pOverlaySurfaceOp->SrcRect.left);
m_ppData_Overlay.inputStride = pSurf->Stride();
switch (m_iRotate)
{
case DMDO_0:
m_ppData_Overlay.flipRot.verticalFlip = FALSE;
m_ppData_Overlay.flipRot.horizontalFlip = FALSE;
m_ppData_Overlay.flipRot.rotate90 = FALSE;
break;
case DMDO_90:
m_ppData_Overlay.flipRot.verticalFlip = TRUE;
m_ppData_Overlay.flipRot.horizontalFlip = TRUE;
m_ppData_Overlay.flipRot.rotate90 = TRUE;
break;
case DMDO_180:
m_ppData_Overlay.flipRot.verticalFlip = TRUE;
m_ppData_Overlay.flipRot.horizontalFlip = TRUE;
m_ppData_Overlay.flipRot.rotate90 = FALSE;
break;
case DMDO_270:
m_ppData_Overlay.flipRot.verticalFlip = FALSE;
m_ppData_Overlay.flipRot.horizontalFlip = FALSE;
m_ppData_Overlay.flipRot.rotate90 = TRUE;
break;
}
// Handle special TV mode settings
if (!m_bTVModeActive)
{
// Normal settings
m_ppData_Overlay.outputSize.height = m_pOverlaySurfaceOp->HeightHw;
m_ppData_Overlay.outputSize.width = m_pOverlaySurfaceOp->WidthHw;
m_ppData_Overlay.outputStride = m_pOverlaySurfaceOp->LineStride;
}
else
{
// If we are in TV mode, do not rotate overlay
m_ppData_Overlay.flipRot.verticalFlip = FALSE;
m_ppData_Overlay.flipRot.horizontalFlip = FALSE;
m_ppData_Overlay.flipRot.rotate90 = FALSE;
// Upsize output dimensions for TV (640x480)
m_ppData_Overlay.outputSize.height = m_pOverlaySurfaceOp->Height * 2;
m_ppData_Overlay.outputSize.width = m_pOverlaySurfaceOp->Width * 2;
m_ppData_Overlay.outputStride = m_ppData_Overlay.outputSize.width * m_pMode->Bpp / 8;
/*
DEBUGMSG(GPE_ZONE_HW, (TEXT("%s: Height: %x\n Width: %x\n HeightHw: %x\n WidthHw: %x\n LineStride: %x\n myheight: %x\n mywidth: %x\n mystride: %x\n\r\n"),
__WFUNCTION__, m_pOverlaySurfaceOp->Height, m_pOverlaySurfaceOp->Width,
m_pOverlaySurfaceOp->HeightHw, m_pOverlaySurfaceOp->WidthHw,
m_pOverlaySurfaceOp->LineStride, m_ppData_Overlay.outputSize.height,
m_ppData_Overlay.outputSize.width, m_ppData_Overlay.outputStride));
*/
}
m_ppData_Overlay.directDisplay = FALSE;
return;
}
//------------------------------------------------------------------------------
//
// Function: WaitForNotBusyOverlay
//
// This function waits until the graphics window of the IPU is ready to
// update.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
VOID DDIPU_SDC::WaitForNotBusyOverlay(VOID)
{
DisplayPlaneWaitForNotBusy(DisplayPlane_1);
return;
}
//------------------------------------------------------------------------------
//
// Function: OverlayWindowSetup
//
// This function waits until the graphics window of the IPU is ready to
// update.
//
// Parameters:
// None.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
VOID DDIPU_SDC::OverlayWindowSetup(VOID)
{
POINT ptOverlayOffset;
DISPLAY_SDC_FG_CONFIG_DATA dispConfigData;
ptOverlayOffset.x = m_pOverlaySurfaceOp->XOffset;
ptOverlayOffset.y = m_pOverlaySurfaceOp->YOffset;
if (m_bTVModeActive)
{
ptOverlayOffset.x *= 2;
ptOverlayOffset.y *= 2;
}
ForegroundWindowSetOffset(&ptOverlayOffset);
dispConfigData.alpha = m_pOverlaySurfaceOp->Transparency;
dispConfigData.width = m_pOverlaySurfaceOp->WidthHw;
dispConfigData.height = m_pOverlaySurfaceOp->HeightHw;
dispConfigData.bpp = m_pOverlaySurfaceOp->Bpp;
dispConfigData.stride = m_pOverlaySurfaceOp->LineStride;
dispConfigData.verticalFlip = m_pOverlaySurfaceOp->isUpsideDown;
dispConfigData.colorKey = m_pOverlaySurfaceOp->ColorKeyMask;
dispConfigData.plane = m_pOverlaySurfaceOp->ColorKeyPlane;
if (m_bTVModeActive)
{
dispConfigData.width = m_pOverlaySurfaceOp->Width * 2;
dispConfigData.height = m_pOverlaySurfaceOp->Height * 2;
}
if (!ForegroundWindowConfig(&dispConfigData))
{
DEBUGMSG(GPE_ZONE_ERROR, (TEXT("DDIPU_SDC SetOverlayPosition: ForegroundWindowConfig error\r\n")));
return;
}
return;
}
//------------------------------------------------------------------------------
//
// Function: SetupOverlayPosition
//
// This function waits until the graphics window of the IPU is ready to
// update.
//
// Parameters:
// pOverlaySurf
// [in/out] Surface for which the X and Y offsets are to
// be configured.
//
// X
// [in] Desired X offset of overlay surface in display.
//
// Y
// [in] Desired Y offset of overlay surface in display.
//
// Returns:
// None.
//
//------------------------------------------------------------------------------
void DDIPU_SDC::SetupOverlayPosition(pOverlaySurf_t pOverlaySurf, LONG X, LONG Y)
{
switch(m_iRotate){
case DMDO_0:
pOverlaySurf->XOffset = (UINT16)X;
pOverlaySurf->YOffset = (UINT16)Y;
break;
case DMDO_90:
pOverlaySurf->XOffset = (UINT16)Y;
pOverlaySurf->YOffset = (UINT16)(m_pMode->width - (X + pOverlaySurf->Width));
break;
case DMDO_180:
pOverlaySurf->XOffset = (UINT16)(m_pMode->width - (X + pOverlaySurf->Width));
pOverlaySurf->YOffset = (UINT16)(m_pMode->height - (Y + pOverlaySurf->Height));
break;
case DMDO_270:
pOverlaySurf->XOffset = (UINT16)(m_pMode->height - (Y + pOverlaySurf->Height));
pOverlaySurf->YOffset = (UINT16)X;
break;
}
}
//------------------------------------------------------------------------------
//
// Function: IsOverlaySurfEqual
//
// This function compares overlay surfaces to determine if they are equal.
// update.
//
// Parameters:
// pSurf1
// [in] Overlay surface descriptor 1.
//
// pSurf2
// [in] Overlay surface descriptor 2.
//
// Returns:
// TRUE if pSurf1 and pSurf2 are equal.
// FALSE if not.
//
//------------------------------------------------------------------------------
BOOL IsOverlaySurfEqual(pOverlaySurf_t pSurf1, pOverlaySurf_t pSurf2)
{
if ((pSurf1->Width == pSurf2->Width) &&
(pSurf1->Height == pSurf2->Height) &&
(pSurf1->WidthHw == pSurf2->WidthHw) &&
(pSurf1->HeightHw == pSurf2->HeightHw) &&
(pSurf1->LineStride == pSurf2->LineStride) &&
(pSurf1->XOffset == pSurf2->XOffset) &&
(pSurf1->YOffset == pSurf2->YOffset) &&
(pSurf1->SrcRect.top == pSurf2->SrcRect.top) &&
(pSurf1->SrcRect.left == pSurf2->SrcRect.left) &&
(pSurf1->SrcRect.bottom == pSurf2->SrcRect.bottom) &&
(pSurf1->SrcRect.right == pSurf2->SrcRect.right) &&
(pSurf1->Bpp == pSurf2->Bpp) &&
(pSurf1->Transparency == pSurf2->Transparency) &&
(pSurf1->isUpsideDown == pSurf2->isUpsideDown) &&
(pSurf1->ColorKeyMask == pSurf2->ColorKeyMask) &&
(pSurf1->ColorKeyPlane == pSurf2->ColorKeyPlane))
{
return TRUE;
}
else
{
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -