summaryrefslogtreecommitdiff
path: root/omx/videodecode
diff options
context:
space:
mode:
Diffstat (limited to 'omx/videodecode')
-rw-r--r--omx/videodecode/Android.mk52
-rw-r--r--omx/videodecode/omx_h264_dec/inc/omx_h264vd.h67
-rw-r--r--omx/videodecode/omx_h264_dec/src/omx_h264dec.c721
-rw-r--r--omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h68
-rw-r--r--omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c451
-rw-r--r--omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h71
-rw-r--r--omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c422
-rw-r--r--omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h258
-rw-r--r--omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h47
-rw-r--r--omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h101
-rw-r--r--omx/videodecode/omx_videodec_common/src/omx_video_decoder.c1726
-rw-r--r--omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c33
-rw-r--r--omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c946
13 files changed, 0 insertions, 4963 deletions
diff --git a/omx/videodecode/Android.mk b/omx/videodecode/Android.mk
deleted file mode 100644
index 105b5b1..0000000
--- a/omx/videodecode/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-
-#
-# libOMX.TI.DUCATI1.VIDEO.DECODER.so
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_C_INCLUDES += \
- frameworks/native/include/media/openmax \
- $(LOCAL_PATH)/../base/omx_core/inc \
- $(LOCAL_PATH)/../osal/inc \
- $(LOCAL_PATH)/../base/omx_base_comp/inc \
- $(LOCAL_PATH)/../base/omx_base_dio_plugin/inc \
- hardware/libhardware/include \
- hardware/ti/dra7xx/hwcomposer/ \
- hardware/ti/dce/ \
- $(LOCAL_PATH)/omx_videodec_common/inc/ \
- $(LOCAL_PATH)/omx_h264_dec/inc/ \
- $(LOCAL_PATH)/omx_mpeg4_dec/inc/ \
- $(LOCAL_PATH)/omx_mpeg2_dec/inc/ \
- hardware/ti/dce/packages/codec_engine/ \
- hardware/ti/dce/packages/framework_components/ \
- hardware/ti/dce/packages/ivahd_codecs/ \
- hardware/ti/dce/packages/xdais/ \
- hardware/ti/dce/packages/xdctools
-
-LOCAL_HEADER_LIBRARIES += libutils_headers
-
-LOCAL_SHARED_LIBRARIES := \
- libosal \
- libc \
- liblog \
- libOMX \
- libhardware \
- libdce
-
-LOCAL_CFLAGS += -Dxdc_target_types__=google/targets/arm/std.h -DBUILDOS_ANDROID -Dxdc__deprecated_types
-
-LOCAL_MODULE_TAGS:= optional
-
-LOCAL_SRC_FILES:= omx_videodec_common/src/omx_video_decoder.c \
- omx_videodec_common/src/omx_video_decoder_componenttable.c \
- omx_videodec_common/src/omx_video_decoder_internal.c \
- omx_h264_dec/src/omx_h264dec.c \
- omx_mpeg4_dec/src/omx_mpeg4dec.c \
- omx_mpeg2_dec/src/omx_mpeg2dec.c
-
-LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.DECODER
-LOCAL_VENDOR_MODULE := true
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/omx/videodecode/omx_h264_dec/inc/omx_h264vd.h b/omx/videodecode/omx_h264_dec/inc/omx_h264vd.h
deleted file mode 100644
index b01a3ed..0000000
--- a/omx/videodecode/omx_h264_dec/inc/omx_h264vd.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _OMX_H264VD_H_
-#define _OMX_H264VD_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <omx_video_decoder.h>
-#include <ti/sdo/codecs/h264vdec/ih264vdec.h>
-
-/*! Padding for width as per Codec Requirement */
- #define PADX (32)
-/*! Padding for height as per Codec requirement */
- #define PADY (24)
-
-/** Default Frame skip H264 Decoder */
-#define H264VD_DEFAULT_FRAME_SKIP IVIDEO_SKIP_DEFAULT
-
-
-static OMX_ERRORTYPE OMXH264VD_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-static OMX_ERRORTYPE OMXH264VD_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-void OMXH264VD_Set_StaticParams(OMX_HANDLETYPE hComponent, void *staticparams);
-
-void OMXH264VD_Set_DynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams);
-
-void OMXH264VD_Set_Status(OMX_HANDLETYPE hComponent, void *status);
-
-OMX_ERRORTYPE OMXH264VD_HandleError(OMX_HANDLETYPE hComponent);
-
-PaddedBuffParams CalculateH264VD_outbuff_details(OMX_HANDLETYPE hComponent,
- OMX_U32 width, OMX_U32 height);
-
-extern OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent);
-extern void OMXH264VD_DeInit(OMX_HANDLETYPE hComponent);
-extern OMX_U32 OMXH264VD_Calculate_TotalRefFrames(OMX_U32 nWidth, OMX_U32 nHeight, OMX_VIDEO_AVCLEVELTYPE eLevel);
-
-typedef struct OMXH264VidDecComp {
- OMX_VIDEO_PARAM_AVCTYPE tH264VideoParam;
-} OMXH264VidDecComp;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _OMX_H2644VD_NEW_H_ */
-
diff --git a/omx/videodecode/omx_h264_dec/src/omx_h264dec.c b/omx/videodecode/omx_h264_dec/src/omx_h264dec.c
deleted file mode 100644
index 18e7889..0000000
--- a/omx/videodecode/omx_h264_dec/src/omx_h264dec.c
+++ /dev/null
@@ -1,721 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "OMX_H264_VIDDEC"
-
-#include <omx_h264vd.h>
-#include <omx_video_decoder_internal.h>
-
-#define OMX_MAX_DEC_OP_BUFFERS 20
-
-OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXH264VidDecComp *pH264VidDecComp = NULL;
- IVIDDEC3_Params *pDecParams;
- IH264VDEC_Params *params;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- /*! Initialize the function parameters for OMX functions */
- pHandle->SetParameter = OMXH264VD_SetParameter;
- pHandle->GetParameter = OMXH264VD_GetParameter;
-
- /*! Initialize the function pointers */
- pVidDecComp->fpSet_StaticParams = OMXH264VD_Set_StaticParams;
- pVidDecComp->fpSet_DynamicParams = OMXH264VD_Set_DynamicParams;
- pVidDecComp->fpSet_Status = OMXH264VD_Set_Status;
- pVidDecComp->fpCalc_OubuffDetails
- = CalculateH264VD_outbuff_details;
- pVidDecComp->fpDeinit_Codec = OMXH264VD_DeInit;
- pVidDecComp->cDecoderName = "ivahd_h264dec";
- pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingAVC;
- pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused;
- pVidDecComp->fpHandle_ExtendedError = OMXH264VD_HandleError;
-
- pVidDecComp->pCodecSpecific =
- (OMXH264VidDecComp *) OSAL_Malloc(sizeof (OMXH264VidDecComp));
- OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources);
-
- pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific;
-
- OMX_BASE_INIT_STRUCT_PTR(&(pH264VidDecComp->tH264VideoParam), OMX_VIDEO_PARAM_AVCTYPE);
- pH264VidDecComp->tH264VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT;
- pH264VidDecComp->tH264VideoParam.eProfile = OMX_VIDEO_AVCProfileHigh;
- pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel41;
- pH264VidDecComp->tH264VideoParam.nRefFrames = 0xFFFFFFFF;
-
- /*! Allocate Memory for Static Parameter */
- pVidDecComp->pDecStaticParams
- = (IVIDDEC3_Params *) memplugin_alloc(sizeof(IH264VDEC_Params), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IH264VDEC_Params));
-
- params = (IH264VDEC_Params *) (pVidDecComp->pDecStaticParams);
- pDecParams = &(params->viddec3Params);
- pDecParams->displayDelay = IVIDDEC3_DISPLAY_DELAY_AUTO;
- params->presetLevelIdc = IH264VDEC_LEVEL41;
- params->dpbSizeInFrames = IH264VDEC_DPB_NUMFRAMES_AUTO;
-
- /*! Allocate Memory for Dynamic Parameter */
- pVidDecComp->pDecDynParams
- = (IVIDDEC3_DynamicParams *) memplugin_alloc(sizeof(IH264VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IH264VDEC_DynamicParams));
-
- /*! Allocate Memory for Status Structure */
- pVidDecComp->pDecStatus
- = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IH264VDEC_Status), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IH264VDEC_Status));
- ((IH264VDEC_Status *)pVidDecComp->pDecStatus)->spsMaxRefFrames = 1;
-
- /*! Allocate Memory for Input Arguments */
- pVidDecComp->pDecInArgs
- = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IH264VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IH264VDEC_InArgs));
-
- /*! Allocate Memory for Output Arguments */
- pVidDecComp->pDecOutArgs
- = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IH264VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IH264VDEC_OutArgs));
-
- pVidDecComp->pDecInArgs->size = sizeof(IH264VDEC_InArgs);
- pVidDecComp->pDecOutArgs->size = sizeof(IH264VDEC_OutArgs);
-
- pDecParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
- pDecParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
- pDecParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
-
- pDecParams->operatingMode = IVIDEO_DECODE_ONLY;
- pDecParams->inputDataMode = IVIDEO_ENTIREFRAME;
- pDecParams->numInputDataUnits = 0;
-
-EXIT:
- return (eError);
-}
-
-
-void OMXH264VD_Set_StaticParams(OMX_HANDLETYPE hComponent, void *staticparams)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- IVIDDEC3_Params *pDecParams;
- IH264VDEC_Params *params = (IH264VDEC_Params *)staticparams;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- pDecParams = &(params->viddec3Params);
- pDecParams->size = sizeof(IH264VDEC_Params);
- pDecParams->maxWidth = 1920;
- pDecParams->maxHeight = 1088;
- pDecParams->maxFrameRate = 30000;
- pDecParams->maxBitRate = 10000000;
- pDecParams->dataEndianness = XDM_BYTE;
-
- /*init outArgs IVIDDEC3_OutArgs*/
- pDecParams->forceChromaFormat = XDM_YUV_420SP;
- pDecParams->displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
- pDecParams->outputDataMode = IVIDEO_ENTIREFRAME;
- pDecParams->numOutputDataUnits = 0;
- pDecParams->errorInfoMode = IVIDEO_ERRORINFO_OFF;
- params->errConcealmentMode =
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment;
-
- params->temporalDirModePred = IH264VDEC_ENABLE_TEMPORALDIRECT;
- params->debugTraceLevel= 0;
- params->lastNFramesToLog= 0;
-
- return;
-}
-
-
-void OMXH264VD_Set_DynamicParams(OMX_HANDLETYPE hComponent, void *dynParams)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- IVIDDEC3_DynamicParams *pDecDynParams;
- IH264VDEC_DynamicParams *params = (IH264VDEC_DynamicParams *) dynParams;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pDecDynParams = &(params->viddec3DynamicParams);
- pDecDynParams->size = sizeof(IVIDDEC3_DynamicParams);
-
- /* init dynamic params IVIDDEC3_DynamicParams */
- pDecDynParams->decodeHeader = XDM_DECODE_AU; /* Supported */
-
- pDecDynParams->displayWidth = 0; /* Not Supported: Set default */
- /*Not Supported: Set default*/
- pDecDynParams->frameSkipMode = H264VD_DEFAULT_FRAME_SKIP;
- pDecDynParams->newFrameFlag = XDAS_TRUE; //Not Supported: Set default
-
- if( ((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME )
- {
- pDecDynParams->putBufferFxn = NULL;
- pDecDynParams->putBufferHandle = NULL;
- pDecDynParams->putDataFxn = NULL;
- pDecDynParams->putDataHandle = NULL;
- pDecDynParams->getDataHandle = NULL;
- pDecDynParams->getDataFxn = NULL;
- }
-
- return;
-}
-
-/**/
-void OMXH264VD_Set_Status(OMX_HANDLETYPE hComponent, void *decstatus)
-{
- IH264VDEC_Status *status;
- (void)hComponent;
-
- status = (IH264VDEC_Status *)decstatus;
- status->viddec3Status.size = sizeof(IH264VDEC_Status);
- return;
-}
-
-PaddedBuffParams CalculateH264VD_outbuff_details(OMX_HANDLETYPE hComponent, OMX_U32 width, OMX_U32 height)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXH264VidDecComp *pH264VidDecComp = NULL;
- OMX_U32 nRefBufferCount=16;
- IH264VDEC_Status *pDecStatus = NULL;
- IH264VDEC_Params *staticparams;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific;
-
- pDecStatus = (IH264VDEC_Status *)(pVidDecComp->pDecStatus);
-
- PaddedBuffParams OutBuffDetails;
- OutBuffDetails.nBufferSize
- = ((((width + (2 * PADX) + 127) & 0xFFFFFF80) * (height + 4 * PADY)));
- /* Multiply buffer size by 1.5 to account for both luma and chroma */
- OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1;
- OutBuffDetails.nBufferCountMin = OMXH264VD_Calculate_TotalRefFrames(width, height, pH264VidDecComp->tH264VideoParam.eLevel);
- staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams);
-
- /* Assume 0 ref frames initially only if IL client is using port reconfig for allocating padded buffers.
- * In that case use the correct ref frames at the time of port reconfig to calculate nBufferCountMin/Actual.
- */
- if( pDecStatus->spsMaxRefFrames != 0 || pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) {
- if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) {
- staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER;
- } else {
- staticparams->viddec3Params.displayDelay = pDecStatus->spsMaxRefFrames;
- }
-
- staticparams->dpbSizeInFrames = pDecStatus->spsMaxRefFrames;
- pH264VidDecComp->tH264VideoParam.nRefFrames = pDecStatus->spsMaxRefFrames;
- if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) {
- /*Base profile*/
- OutBuffDetails.nBufferCountMin = pDecStatus->spsMaxRefFrames + 1;
- } else {
- /* High Profile */
- OutBuffDetails.nBufferCountMin = 2 * pDecStatus->spsMaxRefFrames + 1;
- }
- } else if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) {
- if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) {
- OutBuffDetails.nBufferCountMin = OMXH264VD_Calculate_TotalRefFrames
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- pH264VidDecComp->tH264VideoParam.eLevel);
- } else {
- nRefBufferCount = OMXH264VD_Calculate_TotalRefFrames
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- pH264VidDecComp->tH264VideoParam.eLevel) - 1;
- if((2 * nRefBufferCount + 1) < OMX_MAX_DEC_OP_BUFFERS ) {
- OutBuffDetails.nBufferCountMin = 2 * nRefBufferCount + 1;
- } else {
- OutBuffDetails.nBufferCountMin = OMX_MAX_DEC_OP_BUFFERS; //Cap max buffers to 20
- }
- }
- } else if( pH264VidDecComp->tH264VideoParam.nRefFrames <= 16 ) {
- if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) {
- OutBuffDetails.nBufferCountMin = pH264VidDecComp->tH264VideoParam.nRefFrames + 1;
- } else {
- OutBuffDetails.nBufferCountMin = 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1;
- }
- }
- OutBuffDetails.nBufferCountActual = OutBuffDetails.nBufferCountMin + 2;
- OutBuffDetails.n1DBufferAlignment = 16;
- OutBuffDetails.nPaddedWidth = (width + (2 * PADX) + 127) & 0xFFFFFF80;
- OutBuffDetails.nPaddedHeight = height + 4 * PADY;
- OutBuffDetails.n2DBufferYAlignment = 1;
- OutBuffDetails.n2DBufferXAlignment = 16;
-
- return (OutBuffDetails);
-}
-
-
-void OMXH264VD_DeInit(OMX_HANDLETYPE hComponent)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- /*! Delete all the memory which was allocated during init of decoder */
- if( pVidDecComp->pDecStaticParams ) {
- memplugin_free(pVidDecComp->pDecStaticParams);
- pVidDecComp->pDecStaticParams = NULL;
- }
- if( pVidDecComp->pDecDynParams ) {
- memplugin_free(pVidDecComp->pDecDynParams);
- pVidDecComp->pDecDynParams = NULL;
- }
- if( pVidDecComp->pDecStatus ) {
- memplugin_free(pVidDecComp->pDecStatus);
- pVidDecComp->pDecStatus = NULL;
- }
- if( pVidDecComp->pDecInArgs ) {
- memplugin_free(pVidDecComp->pDecInArgs);
- pVidDecComp->pDecInArgs = NULL;
- }
- if( pVidDecComp->pDecOutArgs ) {
- memplugin_free(pVidDecComp->pDecOutArgs);
- pVidDecComp->pDecOutArgs = NULL;
- }
- if( pVidDecComp->pCodecSpecific ) {
- OSAL_Free(pVidDecComp->pCodecSpecific);
- pVidDecComp->pCodecSpecific = NULL;
- }
- pHandle->SetParameter = OMXVidDec_SetParameter;
- pHandle->GetParameter = OMXVidDec_GetParameter;
- pVidDecComp->fpHandle_ExtendedError = NULL;
-}
-
-
-OMX_U32 OMXH264VD_Calculate_TotalRefFrames(OMX_U32 nWidth, OMX_U32 nHeight, OMX_VIDEO_AVCLEVELTYPE eLevel)
-{
- OMX_U32 ref_frames = 0;
- OMX_U32 MaxDpbMbs;
- OMX_U32 PicWidthInMbs;
- OMX_U32 FrameHeightInMbs;
-
- switch( eLevel ) {
- case OMX_VIDEO_AVCLevel1 :
- case OMX_VIDEO_AVCLevel1b :
- {
- MaxDpbMbs = 396;
- break;
- }
-
- case OMX_VIDEO_AVCLevel11 :
- {
- MaxDpbMbs = 900;
- break;
- }
-
- case OMX_VIDEO_AVCLevel12 :
- case OMX_VIDEO_AVCLevel13 :
- case OMX_VIDEO_AVCLevel2 :
- {
- MaxDpbMbs = 2376;
- break;
- }
-
- case OMX_VIDEO_AVCLevel21 :
- {
- MaxDpbMbs = 4752;
- break;
- }
-
- case OMX_VIDEO_AVCLevel22 :
- case OMX_VIDEO_AVCLevel3 :
- {
- MaxDpbMbs = 8100;
- break;
- }
-
- case OMX_VIDEO_AVCLevel31 :
- {
- MaxDpbMbs = 18000;
- break;
- }
-
- case OMX_VIDEO_AVCLevel32 :
- {
- MaxDpbMbs = 20480;
- break;
- }
-
- case OMX_VIDEO_AVCLevel5 :
- {
- MaxDpbMbs = 110400; //Maximum value for upto level 5
- break;
- }
-
- case OMX_VIDEO_AVCLevel51 :
- {
- MaxDpbMbs = 184320; //Maximum value for upto level 5.1
- break;
- }
-
- default :
- {
- MaxDpbMbs = 32768; //Maximum value for upto level 4.1
- }
- }
-
- PicWidthInMbs = nWidth / 16;
- FrameHeightInMbs = nHeight / 16;
- ref_frames = (OMX_U32)(MaxDpbMbs / (PicWidthInMbs * FrameHeightInMbs));
-
- ref_frames = (ref_frames > 16) ? 16 : ref_frames;
-
- /* Three is added to total reference frames because of the N+3 buffer issue
- * It was found that theoretically 2N+1 buffers are required but from a practical
- * point of view N+3 was sufficient */
- return (ref_frames + 1);
-}
-
-
-OMX_ERRORTYPE OMXH264VD_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXH264VidDecComp *pH264VidDecComp = NULL;
- OMX_VIDEO_PARAM_AVCTYPE *pH264VideoParam = NULL;
- OMX_U32 nRefBufferCount = 0;
- OMX_U8 i;
- IH264VDEC_Params *staticparams;
-
- OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL),
- OMX_ErrorBadParameter);
-
- /*! Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pH264VidDecComp = (OMXH264VidDecComp *) pVidDecComp->pCodecSpecific;
- staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams);
-
- switch( nIndex ) {
- case OMX_IndexParamVideoAvc :
- {
- pH264VideoParam = (OMX_VIDEO_PARAM_AVCTYPE *) pParamStruct;
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) ||
- (pVidDecComp->sBase.pPorts[pH264VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
- OMX_ErrorIncorrectStateOperation);
-
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError);
- OMX_CHECK(pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline
- || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileMain
- || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileExtended
- || pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileHigh,
- OMX_ErrorUnsupportedSetting);
- OMX_CHECK(pH264VideoParam->eLevel <= OMX_VIDEO_AVCLevel51,
- OMX_ErrorUnsupportedSetting);
- if( pH264VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- pH264VidDecComp->tH264VideoParam = *pH264VideoParam;
- } else if( pH264VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoAvc supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- goto EXIT;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- ALOGE("Profile set = %x, Level Set = %x, num ref frames set = %d",
- pH264VideoParam->eProfile, pH264VideoParam->eLevel, pH264VideoParam->nRefFrames);
- if( pH264VideoParam->eLevel == OMX_VIDEO_AVCLevel5 ) {
- staticparams->presetLevelIdc = IH264VDEC_LEVEL5;
- } else if( pH264VideoParam->eLevel == OMX_VIDEO_AVCLevel51 ) {
- staticparams->presetLevelIdc = IH264VDEC_LEVEL51;
- }
- if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) {
- if( pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline ) {
- staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER;
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin =
- OMXH264VD_Calculate_TotalRefFrames(
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- pH264VideoParam->eLevel);
- } else {
- nRefBufferCount = OMXH264VD_Calculate_TotalRefFrames
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- pH264VideoParam->eLevel) - 1;
-
- if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) {
- staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER;
- } else {
- staticparams->viddec3Params.displayDelay = nRefBufferCount;
- }
-
- if((2 * nRefBufferCount + 1) < OMX_MAX_DEC_OP_BUFFERS ) {
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin
- = 2 * nRefBufferCount + 1;
- } else {
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin
- = OMX_MAX_DEC_OP_BUFFERS; //Cap max buffers to 20
- }
- }
- } else if( pH264VidDecComp->tH264VideoParam.nRefFrames <= 16 ) {
- staticparams->dpbSizeInFrames = pH264VidDecComp->tH264VideoParam.nRefFrames;
- if( pH264VideoParam->eProfile == OMX_VIDEO_AVCProfileBaseline ) {
- staticparams->viddec3Params.displayDelay
- = IVIDDEC3_DECODE_ORDER;
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin
- = pH264VidDecComp->tH264VideoParam.nRefFrames + 1;
- } else {
- if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) {
- staticparams->viddec3Params.displayDelay
- = IVIDDEC3_DECODE_ORDER;
- } else {
- staticparams->viddec3Params.displayDelay
- = pH264VidDecComp->tH264VideoParam.nRefFrames;
- }
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin =
- 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1;
- }
- } else {
- OSAL_ErrorTrace("Invalid value of nRefFrames = %d of the structure OMX_VIDEO_PARAM_AVCTYPE provided ",
- pH264VidDecComp->tH264VideoParam.nRefFrames);
- }
- }
- break;
-
- case OMX_IndexParamVideoProfileLevelQuerySupported :
- {
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded,
- OMX_ErrorIncorrectStateOperation);
- /* Check for the correct nSize & nVersion information */
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
- /*As of now do nothing. This i ndex is required for StdVideoDecoderTest. Later on do code review and fill in proper code here.*/
- eError = OMX_ErrorNoMore;
- }
- break;
-
- case OMX_IndexParamVideoProfileLevelCurrent :
- {
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded,
- OMX_ErrorIncorrectStateOperation);
- /* Check for the correct nSize & nVersion information */
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
- /*As of now do nothing. This index is required for StdVideoDecoderTest. Later on do code review and fill in proper code here.*/
- eError = OMX_ErrorNoMore;
- }
- break;
-
- default :
- eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-
-OMX_ERRORTYPE OMXH264VD_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXH264VidDecComp *pH264VidDecComp = NULL;
- OMX_VIDEO_PARAM_AVCTYPE *pH264VideoParam = NULL;
- OMX_VIDEO_PARAM_PROFILELEVELTYPE *pH264ProfileLevelParam = NULL;
-
-
- OMX_CHECK((hComponent != NULL) &&
- (pParamStruct != NULL), OMX_ErrorBadParameter);
-
- // Initialize the local variables
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- pH264VidDecComp = (OMXH264VidDecComp *) pVidDecComp->pCodecSpecific;
-
- /* GetParameter can't be invoked incase the comp is in Invalid State */
- OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid,
- OMX_ErrorIncorrectStateOperation);
-
- switch( nIndex ) {
- case OMX_IndexParamVideoAvc :
- {
- pH264VideoParam = (OMX_VIDEO_PARAM_AVCTYPE *) pParamStruct;
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError);
- if( pH264VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- *pH264VideoParam = pH264VidDecComp->tH264VideoParam;
- } else if( pH264VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoAvc supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- }
- break;
-
- case OMX_IndexParamVideoProfileLevelQuerySupported :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
- pH264ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct;
- if( pH264ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- if( pH264ProfileLevelParam->nProfileIndex == 0 ) {
- pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileBaseline;
- pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41;
- } else if( pH264ProfileLevelParam->nProfileIndex == 1 ) {
- pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileMain;
- pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41;
- } else if( pH264ProfileLevelParam->nProfileIndex == 2 ) {
- pH264ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_AVCProfileHigh;
- pH264ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_AVCLevel41;
- } else {
- eError = OMX_ErrorNoMore;
- }
- } else if( pH264ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- }
- break;
-
- case OMX_IndexParamVideoProfileLevelCurrent :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
- eError = OMX_ErrorNoMore;
- }
- break;
-
- case OMX_IndexParamVideoMacroblocksPerFrame :
- {
- OMX_U32 MBwidth = 0, MBheight = 0;
- /* Check for the correct nSize & nVersion information */
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_MACROBLOCKSTYPE, eError);
- MBwidth = (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth) / 16;
- MBwidth = MBwidth + ((pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth) % 16);
- MBheight = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight / 16;
- MBheight = MBheight + ((pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight) % 16);
- ((OMX_PARAM_MACROBLOCKSTYPE *)(pParamStruct))->nMacroblocks = MBwidth * MBheight;
- }
- break;
-
- default :
- eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-/* */
-OMX_ERRORTYPE OMXH264VD_HandleError(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_U32 nRefFramesOld, nRefFrames41, nRefFrames5;
- OMXH264VidDecComp *pH264VidDecComp = NULL;
- IH264VDEC_Params *staticparams = NULL;
- IH264VDEC_Status *pDecStatus = NULL;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_U32 nBufferCountMin_old = 0;
-
- /* Initialize pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- staticparams = (IH264VDEC_Params *)(pVidDecComp->pDecStaticParams);
- pH264VidDecComp =(OMXH264VidDecComp *) pVidDecComp->pCodecSpecific;
-
- pDecStatus = (IH264VDEC_Status *)(pVidDecComp->pDecStatus);
- if( pH264VidDecComp->tH264VideoParam.nRefFrames == 0xFFFFFFFF ) {
- nRefFramesOld = OMXH264VD_Calculate_TotalRefFrames
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- pH264VidDecComp->tH264VideoParam.eLevel) - 1;
- } else {
- nRefFramesOld = pH264VidDecComp->tH264VideoParam.nRefFrames;
- }
- nRefFrames41 = OMXH264VD_Calculate_TotalRefFrames
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- OMX_VIDEO_AVCLevel41) - 1;
- nRefFrames5 = OMXH264VD_Calculate_TotalRefFrames
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
- OMX_VIDEO_AVCLevel5) - 1;
- nBufferCountMin_old = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin;
- if( pDecStatus->spsMaxRefFrames > nRefFramesOld ) {
- ALOGE("spsMaxRefFrames = %d, nRefFrames set initially = %d",
- (OMX_U32)pDecStatus->spsMaxRefFrames, pH264VidDecComp->tH264VideoParam.nRefFrames);
- pH264VidDecComp->tH264VideoParam.nRefFrames
- = pDecStatus->spsMaxRefFrames;
- staticparams->dpbSizeInFrames
- = pDecStatus->spsMaxRefFrames;
- staticparams->viddec3Params.displayDelay
- = pDecStatus->spsMaxRefFrames;
- if( pH264VidDecComp->tH264VideoParam.eProfile == OMX_VIDEO_AVCProfileBaseline ) {
- staticparams->viddec3Params.displayDelay = IVIDDEC3_DECODE_ORDER;
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin
- = pH264VidDecComp->tH264VideoParam.nRefFrames + 1;
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountActual
- = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin + 2;
- } else {
- if (pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE) {
- staticparams->viddec3Params.displayDelay
- = IVIDDEC3_DECODE_ORDER;
- } else {
- staticparams->viddec3Params.displayDelay = pDecStatus->spsMaxRefFrames;
- }
-
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin
- = 2 * pH264VidDecComp->tH264VideoParam.nRefFrames + 1;
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountActual
- = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin + 2;
- }
- if( pDecStatus->spsMaxRefFrames > nRefFrames5 ) {
- pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel51;
- staticparams->presetLevelIdc = IH264VDEC_LEVEL51;
- OSAL_ErrorTrace("Resetting level of the stream to Level 5.1");
- pVidDecComp->nCodecRecreationRequired = 1;
- pVidDecComp->nOutPortReconfigRequired = 1;
- } else if( pDecStatus->spsMaxRefFrames > nRefFrames41 ) {
- pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel5;
- staticparams->presetLevelIdc = IH264VDEC_LEVEL5;
- OSAL_ErrorTrace("Resetting level of the stream to Level 5");
- pVidDecComp->nCodecRecreationRequired = 1;
- pVidDecComp->nOutPortReconfigRequired = 1;
- } else if( pDecStatus->spsMaxRefFrames > nRefFramesOld ) {
- pH264VidDecComp->tH264VideoParam.eLevel = OMX_VIDEO_AVCLevel41;
- OSAL_ErrorTrace("Resetting level of the stream to Level 4.1");
- }
- if( pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin
- > nBufferCountMin_old ) {
- OSAL_ErrorTrace("nBufferCountMin_old = %d, nBufferCountMin_new = %d",
- nBufferCountMin_old, pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.nBufferCountMin);
- pVidDecComp->nOutPortReconfigRequired = 1;
- pVidDecComp->nCodecRecreationRequired = 1;
- }
- }
-
- return (eError);
-}
-
diff --git a/omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h b/omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h
deleted file mode 100644
index 4f489f0..0000000
--- a/omx/videodecode/omx_mpeg2_dec/inc/omx_mpeg2dec.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _OMX_MPEG2DEC_H_
-#define _OMX_MPEG2DEC_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/******************************************************************
- * INCLUDE FILES
- ******************************************************************/
-#include <omx_video_decoder.h>
-#include <ti/sdo/codecs/mpeg2vdec/impeg2vdec.h>
-
-
-void OMXMPEG2VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams);
-
-void OMXMPEG2VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams);
-
-void OMXMPEG2VD_SetStatus(OMX_HANDLETYPE hComponent, void *status);
-
-PaddedBuffParams CalculateMPEG2VD_outbuff_details(OMX_HANDLETYPE hComponent,
- OMX_U32 width, OMX_U32 height);
-
-/*---------- function prototypes ------------------- */
-extern OMX_ERRORTYPE OMX_TI_VideoDecoder_ComponentInit(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent);
-void OMXMPEG2VD_DeInit(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXMPEG2VD_HandleError(OMX_HANDLETYPE hComponent);
-
-extern OMX_ERRORTYPE OMXMPEG2VD_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-extern OMX_ERRORTYPE OMXMPEG2VD_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-extern OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-extern OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-
-typedef struct OMXMPEG2VidDecComp {
- OMX_PARAM_DEBLOCKINGTYPE tDeblockingParam;
- OMX_VIDEO_PARAM_MPEG2TYPE tMPEG2VideoParam;
-} OMXMPEG2VidDecComp;
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* _OMX_MPEG2DEC_H_ */
-
diff --git a/omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c b/omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c
deleted file mode 100644
index c9e8954..0000000
--- a/omx/videodecode/omx_mpeg2_dec/src/omx_mpeg2dec.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "OMX_MPEG2_VIDDEC"
-
-#include <omx_mpeg2dec.h>
-
-
-OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- /*! Initialize the function parameters for OMX functions */
- pHandle->SetParameter = OMXMPEG2VD_SetParameter;
- pHandle->GetParameter = OMXMPEG2VD_GetParameter;
-
- /*! Initialize the function pointers */
- pVidDecComp->fpSet_StaticParams = OMXMPEG2VD_SetStaticParams;
- pVidDecComp->fpSet_DynamicParams = OMXMPEG2VD_SetDynamicParams;
- pVidDecComp->fpSet_Status = OMXMPEG2VD_SetStatus;
- pVidDecComp->fpCalc_OubuffDetails = CalculateMPEG2VD_outbuff_details;
- pVidDecComp->fpDeinit_Codec = OMXMPEG2VD_DeInit;
- pVidDecComp->cDecoderName = "ivahd_mpeg2vdec";
-
- pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingMPEG2;
- pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused;
-
- pVidDecComp->fpHandle_ExtendedError = OMXMPEG2VD_HandleError;
-
- pVidDecComp->pCodecSpecific =
- (OMXMPEG2VidDecComp *) OSAL_Malloc(sizeof (OMXMPEG2VidDecComp));
- OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources);
-
- pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific;
-
- OMX_BASE_INIT_STRUCT_PTR(&(pMPEG2VidDecComp->tDeblockingParam), OMX_PARAM_DEBLOCKINGTYPE);
- pMPEG2VidDecComp->tDeblockingParam.nPortIndex = OMX_VIDDEC_OUTPUT_PORT;
- pMPEG2VidDecComp->tDeblockingParam.bDeblocking = OMX_FALSE;
-
-
- OMX_BASE_INIT_STRUCT_PTR(&(pMPEG2VidDecComp->tMPEG2VideoParam), OMX_VIDEO_PARAM_MPEG2TYPE);
- pMPEG2VidDecComp->tMPEG2VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT;
- pMPEG2VidDecComp->tMPEG2VideoParam.eProfile = OMX_VIDEO_MPEG2ProfileMain;
- pMPEG2VidDecComp->tMPEG2VideoParam.eLevel = OMX_VIDEO_MPEG2LevelML;
-
- /*! Allocate Memory for Static Parameter */
- pVidDecComp->pDecStaticParams = (IVIDDEC3_Params *)memplugin_alloc(sizeof(IMPEG2VDEC_Params), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IMPEG2VDEC_Params));
-
- /*! Allocate Memory for Dynamic Parameter */
- pVidDecComp->pDecDynParams = (IVIDDEC3_DynamicParams *)memplugin_alloc(sizeof(IMPEG2VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IMPEG2VDEC_DynamicParams));
-
- /*! Allocate Memory for Status Structure */
- pVidDecComp->pDecStatus = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IMPEG2VDEC_Status), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IMPEG2VDEC_Status));
-
- /*! Allocate Memory for Input Arguments */
- pVidDecComp->pDecInArgs = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IMPEG2VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IMPEG2VDEC_InArgs));
-
- /*! Allocate Memory for Output Arguments */
- pVidDecComp->pDecOutArgs = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IMPEG2VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IMPEG2VDEC_OutArgs));
-
- pVidDecComp->pDecInArgs->size = sizeof(IMPEG2VDEC_InArgs);
- pVidDecComp->pDecOutArgs->size = sizeof(IMPEG2VDEC_OutArgs);
-
- pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
- pVidDecComp->pDecStaticParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
- pVidDecComp->pDecStaticParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
-
- pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_DECODE_ONLY; //IVIDEO_TRANSCODE_FRAMELEVEL; //
-
- pVidDecComp->pDecStaticParams->inputDataMode = IVIDEO_ENTIREFRAME;
- pVidDecComp->pDecStaticParams->numInputDataUnits = 0;
-
-
-EXIT:
- return (eError);
-
-}
-
-void OMXMPEG2VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL;
- IMPEG2VDEC_Params *params;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp
- = (OMXVidDecComp *)pHandle->pComponentPrivate;
- p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]);
-
- pMPEG2VidDecComp =
- (OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific;
-
- params = (IMPEG2VDEC_Params *) staticparams;
-
- params->viddecParams.size = sizeof(IMPEG2VDEC_Params);
-
- params->viddecParams.maxWidth = p2DOutBufAllocParam->nWidth;
-
- params->viddecParams.maxFrameRate = 30000;
-
- params->viddecParams.maxBitRate = 10000000;
-
- params->viddecParams.dataEndianness = XDM_BYTE;
- params->viddecParams.forceChromaFormat = XDM_YUV_420SP;
- params->viddecParams.displayDelay = IVIDDEC3_DISPLAY_DELAY_1;
- params->viddecParams.inputDataMode = IVIDEO_ENTIREFRAME;
- params->viddecParams.numInputDataUnits = 0;
- params->viddecParams.numOutputDataUnits = 0;
- params->viddecParams.outputDataMode = IVIDEO_ENTIREFRAME;
- params->viddecParams.displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
-
- params->viddecParams.errorInfoMode = IVIDEO_ERRORINFO_OFF;
-
- params->outloopDeBlocking = pMPEG2VidDecComp->tDeblockingParam.bDeblocking;
- params->ErrorConcealmentON = pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment;
- /* If ErrorConcealmentON, then metadata[0] should be set to IVIDEO_METADATAPLANE_MBINFO */
- if (params->ErrorConcealmentON) {
- pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_MBINFO;
- pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_TRANSCODE_FRAMELEVEL;
- }
-
- params->debugTraceLevel= 0;
- params->lastNFramesToLog= 0;
-
- return;
-}
-
-
-void OMXMPEG2VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynParams)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL;
- IMPEG2VDEC_DynamicParams *dynamicParams;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp
- = (OMXVidDecComp *)pHandle->pComponentPrivate;
- p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]);
- dynamicParams = (IMPEG2VDEC_DynamicParams *)dynParams;
-
- /*! Update the Individual fields in the Dyanmic Params of MPEG2 decoder */
- dynamicParams->viddecDynamicParams.size = sizeof(IMPEG2VDEC_DynamicParams);
- dynamicParams->viddecDynamicParams.decodeHeader = XDM_DECODE_AU;
- dynamicParams->viddecDynamicParams.displayWidth = p2DOutBufAllocParam->nWidth;
- dynamicParams->viddecDynamicParams.frameSkipMode = IVIDEO_NO_SKIP;
- dynamicParams->viddecDynamicParams.newFrameFlag = XDAS_TRUE;
- dynamicParams->viddecDynamicParams.putDataFxn = NULL;
- dynamicParams->viddecDynamicParams.putDataHandle = NULL;
- dynamicParams->viddecDynamicParams.getDataFxn = NULL;
- dynamicParams->viddecDynamicParams.getDataHandle = NULL;
- dynamicParams->viddecDynamicParams.putBufferFxn = NULL;
- dynamicParams->viddecDynamicParams.putBufferHandle = NULL;
- dynamicParams->viddecDynamicParams.lateAcquireArg = IRES_HDVICP2_UNKNOWNLATEACQUIREARG;
- return;
-}
-
-
-void OMXMPEG2VD_SetStatus(OMX_HANDLETYPE hComponent, void *decstatus)
-{
- IMPEG2VDEC_Status *status;
- (void)hComponent;
-
- status = (IMPEG2VDEC_Status *)decstatus;
-
- status->viddecStatus.size = sizeof(IMPEG2VDEC_Status);
- return;
-}
-
-
-PaddedBuffParams CalculateMPEG2VD_outbuff_details(OMX_HANDLETYPE hComponent,
- OMX_U32 width, OMX_U32 height)
-{
- PaddedBuffParams OutBuffDetails;
- (void)hComponent;
-
- /* OutBuffDetails.nBufferSize
- = ((((width + PADX + 127) & ~127) * (height + PADY))); */
- /* The 2 additional rows and columns are required as per codec request to boost performance. */
- OutBuffDetails.nBufferSize
- = ((((width + 127) & ~127) + 2) * (height + 2));
- /* Multiply buffer size by 1.5 to account for both luma and chroma */
- OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1;
-
- OutBuffDetails.nBufferCountMin = 4;
- OutBuffDetails.nBufferCountActual = 8;
- OutBuffDetails.n1DBufferAlignment = 16;
- //OutBuffDetails.nPaddedWidth = (width + PADX + 127) & ~127;
- //OutBuffDetails.nPaddedHeight = height + PADY;
- OutBuffDetails.nPaddedWidth = (width + 127) & ~127;
- OutBuffDetails.nPaddedHeight = height;
- OutBuffDetails.n2DBufferYAlignment = 1;
- OutBuffDetails.n2DBufferXAlignment = 16;
-
- return (OutBuffDetails);
-}
-
-
-void OMXMPEG2VD_DeInit(OMX_HANDLETYPE hComponent)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- /*! Delete all the memory which was allocated during init of decoder */
- if( pVidDecComp->pDecStaticParams ) {
- memplugin_free(pVidDecComp->pDecStaticParams);
- pVidDecComp->pDecStaticParams = NULL;
- }
- if( pVidDecComp->pDecDynParams ) {
- memplugin_free(pVidDecComp->pDecDynParams);
- pVidDecComp->pDecDynParams = NULL;
- }
- if( pVidDecComp->pDecStatus ) {
- memplugin_free(pVidDecComp->pDecStatus);
- pVidDecComp->pDecStatus = NULL;
- }
- if( pVidDecComp->pDecInArgs ) {
- memplugin_free(pVidDecComp->pDecInArgs);
- pVidDecComp->pDecInArgs = NULL;
- }
- if( pVidDecComp->pDecOutArgs ) {
- memplugin_free(pVidDecComp->pDecOutArgs);
- pVidDecComp->pDecOutArgs = NULL;
- }
- if( pVidDecComp->pCodecSpecific ) {
- OSAL_Free(pVidDecComp->pCodecSpecific);
- pVidDecComp->pCodecSpecific = NULL;
- }
- pHandle->SetParameter = OMXVidDec_SetParameter;
- pHandle->GetParameter = OMXVidDec_GetParameter;
- pVidDecComp->fpHandle_ExtendedError = NULL;
-}
-
-OMX_ERRORTYPE OMXMPEG2VD_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL;
- OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL;
- OMX_VIDEO_PARAM_MPEG2TYPE *pMPEG2VideoParam = NULL;
-
- OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL),
- OMX_ErrorBadParameter);
-
- /*! Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific;
-
- switch( nIndex ) {
- case OMX_IndexParamVideoMpeg2 :
-
- pMPEG2VideoParam = (OMX_VIDEO_PARAM_MPEG2TYPE *) pParamStruct;
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) ||
- (pVidDecComp->sBase.pPorts[pMPEG2VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
- OMX_ErrorIncorrectStateOperation);
-
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG2TYPE, eError);
- OMX_CHECK(pMPEG2VideoParam->eProfile == OMX_VIDEO_MPEG2ProfileSimple
- || pMPEG2VideoParam->eProfile == OMX_VIDEO_MPEG2ProfileMain,
- OMX_ErrorUnsupportedSetting);
- if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- pMPEG2VidDecComp->tMPEG2VideoParam = *pMPEG2VideoParam;
- } else if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoMpeg2 supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- break;
- case OMX_IndexParamCommonDeblocking :
-
- pDeblockingParam = (OMX_PARAM_DEBLOCKINGTYPE *) pParamStruct;
-
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) ||
- (pVidDecComp->sBase.pPorts[pDeblockingParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
- OMX_ErrorIncorrectStateOperation);
-
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_DEBLOCKINGTYPE, eError);
- if( pDeblockingParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- pMPEG2VidDecComp->tDeblockingParam.bDeblocking = pDeblockingParam->bDeblocking;
- } else if( pDeblockingParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- OSAL_ErrorTrace("\n Deblocking supported only on o/p port... \n");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- break;
- default :
- eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-OMX_ERRORTYPE OMXMPEG2VD_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG2VidDecComp *pMPEG2VidDecComp = NULL;
- OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL;
- OMX_VIDEO_PARAM_MPEG2TYPE *pMPEG2VideoParam = NULL;
- OMX_VIDEO_PARAM_PROFILELEVELTYPE *pMPEG2ProfileLevelParam = NULL;
-
- OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL),
- OMX_ErrorBadParameter);
-
- /*! Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- /* GetParameter can't be invoked incase the comp is in Invalid State */
- OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid,
- OMX_ErrorIncorrectStateOperation);
-
- pMPEG2VidDecComp =(OMXMPEG2VidDecComp *) pVidDecComp->pCodecSpecific;
-
- switch( nIndex ) {
- case OMX_IndexParamVideoMpeg2 :
-
- pMPEG2VideoParam = (OMX_VIDEO_PARAM_MPEG2TYPE *) pParamStruct;
-
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG2TYPE, eError);
- if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- *pMPEG2VideoParam = pMPEG2VidDecComp->tMPEG2VideoParam;
- } else if( pMPEG2VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoMpeg2 supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- break;
- case OMX_IndexParamCommonDeblocking :
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_DEBLOCKINGTYPE, eError);
- pDeblockingParam = (OMX_PARAM_DEBLOCKINGTYPE *) pParamStruct;
- if( pDeblockingParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- pDeblockingParam->bDeblocking = pMPEG2VidDecComp->tDeblockingParam.bDeblocking;
- } else if( pDeblockingParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- OSAL_ErrorTrace("\n Deblocking supported only on o/p port... \n");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- break;
- case OMX_IndexParamVideoProfileLevelQuerySupported :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
- pMPEG2ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct;
- if( pMPEG2ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- if( pMPEG2ProfileLevelParam->nProfileIndex == 0 ) {
- if( pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2 ) {
- pMPEG2ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG2ProfileSimple;
- pMPEG2ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG2LevelLL;
- }
- } else if( pMPEG2ProfileLevelParam->nProfileIndex == 1 ) {
- if( pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2 ) {
- pMPEG2ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG2ProfileMain;
- pMPEG2ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG2LevelML;
- }
- } else {
- eError = OMX_ErrorNoMore;
- }
- } else if( pMPEG2ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- }
- break;
-
- default :
- eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-
-OMX_ERRORTYPE OMXMPEG2VD_HandleError(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- XDAS_Int32 status = 0;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- /* Initialize pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- /*! Call the Codec Status function to know cause of error */
- status = VIDDEC3_control(pVidDecComp->pDecHandle,
- XDM_GETSTATUS,
- pVidDecComp->pDecDynParams,
- pVidDecComp->pDecStatus);
- /* Check whether the Codec Status call was succesful */
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_GETSTATUS failed");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
-
- ALOGE("Mpeg2: extendedErrorCode0 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode0);
- ALOGE("Mpeg2: extendedErrorCode1 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode1);
- ALOGE("Mpeg2: extendedErrorCode2 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode2);
- ALOGE("Mpeg2: extendedErrorCode3 0x%x", (OMX_U32)((IMPEG2VDEC_Status *)(pVidDecComp->pDecStatus))->extendedErrorCode3);
-
-EXIT:
- return (eError);
-}
-
diff --git a/omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h b/omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h
deleted file mode 100644
index 4aadbfe..0000000
--- a/omx/videodecode/omx_mpeg4_dec/inc/omx_mpeg4vd.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _OMX_MPEG4VD_H_
-#define _OMX_MPEG4VD_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <omx_video_decoder.h>
-#include <ti/sdo/codecs/mpeg4vdec/impeg4vdec.h>
-
-/*! Padding for width as per Codec Requirement */
-#define PADX (32)
-/*! Padding for height as per Codec requirement */
-#define PADY (32)
-
-
-void OMXMPEG4VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams);
-
-void OMXMPEG4VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynamicParams);
-
-void OMXMPEG4VD_SetStatus(OMX_HANDLETYPE hComponent, void *status);
-
-PaddedBuffParams CalculateMPEG4VD_outbuff_details(OMX_HANDLETYPE hComponent,
- OMX_U32 width, OMX_U32 height);
-
-OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXMPEG4_H263VD_Init(OMX_HANDLETYPE hComponent);
-void OMXMPEG4VD_DeInit(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXMPEG4VD_HandleError(OMX_HANDLETYPE hComponent);
-
-extern OMX_ERRORTYPE OMXMPEG4VD_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-extern OMX_ERRORTYPE OMXMPEG4VD_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-extern OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-extern OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-
-typedef struct OMXMPEG4VidDecComp {
- OMX_PARAM_DEBLOCKINGTYPE tDeblockingParam;
- OMX_VIDEO_PARAM_MPEG4TYPE tMPEG4VideoParam;
- OMX_BOOL bIsSorensonSpark;
-} OMXMPEG4VidDecComp;
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _OMX_MPEG4VD_H_ */
-
diff --git a/omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c b/omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c
deleted file mode 100644
index 6f24f88..0000000
--- a/omx/videodecode/omx_mpeg4_dec/src/omx_mpeg4dec.c
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "OMX_MPEG4_VIDDEC"
-#include <omx_mpeg4vd.h>
-
-OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL;
-
- eError = OMXMPEG4_H263VD_Init(hComponent);
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific;
- pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingMPEG4;
- pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused;
- pMPEG4VidDecComp->bIsSorensonSpark = OMX_FALSE;
-
- return (eError);
-}
-
-OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL;
-
- eError = OMXMPEG4_H263VD_Init(hComponent);
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific;
-
- pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingH263;
- pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat = OMX_VIDEO_CodingUnused;
-
- pMPEG4VidDecComp->bIsSorensonSpark = OMX_FALSE;
-
- return (eError);
-}
-
-OMX_ERRORTYPE OMXMPEG4_H263VD_Init(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- /*! Initialize the function pointers */
- pVidDecComp->fpSet_StaticParams = OMXMPEG4VD_SetStaticParams;
- pVidDecComp->fpSet_DynamicParams = OMXMPEG4VD_SetDynamicParams;
- pVidDecComp->fpSet_Status = OMXMPEG4VD_SetStatus;
- pVidDecComp->fpCalc_OubuffDetails = CalculateMPEG4VD_outbuff_details;
- pVidDecComp->fpDeinit_Codec = OMXMPEG4VD_DeInit;
- pVidDecComp->cDecoderName = "ivahd_mpeg4dec";
- pHandle->SetParameter = OMXMPEG4VD_SetParameter;
- pHandle->GetParameter = OMXMPEG4VD_GetParameter;
- pVidDecComp->fpHandle_ExtendedError = OMXMPEG4VD_HandleError;
-
- /*! Initialize the framerate divisor to 10000 as WA because MPEG4 codec is providing framerate by multiplying with 10000 instead of 1000*/
- pVidDecComp->nFrameRateDivisor = 10000;
-
- pVidDecComp->pCodecSpecific = (OMXMPEG4VidDecComp *) OSAL_Malloc(sizeof (OMXMPEG4VidDecComp));
- OMX_CHECK((pVidDecComp->pCodecSpecific) != NULL, OMX_ErrorInsufficientResources);
-
- pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific;
-
- OMX_BASE_INIT_STRUCT_PTR(&(pMPEG4VidDecComp->tDeblockingParam), OMX_PARAM_DEBLOCKINGTYPE);
- pMPEG4VidDecComp->tDeblockingParam.nPortIndex = OMX_VIDDEC_OUTPUT_PORT;
- pMPEG4VidDecComp->tDeblockingParam.bDeblocking = OMX_TRUE;
-
- OMX_BASE_INIT_STRUCT_PTR(&(pMPEG4VidDecComp->tMPEG4VideoParam), OMX_VIDEO_PARAM_MPEG4TYPE);
- pMPEG4VidDecComp->tMPEG4VideoParam.nPortIndex = OMX_VIDDEC_INPUT_PORT;
- pMPEG4VidDecComp->tMPEG4VideoParam.eProfile = OMX_VIDEO_MPEG4ProfileAdvancedSimple;
- pMPEG4VidDecComp->tMPEG4VideoParam.eLevel = OMX_VIDEO_MPEG4Level5;
-
- /*! Allocate Memory for Static Parameter */
- pVidDecComp->pDecStaticParams = (IVIDDEC3_Params *) memplugin_alloc(sizeof(IMPEG4VDEC_Params), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecStaticParams != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecStaticParams, 0x0, sizeof(IMPEG4VDEC_Params));
-
- /*! Allocate Memory for Dynamic Parameter */
- pVidDecComp->pDecDynParams = (IVIDDEC3_DynamicParams *)memplugin_alloc(sizeof(IMPEG4VDEC_DynamicParams), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecDynParams != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecDynParams, 0x0, sizeof(IMPEG4VDEC_DynamicParams));
-
- /*! Allocate Memory for Status Structure */
- pVidDecComp->pDecStatus = (IVIDDEC3_Status *) memplugin_alloc(sizeof(IMPEG4VDEC_Status), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecStatus != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecStatus, 0x0, sizeof(IMPEG4VDEC_Status));
-
- /*! Allocate Memory for Input Arguments */
- pVidDecComp->pDecInArgs = (IVIDDEC3_InArgs *) memplugin_alloc(sizeof(IMPEG4VDEC_InArgs), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecInArgs != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecInArgs, 0x0, sizeof(IMPEG4VDEC_InArgs));
-
- /*! Allocate Memory for Output Arguments */
- pVidDecComp->pDecOutArgs = (IVIDDEC3_OutArgs *) memplugin_alloc(sizeof(IMPEG4VDEC_OutArgs), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->pDecOutArgs != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->pDecOutArgs, 0x0, sizeof(IMPEG4VDEC_OutArgs));
-
- pVidDecComp->pDecInArgs->size = sizeof(IMPEG4VDEC_InArgs);
- pVidDecComp->pDecOutArgs->size = sizeof(IMPEG4VDEC_OutArgs);
-
- pVidDecComp->pDecStaticParams->metadataType[0] = IVIDEO_METADATAPLANE_NONE;
- pVidDecComp->pDecStaticParams->metadataType[1] = IVIDEO_METADATAPLANE_NONE;
- pVidDecComp->pDecStaticParams->metadataType[2] = IVIDEO_METADATAPLANE_NONE;
-
- pVidDecComp->pDecStaticParams->operatingMode = IVIDEO_DECODE_ONLY;
-
- pVidDecComp->pDecStaticParams->inputDataMode = IVIDEO_ENTIREFRAME;
- pVidDecComp->pDecStaticParams->numInputDataUnits = 0;
-
-EXIT:
- return (eError);
-}
-
-void OMXMPEG4VD_SetStaticParams(OMX_HANDLETYPE hComponent, void *staticparams)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL;
- IMPEG4VDEC_Params *params;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp
- = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- pMPEG4VidDecComp =
- (OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific;
-
- params = (IMPEG4VDEC_Params *) staticparams;
-
- params->viddec3Params.size = sizeof(IMPEG4VDEC_Params);
- params->viddec3Params.maxFrameRate = 300000;
- params->viddec3Params.maxBitRate = 10000000;
- params->viddec3Params.dataEndianness = XDM_BYTE;
- params->viddec3Params.forceChromaFormat = XDM_YUV_420SP;
- params->viddec3Params.displayDelay = IVIDDEC3_DISPLAY_DELAY_1;
- params->viddec3Params.inputDataMode = IVIDEO_ENTIREFRAME;
- params->viddec3Params.numInputDataUnits = 0;
- params->viddec3Params.outputDataMode = IVIDEO_ENTIREFRAME;
- params->viddec3Params.displayBufsMode = IVIDDEC3_DISPLAYBUFS_EMBEDDED;
-
- params->viddec3Params.errorInfoMode = IVIDEO_ERRORINFO_OFF;
- params->outloopDeBlocking = IMPEG4VDEC_DEBLOCK_DISABLE;
- params->enhancedDeBlockingQp = 31;
- params->sorensonSparkStream = pMPEG4VidDecComp->bIsSorensonSpark;
- params->errorConcealmentEnable = pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment;
- params->debugTraceLevel = 0;
- params->lastNFramesToLog = 0;
- params->paddingMode = IMPEG4VDEC_MPEG4_MODE_PADDING;
-
- return;
-}
-
-
-void OMXMPEG4VD_SetDynamicParams(OMX_HANDLETYPE hComponent, void *dynParams)
-{
- IMPEG4VDEC_DynamicParams *dynamicParams;
- (void)hComponent;
-
- dynamicParams = (IMPEG4VDEC_DynamicParams *)dynParams;
-
- /*! Update the Individual fields in the Dyanmic Params of MPEG4 decoder */
- dynamicParams->viddec3DynamicParams.size = sizeof(IMPEG4VDEC_DynamicParams);
- dynamicParams->viddec3DynamicParams.decodeHeader = XDM_DECODE_AU;
- dynamicParams->viddec3DynamicParams.displayWidth = 0;
- dynamicParams->viddec3DynamicParams.frameSkipMode = IVIDEO_NO_SKIP;
- dynamicParams->viddec3DynamicParams.newFrameFlag = XDAS_TRUE;
- dynamicParams->viddec3DynamicParams.putDataFxn = NULL;
- dynamicParams->viddec3DynamicParams.putDataHandle = NULL;
- dynamicParams->viddec3DynamicParams.getDataFxn = NULL;
- dynamicParams->viddec3DynamicParams.getDataHandle = NULL;
- dynamicParams->viddec3DynamicParams.putBufferFxn = NULL;
- dynamicParams->viddec3DynamicParams.putBufferHandle = NULL;
- return;
-}
-
-
-void OMXMPEG4VD_SetStatus(OMX_HANDLETYPE hComponent, void *decstatus)
-{
- IMPEG4VDEC_Status *status;
- (void)hComponent;
-
- status = (IMPEG4VDEC_Status *)decstatus;
-
- status->viddec3Status.size = sizeof(IMPEG4VDEC_Status);
- return;
-}
-
-
-PaddedBuffParams CalculateMPEG4VD_outbuff_details(OMX_HANDLETYPE hComponent,
- OMX_U32 width, OMX_U32 height)
-{
- PaddedBuffParams OutBuffDetails;
- (void)hComponent;
-
- OutBuffDetails.nBufferSize = ((((width + PADX + 127) & ~127) * (height + PADY)));
- /* Multiply buffer size by 1.5 to account for both luma and chroma */
- OutBuffDetails.nBufferSize = (OutBuffDetails.nBufferSize * 3) >> 1;
-
- OutBuffDetails.nBufferCountMin = 4;
- OutBuffDetails.nBufferCountActual = 8;
- OutBuffDetails.n1DBufferAlignment = 16;
- OutBuffDetails.nPaddedWidth = (width + PADX + 127) & ~127;
- OutBuffDetails.nPaddedHeight = height + PADY;
- OutBuffDetails.n2DBufferYAlignment = 1;
- OutBuffDetails.n2DBufferXAlignment = 16;
- return (OutBuffDetails);
-}
-
-
-void OMXMPEG4VD_DeInit(OMX_HANDLETYPE hComponent)
-{
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- /*! Delete all the memory which was allocated during init of decoder */
- if( pVidDecComp->pDecStaticParams ) {
- memplugin_free(pVidDecComp->pDecStaticParams);
- pVidDecComp->pDecStaticParams = NULL;
- }
- if( pVidDecComp->pDecDynParams ) {
- memplugin_free(pVidDecComp->pDecDynParams);
- pVidDecComp->pDecDynParams = NULL;
- }
- if( pVidDecComp->pDecStatus ) {
- memplugin_free(pVidDecComp->pDecStatus);
- pVidDecComp->pDecStatus = NULL;
- }
- if( pVidDecComp->pDecInArgs ) {
- memplugin_free(pVidDecComp->pDecInArgs);
- pVidDecComp->pDecInArgs = NULL;
- }
- if( pVidDecComp->pDecOutArgs ) {
- memplugin_free(pVidDecComp->pDecOutArgs);
- pVidDecComp->pDecOutArgs = NULL;
- }
- if( pVidDecComp->pCodecSpecific ) {
- OSAL_Free(pVidDecComp->pCodecSpecific);
- pVidDecComp->pCodecSpecific = NULL;
- }
- pHandle->SetParameter = OMXVidDec_SetParameter;
- pHandle->GetParameter = OMXVidDec_GetParameter;
- pVidDecComp->fpHandle_ExtendedError = NULL;
- pVidDecComp->nFrameRateDivisor = 1000;
-}
-
-OMX_ERRORTYPE OMXMPEG4VD_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL;
- OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL;
- OMX_VIDEO_PARAM_MPEG4TYPE *pMPEG4VideoParam = NULL;
-
- OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL),
- OMX_ErrorBadParameter);
-
- /*! Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific;
-
- switch( nIndex ) {
- case OMX_IndexParamVideoMpeg4 :
- pMPEG4VideoParam = (OMX_VIDEO_PARAM_MPEG4TYPE *) pParamStruct;
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) ||
- (pVidDecComp->sBase.pPorts[pMPEG4VideoParam->nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
- OMX_ErrorIncorrectStateOperation);
-
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG4TYPE, eError);
- OMX_CHECK(pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileSimple
- || pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileMain
- || pMPEG4VideoParam->eProfile == OMX_VIDEO_MPEG4ProfileAdvancedSimple,
- OMX_ErrorUnsupportedSetting);
- if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- pMPEG4VidDecComp->tMPEG4VideoParam = *pMPEG4VideoParam;
- } else if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoMpeg4 supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- break;
-
- default :
- eError = OMXVidDec_SetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-OMX_ERRORTYPE OMXMPEG4VD_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMXMPEG4VidDecComp *pMPEG4VidDecComp = NULL;
- OMX_PARAM_DEBLOCKINGTYPE *pDeblockingParam = NULL;
- OMX_VIDEO_PARAM_MPEG4TYPE *pMPEG4VideoParam = NULL;
- OMX_VIDEO_PARAM_PROFILELEVELTYPE *pMPEG4ProfileLevelParam = NULL;
-
- OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL),
- OMX_ErrorBadParameter);
-
- /*! Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- /* GetParameter can't be invoked incase the comp is in Invalid State */
- OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid,
- OMX_ErrorIncorrectStateOperation);
-
- pMPEG4VidDecComp =(OMXMPEG4VidDecComp *) pVidDecComp->pCodecSpecific;
-
- switch( nIndex ) {
- case OMX_IndexParamVideoMpeg4 :
- pMPEG4VideoParam = (OMX_VIDEO_PARAM_MPEG4TYPE *) pParamStruct;
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MPEG4TYPE, eError);
- if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- *pMPEG4VideoParam = pMPEG4VidDecComp->tMPEG4VideoParam;
- } else if( pMPEG4VideoParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoMpeg4 supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- break;
- case OMX_IndexParamVideoProfileLevelQuerySupported :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
- pMPEG4ProfileLevelParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct;
- if( pMPEG4ProfileLevelParam->nPortIndex == OMX_VIDDEC_INPUT_PORT ) {
- if( pMPEG4ProfileLevelParam->nProfileIndex == 0 ) {
- if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ) {
- pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileSimple;
- pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG4LevelMax;
- } else if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263 ) {
- pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_H263ProfileBaseline;
- pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_H263Level70;
- }
- } else if( pMPEG4ProfileLevelParam->nProfileIndex == 1 ) {
- if(pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingMPEG4 ) {
- pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileAdvancedSimple;
- pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_MPEG4LevelMax;
- } else if( pVidDecComp->sBase.pPorts[pMPEG4ProfileLevelParam->nPortIndex]->sPortDef.format.video.eCompressionFormat == OMX_VIDEO_CodingH263 ) {
- pMPEG4ProfileLevelParam->eProfile = (OMX_U32) OMX_VIDEO_H263ProfileISWV2;
- pMPEG4ProfileLevelParam->eLevel = (OMX_U32) OMX_VIDEO_H263Level70;
- }
- } else {
- eError = OMX_ErrorNoMore;
- }
- } else if( pMPEG4ProfileLevelParam->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- OSAL_ErrorTrace("OMX_IndexParamVideoProfileLevelQuerySupported supported only on i/p port");
- eError = OMX_ErrorUnsupportedIndex;
- } else {
- eError = OMX_ErrorBadPortIndex;
- }
- }
- break;
- default :
- eError = OMXVidDec_GetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-
-OMX_ERRORTYPE OMXMPEG4VD_HandleError(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- /* Initialize pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- /* To send the output buffer to display in case of no valid VOL/VOP header */
-
- if((!(pVidDecComp->pDecOutArgs->extendedError & 0x8000)
- && ((pVidDecComp->pDecOutArgs->extendedError & 0x100000)
- || (pVidDecComp->pDecOutArgs->extendedError & 0x80000)))
- && (pVidDecComp->pDecInArgs->inputID == pVidDecComp->pDecOutArgs->freeBufID[0]
- && pVidDecComp->pDecOutArgs->outputID[0] == 0)) {
- pVidDecComp->pDecOutArgs->outputID[0] = pVidDecComp->pDecInArgs->inputID;
- pVidDecComp->bSyncFrameReady = OMX_TRUE;
- }
-
- return (eError);
-}
-
diff --git a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h b/omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h
deleted file mode 100644
index 543cb75..0000000
--- a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder.h
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _OMX_VIDEO_DECODER_H_
-#define _OMX_VIDEO_DECODER_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <OMX_Types.h>
-#include <omx_base.h>
-#include <xdc/std.h>
-#include <ti/xdais/xdas.h>
-#include <ti/sdo/ce/video3/viddec3.h>
-#include <omx_base_utils.h>
-
-#include <hardware/gralloc.h>
-#include <hardware/hardware.h>
-#include <hal_public.h>
-
-#define OMX_VIDDEC_NUM_OF_PORTS OMX_BASE_NUM_OF_PORTS
-#define OMX_VIDDEC_INPUT_PORT OMX_BASE_INPUT_PORT
-#define OMX_VIDDEC_OUTPUT_PORT OMX_BASE_OUTPUT_PORT
-#define OMX_VIDDEC_DEFAULT_START_PORT_NUM OMX_BASE_DEFAULT_START_PORT_NUM
-
-
-/*Android Data structures*/
-
-enum Type {
- MEDIA_IMAGE_TYPE_UNKNOWN = 0,
- MEDIA_IMAGE_TYPE_YUV,
-};
-
-enum PlaneIndex {
- Y = 0,
- U,
- V,
- MAX_NUM_PLANES
-};
-
-typedef struct PlaneInfo {
- uint32_t mOffset; // offset of first pixel of the plane in bytes
- // from buffer offset
- uint32_t mColInc; // column increment in bytes
- uint32_t mRowInc; // row increment in bytes
- uint32_t mHorizSubsampling; // subsampling compared to the largest plane
- uint32_t mVertSubsampling; // subsampling compared to the largest plane
-}PlaneInfo;
-
-// Structure describing a media image (frame)
-// Currently only supporting YUV
-typedef struct MediaImage {
- int mType;
- uint32_t mNumPlanes; // number of planes
- uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth)
- uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight)
- uint32_t mBitDepth; // useable bit depth
- PlaneInfo mPlane[MAX_NUM_PLANES];
-}MediaImage;
-
-// A pointer to this struct is passed to OMX_GetParameter when the extension
-// index for the 'OMX.google.android.index.describeColorFormat'
-// extension is given. This method can be called from any component state
-// other than invalid. The color-format, frame width/height, and stride/
-// slice-height parameters are ones that are associated with a raw video
-// port (input or output), but the stride/slice height parameters may be
-// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will
-// be used (while specifying this color format).
-//
-// The component shall fill out the MediaImage structure that
-// corresponds to the described raw video format, and the potentially corrected
-// stride and slice-height info.
-//
-// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE,
-// though most implementations can ignore this difference. When using native buffers,
-// the component may change the configured color format to an optimized format.
-// Additionally, when allocating these buffers for flexible usecase, the framework
-// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers
-// is OMX_TRUE), the component shall fill out the MediaImage information for the
-// scenario when these SW-readable/writable buffers are locked using gralloc_lock.
-// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must
-// be supported for vendor-specific formats.
-//
-// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers
-// is OMX_TRUE and the component does not support this color format with native
-// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN.
-typedef struct DescribeColorFormatParams {
- OMX_U32 nSize;
- OMX_VERSIONTYPE nVersion;
- // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE
- OMX_COLOR_FORMATTYPE eColorFormat;
- OMX_U32 nFrameWidth;
- OMX_U32 nFrameHeight;
- OMX_U32 nStride;
- OMX_U32 nSliceHeight;
- OMX_BOOL bUsingNativeBuffers;
-
- // output: fill out the MediaImage fields
- MediaImage sMediaImage;
-}DescribeColorFormatParams;
-
-// A pointer to this struct is passed to OMX_SetParameter() when the extension
-// index "OMX.google.android.index.prepareForAdaptivePlayback" is given.
-//
-// This method is used to signal a video decoder, that the user has requested
-// seamless resolution change support (if bEnable is set to OMX_TRUE).
-// nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest
-// anticipated frames in the video. If bEnable is OMX_FALSE, no resolution
-// change is expected, and the nMaxFrameWidth/Height fields are unused.
-//
-// If the decoder supports dynamic output buffers, it may ignore this
-// request. Otherwise, it shall request resources in such a way so that it
-// avoids full port-reconfiguration (due to output port-definition change)
-// during resolution changes.
-//
-// DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT
-// METADATA SUPPORT FOR VIDEO DECODERS.
-typedef struct PrepareForAdaptivePlaybackParams {
- OMX_U32 nSize;
- OMX_VERSIONTYPE nVersion;
- OMX_U32 nPortIndex;
- OMX_BOOL bEnable;
- OMX_U32 nMaxFrameWidth;
- OMX_U32 nMaxFrameHeight;
-}PrepareForAdaptivePlaybackParams;
-
-/*
-* Padded Buffer Parameters
-*/
-typedef struct PaddedBuffParams {
- OMX_U32 nBufferSize; /*! Buffer size */
- OMX_U32 nPaddedWidth; /*! Padded Width of the buffer */
- OMX_U32 nPaddedHeight; /*! Padded Height */
- OMX_U32 nBufferCountMin; /*! Min number of buffers required */
- OMX_U32 nBufferCountActual; /*! Actual number of buffers */
- OMX_U32 n1DBufferAlignment; /*! 1D Buffer Alignment value */
- OMX_U32 n2DBufferYAlignment; /*! Y axis alignment value in 2Dbuffer */
- OMX_U32 n2DBufferXAlignment; /*! X Axis alignment value in 2Dbuffer */
-} PaddedBuffParams;
-
-/*
-* OMX Video decoder component
-*/
-typedef struct OMXVideoDecoderComponent {
- OMXBaseComp sBase;
- /* codec related fields */
- OMX_STRING cDecoderName;
- VIDDEC3_Handle pDecHandle;
- Engine_Handle ce;
- IVIDDEC3_Params *pDecStaticParams; /*! Pointer to Decoder Static Params */
- IVIDDEC3_DynamicParams *pDecDynParams; /*! Pointer to Decoder Dynamic Params */
- IVIDDEC3_Status *pDecStatus; /*! Pointer to Decoder Status struct */
- IVIDDEC3_InArgs *pDecInArgs; /*! Pointer to Decoder InArgs */
- IVIDDEC3_OutArgs *pDecOutArgs; /*! Pointer to Decoder OutArgs */
- XDM2_BufDesc *tInBufDesc;
- XDM2_BufDesc *tOutBufDesc;
-
- /* OMX params */
- OMX_VIDEO_PARAM_PORTFORMATTYPE tVideoParams[OMX_VIDDEC_NUM_OF_PORTS];
- OMX_CONFIG_RECTTYPE tCropDimension;
- OMX_CONFIG_SCALEFACTORTYPE tScaleParams;
- OMX_PARAM_COMPONENTROLETYPE tComponentRole;
- OMX_CONFIG_RECTTYPE t2DBufferAllocParams[OMX_VIDDEC_NUM_OF_PORTS];
-
- /* local params */
- gralloc_module_t const *grallocModule;
- OMXBase_CodecConfigBuf sCodecConfig;
- OMX_U32 nOutPortReconfigRequired;
- OMX_U32 nCodecRecreationRequired;
- OMX_U32 bInputBufferCancelled;
-
- OMX_U32 bIsFlushRequired;
- OMX_BOOL bUsePortReconfigForCrop;
- OMX_BOOL bUsePortReconfigForPadding;
- OMX_BOOL bSupportDecodeOrderTimeStamp;
- OMX_BOOL bSupportSkipGreyOutputFrames;
- OMX_BOOL bEnableDecodeZeroDisplayDelayMode;
-
- OMX_U32 nFrameCounter;
- OMX_BOOL bSyncFrameReady;
- OMX_U32 nOutbufInUseFlag;
- OMX_PTR pCodecSpecific;
- OMX_U32 nDecoderMode;
- OMX_U32 nFatalErrorGiven;
- OMX_PTR pTimeStampStoragePipe;
- OMX_U32 nFrameRateDivisor;
- OMX_BOOL bFirstFrameHandled;
-
- OMX_BOOL bIPCRecoveryNeeded;
-
- //Parameters for Adaptive video playback
- OMX_BOOL bisAdaptivePlayback;
- OMX_U32 nAdaptiveMaxFrameWidth;
- OMX_U32 nAdaptiveMaxFrameHeight;
-
- void (*fpSet_StaticParams)(OMX_HANDLETYPE hComponent, void *params);
- void (*fpSet_DynamicParams)(OMX_HANDLETYPE hComponent, void *dynamicparams);
- void (*fpSet_Status)(OMX_HANDLETYPE hComponent, void *status);
- void (*fpDeinit_Codec)(OMX_HANDLETYPE hComponent);
- OMX_ERRORTYPE (*fpHandle_ExtendedError)(OMX_HANDLETYPE hComponent);
- OMX_ERRORTYPE (*fpHandle_CodecGetStatus)(OMX_HANDLETYPE hComponent);
- PaddedBuffParams (*fpCalc_OubuffDetails)(OMX_HANDLETYPE hComponent, OMX_U32 width, OMX_U32 height);
- MemHeader *pmetaBuffer;
-
-}OMXVidDecComp;
-
-/* Component Entry Method */
-OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXVidDec_ComponentInit(OMX_HANDLETYPE hComponent);
-OMX_ERRORTYPE OMXVidDec_ComponentDeinit(OMX_HANDLETYPE hComponent);
-
-OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct);
-
-OMX_ERRORTYPE OMXVidDec_GetConfig(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure);
-
-OMX_ERRORTYPE OMXVidDec_SetConfig(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure);
-
-OMX_ERRORTYPE OMXVidDec_CommandNotify(OMX_HANDLETYPE hComponent, OMX_COMMANDTYPE Cmd,
- OMX_U32 nParam, OMX_PTR pCmdData);
-
-OMX_ERRORTYPE OMXVidDec_DataNotify(OMX_HANDLETYPE hComponent);
-
-OMX_ERRORTYPE OMXVidDec_XlateBuffHandle(OMX_HANDLETYPE hComponent, OMX_PTR pBufferHdr, OMX_BOOL bRegister);
-
-OMX_ERRORTYPE OMXVidDec_GetExtensionIndex(OMX_HANDLETYPE hComponent, OMX_STRING cParameterName,
- OMX_INDEXTYPE *pIndexType);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _OMX_VIDEO_DECODER_H_ */
-
diff --git a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h b/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h
deleted file mode 100644
index b3638db..0000000
--- a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_componenttable.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _OMX_VIDEO_DECODER_COMPONENTTABLE_H_
-#define _OMX_VIDEO_DECODER_COMPONENTTABLE_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdio.h>
-#include <OMX_Video.h>
-
-typedef struct OMXDecoderComponentList {
- /*Component role to be specified here*/
- OMX_U8 cRole[OMX_MAX_STRINGNAME_SIZE];
-
- /*! Video Coding Type Format */
- OMX_VIDEO_CODINGTYPE eCompressionFormat;
-
- /*! Function pointer to the component Init function of decoder */
- OMX_ERRORTYPE (*fpDecoderComponentInit)(OMX_HANDLETYPE hComponent);
-
-} OMXDecoderComponentList;
-
-/* external definition for the Decoder Component List*/
-extern OMXDecoderComponentList DecoderList[];
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _OMX_VIDEO_DECODER_COMPONENTTABLE_H_ */
-
diff --git a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h b/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h
deleted file mode 100644
index 12efba5..0000000
--- a/omx/videodecode/omx_videodec_common/inc/omx_video_decoder_internal.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _OMX_VIDEO_DECODER_INTERNAL_H_
-#define _OMX_VIDEO_DECODER_INTERNAL_H_
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <osal_trace.h>
-#include <OMX_Core.h>
-#include <OMX_Component.h>
-#include <omx_base.h>
-#include <OMX_Types.h>
-#include <omx_base_utils.h>
-#include <omx_video_decoder.h>
-#include <omx_video_decoder_componenttable.h>
-
-static OMX_STRING engineName = "ivahd_vidsvr";
-
-#define OMX_VIDDEC_COMP_VERSION_MAJOR 1
-#define OMX_VIDDEC_COMP_VERSION_MINOR 1
-#define OMX_VIDDEC_COMP_VERSION_REVISION 0
-#define OMX_VIDDEC_COMP_VERSION_STEP 0
-
-#define OMX_VIDEODECODER_DEFAULT_FRAMERATE 30
-
-/*! Minimum Input Buffer Count */
-#define OMX_VIDDEC_MIN_IN_BUF_COUNT 1
-/*! Default Input Buffer Count */
-#define OMX_VIDDEC_DEFAULT_IN_BUF_COUNT 2
-/*! Minimum Input Buffer Count in Data Sync mode
-* codec releases input buffer of Nth Data Sync call during (N+2)th Data Sync call
-* So minimum number of input buffers required is 3 */
-#define OMX_VIDDEC_DATASYNC_MIN_IN_BUF_COUNT 3
-/*! Default Input Buffer Count in Data Sync mode*/
-#define OMX_VIDDEC_DATASYNC_DEFAULT_IN_BUF_COUNT 4
-/*! Default Frame Width */
-#define OMX_VIDDEC_DEFAULT_FRAME_WIDTH 176
-/*! Default Frame Height */
-#define OMX_VIDDEC_DEFAULT_FRAME_HEIGHT 144
-/*! Default 1D-Buffer Alignment */
-#define OMX_VIDDEC_DEFAULT_1D_INPUT_BUFFER_ALIGNMENT 1
-/*! Default Stride value for 2D buffer */
-#define OMX_VIDDEC_DEFAULT_STRIDE OMX_VIDDEC_DEFAULT_FRAME_WIDTH
-/*! Max Image Width supported */
-#define OMX_VIDDEC_MAX_WIDTH (2048)
-/*! Max Image Height supported */
-#define OMX_VIDDEC_MAX_HEIGHT (2048)
-/*! Max Number of MBs supported */
-#define OMX_VIDDEC_MAX_MACROBLOCK (8160)
-
-#define OMX_VIDEODECODER_COMPONENT_NAME "OMX.TI.DUCATI1.VIDEO.DECODER"
-
-/* external definition for the Video Params Init function */
-extern OMX_ERRORTYPE OMXVidDec_InitFields(OMXVidDecComp *pVidDecComp);
-extern void OMXVidDec_InitPortDefs(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp);
-extern void OMXVidDec_InitPortParams(OMXVidDecComp *pVidDecComp);
-extern void OMXVidDec_InitDecoderParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp);
-
-extern OMX_ERRORTYPE OMXVidDec_HandleFLUSH_EOS(OMX_HANDLETYPE hComponent, OMX_BUFFERHEADERTYPE *pOutBufHeader,
- OMX_BUFFERHEADERTYPE *pInBufHeader);
-extern OMX_ERRORTYPE OMXVidDec_SetInPortDef(OMX_HANDLETYPE hComponent,
- OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs);
-extern OMX_ERRORTYPE OMXVidDec_SetOutPortDef(OMXVidDecComp *pVidDecComp,
- OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs);
-extern OMX_ERRORTYPE OMXVidDec_HandleFirstFrame(OMX_HANDLETYPE hComponent,
- OMX_BUFFERHEADERTYPE * *ppInBufHeader);
-extern OMX_ERRORTYPE OMXVidDec_HandleCodecProcError(OMX_HANDLETYPE hComponent,
- OMX_BUFFERHEADERTYPE * *ppInBufHeader,
- OMX_BUFFERHEADERTYPE * *ppOutBufHeader);
-extern OMX_ERRORTYPE OMXVidDec_HandleLockedBuffer(OMX_HANDLETYPE hComponent,
- OMX_BUFFERHEADERTYPE *pOutBufHeader);
-
-XDAS_Int32 OMXVidDec_DataSync_GetInputData(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc);
-
-XDAS_Int32 OMXVidDec_DataSync_PutBuffer(XDM_DataSyncHandle dataSyncHandle, XDM_DataSyncDesc *dataSyncDesc);
-
-extern void OMXVidDec_Set2DBuffParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp);
-extern OMX_U32 Calc_InbufSize(OMX_U32 width, OMX_U32 height);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _OMX_VIDEO_DECODER_H_ */
-
diff --git a/omx/videodecode/omx_videodec_common/src/omx_video_decoder.c b/omx/videodecode/omx_videodec_common/src/omx_video_decoder.c
deleted file mode 100644
index c688277..0000000
--- a/omx/videodecode/omx_videodec_common/src/omx_video_decoder.c
+++ /dev/null
@@ -1,1726 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "OMX_VIDDEC_COMMON"
-
-#include <omx_video_decoder_internal.h>
-#include <OMX_TI_Custom.h>
-
-#include <osal_trace.h>
-#include <memplugin.h>
-#include <libdce.h>
-
-
-#define HAL_NV12_PADDED_PIXEL_FORMAT HAL_PIXEL_FORMAT_NV12
-
-#define MAX_REF_FRAMES 16
-
-/*
-* Component Init
-*/
-OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
-
- /*! Call the Common Decoder Component Init */
- eError = OMXVidDec_ComponentInit(hComponent);
- OMX_CHECK(eError == OMX_ErrorNone, eError);
-
- /*! Call the Decoder Specific Init as default */
- eError = DecoderList[DEFAULT_COMPOENENT].fpDecoderComponentInit(hComponent);
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- OMXVidDec_InitPortDefs(hComponent, pVidDecComp);
- OMXVidDec_InitPortParams(pVidDecComp);
- OMXVidDec_Set2DBuffParams(hComponent, pVidDecComp);
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]);
- pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth;
-
- /* Call Decoder Specific function to set Static Params */
- pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams);
-
- strcpy((char *)pVidDecComp->tComponentRole.cRole,
- (char *)DecoderList[DEFAULT_COMPOENENT].cRole);
- /* Set the Parse Header flag to XDM_PARSE_HEADER */
- pVidDecComp->nDecoderMode = XDM_PARSE_HEADER;
-
-EXIT:
- return (eError);
-}
-
-/*
-* Video Decoder Component Init
-*/
-OMX_ERRORTYPE OMXVidDec_ComponentInit(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- Engine_Error errorCode;
-
- OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
-
- /* allocate the decoder component */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pHandle->pComponentPrivate = (OMXVidDecComp*)OSAL_Malloc(sizeof(OMXVidDecComp));
- OMX_CHECK(pHandle->pComponentPrivate != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pHandle->pComponentPrivate, 0x0, sizeof(OMXVidDecComp));
-
- pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate;
-
- /*! Initialize the fields */
- eError = OMXVidDec_InitFields(pHandle->pComponentPrivate);
- OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUndefined);
-
- strcpy(pVidDecComp->sBase.cComponentName, OMX_VIDEODECODER_COMPONENT_NAME);
-
- /* Initialize the base component */
- eError = OMXBase_ComponentInit(hComponent);
- OMX_CHECK(eError == OMX_ErrorNone, eError);
-
- /*Setting default properties.
- * PreCondition: NumOfPorts is filled and all pointers allocated*/
- eError = OMXBase_SetDefaultProperties(hComponent);
- OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting);
-
- /*! Initialize function pointers for Command and Data Notify */
- pVidDecComp->sBase.fpCommandNotify = OMXVidDec_CommandNotify;
- pVidDecComp->sBase.fpDataNotify = OMXVidDec_DataNotify;
- pVidDecComp->sBase.fpXlateBuffHandle = OMXVidDec_XlateBuffHandle;
-
- /*! Initialize the function parameters for OMX functions */
- pHandle->SetParameter = OMXVidDec_SetParameter;
- pHandle->GetParameter = OMXVidDec_GetParameter;
- pHandle->GetConfig = OMXVidDec_GetConfig;
- pHandle->SetConfig = OMXVidDec_SetConfig;
- pHandle->ComponentDeInit = OMXVidDec_ComponentDeinit;
- pHandle->GetExtensionIndex = OMXVidDec_GetExtensionIndex;
-
- /*! Open instance of Codec engine */
- pVidDecComp->ce = Engine_open(engineName, NULL, &errorCode);
- pVidDecComp->pDecHandle = NULL;
- pVidDecComp->nFrameCounter = 0;
- pVidDecComp->bSyncFrameReady = OMX_FALSE;
- pVidDecComp->nOutbufInUseFlag = 0;
- pVidDecComp->nCodecRecreationRequired = 0;
- pVidDecComp->nOutPortReconfigRequired = 0;
- pVidDecComp->nFatalErrorGiven = 0;
- pVidDecComp->bInputBufferCancelled = 0;
- pVidDecComp->bIPCRecoveryNeeded = OMX_FALSE;
- /*! Initialize the Framerate divisor to 1000 as codec is supposed provide framerate after by multiplying with 1000 */
- pVidDecComp->nFrameRateDivisor = 1000;
- pVidDecComp->tCropDimension.nTop = 0;
- pVidDecComp->tCropDimension.nLeft = 0;
- pVidDecComp->tScaleParams.xWidth = 0x10000;
- pVidDecComp->tScaleParams.xHeight = 0x10000;
- pVidDecComp->bUsePortReconfigForCrop = OMX_TRUE;
- pVidDecComp->bUsePortReconfigForPadding = OMX_TRUE;
- pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_FALSE;
- pVidDecComp->bSupportSkipGreyOutputFrames = OMX_TRUE;
- pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_FALSE;
-
- /*Optimize this pipe to be created only if decode timestamps is requested. */
- OSAL_CreatePipe(&(pVidDecComp->pTimeStampStoragePipe), MAX_REF_FRAMES * sizeof(OMX_TICKS),
- sizeof(OMX_TICKS), 1);
-
- pVidDecComp->tInBufDesc = (XDM2_BufDesc*)memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->tInBufDesc != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->tInBufDesc, 0x0, sizeof(XDM2_BufDesc));
-
- pVidDecComp->tOutBufDesc = (XDM2_BufDesc*)memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0);
- OMX_CHECK(pVidDecComp->tOutBufDesc != NULL, OMX_ErrorInsufficientResources);
- OSAL_Memset(pVidDecComp->tOutBufDesc, 0x0, sizeof(XDM2_BufDesc));
-
-EXIT:
- if( eError != OMX_ErrorNone ) {
- if( pHandle != NULL ) {
- OMXVidDec_ComponentDeinit(hComponent);
- }
- }
- return (eError);
-}
-
-
-/*
-* Video decoder setParameter
-*/
-OMX_ERRORTYPE OMXVidDec_SetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs = NULL;
- OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoParams = NULL;
- OMX_CONFIG_RECTTYPE *p2DBufferAllocParams = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- OMX_VIDEO_PARAM_PORTFORMATTYPE *pInPortFmtType = NULL;
- OMX_VIDEO_PARAM_PORTFORMATTYPE *pOutPortFmtType = NULL;
- OMX_CONFIG_RECTTYPE *pOut2DBufAllocParam = NULL;
- OMX_CONFIG_RECTTYPE *pIn2DBufAllocParam = NULL;
- OMX_U32 i=0;
- OMX_U32 bFound = 0;
- OMX_U32 nFrameHeight = 0;
- OMX_U32 nFrameWidth = 0;
- struct PrepareForAdaptivePlaybackParams *pPrepareForAdaptivePlaybackParams;
- OMX_U32 framesize = 0;
- OMX_U32 metasize = 0;
-
- OMX_CHECK((hComponent != NULL) && (pParamStruct != NULL), OMX_ErrorBadParameter);
-
- /*! Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate;
-
- switch( (int) nIndex ) {
- case OMX_IndexParamPortDefinition :
- {
- /*! To set the Port Definition */
- OMX_BASE_CHK_VERSION(pParamStruct,
- OMX_PARAM_PORTDEFINITIONTYPE, eError);
-
- pPortDefs = (OMX_PARAM_PORTDEFINITIONTYPE *) pParamStruct;
- pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef);
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
-
- //Check if an invalid port index is not sent
- OMX_CHECK(pPortDefs->nPortIndex >= pVidDecComp->sBase.nMinStartPortIndex
- && pPortDefs->nPortIndex < (pVidDecComp->sBase.nNumPorts + pVidDecComp->sBase.nMinStartPortIndex),
- OMX_ErrorBadPortIndex);
-
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- // OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) ||
- // (pVidDecComp->sBase.pPorts[pPortDefs->nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
- // OMX_ErrorIncorrectStateOperation);
- // If Input Port Parameters have to be changed
- if( pPortDefs->nPortIndex == pInputPortDef->nPortIndex ) {
- /*! Check for correct resolution of the stream */
- nFrameWidth = pPortDefs->format.video.nFrameWidth;
- nFrameHeight = pPortDefs->format.video.nFrameHeight;
-
- OMX_CHECK((nFrameWidth <= OMX_VIDDEC_MAX_WIDTH),
- OMX_ErrorUnsupportedSetting);
- OMX_CHECK((nFrameHeight <= OMX_VIDDEC_MAX_HEIGHT),
- OMX_ErrorUnsupportedSetting);
- OMX_CHECK((((nFrameWidth * nFrameHeight) >> 16) <= OMX_VIDDEC_MAX_MACROBLOCK),
- OMX_ErrorUnsupportedSetting);
-
- /*! Call function to set input port definition */
- eError = OMXVidDec_SetInPortDef(hComponent, pPortDefs);
- if( eError != OMX_ErrorNone ) {
- goto EXIT;
- }
- if( pVidDecComp->sBase.tCurState != OMX_StateLoaded ) {
- pVidDecComp->nCodecRecreationRequired = 1;
- }
- }
- // If Output Port Parameters have to be changed
- else if( pPortDefs->nPortIndex == pOutputPortDef->nPortIndex ) {
- // Check the buffer cnt is greater than min required
- // buffer count
- OMX_CHECK((pPortDefs->nBufferCountActual
- >= pOutputPortDef->nBufferCountMin),
- OMX_ErrorUnsupportedSetting);
- // Check if Resolution being set at output port is same
- // as the input port
- OMX_CHECK((pOutputPortDef->format.video.nFrameHeight
- == pPortDefs->format.video.nFrameHeight)
- && (pOutputPortDef->format.video.nFrameWidth
- == pPortDefs->format.video.nFrameWidth),
- OMX_ErrorUnsupportedSetting);
-
- OMX_CHECK((OMX_U32)pPortDefs->format.video.nStride >=
- pOutputPortDef->format.video.nFrameWidth,
- OMX_ErrorUnsupportedSetting);
- if( (OMX_U32)pPortDefs->format.video.nStride >
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) {
- //Supported values of stride are only multiples of 128
- OMX_CHECK((pPortDefs->format.video.nStride & 0x7F) == 0,
- OMX_ErrorUnsupportedSetting);
- }
- //Check for the supported Color-fromat
- //and compression format.
-
- if (pVidDecComp->sBase.pPorts[pOutputPortDef->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) {
- //OMX_CHECK((pOutputPortDef->format.video.eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT),
- // OMX_ErrorUnsupportedSetting);
- } else {
- OMX_CHECK((pOutputPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar),
- OMX_ErrorUnsupportedSetting);
- }
-
- OMX_CHECK((pOutputPortDef->format.video.eCompressionFormat ==
- OMX_VIDEO_CodingUnused),
- OMX_ErrorUnsupportedSetting);
-
- /*! Call function to set output port definition */
- eError = OMXVidDec_SetOutPortDef(pVidDecComp, pPortDefs);
- if( eError != OMX_ErrorNone ) {
- goto EXIT;
- }
- }
- }
-
- /* If MPEG2 and Error Concealment; then memplugin_alloc for pOutBufDescPtr->descs[2] one time allocation only.*/
- if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) {
- if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment) {
- /* It's MPEG2 and ErrorConcealment is ON; calculate metadata buffer size based on formula described in MPEG2 User Guide */
- framesize = (((pInputPortDef->format.video.nFrameWidth + 15) / 16) * 16) * (((pInputPortDef->format.video.nFrameHeight + 15) / 16) * 16);
- metasize = ((framesize >> 8) * 112) + framesize;
- if (pVidDecComp->pmetaBuffer && pVidDecComp->pmetaBuffer->size < metasize) {
- memplugin_free((void*)H2P(pVidDecComp->pmetaBuffer));
- pVidDecComp->pmetaBuffer = NULL;
- }
- if (pVidDecComp->pmetaBuffer == NULL) {
- pVidDecComp->pmetaBuffer = P2H(memplugin_alloc(metasize, 1, MEM_CARVEOUT, 0, 0));
- OMX_CHECK(pVidDecComp->pmetaBuffer != NULL, OMX_ErrorInsufficientResources);
- }
- }
- }
- break;
-
- case OMX_IndexParamVideoPortFormat :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError);
- pVideoParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *) pParamStruct;
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- OMX_CHECK((pVidDecComp->sBase.tCurState == OMX_StateLoaded) ||
- (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
- OMX_ErrorIncorrectStateOperation);
-
- pInPortFmtType = &(pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]);
- pOutPortFmtType = &(pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]);
- // If Input Port Format type has to be changed
- if( pVideoParams->nPortIndex == pInPortFmtType->nPortIndex ) {
- // Change Compression type and frame-rate
- pInPortFmtType->eCompressionFormat
- = pVideoParams->eCompressionFormat;
- pInPortFmtType->xFramerate = pVideoParams->xFramerate;
- }
- // In case Output Port Format type has to be changed
- else if( pVideoParams->nPortIndex == pOutPortFmtType->nPortIndex ) {
- //Check for the supported Color-fromat
- //and compression format.
- if (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) {
- // OMX_CHECK((pVideoParams->eColorFormat == HAL_NV12_PADDED_PIXEL_FORMAT),
- // OMX_ErrorUnsupportedSetting);
- } else {
- OMX_CHECK((pVideoParams->eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar),
- OMX_ErrorUnsupportedSetting);
- }
- OMX_CHECK((pVideoParams->eCompressionFormat ==
- OMX_VIDEO_CodingUnused), OMX_ErrorUnsupportedSetting);
-
- pOutputPortDef->format.video.eColorFormat
- = pVideoParams->eColorFormat;
-
- // Change Compression type, color format and frame-rate
- pOutPortFmtType->eCompressionFormat
- = pVideoParams->eCompressionFormat;
- pOutPortFmtType->eColorFormat = pVideoParams->eColorFormat;
- pOutPortFmtType->xFramerate = pVideoParams->xFramerate;
- }
- }
- break;
-
- case OMX_IndexParamStandardComponentRole :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_COMPONENTROLETYPE, eError);
-
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded,
- OMX_ErrorIncorrectStateOperation);
- /*! In case there is change in Role */
- if( strcmp((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole,
- (char *)pVidDecComp->tComponentRole.cRole)) {
- /* De-initialize the current codec */
- pVidDecComp->fpDeinit_Codec(hComponent);
-
- /* Call specific component init depending upon the
- cRole set. */
- i=0;
- while( NULL != DecoderList[i].cRole[0] ) {
- if( strcmp((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole,
- (char *)DecoderList[i].cRole) == 0 ) {
- /* Component found */
- bFound = 1;
- break;
- }
- i++;
- }
-
- if( bFound == 0 ) {
- OSAL_ErrorTrace("Unsupported Role set");
- eError = OMX_ErrorUnsupportedSetting;
- goto EXIT;
- }
- /* Call the Specific Decoder Init function and Initialize Params */
- eError = DecoderList[i].fpDecoderComponentInit(hComponent);
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- OMXVidDec_InitDecoderParams(hComponent, pHandle->pComponentPrivate);
-
- strcpy((char *)pVidDecComp->tComponentRole.cRole,
- (char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole);
- }
- }
- break;
-
- case OMX_TI_IndexParamTimeStampInDecodeOrder :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER, eError);
-
- /* SetParameter can be invoked in Loaded State or on Disabled ports only*/
- OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded,
- OMX_ErrorIncorrectStateOperation);
- if(((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled == OMX_TRUE ) {
- pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_TRUE;
- } else {
- pVidDecComp->bSupportDecodeOrderTimeStamp = OMX_FALSE;
- }
- }
- break;
-
- case (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode :
- {
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE, eError);
-
- /* This SetParameter can be invoked in Loaded State only as it needs codec recreate.*/
- OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded,
- OMX_ErrorIncorrectStateOperation);
- if(((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled == OMX_TRUE ) {
- pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_TRUE;
- } else {
- pVidDecComp->bEnableDecodeZeroDisplayDelayMode = OMX_FALSE;
- }
- }
- break;
-
- case (OMX_INDEXTYPE) OMX_TI_IndexPrepareForAdaptivePlayback:
- {
- OMX_BASE_CHK_VERSION(pParamStruct, PrepareForAdaptivePlaybackParams, eError);
- /* This SetParameter can be invoked in Loaded State only as it needs codec recreate.*/
- OMX_CHECK(pVidDecComp->sBase.tCurState == OMX_StateLoaded,
- OMX_ErrorIncorrectStateOperation);
- pPrepareForAdaptivePlaybackParams = (PrepareForAdaptivePlaybackParams *) pParamStruct;
- pVidDecComp->bisAdaptivePlayback = pPrepareForAdaptivePlaybackParams->bEnable;
- pVidDecComp->nAdaptiveMaxFrameWidth = pPrepareForAdaptivePlaybackParams->nMaxFrameWidth;
- pVidDecComp->nAdaptiveMaxFrameHeight = pPrepareForAdaptivePlaybackParams->nMaxFrameHeight;
- }
- break;
-
-
- default :
- eError = OMXBase_SetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-/*
-* Video Decoder Get Parameter
-*/
-OMX_ERRORTYPE OMXVidDec_GetParameter(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pParamStruct)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoParams = NULL;
- OMX_CONFIG_RECTTYPE *p2DBufferAllocParams = NULL;
- OMX_VIDEO_PARAM_PORTFORMATTYPE inPortParam;
- OMX_VIDEO_PARAM_PORTFORMATTYPE outPortParam;
- OMX_TI_PARAMNATIVEBUFFERUSAGE *pUsage = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pPortDef = NULL;
- OMX_U32 nStartPortNumber, nPorts, nPortIndex;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- struct DescribeColorFormatParams *Colorparams;
-
- OMX_CHECK((hComponent != NULL) &&
- (pParamStruct != NULL), OMX_ErrorBadParameter);
-
- // Initialize the local variables
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp*)pHandle->pComponentPrivate;
-
- /* GetParameter can't be invoked incase the comp is in Invalid State */
- OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid,
- OMX_ErrorIncorrectStateOperation);
-
- switch( (int) nIndex ) {
- case OMX_IndexParamPortDefinition:
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE,
- eError);
- pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct;
-
- nPorts = pVidDecComp->sBase.nNumPorts;
- nStartPortNumber = pVidDecComp->sBase.nMinStartPortIndex;
-
- nPortIndex = pPortDef->nPortIndex - nStartPortNumber;
- /* check for valid port index */
- OMX_CHECK(nPortIndex < nPorts, OMX_ErrorBadPortIndex);
- *pPortDef = pVidDecComp->sBase.pPorts[nPortIndex]->sPortDef;
- if (pPortDef->eDir == OMX_DirOutput &&
- pVidDecComp->sBase.pPorts[nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) {
- pPortDef->format.video.eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT;
- }
- break;
-
- case OMX_IndexParamVideoPortFormat :
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError);
- // Initialize Port Params
- pVideoParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *) pParamStruct;
- inPortParam = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT];
- outPortParam = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT];
- if( pVideoParams->nPortIndex == inPortParam.nPortIndex ) {
- if( pVideoParams->nIndex > inPortParam.nIndex ) {
- return (OMX_ErrorNoMore);
- }
- pVideoParams->eCompressionFormat = inPortParam.eCompressionFormat;
- pVideoParams->eColorFormat = inPortParam.eColorFormat;
- pVideoParams->xFramerate = inPortParam.xFramerate;
- if(pVideoParams->eColorFormat == OMX_COLOR_FormatYUV420PackedSemiPlanar)
- pVideoParams->eColorFormat = OMX_COLOR_FormatYUV420Flexible; // OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
- } else if( pVideoParams->nPortIndex == outPortParam.nPortIndex ) {
- if( pVideoParams->nIndex == 0 ) {
- if (pVidDecComp->sBase.pPorts[pVideoParams->nPortIndex]->sProps.eBufMemoryType == MEM_GRALLOC) {
- pVideoParams->eColorFormat = HAL_NV12_PADDED_PIXEL_FORMAT;
- } else {
- pVideoParams->eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
- }
- } else if( pVideoParams->nIndex > outPortParam.nIndex ) {
- return (OMX_ErrorNoMore);
- }
- pVideoParams->eCompressionFormat = outPortParam.eCompressionFormat;
- pVideoParams->xFramerate = outPortParam.xFramerate;
- }
- break;
-
- case OMX_IndexParamStandardComponentRole :
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_COMPONENTROLETYPE, eError);
- strcpy((char *)((OMX_PARAM_COMPONENTROLETYPE *)pParamStruct)->cRole,
- (char *)pVidDecComp->tComponentRole.cRole);
- break;
-
- case (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage:
- pUsage = (OMX_TI_PARAMNATIVEBUFFERUSAGE*)pParamStruct;
- pUsage->nUsage = GRALLOC_USAGE_HW_RENDER;
- break;
-
- case (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat:
- Colorparams = (struct DescribeColorFormatParams*)(pParamStruct);
-
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
-
- struct MediaImage *image = &(Colorparams->sMediaImage);
- memset(image, 0, sizeof(MediaImage));
-
- image->mWidth = pOutputPortDef->format.video.nFrameWidth;
- image->mHeight = pOutputPortDef->format.video.nFrameHeight;
-
- image->mType = MEDIA_IMAGE_TYPE_YUV;
- image->mNumPlanes = 3;
- image->mBitDepth = 8;
- /* The crop left and top calculation is not needed here.
- Stagefright will add pBuffer->nOffset to this Y offset. */
- image->mPlane[Y].mOffset = 0;
- image->mPlane[Y].mColInc = 1;
- image->mPlane[Y].mRowInc = pOutputPortDef->format.video.nStride;
- image->mPlane[Y].mHorizSubsampling = 1;
- image->mPlane[Y].mVertSubsampling = 1;
-
- /* Since the position of the Buffer is at the starting of Y buffer (UV offset from base - Y offset),
- UV offset = (Stride*Height + (Top/2)*Stride + Left )- (Top*Stride + Left)
- on simplification
- UV offset = Stride*Height - (Top/2)*Stride */
- image->mPlane[U].mOffset = pOutputPortDef->format.video.nStride * pOutputPortDef->format.video.nFrameHeight;
- image->mPlane[U].mColInc = 2;
- image->mPlane[U].mRowInc = pOutputPortDef->format.video.nStride;
- image->mPlane[U].mHorizSubsampling = 2;
- image->mPlane[U].mVertSubsampling = 2;
-
- image->mPlane[V].mOffset = image->mPlane[U].mOffset + 1;
- image->mPlane[V].mColInc = 2;
- image->mPlane[V].mRowInc = pOutputPortDef->format.video.nStride;
- image->mPlane[V].mHorizSubsampling = 2;
- image->mPlane[V].mVertSubsampling = 2;
-
- break;
-
- case (OMX_INDEXTYPE) OMX_TI_IndexParamTimeStampInDecodeOrder :
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER, eError);
- if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) {
- ((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled = OMX_TRUE;
- } else {
- ((OMX_TI_PARAM_TIMESTAMP_IN_DECODE_ORDER *) pParamStruct)->bEnabled = OMX_FALSE;
- }
- break;
-
- case (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode :
- OMX_BASE_CHK_VERSION(pParamStruct, OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE, eError);
- if( pVidDecComp->bEnableDecodeZeroDisplayDelayMode == OMX_TRUE ) {
- ((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled = OMX_TRUE;
- } else {
- ((OMX_TI_ENABLE_DECODER_ZERODISPLAYDELAY_MODE *) pParamStruct)->bEnabled = OMX_FALSE;
- }
- break;
-
- default :
- eError = OMXBase_GetParameter(hComponent, nIndex, pParamStruct);
- }
-
-EXIT:
- return (eError);
-}
-
-/*
-* Video decoder GetConfig
-*/
-OMX_ERRORTYPE OMXVidDec_GetConfig(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure) {
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_CONFIG_RECTTYPE *pCropParams = NULL;
- OMX_CONFIG_SCALEFACTORTYPE *pScaleParams = NULL;
-
- OMX_CHECK((hComponent != NULL) &&
- (pComponentConfigStructure != NULL), OMX_ErrorBadParameter);
-
- // Initialize the local variables
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- /* GetConfig can't be invoked incase the comp is in Invalid State */
- OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid,
- OMX_ErrorIncorrectStateOperation);
-
- switch( nIndex ) {
- case OMX_IndexConfigCommonOutputCrop :
- {
- OMX_BASE_CHK_VERSION(pComponentConfigStructure, OMX_CONFIG_RECTTYPE, eError);
- pCropParams = (OMX_CONFIG_RECTTYPE *) pComponentConfigStructure;
- if( pCropParams->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- pCropParams->nWidth = pVidDecComp->tCropDimension.nWidth;
- pCropParams->nHeight = pVidDecComp->tCropDimension.nHeight;
- pCropParams->nTop = pVidDecComp->tCropDimension.nTop;
- pCropParams->nLeft = pVidDecComp->tCropDimension.nLeft;
- } else {
- eError = OMX_ErrorBadParameter;
- OSAL_ErrorTrace("OMX_IndexConfigCommonOutputCrop called on i/p port. Not Supported.");
- }
- }
- break;
-
- case OMX_IndexConfigCommonScale :
- {
- OMX_BASE_CHK_VERSION(pComponentConfigStructure, OMX_CONFIG_SCALEFACTORTYPE, eError);
- pScaleParams = (OMX_CONFIG_SCALEFACTORTYPE *) pComponentConfigStructure;
- if( pScaleParams->nPortIndex == OMX_VIDDEC_OUTPUT_PORT ) {
- pScaleParams->xWidth = pVidDecComp->tScaleParams.xWidth;
- pScaleParams->xHeight = pVidDecComp->tScaleParams.xHeight;
- OSAL_ErrorTrace("OMX_IndexConfigCommonScale called on o/p port.");
- } else {
- eError = OMX_ErrorBadParameter;
- OSAL_ErrorTrace("OMX_IndexConfigCommonOutputCrop called on i/p port. Not Supported.");
- }
- }
- break;
-
- default :
- eError = OMXBase_GetConfig(hComponent, nIndex, pComponentConfigStructure);
- }
-
-EXIT:
- return (eError);
-}
-
-/*
-* Video Decoder SetConfig
-*/
-OMX_ERRORTYPE OMXVidDec_SetConfig(OMX_HANDLETYPE hComponent,
- OMX_INDEXTYPE nIndex, OMX_PTR pComponentConfigStructure) {
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- OMX_CHECK((hComponent != NULL) &&
- (pComponentConfigStructure != NULL), OMX_ErrorBadParameter);
-
- // Initialize the local variables
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- /* SetConfig can't be invoked incase the comp is in Invalid State */
- OMX_CHECK(pVidDecComp->sBase.tCurState != OMX_StateInvalid,
- OMX_ErrorIncorrectStateOperation);
-
- switch( nIndex ) {
- default :
- eError = OMXBase_SetConfig(hComponent, nIndex, pComponentConfigStructure);
- }
-
-EXIT:
- return (eError);
-}
-
-/*
-* Video Decoder xlateBuffer Handles
-*/
-OMX_ERRORTYPE OMXVidDec_XlateBuffHandle(OMX_HANDLETYPE hComponent,
- OMX_PTR pBufferHdr, OMX_BOOL bRegister)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pComp = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_BUFFERHEADERTYPE *pOMXBufHeader;
- OMXBase_Port *pPort;
- OMX_U32 nPortIndex;
- int32_t tRetVal;
- int i;
-
- pComp = (OMX_COMPONENTTYPE *)(hComponent);
- pVidDecComp = (OMXVidDecComp *)pComp->pComponentPrivate;
-
- pOMXBufHeader = (OMX_BUFFERHEADERTYPE *) (pBufferHdr);
- nPortIndex = (pOMXBufHeader->nInputPortIndex == OMX_NOPORT) ?
- pOMXBufHeader->nOutputPortIndex :
- pOMXBufHeader->nInputPortIndex;
-
- pPort = pVidDecComp->sBase.pPorts[nPortIndex];
-
- /* Non a buffer allocator, then check if any xlation is needed */
- if (pPort->sProps.eBufMemoryType == MEM_GRALLOC) {
- //populate the DMA BUFF_FDs from the gralloc pointers
- for ( i = 0; i < MAX_PLANES_PER_BUFFER; i++ ) {
- ((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd = (OMX_U32)(((IMG_native_handle_t*)(pOMXBufHeader->pBuffer))->fd[i]);
- if (((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd > 0) {
- if (bRegister) {
- dce_buf_lock(1, (size_t *)&(((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd));
- } else {
- dce_buf_unlock(1, (size_t *)&(((OMXBase_BufHdrPvtData *)(pOMXBufHeader->pPlatformPrivate))->sMemHdr[i].dma_buf_fd));
- }
- }
- }
- }
-
-EXIT:
- return (eError);
-}
-
-/*
-* video decoder Command Notify
-*/
-OMX_ERRORTYPE OMXVidDec_CommandNotify(OMX_HANDLETYPE hComponent,
- OMX_COMMANDTYPE Cmd, OMX_U32 nParam, OMX_PTR pCmdData)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- XDAS_Int32 status;
- OMX_U32 ReturnCmdCompletionCallBack = 1, i;
- OMX_PTR pDecStaticParams;
- OMX_PTR pDecDynamicParams;
- OMX_PTR pDecStatus;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef;
- OMX_U32 nFrameWidth, nFrameHeight;
- OMX_U32 nFrameWidthOrig;
- (void) pCmdData;
-
- OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = pHandle->pComponentPrivate;
-
- switch( Cmd ) {
- case OMX_CommandStateSet :
- if( pVidDecComp->sBase.tCurState == OMX_StateLoaded &&
- pVidDecComp->sBase.tNewState == OMX_StateIdle ) {
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- // Check the buffer cnt is greater than min required
- // buffer count
- if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) {
- OSAL_ErrorTrace("Number of actual buffers on o/p port less than the minmum required by componenet as set on o/p port defs");
- eError = OMX_ErrorUnsupportedSetting;
- goto EXIT;
- }
-
- // Transitioning from Loaded to Idle state
- if(pVidDecComp->pDecHandle == NULL ) {
- pDecStaticParams = pVidDecComp->pDecStaticParams;
- // Call the Video Decoder Create Call
- pVidDecComp->pDecHandle
- = VIDDEC3_create(pVidDecComp->ce,
- pVidDecComp->cDecoderName,
- (VIDDEC3_Params *) pDecStaticParams);
-
- if( pVidDecComp->pDecHandle == NULL ) {
- OSAL_ErrorTrace("VIDDEC3_create failed ....! \n");
- eError = OMX_ErrorInsufficientResources;
- pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE;
- goto EXIT;
- }
- pVidDecComp->nCodecRecreationRequired = 0;
- pVidDecComp->nOutPortReconfigRequired = 0;
-
- // Populate Dynamic Params and the Status structures
- pVidDecComp->fpSet_DynamicParams(hComponent, pVidDecComp->pDecDynParams);
- pVidDecComp->fpSet_Status(hComponent, pVidDecComp->pDecStatus);
- //This is to handle Arbitrary stride requirement given by IL client.
- if((OMX_U32)pOutputPortDef->format.video.nStride >
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth) {
- pVidDecComp->pDecDynParams->displayWidth =
- pOutputPortDef->format.video.nStride;
- }
- pDecDynamicParams = pVidDecComp->pDecDynParams;
- pDecStatus = pVidDecComp->pDecStatus;
-
- OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter);
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
-
- // Call the Decoder Control function
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETBUFINFO, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_GETBUFINFO failed! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- }
- } else if( pVidDecComp->sBase.tCurState == OMX_StateIdle &&
- pVidDecComp->sBase.tNewState == OMX_StateLoaded ) {
- // Transitioning from Idle to Loaded
- if( pVidDecComp->pDecHandle != NULL ) {
- // Delete the Decoder Component Private Handle
- pVidDecComp->nFrameCounter = 0;
- if( pVidDecComp->bSupportSkipGreyOutputFrames ) {
- pVidDecComp->bSyncFrameReady = OMX_FALSE;
- }
-
- pVidDecComp->nOutbufInUseFlag = 0;
- VIDDEC3_delete(pVidDecComp->pDecHandle);
- pVidDecComp->pDecHandle = NULL;
- }
-
- } else if(((pVidDecComp->sBase.tCurState == OMX_StateExecuting) &&
- (pVidDecComp->sBase.tNewState == OMX_StateIdle)) ||
- ((pVidDecComp->sBase.tCurState == OMX_StatePause) &&
- (pVidDecComp->sBase.tNewState == OMX_StateIdle))) {
- OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL);
- }
-
- break;
-
- case OMX_CommandPortDisable :
- // In case of Port Disable Command
- // Loaded state implies codec is deleted. so no need to delete again
- if( pVidDecComp->sBase.tCurState != OMX_StateLoaded
- && pVidDecComp->pDecHandle != NULL ) {
- // Call Decoder Flush function
- OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL);
- }
- break;
-
- case OMX_CommandPortEnable :
- if( nParam == OMX_VIDDEC_OUTPUT_PORT ) {
- // Check the buffer cnt is greater than min required
- // buffer count
- pOutputPortDef =
- &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) {
- OSAL_ErrorTrace("Number of actual buffers on o/p port less than the minmum required by componenet as set on o/p port defs");
- eError = OMX_ErrorUnsupportedSetting;
- goto EXIT;
- }
- if( (OMX_U32)pOutputPortDef->format.video.nStride <
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) {
- OSAL_ErrorTrace("Unsupported Stride set on o/p port defs");
- eError = OMX_ErrorUnsupportedSetting;
- goto EXIT;
- }
- }
- if( pVidDecComp->sBase.tCurState != OMX_StateLoaded ) {
- if( pVidDecComp->nCodecRecreationRequired == 1
- && pVidDecComp->pDecHandle != NULL ) {
- pVidDecComp->nCodecRecreationRequired = 0;
- pVidDecComp->nFrameCounter = 0;
- pVidDecComp->tScaleParams.xWidth = 0x10000;
- pVidDecComp->tScaleParams.xHeight = 0x10000;
- if( pVidDecComp->bSupportSkipGreyOutputFrames ) {
- pVidDecComp->bSyncFrameReady = OMX_FALSE;
- }
- pVidDecComp->nOutbufInUseFlag = 0;
- VIDDEC3_delete(pVidDecComp->pDecHandle);
- pVidDecComp->pDecHandle = NULL;
-
- pOutputPortDef =
- &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- // Set the Static Params
- pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams);
- if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE
- && pVidDecComp->pDecStatus->outputWidth != 0
- && pVidDecComp->pDecStatus->outputHeight != 0 ) {
- nFrameWidth = pVidDecComp->pDecStatus->outputWidth;
- nFrameHeight = pVidDecComp->pDecStatus->outputHeight;
- } else {
- nFrameWidth = pOutputPortDef->format.video.nFrameWidth;
- nFrameHeight = pOutputPortDef->format.video.nFrameHeight;
- }
- if( nFrameWidth & 0x0F ) {
- nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F);
- }
- if( nFrameHeight & 0x1F ) {
- nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F);
- }
- nFrameWidthOrig = pOutputPortDef->format.video.nFrameWidth;
- if( nFrameWidthOrig & 0x0F ) {
- nFrameWidthOrig = nFrameWidthOrig + 16 - (nFrameWidthOrig & 0x0F);
- }
- pVidDecComp->pDecStaticParams->maxHeight = nFrameHeight;
- pVidDecComp->pDecStaticParams->maxWidth = nFrameWidth;
-
- /* Check whether the displayWidth already accounts for any
- * difference between the current and new frame width and
- * set maxWidth accordingly */
- if ( nFrameWidth != nFrameWidthOrig &&
- nFrameWidthOrig == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) {
- pVidDecComp->pDecStaticParams->maxWidth = nFrameWidthOrig;
- }
-
- // And Call the Codec Create
- pVidDecComp->pDecHandle = VIDDEC3_create(pVidDecComp->ce,
- pVidDecComp->cDecoderName,
- (VIDDEC3_Params *)
- pVidDecComp->pDecStaticParams);
- if( pVidDecComp->pDecHandle == NULL ) {
- OSAL_ErrorTrace("VIDDEC3_create failed ....! \n");
- eError = OMX_ErrorInsufficientResources;
- pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE;
- goto EXIT;
- }
-
- // Populate Dynamic Params and the Status structures
- pVidDecComp->fpSet_DynamicParams(hComponent, pVidDecComp->pDecDynParams);
- pVidDecComp->fpSet_Status(hComponent, pVidDecComp->pDecStatus);
- //This is to handle Arbitrary stride requirement given by IL client.
- if((OMX_U32)pOutputPortDef->format.video.nStride !=
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth) {
- pVidDecComp->pDecDynParams->displayWidth =
- pOutputPortDef->format.video.nStride;
- }
- pDecDynamicParams = pVidDecComp->pDecDynParams;
- pDecStatus = pVidDecComp->pDecStatus;
-
- // Call the Decoder Control function
- OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter);
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- }
- pVidDecComp->nOutPortReconfigRequired = 0;
- }
-
- break;
-
- case OMX_CommandFlush :
- {
- // In case of Flush Command
- // In case all ports have to be flushed or the output port
- // has to be flushed
- if( nParam == OMX_ALL || nParam == OMX_VIDDEC_OUTPUT_PORT ) {
- // Only then flush the port
- OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL);
- }
- }
- break;
-
- case OMX_CommandMarkBuffer :
- ReturnCmdCompletionCallBack = 0;
- break;
-
- default:
- OSAL_ErrorTrace("Invalid command");
- }
-
- if( ReturnCmdCompletionCallBack == 1 ) {
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent,
- OMX_EventCmdComplete, Cmd, nParam, NULL);
- }
-
-EXIT:
- return (eError);
-
-}
-
-/*
-* Video Decoder DataNotify
-*/
-OMX_ERRORTYPE OMXVidDec_DataNotify(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone, eRMError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMX_BUFFERHEADERTYPE sInBufHeader;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_BUFFERHEADERTYPE *pInBufHeader = NULL;
- OMX_BUFFERHEADERTYPE *pOutBufHeader = NULL;
- OMX_BUFFERHEADERTYPE *pDupBufHeader = NULL;
- OMX_BUFFERHEADERTYPE *pFreeBufHeader = NULL;
- OMX_U32 nInMsgCount = 0;
- OMX_U32 nOutMsgCount = 0;
- OMX_U32 Buffer_locked = 1;
- OMX_U32 ii = 0, i, jj = 0;
- OMX_U32 nStride = 0;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL;
- OMX_BOOL nIsDioReady = OMX_FALSE;
- XDAS_Int32 status;
- XDM2_BufDesc *pInBufDescPtr = NULL;
- XDM2_BufDesc *pOutBufDescPtr = NULL;
- OMX_CONFIG_RECTTYPE out2DAllocParam;
- IVIDDEC3_OutArgs *pDecOutArgs = NULL;
- IVIDDEC3_Status *pDecStatus = NULL;
- XDM_Rect activeFrameRegion[2];
- OMX_U32 nNewInBufferRequired = 0;
- OMX_BOOL bSendPortReconfigForScale = OMX_FALSE;
- OMX_U32 nScale, nScaleRem, nScaleQ16Low, nScaleWidth, nScaleHeight;
- OMX_U64 nScaleQ16 = 0;
- uint32_t nActualSize;
- OMX_BOOL went_thru_loop = OMX_FALSE;
- OMX_BOOL duped_IPbuffer = OMX_TRUE;
- IMG_native_handle_t* grallocHandle;
- OMX_U32 nLockedCount = 0;
-
- OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
-
- //! Initialize pointers
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- OMX_CHECK(pVidDecComp != NULL, OMX_ErrorBadParameter);
-
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef);
- out2DAllocParam = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT];
-
- /*! Ensure that the stride on output portdef structure is more than
- the padded width. This is needed in the case where application
- sets the Stride less than padded width */
- if( (OMX_U32)pOutputPortDef->format.video.nStride >=
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth ) {
- nStride = pOutputPortDef->format.video.nStride;
- } else {
- nStride = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth;
- }
- if((pVidDecComp->sBase.tCurState != OMX_StateExecuting) ||
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.bEnabled == OMX_FALSE) ||
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.bEnabled == OMX_FALSE)) {
- goto EXIT;
- }
- nIsDioReady = OMXBase_IsDioReady(hComponent, OMX_VIDDEC_OUTPUT_PORT);
- if( nIsDioReady == OMX_FALSE ) {
- goto EXIT;
- }
- //! Get the number of input and output buffers
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_INPUT_PORT,
- (OMX_PTR)&nInMsgCount);
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_OUTPUT_PORT,
- (OMX_PTR)&nOutMsgCount);
-
- // Loop until input or output buffers are exhausted
- while((nInMsgCount > 0) && (nOutMsgCount > 0)) {
- // Only if Cur-State is Execute proceed.
- if((pVidDecComp->sBase.tCurState != OMX_StateExecuting) ||
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.bEnabled == OMX_FALSE) ||
- (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.bEnabled == OMX_FALSE)) {
- break;
- }
- if( OMXBase_IsCmdPending(hComponent) && pVidDecComp->nOutbufInUseFlag == 0 ) {
- OSAL_ErrorTrace("Exiting dataNotify because command is pending");
- goto EXIT;
- }
- if( pVidDecComp->nOutPortReconfigRequired == 1 ) {
- OSAL_ErrorTrace("Port disable/reconfiguration needed");
- goto EXIT;
- }
- if( pVidDecComp->nFatalErrorGiven == 1 ) {
- OSAL_ErrorTrace("Fatal error given to IL client");
- goto EXIT;
- }
- // Buffer is locked by the codec by default.
- // It can be freed only if mentioned in freeBufId[] field.
- Buffer_locked = 1;
- ii=0;
- went_thru_loop = OMX_TRUE;
- if( nNewInBufferRequired == 0 && pVidDecComp->sCodecConfig.sBuffer == NULL ) {
- duped_IPbuffer = OMX_FALSE;
- //! Get Input and Output Buffer header from Queue
- eError = pVidDecComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_VIDDEC_INPUT_PORT,
- (OMX_PTR*)(&pInBufHeader));
- if( eError == OMX_TI_WarningAttributePending ) {
- pVidDecComp->sCodecConfig.sBuffer = P2H(memplugin_alloc(2, 1, MEM_CARVEOUT, 0, 0));
- OMX_CHECK(pVidDecComp->sCodecConfig.sBuffer != NULL, OMX_ErrorInsufficientResources);
- eError = pVidDecComp->sBase.pPvtData->fpDioControl(hComponent, OMX_VIDDEC_INPUT_PORT,
- OMX_DIO_CtrlCmd_GetCtrlAttribute, (OMX_PTR)&(pVidDecComp->sCodecConfig));
- if( eError == OMX_TI_WarningInsufficientAttributeSize ) {
- /*Allocate the data pointer again with correct size*/
- uint32_t new_size = pVidDecComp->sCodecConfig.sBuffer->size;
- memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer));
- pVidDecComp->sCodecConfig.sBuffer = P2H(memplugin_alloc(new_size, 1, MEM_CARVEOUT, 0, 0));
- OMX_CHECK(pVidDecComp->sCodecConfig.sBuffer != NULL, OMX_ErrorInsufficientResources);
- eError = pVidDecComp->sBase.pPvtData->fpDioControl(hComponent, OMX_VIDDEC_INPUT_PORT,
- OMX_DIO_CtrlCmd_GetCtrlAttribute, (OMX_PTR)&(pVidDecComp->sCodecConfig));
- if( eError != OMX_ErrorNone ) {
- OSAL_ErrorTrace("Codec config test failed because DIO Control returned buffer");
- goto EXIT;
- }
- }
- pVidDecComp->pDecDynParams->decodeHeader = pVidDecComp->nDecoderMode;
- pInBufHeader = NULL;
- // Call the Decoder Control function
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- } else if( pVidDecComp->nOutbufInUseFlag == 0 ) {
- if( pVidDecComp->pDecDynParams->decodeHeader != XDM_DECODE_AU ) {
- pVidDecComp->pDecDynParams->decodeHeader = XDM_DECODE_AU;
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- }
- if( pInBufHeader ) {
- if(!(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) && (pInBufHeader->nFilledLen - pInBufHeader->nOffset == 0)) {
- // Send Input buffer back to base
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent,
- OMX_VIDDEC_INPUT_PORT,
- pInBufHeader);
-
- //! Get the number of input and output buffers
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_INPUT_PORT,
- (OMX_PTR)&nInMsgCount);
- if( nInMsgCount ) {
- continue;
- } else {
- break;
- }
- }
- }
- nLockedCount = 0;
- while (nLockedCount < nOutMsgCount) {
- eError = pVidDecComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_VIDDEC_OUTPUT_PORT,
- (OMX_PTR*)(&pOutBufHeader));
- if (pOutBufHeader) {
- // check locked flag
- if (((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bIsLocked) {
- nLockedCount++;
- // Send the buffer to the back of the queue
- pVidDecComp->sBase.pPvtData->fpDioQueue(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader);
- pOutBufHeader = NULL;
- // Get the number of output buffers
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_OUTPUT_PORT,
- (OMX_PTR)&nOutMsgCount);
- continue;
- }
- }
- // if we get here we have our buffer, or it is an error
- break;
- }
- if (pOutBufHeader == NULL) {
- // Cancel input buffer and continue
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_INPUT_PORT,
- pInBufHeader);
-
- goto EXIT;
- }
- }
- }
- pOutBufDescPtr = pVidDecComp->tOutBufDesc;
- pInBufDescPtr = pVidDecComp->tInBufDesc;
- if( pVidDecComp->sCodecConfig.sBuffer != NULL &&
- (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) {
- pVidDecComp->pDecDynParams->decodeHeader = pVidDecComp->nDecoderMode;
- // Call the Decoder Control function
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_SETPARAMS,
- pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_SETPARAMS failed ....! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- }
- pInBufDescPtr->numBufs = 1;
- if( pInBufHeader != NULL && pVidDecComp->nOutbufInUseFlag == 1 ) {
- pVidDecComp->pDecInArgs->numBytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset;
- //Sending the same input ID for second field
- pVidDecComp->pDecInArgs->inputID = (OMX_S32) pOutBufHeader;
- if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) {
- (((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = pInBufHeader->nOffset;
- pInBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]);
- pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE;
- pInBufDescPtr->descs[0].bufSize.bytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset;
- pInBufDescPtr->descs[0].bufSize.tileMem.height = 1;
- }
- } else if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader == pVidDecComp->nDecoderMode ) {
- pVidDecComp->pDecInArgs->numBytes = pVidDecComp->sCodecConfig.sBuffer->size;
- pVidDecComp->pDecInArgs->inputID = 1;
- pVidDecComp->sCodecConfig.sBuffer->offset = sizeof(MemHeader);
- pInBufDescPtr->descs[0].buf = (XDAS_Int8*)(pVidDecComp->sCodecConfig.sBuffer);
- pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE;
- pInBufDescPtr->descs[0].bufSize.bytes = pVidDecComp->sCodecConfig.sBuffer->size;
- pInBufDescPtr->descs[0].bufSize.tileMem.height = 1;
- pOutBufDescPtr->numBufs = 0;
- } else if( pInBufHeader != NULL && pVidDecComp->pDecDynParams->decodeHeader == XDM_DECODE_AU ) {
- // In case EOS and Number of Input bytes=0. Flush Decoder and exit
- if( pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS ) {
- if( pInBufHeader->nFilledLen == 0 ) {
- pOutBufHeader->nFilledLen = 0;
- eError = OMXVidDec_HandleFLUSH_EOS(hComponent, pOutBufHeader, pInBufHeader);
- goto EXIT;
- } else {
- pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
- }
- }
- if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) {
- if( pOutputPortDef->format.video.nFrameWidth < out2DAllocParam.nWidth
- || pOutputPortDef->format.video.nFrameHeight < out2DAllocParam.nHeight ) {
-
- if (pVidDecComp->nFrameCounter) {
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader);
-
- OMXVidDec_HandleFirstFrame(hComponent, NULL);
- } else {
- pOutputPortDef->format.video.nFrameWidth = out2DAllocParam.nWidth;
- pOutputPortDef->format.video.nFrameHeight = out2DAllocParam.nHeight;
- pOutputPortDef->format.video.nStride = pOutputPortDef->format.video.nFrameWidth;
- pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride *
- ((pOutputPortDef->format.video.nFrameHeight * 3) >> 1);
- pInputPortDef->format.video.nFrameWidth = out2DAllocParam.nWidth;
- pInputPortDef->format.video.nFrameHeight = out2DAllocParam.nHeight;
-
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader);
-
- /*! Notify to Client change in output port settings */
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent,
- OMX_EventPortSettingsChanged, OMX_VIDDEC_OUTPUT_PORT, 0, NULL);
- pVidDecComp->nOutPortReconfigRequired = 1;
- }
- goto EXIT;
- }
- }
- /*! Populate xDM structure */
- pVidDecComp->pDecInArgs->numBytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset;
- pVidDecComp->pDecInArgs->inputID = (OMX_S32) pOutBufHeader;
- if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) {
- /* Fill Input Buffer Descriptor */
- (((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = pInBufHeader->nOffset;
- pInBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pInBufHeader->pPlatformPrivate)->sMemHdr[0]);
- pInBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE;
- pInBufDescPtr->descs[0].bufSize.bytes = pInBufHeader->nFilledLen - pInBufHeader->nOffset;
- pInBufDescPtr->descs[0].bufSize.tileMem.height = 1;
- }
- /* Initialize Number of Buffers for input and output */
- pInBufDescPtr->numBufs = 1;
- pOutBufDescPtr->numBufs = 2;
-
- /* Fill Output Buffer Descriptor */
- /* if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sProps.eBufMemoryType == MEM_GRALLOC) {
- pOutBufDescPtr->descs[0].bufSize.tileMem.width = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth;
- pOutBufDescPtr->descs[0].bufSize.tileMem.height = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight;
- (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]).offset = 0;
- pOutBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]);
- pOutBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILED8;
- (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]).offset = 0;
- pOutBufDescPtr->descs[1].bufSize.tileMem.width =pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth;
- pOutBufDescPtr->descs[1].bufSize.tileMem.height = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight / 2;
- pOutBufDescPtr->descs[1].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]);
- pOutBufDescPtr->descs[1].memType = XDM_MEMTYPE_TILED16;
- } else*/ {
- pOutBufDescPtr->descs[0].bufSize.bytes = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth *
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight;
- pOutBufDescPtr->descs[0].bufSize.tileMem.height = 1;
- pOutBufDescPtr->descs[0].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]);
- pOutBufDescPtr->descs[0].memType = XDM_MEMTYPE_TILEDPAGE;
-
- memcpy(&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]), &(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]), sizeof(MemHeader));
-
- (((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]).offset = pOutBufDescPtr->descs[0].bufSize.bytes;
-
- pOutBufDescPtr->descs[1].bufSize.bytes = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth *
- pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight/2;
- pOutBufDescPtr->descs[1].bufSize.tileMem.height = 1;
- pOutBufDescPtr->descs[1].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[1]);
- pOutBufDescPtr->descs[1].memType = XDM_MEMTYPE_TILEDPAGE;
- nStride = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth;
- }
-
- if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) {
- if (pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment) {
- /* provide metaBuffer to codec because it's MPEG2 with Error Concealment */
- pOutBufDescPtr->numBufs = 3;
- pVidDecComp->pmetaBuffer->offset = sizeof(MemHeader);
- pOutBufDescPtr->descs[2].buf = (XDAS_Int8*)(pVidDecComp->pmetaBuffer);
- pOutBufDescPtr->descs[2].memType = XDM_MEMTYPE_RAW;
- pOutBufDescPtr->descs[2].bufSize.bytes = pVidDecComp->pmetaBuffer->size;
- pOutBufDescPtr->descs[2].bufSize.tileMem.height = 1;
- }
- }
-
- pOutBufHeader->nTimeStamp = pInBufHeader->nTimeStamp;
- if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE && pVidDecComp->bInputBufferCancelled == 0 ) {
- OSAL_WriteToPipe(pVidDecComp->pTimeStampStoragePipe, &(pInBufHeader->nTimeStamp),
- sizeof(OMX_TICKS), OSAL_NO_SUSPEND);
- }
- }
- /*Copy OMX_BUFFERFLAG_DECODEONLY from input buffer header to output buffer header*/
- if (pOutBufHeader && pInBufHeader) {
- pOutBufHeader->nFlags |= (pInBufHeader->nFlags & OMX_BUFFERFLAG_DECODEONLY);
- ((OMXBase_BufHdrPvtData *)(pInBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC;
- ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC;
- }
-
- if (pOutBufHeader) {
- grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->lock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle, GRALLOC_USAGE_HW_RENDER,
- 0,0,pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth,
- pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight,NULL);
- ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bIsLocked = OMX_TRUE;
- }
-
- status = VIDDEC3_process(pVidDecComp->pDecHandle, pInBufDescPtr, pOutBufDescPtr,
- (VIDDEC3_InArgs *)pVidDecComp->pDecInArgs, (VIDDEC3_OutArgs *)pVidDecComp->pDecOutArgs);
-
- pDecOutArgs = pVidDecComp->pDecOutArgs;
-
- /*! In case this is an IPC failure */
- if(status == DCE_EIPC_CALL_FAIL) {
- ALOGE("\n Remote Core Communication Failure... \n");
- eError = OMX_ErrorHardware;
- pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE;
- goto EXIT;
- }
- /*! In case Process returns error */
- if(status == XDM_EFAIL ){
- ALOGE("\n Process function returned an Error... \n");
- ALOGE("Codec Extended - 0x%x", (OMX_U32)pVidDecComp->pDecOutArgs->extendedError);
- ALOGE("Input Buffer Size provided to codec is : %d", (int)pInBufDescPtr->descs[0].bufSize.bytes);
- ALOGE("Frame count is : %d", pVidDecComp->nFrameCounter + 1);
- ALOGE("Bytes consumed - %d", (int)pVidDecComp->pDecOutArgs->bytesConsumed);
-
- if( !(pVidDecComp->bInputBufferCancelled == 1 && pVidDecComp->pDecOutArgs->extendedError & 0x8000)) {
- /*! Call function to handle Codec Error */
- eError = OMXVidDec_HandleCodecProcError(hComponent, &(pInBufHeader), &(pOutBufHeader));
- }
- if( eError != OMX_ErrorNone ) {
- goto EXIT;
- }
- if( pVidDecComp->nOutPortReconfigRequired == 1 ) {
- goto EXIT;
- }
- }
- if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader == pVidDecComp->nDecoderMode ) {
- eError = OMXVidDec_HandleFirstFrame(hComponent, NULL);
- //we have to loop once again if we duplicated any input buffer
- if(duped_IPbuffer && nInMsgCount) {
- if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer && pVidDecComp->nOutPortReconfigRequired == 0 && went_thru_loop) {
- memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer));
- pVidDecComp->sCodecConfig.sBuffer = NULL;
- }
- continue;
- }
- goto EXIT;
- }
- // Increment the FrameCounter value
- pVidDecComp->nFrameCounter++;
- if( pDecOutArgs->outBufsInUseFlag && pVidDecComp->nOutbufInUseFlag == 1 ) {
- pVidDecComp->nFrameCounter--;
- }
- if( pDecOutArgs->outBufsInUseFlag ) {
- pVidDecComp->nOutbufInUseFlag = 1;
- /* Check for any output buffer which is freed by codec*/
- ii = 0;
- while( pDecOutArgs->freeBufID[ii] ) {
- if( pDecOutArgs->outputID[0] == 0 && pDecOutArgs->freeBufID[ii] == pVidDecComp->pDecInArgs->inputID ) {
- pVidDecComp->nOutbufInUseFlag = 0;
- pVidDecComp->nFrameCounter--;
- }
- pFreeBufHeader = (OMX_BUFFERHEADERTYPE *) pDecOutArgs->freeBufID[ii];
- ((OMXBase_BufHdrPvtData *)(pFreeBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE;
- grallocHandle = (IMG_native_handle_t*)(pFreeBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle);
-
- /* Send the Freed buffer back to base component */
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pFreeBufHeader);
- ii++;
- }
-
- if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) {
- ii = 0;
- if( pInBufHeader != NULL ) {
- if((pInBufHeader->nFilledLen - pInBufHeader->nOffset) != (OMX_U32)pDecOutArgs->bytesConsumed ) {
- nNewInBufferRequired = 1;
- pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed;
- continue;
- }
- nNewInBufferRequired = 0;
- pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed;
- if( !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS)) {
- // Send Input buffer back to base
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent,
- OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- } else if( pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS ) {
- OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, pInBufHeader);
- if( eError != OMX_ErrorNone ) {
- goto EXIT;
- }
- }
- }
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_INPUT_PORT, (OMX_PTR)&nInMsgCount);
- if( nInMsgCount > 0 ) {
- continue;
- } else {
- break;
- }
- }
- }
-
- // Check for the width/height after first frame
- if((pVidDecComp->nFrameCounter == 1) || (pVidDecComp->nOutbufInUseFlag == 1 && pVidDecComp->nFrameCounter == 2)) {
- eError = OMXVidDec_HandleFirstFrame(hComponent, &(pInBufHeader));
- if( eError != OMX_ErrorNone ) {
- goto EXIT;
- }
- if( pVidDecComp->nOutPortReconfigRequired == 1
- && pVidDecComp->pDecStaticParams->displayDelay
- != IVIDDEC3_DECODE_ORDER ) {
- /*! In case Port reconfiguration is required
- * output buffer */
- goto EXIT;
- }
- } // End of if condition from nFrameCounter = 1
-
- if( pVidDecComp->nOutbufInUseFlag == 1 ) {
- pVidDecComp->nOutbufInUseFlag = 0;
- nNewInBufferRequired = 0;
- }
- ii = 0;
- while( pDecOutArgs->outputID[ii] ) {
- pOutBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[ii];
- if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) {
- OSAL_ReadFromPipe(pVidDecComp->pTimeStampStoragePipe, &(pOutBufHeader->nTimeStamp),
- sizeof(OMX_TICKS), &(nActualSize), OSAL_NO_SUSPEND);
- }
-
- activeFrameRegion[0] = pDecOutArgs->displayBufs.bufDesc[0].activeFrameRegion;
- activeFrameRegion[1].bottomRight.y = (activeFrameRegion[0].bottomRight.y) / 2;
- activeFrameRegion[1].bottomRight.x = activeFrameRegion[0].bottomRight.x;
-
- //Crop rectangle handles the offsets for Y and UV buffers
- pOutBufHeader->nOffset = 0;
- pOutBufHeader->nFilledLen = (pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * nStride * 3) / 2;
-
- if((pVidDecComp->tCropDimension.nTop != activeFrameRegion[0].topLeft.y
- || pVidDecComp->tCropDimension.nLeft != activeFrameRegion[0].topLeft.x)
- || (pVidDecComp->tCropDimension.nWidth != (OMX_U32)(activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x)
- || pVidDecComp->tCropDimension.nHeight != (OMX_U32)(activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y))) {
- pVidDecComp->tCropDimension.nTop = activeFrameRegion[0].topLeft.y;
- pVidDecComp->tCropDimension.nLeft = activeFrameRegion[0].topLeft.x;
- pVidDecComp->tCropDimension.nWidth = activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x;
- pVidDecComp->tCropDimension.nHeight = activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y;
- if( pVidDecComp->bUsePortReconfigForCrop == OMX_TRUE ) {
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventPortSettingsChanged,
- OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonOutputCrop, NULL);
- if( eError != OMX_ErrorNone ) {
- OSAL_ErrorTrace("Port reconfig callback returned error, trying to continue");
- }
- }
- }
-
- if( pVidDecComp->bSupportSkipGreyOutputFrames ) {
- if( pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_I_FRAME ||
- pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IDR_FRAME ||
- pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IP_FRAME ||
- pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IB_FRAME ) {
- pVidDecComp->bSyncFrameReady = OMX_TRUE;
- }
- }
- grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle);
-
- if( pVidDecComp->bSyncFrameReady == OMX_TRUE ) {
- if( !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) || !(pVidDecComp->bIsFlushRequired)) {
- // Send the Output buffer to Base component
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader);
- }
- } else {
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader);
- }
- pDecOutArgs->outputID[ii] = 0;
- ii++;
- }
-
- jj = 0;
- while(pDecOutArgs->freeBufID[jj]) {
- // update locked flag of buffer to "unlocked"
- pFreeBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->freeBufID[jj];
- ((OMXBase_BufHdrPvtData *)(pFreeBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE;
- if (!ii && pDecOutArgs->freeBufID[jj] == pVidDecComp->pDecInArgs->inputID) {
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader);
- break;
- }
- jj++;
- }
-
- if(((IVIDDEC3_Params *)(pVidDecComp->pDecStaticParams))->inputDataMode == IVIDEO_ENTIREFRAME ) {
- if( pInBufHeader && pDecOutArgs &&
- (pVidDecComp->pDecDynParams->decodeHeader == XDM_DECODE_AU && pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE)) {
- if((pVidDecComp->bInputBufferCancelled == 1) && (((pDecOutArgs->bytesConsumed == 0) || (((OMX_S32)pInBufHeader->nFilledLen)
- <= ((OMX_S32)pInBufHeader->nOffset + pDecOutArgs->bytesConsumed + 3))) ||
- (pVidDecComp->pDecOutArgs->extendedError & 0x8000))) {
- pVidDecComp->bInputBufferCancelled = 0;
- } else if((((OMX_S32)pInBufHeader->nFilledLen) > ((OMX_S32)pInBufHeader->nOffset + pDecOutArgs->bytesConsumed + 3)) &&
- ((pDecOutArgs->bytesConsumed != 0) && !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS))) {
- pInBufHeader->nOffset = pInBufHeader->nOffset + pDecOutArgs->bytesConsumed;
- pVidDecComp->bInputBufferCancelled = 1;
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- }
- }
- /* Currently the assumption is that the entire input buffer is consumed
- * going forward we might have to handle cases where partial buffer is
- * consumed */
- if( pVidDecComp->bInputBufferCancelled == 0 ) {
- if( pInBufHeader != NULL &&
- !(pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) &&
- pVidDecComp->nOutPortReconfigRequired != 1 ) {
- pInBufHeader->nFilledLen
- = pInBufHeader->nFilledLen - pDecOutArgs->bytesConsumed - pInBufHeader->nOffset;
- pInBufHeader->nOffset = 0;
- // Send Input buffer back to base
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent,
- OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- }
- else if( pInBufHeader != NULL && (pInBufHeader->nFlags & OMX_BUFFERFLAG_EOS) &&
- pVidDecComp->nOutPortReconfigRequired != 1 ) {
- pInBufHeader->nFilledLen
- = pInBufHeader->nFilledLen - pDecOutArgs->bytesConsumed - pInBufHeader->nOffset;
- pInBufHeader->nOffset = 0;
- if( Buffer_locked == 1 ) {
- OMXVidDec_HandleFLUSH_EOS(hComponent, pDupBufHeader, pInBufHeader);
- } else {
- OMXVidDec_HandleFLUSH_EOS(hComponent, pOutBufHeader, pInBufHeader);
- }
- if( eError != OMX_ErrorNone ) {
- goto EXIT;
- }
- }
- }
- }
- nIsDioReady = OMXBase_IsDioReady(hComponent, OMX_VIDDEC_OUTPUT_PORT);
- if( nIsDioReady == OMX_FALSE ) {
- goto EXIT;
- }
- // Get the number of buffers in Input and Output port
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_INPUT_PORT, (OMX_PTR)&nInMsgCount);
- pVidDecComp->sBase.pPvtData->fpDioGetCount(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount);
-
- } // End of while loop for input and output buffers
-
-EXIT:
- if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer && pVidDecComp->nOutPortReconfigRequired == 0 && went_thru_loop) {
- memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer));
- pVidDecComp->sCodecConfig.sBuffer = NULL;
- }
-
- return (eError);
-}
-
-/*
-* Video Decoder DeInit
-*/
-OMX_ERRORTYPE OMXVidDec_ComponentDeinit(OMX_HANDLETYPE hComponent)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pComp;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_U32 i;
- OMXBase_PortProps *pOutPortProperties = NULL;
-
- OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
- pComp = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pComp->pComponentPrivate;
-
- // For MPEG2 with Error Concealment ON, need to free the metadata buffer.
- if ((pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) && (pVidDecComp->pmetaBuffer)) {
- memplugin_free((void*)H2P(pVidDecComp->pmetaBuffer));
- pVidDecComp->pmetaBuffer = NULL;
- }
-
- // Free sBuffer if it hasn't already been freed
- if( pVidDecComp && pVidDecComp->sCodecConfig.sBuffer ) {
- memplugin_free((void*)H2P(pVidDecComp->sCodecConfig.sBuffer));
- pVidDecComp->sCodecConfig.sBuffer = NULL;
- }
-
- OSAL_DeletePipe(pVidDecComp->pTimeStampStoragePipe);
-
- OMXBase_UtilCleanupIfError(hComponent);
-
- // Call to Specific Decoder De-init routine
- pVidDecComp->fpDeinit_Codec(hComponent);
- // Close Codec-Engine
- if( pVidDecComp->ce ) {
- Engine_close(pVidDecComp->ce);
- }
-
- if( pVidDecComp->sBase.cComponentName ) {
- OSAL_Free(pVidDecComp->sBase.cComponentName);
- pVidDecComp->sBase.cComponentName = NULL;
- }
- if( pVidDecComp->sBase.pVideoPortParams ) {
- OSAL_Free(pVidDecComp->sBase.pVideoPortParams);
- pVidDecComp->sBase.pVideoPortParams = NULL;
- }
-
- if (pVidDecComp->tInBufDesc) {
- memplugin_free(pVidDecComp->tInBufDesc);
- pVidDecComp->tInBufDesc = NULL;
- }
-
- if (pVidDecComp->tOutBufDesc) {
- memplugin_free(pVidDecComp->tOutBufDesc);
- pVidDecComp->tOutBufDesc = NULL;
- }
-
- // Call to base Component De-init routine
- eError = OMXBase_ComponentDeinit(hComponent);
-
- if (pVidDecComp->bIPCRecoveryNeeded) {
- dce_ipc_recover();
- }
-
- OSAL_Free(pVidDecComp);
- pVidDecComp = NULL;
-
-EXIT:
- return (eError);
-}
-
-/*
-* GetExtension Index
-*/
-OMX_ERRORTYPE OMXVidDec_GetExtensionIndex(OMX_HANDLETYPE hComponent,
- OMX_STRING cParameterName, OMX_INDEXTYPE *pIndexType)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- // Check for NULL Parameters
- if((cParameterName == NULL) || (pIndexType == NULL)) {
- eError = OMX_ErrorBadParameter;
- goto EXIT;
- }
- // Check for Valid State
- if( pVidDecComp->sBase.tCurState == OMX_StateInvalid ) {
- eError = OMX_ErrorInvalidState;
- goto EXIT;
- }
- // Ensure that String length is not greater than Max allowed length
- if( strlen(cParameterName) > 127 ) {
- //strlen does not include \0 size, hence 127
- eError = OMX_ErrorBadParameter;
- goto EXIT;
- }
-
- if(strcmp(cParameterName, "OMX.google.android.index.enableAndroidNativeBuffers") == 0) {
- // If Index type is 2D Buffer Allocated Dimension
- *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexUseNativeBuffers;
- goto EXIT;
- } else if (strcmp(cParameterName, "OMX.google.android.index.useAndroidNativeBuffer2") == 0) {
- //This is call just a dummy for android to support backward compatibility
- *pIndexType = (OMX_INDEXTYPE) NULL;
- goto EXIT;
- } else if (strcmp(cParameterName, "OMX.google.android.index.getAndroidNativeBufferUsage") == 0) {
- *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexAndroidNativeBufferUsage;
- } else if( strcmp(cParameterName, "OMX.google.android.index.describeColorFormat") == 0 ) {
- // If Index type is Time Stamp In Decode Order
- *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexDescribeColorFormat;
- } else if( strcmp(cParameterName, "OMX_TI_IndexParamTimeStampInDecodeOrder") == 0 ) {
- // If Index type is Time Stamp In Decode Order
- *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexParamTimeStampInDecodeOrder;
- } else if( strcmp(cParameterName, "OMX_TI_IndexEnableDecoderZeroDisplayDelayMode") == 0 ) {
- // If Index type is Enable Decoder Zero Display Delay Mode
- *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEnableDecoderZeroDisplayDelayMode;
- } else if( strcmp(cParameterName, "OMX.google.android.index.prepareForAdaptivePlayback") == 0 ) {
- // If Index type is Enable Decoder Zero Display Delay Mode
- *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexPrepareForAdaptivePlayback;
- } else {
- //does not match any custom index
- eError = OMX_ErrorUnsupportedIndex;
- }
-
-EXIT:
- return (eError);
-}
-
-
diff --git a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c b/omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c
deleted file mode 100644
index 94bf1fd..0000000
--- a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_componenttable.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <omx_video_decoder_componenttable.h>
-
-
-extern OMX_ERRORTYPE OMXH264VD_Init(OMX_HANDLETYPE hComponent);
-extern OMX_ERRORTYPE OMXMPEG4VD_Init(OMX_HANDLETYPE hComponent);
-extern OMX_ERRORTYPE OMXH263VD_Init(OMX_HANDLETYPE hComponent);
-extern OMX_ERRORTYPE OMXMPEG2VD_Init(OMX_HANDLETYPE hComponent);
-
-OMXDecoderComponentList DecoderList[] =
-{
- { "video_decoder.avc", OMX_VIDEO_CodingAVC, OMXH264VD_Init }, /*! H264 Decoder */
- {"video_decoder.mpeg4", OMX_VIDEO_CodingMPEG4, OMXMPEG4VD_Init},
- { "video_decoder.h263", OMX_VIDEO_CodingH263, OMXH263VD_Init }, /*! H263 Decoder */
- { "video_decoder.mpeg2", OMX_VIDEO_CodingMPEG2, OMXMPEG2VD_Init }, /*! MPEG2 Decoder */
- { "NULL", 0, NULL }
-};
-
diff --git a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c b/omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c
deleted file mode 100644
index 3536a99..0000000
--- a/omx/videodecode/omx_videodec_common/src/omx_video_decoder_internal.c
+++ /dev/null
@@ -1,946 +0,0 @@
-/*
- * Copyright (C) Texas Instruments - http://www.ti.com/
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "OMX_VIDDEC_INTERNAL"
-
-#include <omx_video_decoder_internal.h>
-#include <libdce.h>
-
-#define OMX_VIDDEC_DEFAULT_INBUF_WIDTH 1024
-#define OMX_VIDDEC_DEFAULT_INBUF_HEIGHT 1024
-
-OMX_ERRORTYPE OMXVidDec_InitFields(OMXVidDecComp *pVidDecComp)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- hw_module_t const* module;
- OMX_U32 i = 0;
-
- pVidDecComp->sBase.cComponentName = (OMX_STRING )OSAL_Malloc(sizeof(OMX_U8) * OMX_MAX_STRINGNAME_SIZE);
- OMX_CHECK(pVidDecComp->sBase.cComponentName != NULL, OMX_ErrorInsufficientResources);
-
- /* Initialize Video Port parameters */
- pVidDecComp->sBase.pVideoPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE));
-
- OMX_BASE_INIT_STRUCT_PTR(pVidDecComp->sBase.pVideoPortParams, OMX_PORT_PARAM_TYPE);
- pVidDecComp->sBase.pVideoPortParams->nPorts = OMX_VIDDEC_NUM_OF_PORTS;
- pVidDecComp->sBase.pVideoPortParams->nStartPortNumber = OMX_VIDDEC_DEFAULT_START_PORT_NUM;
- pVidDecComp->sBase.nNumPorts = OMX_VIDDEC_NUM_OF_PORTS;
- pVidDecComp->sBase.nMinStartPortIndex = OMX_VIDDEC_DEFAULT_START_PORT_NUM;
-
- pVidDecComp->sBase.nComponentVersion.s.nVersionMajor = OMX_VIDDEC_COMP_VERSION_MAJOR;
- pVidDecComp->sBase.nComponentVersion.s.nVersionMinor = OMX_VIDDEC_COMP_VERSION_MINOR;
- pVidDecComp->sBase.nComponentVersion.s.nRevision = OMX_VIDDEC_COMP_VERSION_REVISION;
- pVidDecComp->sBase.nComponentVersion.s.nStep = OMX_VIDDEC_COMP_VERSION_STEP;
-
- eError = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
- if (eError == 0) {
- pVidDecComp->grallocModule = (gralloc_module_t const *)module;
- } else {
- eError = OMX_ErrorInsufficientResources;
- }
-
-EXIT:
- return (eError);
-}
-
-/*
-*/
-void OMXVidDec_InitPortDefs(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp)
-{
- OMXBaseComp *pBaseComp = &(pVidDecComp->sBase);
-
- OMX_PARAM_PORTDEFINITIONTYPE *inPortDefs = &(pBaseComp->pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef);
- OMX_PARAM_PORTDEFINITIONTYPE *outPortDefs= &(pBaseComp->pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
-
- /* set the default/Actual values of an Input port */
- inPortDefs->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
- inPortDefs->nVersion = pBaseComp->nComponentVersion;
- inPortDefs->bEnabled = OMX_TRUE;
- inPortDefs->bPopulated = OMX_FALSE;
- inPortDefs->eDir = OMX_DirInput;
- inPortDefs->nPortIndex = OMX_VIDDEC_INPUT_PORT;
- inPortDefs->nBufferCountMin = OMX_VIDDEC_MIN_IN_BUF_COUNT;
- inPortDefs->nBufferCountActual = OMX_VIDDEC_DEFAULT_IN_BUF_COUNT;
- inPortDefs->nBufferSize = Calc_InbufSize(OMX_VIDDEC_DEFAULT_INBUF_WIDTH,
- OMX_VIDDEC_DEFAULT_INBUF_HEIGHT);
-
- inPortDefs->eDomain = OMX_PortDomainVideo;
- inPortDefs->bBuffersContiguous = OMX_TRUE;
- inPortDefs->nBufferAlignment = OMX_VIDDEC_DEFAULT_1D_INPUT_BUFFER_ALIGNMENT;
- inPortDefs->format.video.cMIMEType= NULL;
- inPortDefs->format.video.pNativeRender = NULL;
- inPortDefs->format.video.nFrameWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH;
- inPortDefs->format.video.nFrameHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT;
- inPortDefs->format.video.nStride = 0;
- inPortDefs->format.video.nSliceHeight = 0;
- inPortDefs->format.video.nBitrate = 0;
- inPortDefs->format.video.xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE << 16;
- inPortDefs->format.video.bFlagErrorConcealment = OMX_TRUE;
- inPortDefs->format.video.eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat;
- inPortDefs->format.video.eColorFormat = OMX_COLOR_FormatUnused;
-
- /* set the default/Actual values of an output port */
- outPortDefs->nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
- outPortDefs->nVersion = pVidDecComp->sBase.nComponentVersion;
- outPortDefs->bEnabled = OMX_TRUE;
- outPortDefs->bPopulated = OMX_FALSE;
- outPortDefs->eDir = OMX_DirOutput;
- outPortDefs->nPortIndex = OMX_VIDDEC_OUTPUT_PORT;
- outPortDefs->nBufferCountMin = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- OMX_VIDDEC_DEFAULT_FRAME_WIDTH,
- OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferCountMin;
- outPortDefs->nBufferCountActual = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- OMX_VIDDEC_DEFAULT_FRAME_WIDTH,
- OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferCountActual;
-
- outPortDefs->nBufferSize = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- OMX_VIDDEC_DEFAULT_FRAME_WIDTH,
- OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).nBufferSize;
- outPortDefs->eDomain = OMX_PortDomainVideo;
- outPortDefs->bBuffersContiguous = OMX_TRUE;
- outPortDefs->nBufferAlignment = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- OMX_VIDDEC_DEFAULT_FRAME_WIDTH,
- OMX_VIDDEC_DEFAULT_FRAME_HEIGHT).n1DBufferAlignment;
- outPortDefs->format.video.cMIMEType = NULL;
- outPortDefs->format.video.pNativeRender = NULL;
- outPortDefs->format.video.nFrameWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH;
- outPortDefs->format.video.nFrameHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT;
- outPortDefs->format.video.nStride = OMX_VIDDEC_DEFAULT_STRIDE;
- outPortDefs->format.video.nSliceHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT;
- outPortDefs->format.video.nBitrate = 0;
- outPortDefs->format.video.xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE << 16;
- outPortDefs->format.video.bFlagErrorConcealment = OMX_TRUE;
- outPortDefs->format.video.eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat;
- outPortDefs->format.video.eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar;
-}
-
-
-void OMXVidDec_InitPortParams(OMXVidDecComp *pVidDecComp)
-{
- OMX_VIDEO_PARAM_PORTFORMATTYPE *tInPortVideoParam
- = &(pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT]);
- OMX_VIDEO_PARAM_PORTFORMATTYPE *tOutPortVideoParam
- = &(pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT]);
-
- // Initialize Input Video Port Param
- tInPortVideoParam->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE);
- tInPortVideoParam->nVersion = pVidDecComp->sBase.nComponentVersion;
- tInPortVideoParam->nPortIndex = OMX_VIDDEC_INPUT_PORT;
- tInPortVideoParam->nIndex = 0;
- tInPortVideoParam->eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat;
- tInPortVideoParam->eColorFormat = OMX_COLOR_FormatUnused;
- tInPortVideoParam->xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE;
-
- // Initialize Output Video Port Param
- tOutPortVideoParam->nSize = sizeof(OMX_VIDEO_PARAM_PORTFORMATTYPE);
- tOutPortVideoParam->nVersion = pVidDecComp->sBase.nComponentVersion;
- tOutPortVideoParam->nPortIndex = OMX_VIDDEC_OUTPUT_PORT;
- tOutPortVideoParam->nIndex = 1;
- tOutPortVideoParam->eCompressionFormat = pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].eCompressionFormat;
- tOutPortVideoParam->eColorFormat = OMX_COLOR_FormatYUV420PackedSemiPlanar;
- tOutPortVideoParam->xFramerate = OMX_VIDEODECODER_DEFAULT_FRAMERATE;
-}
-
-void OMXVidDec_InitDecoderParams(OMX_HANDLETYPE hComponent,
- OMXVidDecComp *pVidDecComp)
-{
- OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = &(pVidDecComp->sBase.pPorts[outPort]->sPortDef);
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]);
-
- OMXVidDec_InitPortDefs(hComponent, pVidDecComp);
- OMXVidDec_InitPortParams(pVidDecComp);
- OMXVidDec_Set2DBuffParams(hComponent, pVidDecComp);
- pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth;
-
- pVidDecComp->pDecStaticParams->maxHeight = OMX_VIDDEC_DEFAULT_FRAME_HEIGHT;
- pVidDecComp->pDecStaticParams->maxWidth = OMX_VIDDEC_DEFAULT_FRAME_WIDTH;
-
- /* Call Decoder Specific function to set Static Params */
- pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams);
- return;
-}
-
-
-void OMXVidDec_Set2DBuffParams(OMX_HANDLETYPE hComponent, OMXVidDecComp *pVidDecComp)
-{
- OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT;
- OMX_U32 inPort = (OMX_U32)OMX_VIDDEC_INPUT_PORT;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]);
- OMX_CONFIG_RECTTYPE *p2DInBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[inPort]);
-
- PaddedBuffParams outBuffParams;
- OMX_U32 nFrameWidth, nFrameHeight;
-
- p2DOutBufAllocParam->nSize = sizeof(OMX_CONFIG_RECTTYPE);
- p2DOutBufAllocParam->nVersion = pVidDecComp->sBase.nComponentVersion;
- p2DOutBufAllocParam->nPortIndex = outPort;
-
- nFrameWidth = pVidDecComp->sBase.pPorts[inPort]->sPortDef.format.video.nFrameWidth;
- nFrameHeight = pVidDecComp->sBase.pPorts[inPort]->sPortDef.format.video.nFrameHeight;
- if( nFrameWidth & 0x0F ) {
- nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F);
- }
- if( nFrameHeight & 0x1F ) {
- nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F);
- }
- outBuffParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, nFrameWidth, nFrameHeight);
-
- p2DOutBufAllocParam->nWidth = outBuffParams.nPaddedWidth;
- p2DOutBufAllocParam->nHeight = outBuffParams.nPaddedHeight;
- p2DOutBufAllocParam->nLeft = outBuffParams.n2DBufferXAlignment;
- p2DOutBufAllocParam->nTop = outBuffParams.n2DBufferYAlignment;
-
- p2DInBufAllocParam->nSize = sizeof(OMX_CONFIG_RECTTYPE);
- p2DInBufAllocParam->nVersion = pVidDecComp->sBase.nComponentVersion;
- p2DInBufAllocParam->nPortIndex = OMX_VIDDEC_INPUT_PORT;
- p2DInBufAllocParam->nWidth = pVidDecComp->sBase.pPorts[inPort]->sPortDef.nBufferSize;
- p2DInBufAllocParam->nHeight = 1; //On input port only 1D buffers supported.
- p2DInBufAllocParam->nLeft = pVidDecComp->sBase.pPorts[inPort]->sPortDef.nBufferAlignment;
- p2DInBufAllocParam->nTop = 1;
-}
-
-
-OMX_ERRORTYPE OMXVidDec_HandleFLUSH_EOS(OMX_HANDLETYPE hComponent,
- OMX_BUFFERHEADERTYPE *pLastOutBufHeader,
- OMX_BUFFERHEADERTYPE *pInBufHeader)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone, eRMError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMX_BUFFERHEADERTYPE *pDupBufHeader = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
- OMX_U32 i = 0;
- OMX_U32 nStride;
- IVIDDEC3_OutArgs *pDecOutArgs = NULL;
- OMX_U32 outPort = (OMX_U32)OMX_VIDDEC_OUTPUT_PORT;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL;
- XDAS_Int32 status;
- uint32_t nActualSize;
- IMG_native_handle_t* grallocHandle;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- XDM_Rect activeFrameRegion[2];
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pDecOutArgs = pVidDecComp->pDecOutArgs;
- p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[outPort]);
-
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[outPort]->sPortDef);
- /*! Ensure that the stride on output portdef structure is more than
- the padded width. This is needed in the case where application
- sets the Stride less than padded width */
- if( (OMX_U32)pOutputPortDef->format.video.nStride >=
- p2DOutBufAllocParam->nWidth ) {
- nStride = pOutputPortDef->format.video.nStride;
- } else {
- nStride = p2DOutBufAllocParam->nWidth;
- }
-
- if( pVidDecComp->nFrameCounter > 0 ) {
- /* Call codec flush and call process call until error */
- OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter);
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_FLUSH, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_FLUSH failed ....! \n");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- do {
- pVidDecComp->tOutBufDesc->numBufs = 0;
- pVidDecComp->tInBufDesc->numBufs = 0;
- status = VIDDEC3_process(pVidDecComp->pDecHandle, (XDM2_BufDesc *)pVidDecComp->tInBufDesc,
- (XDM2_BufDesc *)pVidDecComp->tOutBufDesc,
- (VIDDEC3_InArgs *)pVidDecComp->pDecInArgs,
- (VIDDEC3_OutArgs *)pVidDecComp->pDecOutArgs);
-
- /*! In case this is an IPC failure */
- if(status == DCE_EIPC_CALL_FAIL) {
- ALOGE("\n Remote Core Communication Failure... \n");
- eError = OMX_ErrorHardware;
- pVidDecComp->bIPCRecoveryNeeded = OMX_TRUE;
- goto EXIT;
- }
-
- if( status != XDM_EFAIL ) {
- /* Send the buffers out */
- i = 0;
- while( pDecOutArgs->outputID[i] ) {
- pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[i];
- if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) {
- OSAL_ReadFromPipe(pVidDecComp->pTimeStampStoragePipe, &(pDupBufHeader->nTimeStamp),
- sizeof(OMX_TICKS), &(nActualSize), OSAL_NO_SUSPEND);
- }
-
- activeFrameRegion[0] = pDecOutArgs->displayBufs.bufDesc[0].activeFrameRegion;
- activeFrameRegion[1].bottomRight.y = (activeFrameRegion[0].bottomRight.y) / 2;
- activeFrameRegion[1].bottomRight.x = activeFrameRegion[0].bottomRight.x;
-
- // Crop rectangle handles the Y and UV buffer offsets
- pDupBufHeader->nOffset = 0;
- pDupBufHeader->nFilledLen = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3 ) / 2;
-
- if((pVidDecComp->tCropDimension.nTop != activeFrameRegion[0].topLeft.y
- || pVidDecComp->tCropDimension.nLeft != activeFrameRegion[0].topLeft.x)
- || (pVidDecComp->tCropDimension.nWidth != (OMX_U32)(activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x)
- || pVidDecComp->tCropDimension.nHeight != (OMX_U32)(activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y))) {
- pVidDecComp->tCropDimension.nTop = activeFrameRegion[0].topLeft.y;
- pVidDecComp->tCropDimension.nLeft = activeFrameRegion[0].topLeft.x;
- pVidDecComp->tCropDimension.nWidth = activeFrameRegion[0].bottomRight.x - activeFrameRegion[0].topLeft.x;
- pVidDecComp->tCropDimension.nHeight = activeFrameRegion[0].bottomRight.y - activeFrameRegion[0].topLeft.y;
- if( pVidDecComp->bUsePortReconfigForCrop == OMX_TRUE ) {
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventPortSettingsChanged,
- OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonOutputCrop, NULL);
- if( eError != OMX_ErrorNone ) {
- OSAL_ErrorTrace("Port reconfig callback returned error, trying to continue");
- }
- }
- }
-
- if( pVidDecComp->bSupportSkipGreyOutputFrames ) {
- if( pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_I_FRAME ||
- pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IDR_FRAME ||
- pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IP_FRAME ||
- pDecOutArgs->displayBufs.bufDesc[0].frameType == IVIDEO_IB_FRAME ) {
- pVidDecComp->bSyncFrameReady = OMX_TRUE;
- }
- }
- grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule, (buffer_handle_t)grallocHandle);
-
- if( pVidDecComp->bSyncFrameReady == OMX_TRUE ) {
- // Send the Output buffer to Base component
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader);
- }
- pDecOutArgs->outputID[i] = 0;
- i++;
- }
- i = 0;
- while( pDecOutArgs->freeBufID[i] != 0 ) {
- pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->freeBufID[i];
- ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE;
- if( pDupBufHeader ) {
- grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader);
- }
- i++;
- }
- }
- } while( status != XDM_EFAIL );
- }
- if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) {
- OSAL_ClearPipe(pVidDecComp->pTimeStampStoragePipe);
- }
- if( pLastOutBufHeader != NULL ) {
- pLastOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
- grallocHandle = (IMG_native_handle_t*)(pLastOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_OUTPUT_PORT, pLastOutBufHeader);
- }
- if( pInBufHeader != NULL ) {
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- /* Send the EOS event to client */
- pVidDecComp->sBase.fpReturnEventNotify(hComponent, OMX_EventBufferFlag,
- OMX_VIDDEC_OUTPUT_PORT, OMX_BUFFERFLAG_EOS, NULL);
- }
- pVidDecComp->nFrameCounter = 0;
- if( pVidDecComp->bSupportSkipGreyOutputFrames ) {
- pVidDecComp->bSyncFrameReady = OMX_FALSE;
- }
- pVidDecComp->nOutbufInUseFlag = 0;
- pVidDecComp->nFatalErrorGiven = 0;
-
-EXIT:
- if( pVidDecComp->bSupportDecodeOrderTimeStamp == OMX_TRUE ) {
- //Clear the pipe, to discard the stale messages
- OSAL_ERROR err = OSAL_ClearPipe(pVidDecComp->pTimeStampStoragePipe);
- if( err != OSAL_ErrNone ) {
- /* if pipe clear fails, nothing can be done, just put error trace */
- OSAL_ErrorTrace("\npipe clear failed");
- }
- }
- return (eError);
-}
-
-/* ==========================================================================*/
-/**
- * @fn Calc_InbufSize()
- * This method Calcullates Buffer size given width and
- * height of buffer
- *
- * @param [in] width : Width of the buffer
- * @param [in] height : Height of the buffer
- *
- */
-/* ==========================================================================*/
-OMX_U32 Calc_InbufSize(OMX_U32 width, OMX_U32 height)
-{
- return ((width * height * 3) / 2);
-}
-
-OMX_ERRORTYPE OMXVidDec_SetInPortDef(OMX_HANDLETYPE hComponent,
- OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_VIDEO_CODINGTYPE currentCompressionType, desiredCompressionType;
- OMX_U32 nFrameWidth, nFrameHeight;
- OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- PaddedBuffParams tOutBufParams;
- OMX_U32 i=0;
- OMX_U32 bFound = 0;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- /*! Initialize pointers and variables */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef);
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- nFrameWidth = pPortDefs->format.video.nFrameWidth;
- nFrameHeight = pPortDefs->format.video.nFrameHeight;
- if( nFrameWidth & 0x0F ) {
- nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F);
- }
- if( nFrameHeight & 0x1F ) {
- nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F);
- }
- currentCompressionType = pInputPortDef->format.video.eCompressionFormat;
- desiredCompressionType = pPortDefs->format.video.eCompressionFormat;
- /*! In case there is change in Compression type */
- if( currentCompressionType != desiredCompressionType ) {
- /* De-initialize the current codec */
- pVidDecComp->fpDeinit_Codec(hComponent);
- /* Call specific component init depending upon the
- eCompressionFormat set. */
- i=0;
- while( NULL != DecoderList[i].eCompressionFormat ) {
- if( DecoderList[i].eCompressionFormat
- == desiredCompressionType ) {
- /* Component found */
- bFound = 1;
- break;
- }
- i++;
- }
- if( bFound == 0 ) {
- OSAL_ErrorTrace("Unsupported Compression format given in port definition");
- eError = OMX_ErrorUnsupportedSetting;
- goto EXIT;
- }
- /* Call the Specific Decoder Init function and Initialize Params */
- eError = DecoderList[i].fpDecoderComponentInit(hComponent);
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- OMXVidDec_InitDecoderParams(hComponent, pHandle->pComponentPrivate);
- strcpy((char *)pVidDecComp->tComponentRole.cRole,
- (char *)DecoderList[i].cRole);
- } /* End of if condition for change in codec type */
-
- /*! set the Actual values of an Input port */
- pInputPortDef->nBufferCountActual = pPortDefs->nBufferCountActual;
- pInputPortDef->format = pPortDefs->format;
- pInputPortDef->nBufferSize = Calc_InbufSize(nFrameWidth, nFrameHeight);
- pVidDecComp->tCropDimension.nTop = 0;
- pVidDecComp->tCropDimension.nLeft = 0;
- pVidDecComp->tCropDimension.nWidth = pInputPortDef->format.video.nFrameWidth;
- pVidDecComp->tCropDimension.nHeight = pInputPortDef->format.video.nFrameHeight;
-
- /*! Set o/p port details according to width/height set at i/p Port. */
- pOutputPortDef->format.video.nFrameWidth = pInputPortDef->format.video.nFrameWidth;
- pOutputPortDef->format.video.nFrameHeight = pInputPortDef->format.video.nFrameHeight;
- pOutputPortDef->format.video.nStride = pInputPortDef->format.video.nFrameWidth;
- OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate);
- pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride *
- ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1);
-
- tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent, nFrameWidth, nFrameHeight);
- pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin;
- pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual;
-
- /*! Set the Static Params (Decoder Specific) */
- pVidDecComp->fpSet_StaticParams(hComponent, pVidDecComp->pDecStaticParams);
- pVidDecComp->pDecStaticParams->maxHeight = nFrameHeight;
- pVidDecComp->pDecStaticParams->maxWidth = nFrameWidth;
- if (pVidDecComp->tVideoParams[OMX_VIDDEC_INPUT_PORT].eCompressionFormat == OMX_VIDEO_CodingMPEG2) {
- pVidDecComp->pDecStaticParams->maxWidth = pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nWidth;
- }
- if( pOutputPortDef->nBufferCountActual < pOutputPortDef->nBufferCountMin ) {
- pOutputPortDef->nBufferCountActual = pOutputPortDef->nBufferCountMin;
- }
-
-EXIT:
- return (eError);
-
-}
-
-OMX_ERRORTYPE OMXVidDec_SetOutPortDef(OMXVidDecComp *pVidDecComp,
- OMX_PARAM_PORTDEFINITIONTYPE *pPortDefs)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- OMX_PTR *pBufParams = NULL;
- OMX_U32 nOutPort = OMX_VIDDEC_OUTPUT_PORT;
- OMX_U32 nNumBuffers = 0;
-
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[nOutPort]->sPortDef);
-
- /*! Set Values to output port based on input parameter */
- pOutputPortDef->nBufferCountActual = pPortDefs->nBufferCountActual;
- pOutputPortDef->format = pPortDefs->format;
- pOutputPortDef->format.video.nSliceHeight
- = pOutputPortDef->format.video.nFrameHeight;
- pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride *
- ((pVidDecComp->t2DBufferAllocParams[nOutPort].nHeight * 3) >> 1);
-
-EXIT:
- return (eError);
-}
-
-
-OMX_ERRORTYPE OMXVidDec_HandleFirstFrame(OMX_HANDLETYPE hComponent,
- OMX_BUFFERHEADERTYPE * *ppInBufHeader)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMX_U32 nFrameWidth, nFrameHeight, nFrameWidthNew, nFrameHeightNew, nFrameRate, nFrameRateNew;
- OMXVidDecComp *pVidDecComp = NULL;
- XDAS_Int32 status = 0;
- IVIDDEC3_Status *pDecStatus = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL;
- PaddedBuffParams tOutBufParams;
- OMX_BUFFERHEADERTYPE *pInBufHeader;
- OMX_BOOL bPortReconfigRequiredForPadding = OMX_FALSE;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL;
-
- OMX_BOOL bSendPortReconfigForScale = OMX_FALSE;
- OMX_U32 nScale, nScaleRem, nScaleQ16Low, nScaleWidth, nScaleHeight;
- OMX_U64 nScaleQ16 = 0;
-
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef);
- pVidDecComp->nOutPortReconfigRequired = 0;
- p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]);
-
- /*! Call the Codec Control call to get Status from Codec */
- OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter);
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETSTATUS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("Error in Codec Control Call for GETSTATUS");
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
- if( pVidDecComp->fpHandle_CodecGetStatus != NULL ) {
- eError = pVidDecComp->fpHandle_CodecGetStatus(hComponent);
- }
- pDecStatus = (IVIDDEC3_Status *)(pVidDecComp->pDecStatus);
- nFrameWidth = pOutputPortDef->format.video.nFrameWidth;
- nFrameHeight = pOutputPortDef->format.video.nFrameHeight;
- nFrameWidthNew = (OMX_U32)pDecStatus->outputWidth;
- nFrameHeightNew = (OMX_U32)pDecStatus->outputHeight;
- nFrameRate = pOutputPortDef->format.video.xFramerate >> 16;
-
- OMX_CHECK(pVidDecComp->nFrameRateDivisor != 0, OMX_ErrorBadParameter);
- nFrameRateNew = (OMX_U32)(pDecStatus->frameRate / pVidDecComp->nFrameRateDivisor);
- /*Set 200 as max cap, as if clip with incorrect setting is present in sdcard
- it breaks havoc on thumbnail generation */
- if((nFrameRateNew == 0) || (nFrameRateNew > 200)) {
- OSAL_ErrorTrace("Codec Returned spurious FrameRate Value - %d Setting Back to - %d",
- nFrameRateNew, nFrameRate);
- nFrameRateNew = nFrameRate;
- }
-
- if( nFrameWidth & 0x0F ) {
- nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F);
- }
- if( nFrameHeight & 0x1F ) {
- nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F);
- }
- if( nFrameWidthNew & 0x0F ) {
- nFrameWidthNew = nFrameWidthNew + 16 - (nFrameWidthNew & 0x0F);
- }
- if( nFrameHeightNew & 0x1F ) {
- nFrameHeightNew = nFrameHeightNew + 32 - (nFrameHeightNew & 0x1F);
- }
- if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) {
- if( pOutputPortDef->format.video.nFrameWidth != p2DOutBufAllocParam->nWidth
- || pOutputPortDef->format.video.nFrameHeight != p2DOutBufAllocParam->nHeight ) {
- bPortReconfigRequiredForPadding = OMX_TRUE;
- }
- nFrameWidth = pVidDecComp->pDecStaticParams->maxWidth;
- nFrameHeight = pVidDecComp->pDecStaticParams->maxHeight;
- }
-
- /*! Check whether the displayWidth already accounts for any
- * difference between the current and new frame width */
- if ( nFrameWidth != nFrameWidthNew &&
- nFrameWidth == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) {
- nFrameWidthNew = nFrameWidth;
- }
-
- tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- (OMX_U32)pDecStatus->outputWidth, (OMX_U32)pDecStatus->outputHeight);
-
- /*! Check whether the height and width reported by codec matches
- * that of output port */
- if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth
- || bPortReconfigRequiredForPadding == OMX_TRUE ||
- pOutputPortDef->nBufferCountMin < tOutBufParams.nBufferCountMin ||
- nFrameRate < nFrameRateNew ) { /* Compare the min againt the older min buffer count
- since parameters like display delay also gets set according to ref frame. */
- /*! Since the dimensions does not match trigger port reconfig */
- pVidDecComp->nOutPortReconfigRequired = 1;
- pVidDecComp->nCodecRecreationRequired = 1;
- /* Return back the Input buffer headers Note that the output header
- * will be cancelled later so no need to cancel it here */
- if( ppInBufHeader != NULL ) {
- pInBufHeader = *(ppInBufHeader);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_VIDDEC_INPUT_PORT,
- pInBufHeader);
- pInBufHeader = NULL;
- }
- /*! Change port definition to match with what codec reports */
- pInputPortDef->format.video.nFrameHeight = (OMX_U32)pDecStatus->outputHeight;
- pInputPortDef->format.video.nFrameWidth = (OMX_U32)pDecStatus->outputWidth;
- pOutputPortDef->format.video.nFrameHeight = (OMX_U32)pDecStatus->outputHeight;
- pOutputPortDef->format.video.nFrameWidth = (OMX_U32)pDecStatus->outputWidth;
- pOutputPortDef->format.video.nStride = (OMX_U32)pDecStatus->outputWidth;
- pOutputPortDef->format.video.nSliceHeight = (OMX_U32)pDecStatus->outputHeight;
- if( nFrameRate < nFrameRateNew ) {
- pOutputPortDef->format.video.xFramerate = nFrameRateNew << 16;
- pVidDecComp->tVideoParams[OMX_VIDDEC_OUTPUT_PORT].xFramerate = nFrameRateNew;
- }
- pVidDecComp->tCropDimension.nWidth = (OMX_U32)pDecStatus->outputWidth;
- pVidDecComp->tCropDimension.nHeight = (OMX_U32)pDecStatus->outputHeight;
- tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- (OMX_U32)pDecStatus->outputWidth,
- (OMX_U32)pDecStatus->outputHeight);
- pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin;
- pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual;
- OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate);
-
- pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth;
- pOutputPortDef->format.video.nSliceHeight = p2DOutBufAllocParam->nHeight;
-
- pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride *
- ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1);
- if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) {
- pInputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight;
- pInputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth;
- pOutputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight;
- pOutputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth;
- }
- }
-
- if( pVidDecComp->nOutPortReconfigRequired == 1 ) {
- /*! Notify to Client change in output port settings */
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent,
- OMX_EventPortSettingsChanged,
- OMX_VIDDEC_OUTPUT_PORT, 0, NULL);
- } else if( pDecStatus->sampleAspectRatioHeight != 0 && pDecStatus->sampleAspectRatioWidth != 0 ) {
- nScaleWidth = (OMX_U32)pDecStatus->sampleAspectRatioWidth;
- nScaleHeight = (OMX_U32)pDecStatus->sampleAspectRatioHeight;
- nScale = nScaleWidth / nScaleHeight;
- if( nScale >= 1 ) {
- nScaleRem = nScaleWidth % nScaleHeight;
- nScaleQ16Low = 0xFFFF * nScaleRem / nScaleHeight;
- nScaleQ16 = nScale << 16;
- nScaleQ16 |= nScaleQ16Low;
- if( (OMX_U64)pVidDecComp->tScaleParams.xWidth != nScaleQ16
- || pVidDecComp->tScaleParams.xHeight != 0x10000 ) {
- pVidDecComp->tScaleParams.xWidth = nScaleQ16;
- pVidDecComp->tScaleParams.xHeight = 0x10000;
- bSendPortReconfigForScale = OMX_TRUE;
- }
- } else {
- nScale = nScaleHeight / nScaleWidth;
- nScaleRem = nScaleHeight % nScaleWidth;
- nScaleQ16Low = 0xFFFF * nScaleRem / nScaleWidth;
- nScaleQ16 = nScale << 16;
- nScaleQ16 |= nScaleQ16Low;
- if( pVidDecComp->tScaleParams.xWidth != 0x10000
- || (OMX_U64)pVidDecComp->tScaleParams.xHeight != nScaleQ16 ) {
- pVidDecComp->tScaleParams.xWidth = 0x10000;
- pVidDecComp->tScaleParams.xHeight = nScaleQ16;
- bSendPortReconfigForScale = OMX_TRUE;
- }
- }
- if( bSendPortReconfigForScale == OMX_TRUE ) {
- /*! Notify to Client change in output port settings */
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent,
- OMX_EventPortSettingsChanged, OMX_VIDDEC_OUTPUT_PORT, OMX_IndexConfigCommonScale, NULL);
- bSendPortReconfigForScale = OMX_FALSE;
- }
- }
-
-EXIT:
- return (eError);
-
-}
-
-OMX_ERRORTYPE OMXVidDec_HandleCodecProcError(OMX_HANDLETYPE hComponent,
- OMX_BUFFERHEADERTYPE * *ppInBufHeader,
- OMX_BUFFERHEADERTYPE * *ppOutBufHeader)
-{
- OMX_ERRORTYPE eError = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMX_U32 nFrameWidth, nFrameHeight, nFrameWidthNew, nFrameHeightNew;
- OMXVidDecComp *pVidDecComp = NULL;
- XDAS_Int32 status = 0;
- IVIDDEC3_Status *pDecStatus = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pOutputPortDef = NULL;
- OMX_PARAM_PORTDEFINITIONTYPE *pInputPortDef = NULL;
- PaddedBuffParams tOutBufParams;
- OMX_BUFFERHEADERTYPE *pInBufHeader = *(ppInBufHeader);
- OMX_BUFFERHEADERTYPE *pDupBufHeader;
- OMX_BUFFERHEADERTYPE *pNewOutBufHeader = NULL;
- OMX_BUFFERHEADERTYPE *pOutBufHeader = *(ppOutBufHeader);
- OMX_U32 ii=0;
- OMX_U32 nStride =0;
- OMX_BOOL bPortReconfigRequiredForPadding = OMX_FALSE;
- OMX_CONFIG_RECTTYPE *p2DOutBufAllocParam = NULL;
- IMG_native_handle_t* grallocHandle;
-
- /* Initialize pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
- pOutputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef);
- pInputPortDef = &(pVidDecComp->sBase.pPorts[OMX_VIDDEC_INPUT_PORT]->sPortDef);
- p2DOutBufAllocParam = &(pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT]);
-
- /*! Call the Codec Status function to know cause of error */
- OMX_CHECK(((pVidDecComp->pDecDynParams != NULL) && (pVidDecComp->pDecStatus != NULL)), OMX_ErrorBadParameter);
- status = VIDDEC3_control(pVidDecComp->pDecHandle, XDM_GETSTATUS, pVidDecComp->pDecDynParams, pVidDecComp->pDecStatus);
-
- /* Check whether the Codec Status call was succesful */
- if( status != VIDDEC3_EOK ) {
- OSAL_ErrorTrace("VIDDEC3_control XDM_GETSTATUS failed");
- if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader
- != pVidDecComp->nDecoderMode ) {
- // Return the Input and Output buffer header
- grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT,
- pOutBufHeader);
-
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_INPUT_PORT,
- pInBufHeader);
- /*! Make Input buffer header pointer NULL */
- pInBufHeader = NULL;
- }
- eError = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- OMX_CHECK(eError == OMX_ErrorNone, eError);
-
- pDecStatus = (IVIDDEC3_Status *)(pVidDecComp->pDecStatus);
- nFrameWidth = pOutputPortDef->format.video.nFrameWidth;
- nFrameHeight = pOutputPortDef->format.video.nFrameHeight;
- nFrameWidthNew = pDecStatus->outputWidth;
- nFrameHeightNew = pDecStatus->outputHeight;
-
- if( nFrameWidth & 0x0F ) {
- nFrameWidth = nFrameWidth + 16 - (nFrameWidth & 0x0F);
- }
- if( nFrameHeight & 0x1F ) {
- nFrameHeight = nFrameHeight + 32 - (nFrameHeight & 0x1F);
- }
- if( nFrameWidthNew & 0x0F ) {
- nFrameWidthNew = nFrameWidthNew + 16 - (nFrameWidthNew & 0x0F);
- }
- if( nFrameHeightNew & 0x1F ) {
- nFrameHeightNew = nFrameHeightNew + 32 - (nFrameHeightNew & 0x1F);
- }
-
- if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) {
- if( pOutputPortDef->format.video.nFrameWidth != p2DOutBufAllocParam->nWidth
- || pOutputPortDef->format.video.nFrameHeight != p2DOutBufAllocParam->nHeight ) {
- bPortReconfigRequiredForPadding = OMX_TRUE;
- }
- nFrameWidth = pVidDecComp->pDecStaticParams->maxWidth;
- nFrameHeight = pVidDecComp->pDecStaticParams->maxHeight;
- }
-
- /*! Check whether the displayWidth already accounts for any
- * difference between the current and new frame width */
- if ( nFrameWidth != nFrameWidthNew &&
- nFrameWidth == (OMX_U32)pVidDecComp->pDecDynParams->displayWidth ) {
- nFrameWidthNew = nFrameWidth;
- }
-
- /*! Check whether the height and width reported by codec matches
- * that of output port */
- if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth
- || bPortReconfigRequiredForPadding == OMX_TRUE ) {
- pVidDecComp->nOutPortReconfigRequired = 1;
- pVidDecComp->nCodecRecreationRequired = 1;
- }
-
- if( pVidDecComp->fpHandle_ExtendedError != NULL ) {
- eError = pVidDecComp->fpHandle_ExtendedError(hComponent);
- }
-
- if( pVidDecComp->nOutPortReconfigRequired == 1 ) {
- pNewOutBufHeader = (OMX_BUFFERHEADERTYPE *) pVidDecComp->pDecOutArgs->outputID[0];
- if( pNewOutBufHeader != NULL ) {
- pVidDecComp->tCropDimension.nWidth = pDecStatus->outputWidth;
- pVidDecComp->tCropDimension.nHeight = pDecStatus->outputHeight;
- nStride = pVidDecComp->sBase.pPorts[OMX_VIDDEC_OUTPUT_PORT]->sPortDef.format.video.nStride;
- // Crop rect handles the offsets for Y and UV buffers
- pNewOutBufHeader->nOffset = 0;
- // FilledLen
- pNewOutBufHeader->nFilledLen
- = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) / 2;
- grallocHandle = (IMG_native_handle_t*)(pNewOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioSend(hComponent, OMX_VIDDEC_OUTPUT_PORT,
- pNewOutBufHeader);
- }
-
- if( pVidDecComp->nOutbufInUseFlag == 0
- && (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) {
- grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); // This buffer header is freed afterwards.
- } else {
- pOutBufHeader = NULL;
- }
- if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) {
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_INPUT_PORT, pInBufHeader);
-
- while( pVidDecComp->pDecOutArgs->freeBufID[ii] != 0 ) {
- pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pVidDecComp->pDecOutArgs->freeBufID[ii++];
- ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE;
- if( pDupBufHeader != pOutBufHeader && pDupBufHeader != pNewOutBufHeader ) {
- grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader);
- }
- }
- }
-
- /*! Notify to Client change in output port settings */
- eError = pVidDecComp->sBase.fpReturnEventNotify(hComponent,
- OMX_EventPortSettingsChanged,
- OMX_VIDDEC_OUTPUT_PORT, 0, NULL);
- }
- if( pVidDecComp->nOutPortReconfigRequired == 0 ) {
- if( pVidDecComp->pDecOutArgs->extendedError & 0x8000 ) {
- eError = OMX_ErrorFormatNotDetected;
- if( (OMX_U32)pVidDecComp->pDecDynParams->decodeHeader != pVidDecComp->nDecoderMode ) {
- if( pVidDecComp->nOutbufInUseFlag == 0 ) {
- grallocHandle = (IMG_native_handle_t*)(pOutBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pOutBufHeader); // This buffer header is freed afterwards.
- }
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_INPUT_PORT, pInBufHeader);
- while( pVidDecComp->pDecOutArgs->freeBufID[ii] != 0 ) {
- pDupBufHeader = (OMX_BUFFERHEADERTYPE *)pVidDecComp->pDecOutArgs->freeBufID[ii++];
- ((OMXBase_BufHdrPvtData *)(pDupBufHeader->pPlatformPrivate))->bIsLocked = OMX_FALSE;
- if( pOutBufHeader != pDupBufHeader ) {
- grallocHandle = (IMG_native_handle_t*)(pDupBufHeader->pBuffer);
- pVidDecComp->grallocModule->unlock((gralloc_module_t const *) pVidDecComp->grallocModule,
- (buffer_handle_t)grallocHandle);
- pVidDecComp->sBase.pPvtData->fpDioCancel(hComponent,
- OMX_VIDDEC_OUTPUT_PORT, pDupBufHeader);
- }
- }
- }
- pVidDecComp->nFatalErrorGiven = 1;
- }
- }
-
- if( nFrameHeightNew != nFrameHeight || nFrameWidthNew != nFrameWidth
- || bPortReconfigRequiredForPadding == OMX_TRUE ) {
- /*Return back the locked buffers before changing the port definition */
- OMXVidDec_HandleFLUSH_EOS(hComponent, NULL, NULL);
- /*! Change Port Definition */
- pInputPortDef->format.video.nFrameHeight = pDecStatus->outputHeight;
- pInputPortDef->format.video.nFrameWidth = pDecStatus->outputWidth;
-
- pOutputPortDef->format.video.nFrameHeight = pDecStatus->outputHeight;
- pOutputPortDef->format.video.nFrameWidth = pDecStatus->outputWidth;
- pOutputPortDef->format.video.nSliceHeight = pDecStatus->outputHeight;
- pVidDecComp->tCropDimension.nWidth = pDecStatus->outputWidth;
- pVidDecComp->tCropDimension.nHeight = pDecStatus->outputHeight;
- tOutBufParams = pVidDecComp->fpCalc_OubuffDetails(hComponent,
- pDecStatus->outputWidth,
- pDecStatus->outputHeight);
- pOutputPortDef->nBufferCountMin = tOutBufParams.nBufferCountMin;
- pOutputPortDef->nBufferCountActual = tOutBufParams.nBufferCountActual;
- OMXVidDec_Set2DBuffParams(hComponent, pHandle->pComponentPrivate);
-
- pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth;
-
- pOutputPortDef->nBufferSize = pOutputPortDef->format.video.nStride *
- ((pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) >> 1);
- if( pVidDecComp->bUsePortReconfigForPadding == OMX_TRUE ) {
- pInputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight;
- pInputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth;
- pOutputPortDef->format.video.nFrameHeight = p2DOutBufAllocParam->nHeight;
- pOutputPortDef->format.video.nFrameWidth = p2DOutBufAllocParam->nWidth;
- pOutputPortDef->format.video.nStride = p2DOutBufAllocParam->nWidth;
- pOutputPortDef->format.video.nSliceHeight = p2DOutBufAllocParam->nHeight;
- }
- }
-
-EXIT:
- return (eError);
-}
-
-void OMXVidDec_CalcFilledLen(OMX_HANDLETYPE hComponent,
- IVIDDEC3_OutArgs *pDecOutArgs,
- OMX_U32 nStride)
-{
- OMX_BUFFERHEADERTYPE *pOutBufHeader;
- OMX_COMPONENTTYPE *pHandle = NULL;
- OMXVidDecComp *pVidDecComp = NULL;
-
- /* Initialize the pointers */
- pHandle = (OMX_COMPONENTTYPE *)hComponent;
- pVidDecComp = (OMXVidDecComp *)pHandle->pComponentPrivate;
-
- pOutBufHeader = (OMX_BUFFERHEADERTYPE *)pDecOutArgs->outputID[0];
- /*Crop rectangle handles the offsets for Y and UV buffers */
- pOutBufHeader->nOffset = 0;
-
- /*! Calcullate the Total Filled length */
- pOutBufHeader->nFilledLen = (nStride * pVidDecComp->t2DBufferAllocParams[OMX_VIDDEC_OUTPUT_PORT].nHeight * 3) / 2;
-
- return;
-}
-
-