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.

quesion about omx nf component

Hi,

My qusition is that my input video is 1920* 1080 yuv422,and I want to chage it to nv12. so I use the Nf component.but I find that sometimes there will be get a green frame. how to solve it?

the set omx nf code is under this: the m_inWidth =1920, the m_inHeight=1080.

bool setNfParams() {
if (NULL == m_pNfHandle) {
return false;
}
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 (m_pNfHandle, (OMX_INDEXTYPE)OMX_TI_IndexParamBuffMemType, &memTypeCfg);

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

/* 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 (m_pNfHandle, (OMX_INDEXTYPE)OMX_TI_IndexParamBuffMemType, &memTypeCfg);

if (eError != OMX_ErrorNone) {
printf("failed to set memory Type at output port\n");
return false;
}

/* set input height/width and color format */
OMX_INIT_PARAM(&paramPort);
paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;

OMX_GetParameter(m_pNfHandle, OMX_IndexParamPortDefinition, &paramPort);
paramPort.nPortIndex = OMX_VFPC_INPUT_PORT_START_INDEX;
paramPort.format.video.nFrameWidth = UTIL_ALIGN(m_inWidth, 32);
paramPort.format.video.nFrameHeight = UTIL_ALIGN(m_inHeight, 32);

paramPort.format.video.nStride = UTIL_ALIGN(m_inWidth * 2, 32);
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 = OMX_FALSE;
paramPort.nBufferCountActual = KOtherComponentInOutPutNum;
OMX_SetParameter(m_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(m_pNfHandle, OMX_IndexParamPortDefinition, &paramPort);

paramPort.nPortIndex = OMX_VFPC_OUTPUT_PORT_START_INDEX;
paramPort.format.video.nFrameWidth = UTIL_ALIGN(m_inWidth, 32);
paramPort.format.video.nFrameHeight = UTIL_ALIGN(m_inHeight, 32);
paramPort.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
paramPort.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
paramPort.nBufferAlignment = 0;
paramPort.bBuffersContiguous = OMX_FALSE;
paramPort.nBufferCountActual = KOtherComponentInOutPutNum;
paramPort.format.video.nStride = UTIL_ALIGN(m_inWidth, 32);
paramPort.nBufferSize = (paramPort.format.video.nStride * paramPort.format.video.nFrameHeight * 3) >> 1;

OMX_SetParameter(m_pNfHandle, OMX_IndexParamPortDefinition, &paramPort);

OMX_INIT_PARAM(&sNumChPerHandle);
sNumChPerHandle.nNumChannelsPerHandle = 1;
eError = OMX_SetParameter (m_pNfHandle, (OMX_INDEXTYPE) OMX_TI_IndexParamVFPCNumChPerHandle, &sNumChPerHandle);
if (eError != OMX_ErrorNone) {
printf("failed to set num of channels\n");
return false;
}

/* set VFPC input and output resolution information */
printf("set input resolution \n");


OMX_INIT_PARAM(&chResolution);
chResolution.Frm0Width = UTIL_ALIGN(m_inWidth, 32);
chResolution.Frm0Height = UTIL_ALIGN(m_inHeight, 32);
chResolution.Frm0Pitch = UTIL_ALIGN(m_inWidth * 2, 32);
chResolution.Frm1Width = 0;
chResolution.Frm1Height = 0;
chResolution.Frm1Pitch = 0;
chResolution.FrmStartX = 0;
chResolution.FrmStartY = 0;
chResolution.FrmCropWidth = m_inWidth;
chResolution.FrmCropHeight = m_inHeight;
chResolution.eDir = OMX_DirInput;
chResolution.nChId = 0;

eError = OMX_SetConfig (m_pNfHandle, (OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution, &chResolution);
if (eError != OMX_ErrorNone) {
printf("failed to set input channel resolution\n");
}

printf("set output resolution \n");
OMX_INIT_PARAM(&chResolution);
chResolution.Frm0Width = UTIL_ALIGN(m_inWidth, 32);
chResolution.Frm0Height = UTIL_ALIGN(m_inHeight, 32);
chResolution.Frm0Pitch = UTIL_ALIGN(m_inWidth, 32);
chResolution.Frm1Width = 0;
chResolution.Frm1Height = 0;
chResolution.Frm1Pitch = 0;

chResolution.FrmStartX = 0;
chResolution.FrmStartY = 0;
chResolution.FrmCropWidth = m_inWidth;
chResolution.FrmCropHeight = m_inHeight;
chResolution.eDir = OMX_DirOutput;
chResolution.nChId = 0;

eError = OMX_SetConfig (m_pNfHandle, (OMX_INDEXTYPE) OMX_TI_IndexConfigVidChResolution, &chResolution);
if (eError != OMX_ErrorNone) {
printf("failed to set output channel resolution\n");
return false;
}

/* disable algo bypass mode */
OMX_INIT_PARAM(&algEnable);
algEnable.nPortIndex = 0;
algEnable.nChId = 0;
algEnable.bAlgBypass = OMX_FALSE;
OMX_INIT_PARAM(&algEnable);

eError = OMX_SetConfig (m_pNfHandle, (OMX_INDEXTYPE) OMX_TI_IndexConfigAlgEnable, &algEnable);

return true;
}

and the empty this buffer is like this:

int size = 1920*1080*2;

read(InportParamsPtr->ipBufPipe[0], &pBufferIn, sizeof(pBufferIn));

OMX_PTR pTempPhyAddr = (OMX_PTR) DomxCore_mapUsrVirtualAddr2phy( (uint32_t) pBufferIn->pBuffer);

m_pKernel->getEdmaInstance()->copy((unsigned char*)pTempPhyAddr, pPhyAddr,
m_inWidth * 2, m_inWidth * 2, size, 1);

pBufferIn->nFilledLen = size;

err = OMX_EmptyThisBuffer (m_pNfHandle, pBufferIn);

Thanks for your reply!!