我找到了解决办法
//------------------------------------------------------------------------------
//
// Function: PP_CSC_YUV444_RGB888Test
//
// This function tests the Post-processor
//
//
//
// Parameters:
// uiMsg
// [in] Ignored.
//
// tpParam
// [in] Ignored.
//
// lpFTE
// [in] Ignored.
//
// Returns:
// Specifies if the test passed (TPR_PASS), failed (TPR_FAIL), or was
// skipped (TPR_SKIP).
//
//------------------------------------------------------------------------------
TESTPROCAPI PP_CSC_YUV444_RGB888Test(UINT uMsg, TPPARAM tpParam, LPFUNCTION_TABLE_ENTRY lpFTE)
{
UNREFERENCED_PARAMETER(tpParam);
UNREFERENCED_PARAMETER(lpFTE);
DWORD dwResult= TPR_SKIP;
ppConfigData ppData;
DWORD iInputBytesPerFrame, iOutputBytesPerFrame;
UINT32 iInputStride, iOutputStride;
UINT16 iOutputWidth, iOutputHeight, iOutputBPP;
UINT16 iInputWidth, iInputHeight, iInputBPP;
int iOption;
PP_TEST_FUNCTION_ENTRY();
// Validate that the shell wants the test to run
if (uMsg != TPM_EXECUTE)
{
return TPR_NOT_HANDLED;
}
PPTestInit();
RETAILMSG(1, (TEXT("===> YUV444->RGB888 TEST \r\n")));
iInputWidth = PP_TEST_FRAME_WIDTH;
iInputHeight = PP_TEST_FRAME_HEIGHT;
iInputBPP = 3;
iInputStride = iInputWidth * 3; // YUV444 is 24 bits per pixel
iOutputWidth = PP_TEST_FRAME_WIDTH;
iOutputHeight = PP_TEST_FRAME_HEIGHT;
iOutputBPP = 3; // for RGB888 case
iOutputStride = iOutputWidth * iOutputBPP;
RETAILMSG(1,(L"At %s, Input -> width = %u, height = %u \r\n",__WFUNCTION__,iInputWidth,iInputHeight));
RETAILMSG(1,(L"At %s, Output -> width = %u, height = %u \r\n",__WFUNCTION__,iOutputWidth,iOutputHeight));
//-----------------------------
// Configure PP
//-----------------------------
// Set up post-processing configuration data
memset(&ppData, 0 , sizeof(ppData));
// Set up input format and data width
ppData.inputIDMAChannel.FrameFormat = icFormat_YUV444;
ppData.inputIDMAChannel.DataWidth = icDataWidth_24BPP;
// dummy value for YUV
ppData.inputIDMAChannel.PixelFormat.component0_offset = 0;
ppData.inputIDMAChannel.PixelFormat.component1_offset = 8;
ppData.inputIDMAChannel.PixelFormat.component2_offset = 16;
ppData.inputIDMAChannel.PixelFormat.component3_offset = 24;
ppData.inputIDMAChannel.PixelFormat.component0_width = 8-1;
ppData.inputIDMAChannel.PixelFormat.component1_width = 8-1;
ppData.inputIDMAChannel.PixelFormat.component2_width = 8-1;
ppData.inputIDMAChannel.PixelFormat.component3_width = 0;
ppData.inputIDMAChannel.FrameSize.height = iInputHeight;
ppData.inputIDMAChannel.FrameSize.width = iInputWidth;
ppData.inputIDMAChannel.LineStride = iInputWidth ;
// Set up output format and data width
ppData.outputIDMAChannel.FrameFormat = icFormat_RGB;
ppData.outputIDMAChannel.DataWidth = icDataWidth_24BPP;
ppData.outputIDMAChannel.PixelFormat.component0_offset = 0;
ppData.outputIDMAChannel.PixelFormat.component1_offset = 8;
ppData.outputIDMAChannel.PixelFormat.component2_offset = 16;
ppData.outputIDMAChannel.PixelFormat.component3_offset = 24;
ppData.outputIDMAChannel.PixelFormat.component0_width = 7;
ppData.outputIDMAChannel.PixelFormat.component1_width = 7;
ppData.outputIDMAChannel.PixelFormat.component2_width = 7;
ppData.outputIDMAChannel.PixelFormat.component3_width = 0;
ppData.outputIDMAChannel.FrameSize.height = iOutputHeight;
ppData.outputIDMAChannel.FrameSize.width = iOutputWidth;
ppData.outputIDMAChannel.LineStride = iOutputWidth * 3;
ppData.CSCEquation = CSCY2R_A1;
ppData.inputIDMAChannel.UBufOffset = iInputHeight * iInputWidth;
ppData.inputIDMAChannel.VBufOffset = 2 * iInputHeight * iInputWidth;
// Allocate buffers for input and output frames
iInputBytesPerFrame = iInputStride * iInputHeight;
pInputFrameVirtAddr = (UINT32 *) AllocPhysMem(iInputBytesPerFrame, PAGE_EXECUTE_READWRITE, 0, 0, (ULONG *) &pInputFramePhysAddr);
iOutputBytesPerFrame = iOutputStride * iOutputHeight;
pOutputFrameVirtAddr = (UINT32 *) AllocPhysMem(iOutputBytesPerFrame, PAGE_EXECUTE_READWRITE, 0, 0, (ULONG *) &pOutputFramePhysAddr);
if ((NULL == pInputFrameVirtAddr) || (NULL == pOutputFrameVirtAddr))
{
dwResult = TPR_FAIL;
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
ppData.FlipRot.verticalFlip = FALSE;
ppData.FlipRot.horizontalFlip = FALSE;
ppData.FlipRot.rotate90 = FALSE;
if (!PPConfigure(hPP, &ppData))
{
dwResult = TPR_FAIL;
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
//-----------------------------
// Read first input buffer
//-----------------------------
// Read Input file for new frame
if (!ReadImage(PP_TEST_YUV444_FILENAME,pInputFrameVirtAddr,iInputBytesPerFrame,PP_TEST_FRAME_WIDTH,PP_TEST_FRAME_HEIGHT))
{
g_pKato->Log(PP_ZONE_ERROR, (TEXT("fail to ReadImage()!\r\n")));
dwResult = TPR_FAIL;
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
//-----------------------------
// Start PP
//-----------------------------
if (!PPStart(hPP))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPStart Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
if (!PPInterruptEnable(hPP, FRAME_INTERRUPT))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPInterruptEnable Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
//-----------------------------
// Queue Input/Output Buffers
//-----------------------------
UINT32 starttime = GetTickCount();
// Add input and output buffers to PP queues.
if (!PPAddInputBuffer(hPP, (UINT32) pInputFramePhysAddr))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPAddInputBuffer Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
RETAILMSG(1,(L"Input time = %dms",(GetTickCount() - starttime)));
UINT32 oTime = GetTickCount();
if (!PPAddOutputBuffer(hPP,(UINT32) pOutputFramePhysAddr))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPAddOutputBuffer Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
RETAILMSG(1,(L"Output time = %dms",(GetTickCount() - oTime)));
UINT32 waitTime = GetTickCount();
if (!PPWaitForNotBusy(hPP, FRAME_INTERRUPT))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPWaitForNotBusy Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
RETAILMSG(1,(L"Waiting time = %dms",(GetTickCount() - waitTime)));
RETAILMSG(1, (TEXT("===========FLIP TIME: %dms & %d---%d\r\n"),(GetTickCount() - starttime),starttime,GetTickCount()));
//-----------------------------
// Stop PP
//-----------------------------
if (!PPStop(hPP))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPStop Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
if (!PPClearBuffers(hPP))
{
dwResult = TPR_FAIL;
RETAILMSG(1, (TEXT("===========PPClearBuffers Failed \r\n")));
goto PP_CSC_YUV444_RGB888Test_clean_up;
}
ShowRGB888Content((UINT8 *) pOutputFrameVirtAddr, (PP_TEST_FRAME_WIDTH), (PP_TEST_FRAME_HEIGHT));
iOption = MessageBox( NULL,TEXT("After CSC(YUV444->RGB888). Is it correct?"),TEXT("Test result"),MB_YESNO );
if ( IDNO == iOption )
{
dwResult = TPR_FAIL;
}
else
{
dwResult = TPR_PASS;
}
PP_CSC_YUV444_RGB888Test_clean_up:
if(NULL != pInputFrameVirtAddr)
{
FreePhysMem( pInputFrameVirtAddr );
pInputFrameVirtAddr = NULL;
}
if(NULL != pOutputFrameVirtAddr)
{
FreePhysMem( pOutputFrameVirtAddr );
pOutputFrameVirtAddr = NULL;
}
PPTestDeInit();
return dwResult;
}