void vcil_in_free_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen) { IL_FREE_BUFFER_EXECUTE_T *exe = call; IL_RESPONSE_HEADER_T *ret = resp; OMX_COMPONENTTYPE *pComp = exe->reference; OMX_BUFFERHEADERTYPE *pHeader; OMX_U8 *buffer; OMX_PARAM_PORTDEFINITIONTYPE def; OMX_ERRORTYPE error; def.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); def.nVersion.nVersion = OMX_VERSION; def.nPortIndex = exe->port; error = pComp->GetParameter(pComp, OMX_IndexParamPortDefinition, &def); vc_assert(error == OMX_ErrorNone); if (def.eDir == OMX_DirInput) pHeader = exe->inputPrivate; else pHeader = exe->outputPrivate; buffer = pHeader->pBuffer; *rlen = sizeof(IL_RESPONSE_HEADER_T); ret->func = IL_FREE_BUFFER; ret->err = pComp->FreeBuffer(pComp, exe->port, pHeader); if (ret->err == OMX_ErrorNone) vcos_free(buffer); }
static OMX_ERRORTYPE OMX_ConfigureDynamicPFramesInH264E( OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE * pBufferHdr, OMX_U32 nCurrentFrameRate, OMX_U32 nTargetFrameRate) { OMX_ERRORTYPE eError = OMX_ErrorNone; OMX_U32 remainder = 0; OMX_U16 nTargetPFrames =0; /* Target Pframes to be provided to Encoder */ OMX_U16 nCurrentPFrames = 0; /* Current pFrame Value configured to Encoder */ OMX_VIDEO_CONFIG_AVCINTRAPERIOD tPframeH264e; OMX_VIDEO_PARAM_AVCTYPE h264type; OMX_COMPONENTTYPE *pHandle; if (hComponent == NULL){ DOMX_ERROR("Component is invalid/ not present "); return OMX_ErrorBadParameter; } pHandle = (OMX_COMPONENTTYPE *) hComponent; /* Initialise the OMX structures */ OMX_INIT_STRUCT(tPframeH264e, OMX_VIDEO_CONFIG_AVCINTRAPERIOD); OMX_INIT_STRUCT(h264type,OMX_VIDEO_PARAM_AVCTYPE); /* Read number of B Frames if not read yet */ if(!nBFrames){ h264type.nPortIndex = 1; eError = pHandle->GetParameter(hComponent,OMX_IndexParamVideoAvc,&h264type); if(eError != OMX_ErrorNone) { DOMX_ERROR(" Error while reading component info = %d",eError); return eError; } nBFrames = h264type.nBFrames; } /* Read Current pFrames set in Encoder */ tPframeH264e.nPortIndex = 1; eError = pHandle->GetConfig(hComponent,OMX_IndexConfigVideoAVCIntraPeriod,&tPframeH264e); if(eError != OMX_ErrorNone) { DOMX_ERROR(" Error while Getting PFrame info, Error code = %d",eError); return eError; } nCurrentPFrames = tPframeH264e.nPFrames; /* Calculate Target P Frames */ nTargetPFrames = (nCurrentPFrames * nTargetFrameRate) /nCurrentFrameRate; /* Number of pFrames should be multiple of (B FRAMES + 1) */ remainder = nTargetPFrames % (nBFrames + 1); nTargetPFrames = nTargetPFrames - remainder; if(nTargetPFrames == nCurrentPFrames){ DOMX_INFO(" No Change in P Frames, No Update required"); return OMX_ErrorNone; } /* Update the new PFrames to the Encoder */ tPframeH264e.nPFrames = nTargetPFrames; eError = pHandle->SetConfig(hComponent,OMX_IndexConfigVideoAVCIntraPeriod,&tPframeH264e); if(eError != OMX_ErrorNone) { DOMX_ERROR(" Error while setting PFrame info, Error code = %d",eError); } return eError; }
void vcil_in_use_buffer(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen) { IL_ADD_BUFFER_EXECUTE_T *exe = call; IL_ADD_BUFFER_RESPONSE_T *ret = resp; OMX_COMPONENTTYPE *pComp = exe->reference; OMX_U8 *buffer; OMX_BUFFERHEADERTYPE *bufferHeader; *rlen = sizeof(IL_ADD_BUFFER_RESPONSE_T); buffer = vcos_malloc_aligned(exe->size, 32, "vcin mapping buffer"); // 32-byte aligned if (!buffer) { ret->err = OMX_ErrorInsufficientResources; return; } //OMX_OSAL_Trace(OMX_OSAL_TRACE_COMPONENT, "hostcomp: use buffer(%p)\n", buffer); ret->func = IL_USE_BUFFER; ret->err = pComp->UseBuffer(pComp, &bufferHeader, exe->port, exe->bufferReference, exe->size, buffer); if (ret->err == OMX_ErrorNone) { // we're going to pass this buffer to VC // initialise our private field in their copy with the host buffer reference OMX_PARAM_PORTDEFINITIONTYPE def; OMX_ERRORTYPE error; def.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE); def.nVersion.nVersion = OMX_VERSION; def.nPortIndex = exe->port; error = pComp->GetParameter(pComp, OMX_IndexParamPortDefinition, &def); vc_assert(error == OMX_ErrorNone); ret->reference = bufferHeader; memcpy(&ret->bufferHeader, bufferHeader, sizeof(OMX_BUFFERHEADERTYPE)); if (def.eDir == OMX_DirInput) ret->bufferHeader.pInputPortPrivate = bufferHeader; else ret->bufferHeader.pOutputPortPrivate = bufferHeader; } else vcos_free(buffer); }
void vcil_in_get_parameter(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen) { IL_GET_EXECUTE_T *exe = call; IL_GET_RESPONSE_T *ret = resp; OMX_COMPONENTTYPE *pComp = exe->reference; OMX_U32 size = *((OMX_U32 *) (&exe->param)); ret->func = IL_GET_PARAMETER; if(size > VC_ILCS_MAX_PARAM_SIZE) { *rlen = IL_GET_RESPONSE_HEADER_SIZE; ret->err = OMX_ErrorHardware; } else { *rlen = size + IL_GET_RESPONSE_HEADER_SIZE; ret->err = pComp->GetParameter(pComp, exe->index, exe->param); memcpy(ret->param, exe->param, size); } }