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.

Problem on Capturing pal/ntsc video from cvbs channel and encode+display to cvbs at low bitrate (50000bps)



Hi,

I am working on DM8148 , ti-ezsdk / omx_05_02_00_46

My project is to capture pal/ntsc intelaced from CVBS channel and displaying using CVBS output channel + encode.

For this, I used the ti example capture_encode that uses the components:Cap, Dei, Enc, Dis and for displaying to CVBS

I added the component Noise Filter (between DEI (port0) and Dis components. Because 420 is needed for displaying cvbs.

when I worked with bit rate 1000000bps, it works well.  but when when I work at 50000bps on the output (by skiping frames

by the capture component). The Display was not good.but when working without noisefilter i.e. output-hdmi  low bitrate - It works O.K

OMX_ERRORTYPE IL_ClientSetNfParams (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_INIT_PARAM (&memTypeCfg);
memTypeCfg.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;
eError =
OMX_SetParameter (pAppData->pNfHandle, 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->pNfHandle, 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->pNfHandle, OMX_IndexParamPortDefinition,
&paramPort);
paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
paramPort.format.video.nFrameWidth = pAppData->nInWidth;
paramPort.format.video.nFrameHeight = pAppData->nInHeight;

/* Scalar is connceted to H264 decoder, whose stride is different than width*/
paramPort.format.video.nStride = pAppData->nInWidth * 2;
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr;
paramPort.nBufferSize = (paramPort.format.video.nStride *
paramPort.format.video.nFrameHeight);

paramPort.nBufferAlignment = 0;
paramPort.bBuffersContiguous = 0;
paramPort.nBufferCountActual = IL_CLIENT_NF_INPUT_BUFFER_COUNT;
printf ("set input port params (width = %u, height = %u) \n",
(unsigned int) pAppData->nInWidth, (unsigned int) pAppData->nInHeight);
OMX_SetParameter (pAppData->pNfHandle, 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->pNfHandle, OMX_IndexParamPortDefinition,
&paramPort);

paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
paramPort.format.video.nFrameWidth = pAppData->nInWidth;
paramPort.format.video.nFrameHeight = pAppData->nInHeight;
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
paramPort.nBufferAlignment = 0;
paramPort.bBuffersContiguous = 0;
paramPort.nBufferCountActual = IL_CLIENT_NF_OUTPUT_BUFFER_COUNT;
/* scalar buffer pitch should be multiple of 16 */
paramPort.format.video.nStride = pAppData->nInWidth;

paramPort.nBufferSize =
(paramPort.format.video.nStride * paramPort.format.video.nFrameHeight * 3 )>> 1;

printf ("set output port params (width = %d, height = %d) \n",
(int) paramPort.format.video.nFrameWidth,
(int) paramPort.format.video.nFrameHeight);

OMX_SetParameter (pAppData->pNfHandle, OMX_IndexParamPortDefinition,
&paramPort);

/* set number of channles */
printf ("set number of channels \n");

OMX_INIT_PARAM (&sNumChPerHandle);
sNumChPerHandle.nNumChannelsPerHandle = 1;
eError =
OMX_SetParameter (pAppData->pNfHandle,
(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 \n");

OMX_INIT_PARAM (&chResolution);
chResolution.Frm0Width = pAppData->nInWidth;
chResolution.Frm0Height = pAppData->nInHeight;
chResolution.Frm0Pitch = pAppData->nInWidth * 2;
chResolution.Frm1Width = 0;
chResolution.Frm1Height = 0;
chResolution.Frm1Pitch = 0;
chResolution.FrmStartX = 0;
chResolution.FrmStartY = 0;
chResolution.FrmCropWidth = 0;
chResolution.FrmCropHeight = 0;
chResolution.eDir = OMX_DirInput;
chResolution.nChId = 0;

eError =
OMX_SetConfig (pAppData->pNfHandle,
(OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution,
&chResolution);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set input channel resolution\n");
}

printf ("set output resolution \n");
OMX_INIT_PARAM (&chResolution);
chResolution.Frm0Width = pAppData->nInWidth;
chResolution.Frm0Height = pAppData->nInHeight;
chResolution.Frm0Pitch = pAppData->nInWidth;
chResolution.Frm1Width = 0;
chResolution.Frm1Height = 0;
chResolution.Frm1Pitch = 0;
chResolution.FrmStartX = 0;
chResolution.FrmStartY = 0;
chResolution.FrmCropWidth = 0;
chResolution.FrmCropHeight = 0;
chResolution.eDir = OMX_DirOutput;
chResolution.nChId = 0;

eError =
OMX_SetConfig (pAppData->pNfHandle,
(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;
algEnable.bAlgBypass = 0;

eError =
OMX_SetConfig (pAppData->pNfHandle,
(OMX_INDEXTYPE) OMX_TI_IndexConfigAlgEnable, &algEnable);
if (eError != OMX_ErrorNone)
ERROR ("failed to disable algo by pass mode\n");

return (eError);
}

 

OMX_ERRORTYPE IL_ClientSetDisplayParams (IL_Client *pAppData)
{
OMX_ERRORTYPE eError = OMX_ErrorNone;
OMX_PARAM_BUFFER_MEMORYTYPE memTypeCfg;
OMX_PARAM_PORTDEFINITIONTYPE paramPort;
OMX_PARAM_VFPC_NUMCHANNELPERHANDLE sNumChPerHandle;
OMX_PARAM_VFDC_DRIVERINSTID driverId;
OMX_PARAM_VFDC_CREATEMOSAICLAYOUT mosaicLayout;
OMX_CONFIG_VFDC_MOSAICLAYOUT_PORT2WINMAP port2Winmap;
OMX_U32 displayId;

OMX_INIT_PARAM (&paramPort);

/* set input height/width and color format */
paramPort.nPortIndex = OMX_VFDC_INPUT_PORT_START_INDEX;

OMX_GetParameter (pAppData->pDisHandle, OMX_IndexParamPortDefinition,
&paramPort);
displayId = pAppData->displayId;


paramPort.nPortIndex = OMX_VFDC_INPUT_PORT_START_INDEX;
paramPort.format.video.nFrameWidth = pAppData->nInWidth;
paramPort.format.video.nFrameHeight = pAppData->nInHeight;
paramPort.format.video.nStride = pAppData->nInWidth * 2;
paramPort.nBufferCountActual = IL_CLIENT_DISPLAY_INPUT_BUFFER_COUNT;
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYCbYCr;

paramPort.nBufferSize = paramPort.format.video.nStride * pAppData->nInHeight;

if (2 == displayId)
{
/*For the case of On-chip HDMI as display device*/

paramPort.format.video.nStride = pAppData->nInWidth;
/* The SD display accepts 420SP buffers at input port*/
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
paramPort.nBufferSize = ((paramPort.format.video.nStride *
paramPort.format.video.nFrameHeight) * 3 ) >> 1;
}

OMX_SetParameter (pAppData->pDisHandle, OMX_IndexParamPortDefinition,
&paramPort);


/* --------------------------------------------------------------------------*
Supported display IDs by VFDC and DC are below The names will be renamed in
future releases as some of the driver names & interfaces will be changed in
future @ param OMX_VIDEO_DISPLAY_ID_HD0: 422P On-chip HDMI @ param
OMX_VIDEO_DISPLAY_ID_HD1: 422P HDDAC component output @ param
OMX_VIDEO_DISPLAY_ID_SD0: 420T/422T SD display (NTSC): Not supported yet.
------------------------------------------------------------------------ */

/* set the parameter to the disaply component to 1080P @60 mode */
OMX_INIT_PARAM (&driverId);
/* Configured to use on-chip HDMI */


if (0 == displayId) {
/* Configured to use on-chip HDMI */
driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_HD0;

/* Depending on the mode parameter set via cmd line, set the mode*/
if ((pAppData->nOutWidth == 1280)&&(pAppData->nOutHeight == 720)&& (pAppData->nOutScanningSystem == PROGRESSIVE_E))

driverId.eDispVencMode = OMX_DC_MODE_720P_60;
else if ((pAppData->nOutWidth == 1920)&&(pAppData->nOutHeight == 1080)&& (pAppData->nOutScanningSystem == PROGRESSIVE_E))
driverId.eDispVencMode = OMX_DC_MODE_1080P_60;
else
driverId.eDispVencMode = OMX_DC_MODE_720P_60;


}

else if (1 == displayId) {
/* Configured to use LCD Display */
driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_HD1;
driverId.eDispVencMode = DISPLAY_VENC_MODE;
}
else if (2 == displayId)
{
/* Configured to composite display*/
driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_SD0;
driverId.eDispVencMode = OMX_DC_MODE_NTSC;
}
else
{
ERROR ("Incorrect Display Id configured\n");
}


eError = OMX_SetParameter (pAppData->pDisHandle,
(OMX_INDEXTYPE) OMX_TI_IndexParamVFDCDriverInstId,
&driverId);

if (eError != OMX_ErrorNone)
{
ERROR ("failed to set driver mode to 1080P@60\n");
}

/* set the parameter to the disaply controller component to 1080P @60 mode */
OMX_INIT_PARAM (&driverId);
/* Configured to use on-chip HDMI */

if (0 == displayId) {
/* Configured to use on-chip HDMI */
driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_HD0;

/* Depending on the mode parameter set via cmd line, set the mode*/
if ((pAppData->nOutWidth == 1280)&&(pAppData->nOutHeight == 720)&& (pAppData->nOutScanningSystem == PROGRESSIVE_E))
driverId.eDispVencMode = OMX_DC_MODE_720P_60;
else if ((pAppData->nOutWidth == 1920)&&(pAppData->nOutHeight == 1080)&& (pAppData->nOutScanningSystem == PROGRESSIVE_E))
driverId.eDispVencMode = OMX_DC_MODE_1080P_60;
else
driverId.eDispVencMode = OMX_DC_MODE_720P_60;
}
else if (1 == displayId) {
/* Configured to use LCD Display */
driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_HD1;

driverId.eDispVencMode = DISPLAY_VENC_MODE;
}
else if (2 == displayId)
{
/* Configured to composite display*/
driverId.nDrvInstID = OMX_VIDEO_DISPLAY_ID_SD0;
if (pAppData->nOutHeight == PAL_E)
{
driverId.eDispVencMode = OMX_DC_MODE_PAL;
}
else if (pAppData->nOutHeight == NTSC_E)
{
driverId.eDispVencMode = OMX_DC_MODE_NTSC;
}
}
else {
ERROR ("Incorrect Display Id configured\n");
}


eError = OMX_SetParameter (pAppData->pctrlHandle,
(OMX_INDEXTYPE) OMX_TI_IndexParamVFDCDriverInstId,
&driverId);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set driver mode to 1080P@60\n");
}
/* XXX DAVID */
#if 1
if (1 == displayId) {
IL_ClientSetSecondaryDisplayParams(pAppData);
}
#endif
/* set mosaic layout info */

OMX_INIT_PARAM (&mosaicLayout);
/* Configuring the first (and only) window */
mosaicLayout.sMosaicWinFmt[0].winStartX = 0;
mosaicLayout.sMosaicWinFmt[0].winStartY = 0;
mosaicLayout.sMosaicWinFmt[0].winWidth = pAppData->nInWidth;
mosaicLayout.sMosaicWinFmt[0].winHeight = pAppData->nInHeight;
mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] =
pAppData->nInWidth * 2;

mosaicLayout.sMosaicWinFmt[0].dataFormat = VFDC_DF_YUV422I_YVYU;
mosaicLayout.sMosaicWinFmt[0].bpp = VFDC_BPP_BITS16;
mosaicLayout.sMosaicWinFmt[0].priority = 0;
mosaicLayout.nDisChannelNum = 0;
/* Only one window in this layout, hence setting it to 1 */
mosaicLayout.nNumWindows = 1;

if (1 == displayId) {
/* For secondary Display, start the window at (0,0), since it is
scaled to display device size */
mosaicLayout.sMosaicWinFmt[0].winStartX = 0;
mosaicLayout.sMosaicWinFmt[0].winStartY = 0;

/*If LCD is chosen, fir the mosaic window to the size of the LCD display*/

mosaicLayout.sMosaicWinFmt[0].winWidth = pAppData->nInWidth;
mosaicLayout.sMosaicWinFmt[0].winHeight = pAppData->nInHeight;
mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] = pAppData->nInWidth * 2;
// mosaicLayout.sMosaicWinFmt[0].winInWidth = DISPLAY_WIDTH;
// mosaicLayout.sMosaicWinFmt[0].winInHeight = DISPLAY_HEIGHT;
// mosaicLayout.sMosaicWinFmt[0].pitch[VFDC_YUV_INT_ADDR_IDX] = DISPLAY_WIDTH * 2;

}

if ((0 == displayId) || (1 == displayId))
{

eError = OMX_SetParameter (pAppData->pDisHandle, (OMX_INDEXTYPE)
OMX_TI_IndexParamVFDCCreateMosaicLayout,
&mosaicLayout);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to set mosaic window parameter\n");
}

/* map OMX port to window */
OMX_INIT_PARAM (&port2Winmap);
/* signifies the layout id this port2win mapping refers to */
port2Winmap.nLayoutId = 0;
/* Just one window in this layout, hence setting the value to 1 */
port2Winmap.numWindows = 1;
/* Only 1st input port used here */
port2Winmap.omxPortList[0] = OMX_VFDC_INPUT_PORT_START_INDEX + 0;

eError = OMX_SetConfig (pAppData->pDisHandle,
(OMX_INDEXTYPE)
OMX_TI_IndexConfigVFDCMosaicPort2WinMap,
&port2Winmap);
if (eError != OMX_ErrorNone)
{
ERROR ("failed to map port to windows\n");
}
}


/* Setting Memory type at input port to Raw Memory */
printf ("setting input and output memory type to default\n");
OMX_INIT_PARAM (&memTypeCfg);
memTypeCfg.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
memTypeCfg.eBufMemoryType = OMX_BUFFER_MEMORY_DEFAULT;

eError = OMX_SetParameter (pAppData->pDisHandle, OMX_TI_IndexParamBuffMemType,
&memTypeCfg);

if (eError != OMX_ErrorNone)
{
ERROR ("failed to set memory Type at input port\n");
}

}

Best Regards,

Nitza