This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DEI in capture_encode example in EZSDK 5.03



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 (&paramPort);
paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;

OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
&paramPort);
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,
&paramPort);

/* set output height/width and color format */
OMX_INIT_PARAM (&paramPort);
paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
&paramPort);

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,
&paramPort);

OMX_INIT_PARAM (&paramPort);
paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX + 1;
OMX_GetParameter (pAppData->pDeiHandle, OMX_IndexParamPortDefinition,
&paramPort);

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,
&paramPort);

/* 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");
}
}

  • Gabi,

    DEI would not provide both o/ps as 420SP. It can provide only one o/p of 420sp format. 

    Regards

    Vimal

  • Hi Vimal,

    Thank you very much for your response.
    This is very disappointing. Is there a reason for that the DEI can't provide both o/ps as 420SP? Do you intend to change this in next versions? 
    Is there a way to connect an output from OMX component into 2 different inputs?

    Thanks,
    Gabi 

  • Gabi,

    This is a hardware restriction. The second scalar output only has a 422interleaved path back to memory. The solution to your problem is to use a Noise Filter OMX component to do the 422I to 420SP transformation. Search for OMX_NSF_BYPASS_MODE_SNF_TNF in OMX User Guide. 

    Iain

  • Hi Iain,

    Thanks you very much for your answer, i still have an unsolved issue with this answer, if i am using a DEI with 2 outputs that one is scaled by 0.25 in horizontal and vertical  and is in 420 format and the other also scaled by 0.25 in horizontal and vertical and is in 422 format and then i use the Noise Filter OMX component to convert the data from 422 to 420, will the data will be exactly the same in both sides? because it very important to my algorithm.

    Thanks,
    Gabi 

  • Hi,

    I am trying to implement this same solution, but keep receiving  the error: OMX_ErrorInsufficientResources after Allocating buffers and before the Noise Filter component comes to the IDLE state. I am working with ezsdk 5.04. Is it a settings problem or is related to the HW issue ?

    Thanks.

    Ignacio.

  • Hi,

    We identified an issue with NF, where It can not be instantiated, and would show up the issue,as you observed. Next release, we will provide fix for this.

    Thanks

    Vimal

  • Hi Vimal,

    Thanks you very much for your answer, i still have an unsolved issue with this use case, if i am using a DEI with 2 outputs that one is scaled by 0.25 in horizontal and vertical  and is in 420 format and the other also scaled by 0.25 in horizontal and vertical and is in 422 format and then i use the Noise Filter OMX component to convert the data from 422 to 420, will the data will be exactly the same in both sides? because it very important to my algorithm.

    Thanks,
    Gabi