Hi,
I am using EZSDK ver 5.03, i have modified the capture_encode example that it will have Cap->DEI->DEI2->display. when DEI second output port goes to the encoder.
I have changed the first output port of the DEI from 422 output to 420 output and scaling 1/4 in width and 1/4 in height and the conversion from 420 to 422 before the display is done on the DEI2.
I have changed the parameters of the DEI first output port according to the second DEI output port in the function IL_ClientSetDeiParams in the file ilclient_utils.c but the output for some reason remains in 422 format. Please see below.
Can anyone please advice?
Thanks,
Gabi
OMX_ERRORTYPE IL_ClientSetDeiParams (IL_Client *pAppData)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_PARAM_BUFFER_MEMORYTYPE memTypeCfg;
OMX_PARAM_PORTDEFINITIONTYPE paramPort;
OMX_PARAM_VFPC_NUMCHANNELPERHANDLE sNumChPerHandle;
OMX_CONFIG_ALG_ENABLE algEnable;
OMX_CONFIG_VIDCHANNEL_RESOLUTION chResolution;
OMX_CONFIG_SUBSAMPLING_FACTOR sSubSamplinginfo;
OMX_INIT_PARAM (&memTypeCfg);
memTypeCfg.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
eError = OMX_SetParameter (pAppData->pDeiHandle, OMX_TI_IndexParamBuffMemType,
&memTypeCfg);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set memory Type at input port\n");
}
/* Setting Memory type at output port to Raw Memory */
OMX_INIT_PARAM (&memTypeCfg);
memTypeCfg.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
eError = OMX_SetParameter (pAppData->pDeiHandle, OMX_TI_IndexParamBuffMemType,
&memTypeCfg);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set memory Type at output port\n");
}
OMX_INIT_PARAM (&memTypeCfg);
memTypeCfg.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
eError = OMX_SetParameter (pAppData->pDeiHandle, OMX_TI_IndexParamBuffMemType,
&memTypeCfg);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set memory Type at output port\n");
}
/* set input height/width and color format */
OMX_INIT_PARAM (¶mPort);
paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
¶mPort);
paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
paramPort.format.video.nFrameWidth = pAppData->nWidth;
if ( pAppData->vidDetectStatus.isInterlaced ) {
paramPort.format.video.nFrameHeight = pAppData->nHeight/2;
} else {
paramPort.format.video.nFrameHeight = pAppData->nHeight;
}
paramPort.format.video.nStride = pAppData->nWidth;
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
paramPort.nBufferSize =
((paramPort.format.video.nStride * paramPort.format.video.nFrameHeight * 3) >> 1);
paramPort.nBufferAlignment = 0;
paramPort.bBuffersContiguous = 0;
paramPort.nBufferCountActual = IL_CLIENT_DEI_INPUT_BUFFER_COUNT;
printf ("set input port params (width = %u, height = %u) \n",
pAppData->nWidth, paramPort.format.video.nFrameHeight);
OMX_SetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
¶mPort);
/* set output height/width and color format */
OMX_INIT_PARAM (¶mPort);
paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
¶mPort);
paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
paramPort.format.video.nFrameWidth = (pAppData->nWidth>>2);
paramPort.format.video.nFrameHeight = (pAppData->nHeight>>2);
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.nBufferAlignment = 0;
paramPort.bBuffersContiguous = 0;
paramPort.nBufferCountActual = IL_CLIENT_DEI_OUTPUT_BUFFER_COUNT;
/* This port is connected to display and provides 422 o/p */
paramPort.format.video.nStride = (pAppData->nWidth>>2);
paramPort.nBufferSize = ((paramPort.format.video.nStride *
paramPort.format.video.nFrameHeight*3)>>1);
printf ("set output port params (width = %d, height = %d)\n", paramPort.format.video.nFrameWidth,
paramPort.format.video.nFrameHeight);
OMX_SetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
¶mPort);
OMX_INIT_PARAM (¶mPort);
paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
¶mPort);
paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
paramPort.format.video.nFrameWidth = pAppData->nWidth ;
paramPort.format.video.nFrameHeight = pAppData->nHeight;
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.nBufferAlignment = 0;
paramPort.bBuffersContiguous = 0;
paramPort.nBufferCountActual = IL_CLIENT_DEI_OUTPUT_BUFFER_COUNT;
paramPort.format.video.nStride = pAppData->nWidth;
paramPort.nBufferSize = ((paramPort.format.video.nStride *
paramPort.format.video.nFrameHeight*3)>>1);
printf ("set output port params (width = %d, height = %d)\n", paramPort.format.video.nFrameWidth,
paramPort.format.video.nFrameHeight);
OMX_SetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
¶mPort);
/* set number of channles */
printf ("set number of channels");
OMX_INIT_PARAM (&sNumChPerHandle);
sNumChPerHandle.nNumChannelsPerHandle = 1;
eError = OMX_SetParameter (pAppData->pDeiHandle,
(OMX_INDEXTYPE)
OMX_TI_IndexParamVFPCNumChPerHandle,
&sNumChPerHandle);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set num of channels\n");
}
/* set VFPC input and output resolution information */
printf ("set input resolution");
OMX_INIT_PARAM (&chResolution);
chResolution.Frm0Width = pAppData->nWidth;
if ( pAppData->vidDetectStatus.isInterlaced )
{
chResolution.Frm0Height = pAppData->nHeight/2;
}
else
{
chResolution.Frm0Height = pAppData->nHeight;
}
chResolution.Frm0Pitch = pAppData->nWidth;;
chResolution.Frm1Width = 0;
chResolution.Frm1Height = 0;
chResolution.Frm1Pitch = 0;
chResolution.FrmStartX = 0;
chResolution.FrmStartY = 0;
chResolution.FrmCropWidth = pAppData->nWidth;
if ( pAppData->vidDetectStatus.isInterlaced )
{
chResolution.FrmCropHeight = pAppData->nHeight/2;
}
else
{
chResolution.FrmCropHeight = pAppData->nHeight;
}
chResolution.eDir = OMX_DirInput;
chResolution.nChId = 0;
eError = OMX_SetConfig (pAppData->pDeiHandle,
(OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution,
&chResolution);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set input channel resolution\n");
}
printf ("set output resolution");
OMX_INIT_PARAM (&chResolution);
/* first output to display */
chResolution.Frm0Width = (pAppData->nWidth>>2);
chResolution.Frm0Height = (pAppData->nHeight>>2);
chResolution.Frm0Pitch = (pAppData->nWidth>>2);
/* second output to encode */
chResolution.Frm1Width = pAppData->nWidth;
chResolution.Frm1Height = pAppData->nHeight;
chResolution.Frm1Pitch = pAppData->nWidth;
chResolution.FrmStartX = 0;
chResolution.FrmStartY = 0;
chResolution.FrmCropWidth = 0;
chResolution.FrmCropHeight = 0;
chResolution.eDir = OMX_DirOutput;
chResolution.nChId = 0;
eError = OMX_SetConfig (pAppData->pDeiHandle,
(OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution,
&chResolution);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set output channel resolution\n");
}
/* disable algo bypass mode */
OMX_INIT_PARAM (&algEnable);
algEnable.nPortIndex = 0;
algEnable.nChId = 0;
if ( pAppData->vidDetectStatus.isInterlaced )
{
/* capture providing interlaced input, alg is not bypassed */
algEnable.bAlgBypass = 0;
}
else
{
/* capture providing progressive input, alg is bypassed */
algEnable.bAlgBypass = 1;
}
eError = OMX_SetConfig (pAppData->pDeiHandle,
(OMX_INDEXTYPE) OMX_TI_IndexConfigAlgEnable,
&algEnable);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to disable algo by pass mode\n");
}
OMX_INIT_PARAM(&sSubSamplinginfo);
sSubSamplinginfo.nSubSamplingFactor = pAppData->deiSubSampleFactor;
eError = OMX_SetConfig ( pAppData->pDeiHandle, ( OMX_INDEXTYPE )
( OMX_TI_IndexConfigSubSamplingFactor ),
&sSubSamplinginfo );
fprintf( stderr, "Set DEI subsampling %u\n", sSubSamplinginfo.nSubSamplingFactor );
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set subsampling\n");
}
}