📄 ppclass.cpp
字号:
// planar format is found
m_bOutputPlanar = FALSE;
//-----------------------------------------------------------------
// Setup output format
//-----------------------------------------------------------------
switch(iFormat)
{
case ppFormat_YUV444:
channelParams.bInterleaved = FALSE;
channelParams.iFormatCode = IDMAC_NON_INTERLEAVED_FORMAT_CODE_YUV444;
iRotatedStride = iOutputHeight;
iOutputBufSize = iOutputWidth * iOutputHeight * 3;
m_bOutputPlanar = TRUE;
break;
case ppFormat_YUV422:
channelParams.bInterleaved = FALSE;
channelParams.iFormatCode = IDMAC_NON_INTERLEAVED_FORMAT_CODE_YUV422;
iRotatedStride = iOutputHeight;
iOutputBufSize = (iOutputWidth * iOutputHeight) << 1;
m_bOutputPlanar = TRUE;
break;
case ppFormat_YUV420:
channelParams.bInterleaved = FALSE;
channelParams.iFormatCode = IDMAC_NON_INTERLEAVED_FORMAT_CODE_YUV420;
iRotatedStride = iOutputHeight;
iOutputBufSize = (iOutputWidth * iOutputHeight * 3) >> 1;
m_bOutputPlanar = TRUE;
break;
case ppFormat_YUV444IL:
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 8;
channelParams.pixelFormat.component2_offset = 16;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
iRotatedStride = iOutputHeight * 3;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_24; // Code for 24BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV444;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
case ppFormat_YUYV422:
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 8;
channelParams.pixelFormat.component2_offset = 24;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
iRotatedStride = iOutputHeight << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
case ppFormat_YVYU422:
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 24;
channelParams.pixelFormat.component2_offset = 8;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
iRotatedStride = iOutputHeight << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
case ppFormat_UYVY422:
channelParams.pixelFormat.component0_offset = 8;
channelParams.pixelFormat.component1_offset = 0;
channelParams.pixelFormat.component2_offset = 16;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
iRotatedStride = iOutputHeight << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
case ppFormat_VYUY422:
channelParams.pixelFormat.component0_offset = 8;
channelParams.pixelFormat.component1_offset = 16;
channelParams.pixelFormat.component2_offset = 0;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
iRotatedStride = iOutputHeight << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
case ppFormat_RGB:
channelParams.pixelFormat.component0_offset = pConfigData->outputRGBPixelFormat.component0_offset;
channelParams.pixelFormat.component1_offset = pConfigData->outputRGBPixelFormat.component1_offset;
channelParams.pixelFormat.component2_offset = pConfigData->outputRGBPixelFormat.component2_offset;
channelParams.pixelFormat.component3_offset = 0;
channelParams.pixelFormat.component0_width = pConfigData->outputRGBPixelFormat.component0_width-1;
channelParams.pixelFormat.component1_width = pConfigData->outputRGBPixelFormat.component1_width-1;
channelParams.pixelFormat.component2_width = pConfigData->outputRGBPixelFormat.component2_width-1;
channelParams.pixelFormat.component3_width = 0;
switch (pConfigData->outputDataWidth)
{
case ppDataWidth_8BPP:
iRotatedStride = iOutputHeight;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_8;
break;
case ppDataWidth_16BPP:
iRotatedStride = iOutputHeight << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16;
break;
case ppDataWidth_24BPP:
iRotatedStride = iOutputHeight * 3;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_24;
break;
case ppDataWidth_32BPP:
iRotatedStride = iOutputHeight << 2;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_32;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Error PP data width, %d !! \r\n"), __WFUNCTION__, pConfigData->outputDataWidth));
result = FALSE;
goto _outputDone;
}
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
case ppFormat_RGBA:
// TODO: Add support for RGBA, and find out data path and use cases for RGBA
channelParams.pixelFormat.component0_offset = 0;
channelParams.pixelFormat.component1_offset = 8;
channelParams.pixelFormat.component2_offset = 16;
channelParams.pixelFormat.component3_offset = 24;
channelParams.pixelFormat.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
channelParams.pixelFormat.component3_width = 7;
// 32 bits per pixel for RGB data
iRotatedStride = iOutputHeight << 2;
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
iOutputBufSize = iOutputStride * iOutputHeight;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Invalid PP output format, %d !! \r\n"), __WFUNCTION__, pConfigData->outputFormat));
result = FALSE;
goto _outputDone;
}
channelParams.iHeight = iOutputHeight;
channelParams.iWidth = iOutputWidth;
channelParams.iLineStride = iOutputStride;
// If we are rotating, we must Reverse the width, height, and
// line stride for the image that is the output from the IC
// task, and for the image that is the input to the
// rotation task. This way, the requested output size is
// always achieved correctly. If the input dimensions do
// not match the reverse of the output dimensions, the
// image is resized before the rotation task.
if (pConfigData->flipRot.rotate90)
{
tempWidth = channelParams.iWidth;
channelParams.iWidth = channelParams.iHeight;
channelParams.iHeight = tempWidth;
channelParams.iLineStride = iRotatedStride;
}
//-----------------------------------------------------------------
// Image size validity check
// Setup post-processing channel output image size
//-----------------------------------------------------------------
if((iOutputWidth < PP_MIN_OUTPUT_WIDTH) ||
(iOutputHeight < PP_MIN_OUTPUT_HEIGHT) ||
(iOutputWidth > PP_MAX_OUTPUT_WIDTH) ||
(iOutputHeight > PP_MAX_OUTPUT_HEIGHT) ||
(pConfigData->inputSize.width > (channelParams.iWidth << 3)) ||
(pConfigData->inputSize.height > (channelParams.iHeight << 3)))
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Error post-processing channel size: \r\n"), __WFUNCTION__));
DEBUGMSG(ZONE_ERROR,
(TEXT("\t Input Size: width (%d), height (%d)\r\n"),
pConfigData->inputSize.width, pConfigData->inputSize.height));
DEBUGMSG(ZONE_ERROR,
(TEXT("\t Viewfinding Channel Size: width (%d), height (%d)\r\n"),
channelParams.iWidth, channelParams.iHeight));
result = FALSE;
goto _outputDone;
}
// Set member variable for whether we will be
// displaying viewfinder data directly to display or not.
m_bVfDirectDisplay = pConfigData->directDisplay;
// Check validity of output format for direct display
// (viewfinding) case.
if (m_bVfDirectDisplay && ((iFormat != ppFormat_RGBA) && (iFormat != ppFormat_RGB)))
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Invalid output format for direct display mode. Must be RGB. Disabling viewfinding.\r\n"), __WFUNCTION__));
m_bVfDirectDisplay = FALSE;
}
// The following are our scenarios for using
// the viewfinding channel:
// 1) Direct Display + SDC:
// - Set up frame sync for task chaining to SDC BG
// - Configure display for viewfinding
// 2) Direct Display + ADC:
// - Set up frame sync for task chaining to ADC direct
// - Configure display for viewfinding
// 3) No direct display:
// - Set up frame sync to write to memory
// - No configuration of display for viewfinding,
// as we will not be displaying viewfinding image
if (m_bVfDirectDisplay)
{
// Direct display mode enabled
// Check that requested width and height do not
// exceed width and height supported by display
if (pConfigData->flipRot.rotate90)
{
if (m_displayCharacteristics.width < iOutputHeight)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Requested viewfinding width %x greater than display width %x. Width will be set to the display width.\r\n"),
__WFUNCTION__, iOutputHeight, m_displayCharacteristics.width));
}
if (m_displayCharacteristics.height < iOutputWidth)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Requested viewfinding height %x greater than display height %x. Height will be set to the display height. \r\n"),
__WFUNCTION__, iOutputWidth, m_displayCharacteristics.height));
}
}
else
{
if (m_displayCharacteristics.width < iOutputWidth)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Requested viewfinding width %x greater than display width %x. Width will be set to the display width.\r\n"),
__WFUNCTION__, iOutputWidth, m_displayCharacteristics.width));
}
if (m_displayCharacteristics.height < iOutputHeight)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Requested viewfinding height %x greater than display height %x. Height will be set to the display height. \r\n"),
__WFUNCTION__, iOutputHeight, m_displayCharacteristics.height));
}
}
// Set up display structure to configure
// display for viewfinding mode.
displayConfig.verticalFlip = FALSE;
displayConfig.alpha = 0xFF;
displayConfig.colorKey = 0;
displayConfig.plane = IPU_SDC_COM_CONF_GWSEL_FG;
displayConfig.bpp = m_displayCharacteristics.bpp;
if (pConfigData->flipRot.rotate90)
{
displayConfig.width = iOutputHeight;
displayConfig.height = iOutputWidth;
}
else
{
displayConfig.width = iOutputWidth;
displayConfig.height = iOutputHeight;
}
// Configure display for viewfinding mode
if (ExtEscape(m_hDisplay, VF_SET_OFFSET, sizeof(POINT),
(LPCSTR) &pConfigData->offset, 0, NULL) <= 0)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Error initialize VF display mode. \r\n"), __WFUNCTION__));
return FALSE;
}
// Configure display for viewfinding mode
if (ExtEscape(m_hDisplay, VF_CONFIG, sizeof(DISPLAY_SDC_FG_CONFIG_DATA),
(LPCSTR) &displayConfig, 0, NULL) <= 0)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Error initializing VF display mode. \r\n"), __WFUNCTION__));
return FALSE;
}
switch (m_displayCharacteristics.eType)
{
case eIPU_SDC:
m_bADCDirect = FALSE;
// Compute bitmask and shifted bit value for IPU_FS_PROC_FLOW register
iMask = CSP_BITFMASK(IPU_IPU_FS_PROC_FLOW_PP_DEST_SEL);
iBitval = CSP_BITFVAL(IPU_IPU_FS_PROC_FLOW_PP_DEST_SEL,
IPU_IPU_FS_PROC_FLOW_PP_DEST_SEL_ARM);
// If display type is a dumb display, we configure
// frame synchronization to write data to SDC
// Foreground/Background plane.
do
{
oldVal = INREG32(&P_IPU_REGS->IPU_FS_PROC_FLOW);
newVal = (oldVal & (~iMask)) | iBitval;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -