PDA

View Full Version : OMX State transition failing



barindam
02-16-2012, 08:22 AM
I am developing an application for hardware h.264 encoding in samsung galaxy sII phone. After doing OMX_GetParameter and OMX_SetParameter successfully when I am doing OMX_SendCommand for OMX_StateIdle it is failing with error code 0x80001000 (insufficient resource), also after that when I am trying OMX_AllocateBuffer it is giving error code 0x8001017. Any help on this will be great. Please find below the code for your reference.

OMX_PORT_PARAM_TYPE VideoPortParameters;

VideoPortParameters.nSize = sizeof(OMX_PORT_PARAM_TYPE);
VideoPortParameters.nVersion.s.nVersionMajor = 1;
VideoPortParameters.nVersion.s.nVersionMinor = 0;
VideoPortParameters.nVersion.s.nRevision = 0;
VideoPortParameters.nVersion.s.nStep = 0;
if(OMX_GetParameter(ComponentHandler, OMX_IndexParamVideoInit, &VideoPortParameters) == OMX_ErrorNone)
{
OMX_U32 nPorts = VideoPortParameters.nPorts;
OMX_U32 nStartPortNumber = VideoPortParameters.nStartPortNumber;
LOGI("nPorts = %d, nStartPortNumber = %d\n", nPorts, nStartPortNumber);
}
else
{
LOGI("OMX_GetParameter fails, Error Code:0x%x\n", OMXErrType);
}

OMX_PARAM_PORTDEFINITIONTYPE port_def;
OMX_VIDEO_PORTDEFINITIONTYPE * video = &port_def.format.video;
// configure input parameters
port_def.nSize = sizeof(port_def);
port_def.nPortIndex = 0;
port_def.nVersion.s.nVersionMajor = 1;
port_def.nVersion.s.nVersionMinor = 0;
port_def.nVersion.s.nRevision = 0;
port_def.nVersion.s.nStep = 0;
if(OMX_GetParameter(ComponentHandler, OMX_IndexParamPortDefinition, &port_def)!= OMX_ErrorNone)
{
LOGI("ErrorType:0x%x\n", OMXErrType);
LOGI("unable to get port %d definition.\n", port_def.nPortIndex);
}
//Set input Param
InBufCnt = port_def.nBufferCountActual;
video->nFrameWidth = 176;
video->nFrameHeight = 144;
video->nStride = 176;
//video->xFramerate = 25 << 16;
// default values, can optionally ignore
video->eColorFormat = OMX_COLOR_FormatYUV420Planar;
video->eCompressionFormat = OMX_VIDEO_CodingUnused;
in_buf_bytes = (176 * 144 * 3) / 2;
if(in_buf_bytes < port_def.nBufferSize)
in_buf_bytes = port_def.nBufferSize;

if(OMX_SetParameter(ComponentHandler, OMX_IndexParamPortDefinition, &port_def) != OMX_ErrorNone)
{
LOGI("unable to set port %d definition.\n", port_def.nPortIndex);
}

//Set output Param
port_def.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
port_def.nPortIndex = 1;
port_def.nVersion.s.nVersionMajor = 1;
port_def.nVersion.s.nVersionMinor = 0;
port_def.nVersion.s.nRevision = 0;
port_def.nVersion.s.nStep = 0;
if(OMX_GetParameter(ComponentHandler, OMX_IndexParamPortDefinition, &port_def) != OMX_ErrorNone)
{
LOGI("unable to get port %d definition.\n", port_def.nPortIndex);
}
OutBufCnt = port_def.nBufferCountActual;
video->nFrameWidth = 176;
video->nFrameHeight = 144;
video->nBitrate = 384000;
video->xFramerate = 25 << 16;
video->eCompressionFormat = OMX_VIDEO_CodingAVC;
out_buf_bytes = port_def.nBufferSize;

if(OMX_SetParameter(ComponentHandler, OMX_IndexParamPortDefinition, &port_def) != OMX_ErrorNone)
{
LOGI("unable to set port %d definition.\n", port_def.nPortIndex);
}

OMX_ERRORTYPE Err = OMX_ErrorNone;
OMX_VIDEO_PARAM_AVCTYPE H264Type;
H264Type.nSize = sizeof(OMX_VIDEO_PARAM_AVCTYPE);
H264Type.nVersion.s.nVersionMajor = 1;
H264Type.nVersion.s.nVersionMinor = 0;
H264Type.nVersion.s.nRevision = 0;
H264Type.nVersion.s.nStep = 0;
H264Type.nPortIndex = 1;
Err = OMX_GetParameter(ComponentHandler, OMX_IndexParamVideoAvc, &H264Type);
if (OMX_ErrorNone != Err)
{
LOGI("OMX Error Type:0x%x\n", Err);
LOGI("SetH264EncoderParameters OMX_IndexParamVideoAvc GetParameter Fails\n");
}




if(OMX_SendCommand(ComponentHandler, OMX_CommandStateSet,OMX_StateIdle, NULL) != OMX_ErrorNone)
{
LOGI("OMX Send Command: OMX_StateIdle Error\n");
}



Thanks
Arindam