📄 prpclass.cpp
字号:
channelParams.bInterleaved = FALSE;
channelParams.iFormatCode = IDMAC_NON_INTERLEAVED_FORMAT_CODE_YUV444;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_8; // required for planar formats
channelParams.iLineStride = iEncOutputWidth; // Used to compute Y stride
// for YUV non-interleaved
// TODO: Make sure this is right: Compute U buffer
// start address for program channel parameter
iYBufLen = channelParams.iLineStride * iEncOutputHeight;
iUBufOffset = iYBufLen;
iVBufOffset = iYBufLen << 1;
break;
case prpEncOutputFormat_YUV422:
channelParams.bInterleaved = FALSE;
channelParams.iFormatCode = IDMAC_NON_INTERLEAVED_FORMAT_CODE_YUV422;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_8; // required for planar formats
channelParams.iLineStride = iEncOutputWidth; // Used to compute Y stride
// for YUV non-interleaved
iYBufLen = channelParams.iLineStride * iEncOutputHeight;
iUBufOffset = iYBufLen;
iVBufOffset = iYBufLen + (iYBufLen >> 1);
break;
case prpEncOutputFormat_YUV420:
channelParams.bInterleaved = FALSE;
channelParams.iFormatCode = IDMAC_NON_INTERLEAVED_FORMAT_CODE_YUV420;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_8; // required for planar formats
channelParams.iLineStride = iEncOutputWidth; // Used to compute Y stride
// for YUV non-interleaved
iYBufLen = iEncOutputWidth * iEncOutputHeight;
iUBufOffset = iYBufLen;
iVBufOffset = iYBufLen + (iYBufLen >> 2);
break;
case prpEncOutputFormat_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;
channelParams.iLineStride = iEncOutputWidth * 3;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_24; // Code for 24BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV444;
break;
case prpEncOutputFormat_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;
channelParams.iLineStride = iEncOutputWidth << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
break;
case prpEncOutputFormat_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;
channelParams.iLineStride = iEncOutputWidth << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
break;
case prpEncOutputFormat_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;
channelParams.iLineStride = iEncOutputWidth << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
break;
case prpEncOutputFormat_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;
channelParams.iLineStride = iEncOutputWidth << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16; // Code for 16BPP
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_YUV422;
break;
case prpEncOutputFormat_RGB:
channelParams.pixelFormat.component0_offset = configData->encRGBPixelFormat.component0_offset;
channelParams.pixelFormat.component1_offset = configData->encRGBPixelFormat.component1_offset;
channelParams.pixelFormat.component2_offset = configData->encRGBPixelFormat.component2_offset;
channelParams.pixelFormat.component3_offset = configData->encRGBPixelFormat.component3_offset;
channelParams.pixelFormat.component0_width = configData->encRGBPixelFormat.component0_width-1;
channelParams.pixelFormat.component1_width = configData->encRGBPixelFormat.component1_width-1;
channelParams.pixelFormat.component2_width = configData->encRGBPixelFormat.component2_width-1;
channelParams.pixelFormat.component3_width = configData->encRGBPixelFormat.component3_width-1;
switch (configData->encDataWidth)
{
case prpDataWidth_8BPP:
channelParams.iLineStride = iEncOutputWidth;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_8;
break;
case prpDataWidth_16BPP:
channelParams.iLineStride = iEncOutputWidth << 1;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_16;
break;
case prpDataWidth_24BPP:
channelParams.iLineStride = iEncOutputWidth * 3;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_24;
break;
case prpDataWidth_32BPP:
channelParams.iLineStride = iEncOutputWidth << 2;
channelParams.iBitsPerPixelCode = IDMAC_BPP_CODE_32;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Error encoding data width, %d !! \r\n"), __WFUNCTION__, configData->encDataWidth));
result = FALSE;
goto _encDone;
}
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
break;
case prpEncOutputFormat_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.component0_width = 7;
channelParams.pixelFormat.component1_width = 7;
channelParams.pixelFormat.component2_width = 7;
// 32 bits per pixel for RGB data
channelParams.iLineStride = iEncOutputWidth << 2;
channelParams.bInterleaved = TRUE;
channelParams.iFormatCode = IDMAC_INTERLEAVED_FORMAT_CODE_RGB;
break;
default:
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Invalid encoding output format, %d !! \r\n"), __WFUNCTION__, configData->encFormat));
result = FALSE;
goto _encDone;
}
//-----------------------------------------------------------------
// Image size validity check
// Setup encoding channel output image size
//-----------------------------------------------------------------
if((iEncOutputWidth < PRP_MIN_OUTPUT_WIDTH) ||
(iEncOutputHeight < PRP_MIN_OUTPUT_HEIGHT) ||
(iEncOutputWidth > PRP_MAX_OUTPUT_WIDTH) ||
(iEncOutputHeight > PRP_MAX_OUTPUT_HEIGHT) ||
(configData->inputSize.width > (iEncOutputWidth << 3)) ||
(configData->inputSize.height > (iEncOutputHeight << 3)))
{
DEBUGMSG(ZONE_ERROR, (TEXT("%s: Error encoding channel size: \r\n"), __WFUNCTION__));
DEBUGMSG(ZONE_ERROR,
(TEXT("\t Input Size: width (%d), height (%d)\r\n"),
configData->inputSize.width, configData->inputSize.height));
DEBUGMSG(ZONE_ERROR,
(TEXT("\t Encoding Channel Size: width (%d), height (%d)\r\n"),
iEncOutputWidth, iEncOutputHeight));
result = FALSE;
goto _encDone;
}
// Alignment check
if(iEncFormat != prpEncOutputFormat_RGB)
{
if(iEncOutputWidth & 0x01)
{
DEBUGMSG(ZONE_ERROR,
(TEXT("%s: Error Channel-1 size, w (%d), h (%d)! \r\n"), __WFUNCTION__,
iEncOutputWidth, iEncOutputHeight));
result = FALSE;
goto _encDone;
}
}
// Set the frame height and width
channelParams.iHeight = iEncOutputHeight;
channelParams.iWidth = iEncOutputWidth;
// Pixel Burst rate always 16 unless we are using a rotation channel
channelParams.iPixelBurstCode = IDMAC_PIXEL_BURST_CODE_16;
channelParams.iBAM = 0;
// Set encoding channel parameters (IC->Mem for encoding)
PrpIDMACChannelConfig(0, &channelParams, iUBufOffset, iVBufOffset);
if (m_bEncFlipRot)
{
// Rotation/Flipping datapath
// First, allocate rotation buffers
if (!m_bEncRotBuffersAllocated)
{
PrpAllocateEncRotBuffers();
}
// Burst length is 8 for rotation channels
channelParams.iPixelBurstCode = IDMAC_PIXEL_BURST_CODE_8;
channelParams.iBAM = (configData->encFlipRot.verticalFlip ? 1 : 0) |
(configData->encFlipRot.horizontalFlip ? 1 : 0) << 1 |
(configData->encFlipRot.rotate90 ? 1 : 0) << 2;
// Set encoding channel parameters (Mem->IC for rotation)
PrpIDMACChannelConfig(10, &channelParams, iUBufOffset, iVBufOffset);
// If we are rotating, we must Reverse the width, height, and
// line stride for the image after rotation is complete.
if (configData->encFlipRot.rotate90)
{
tempWidth = channelParams.iWidth;
channelParams.iWidth = channelParams.iHeight;
channelParams.iHeight = tempWidth;
strideFactor = channelParams.iLineStride / tempWidth;
channelParams.iLineStride = strideFactor * channelParams.iWidth;
}
channelParams.iBAM = 0;
// Set encoding channel parameters (IC->Mem after rotation)
PrpIDMACChannelConfig(8, &channelParams, iUBufOffset, iVBufOffset);
}
else
{
// No rotation; data written to memory.
// Compute bitmask and shifted bit value for IPU_FS_PROC_FLOW register
iMask = CSP_BITFMASK(IPU_IPU_FS_PROC_FLOW_PRPENC_DEST_SEL);
iBitval = CSP_BITFVAL(IPU_IPU_FS_PROC_FLOW_PRPENC_DEST_SEL,
IPU_IPU_FS_PROC_FLOW_PRPENC_DEST_SEL_ARM);
// Configure frame synchronization
do
{
oldVal = INREG32(&P_IPU_REGS->IPU_FS_PROC_FLOW);
newVal = (oldVal & (~iMask)) | iBitval;
} while (InterlockedTestExchange((LPLONG)&P_IPU_REGS->IPU_FS_PROC_FLOW,
oldVal, newVal) != oldVal);
}
m_bEncConfigured = TRUE;
}
_encDone:
PRP_FUNCTION_EXIT();
return result;
}
//-----------------------------------------------------------------------------
//
// Function: PrpConfigureViewfinding
//
// This function configures the IC registers and IDMAC
// channels for the preprocessor viewfinding channel.
//
// Parameters:
// pPrpVfConfigureData
// [in] Pointer to configuration data structure
//
// Returns:
// TRUE if success
// FALSE if failure
//
//-----------------------------------------------------------------------------
BOOL PrpClass::PrpConfigureViewfinding(pPrpVfConfigData configData)
{
BOOL result = TRUE;
UINT16 iVfOutputWidth, iVfOutputHeight, tempWidth;
prpVfOutputFormat iVfFormat = configData->vfFormat;
prpIDMACChannelParams channelParams;
prpCSCCoeffs CSCCoeffs;
prpResizeCoeffs resizeCoeffs;
DISPLAY_SDC_FG_CONFIG_DATA displayConfig;
UINT32 strideFactor;
UINT32 oldVal, newVal, iMask, iBitval;
PRP_FUNCTION_ENTRY();
// Now, the viewfinding channel
if (iVfFormat != prpVfOutputFormat_Disabled)
{
// Configure rotation BAM parameter
channelParams.iBAM = (configData->vfFlipRot.verticalFlip ? 1 : 0) |
(configData->vfFlipRot.horizontalFlip ? 1 : 0) << 1 |
(configData->vfFlipRot.rotate90 ? 1 : 0) << 2;
m_bVfFlipRot = (channelParams.iBAM == 0) ? 0 : 1;
// Set these variables to reduce pointer computations,
// as these will be referenced several times.
iVfOutputWidth = configData->vfSize.width;
iVfOutputHeight = configData->vfSize.height;
// Check that requested width and height do not
// exceed width and height supported by display
if (m_displayCharacteristics.width < iVfOutputWidth)
{
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__, iVfOutputWidth, m_displayCharacteristics.width));
}
if (m_displayCharacteristics.height < iVfOutputHeight)
{
DEBUGMSG(ZONE_ERROR,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -