summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunita Nadampalli <sunitan@ti.com>2014-11-14 12:12:58 -0600
committerGerrit Code Review <gerrit2@git.omapzoom.org>2014-11-25 10:35:15 -0600
commit6a94787ccf0c7cd748570920bb1b80279b6f08ae (patch)
treebb5a652c3484fea70a67d4ba95ce7bf08941553d
parentd2ee35d72853e8c91ac45b50863dc54c9e58cc32 (diff)
downloaddra7xx-6a94787ccf0c7cd748570920bb1b80279b6f08ae.tar.gz
OMX: VideoEncoder: Added H264 video encoder support
Change-Id: I5ce5e5e2839f41a56804aeca687523d1dd741133 Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
-rw-r--r--omx/videoencode/Android.mk43
-rw-r--r--omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h103
-rw-r--r--omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h1122
-rw-r--r--omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c2229
-rw-r--r--omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c981
5 files changed, 4478 insertions, 0 deletions
diff --git a/omx/videoencode/Android.mk b/omx/videoencode/Android.mk
new file mode 100644
index 0000000..19d74f2
--- /dev/null
+++ b/omx/videoencode/Android.mk
@@ -0,0 +1,43 @@
+LOCAL_PATH:= $(call my-dir)
+
+#
+# libOMX.TI.DUCATI1.VIDEO.H264E
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_C_INCLUDES += \
+ frameworks/native/include/media/openmax \
+ frameworks/native/include/media/hardware \
+ $(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/ti/dra7xx/hwcomposer/ \
+ hardware/ti/dce/ \
+ system/core/include/cutils \
+ $(LOCAL_PATH)/omx_h264_enc/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_SHARED_LIBRARIES := \
+ libosal \
+ libc \
+ liblog \
+ libOMX \
+ libhardware \
+ libdce
+
+LOCAL_CFLAGS += -Dxdc_target_types__=google/targets/arm/std.h -DSUPPORT_ANDROID_FRAMEBUFFER_HAL -DSUPPORT_ANDROID_MEMTRACK_HAL -DBUILDOS_ANDROID
+
+LOCAL_MODULE_TAGS:= optional
+
+LOCAL_SRC_FILES:= omx_h264_enc/src/omx_H264videoencoder.c \
+ omx_h264_enc/src/omx_H264videoencoderutils.c
+
+LOCAL_MODULE:= libOMX.TI.DUCATI1.VIDEO.H264E
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h b/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h
new file mode 100644
index 0000000..1c908f7
--- /dev/null
+++ b/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoder.h
@@ -0,0 +1,103 @@
+/*
+ * 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_H264VE_COMPONENT_H
+#define _OMX_H264VE_COMPONENT_H
+
+#ifdef _cplusplus
+extern "C" {
+#endif /* _cplusplus */
+
+#define ENCODE_RAM_BUFFERS
+
+#include "native_handle.h"
+#include <hal_public.h>
+
+#include "omx_H264videoencoderutils.h"
+
+#define OMX_VIDENC_NUM_PORTS (2)
+
+#define OMX_ENGINE_NAME "ivahd_vidsvr"
+
+typedef struct OMX_H264_LVL_BITRATE {
+ OMX_VIDEO_AVCLEVELTYPE eLevel;
+ OMX_U32 nMaxBitRateSupport;
+}OMX_H264_LVL_BITRATE;
+
+typedef struct OMX_MetaDataBuffer {
+ int type;
+ void *handle;
+ int offset;
+}OMX_MetaDataBuffer;
+
+/* OMX H264 Encoder Component */
+typedef struct OMXH264VideoEncoderComponent {
+ /* base component handle */
+ OMXBaseComp sBase;
+
+ /* codec and engine handles */
+ Engine_Handle pCEhandle;
+ Engine_Error tCEerror;
+ VIDENC2_Handle pVidEncHandle;
+ OMX_BOOL bCodecCreate;
+ OMX_BOOL bCodecCreateSettingsChange;
+
+ /* Encoder static/dynamic/buf args */
+ IH264ENC_Params *pVidEncStaticParams;
+ IH264ENC_DynamicParams *pVidEncDynamicParams;
+ IH264ENC_Status *pVidEncStatus;
+ IH264ENC_InArgs *pVidEncInArgs;
+ IH264ENC_OutArgs *pVidEncOutArgs;
+ IVIDEO2_BufDesc *pVedEncInBufs;
+ XDM2_BufDesc *pVedEncOutBufs;
+
+ /* omx component statemachine variables */
+ OMX_BOOL bInputPortDisable;
+ OMX_BOOL bCodecFlush;
+ PARAMS_UPDATE_STATUS bCallxDMSetParams;
+ OMX_BOOL bAfterEOSReception;
+ OMX_BOOL bNotifyEOSEventToClient;
+ OMX_BOOL bPropagateEOSToOutputBuffer;
+ OMX_BOOL bSetParamInputIsDone;
+
+ /* codec config handling variables*/
+ OMXBase_CodecConfigBuf sCodecConfigData;
+ OMX_BOOL bSendCodecConfig;
+ OMX_U32 nCodecConfigSize;
+ OMX_BOOL bAfterGenHeader;
+
+ /* internal buffer tracking arrays */
+ OMX_BUFFERHEADERTYPE **pCodecInBufferArray;
+ OMXBase_BufHdrPvtData *pCodecInBufferBackupArray;
+
+ /* temporary memory to meet and codec and dce requirements */
+ MemHeader *pTempBuffer[2];
+
+ OMX_BOOL bInputMetaDataBufferMode;
+ OMX_PTR hCC;
+ IMG_native_handle_t **pBackupBuffers;
+ alloc_device_t *mAllocDev;
+
+} OMXH264VidEncComp;
+
+OMX_ERRORTYPE OMXH264VE_ComponentInit(OMX_HANDLETYPE hComponent);
+
+#ifdef _cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _OMX_H264VE_COMPONENT_H */
+
diff --git a/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h b/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h
new file mode 100644
index 0000000..d8ec662
--- /dev/null
+++ b/omx/videoencode/omx_h264_enc/inc/omx_H264videoencoderutils.h
@@ -0,0 +1,1122 @@
+/*
+ * 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 <string.h>
+
+#include <OMX_Core.h>
+#include <OMX_Component.h>
+#include <OMX_TI_Custom.h>
+
+#include <omx_base.h>
+#include <omx_base_utils.h>
+
+#include <xdc/std.h>
+#include <ti/sdo/ce/video2/videnc2.h>
+#include <ti/sdo/codecs/h264enc/ih264enc.h>
+
+/* For Baseline Profile :: FLAG to indicate Constrained Baseline profile in the Bitstream generated by codec
+conforming to the H264Standard */
+#define OMX_H264_SET_CONSTRAINT_SET1_FLAG 0x14
+#define OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS 0x0
+
+/* OMX Component Version */
+#define OMX_H264VE_COMP_VERSION_MAJOR 1
+
+#define OMX_H264VE_COMP_VERSION_MINOR 1
+
+#define OMX_H264VE_COMP_VERSION_REVISION 0
+
+#define OMX_H264VE_COMP_VERSION_STEP 0
+
+/* OMX Component port numbers */
+#define OMX_H264VE_NUM_PORTS (2)
+
+#define OMX_H264VE_DEFAULT_START_PORT_NUM (0)
+
+#define OMX_H264VE_INPUT_PORT (0)
+
+#define OMX_H264VE_OUTPUT_PORT (1)
+
+/* OMX Component thread related */
+#define OMX_H264VE_DEFAULT_TASKPRIORITY (10)
+
+#define OMX_H264VE_STACKSIZE (1024 * 100)
+
+/* OMX Component and Encoder Name */
+#define OMX_H264VE_COMP_NAME "OMX.TI.DUCATI1.VIDEO.H264E"
+
+#define OMX_H264V_ENCODER_NAME "ivahd_h264enc"
+
+/* Default Interframe intervals */
+#define OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL (3)
+
+#define OMX_H264VE_BASELINE_INTERFRAME_INTERVAL (1)
+
+/* OMX Component Buffer defaults */
+#define OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT (2)
+
+#define OMX_H264VE_DEFAULT_OUTPUT_BUFFER_COUNT (OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT + 2)
+
+#define OMX_H264VE_MIN_INPUT_BUFFER_COUNT (OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL)
+
+#define OMX_H264VE_DEFAULT_INPUT_BUFFER_COUNT (OMX_H264VE_MIN_INPUT_BUFFER_COUNT)
+
+/* Default Framerate */
+#define OMX_H264VE_DEFAULT_FRAME_RATE (15)
+
+/* Default Intra Frame Interval */
+#define OMX_H264VE_DEFAULT_INTRAFRAME_INTERVAL (OMX_H264VE_DEFAULT_FRAME_RATE)
+
+/* Default MaxIntra Frame Interval */
+#define OMX_H264VE_DEFAULT_MAXINTRAFRAME_INTERVAL (0x7FFFFFFF)
+
+/* Default Bitrate */
+#define OMX_H264VE_DEFAULT_BITRATE (64000)
+
+/*Default Frame Width */
+#define OMX_H264VE_DEFAULT_FRAME_WIDTH (176)
+
+/* Default Frame Height */
+#define OMX_H264VE_DEFAULT_FRAME_HEIGHT (144)
+
+/* Max Frame width */
+#define OMX_H264VE_MAX_FRAME_WIDTH (1920)
+
+/* Max Frame Height */
+#define OMX_H264VE_MAX_FRAME_HEIGHT (1088)
+
+/* Max Inter Frame Interval */
+#define OMX_H264VE_MAX_INTER_FRAME_INTERVAL (OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL)
+
+/* deafult input buffer size */
+#define OMX_H264VE_DEFAULT_INPUT_BUFFER_SIZE (OMX_H264VE_DEFAULT_FRAME_WIDTH * OMX_H264VE_DEFAULT_FRAME_HEIGHT * 3 / 2)
+
+/* deafult output buffer size */
+#define OMX_H264VE_DEFAULT_OUTPUT_BUFFER_SIZE (OMX_H264VE_DEFAULT_FRAME_WIDTH * OMX_H264VE_DEFAULT_FRAME_HEIGHT * 3 / 2)
+/* Assuming encoded frame size will not exceed this size*/
+
+/* deafult Aspect Ratio Height */
+#define OMX_H264VE_DEFAULT_ASPECT_RATIO_HEIGHT (1)
+
+/* deafult Aspect Ratio Width */
+#define OMX_H264VE_DEFAULT_ASPECT_RATIO_WIDTH (1)
+
+/* default Qp Settings for I frame */
+#define OMX_H264VE_DEFAULT_QP_IFRAME (28)
+#define OMX_H264VE_DEFAULT_QPMAX_IFRAME (36)
+#define OMX_H264VE_DEFAULT_QPMIN_IFRAME (10)
+
+/* default Qp Settings for P frame */
+#define OMX_H264VE_DEFAULT_QP_PFRAME (28)
+#define OMX_H264VE_DEFAULT_QPMAX_PFRAME (40)
+#define OMX_H264VE_DEFAULT_QPMIN_PFRAME (10)
+
+/* default Qp Settings for B frame */
+#define OMX_H264VE_DEFAULT_QPOFFSET_BFRAME (4)
+#define OMX_H264VE_DEFAULT_QPMAX_BFRAME (44)
+#define OMX_H264VE_DEFAULT_QPMIN_BFRAME (10)
+
+/* default Qp Settings for Chroma */
+#define OMX_H264VE_DEFAULT_QPOFFSET_CHROMA (0)
+
+/* default Search Range for P */
+#define OMX_H264VE_DEFAULT_HORSEARCH_PFRAME (144)
+#define OMX_H264VE_DEFAULT_VERSEARCH_PFRAME (32)
+
+/* default Search Range for B */
+#define OMX_H264VE_DEFAULT_HORSEARCH_BFRAME (144)
+#define OMX_H264VE_DEFAULT_VERSEARCH_BFRAME (16)
+
+/* default Min and Max Pic Size Ratio. Enables Codec to to chose ratio */
+#define OMX_H264VE_DEFAULT_MINPICSIZERATIO (0)
+#define OMX_H264VE_DEFAULT_MAXPICSIZERATIOI (20) // codec default is 640 in Q5 format
+#define OMX_H264VE_DEFAULT_MAXPICSIZERATIOP (0)
+#define OMX_H264VE_DEFAULT_MAXPICSIZERATIOB (0)
+
+/* the header size SPS+PPS */
+#define SPS_PPS_HEADER_DATA_SIZE 0x100
+
+/* The PARAMS_UPDATE_STATUS enum represents the status of the setconfig call.
+* With respect to a process call there are 3 possibilities:
+* 1. No params have been changed(no setconfig call has occured)
+* 2. Setconfig call has occured but the modified params have not been updated to the codec
+* It has been updated only at Ducati
+* 3. Setconfig call has occured and the modified params have been updated to the codec
+*/
+typedef enum PARAMS_UPDATE_STATUS {
+ NO_PARAM_CHANGE = 0,
+ PARAMS_UPDATED_AT_OMX = 1,
+ PARAMS_UPDATED_AT_CODEC = 2,
+ PARAMS_UPDATE_STATUS_MAX = 0x7FFFFFFF
+} PARAMS_UPDATE_STATUS;
+
+/* inline functions */
+#define GET_OMX_RC_ALG(_pCompPvtStruct_, _pParamStruct_, _e_) \
+ if((_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC) && (_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip == OMX_FALSE)) { \
+ ((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate = OMX_Video_ControlRateVariable;\
+ _e_=OMX_ErrorNone;\
+ } else if((_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY) && (_pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip == OMX_FALSE)) { \
+ ((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate = OMX_Video_ControlRateConstant;\
+ _e_=OMX_ErrorNone;\
+ }
+
+#define SET_H264CODEC_RC_ALG(_pParamStruct_, _pCompPvtStruct_, _e_) \
+ if(((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate == OMX_Video_ControlRateVariable ) { \
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_PRC;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\
+ _e_=OMX_ErrorNone;\
+ } else if(((OMX_VIDEO_PARAM_BITRATETYPE *)_pParamStruct_)->eControlRate == OMX_Video_ControlRateConstant ) { \
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_PRC_LOW_DELAY;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\
+ _e_=OMX_ErrorNone;\
+ } else {\
+ _e_=OMX_ErrorUnsupportedSetting;\
+ }
+
+#define GET_OMX_AVC_PARAMS(_pCompPvtStruct_, _pParamStruct_) \
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nSliceHeaderSpacing = 0; /* present code doesn't use this value: set to 0 */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nPFrames = (_pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval);\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames = ((_pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval) - 1);\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bUseHadamard = OMX_TRUE; /* Set to OMX_TRUE According to the Spec BUT it is not being Used by the component */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefFrames = 1; /* According to the Spec BUT present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefIdx10ActiveMinus1 = 1; /* According to Codec Support (2 ref frames for B frame Encoding)but present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nRefIdx11ActiveMinus1 = 1; /* According to Codec Support (2 ref frames for B frame Encoding)but present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableUEP = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableFMO = (((_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset) == IH264_FMOCODING_NONE) ? OMX_FALSE : OMX_TRUE);\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableASO = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableRS = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nAllowedPictureTypes = 3; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bFrameMBsOnly = OMX_TRUE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bMBAFF = ((_pCompPvtStruct_->pVidEncStaticParams->interlaceCodingType == IH264_INTERLACE_MBAFF) ? OMX_TRUE : OMX_FALSE); /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEntropyCodingCABAC = ((_pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode == IH264_ENTROPYCODING_CABAC) ? OMX_TRUE : OMX_FALSE);\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bWeightedPPrediction = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nWeightedBipredicitonMode = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred = (((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable) == 0) ? OMX_FALSE : OMX_TRUE);\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bDirect8x8Inference = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bDirectSpatialTemporal = OMX_FALSE; /* present code doesn't use this value */\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nCabacInitIdc = 0; /* present code doesn't use this value */
+
+
+#define SET_H264CODEC_PARAMS_FROM_AVC(_pParamStruct_, _pCompPvtStruct_) \
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nPFrames;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames + 1);\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = (((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->nBFrames + 1);\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEnableFMO;\
+ _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = ((((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bEntropyCodingCABAC) ? IH264_ENTROPYCODING_CABAC : IH264_ENTROPYCODING_CAVLC);\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable = ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->bconstIpred;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\
+ }
+
+#define GET_OMX_AVC_PROFILE(_pCompPvtStruct_, _pParamStruct_, _e_)\
+ switch( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile ) {\
+ case IH264_BASELINE_PROFILE :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileBaseline;\
+ break;\
+ case IH264_MAIN_PROFILE :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileMain;\
+ break;\
+ case IH264_HIGH_PROFILE :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh;\
+ break;\
+ case IH264_EXTENDED_PROFILE :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileExtended;\
+ break;\
+ case IH264_HIGH10_PROFILE :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh10;\
+ break;\
+ case IH264_HIGH422_PROFILE :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile = OMX_VIDEO_AVCProfileHigh422;\
+ break;\
+ default :\
+ _e_= OMX_ErrorNoMore;\
+ break;\
+ }
+
+#define SET_H264CODEC_PROFILE(_pParamStruct_, _pCompPvtStruct_, _e_) \
+ switch(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eProfile ) {\
+ case OMX_VIDEO_AVCProfileBaseline :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile = IH264_BASELINE_PROFILE;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\
+ _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1_FLAG;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC;\
+ _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\
+ break;\
+ case OMX_VIDEO_AVCProfileMain :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile =IH264_MAIN_PROFILE;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\
+ _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\
+ _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\
+ break;\
+ case OMX_VIDEO_AVCProfileHigh :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile=IH264_HIGH_PROFILE;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\
+ _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\
+ _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_ADAPTIVE;\
+ break;\
+ case OMX_VIDEO_AVCProfileExtended :\
+ case OMX_VIDEO_AVCProfileHigh10 :\
+ case OMX_VIDEO_AVCProfileHigh422 :\
+ default :\
+ _e_= OMX_ErrorUnsupportedSetting;\
+ break;\
+ }
+
+
+#define GET_OMX_AVC_LEVEL(_pCompPvtStruct_, _pParamStruct_, _e_)\
+ switch( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level ) {\
+ case IH264_LEVEL_10 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel1;\
+ break;\
+ case IH264_LEVEL_1b :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel1b;\
+ break;\
+ case IH264_LEVEL_11 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel11;\
+ break;\
+ case IH264_LEVEL_12 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel12;\
+ break;\
+ case IH264_LEVEL_13 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel13;\
+ break;\
+ case IH264_LEVEL_20 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel2;\
+ break;\
+ case IH264_LEVEL_21 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel21;\
+ break;\
+ case IH264_LEVEL_22 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel22;\
+ break;\
+ case IH264_LEVEL_30 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel3;\
+ break;\
+ case IH264_LEVEL_31 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel31;\
+ break;\
+ case IH264_LEVEL_32 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel32;\
+ break;\
+ case IH264_LEVEL_40 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel4;\
+ break;\
+ case IH264_LEVEL_41 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel41;\
+ break;\
+ case IH264_LEVEL_42 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel42;\
+ break;\
+ case IH264_LEVEL_50 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel5;\
+ break;\
+ case IH264_LEVEL_51 :\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel = OMX_VIDEO_AVCLevel51;\
+ break;\
+ default :\
+ _e_= OMX_ErrorNoMore;\
+ break;\
+ }
+
+#define SET_H264CODEC_LEVEL(_pParamStruct_, _pCompPvtStruct_, _e_)\
+ switch(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLevel ) {\
+ case OMX_VIDEO_AVCLevel1 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_10;\
+ break;\
+ case OMX_VIDEO_AVCLevel1b :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_1b;\
+ break;\
+ case OMX_VIDEO_AVCLevel11 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_11;\
+ break;\
+ case OMX_VIDEO_AVCLevel12 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_12;\
+ break;\
+ case OMX_VIDEO_AVCLevel13 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_13;\
+ break;\
+ case OMX_VIDEO_AVCLevel2 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_20;\
+ break;\
+ case OMX_VIDEO_AVCLevel21 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_21;\
+ break;\
+ case OMX_VIDEO_AVCLevel22 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_22;\
+ break;\
+ case OMX_VIDEO_AVCLevel3 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_30;\
+ break;\
+ case OMX_VIDEO_AVCLevel31 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_31;\
+ break;\
+ case OMX_VIDEO_AVCLevel32 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_32;\
+ break;\
+ case OMX_VIDEO_AVCLevel4 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_40;\
+ break;\
+ case OMX_VIDEO_AVCLevel41 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_41;\
+ break;\
+ case OMX_VIDEO_AVCLevel42 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_42;\
+ break;\
+ case OMX_VIDEO_AVCLevel5 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_50;\
+ break;\
+ case OMX_VIDEO_AVCLevel51 :\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_51;\
+ break;\
+ default :\
+ _e_= OMX_ErrorUnsupportedSetting;\
+ break;\
+ }
+
+#define GET_OMX_AVC_LFMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\
+ if((_pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_NONE) || (_pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_DEFAULT)) {\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_ALL_EDGES ) {\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterDisable;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC == IH264_DISABLE_FILTER_SLICE_EDGES ) {\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterDisableSliceBoundary;\
+ } else {\
+ ((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode = OMX_VIDEO_AVCLoopFilterMax;\
+ _e_= OMX_ErrorNoMore;\
+ }
+
+
+#define SET_H264CODEC_LFMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\
+ if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterEnable ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_NONE;\
+ } else if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterDisable ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_ALL_EDGES;\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = 1;\
+ } else if(((OMX_VIDEO_PARAM_AVCTYPE *)_pParamStruct_)->eLoopFilterMode == OMX_VIDEO_AVCLoopFilterDisableSliceBoundary ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_SLICE_EDGES;\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = 1;\
+ } else {\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_MAX;\
+ _e_= OMX_ErrorUnsupportedSetting;\
+ }
+
+#define GET_OMX_FMO_SLIGRPMAPTYPE(_pCompPvtStruct_, _pParamStruct_, _e_)\
+ if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_INTERLEAVED_SLICE_GRP ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 0;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_DISPERSED_SLICE_GRP ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 1;\
+ } else if((_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_SLICE_GRP_MAP_DEFAULT) || (_pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_RASTER_SCAN_SLICE_GRP)) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 2;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 3;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_BOX_OUT_SLICE_GRP ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 4;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_WIPE_SLICE_GRP ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 5;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType == IH264_EXPLICIT_SLICE_GRP ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType = 6;\
+ } else {\
+ _e_= OMX_ErrorNoMore;\
+ }
+
+#define SET_H264CODEC_FMO_SLIGRPMAPTYPE(_pParamStruct_, _pCompPvtStruct_, _e_)\
+ if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 0 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_INTERLEAVED_SLICE_GRP;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 1 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_DISPERSED_SLICE_GRP;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 2 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_RASTER_SCAN_SLICE_GRP;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 3 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_FOREGRND_WITH_LEFTOVER_SLICE_GRP;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 4 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_BOX_OUT_SLICE_GRP;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 5 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_WIPE_SLICE_GRP;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->nSliceGroupMapType == 6 ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_EXPLICIT_SLICE_GRP;\
+ } else {\
+ _e_= OMX_ErrorUnsupportedSetting;\
+ }
+
+#define GET_OMX_FMO_SLICEMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\
+ if((_pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_NONE) || (_pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT)) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCDefault;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_MBUNIT ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCMBSlice;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) {\
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode = OMX_VIDEO_SLICEMODE_AVCByteSlice;\
+ } else {\
+ _e_= OMX_ErrorNoMore;\
+ }
+
+#define SET_H264CODEC_SLICEMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\
+ if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCDefault ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCMBSlice ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_MBUNIT;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset=1;\
+ } else if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)_pParamStruct_)->eSliceMode == OMX_VIDEO_SLICEMODE_AVCByteSlice ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = 1;\
+ } else {\
+ _e_= OMX_ErrorUnsupportedSetting;\
+ }
+
+#define GET_OMX_INTRAREFRESHMODE(_pCompPvtStruct_, _pParamStruct_, _e_)\
+ if((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_NONE) || (_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_DEFAULT) || (_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_MAX)) {\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode = OMX_VIDEO_IntraRefreshMax;\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs = 0;\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirRef = 0;\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nCirMBs = 0;\
+ } else if( _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod == IH264_INTRAREFRESH_CYCLIC_MBS ) {\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode = OMX_VIDEO_IntraRefreshAdaptive;\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs = ((_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth) * (_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)) / ((_pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate) * 256);\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirRef = 0;\
+ ((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nCirMBs = 0;\
+ } else {\
+ _e_= OMX_ErrorNoMore;\
+ }
+
+#define SET_H264CODEC_INTRAREFRESHMODE(_pParamStruct_, _pCompPvtStruct_, _e_)\
+ if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode == OMX_VIDEO_IntraRefreshAdaptive ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_CYCLIC_MBS;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = ((_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth) * (_pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight)) / (((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->nAirMBs * 256);\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_CYCLIC_MBS;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate;\
+ } else if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)_pParamStruct_)->eRefreshMode == OMX_VIDEO_IntraRefreshMax ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_USERDEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_NONE;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_NONE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = 0;\
+ } else {\
+ _e_= OMX_ErrorUnsupportedSetting;\
+ }
+
+
+/*Set the Codec Chroma Format*/
+#define GET_OMX_COLORFORMAT(_pCompPvtStruct_, _e_)\
+ if((_pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat == XDM_YUV_420SP)) {\
+ _pCompPvtStruct_->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat = OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;\
+ } else {\
+ _e_ = OMX_ErrorNoMore; }
+
+#define SET_H264CODEC_CHROMAFORMAT(_pPortdefStruct_, _pCompPvtStruct_, _e_)\
+ if((_pPortdefStruct_->format.video.eColorFormat) == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar ||\
+ (_pPortdefStruct_->format.video.eColorFormat) == OMX_COLOR_FormatAndroidOpaque) {\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat = XDM_YUV_420SP;\
+ } else {\
+ _e_= OMX_ErrorUnsupportedSetting; }
+
+
+#define SET_H264CODEC_DEFAULT_IVIDENC2_PARAMS(_pCompPvtStruct_, _i_)\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.size = sizeof(IH264ENC_Params);\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.encodingPreset = XDM_USER_DEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.rateControlPreset = IVIDEO_USER_DEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.dataEndianness = XDM_BYTE;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxBitRate = -1;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.minBitRate = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputChromaFormat = XDM_YUV_420SP;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType = IVIDEO_PROGRESSIVE;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.operatingMode = IVIDEO_ENCODE_ONLY;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile = IH264_HIGH_PROFILE;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.level = IH264_LEVEL_42;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval =OMX_H264VE_MAX_INTER_FRAME_INTERVAL;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\
+ }\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputDataMode = IVIDEO_ENTIREFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.outputDataMode = IVIDEO_ENTIREFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.numInputDataUnits = 1;\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.numOutputDataUnits = 1;\
+ for( _i_ = 0; _i_ < IVIDEO_MAX_NUM_METADATA_PLANES; _i_++ ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.metadataType[_i_] = IVIDEO_METADATAPLANE_NONE;\
+ }
+
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_RATECONTROLPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rateControlParamsPreset=IH264_RATECONTROLPARAMS_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\
+ }\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.rcAlgo = IH264_RATECONTROL_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpI = OMX_H264VE_DEFAULT_QP_IFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxI = OMX_H264VE_DEFAULT_QPMAX_IFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinI = OMX_H264VE_DEFAULT_QPMIN_IFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpP = OMX_H264VE_DEFAULT_QP_PFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxP = OMX_H264VE_DEFAULT_QPMAX_PFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinP = OMX_H264VE_DEFAULT_QPMIN_PFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpOffsetB = OMX_H264VE_DEFAULT_QPOFFSET_BFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMaxB = OMX_H264VE_DEFAULT_QPMAX_BFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.qpMinB = OMX_H264VE_DEFAULT_QPMIN_BFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.allowFrameSkip = OMX_FALSE;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.removeExpensiveCoeff = OMX_FALSE;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.chromaQPIndexOffset = OMX_H264VE_DEFAULT_QPOFFSET_CHROMA;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.IPQualityFactor = IH264_QUALITY_FACTOR_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.HRDBufferSize = OMX_H264VE_DEFAULT_BITRATE;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.initialBufferLevel = pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioI = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioI = OMX_H264VE_DEFAULT_MAXPICSIZERATIOI;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioP = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioP = OMX_H264VE_DEFAULT_MAXPICSIZERATIOP;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.minPicSizeRatioB = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.maxPicSizeRatioB = OMX_H264VE_DEFAULT_MAXPICSIZERATIOB;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enablePRC = 1;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enablePartialFrameSkip = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.discardSavedBits = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reserved = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.VBRDuration = 8;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.VBRsensitivity = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.skipDistributionWindowLength = 5;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.numSkipInDistributionWindow = 1;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.enableHRDComplianceMode = 1;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.frameSkipThMulQ5 = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.vbvUseLevelThQ5 = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[0] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[1] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->rateControlParams.reservedRC[2] = 0;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTERCODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset=IH264_INTERCODING_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeHorP = OMX_H264VE_DEFAULT_HORSEARCH_PFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeVerP = OMX_H264VE_DEFAULT_VERSEARCH_PFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeHorB = OMX_H264VE_DEFAULT_HORSEARCH_BFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.searchRangeVerB = OMX_H264VE_DEFAULT_VERSEARCH_BFRAME;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.meAlgoMode = IH264ENC_MOTIONESTMODE_DEFAULT;
+
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTRACODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_DEFAULT;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x0FF;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x0;\
+ } else {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra4x4Enable = 0x1F;\
+ }\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x0;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x0FF;\
+ } else {\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra8x8Enable = 0x01F;\
+ }\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.lumaIntra16x16Enable = 0xF;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.chromaIntra8x8Enable = 0xF;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraRefreshRate = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.gdrOverlapRowsBtwFrames = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.constrainedIntraPredEnable = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->intraCodingParams.intraCodingBias = IH264ENC_INTRACODINGBIAS_DEFAULT;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_NALUCONTROLPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskStartOfSequence= 0x01A0;\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIDRPicture = 0x01A0;\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIntraPicture= 0x0002;\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskNonIntraPicture= 0x0002;\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskEndOfSequence= 0x0C00;\
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SLICECODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceUnitSize = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[0] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[1] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.sliceStartOffset[2] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_LOOPFILTERPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterPreset = IH264_LOOPFILTER_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.loopfilterDisableIDC = IH264_DISABLE_FILTER_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.filterOffsetA = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->loopFilterParams.filterOffsetB = 0;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_FMOCODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.fmoCodingPreset = IH264_FMOCODING_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.numSliceGroups = 1;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupMapType = IH264_SLICE_GRP_MAP_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeDirectionFlag = IH264ENC_SLICEGROUP_CHANGE_DIRECTION_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeRate = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupChangeCycle = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupParams[0] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->fmoCodingParams.sliceGroupParams[1] = 0;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_VUICODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.vuiCodingPreset = IH264_VUICODING_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.aspectRatioInfoPresentFlag = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.aspectRatioIdc = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoSignalTypePresentFlag = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoFormat = IH264ENC_VIDEOFORMAT_NTSC;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.videoFullRangeFlag = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.timingInfoPresentFlag = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.hrdParamsPresentFlag = XDAS_FALSE;\
+ _pCompPvtStruct_->pVidEncStaticParams->vuiCodingParams.numUnitsInTicks = 1000;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOINFOPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.stereoInfoPreset = IH264_STEREOINFO_DISABLE;\
+ _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.topFieldIsLeftViewFlag = 1;\
+ _pCompPvtStruct_->pVidEncStaticParams->stereoInfoParams.viewSelfContainedFlag = 0;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOFRAMEPACKINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.framePackingPreset = IH264_FRAMEPACK_SEI_DISABLE;\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.framePackingType = IH264_FRAMEPACK_TYPE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame0PositionX = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame0PositionY = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame1PositionX = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.frame1PositionY = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->framePackingSEIParams.reservedByte = 0;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SVCCODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.svcExtensionFlag = IH264_SVC_EXTENSION_FLAG_DISABLE;\
+ _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.dependencyID = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.qualityID = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.enhancementProfileID = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.layerIndex = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->svcCodingParams.refLayerDQId = 0;
+
+#define SET_H264CODEC_DEFAULT_STATIC_IH264ENC_EXTENDEDPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->interlaceCodingType = IH264_INTERLACE_FIELDONLY_ARF;\
+ _pCompPvtStruct_->pVidEncStaticParams->bottomFieldIntra = OMX_FALSE;\
+ _pCompPvtStruct_->pVidEncStaticParams->gopStructure = IH264ENC_GOPSTRUCTURE_DEFAULT;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CAVLC;\
+ } else {\
+ _pCompPvtStruct_->pVidEncStaticParams->entropyCodingMode = IH264_ENTROPYCODING_CABAC;\
+ }\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_ADAPTIVE;\
+ } else {\
+ _pCompPvtStruct_->pVidEncStaticParams->transformBlockSize = IH264_TRANSFORM_4x4;\
+ }\
+ _pCompPvtStruct_->pVidEncStaticParams->log2MaxFNumMinus4 = 10;\
+ _pCompPvtStruct_->pVidEncStaticParams->picOrderCountType = IH264_POC_TYPE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncStaticParams->maxIntraFrameInterval = OMX_H264VE_DEFAULT_MAXINTRAFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncStaticParams->enableWatermark = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->IDRFrameInterval = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->pConstantMemory = NULL;\
+ _pCompPvtStruct_->pVidEncStaticParams->debugTraceLevel = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->lastNFramesToLog = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->enableAnalyticinfo = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->enableGMVSei = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_DISBALE_ALL_CONSTRAINT_SET_FLAGS;\
+ _pCompPvtStruct_->pVidEncStaticParams->enableRCDO = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->enableLongTermRefFrame = IH264ENC_LTRP_NONE;\
+ _pCompPvtStruct_->pVidEncStaticParams->LTRPPeriod = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->numTemporalLayer = IH264_TEMPORAL_LAYERS_1;\
+ _pCompPvtStruct_->pVidEncStaticParams->referencePicMarking = IH264_LONG_TERM_PICTURE;\
+ _pCompPvtStruct_->pVidEncStaticParams->reservedParams[0] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->reservedParams[1] = 0;\
+ _pCompPvtStruct_->pVidEncStaticParams->reservedParams[2] = 0;
+
+#define OVERWRITE_H264CODEC_DEFAULT_STATIC_PARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluControlPreset = IH264_NALU_CONTROL_USERDEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskIDRPicture = 0x0020;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset= IH264_INTERCODING_USERDEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_MILD;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncStaticParams->constraintSetFlags = OMX_H264_SET_CONSTRAINT_SET1_FLAG;\
+ }
+
+#define ENABLE_4MV(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.interCodingPreset = IH264_INTERCODING_USERDEFINED;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;\
+ _pCompPvtStruct_->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8;
+
+#define SET_H264CODEC_DEFAULT_IVIDENC2_DYNAMICPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.size = sizeof(IH264ENC_DynamicParams);\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.inputHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.inputWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.refFrameRate = (OMX_H264VE_DEFAULT_FRAME_RATE) * 1000;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate = (OMX_H264VE_DEFAULT_FRAME_RATE) * 1000;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate = OMX_H264VE_DEFAULT_BITRATE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval = OMX_H264VE_DEFAULT_INTRAFRAME_INTERVAL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.ignoreOutbufSizeFlag = XDAS_TRUE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.captureWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_DEFAULT_INTERFRAME_INTERVAL;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile == IH264_BASELINE_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval = OMX_H264VE_BASELINE_INTERFRAME_INTERVAL;\
+ }\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy = IVIDENC2_MOTIONVECTOR_QUARTERPEL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.sampleAspectRatioHeight = OMX_H264VE_DEFAULT_ASPECT_RATIO_HEIGHT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.sampleAspectRatioWidth = OMX_H264VE_DEFAULT_ASPECT_RATIO_WIDTH;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.putDataFxn = NULL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.putDataHandle = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getDataFxn = NULL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getDataHandle = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getBufferFxn = NULL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.getBufferHandle = NULL;\
+ _pCompPvtStruct_->pVidEncDynamicParams->videnc2DynamicParams.lateAcquireArg = -1;
+
+
+#define SET_H264CODEC_DEFAULT_DYNAMIC_RATECONTROLPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NORMAL;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.scalingMatrixPreset = IH264_SCALINGMATRIX_NONE;\
+ }\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.rcAlgo = IH264_RATECONTROL_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpI = OMX_H264VE_DEFAULT_QP_IFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxI = OMX_H264VE_DEFAULT_QPMAX_IFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinI = OMX_H264VE_DEFAULT_QPMIN_IFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpP = OMX_H264VE_DEFAULT_QP_PFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxP = OMX_H264VE_DEFAULT_QPMAX_PFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinP = OMX_H264VE_DEFAULT_QPMIN_PFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpOffsetB = OMX_H264VE_DEFAULT_QPOFFSET_BFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMaxB = OMX_H264VE_DEFAULT_QPMAX_BFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.qpMinB = OMX_H264VE_DEFAULT_QPMIN_BFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.allowFrameSkip = OMX_FALSE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.removeExpensiveCoeff = OMX_FALSE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.chromaQPIndexOffset = OMX_H264VE_DEFAULT_QPOFFSET_CHROMA;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.IPQualityFactor = IH264_QUALITY_FACTOR_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.HRDBufferSize = OMX_H264VE_DEFAULT_BITRATE;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.initialBufferLevel = pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioI = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioI = OMX_H264VE_DEFAULT_MAXPICSIZERATIOI;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioP = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioP = OMX_H264VE_DEFAULT_MAXPICSIZERATIOP;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.minPicSizeRatioB = OMX_H264VE_DEFAULT_MINPICSIZERATIO;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.maxPicSizeRatioB = OMX_H264VE_DEFAULT_MAXPICSIZERATIOB;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enablePRC = 1;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enablePartialFrameSkip = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.discardSavedBits = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reserved = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.VBRDuration = 8;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.VBRsensitivity = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.skipDistributionWindowLength = 5;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.numSkipInDistributionWindow = 1;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.enableHRDComplianceMode = 1;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.frameSkipThMulQ5 = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.vbvUseLevelThQ5 = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[0] = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[1] = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->rateControlParams.reservedRC[2] = 0;
+
+
+#define SET_H264CODEC_DEFAULT_DYNAMIC_INTERCODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.interCodingPreset = IH264_INTERCODING_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeHorP = OMX_H264VE_DEFAULT_HORSEARCH_PFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeVerP = OMX_H264VE_DEFAULT_VERSEARCH_PFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeHorB = OMX_H264VE_DEFAULT_HORSEARCH_BFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.searchRangeVerB = OMX_H264VE_DEFAULT_VERSEARCH_BFRAME;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.interCodingBias = IH264_BIASFACTOR_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.meAlgoMode = IH264ENC_MOTIONESTMODE_DEFAULT;
+
+
+#define SET_H264CODEC_DEFAULT_DYNAMIC_INTRACODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_DEFAULT;\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x0FF;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x0;\
+ } else {\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra4x4Enable = 0x1F;\
+ }\
+ if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.profile != IH264_HIGH_PROFILE ) {\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x0;\
+ } else if( _pCompPvtStruct_->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x0FF;\
+ } else {\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra8x8Enable = 0x01F;\
+ }\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.lumaIntra16x16Enable = 0xF;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.chromaIntra8x8Enable = 0xF;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.chromaComponentEnable = IH264_CHROMA_COMPONENT_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshMethod = IH264_INTRAREFRESH_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraRefreshRate = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.gdrOverlapRowsBtwFrames = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.constrainedIntraPredEnable = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->intraCodingParams.intraCodingBias = IH264ENC_INTRACODINGBIAS_DEFAULT;
+
+
+#define SET_H264CODEC_DEFAULT_DYNAMIC_SLICECODINGPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_DEFAULT;\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[0] = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[1] = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.sliceStartOffset[2] = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceCodingParams.streamFormat = IH264_STREAM_FORMAT_DEFAULT;
+
+
+#define SET_H264CODEC_DEFAULT_DYNAMIC_IH264_EXTENDEDPARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->sliceGroupChangeCycle = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->searchCenter.x = 0x7FFF;\
+ _pCompPvtStruct_->pVidEncDynamicParams->searchCenter.y = 0x7FFF;\
+ _pCompPvtStruct_->pVidEncDynamicParams->enableStaticMBCount = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->enableROI = 0;\
+ _pCompPvtStruct_->pVidEncDynamicParams->reservedDynParams[0] = 0;
+
+#define OVERWRITE_H264CODEC_DEFAULT_DYNAMIC_PARAMS(_pCompPvtStruct_)\
+ _pCompPvtStruct_->pVidEncDynamicParams->interCodingParams.skipMVCodingBias = IH264_BIASFACTOR_MILD;
+
+
+#define MAP_CODEC_TO_OMX_AVCLEVEL(_InCodecLevel_, _OutOMXLevel_, _nIndex_, _e_)\
+ switch( _InCodecLevel_ ) {\
+ case IH264_LEVEL_10 :\
+ _OutOMXLevel_ = OMX_VIDEO_AVCLevel1;\
+ _nIndex_ = 0;\
+ break;\
+ case IH264_LEVEL_1b :\
+ _OutOMXLevel_ = OMX_VIDEO_AVCLevel1b;\
+ _nIndex_ = 1;\
+ break;\
+ case IH264_LEVEL_11 :\
+ _OutOMXLevel_ = OMX_VIDEO_AVCLevel11;\
+ _nIndex_ = 2;\
+ break;\
+ case IH264_LEVEL_12 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel12;\
+ _nIndex_ = 3;\
+ break;\
+ case IH264_LEVEL_13 :\
+ _OutOMXLevel_ = OMX_VIDEO_AVCLevel13;\
+ _nIndex_ = 4;\
+ break;\
+ case IH264_LEVEL_20 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel2;\
+ _nIndex_ = 5;\
+ break;\
+ case IH264_LEVEL_21 :\
+ _OutOMXLevel_=OMX_VIDEO_AVCLevel21;\
+ _nIndex_ = 6;\
+ break;\
+ case IH264_LEVEL_22 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel22;\
+ _nIndex_ = 7;\
+ break;\
+ case IH264_LEVEL_30 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel3;\
+ _nIndex_ = 8;\
+ break;\
+ case IH264_LEVEL_31 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel31;\
+ _nIndex_ = 9;\
+ break;\
+ case IH264_LEVEL_32 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel32;\
+ _nIndex_ = 10;\
+ break;\
+ case IH264_LEVEL_40 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel4;\
+ _nIndex_ = 11;\
+ break;\
+ case IH264_LEVEL_41 :\
+ _OutOMXLevel_ = OMX_VIDEO_AVCLevel41;\
+ _nIndex_ = 12;\
+ break;\
+ case IH264_LEVEL_42 :\
+ _OutOMXLevel_ = OMX_VIDEO_AVCLevel42;\
+ _nIndex_ = 13;\
+ break;\
+ case IH264_LEVEL_50 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel5;\
+ _nIndex_ = 14;\
+ break;\
+ case IH264_LEVEL_51 :\
+ _OutOMXLevel_= OMX_VIDEO_AVCLevel51;\
+ _nIndex_ = 15;\
+ break;\
+ default :\
+ _e_= OMX_ErrorNoMore;\
+ _nIndex_ = 0xFFFFFFFF;\
+ break;\
+ }
+
+/* Error mapping b/n XDM and OMX */
+#define OMX_TI_GET_ERROR(_pCompPvtStruct_, _x_, _e_) \
+ _e_ = OMX_ErrorUndefined; \
+ if( XDM_ISFATALERROR(_x_)) { /*bit 15*/\
+ _e_ = OMX_ErrorUndefined;\
+ OSAL_ErrorTrace("Undefined From Codec");\
+ }\
+ if(((_x_) >> IH264ENC_LEVEL_INCOMPLAINT_PARAMETER) & 0x1 ) { /*bit 0*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Level Incompliant Param Setting");\
+ }\
+ if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_CONTENTTYPE) & 0x1 ) { /*bit 1*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Profile Incompliant Content type(progressive/Interlace) Setting");\
+ }\
+ if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_FMO_SETTING) & 0x1 ) { /*bit 2*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Profile Incompliant FMO Param Setting");\
+ }\
+ if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_TRANSFORMBLOCKSIZE) & 0x1 ) { /*bit 3*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Profile Incompliant Transform Block Size Setting");\
+ }\
+ if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_INTERFRAMEINTERVAL) & 0x1 ) { /*bit 4*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Profile Incompliant IntraFrame Interval Setting");\
+ }\
+ if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_SCALINGMATRIXPRESET) & 0x1 ) { /*bit 5*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Profile Incompliant Scaling Matrix Setting");\
+ }\
+ if(((_x_) >> IH264ENC_PROFILE_INCOMPLAINT_ENTROPYCODINGMODE) & 0x1 ) { /*bit 6*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Profile Incompliant Entropy Coding Setting");\
+ OSAL_ErrorTrace("_or_ Due to violation of slice size (crossing the limit)");\
+ }\
+ if(((_x_) >> IH264ENC_MAX_BIT_RATE_VOILATION) & 0x1 ) { /*bit 7*/\
+ _e_ = OMX_ErrorOverflow;\
+ OSAL_ErrorTrace("Max bits for one Unit (1 sec) Voilation");\
+ }\
+ if(((_x_) >> IH264ENC_IMPROPER_HDVICP2_STATE) & 0x1 ) { /*bit 16*/\
+ _e_ = OMX_ErrorHardware;\
+ OSAL_ErrorTrace("IVAHD Device is not proper state to use");\
+ }\
+ if(((_x_) >> IH264ENC_IMPROPER_STREAMFORMAT) & 0x1 ) { /*bit 17*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due To Improper StreamFormat");\
+ }\
+ if(((_x_) >> IH264ENC_IMPROPER_POCTYPE) & 0x1 ) { /*bit 18*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to InCorrect POC Type");\
+ }\
+ if(((_x_) >> IH264ENC_IMPROPER_DATASYNC_SETTING) & 0x1 ) { /*bit 19*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Imprper DataSync Settings");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_VIDENC2PARAMS) & 0x1 ) { /*bit 20*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due To Unsupported Videnc2 Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_RATECONTROLPARAMS) & 0x1 ) { /*bit 21*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due To Unsupported Rate Control Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_INTERCODINGPARAMS) & 0x1 ) { /*bit 22*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported Intercoding Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_INTRACODINGPARAMS) & 0x1 ) { /*bit 23*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported Intracoding Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_NALUNITCONTROLPARAMS) & 0x1 ) { /*bit 24*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported NALControl Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_SLICECODINGPARAMS) & 0x1 ) { /*bit 25*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported Slicecoding Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_LOOPFILTERPARAMS) & 0x1 ) { /*bit 26*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported LoopFilter Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_FMOCODINGPARAMS) & 0x1 ) { /*bit 27*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported FMOCoding Params or");\
+ OSAL_ErrorTrace("DATASYNC::No of NALs in 1Kb of data is more than 8/ insufficient memory blocks or");\
+ OSAL_ErrorTrace("Due to Unsupported setting in N frame process call scenario");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_VUICODINGPARAMS) & 0x1 ) { /*bit 28*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported VUIcoding Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_H264ENCPARAMS) & 0x1 ) { /*bit 29*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported H264ENC Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_VIDENC2DYNAMICPARAMS) & 0x1 ) { /*bit 30*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported VIDENC2DYNAMIC Params");\
+ }\
+ if(((_x_) >> IH264ENC_UNSUPPORTED_H264ENCDYNAMICPARAMS) & 0x1 ) { /*bit 31*/\
+ _e_ = OMX_ErrorUnsupportedSetting;\
+ OSAL_ErrorTrace("Due to Unsupported H264ENCDYNAMIC Params");\
+ }\
+ if( XDM_ISUNSUPPORTEDPARAM(_x_)) { /*bit 14*/\
+ _e_ = OMX_ErrorBadParameter;\
+ OSAL_ErrorTrace("Due to UnSupported Parameter");\
+ }\
+ if( XDM_ISUNSUPPORTEDINPUT(_x_)) { /*bit 13*/\
+ _e_ = OMX_ErrorBadParameter;\
+ OSAL_ErrorTrace("Due to Unsupported Input");\
+ }\
+ if( XDM_ISCORRUPTEDHEADER(_x_)) { /*bit 12*/\
+ _e_ = OMX_ErrorStreamCorrupt;\
+ OSAL_ErrorTrace("Due to Corrupt Header");\
+ }\
+ if( XDM_ISCORRUPTEDDATA(_x_)) { /*bit 11*/\
+ _e_ = OMX_ErrorStreamCorrupt;\
+ OSAL_ErrorTrace("Due to Corrupted Data");\
+ }\
+ if( XDM_ISINSUFFICIENTDATA(_x_)) { /*bit 10*/\
+ _e_ = OMX_ErrorInsufficientResources;\
+ OSAL_ErrorTrace("Due to Insufficient Data");\
+ }
+
+/* Internal functions */
+OMX_ERRORTYPE OMXH264VE_InitFields(OMX_HANDLETYPE hComponent);
+
+OMX_ERRORTYPE OMXH264VE_InitialzeComponentPrivateParams(OMX_HANDLETYPE hComponent);
+
+OMX_ERRORTYPE OMXH264VE_SetAlgDefaultCreationParams(OMX_HANDLETYPE pHandle);
+
+OMX_ERRORTYPE OMXH264VE_SetAlgDefaultDynamicParams(OMX_HANDLETYPE pHandle);
+
+OMX_ERRORTYPE OMXH264VE_SetBufferDesc(OMX_HANDLETYPE pHandle, OMX_U32 nPortIndex);
+
+OMX_ERRORTYPE OMXH264VE_SetEncCodecReady(OMX_HANDLETYPE hComponent);
+
+OMX_ERRORTYPE OMXH264VE_UpdateParams(OMX_HANDLETYPE hComponent);
+
+/* Buffer statemachine Related*/
+OMX_ERRORTYPE OMXH264VE_FLUSHLockedBuffers(OMX_HANDLETYPE hComponent);
+OMX_ERRORTYPE OMXH264VE_GetNextFreeBufHdr(OMX_HANDLETYPE hComponent, OMX_S32 *nBuffIndex, OMX_U32 nPortIndex);
+OMX_ERRORTYPE OMXH264VE_GetNumCodecLockedBuffers(OMX_HANDLETYPE hComponent, OMX_U32 *nLockedBuffCount);
+OMX_ERRORTYPE OMXH264VE_SetDynamicParamsToCodec(OMX_HANDLETYPE hComponent);
+
+OMX_ERRORTYPE OMXH264VE_VISACONTROL(VIDENC2_Handle handle, IVIDENC2_Cmd id, IVIDENC2_DynamicParams *dynParams,
+ IVIDENC2_Status *status, OMX_HANDLETYPE hComponent, XDAS_Int32 *retval);
+
+OMX_ERRORTYPE OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(OMX_HANDLETYPE hComponent, XDAS_Int32 *retval);
+
+/* Functions to check the max bit rate supported as per profile & level settings*/
+OMX_ERRORTYPE OMXH264VE_CheckBitRateCap(OMX_U32 targetBitRate, OMX_HANDLETYPE hComponent);
+
diff --git a/omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c b/omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c
new file mode 100644
index 0000000..05fbf4c
--- /dev/null
+++ b/omx/videoencode/omx_h264_enc/src/omx_H264videoencoder.c
@@ -0,0 +1,2229 @@
+/*
+ * 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 <MetadataBufferType.h>
+#include "omx_H264videoencoder.h"
+
+#define LOG_TAG "OMX_H264_ENCODER"
+
+#define COLORCONVERT_MAX_SUB_BUFFERS (3)
+
+#define COLORCONVERT_BUFTYPE_VIRTUAL (0x0)
+#define COLORCONVERT_BUFTYPE_ION (0x1)
+#define COLORCONVERT_BUFTYPE_GRALLOCOPAQUE (0x2)
+
+static OMX_ERRORTYPE OMXH264VE_GetParameter(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nParamIndex,
+ OMX_PTR pParamStruct);
+
+static OMX_ERRORTYPE OMXH264VE_SetParameter(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nParamIndex,
+ OMX_PTR pParamStruct);
+
+static OMX_ERRORTYPE OMXH264VE_GetConfig(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pConfigData);
+
+static OMX_ERRORTYPE OMXH264VE_SetConfig(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pConfigData);
+
+static OMX_ERRORTYPE OMXH264VE_ComponentTunnelRequest(OMX_HANDLETYPE hComponent,
+ OMX_U32 nPort,
+ OMX_HANDLETYPE hTunneledComp,
+ OMX_U32 nTunneledPort,
+ OMX_TUNNELSETUPTYPE *pTunnelSetup);
+
+static OMX_ERRORTYPE OMXH264VE_CommandNotify(OMX_HANDLETYPE hComponent,
+ OMX_COMMANDTYPE Cmd,
+ OMX_U32 nParam,
+ OMX_PTR pCmdData);
+
+static OMX_ERRORTYPE OMXH264VE_DataNotify(OMX_HANDLETYPE hComponent);
+
+
+static OMX_ERRORTYPE OMXH264VE_ComponentDeinit(OMX_IN OMX_HANDLETYPE hComponent);
+
+
+static OMX_ERRORTYPE OMXH264VE_GetExtensionIndex(OMX_HANDLETYPE hComponent,
+ OMX_STRING cParameterName,
+ OMX_INDEXTYPE *pIndexType);
+
+
+int COLORCONVERT_PlatformOpaqueToNV12(void *hCC,
+ void *pSrc[COLORCONVERT_MAX_SUB_BUFFERS],
+ void *pDst[COLORCONVERT_MAX_SUB_BUFFERS],
+ int nWidth, int nHeight, int nStride,
+ int nSrcBufType,int nDstBufType)
+{
+ IMG_gralloc_module_public_t const* module = hCC;
+ int nErr = -1;
+
+ if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_VIRTUAL)) {
+ nErr = module->Blit(module, pSrc[0], pDst, HAL_PIXEL_FORMAT_TI_NV12);
+ } else if((nSrcBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE) && (nDstBufType == COLORCONVERT_BUFTYPE_GRALLOCOPAQUE )) {
+ nErr = module->Blit2(module, pSrc[0], pDst[0], nWidth, nHeight, 0, 0);
+ }
+
+ return nErr;
+}
+
+OMX_ERRORTYPE OMX_ComponentInit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OSAL_ERROR tStatus = OSAL_ErrNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+
+ OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError);
+
+ /* Allocate memory for H264VE Component's private data area */
+ pHandle->pComponentPrivate = (OMXH264VidEncComp *)OSAL_Malloc(sizeof(OMXH264VidEncComp));
+ OMX_CHECK(pHandle->pComponentPrivate != NULL, OMX_ErrorInsufficientResources);
+ tStatus = OSAL_Memset(pHandle->pComponentPrivate, 0x0, sizeof(OMXH264VidEncComp));
+ OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter);
+
+ /*Initialize the Component Private handle*/
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ eError= OMXH264VE_InitFields(pHandle);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+
+ /*initialize the Hooks to Notify Command and Data from Base Comp to Derived Comp */
+ pH264VEComp->sBase.fpCommandNotify = OMXH264VE_CommandNotify;
+ pH264VEComp->sBase.fpDataNotify = OMXH264VE_DataNotify;
+
+ /* initialize the base component */
+ eError = OMXBase_ComponentInit(hComponent);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+
+ strcpy((char *)pH264VEComp->sBase.pPvtData->cTaskName, "H264VideoEncoder");
+ pH264VEComp->sBase.pPvtData->nStackSize = OMX_H264VE_STACKSIZE;
+ pH264VEComp->sBase.pPvtData->nPrioirty = OMX_H264VE_DEFAULT_TASKPRIORITY;
+
+ /*Setting default properties. PreCondition: NumOfPorts is filled and all pointers allocated*/
+ eError = OMXBase_SetDefaultProperties(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting);
+
+ /* Override the function pointers of pHandle "OMX_COMPONENTTYPE"
+ * which Base cannot handle and needs to be taken care by the Dervied comp*/
+ pHandle->GetParameter = OMXH264VE_GetParameter;
+ pHandle->SetParameter = OMXH264VE_SetParameter;
+ pHandle->SetConfig = OMXH264VE_SetConfig;
+ pHandle->GetConfig = OMXH264VE_GetConfig;
+ pHandle->ComponentDeInit = OMXH264VE_ComponentDeinit;
+ pHandle->GetExtensionIndex = OMXH264VE_GetExtensionIndex;
+ pHandle->ComponentTunnelRequest = OMXH264VE_ComponentTunnelRequest;
+
+ eError= OMXH264VE_InitialzeComponentPrivateParams(pHandle);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+
+ /* Open the Engine*/
+ pH264VEComp->pCEhandle = Engine_open(OMX_ENGINE_NAME, NULL, &pH264VEComp->tCEerror);
+ if( pH264VEComp->pCEhandle == NULL ) {
+ OSAL_ErrorTrace("Engine creation: Could not open engine \n");
+ eError = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ pH264VEComp->bInputMetaDataBufferMode = OMX_FALSE;
+ pH264VEComp->mAllocDev = NULL;
+ pH264VEComp->hCC = NULL;
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace(" H264VE Comp Initialization Failed...! ");
+ if( pHandle ) {
+ pHandle->ComponentDeInit(hComponent);
+ }
+ }
+
+ return (eError);
+}
+
+
+static OMX_ERRORTYPE OMXH264VE_GetParameter(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nParamIndex,
+ OMX_PTR pParamStruct)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortParams = NULL;
+ OMX_VIDEO_PARAM_AVCTYPE *LAVCParams=NULL;
+ OMX_VIDEO_PARAM_VBSMCTYPE *LVBSMC = NULL;
+ OMX_STATETYPE nLCurState;
+ OMX_BOOL bAllocateLocalAVC=OMX_FALSE;
+ OMX_U32 nPortIndex;
+
+ /* Check all the input parametrs */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ OMX_CHECK(pParamStruct != NULL, OMX_ErrorBadParameter);
+
+ /*initialize the component handle and component pvt handle*/
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /* Allocate memory for LAVCParams */
+ LAVCParams = (OMX_VIDEO_PARAM_AVCTYPE *)OSAL_Malloc(sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ OMX_CHECK(LAVCParams != NULL, OMX_ErrorInsufficientResources);
+ bAllocateLocalAVC=OMX_TRUE;
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState=pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ /* GetParameter can't be invoked incase the comp is in Invalid State */
+ OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation);
+
+ switch( nParamIndex ) {
+ /* case OMX_IndexParamVideoInit: required for Standard Video Encoder as per Spec & is defined at BASE */
+ /* case OMX_IndexParamPortDefinition: required for Standard Video Encoder as per Spec & is defined at BASE */
+ /* required for Standard Video Encoder as per Spec ..
+ client uses this to query the format supported by the port */
+ case OMX_IndexParamVideoPortFormat :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError);
+ pVideoPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct;
+ /* Retrieving the Input Port params */
+ if( pVideoPortParams->nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex ) {
+ /*Get the compression format*/
+ pVideoPortParams->eCompressionFormat = OMX_VIDEO_CodingUnused;
+
+ /*Get the Frame rate : from the codec Dynamic Params...Q16 format*/
+ pVideoPortParams->xFramerate = (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate / 1000) << 16;
+
+ /*Get the supported (only 420SP is supported) color formats : from the Codec creation time Params*/
+ switch( pVideoPortParams->nIndex ) {
+ case 0 :
+ GET_OMX_COLORFORMAT(pH264VEComp, eError);
+ pVideoPortParams->eColorFormat = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat;
+ break;
+ case 1 :
+ pVideoPortParams->eColorFormat = OMX_COLOR_FormatAndroidOpaque;
+ break;
+ default :
+ eError = OMX_ErrorNoMore;
+ break;
+ }
+ }
+ /* Retrieving the Output Port params */
+ else if( pVideoPortParams->nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex ) {
+
+ /*Get the Color Format*/
+ pVideoPortParams->eColorFormat = OMX_COLOR_FormatUnused;
+
+ /*Get the Frame Rate */
+ pVideoPortParams->xFramerate = 0;
+
+ /*Get the Supported CompressionFormats: only AVC is supported*/
+ switch( pVideoPortParams->nIndex ) {
+ case 0 :
+ pVideoPortParams->eCompressionFormat = OMX_VIDEO_CodingAVC;
+ break;
+ default :
+ eError=OMX_ErrorNoMore;
+ break;
+ }
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* required for Standard Video Encoder as per Spec &
+ Client uses this to retrieve the Info related to the AVC rate control type*/
+ case OMX_IndexParamVideoBitrate :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_BITRATETYPE, eError);
+ if(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*Get the Rate Control Algorithm: from the Codec Creation Time Params*/
+ GET_OMX_RC_ALG(pH264VEComp, pParamStruct, eError);
+
+ /*Get the Target Bit Rate: from the Codec Dynamic Params*/
+ ((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate=
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate;
+
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* required for Standard Video Encoder as per Spec &
+ Client uses this to retrieve the Info related to the AVC structure type*/
+ case OMX_IndexParamVideoAvc :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError);
+ if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ GET_OMX_AVC_PARAMS(pH264VEComp, pParamStruct);
+ /*Get the Profile value from the Codec Creation Params*/
+ GET_OMX_AVC_PROFILE(pH264VEComp, pParamStruct, eError);
+
+ /*Get the level from the Codec Creation Params*/
+ GET_OMX_AVC_LEVEL(pH264VEComp, pParamStruct, eError);
+
+ /*get the LoopFilter mode form the Codec Creation Time Params*/
+ GET_OMX_AVC_LFMODE(pH264VEComp, pParamStruct, eError);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* Client uses this to retrieve the Info related to the Motion vector type*/
+ case OMX_IndexParamVideoMotionVector :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MOTIONVECTORTYPE, eError);
+ if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*Get the MV Accuracy from Codec Dynamic Params*/
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->eAccuracy =
+ (OMX_VIDEO_MOTIONVECTORTYPE)pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy;
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bUnrestrictedMVs = OMX_TRUE; /*by Default Codec Supports*/
+ /*Number of MVs depend on the min Block size selected*/
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bFourMV =
+ (pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_8x8 ? OMX_TRUE : OMX_FALSE);
+ /*Get the Search Range from the search Range for P Frame*/
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange =
+ pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorP;
+
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange =
+ pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerP;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* Client uses this to configure Info related to the quantization parameter type*/
+ case OMX_IndexParamVideoQuantization :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_QUANTIZATIONTYPE, eError);
+ if(((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI = pH264VEComp->pVidEncStaticParams->rateControlParams.qpI;
+ ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP = pH264VEComp->pVidEncStaticParams->rateControlParams.qpP;
+ ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB = (pH264VEComp->pVidEncStaticParams->rateControlParams.qpP)
+ + (pH264VEComp->pVidEncStaticParams->rateControlParams.qpOffsetB);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoSliceFMO :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCSLICEFMO, eError);
+ if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nNumSliceGroups =
+ pH264VEComp->pVidEncStaticParams->fmoCodingParams.numSliceGroups;
+
+ /*get the fmo slice grp type form the Codec Creation Time Params*/
+ GET_OMX_FMO_SLIGRPMAPTYPE(pH264VEComp, pParamStruct, eError);
+
+ /*get the slice mode from the Codec Creation Time Params*/
+ GET_OMX_FMO_SLICEMODE(pH264VEComp, pParamStruct, eError);
+
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoIntraRefresh :
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_INTRAREFRESHTYPE, eError);
+ if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ GET_OMX_INTRAREFRESHMODE(pH264VEComp, pParamStruct, eError);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* required for Standard Video Encoder as per Spec*/
+ case OMX_IndexParamVideoProfileLevelCurrent :
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
+ if(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*Get the Codec Profile */
+ GET_OMX_AVC_PROFILE(pH264VEComp, LAVCParams, eError);
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile = LAVCParams->eProfile;
+
+ /*Get the Codec level */
+ GET_OMX_AVC_LEVEL(pH264VEComp, LAVCParams, eError);
+
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel = LAVCParams->eLevel;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* required for Standard Video Encoder as per Spec*/
+ case OMX_IndexParamVideoProfileLevelQuerySupported :
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
+ if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ switch(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nProfileIndex ) {
+ case 0 :
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile = OMX_VIDEO_AVCProfileBaseline;
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel = OMX_VIDEO_AVCLevel51;
+ break;
+ case 1 :
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile=OMX_VIDEO_AVCProfileMain;
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel=OMX_VIDEO_AVCLevel51;
+ break;
+ case 2 :
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile=OMX_VIDEO_AVCProfileHigh;
+ ((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel=OMX_VIDEO_AVCLevel51;
+ break;
+ default :
+ eError =OMX_ErrorNoMore;
+ }
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoVBSMC :
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState=pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_VBSMCTYPE, eError);
+ if(((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ LVBSMC = ((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct);
+ if( pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_8x8 ) {
+ /*4MV case*/
+ LVBSMC->b16x16=OMX_TRUE;
+ LVBSMC->b16x8=OMX_TRUE;
+ LVBSMC->b8x16=OMX_TRUE;
+ LVBSMC->b8x8=OMX_TRUE;
+ LVBSMC->b8x4=OMX_FALSE;
+ LVBSMC->b4x8=OMX_FALSE;
+ LVBSMC->b4x4=OMX_FALSE;
+ } else if( pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP == IH264_BLOCKSIZE_16x16 ) {
+ /*1 MV case*/
+ /*set the same value for both P & B frames prediction*/
+ LVBSMC->b16x16=OMX_TRUE;
+ LVBSMC->b16x8=OMX_FALSE;
+ LVBSMC->b8x16=OMX_FALSE;
+ LVBSMC->b8x8=OMX_FALSE;
+ LVBSMC->b8x4=OMX_FALSE;
+ LVBSMC->b4x8=OMX_FALSE;
+ LVBSMC->b4x4=OMX_FALSE;
+ } else {
+ eError = OMX_ErrorNoMore;
+ }
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* redirects the call to "OMXBase_GetParameter" which supports standard comp indexes */
+ default :
+ eError = OMXBase_GetParameter(hComponent, nParamIndex, pParamStruct);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+ break;
+
+ }
+
+EXIT:
+ if( bAllocateLocalAVC ) {
+ OSAL_Free(LAVCParams);
+ }
+
+ return (eError);
+}
+
+static OMX_ERRORTYPE OMXH264VE_SetParameter(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nParamIndex,
+ OMX_PTR pParamStruct)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_VIDEO_PARAM_PORTFORMATTYPE *pVideoPortParams = NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *pPortDef=NULL;
+ OMX_PARAM_PORTDEFINITIONTYPE *pLocalPortDef=NULL;
+ OMX_VIDEO_PARAM_AVCTYPE *LAVCParams=NULL;
+ OMX_VIDEO_PARAM_VBSMCTYPE *LVBSMC = NULL;
+ OMX_U32 nPortIndex;
+ OMX_STATETYPE nLCurState;
+ OMX_BOOL bLCodecCreateFlag=OMX_FALSE;
+ PARAMS_UPDATE_STATUS bLCallxDMSetParams=NO_PARAM_CHANGE;
+ OMX_BOOL bAllocateLocalAVC=OMX_FALSE;
+
+ /* Check for the input parameters */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ OMX_CHECK(pParamStruct != NULL, OMX_ErrorBadParameter);
+
+ /*initialize the component handle and component pvt handle*/
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /* Allocate memory for LAVCParams */
+ LAVCParams = (OMX_VIDEO_PARAM_AVCTYPE *)OSAL_Malloc(sizeof(OMX_VIDEO_PARAM_AVCTYPE));
+ OMX_CHECK(LAVCParams != NULL, OMX_ErrorInsufficientResources);
+ bAllocateLocalAVC = OMX_TRUE;
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ /* SetParameter can't be invoked incase the comp is in Invalid State */
+ OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation);
+
+ switch( nParamIndex ) {
+ case OMX_IndexParamVideoInit :
+ OSAL_Info("In OMX_IndexParamVideoInit");
+ /* SetParameter can be invoked only when the comp is in loaded or on a disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+ OMX_CHECK((((OMX_PORT_PARAM_TYPE *)pParamStruct)->nStartPortNumber == 0), OMX_ErrorUnsupportedSetting);
+ OMX_CHECK((((OMX_PORT_PARAM_TYPE *)pParamStruct)->nPorts == 2), OMX_ErrorUnsupportedSetting);
+ OSAL_Memcpy(pH264VEComp->sBase.pVideoPortParams, pParamStruct, sizeof(OMX_PORT_PARAM_TYPE));
+ break;
+
+ case OMX_IndexParamPortDefinition :
+ OSAL_Info("In OMX_IndexParamPortDefinition");
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_PARAM_PORTDEFINITIONTYPE, eError);
+ pPortDef = (OMX_PARAM_PORTDEFINITIONTYPE *)pParamStruct;
+ nPortIndex = pPortDef->nPortIndex;
+
+ /*check for valid port index */
+ OMX_CHECK(nPortIndex < ((pH264VEComp->sBase.pVideoPortParams->nStartPortNumber) +
+ (pH264VEComp->sBase.pVideoPortParams->nPorts)), OMX_ErrorBadPortIndex);
+
+ /*successful only when the comp is in loaded or on a disabled port*/
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded) ||
+ (pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
+ OMX_ErrorIncorrectStateOperation);
+ pLocalPortDef = &(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef);
+
+ OMX_CHECK((pPortDef->nBufferCountActual >=
+ pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.nBufferCountMin), OMX_ErrorUnsupportedSetting);
+
+ pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.nBufferCountActual = pPortDef->nBufferCountActual;
+ /*if frame height/widht changes then change the buffer requirements accordingly*/
+ if( nPortIndex == OMX_H264VE_INPUT_PORT ) {
+ OMX_CHECK(((pPortDef->format.video.nFrameWidth & 0x0F) == 0), OMX_ErrorUnsupportedSetting); /*Width should be multiple of 16*/
+ if( pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType == IVIDEO_PROGRESSIVE ) {
+ OMX_CHECK(((pPortDef->format.video.nFrameHeight & 0x01) == 0), OMX_ErrorUnsupportedSetting); /* Width should be multiple of 16 */
+ } else {
+ OMX_CHECK(((pPortDef->format.video.nFrameHeight & 0x03) == 0), OMX_ErrorUnsupportedSetting); /* Width should be multiple of 16 */
+ }
+ OMX_CHECK(((pPortDef->format.video.nStride % 16 == 0) &&
+ (pPortDef->format.video.nStride >= pPortDef->format.video.nFrameWidth)), OMX_ErrorUnsupportedSetting);
+
+ OMX_CHECK((pPortDef->format.video.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar) ||
+ (pPortDef->format.video.eColorFormat == OMX_COLOR_FormatAndroidOpaque),
+ OMX_ErrorUnsupportedSetting);
+ if((pPortDef->format.video.nFrameWidth < 96) || (pPortDef->format.video.nFrameHeight < 80)) {
+ eError=OMX_ErrorUnsupportedSetting;
+ break;
+ }
+ SET_H264CODEC_CHROMAFORMAT(pPortDef, pH264VEComp, eError);
+
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ // Storing the CLient provided frame rate in internal port def structure for i/p port
+ if( pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate != pPortDef->format.video.xFramerate) {
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate =
+ pPortDef->format.video.xFramerate;
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate =
+ (pPortDef->format.video.xFramerate >> 16) * 1000;
+ }
+
+ if((pLocalPortDef->format.video.nFrameHeight != pPortDef->format.video.nFrameHeight) ||
+ (pLocalPortDef->format.video.nFrameWidth != pPortDef->format.video.nFrameWidth) ||
+ (pLocalPortDef->format.video.nStride != pPortDef->format.video.nStride)) {
+ pLocalPortDef->format.video.nStride =pPortDef->format.video.nStride;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth =
+ pPortDef->format.video.nFrameWidth;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight =
+ pPortDef->format.video.nFrameHeight;
+
+ /*Update the Sliceheight as well*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nSliceHeight =
+ pPortDef->format.video.nFrameHeight;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.maxHeight = pPortDef->format.video.nFrameHeight;
+ pH264VEComp->pVidEncStaticParams->videnc2Params.maxWidth = pPortDef->format.video.nFrameWidth;
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth = pPortDef->format.video.nFrameWidth;
+
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.captureWidth =
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth;
+
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputHeight = pPortDef->format.video.nFrameHeight;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferSize =
+ (pPortDef->format.video.nFrameHeight * pPortDef->format.video.nFrameWidth * 3 )/2;
+
+ bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ OSAL_Memcpy(&(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.format), &(pPortDef->format),
+ sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
+
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize =
+ (pPortDef->format.video.nFrameHeight * pPortDef->format.video.nStride * 3) / 2;
+
+ if (pH264VEComp->bInputMetaDataBufferMode)
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = sizeof(OMX_MetaDataBuffer);
+
+ /* read only field value. update with the frame height.for now codec does not supports the sub frame processing*/
+ pLocalPortDef->format.video.nSliceHeight=pPortDef->format.video.nFrameHeight;
+
+ bLCodecCreateFlag = OMX_TRUE;
+ pH264VEComp->bSetParamInputIsDone = OMX_TRUE;
+ }
+ } else {
+ /*OUTPUT Port*/
+ OMX_CHECK((pPortDef->format.video.nFrameWidth ==
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth),
+ OMX_ErrorUnsupportedSetting);
+ OMX_CHECK((pPortDef->format.video.nFrameHeight ==
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight),
+ OMX_ErrorUnsupportedSetting);
+
+ if( pPortDef->format.video.xFramerate != 0 ) {
+ OSAL_ErrorTrace("Non-zero framerate rate set on o/p port. Setting frame rate is supported only on i/p port");
+ eError = OMX_ErrorUnsupportedSetting;
+ goto EXIT;
+ }
+ eError = OMXH264VE_CheckBitRateCap(pPortDef->format.video.nBitrate, hComponent);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ OSAL_Memcpy(&(pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.format), &(pPortDef->format),
+ sizeof(OMX_VIDEO_PORTDEFINITIONTYPE));
+
+ /*Not to modify the read only field value*/
+ pLocalPortDef->format.video.nSliceHeight =
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight;
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate =
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate;
+
+ OMX_CHECK(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat ==
+ OMX_VIDEO_CodingAVC, OMX_ErrorUnsupportedSetting);
+ bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX;
+ }
+ break;
+
+ /* client uses this to modify the format type of an port */
+ case OMX_IndexParamVideoPortFormat :
+ OSAL_Info("In OMX_IndexParamVideoPortFormat");
+ /* SetParameter can be invoked only when the comp is in loaded or on a disabled port */
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PORTFORMATTYPE, eError);
+ pVideoPortParams = (OMX_VIDEO_PARAM_PORTFORMATTYPE *)pParamStruct;
+ nPortIndex = pVideoPortParams->nPortIndex;
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded) ||
+ (pH264VEComp->sBase.pPorts[nPortIndex]->sPortDef.bEnabled == OMX_FALSE),
+ OMX_ErrorIncorrectStateOperation);
+ /* Specifying the Video port format type params */
+ if( nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex ) {
+ pLocalPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef);
+ if((pLocalPortDef->format.video.xFramerate != pVideoPortParams->xFramerate) ||
+ (pLocalPortDef->format.video.eColorFormat != pVideoPortParams->eColorFormat)) {
+ SET_H264CODEC_CHROMAFORMAT(pLocalPortDef, pH264VEComp, eError);
+
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ /*Set the Codec Params accordingly*/
+ pLocalPortDef->format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ pLocalPortDef->format.video.xFramerate = pVideoPortParams->xFramerate;
+ pLocalPortDef->format.video.eColorFormat = pVideoPortParams->eColorFormat;
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate =
+ (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate >> 16) * 1000;
+ bLCodecCreateFlag = OMX_TRUE;
+ }
+ } else if( nPortIndex == pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex ) {
+ pLocalPortDef = &(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef);
+ /*set the corresponding Portdef fields*/
+ if((pLocalPortDef->format.video.xFramerate != pVideoPortParams->xFramerate) ||
+ (pLocalPortDef->format.video.eCompressionFormat != pVideoPortParams->eCompressionFormat)) {
+ if( pVideoPortParams->xFramerate != 0 ) {
+ OSAL_ErrorTrace("Non-zero framerate rate set on o/p port. Setting frame rate is supported only on i/p port");
+ eError = OMX_ErrorUnsupportedSetting;
+ goto EXIT;
+ }
+ pLocalPortDef->format.video.eCompressionFormat = pVideoPortParams->eCompressionFormat;
+ pLocalPortDef->format.video.xFramerate = pVideoPortParams->xFramerate;
+ pLocalPortDef->format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ OMX_CHECK(pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat ==
+ OMX_VIDEO_CodingAVC, OMX_ErrorUnsupportedSetting);
+ bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ }
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ break;
+ }
+ break;
+
+ /* Client uses this to configure Video Bit rate type and target bit-rate */
+ case OMX_IndexParamVideoBitrate :
+ OSAL_Info("In OMX_IndexParamVideoBitrate");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_BITRATETYPE, eError);
+ if(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*check for the rateControlPreset can be set only when it is IVIDEO_USER_DEFINED*/
+ if( pH264VEComp->pVidEncStaticParams->videnc2Params.rateControlPreset != IVIDEO_USER_DEFINED ) {
+ OSAL_ErrorTrace("Rate control preset is not set to User defined");
+ eError = OMX_ErrorUnsupportedSetting;
+ goto EXIT;
+ }
+ /*Set the Codec Rate Control Algorithm: */
+ SET_H264CODEC_RC_ALG(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ /*Set the Preset to User Defined*/
+ if((((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->eControlRate) != OMX_Video_ControlRateVariable ) {
+ pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = 1; //UserDefined
+ }
+ eError = OMXH264VE_CheckBitRateCap(((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate, hComponent);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ /*Set the Codec Target Bit Rate: from the Codec Dynamic Params*/
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate =
+ ((OMX_VIDEO_PARAM_BITRATETYPE *)pParamStruct)->nTargetBitrate;
+
+ /*Update the output port bit rate as well...for the get param to reflect the proper values*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate =
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* Client uses this to configure AVC structure Parameters*/
+ case OMX_IndexParamVideoAvc :
+ OSAL_Info("In OMX_IndexParamVideoAvc");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCTYPE, eError);
+ if(((OMX_VIDEO_PARAM_AVCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*Set the Codec Profile */
+ SET_H264CODEC_PROFILE(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ /*Set the Codec level */
+ SET_H264CODEC_LEVEL(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ eError = OMXH264VE_CheckBitRateCap(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate, hComponent);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ SET_H264CODEC_PARAMS_FROM_AVC(pParamStruct, pH264VEComp);
+
+ /*Set the LoopFilter mode */
+ SET_H264CODEC_LFMODE(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ /*depending on the interframe interval (nBframes supported) update the buffer requirements */
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin =
+ pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval;
+ if( pH264VEComp->bSetParamInputIsDone == OMX_TRUE ) {
+ if((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual) <
+ (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin)) {
+ eError=OMX_ErrorBadParameter;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual =
+ pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval;
+ OSAL_ErrorTrace("need to set the no of buffers properly (buffactual < min requirement)");
+ goto EXIT;
+ }
+ } else {
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual =
+ pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval;
+ }
+ OSAL_Info("input port buff actual =%d", pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->nBufferCountActual);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoMotionVector :
+ OSAL_Info("In OMX_IndexParamVideoMotionVector");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_MOTIONVECTORTYPE, eError);
+ if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*Get the MV Accuracy from Codec Dynamic Params*/
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.mvAccuracy =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->eAccuracy;
+ /*Number of MVs depend on the min Block size selected*/
+ if(((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->bFourMV ) {
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8;
+ } else {
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_16x16;
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_16x16;
+ }
+ /*Set the Search Range for P Frame*/
+ pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorP =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange;
+ pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerP =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange;
+ /*Set the Search Range for B Frame*/
+ pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeHorB =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange;
+ pH264VEComp->pVidEncStaticParams->interCodingParams.searchRangeVerB =
+ OMX_H264VE_DEFAULT_VERSEARCH_BFRAME; /*the only supported value by codec*/
+
+ /*Update the corresponding Dynamic params also*/
+ /*Set the Search Range for P Frame*/
+ pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeHorP =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange;
+ pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeVerP =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sYSearchRange;
+ /*Set the Search Range for B Frame*/
+ pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeHorB =
+ ((OMX_VIDEO_PARAM_MOTIONVECTORTYPE *)pParamStruct)->sXSearchRange;
+ pH264VEComp->pVidEncDynamicParams->interCodingParams.searchRangeVerB =
+ OMX_H264VE_DEFAULT_VERSEARCH_BFRAME; /*the only supported value by codec*/
+ pH264VEComp->pVidEncStaticParams->interCodingParams.interCodingPreset = 1; //User Defined
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoQuantization :
+ OSAL_Info("In OMX_IndexParamVideoQuantization");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_QUANTIZATIONTYPE, eError);
+ if(((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset =
+ IH264_RATECONTROLPARAMS_USERDEFINED;
+ pH264VEComp->pVidEncStaticParams->rateControlParams.qpI = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI;
+ pH264VEComp->pVidEncStaticParams->rateControlParams.qpP = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP;
+ (pH264VEComp->pVidEncStaticParams->rateControlParams.qpOffsetB) =
+ ((((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB) -
+ (((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP));
+
+ /*Update the corresponding Dynamic params also*/
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset =
+ IH264_RATECONTROLPARAMS_USERDEFINED;
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.qpI = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpI;
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.qpP = ((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP;
+ (pH264VEComp->pVidEncDynamicParams->rateControlParams.qpOffsetB) =
+ ((((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpB) -
+ (((OMX_VIDEO_PARAM_QUANTIZATIONTYPE *)pParamStruct)->nQpP));
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoSliceFMO :
+ OSAL_Info("In OMX_IndexParamVideoSliceFMO");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_AVCSLICEFMO, eError);
+ if(((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ pH264VEComp->pVidEncStaticParams->fmoCodingParams.numSliceGroups =
+ ((OMX_VIDEO_PARAM_AVCSLICEFMO *)pParamStruct)->nNumSliceGroups;
+ /*Set the slicegrp type*/
+ SET_H264CODEC_FMO_SLIGRPMAPTYPE(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ /*Set the slicemode*/
+ SET_H264CODEC_SLICEMODE(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ /*Update the corresponding Dynamic params also*/
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode =
+ pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoIntraRefresh :
+ OSAL_Info("In OMX_IndexParamVideoIntraRefresh");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_INTRAREFRESHTYPE, eError);
+ if(((OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ //SET_H264CODEC_INTRAREFRESHMODE(pParamStruct, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoVBSMC :
+ OSAL_Info("In OMX_IndexParamVideoVBSMC");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_VBSMCTYPE, eError);
+ if(((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ LVBSMC = ((OMX_VIDEO_PARAM_VBSMCTYPE *)pParamStruct);
+ if((LVBSMC->b16x16 == OMX_TRUE) && (LVBSMC->b16x8 == OMX_TRUE) && (LVBSMC->b8x16 == OMX_TRUE) &&
+ (LVBSMC->b8x8 == OMX_TRUE) && (LVBSMC->b8x4 == OMX_FALSE) && (LVBSMC->b4x8 == OMX_FALSE) &&
+ (LVBSMC->b4x4 == OMX_FALSE)) {
+ /*4MV case*/
+ /*set the same value for both P & B frames prediction*/
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_8x8;
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_8x8;
+ } else if((LVBSMC->b16x16 == OMX_TRUE) && (LVBSMC->b16x8 == OMX_FALSE) && (LVBSMC->b8x16 == OMX_FALSE) &&
+ (LVBSMC->b8x8 == OMX_FALSE) && (LVBSMC->b8x4 == OMX_FALSE) && (LVBSMC->b4x8 == OMX_FALSE) &&
+ (LVBSMC->b4x4 == OMX_FALSE)) {
+ /*1 MV case*/
+ /*set the same value for both P & B frames prediction*/
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeP = IH264_BLOCKSIZE_16x16;
+ pH264VEComp->pVidEncStaticParams->interCodingParams.minBlockSizeB = IH264_BLOCKSIZE_16x16;
+ } else {
+ eError = OMX_ErrorUnsupportedSetting;
+ }
+ pH264VEComp->pVidEncStaticParams->interCodingParams.interCodingPreset = 1; //User Defined
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamVideoProfileLevelCurrent :
+ OSAL_Info("In OMX_IndexParamVideoProfileLevelCurrent");
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pParamStruct, OMX_VIDEO_PARAM_PROFILELEVELTYPE, eError);
+ if(((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ /*Set the Codec Profile */
+ LAVCParams->eProfile = (OMX_VIDEO_AVCPROFILETYPE)((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eProfile;
+ SET_H264CODEC_PROFILE(LAVCParams, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+
+ /*Set the Codec level */
+ LAVCParams->eLevel = (OMX_VIDEO_AVCLEVELTYPE)((OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pParamStruct)->eLevel;
+ SET_H264CODEC_LEVEL(LAVCParams, pH264VEComp, eError);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexParamStandardComponentRole :
+ /*Nothing to do Right Now As the Component supports only one Role: AVC*/
+ /*if it suppots multiple roles then need to set the params (Component Pvt, Codec Create & Dynamic acordingly*/
+ break;
+ case (OMX_INDEXTYPE)OMX_TI_IndexEncoderReceiveMetadataBuffers:
+ /* SetParameter can be invoked only when the comp is in loaded or on disabled port */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+
+ hw_module_t const* module = NULL;
+ eError = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module);
+ if (eError == 0) {
+ pH264VEComp->hCC = (void *) ((IMG_gralloc_module_public_t const *)module);
+ pH264VEComp->bInputMetaDataBufferMode = OMX_TRUE;
+ }
+ break;
+
+ /* redirects the call to "OMXBase_SetParameter" which supports standard comp indexes */
+ default :
+ OSAL_Info("In Default: Call to BASE Set Parameter");
+ eError = OMXBase_SetParameter(hComponent, nParamIndex, pParamStruct);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+ break;
+ }
+
+ if( bLCodecCreateFlag == OMX_TRUE ) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCodecCreateSettingsChange=OMX_TRUE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+ if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_OMX;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+
+EXIT:
+
+ if( bAllocateLocalAVC ) {
+ OSAL_Free(LAVCParams);
+ }
+
+ return (eError);
+}
+
+
+static OMX_ERRORTYPE OMXH264VE_GetConfig(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pConfigData)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_STATETYPE nLCurState;
+
+ /* Check the input params */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ OMX_CHECK(pConfigData != NULL, OMX_ErrorBadParameter);
+
+ /*initialize the component handle and component pvt handle*/
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /* GetConfig can't be invoked when the comp is in Invalid state */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation);
+
+ /* Take care of Supported Indexes over here */
+ switch( nIndex ) {
+ /* Client uses this to retrieve the bitrate structure*/
+ case OMX_IndexConfigVideoBitrate :
+ OSAL_Info("In OMX_IndexConfigVideoBitrate");
+ /*required for Standard Video Encoder as per Spec*/
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_BITRATETYPE, eError);
+ if(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ ((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate =
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoFramerate :
+ OSAL_Info("In OMX_IndexConfigVideoFramerate");
+ /*required for Standard Video Encoder as per Spec*/
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_FRAMERATETYPE, eError);
+ if(((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_INPUT_PORT ) {
+ ((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate << 16) / 1000; /*Q16 format*/
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ /* Client uses this to configure the intra refresh period */
+ case OMX_IndexConfigVideoAVCIntraPeriod :
+ OSAL_Info("In OMX_IndexConfigVideoAVCIntraPeriod");
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_AVCINTRAPERIOD, eError);
+ if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod = pH264VEComp->pVidEncStaticParams->IDRFrameInterval;
+ ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPFrames =
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoIntraVOPRefresh :
+ OSAL_Info("In OMX_IndexConfigVideoIntraVOPRefresh");
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_INTRAREFRESHVOPTYPE, eError);
+ if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ ((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->IntraRefreshVOP =
+ ((pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame == IVIDEO_I_FRAME) ? OMX_TRUE : OMX_FALSE);
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoNalSize :
+ OSAL_Info("In OMX_IndexConfigVideoNalSize");
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_NALSIZE, eError);
+ if(((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) {
+ ((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nNaluBytes =
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize;
+ } else {
+ eError = OMX_ErrorUnsupportedSetting;
+ }
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigPriorityMgmt :
+ OSAL_Info("In OMX_IndexConfigPriorityMgmt");
+
+ default :
+ OSAL_Info("In Default: Call to BASE GetConfig");
+ eError = OMXBase_GetConfig(hComponent, nIndex, pConfigData);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+ break;
+ }
+
+EXIT:
+ return (eError);
+
+}
+
+
+static OMX_ERRORTYPE OMXH264VE_SetConfig(OMX_HANDLETYPE hComponent,
+ OMX_INDEXTYPE nIndex,
+ OMX_PTR pConfigData)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_STATETYPE nLCurState;
+ OMX_BOOL bLCodecCreateFlag=OMX_FALSE;
+ OMX_U32 tStatus;
+ PARAMS_UPDATE_STATUS bLCallxDMSetParams=NO_PARAM_CHANGE;
+
+ /* Check the input params */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ OMX_CHECK(pConfigData != NULL, OMX_ErrorBadParameter);
+
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /* SetConfig can't be invoked when the comp is in Invalid state */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ OMX_CHECK(nLCurState != OMX_StateInvalid, OMX_ErrorIncorrectStateOperation);
+
+ /* Take care of Supported Indices over here */
+ switch( nIndex ) {
+ case OMX_IndexConfigVideoBitrate :
+ OSAL_Info("In OMX_IndexConfigVideoBitrate");
+ /*required for Standard Video Encoder as per Spec*/
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_BITRATETYPE, eError);
+ if(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ eError = OMXH264VE_CheckBitRateCap(((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate, hComponent);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorUnsupportedSetting);
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate =
+ ((OMX_VIDEO_CONFIG_BITRATETYPE *)pConfigData)->nEncodeBitrate;
+ /*Update the output port bit rate as well...for the get param to reflect the proper values*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate =
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate;
+ /*set the HRD biffer size appropriately*/
+ if( pH264VEComp->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY ) {
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2;
+ } else {
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate);
+ }
+ bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX;
+
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoFramerate :
+ OSAL_Info("In OMX_IndexConfigVideoFramerate");
+ /*required for Standard Video Encoder as per Spec*/
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_FRAMERATETYPE, eError);
+ if(((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->nPortIndex == OMX_H264VE_INPUT_PORT ) {
+ if( pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate !=
+ (((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate)) {
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetFrameRate =
+ ((((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate) >> 16) * 1000;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate =
+ (((OMX_CONFIG_FRAMERATETYPE *)pConfigData)->xEncodeFramerate);
+ bLCallxDMSetParams=PARAMS_UPDATED_AT_OMX;
+ }
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoAVCIntraPeriod :
+ OSAL_Info("In OMX_IndexConfigVideoAVCIntraPeriod");
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_AVCINTRAPERIOD, eError);
+ if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ nLCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ /*If Client want to set the IDR frame Interval */
+ if(((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod != 1 ) {
+ /*IDR frame Interval is other than the Component default settings -
+ it is possible only when the component is in loaded state*/
+ OMX_CHECK((nLCurState == OMX_StateLoaded), OMX_ErrorIncorrectStateOperation);
+ pH264VEComp->pVidEncStaticParams->IDRFrameInterval = ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nIDRPeriod;
+ bLCodecCreateFlag = OMX_TRUE;
+ }
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.intraFrameInterval =
+ ((OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pConfigData)->nPFrames;
+ bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoIntraVOPRefresh :
+ OSAL_Info("In OMX_IndexConfigVideoIntraVOPRefresh");
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_CONFIG_INTRAREFRESHVOPTYPE, eError);
+ if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ if(((OMX_CONFIG_INTRAREFRESHVOPTYPE *)pConfigData)->IntraRefreshVOP ) {
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_IDR_FRAME;
+ } else {
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.forceFrame = IVIDEO_NA_FRAME;
+ }
+ bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigVideoNalSize :
+ OSAL_Info("In OMX_IndexConfigVideoNalSize");
+ /* Check for the correct nSize & nVersion information */
+ OMX_BASE_CHK_VERSION(pConfigData, OMX_VIDEO_CONFIG_NALSIZE, eError);
+ if(((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT ) {
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES;
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED;
+ }
+ if( pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_BYTES ) {
+ OMX_CHECK(pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType != IVIDEO_INTERLACED,
+ OMX_ErrorUnsupportedSetting);
+ OMX_CHECK(pH264VEComp->pVidEncStaticParams->entropyCodingMode != IH264_ENTROPYCODING_CABAC,
+ OMX_ErrorUnsupportedSetting);
+ OMX_CHECK(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.inputWidth >= 128,
+ OMX_ErrorUnsupportedSetting);
+ OMX_CHECK(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.interFrameInterval == 1,
+ OMX_ErrorUnsupportedSetting);
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize =
+ ((OMX_VIDEO_CONFIG_NALSIZE *)pConfigData)->nNaluBytes;
+
+ bLCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ if((nLCurState == OMX_StateLoaded) && (eError == OMX_ErrorNone)) {
+ if( pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode == IH264_SLICEMODE_DEFAULT ) {
+ pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceMode = IH264_SLICEMODE_BYTES;
+ pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceCodingPreset = IH264_SLICECODING_USERDEFINED;
+ }
+ pH264VEComp->pVidEncStaticParams->sliceCodingParams.sliceUnitSize =
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceUnitSize;
+ }
+ } else {
+ eError = OMX_ErrorUnsupportedSetting;
+ }
+ } else {
+ eError = OMX_ErrorBadPortIndex;
+ }
+ break;
+
+ case OMX_IndexConfigPriorityMgmt :
+ OSAL_ErrorTrace("In OMX_IndexConfigPriorityMgmt");
+
+ break;
+
+ default :
+ OSAL_Info("In Default: Call to BASE SetConfig");
+ eError = OMXBase_SetConfig(hComponent, nIndex, pConfigData);
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+ break;
+ }
+
+ if( bLCodecCreateFlag == OMX_TRUE ) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCodecCreateSettingsChange = OMX_TRUE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+
+ if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+
+EXIT:
+
+ return (eError);
+}
+
+
+static OMX_ERRORTYPE OMXH264VE_CommandNotify(OMX_HANDLETYPE hComponent,
+ OMX_COMMANDTYPE Cmd,
+ OMX_U32 nParam,
+ OMX_PTR pCmdData)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_U32 i;
+ OMX_STATETYPE tCurState, tNewState;
+ XDAS_Int32 retval = 0;
+
+ /* Check the input parameters */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+
+ /* Complete all the operations like Alg Instance create or
+ * allocation of any resources which are specific to the Component, Notify this
+ * Asynchronous event completion to the Base Comp via ReturnEventNotify call*/
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ tCurState = pH264VEComp->sBase.tCurState;
+ tNewState = pH264VEComp->sBase.tNewState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ switch( Cmd ) {
+ case OMX_CommandStateSet :
+ /* Incase if the comp is moving from loaded to idle */
+ if((tCurState == OMX_StateLoaded) && (tNewState == OMX_StateIdle)) {
+ OSAL_Info("In OMX_CommandStateSet:Loaded to Idle");
+ eError = OMXH264VE_SetEncCodecReady(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+
+ /* Incase if the comp is moving from idle to executing, process buffers if an supplier port */
+ else if(((tCurState == OMX_StateIdle) && (tNewState == OMX_StateExecuting)) ||
+ ((tCurState == OMX_StateIdle) && (tNewState == OMX_StatePause))) {
+ OSAL_Info("In OMX_CommandStateSet:Idle to Executing");
+
+ pH264VEComp->pCodecInBufferArray = (OMX_BUFFERHEADERTYPE **)OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE*) *
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual);
+ OMX_CHECK(pH264VEComp->pCodecInBufferArray != NULL, OMX_ErrorInsufficientResources);
+ /*allocate the memory for the bufferhdrs*/
+ for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) {
+ pH264VEComp->pCodecInBufferArray[i] = NULL;
+ }
+
+ pH264VEComp->pCodecInBufferBackupArray = (OMXBase_BufHdrPvtData *)OSAL_Malloc(sizeof(OMXBase_BufHdrPvtData) *
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual);
+
+ OMX_CHECK(pH264VEComp->pCodecInBufferBackupArray != NULL, OMX_ErrorInsufficientResources);
+
+ if ( ! pH264VEComp->bInputMetaDataBufferMode) {
+ for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++) {
+ MemHeader *h = &(pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[0]);
+ h->ptr = memplugin_alloc_noheader(h, pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
+ MEM_TILER8_2D, 0 ,0);
+
+ h = &(pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[1]);
+ h->ptr = memplugin_alloc_noheader(h, pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight / 2,
+ MEM_TILER16_2D, 0 ,0);
+ }
+ }
+ }
+ /* Incase If the comp is moving to Idle from executing, return all the buffers back to the IL client*/
+ else if(((tCurState == OMX_StateExecuting) && (tNewState == OMX_StateIdle)) ||
+ ((tCurState == OMX_StatePause) && (tNewState == OMX_StateIdle))) {
+ OSAL_Info("In OMX_CommandStateSet:Executing/Pause to Idle");
+
+ /*Flushout all the locked buffers*/
+ eError=OMXH264VE_FLUSHLockedBuffers(pHandle);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ if( pH264VEComp->bCodecCreate ) {
+ /*Codec Call: control call with command XDM_RESET*/
+ OSAL_Info("Call Codec_RESET ");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval != VIDENC2_EOK ) {
+ OSAL_ErrorTrace("Got error from the Codec_RESET call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+
+ if( pH264VEComp->pCodecInBufferArray ) {
+ OSAL_Free(pH264VEComp->pCodecInBufferArray);
+ }
+
+ if (!pH264VEComp->bInputMetaDataBufferMode) {
+ for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++) {
+ MemHeader *h = &(pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[0]);
+ memplugin_free_noheader(h);
+
+ h = &(pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[1]);
+ memplugin_free_noheader(h);
+ }
+ } else if (pH264VEComp->pBackupBuffers) {
+ for (i = 0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++) {
+ if(pH264VEComp->pBackupBuffers[i]) {
+ pH264VEComp->mAllocDev->free(pH264VEComp->mAllocDev, (buffer_handle_t)(pH264VEComp->pBackupBuffers[i]));
+ pH264VEComp->pBackupBuffers[i] = NULL;
+ }
+ }
+ OSAL_Free(pH264VEComp->pBackupBuffers);
+ pH264VEComp->pBackupBuffers = NULL;
+ }
+
+ if( pH264VEComp->pCodecInBufferBackupArray ) {
+ OSAL_Free(pH264VEComp->pCodecInBufferBackupArray);
+ }
+
+ if(pH264VEComp && pH264VEComp->mAllocDev) {
+ gralloc_close(pH264VEComp->mAllocDev);
+ pH264VEComp->mAllocDev = NULL;
+ }
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->nCodecConfigSize = 0;
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ /* Update the Generate Header Params : to continue with New stream w/o codec create */
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ pH264VEComp->bSendCodecConfig = OMX_TRUE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+ /* State transition from pause to executing state */
+ else if((tCurState == OMX_StatePause) &&
+ (tNewState == OMX_StateExecuting)) {
+ OSAL_Info("In OMX_CommandStateSet:Pause to Executing");
+ } else if((tCurState == OMX_StateExecuting) &&
+ (tNewState == OMX_StatePause)) {
+ } else if((tCurState == OMX_StateIdle) &&
+ (tNewState == OMX_StateLoaded)) {
+ OSAL_Info("In OMX_CommandStateSet:Idle to Loaded");
+ /* Delete the Codec Instance */
+ if( pH264VEComp->bCodecCreate && pH264VEComp->pVidEncHandle) {
+ VIDENC2_delete(pH264VEComp->pVidEncHandle);
+ pH264VEComp->pVidEncHandle = NULL;
+ }
+ pH264VEComp->bCodecCreate=OMX_FALSE;
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_OMX;
+ pH264VEComp->bSendCodecConfig=OMX_TRUE;
+ pH264VEComp->bSetParamInputIsDone = OMX_FALSE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ } else if( tNewState == OMX_StateInvalid ) {
+ OSAL_Info("In OMX_CommandStateSet:Invalid state");
+ /* Delete the Codec Instance */
+ if( pH264VEComp->bCodecCreate && pH264VEComp->pVidEncHandle) {
+ VIDENC2_delete(pH264VEComp->pVidEncHandle);
+ pH264VEComp->pVidEncHandle = NULL;
+ }
+ pH264VEComp->bCodecCreate=OMX_FALSE;
+ }
+ break;
+
+ case OMX_CommandFlush :
+ OSAL_Info("In OMX_CommandFlush");
+ OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)),
+ OMX_ErrorBadParameter);
+ if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) {
+ if( pH264VEComp->bCodecCreate ) {
+ /*Codec Call: control call with command XDM_FLUSH*/
+ OSAL_Info("Call CodecFlush ");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval != VIDENC2_EOK ) {
+ OSAL_ErrorTrace("Got error from the CodecFlush call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ /*Flushout all the locked buffers*/
+ eError = OMXH264VE_FLUSHLockedBuffers(pHandle);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ /* Reset the Codec : to continue with New stream w/o codec create */
+ if( pH264VEComp->bCodecCreate ) {
+ /*Codec Call: control call with command XDM_RESET*/
+ OSAL_Info("Call Codec_RESET ");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval != VIDENC2_EOK ) {
+ OSAL_ErrorTrace("Got error from the Codec_RESET call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ pH264VEComp->bSendCodecConfig = OMX_TRUE;
+ pH264VEComp->nCodecConfigSize = 0;
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+ if(nParam == OMX_H264VE_OUTPUT_PORT) {
+ /*do nothing*/
+ }
+ break;
+
+ case OMX_CommandPortDisable :
+ OSAL_Info("In OMX_CommandPortDisable");
+ OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)),
+ OMX_ErrorBadParameter);
+ if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) {
+ if( pH264VEComp->bCodecCreate ) {
+ /*control call with command XDM_FLUSH*/
+ OSAL_Info("Call CodecFlush ");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval != VIDENC2_EOK ) {
+ OSAL_ErrorTrace("Got error from the CodecFlush call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ /*Flushout all the locked buffers*/
+ eError= OMXH264VE_FLUSHLockedBuffers(pHandle);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ /* Reset the Codec : to continue with New stream w/o codec create */
+ if( pH264VEComp->bCodecCreate ) {
+ /*Codec Call: control call with command XDM_RESET*/
+ OSAL_Info("Call Codec_RESET ");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval != VIDENC2_EOK ) {
+ OSAL_ErrorTrace("Got error from the Codec_RESET call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ pH264VEComp->bInputPortDisable = OMX_TRUE;
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ pH264VEComp->bSendCodecConfig = OMX_TRUE;
+ pH264VEComp->bSetParamInputIsDone = OMX_FALSE;
+ pH264VEComp->nCodecConfigSize = 0;
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+ if( nParam == OMX_H264VE_OUTPUT_PORT ) {
+ /*do nothing*/
+ }
+ break;
+
+ case OMX_CommandPortEnable :
+ OSAL_Info("In OMX_CommandPortEnable");
+ /*base is taking care of allocating all the resources*/
+ OMX_CHECK(((nParam == OMX_H264VE_OUTPUT_PORT) || (nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)),
+ OMX_ErrorBadParameter);
+ if((nParam == OMX_H264VE_INPUT_PORT) || (nParam == OMX_ALL)) {
+ if((pH264VEComp->bCodecCreate) & (pH264VEComp->bInputPortDisable) & (pH264VEComp->bCodecCreateSettingsChange)) {
+ /* Delete the old Codec Instance */
+ if( pH264VEComp->pVidEncHandle ) {
+ VIDENC2_delete(pH264VEComp->pVidEncHandle);
+ pH264VEComp->pVidEncHandle = NULL;
+ }
+
+ /* Create a New Codec Instance */
+ eError = OMXH264VE_SetEncCodecReady(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ } /*end if codec create*/
+ /*Reset the port disable flag */
+ pH264VEComp->bInputPortDisable = OMX_FALSE;
+ } /*end if(i/p or ALL )*/
+ if( nParam == OMX_H264VE_OUTPUT_PORT ) {
+ /*do nothing*/
+ }
+ break;
+
+ default :
+ OSAL_Info("In Default");
+ eError = OMX_ErrorBadParameter;
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ break;
+ }
+
+ /* Note: Notify this completion to the Base comp via ReturnEventNotify call */
+ OSAL_Info("Notify Base via ReturnEventNotify ");
+ eError = pH264VEComp->sBase.fpReturnEventNotify(hComponent, OMX_EventCmdComplete, Cmd, nParam, NULL);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+EXIT:
+
+ return (eError);
+}
+
+
+static OMX_ERRORTYPE OMXH264VE_DataNotify(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pComp = NULL;
+ OMX_BUFFERHEADERTYPE *pOutBufHeader = NULL;
+ OMX_U32 nInMsgCount = 0, nOutMsgCount = 0, i, j;
+ XDAS_Int32 retval = 0;
+ OMX_STATETYPE tCurState;
+ PARAMS_UPDATE_STATUS bLCallxDMSetParams;
+ OMX_BOOL bLEOS=OMX_FALSE;
+ OMX_BOOL bLCodecFlush=OMX_FALSE;
+ OMX_S32 InBufferHdrIndex = -1;
+ OMX_U32 LCodecLockedBufferCount = 0;
+ OMX_BOOL bLCallCodecProcess = OMX_FALSE;
+ OMXBase_CodecConfigBuf AttrParams;
+ OMX_BOOL bLSendCodecConfig;
+ void *srcPtr = NULL, *dstPtr = NULL;
+ OMX_U32 step, stride;
+
+ /* Check the input parameters */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pComp = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate;
+
+ /* Strat buffer processing only when the comp is in Executing state and the Port are Enabled*/
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ tCurState = pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ if((tCurState == OMX_StateExecuting) && (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bEnabled)
+ && (pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bEnabled)) {
+
+ eError = pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount);
+ OMX_CHECK(((eError == OMX_ErrorNone) || (eError == OMX_TI_WarningEosReceived)), OMX_ErrorInsufficientResources);
+
+ eError = pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources);
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ bLSendCodecConfig = pH264VEComp->bSendCodecConfig;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ if( bLSendCodecConfig ) {
+ if((nOutMsgCount > 0) && (nInMsgCount > 0)) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ bLCallxDMSetParams=pH264VEComp->bCallxDMSetParams;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) {
+ eError = OMXH264VE_SetDynamicParamsToCodec(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+ /* Update the OutBuf details before the Codec Process call */
+ pH264VEComp->pVedEncOutBufs->descs[0].memType = XDM_MEMTYPE_RAW;
+ pH264VEComp->pVedEncOutBufs->descs[0].buf = (XDAS_Int8 *)(pH264VEComp->sCodecConfigData.sBuffer);
+ pH264VEComp->pVedEncOutBufs->descs[0].bufSize.bytes = SPS_PPS_HEADER_DATA_SIZE;
+
+ /* Update the InBuf details before the Codec Process call */
+ for( i = 0; i < pH264VEComp->pVedEncInBufs->numPlanes; i++ ) {
+ pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)(pH264VEComp->pTempBuffer[i]);
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW;
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes =
+ (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes);
+ }
+
+ /* Update the InArgs details before the Codec Process call */
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.size = sizeof(IVIDENC2_InArgs);
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.control=IVIDENC2_CTRL_NONE;
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = 1000; /*to overcome the limitation inside the Codec- codec checks for NULL*/
+
+ /* Update the OutArgs details before the Codec Process call */
+ pH264VEComp->pVidEncOutArgs->videnc2OutArgs.size = sizeof(IVIDENC2_OutArgs);
+
+ /* Call the Codec Process call */
+ eError = OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(hComponent, &retval);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+ ALOGE("BytesGenerated=%d", pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated);
+ ALOGE("freed ID=%d", pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]);
+
+ /* Send the Condec Config Data to the Client */
+ AttrParams.sBuffer = pH264VEComp->sCodecConfigData.sBuffer;
+ AttrParams.sBuffer->size = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated;
+ pH264VEComp->sBase.pPvtData->fpDioControl(pComp, OMX_H264VE_OUTPUT_PORT, OMX_DIO_CtrlCmd_SetCtrlAttribute, &AttrParams);
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_ENCODE_AU;
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bSendCodecConfig =OMX_FALSE;
+ pH264VEComp->nCodecConfigSize = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated;
+ pH264VEComp->bAfterGenHeader = OMX_TRUE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ } else {
+ goto EXIT;
+ }
+ }
+
+ /* check for both input and output */
+ eError=pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount);
+ OMX_CHECK(((eError == OMX_ErrorNone) || (eError == OMX_TI_WarningEosReceived)), OMX_ErrorInsufficientResources);
+
+ eError=pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount);
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources);
+
+ /* if both are ready-> process data */
+ while(((nInMsgCount > 0) && (nOutMsgCount > 0)) || ((pH264VEComp->bAfterEOSReception) && (nOutMsgCount > 0))) {
+ /*dequeue the output buffer*/
+ eError = pH264VEComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR*)(&pOutBufHeader));
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources);
+ ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_CODEC;
+
+ /*branch the control flow based on the Before EOS /After EOS processing*/
+ if( !pH264VEComp->bAfterEOSReception ) {
+ OSAL_Info("Before EOS reception Case");
+ /*get the free bufhdr from the inputbufhdrarray*/
+ eError = OMXH264VE_GetNextFreeBufHdr(pComp, &InBufferHdrIndex, OMX_H264VE_INPUT_PORT);
+ OMX_CHECK(((InBufferHdrIndex != -1) && (eError == OMX_ErrorNone)), OMX_ErrorInsufficientResources);
+
+ /*dequeue the input buffer*/
+ eError = pH264VEComp->sBase.pPvtData->fpDioDequeue(hComponent, OMX_H264VE_INPUT_PORT,
+ (OMX_PTR*)&(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]));
+ OMX_CHECK((eError == OMX_ErrorNone), OMX_ErrorInsufficientResources);
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->bufSt = OWNED_BY_CODEC;
+
+ if((pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])->nFlags & OMX_BUFFERFLAG_EOS ) {
+ bLEOS = OMX_TRUE;
+ pH264VEComp->bPropagateEOSToOutputBuffer = OMX_TRUE;
+ bLCodecFlush = OMX_TRUE;
+ }
+
+ if(((pH264VEComp->pCodecInBufferArray[InBufferHdrIndex])->nFilledLen) == 0 ) {
+ /*update the buffer status to free & return the buffer to the client*/
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->bufSt = OWNED_BY_US;
+
+ pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT,
+ (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]));
+
+ ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US;
+
+ pH264VEComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader);
+ if( bLEOS ) {
+ bLCallCodecProcess = OMX_FALSE;
+ } else {
+ OSAL_ErrorTrace("++++++++Input Buffer Sent with no DATA & no EOS flag++++++++++++");
+ goto CHECKCOUNT;
+ }
+ } else {
+ /* Update the Input buffer details before the Codec Process call */
+ for( i = 0; i < pH264VEComp->pVedEncInBufs->numPlanes; i++ ) {
+ if( i == 0 ) {
+#ifdef ENCODE_RAM_BUFFERS
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0].offset = (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0]);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW;
+
+ pH264VEComp->pVedEncInBufs->imagePitch[0] = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth;
+#else
+ if (pH264VEComp->bInputMetaDataBufferMode) {
+ OMX_U32 *pTempBuffer;
+ OMX_U32 nMetadataBufferType;
+ IMG_native_handle_t* pGrallocHandle=NULL;
+ pTempBuffer = (OMX_U32 *) (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pBuffer);
+ nMetadataBufferType = *pTempBuffer;
+ if(nMetadataBufferType == kMetadataBufferTypeGrallocSource){
+ buffer_handle_t tBufHandle;
+ pTempBuffer++;
+ tBufHandle = *((buffer_handle_t *)pTempBuffer);
+ pGrallocHandle = (IMG_native_handle_t*) tBufHandle;
+ if (pGrallocHandle->iFormat != HAL_PIXEL_FORMAT_TI_NV12) {
+ if (pH264VEComp->pBackupBuffers == NULL) {
+ /* Open gralloc allocator and allocate the backup buffers */
+ gralloc_open(pH264VEComp->hCC, &(pH264VEComp->mAllocDev));
+ OMX_CHECK(pH264VEComp->mAllocDev != NULL, OMX_ErrorInsufficientResources);
+
+ pH264VEComp->pBackupBuffers = (IMG_native_handle_t **)OSAL_Malloc(sizeof(IMG_native_handle_t*) *
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual);
+ OMX_CHECK(pH264VEComp->pBackupBuffers != NULL, OMX_ErrorInsufficientResources);
+
+ for (j = 0; j < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; j++ ) {
+ pH264VEComp->pBackupBuffers[j] = NULL;
+ int err = pH264VEComp->mAllocDev->alloc(pH264VEComp->mAllocDev,
+ (int) pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
+ (int) pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
+ (int) HAL_PIXEL_FORMAT_TI_NV12, (int) GRALLOC_USAGE_HW_RENDER,
+ (const struct native_handle_t * *)(&(pH264VEComp->pBackupBuffers[j])), (int *) &stride);
+ OMX_CHECK(err == 0, err);
+
+ //Get the DMA BUFF_FDs from the gralloc pointers
+ pH264VEComp->pCodecInBufferBackupArray[j].sMemHdr[0].dma_buf_fd = (OMX_U32)((pH264VEComp->pBackupBuffers[j])->fd[0]);
+ pH264VEComp->pCodecInBufferBackupArray[j].sMemHdr[1].dma_buf_fd = (OMX_U32)((pH264VEComp->pBackupBuffers[j])->fd[1]);
+ }
+ }
+
+ /* Invoke color conversion routine here */
+ COLORCONVERT_PlatformOpaqueToNV12(pH264VEComp->hCC, (void **) &pGrallocHandle,
+ (void **) &pH264VEComp->pBackupBuffers[InBufferHdrIndex],
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight,
+ 4096, COLORCONVERT_BUFTYPE_GRALLOCOPAQUE,
+ COLORCONVERT_BUFTYPE_GRALLOCOPAQUE );
+ } else {
+ pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[0].dma_buf_fd = (OMX_U32)(pGrallocHandle->fd[0]);
+ pH264VEComp->pCodecInBufferBackupArray[i].sMemHdr[1].dma_buf_fd = (OMX_U32)(pGrallocHandle->fd[1]);
+ }
+ }
+ } else {
+ srcPtr = ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0].ptr;
+ dstPtr = pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].ptr;
+ step = 4096;
+ for (j = 0; j < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight;
+ j++) {
+ memcpy(dstPtr + j * step,
+ srcPtr + j * pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth);
+ }
+ }
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILED8;
+
+ pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0].offset =
+ (pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->nOffset);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].buf =
+ (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[0]);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.tileMem.width =
+ (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.tileMem.height =
+ (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight);
+
+ pH264VEComp->pVedEncInBufs->imagePitch[0] = 4096;
+#endif
+ } else if( i == 1 ) {
+#ifdef ENCODE_RAM_BUFFERS
+ memcpy(&((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1], &((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0], sizeof(MemHeader));
+
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1].offset = ((pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight));
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[1]);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth) * (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight) / 2;
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW;
+
+ pH264VEComp->pVedEncInBufs->imagePitch[1] = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth;
+
+#else
+ if (pH264VEComp->bInputMetaDataBufferMode) {
+ //Nothing to be done; color conversion and fd xlation is done during the plane0 processing
+ } else {
+ srcPtr =((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[InBufferHdrIndex]->pPlatformPrivate))->sMemHdr[0].ptr;
+ dstPtr = pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1].ptr;
+ for (j = 0; j < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight / 2; j++) {
+ memcpy(dstPtr + j * step,
+ srcPtr + (j + pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight) * pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth,
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth);
+ }
+ }
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_TILED16;
+
+ pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1].offset = 0;
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].buf =
+ (XDAS_Int8 *)&(pH264VEComp->pCodecInBufferBackupArray[InBufferHdrIndex].sMemHdr[1]);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.tileMem.width =
+ (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth);
+
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.tileMem.height =
+ (pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight/ 2);
+
+ pH264VEComp->pVedEncInBufs->imagePitch[1] = 4096;
+#endif
+ } else {
+ eError = OMX_ErrorUnsupportedSetting;
+ OSAL_ErrorTrace("only NV12 is supproted currently; wrong param from Codec");
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ }
+ bLCallCodecProcess=OMX_TRUE;
+ }
+ } else {
+ OSAL_Info("After EOS reception Case");
+ eError = OMXH264VE_GetNumCodecLockedBuffers(pComp, &LCodecLockedBufferCount);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ if( LCodecLockedBufferCount > 0 ) {
+ /*After EOS reception No need to provide Input for the Process, hence passing tempbuffers*/
+ for( i = 0; i < pH264VEComp->pVedEncInBufs->numPlanes; i++ ) {
+ pH264VEComp->pVedEncInBufs->planeDesc[i].buf = (XDAS_Int8 *)(pH264VEComp->pTempBuffer[i]);
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW;
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes =
+ (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes);
+ }
+ bLCallCodecProcess=OMX_TRUE;
+ } else {
+ /*Update the OutBufHeader*/
+ pOutBufHeader->nOffset = 0;
+ pOutBufHeader->nFilledLen = 0;
+ pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
+ pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader);
+ pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE;
+ /*notify the EOSEvent to the client*/
+ pH264VEComp->bNotifyEOSEventToClient = OMX_TRUE;
+ bLCallCodecProcess = OMX_FALSE;
+ }
+ }
+ if( bLCallCodecProcess ) {
+ if( !pH264VEComp->bAfterEOSReception ) {
+ OSAL_Info("update the Dynamic params before Process");
+ /* Call to xDM Set Params depending on the pH264VEComp->bCallxDMSetParams flag status before the process call */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ bLCallxDMSetParams = pH264VEComp->bCallxDMSetParams;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ if( bLCallxDMSetParams == PARAMS_UPDATED_AT_OMX ) {
+ eError = OMXH264VE_SetDynamicParamsToCodec(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ }
+ /* Update the Output buffer details before the Codec Process call */
+ OSAL_Info("Update the Output buffer details before the Codec Process call");
+ /*Note: this implementation assumes
+ a) output buffer is always 1D
+ b) if in case of multiple output buffers that need to given to codec for each process call
+ they are allocated in contiguous memory
+ */
+ if( pH264VEComp->pVedEncOutBufs->numBufs != 1 ) {
+ eError = OMX_ErrorUnsupportedSetting;
+ OSAL_ErrorTrace("Encoder Output Buffer is assigned as 2D Buffer");
+ goto EXIT;
+ }
+
+ pH264VEComp->pVedEncOutBufs->descs[0].buf =
+ (XDAS_Int8 *)&(((OMXBase_BufHdrPvtData*)pOutBufHeader->pPlatformPrivate)->sMemHdr[0]);
+
+ pH264VEComp->pVedEncOutBufs->descs[0].bufSize.bytes = pOutBufHeader->nAllocLen;
+
+ /* Update the InArgs details before the Codec Process call */
+ OSAL_Info("Update the InArgs before the Codec Process call");
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.size = sizeof(IH264ENC_InArgs);
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.control = IVIDENC2_CTRL_NONE;
+
+ if( !pH264VEComp->bAfterEOSReception ) {
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = InBufferHdrIndex + 1;
+ /*Zero is not a valid input so increasing the bufferIndex value by 1*/
+ } else {
+ pH264VEComp->pVidEncInArgs->videnc2InArgs.inputID = 0; /*Zero is not a valid input */
+ }
+
+ pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] = 0;
+ /* Update the OutArgs details before the Codec Process call */
+ OSAL_Info("Update the OutArgs before the Codec Process call");
+ pH264VEComp->pVidEncOutArgs->videnc2OutArgs.size = sizeof(IVIDENC2_OutArgs);
+
+ /* Codec Process call */
+ eError = OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(hComponent, &retval);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+ /* Send the input & corresponding output buffers Back to the Client when the codec frees */
+ /*Note: implementation is based on
+ a) after every process, there will be at max one input buffer that can be freed
+ b)for every input buffer that is freed ......there will be corresponding o/p buffer
+ */
+ if( pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]) {
+ /*Non Zero ID : valid free buffer ID*/
+ OSAL_Info("Codec freed input buffer with ID =%d", pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0]);
+
+ /* Propagate the Time Stamps from input to Corresponding Output */
+ OSAL_Info("Propagate the timestamp");
+ pOutBufHeader->nTimeStamp =
+ (pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)])->nTimeStamp;
+
+ /* Send the input buffers Back to the Client */
+ pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]->nFilledLen = 0;
+ /*Completely Consumed*/
+ pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]->nOffset = 0;
+
+ ((OMXBase_BufHdrPvtData *)((pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)])->pPlatformPrivate))->bufSt = OWNED_BY_US;
+
+ pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT,
+ pH264VEComp->pCodecInBufferArray[(pH264VEComp->pVidEncOutArgs->videnc2OutArgs.freeBufID[0] - 1)]);
+
+
+ /*check for the EOS */
+ if( pH264VEComp->bPropagateEOSToOutputBuffer ) {
+ /*Send the Output with EOS after sending all the previous buffers*/
+ eError = OMXH264VE_GetNumCodecLockedBuffers(pComp, &LCodecLockedBufferCount);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ if(LCodecLockedBufferCount == 0) {
+ /*No locked buffers*/
+ pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
+ pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE;
+ }
+ }
+
+ /* Check for IDR frame & update the Output BufferHdr Flags */
+ if(((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.encodedFrameType) == IVIDEO_IDR_FRAME) ||
+ ((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.encodedFrameType) == IVIDEO_I_FRAME)) {
+ pOutBufHeader->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
+ }
+
+ /* Send the output buffers Back to the Client */
+ OSAL_Info("Send the output buffers Back to the Client");
+ /*Update the OutBufHeader*/
+ if( pH264VEComp->bAfterGenHeader ) {
+ pOutBufHeader->nOffset = pH264VEComp->nCodecConfigSize;
+ pOutBufHeader->nFilledLen = ((pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated) -
+ (pH264VEComp->nCodecConfigSize));
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+ pH264VEComp->nCodecConfigSize = 0;
+ } else {
+ pOutBufHeader->nOffset = 0;
+ pOutBufHeader->nFilledLen = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated;
+ }
+ /* Return this output buffer to the Base comp via ReturnDataNotify call
+ * to communciate with the IL client incase of Non-Tunneling or tunneled
+ * component in case of tunneling*/
+ ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US;
+ pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader);
+ } else {
+ if( pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated == 0 ) {
+ /*free ID ==0 so no inputbuffer is freed & thus no o/p should be generated*/
+ OSAL_Info("codec locked the buffer so do the DIO_Cancel for the outputbuffer");
+ OSAL_Info("bytes generated is Zero & retain the output buffers via DIO_Cancel");
+ ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US;
+ pH264VEComp->sBase.pPvtData->fpDioCancel(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader);
+ } else {
+ if((!pH264VEComp->bAfterEOSReception) ||
+ ((pH264VEComp->pVidEncStaticParams->nalUnitControlParams.naluPresentMaskEndOfSequence) == 0x0)) {
+ OSAL_ErrorTrace("***********something gone wrong***********");
+ goto EXIT;
+ }
+ /* Send the output buffers Back to the Client */
+ OSAL_Info("Send the output buffers Back to the Client");
+ /*Update the OutBufHeader*/
+ pOutBufHeader->nOffset = 0;
+ pOutBufHeader->nFilledLen = pH264VEComp->pVidEncOutArgs->videnc2OutArgs.bytesGenerated;
+ pOutBufHeader->nFlags |= OMX_BUFFERFLAG_EOS;
+ pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE;
+ /*notify the EOSEvent to the client*/
+ pH264VEComp->bNotifyEOSEventToClient = OMX_TRUE;
+ /* Return this output buffer to the Base comp via ReturnDataNotify call
+ * to communciate with the IL client incase of Non-Tunneling or tunneled
+ * component in case of tunneling*/
+ ((OMXBase_BufHdrPvtData *)(pOutBufHeader->pPlatformPrivate))->bufSt = OWNED_BY_US;
+ pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_OUTPUT_PORT, pOutBufHeader);
+ }
+ }
+ }
+ /*Call to xDM_FLUSH when Input with EOS flag has been received*/
+ if( bLCodecFlush ) {
+ /*control call with command XDM_FLUSH*/
+ OSAL_Info("Call CodecFlush ");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_FLUSH,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval == VIDENC2_EFAIL ) {
+ OSAL_ErrorTrace("Got error from the CodecControl call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ /*Set the bCodecFlush to True ....no need to call codec flush during idle->Loaded Transition*/
+ pH264VEComp->bCodecFlush = OMX_TRUE;
+ bLEOS= OMX_FALSE;
+ bLCodecFlush = OMX_FALSE;
+ /* after EOS no need to provide extra input buffer */
+ pH264VEComp->bAfterEOSReception = OMX_TRUE;
+ }
+ if( pH264VEComp->bNotifyEOSEventToClient ) {
+ /* Reset the Codec : to continue with New stream w/o codec create */
+ if( pH264VEComp->bCodecCreate ) {
+ /*Codec Call: control call with command XDM_RESET*/
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_RESET,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval != VIDENC2_EOK ) {
+ OSAL_ErrorTrace("Got error from the Codec_RESET call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ /* Notify EOS event flag to the Base Component via ReturnEventNotify
+ * call , which communciates with the IL Client */
+ pH264VEComp->sBase.fpReturnEventNotify(hComponent, OMX_EventBufferFlag,
+ OMX_H264VE_OUTPUT_PORT,
+ OMX_BUFFERFLAG_EOS, NULL);
+ /*reset the flags*/
+ pH264VEComp->bAfterEOSReception = OMX_FALSE;
+ pH264VEComp->bNotifyEOSEventToClient = OMX_FALSE;
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bSendCodecConfig = OMX_TRUE;
+ pH264VEComp->bCallxDMSetParams = PARAMS_UPDATED_AT_OMX;
+ pH264VEComp->nCodecConfigSize = 0;
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ goto EXIT;
+ }
+
+CHECKCOUNT:
+ /*get the buffer count for the next loop execution*/
+ pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_INPUT_PORT, (OMX_PTR)&nInMsgCount);
+ pH264VEComp->sBase.pPvtData->fpDioGetCount(hComponent, OMX_H264VE_OUTPUT_PORT, (OMX_PTR)&nOutMsgCount);
+ ALOGE("Input Msg Count=%d, Output Msg Count=%d for the Next process loop", nInMsgCount, nOutMsgCount);
+ } /*end of process call loop*/
+ } else {
+ OSAL_WarningTrace("!!!!!!!!!!!Incorrect State operation/ ports need to be enabled!!!!!!!!");
+ }
+
+EXIT:
+
+ return (eError);
+
+}
+
+static OMX_ERRORTYPE OMXH264VE_ComponentDeinit(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pComp = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_U32 i;
+
+
+ /* Check the input parameters */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pComp = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate;
+
+ OMXBase_UtilCleanupIfError(hComponent);
+
+ /* Calling OMX Base Component Deinit */
+ OSAL_Info("Call BaseComponent Deinit");
+ eError = OMXBase_ComponentDeinit(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ /*Allocating memory for port properties before calling SetDefaultProperties*/
+ OSAL_Info("DeInitialize DerToBase.PortProperties");
+
+ pH264VEComp->bInputMetaDataBufferMode = OMX_FALSE;
+
+ /*Add CE deinit related stuff here*/
+ if( pH264VEComp->pCEhandle ) {
+ OSAL_Info("Call Engine_Close");
+ Engine_close(pH264VEComp->pCEhandle);
+ }
+
+ /* Free up the H264VE component's private area */
+ OSAL_Free(pH264VEComp->sBase.pAudioPortParams);
+ OSAL_Free(pH264VEComp->sBase.pVideoPortParams);
+ OSAL_Free(pH264VEComp->sBase.pImagePortParams);
+ OSAL_Free(pH264VEComp->sBase.pOtherPortParams);
+ memplugin_free_noheader(pH264VEComp->sCodecConfigData.sBuffer);
+ memplugin_free_noheader(pH264VEComp->pTempBuffer[0]);
+ memplugin_free_noheader(pH264VEComp->pTempBuffer[1]);
+
+ OSAL_Free(pH264VEComp);
+ pH264VEComp = NULL;
+
+EXIT:
+ OSAL_Info("At the End of Component DeInit");
+ return (eError);
+}
+
+
+OMX_ERRORTYPE OMXH264VE_GetExtensionIndex(OMX_HANDLETYPE hComponent,
+ OMX_STRING cParameterName,
+ OMX_INDEXTYPE *pIndexType)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pComp;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+
+ /* Check the input parameters */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+
+ pComp = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pComp->pComponentPrivate;
+
+ OMX_CHECK(pH264VEComp != NULL, OMX_ErrorBadParameter);
+
+ OMX_CHECK(cParameterName != NULL, OMX_ErrorBadParameter);
+ OMX_CHECK(pIndexType != NULL, OMX_ErrorBadParameter);
+ if( pH264VEComp->sBase.tCurState == OMX_StateInvalid ) {
+ eError = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+ if( strlen(cParameterName) > 127 ) {
+ //strlen does not include �\0� size, hence 127
+ eError = OMX_ErrorBadParameter;
+ goto EXIT;
+ }
+
+ if(strcmp(cParameterName, "OMX.google.android.index.storeMetaDataInBuffers") == 0) {
+ *pIndexType = (OMX_INDEXTYPE) OMX_TI_IndexEncoderReceiveMetadataBuffers;
+ goto EXIT;
+ }
+
+ eError = OMX_ErrorUnsupportedIndex;
+
+EXIT:
+ return (eError);
+}
+
+
+static OMX_ERRORTYPE OMXH264VE_ComponentTunnelRequest(OMX_HANDLETYPE hComponent,
+ OMX_U32 nPort,
+ OMX_HANDLETYPE hTunneledComp,
+ OMX_U32 nTunneledPort,
+ OMX_TUNNELSETUPTYPE *pTunnelSetup)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+
+ /* Check all the input parametrs */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+ OMX_CHECK((pH264VEComp != NULL), OMX_ErrorBadParameter);
+
+ eError = OMX_ErrorNotImplemented;
+ OSAL_ErrorTrace("in omx-h264e ComponentTunnelRequest :: enable input subframe processing first");
+ OMX_CHECK(OMX_ErrorNone == eError, eError);
+
+EXIT:
+ return (eError);
+}
+
+
diff --git a/omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c b/omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c
new file mode 100644
index 0000000..6dd6574
--- /dev/null
+++ b/omx/videoencode/omx_h264_enc/src/omx_H264videoencoderutils.c
@@ -0,0 +1,981 @@
+/*
+ * 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_H264videoencoder.h"
+
+#define LOG_TAG "OMX_H264_ENCODERUTILS"
+
+OMX_H264_LVL_BITRATE OMX_H264_BP_MP_BITRATE_SUPPORT[] =
+{
+ { OMX_VIDEO_AVCLevel1, 64000 },
+ { OMX_VIDEO_AVCLevel1b, 128000 },
+ { OMX_VIDEO_AVCLevel11, 192000 },
+ { OMX_VIDEO_AVCLevel12, 384000 },
+ { OMX_VIDEO_AVCLevel13, 768000 },
+ { OMX_VIDEO_AVCLevel2, 2000000 },
+ { OMX_VIDEO_AVCLevel21, 4000000 },
+ { OMX_VIDEO_AVCLevel22, 4000000 },
+ { OMX_VIDEO_AVCLevel3, 10000000 },
+ { OMX_VIDEO_AVCLevel31, 14000000 },
+ { OMX_VIDEO_AVCLevel32, 20000000 },
+ { OMX_VIDEO_AVCLevel4, 20000000 },
+ { OMX_VIDEO_AVCLevel41, 50000000 },
+ { OMX_VIDEO_AVCLevel42, 50000000 },
+ { OMX_VIDEO_AVCLevel5, 50000000 }, //according to the spec the bit rate supported is 135000000, here the 50mpbs limit is as per the current codec version
+ { OMX_VIDEO_AVCLevel51, 50000000 } //according to the spec the bit rate supported is 240000000, here the 50mpbs limit is as per the current codec version
+};
+
+OMX_H264_LVL_BITRATE OMX_H264_HP_BITRATE_SUPPORT[] =
+{
+ { OMX_VIDEO_AVCLevel1, 80000 },
+ { OMX_VIDEO_AVCLevel1b, 160000 },
+ { OMX_VIDEO_AVCLevel11, 240000 },
+ { OMX_VIDEO_AVCLevel12, 480000 },
+ { OMX_VIDEO_AVCLevel13, 960000 },
+ { OMX_VIDEO_AVCLevel2, 2500000 },
+ { OMX_VIDEO_AVCLevel21, 5000000 },
+ { OMX_VIDEO_AVCLevel22, 5000000 },
+ { OMX_VIDEO_AVCLevel3, 12500000 },
+ { OMX_VIDEO_AVCLevel31, 17500000 },
+ { OMX_VIDEO_AVCLevel32, 25000000 },
+ { OMX_VIDEO_AVCLevel4, 25000000 },
+ { OMX_VIDEO_AVCLevel41, 62500000 },
+ { OMX_VIDEO_AVCLevel42, 62500000 },
+ { OMX_VIDEO_AVCLevel5, 62500000 }, //according to the spec the bit rate supported is 168750000, here the 62.5mpbs limit is as per the current codec version
+ { OMX_VIDEO_AVCLevel51, 62500000 } //according to the spec the bit rate supported is 300000000, here the 62.5mpbs limit is as per the current codec version
+};
+
+OMX_ERRORTYPE OMXH264VE_InitFields(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+
+ OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError);
+
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+ pH264VEComp->sBase.cComponentName = OMX_H264VE_COMP_NAME;
+
+ /* Fill component's version, this may not be same as the OMX Specification version */
+ pH264VEComp->sBase.nComponentVersion.s.nVersionMajor = OMX_H264VE_COMP_VERSION_MAJOR;
+ pH264VEComp->sBase.nComponentVersion.s.nVersionMinor = OMX_H264VE_COMP_VERSION_MINOR;
+ pH264VEComp->sBase.nComponentVersion.s.nRevision = OMX_H264VE_COMP_VERSION_REVISION;
+ pH264VEComp->sBase.nComponentVersion.s.nStep = OMX_H264VE_COMP_VERSION_STEP;
+
+ /* Initialize Audio Port parameters */
+ OSAL_Info("Initialize Audio Port Params");
+ pH264VEComp->sBase.pAudioPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_CHECK(pH264VEComp->sBase.pAudioPortParams != NULL, OMX_ErrorInsufficientResources);
+
+ OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pAudioPortParams, OMX_PORT_PARAM_TYPE);
+ pH264VEComp->sBase.pAudioPortParams->nPorts = 0;
+ pH264VEComp->sBase.pAudioPortParams->nStartPortNumber = 0;
+
+ /* Initialize Video Port parameters */
+ OSAL_Info("Initialize Video Port Params");
+ pH264VEComp->sBase.pVideoPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_CHECK(pH264VEComp->sBase.pVideoPortParams != NULL, OMX_ErrorInsufficientResources);
+
+ OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pVideoPortParams, OMX_PORT_PARAM_TYPE);
+ pH264VEComp->sBase.pVideoPortParams->nPorts = OMX_H264VE_NUM_PORTS;
+ pH264VEComp->sBase.pVideoPortParams->nStartPortNumber = OMX_H264VE_DEFAULT_START_PORT_NUM;
+
+ /* Initialize Image Port parameters */
+ OSAL_Info("Initialize Image Port Params");
+ pH264VEComp->sBase.pImagePortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_CHECK(pH264VEComp->sBase.pImagePortParams != NULL, OMX_ErrorInsufficientResources);
+
+ OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pImagePortParams, OMX_PORT_PARAM_TYPE);
+ pH264VEComp->sBase.pImagePortParams->nPorts = 0;
+ pH264VEComp->sBase.pImagePortParams->nStartPortNumber = 0;
+
+ /* Initialize Other Port parameters */
+ OSAL_Info("Initialize Other Port Params");
+ pH264VEComp->sBase.pOtherPortParams = (OMX_PORT_PARAM_TYPE*)OSAL_Malloc(sizeof(OMX_PORT_PARAM_TYPE));
+ OMX_CHECK(pH264VEComp->sBase.pOtherPortParams != NULL, OMX_ErrorInsufficientResources);
+
+ OMX_BASE_INIT_STRUCT_PTR(pH264VEComp->sBase.pOtherPortParams, OMX_PORT_PARAM_TYPE);
+ pH264VEComp->sBase.pOtherPortParams->nPorts = 0;
+ pH264VEComp->sBase.pOtherPortParams->nStartPortNumber = 0;
+
+ /* Initialize the Total Number of Ports and Start Port Number*/
+ OSAL_Info("Initialize Component Port Params");
+ pH264VEComp->sBase.nNumPorts = OMX_H264VE_NUM_PORTS;
+ pH264VEComp->sBase.nMinStartPortIndex = OMX_H264VE_DEFAULT_START_PORT_NUM;
+
+ /* Overriding this value. Notify derived component only when data is available on all ports */
+ pH264VEComp->sBase.bNotifyForAnyPort = OMX_FALSE;
+
+ /* Allocate Memory for Static Parameter */
+ pH264VEComp->pVidEncStaticParams = (IH264ENC_Params *) memplugin_alloc(sizeof(IH264ENC_Params), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVidEncStaticParams != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVidEncStaticParams, 0x0, sizeof(IH264ENC_Params));
+
+ /* Allocate Memory for Dynamic Parameter */
+ pH264VEComp->pVidEncDynamicParams = (IH264ENC_DynamicParams *) memplugin_alloc(sizeof(IH264ENC_DynamicParams), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVidEncDynamicParams != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVidEncDynamicParams, 0x0, sizeof(IH264ENC_DynamicParams));
+
+ /* Allocate Memory for status Parameter */
+ pH264VEComp->pVidEncStatus = (IH264ENC_Status *) memplugin_alloc(sizeof(IH264ENC_Status), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVidEncStatus != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVidEncStatus, 0x0, sizeof(IH264ENC_Status));
+
+ /* Allocate Memory for InArgs Parameter */
+ pH264VEComp->pVidEncInArgs = (IH264ENC_InArgs *) memplugin_alloc(sizeof(IH264ENC_InArgs), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVidEncInArgs != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVidEncInArgs, 0x0, sizeof(IH264ENC_InArgs));
+
+ /* Allocate Memory for OutArgs Parameter */
+ pH264VEComp->pVidEncOutArgs = (IH264ENC_OutArgs *) memplugin_alloc(sizeof(IH264ENC_OutArgs), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVidEncOutArgs != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVidEncOutArgs, 0x0, sizeof(IH264ENC_OutArgs));
+
+ /* Allocate Memory for InDesc Parameter */
+ pH264VEComp->pVedEncInBufs = (IVIDEO2_BufDesc *) memplugin_alloc(sizeof(IVIDEO2_BufDesc), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVedEncInBufs != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVedEncInBufs, 0x0, sizeof(IVIDEO2_BufDesc));
+
+ /* Allocate Memory for OutDesc Parameter */
+ pH264VEComp->pVedEncOutBufs = (XDM2_BufDesc *) memplugin_alloc(sizeof(XDM2_BufDesc), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pVedEncOutBufs != NULL, OMX_ErrorInsufficientResources);
+ OSAL_Memset(pH264VEComp->pVedEncOutBufs, 0x0, sizeof(XDM2_BufDesc));
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace("in fn OMXH264VE_SesBaseParameters");
+ }
+
+ return (eError);
+
+ }
+
+
+OMX_ERRORTYPE OMXH264VE_InitialzeComponentPrivateParams(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_U32 i = 0;
+ OSAL_ERROR tStatus = OSAL_ErrNone;
+
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+
+ OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError);
+
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ OSAL_Info("Update the default Port Params");
+
+ /* Set the Port Definition (OMX_PARAM_PORTDEFINITIONTYPE) Values : INPUT PORT */
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nPortIndex = OMX_H264VE_INPUT_PORT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.eDir = OMX_DirInput;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual = OMX_H264VE_DEFAULT_INPUT_BUFFER_COUNT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountMin = OMX_H264VE_MIN_INPUT_BUFFER_COUNT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferSize = OMX_H264VE_DEFAULT_INPUT_BUFFER_SIZE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bEnabled = OMX_TRUE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bPopulated = OMX_FALSE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.eDomain = OMX_PortDomainVideo;
+ /*Update the Domain (Video) Specific values*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.cMIMEType = NULL;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.pNativeRender = NULL;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH; /*should be multiples of 16*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride = OMX_H264VE_DEFAULT_FRAME_WIDTH; /*setting the stride as atleaset equal to width (should be multiples of 16)*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nSliceHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; /*setting the sliceheight as equal to frame height*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nBitrate = OMX_H264VE_DEFAULT_BITRATE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.xFramerate = (OMX_H264VE_DEFAULT_FRAME_RATE << 16);
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.eColorFormat =OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.pNativeWindow = NULL;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.bBuffersContiguous=OMX_FALSE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferAlignment=32; /*H264 Encoder Codec has alignment restriction for input buffers */
+
+ /* Set the Port Definition (OMX_PARAM_PORTDEFINITIONTYPE)Values : OUTPUT PORT */
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nPortIndex = OMX_H264VE_OUTPUT_PORT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.eDir = OMX_DirOutput;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferCountActual = OMX_H264VE_DEFAULT_OUTPUT_BUFFER_COUNT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferCountMin = OMX_H264VE_MIN_OUTPUT_BUFFER_COUNT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferSize = OMX_H264VE_DEFAULT_OUTPUT_BUFFER_SIZE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bEnabled = OMX_TRUE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bPopulated = OMX_FALSE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.eDomain = OMX_PortDomainVideo;
+ /*Update the Domain (Video) Specific values*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.cMIMEType = NULL;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.pNativeRender = NULL;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameWidth = OMX_H264VE_DEFAULT_FRAME_WIDTH;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nFrameHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nStride = 0; //Stride is not used on port having bitstream buffers
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nSliceHeight = OMX_H264VE_DEFAULT_FRAME_HEIGHT; /*setting the sliceheight as equal frame height*/
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.nBitrate = OMX_H264VE_DEFAULT_BITRATE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.xFramerate = 0;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.bFlagErrorConcealment = OMX_FALSE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.eColorFormat = OMX_COLOR_FormatUnused;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.format.video.pNativeWindow = NULL;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.bBuffersContiguous=OMX_FALSE;
+ pH264VEComp->sBase.pPorts[OMX_H264VE_OUTPUT_PORT]->sPortDef.nBufferAlignment=0; /*No Alignment required for output buffers*/
+
+ OSAL_Info("SetH264AlgDefaultCreationParams ");
+ /* Set the Default IVIDENC2_Params: videnc2Params . Does not Adhere to Codec Defaults. Can be modified */
+ SET_H264CODEC_DEFAULT_IVIDENC2_PARAMS(pH264VEComp, i);
+ /* Adheres to Codec Defaults. To be modified only when codec default params change */
+ eError = OMXH264VE_SetAlgDefaultCreationParams(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting);
+
+ /*Overwrite some of the codec static defaults*/
+ OVERWRITE_H264CODEC_DEFAULT_STATIC_PARAMS(pH264VEComp);
+ pH264VEComp->pVidEncStaticParams->IDRFrameInterval = 1; /*All I frames are IDR frames*/
+
+ OSAL_Info("SetH264AlgDefaultDynamicParams ");
+ /* Set the IVIDENC2_DynamicParams videnc2DynamicParams */
+ SET_H264CODEC_DEFAULT_IVIDENC2_DYNAMICPARAMS(pH264VEComp);
+ eError = OMXH264VE_SetAlgDefaultDynamicParams(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting);
+
+ /*Overwrite some of the codec static defaults*/
+ OVERWRITE_H264CODEC_DEFAULT_DYNAMIC_PARAMS(pH264VEComp);
+ /*Enable 4 MV*/
+ ENABLE_4MV(pH264VEComp);
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+
+ pH264VEComp->bCodecCreate = OMX_FALSE; /*codec creation hasn't happened yet*/
+ pH264VEComp->bCodecCreateSettingsChange = OMX_FALSE; /*set to true when Create time settings are modified*/
+ pH264VEComp->bInputPortDisable = OMX_FALSE; /*flag to indicate codec creation is required or not */
+ pH264VEComp->bCodecFlush = OMX_FALSE;
+
+ pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE;
+ pH264VEComp->pCodecInBufferArray = NULL;
+ pH264VEComp->bAfterEOSReception = OMX_FALSE;
+ pH264VEComp->bNotifyEOSEventToClient = OMX_FALSE;
+ pH264VEComp->bPropagateEOSToOutputBuffer = OMX_FALSE;
+ pH264VEComp->bSetParamInputIsDone = OMX_FALSE;
+
+ pH264VEComp->bSendCodecConfig = OMX_TRUE;
+
+ pH264VEComp->sCodecConfigData.sBuffer = OSAL_Malloc(sizeof(MemHeader));
+ pH264VEComp->sCodecConfigData.sBuffer->ptr
+ = memplugin_alloc_noheader(pH264VEComp->sCodecConfigData.sBuffer, (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->sCodecConfigData.sBuffer->ptr != NULL, OMX_ErrorInsufficientResources);
+
+ tStatus = OSAL_Memset(pH264VEComp->sCodecConfigData.sBuffer->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE));
+ OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter);
+
+
+ pH264VEComp->pTempBuffer[0] = OSAL_Malloc(sizeof(MemHeader));
+ pH264VEComp->pTempBuffer[0]->ptr
+ = memplugin_alloc_noheader(pH264VEComp->pTempBuffer[0], (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pTempBuffer[0]->ptr != NULL, OMX_ErrorInsufficientResources);
+
+ tStatus = OSAL_Memset(pH264VEComp->pTempBuffer[0]->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE));
+ OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter);
+
+ pH264VEComp->pTempBuffer[1] = OSAL_Malloc(sizeof(MemHeader));
+ pH264VEComp->pTempBuffer[1]->ptr
+ = memplugin_alloc_noheader(pH264VEComp->pTempBuffer[1], (SPS_PPS_HEADER_DATA_SIZE), 1, MEM_CARVEOUT, 0, 0);
+ OMX_CHECK(pH264VEComp->pTempBuffer[1]->ptr != NULL, OMX_ErrorInsufficientResources);
+
+ tStatus = OSAL_Memset(pH264VEComp->pTempBuffer[1]->ptr, 0x0, (SPS_PPS_HEADER_DATA_SIZE));
+ OMX_CHECK(tStatus == OSAL_ErrNone, OMX_ErrorBadParameter);
+
+ pH264VEComp->nCodecConfigSize = 0;
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace(" in fn OMXH264VE_InitialzeComponentPrivateParams");
+ }
+
+ return (eError);
+
+}
+
+OMX_ERRORTYPE OMXH264VE_SetAlgDefaultCreationParams(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError);
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /* Set the Default IH264ENC_RateControlParams: rateControlParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_RATECONTROLPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_InterCodingParams interCodingParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTERCODINGPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_IntraCodingParams intraCodingParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_INTRACODINGPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_NALUControlParams nalUnitControlParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_NALUCONTROLPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_SliceCodingParams sliceCodingParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SLICECODINGPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_LoopFilterParams loopFilterParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_LOOPFILTERPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_FMOCodingParams fmoCodingParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_FMOCODINGPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_VUICodingParams vuiCodingParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_VUICODINGPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_StereoInfoParams stereoInfoParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOINFOPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_FramePackingSEIParams framePackingSEIParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_STEREOFRAMEPACKINGPARAMS(pH264VEComp);
+
+ /* Set the Default IH264ENC_SVCCodingParams svcCodingParams */
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_SVCCODINGPARAMS(pH264VEComp);
+
+ SET_H264CODEC_DEFAULT_STATIC_IH264ENC_EXTENDEDPARAMS(pH264VEComp);
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace("in fn OMXH264VE_SetAlgDefaultCreationParams");
+ }
+
+ return (eError);
+}
+
+OMX_ERRORTYPE OMXH264VE_SetAlgDefaultDynamicParams(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError);
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /* Set the IH264ENC_RateControlParams rateControlParams */
+ SET_H264CODEC_DEFAULT_DYNAMIC_RATECONTROLPARAMS(pH264VEComp);
+
+ /* Set the IH264ENC_InterCodingParams interCodingParams */
+ SET_H264CODEC_DEFAULT_DYNAMIC_INTERCODINGPARAMS(pH264VEComp);
+
+ /* Set the IH264ENC_IntraCodingParams interCodingParams */
+ SET_H264CODEC_DEFAULT_DYNAMIC_INTRACODINGPARAMS(pH264VEComp);
+
+ /* Set the IH264ENC_SliceCodingParams sliceCodingParams */
+ SET_H264CODEC_DEFAULT_DYNAMIC_SLICECODINGPARAMS(pH264VEComp);
+
+ SET_H264CODEC_DEFAULT_DYNAMIC_IH264_EXTENDEDPARAMS(pH264VEComp);
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace(" in fn OMXH264VE_SetAlgDefaultDynamicParams");
+ }
+ return (eError);
+}
+
+
+OMX_ERRORTYPE OMXH264VE_SetBufferDesc(OMX_HANDLETYPE hComponent, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_U8 i;
+ OMX_U32 extWidth, extHeight, extStride;
+
+ /* Check the input parameters, this should be TRUE else report an Error */
+ OMX_CHECK(hComponent != NULL, OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+
+ OMX_BASE_CHK_VERSION(pHandle, OMX_COMPONENTTYPE, eError);
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ if( nPortIndex == OMX_H264VE_INPUT_PORT ) {
+ pH264VEComp->pVedEncInBufs->numPlanes = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minNumInBufs;
+ for( i=0; i < pH264VEComp->pVedEncInBufs->numPlanes; i++ ) {
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.inBufMemoryType[i];
+ if( pH264VEComp->pVedEncInBufs->planeDesc[i].memType == XDM_MEMTYPE_RAW ) {
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes =
+ pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].bytes;
+ } else {
+ /* Since we support non-tiler input buffers for encoding, change the memtype */
+ pH264VEComp->pVedEncInBufs->planeDesc[i].memType = XDM_MEMTYPE_RAW;
+ pH264VEComp->pVedEncInBufs->planeDesc[i].bufSize.bytes = (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].tileMem.width) * (pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minInBufSize[i].tileMem.height);
+ }
+ }
+
+ OSAL_Info("Update the Image,Active region of Codec params");
+ extWidth = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameWidth; /*stride is already checked during codec creation that it should be multiples of 16*/
+ extStride = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nStride;
+ extHeight = pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.format.video.nFrameHeight;
+
+ pH264VEComp->pVedEncInBufs->imageRegion.topLeft.x = 0;
+ pH264VEComp->pVedEncInBufs->imageRegion.topLeft.y = 0;
+ pH264VEComp->pVedEncInBufs->imageRegion.bottomRight.x = extWidth;
+
+ pH264VEComp->pVedEncInBufs->activeFrameRegion.topLeft.x = 0;
+ pH264VEComp->pVedEncInBufs->activeFrameRegion.topLeft.y = 0;
+ pH264VEComp->pVedEncInBufs->activeFrameRegion.bottomRight.x = extWidth;
+
+ pH264VEComp->pVedEncInBufs->imagePitch[0] = extStride;
+ pH264VEComp->pVedEncInBufs->imagePitch[1] = extStride;
+ pH264VEComp->pVedEncInBufs->topFieldFirstFlag = OMX_TRUE;
+
+ pH264VEComp->pVedEncInBufs->contentType = IVIDEO_PROGRESSIVE;
+ pH264VEComp->pVedEncInBufs->activeFrameRegion.bottomRight.y = extHeight;
+ pH264VEComp->pVedEncInBufs->imageRegion.bottomRight.y = extHeight;
+
+ pH264VEComp->pVedEncInBufs->secondFieldOffsetWidth[0] = 0;
+ pH264VEComp->pVedEncInBufs->secondFieldOffsetWidth[1] = 0;
+ pH264VEComp->pVedEncInBufs->secondFieldOffsetHeight[0] = 0;
+ pH264VEComp->pVedEncInBufs->secondFieldOffsetHeight[1] = 0;
+ pH264VEComp->pVedEncInBufs->chromaFormat = XDM_YUV_420SP;
+
+ } else if( nPortIndex == OMX_H264VE_OUTPUT_PORT ) {
+ pH264VEComp->pVedEncOutBufs->numBufs = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minNumOutBufs;
+ for( i=0; i < pH264VEComp->pVedEncOutBufs->numBufs; i++ ) {
+ pH264VEComp->pVedEncOutBufs->descs[i].memType = pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.outBufMemoryType[i];
+ if( pH264VEComp->pVedEncOutBufs->descs[i].memType == XDM_MEMTYPE_RAW ) {
+ pH264VEComp->pVedEncOutBufs->descs[i].bufSize.bytes =
+ pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minOutBufSize[i].bytes;
+ } else {
+ /* since the output buffers are always non-tiled, change the memory type & size to RAW memory type*/
+ pH264VEComp->pVedEncOutBufs->descs[i].memType = XDM_MEMTYPE_RAW;
+ pH264VEComp->pVedEncOutBufs->descs[i].bufSize.bytes =
+ pH264VEComp->pVidEncStatus->videnc2Status.bufInfo.minOutBufSize[i].bytes;
+ }
+ }
+ } else {
+ eError=OMX_ErrorBadPortIndex;
+ }
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace("in fn OMXH264VE_SetBufferDesc");
+ }
+
+ return (eError);
+
+}
+
+OMX_ERRORTYPE OMXH264VE_SetEncCodecReady(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ XDAS_Int32 retval = 0;
+
+ /* Check the input parameters */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ /*set the HRD buffer size appropriately*/
+ if( pH264VEComp->pVidEncStaticParams->rateControlParams.rcAlgo == IH264_RATECONTROL_PRC_LOW_DELAY ) {
+ pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2;
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate) / 2;
+ } else {
+ pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate);
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.HRDBufferSize =
+ (pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.targetBitRate);
+ }
+ pH264VEComp->pVidEncStaticParams->rateControlParams.initialBufferLevel =
+ pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize;
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.initialBufferLevel =
+ pH264VEComp->pVidEncStaticParams->rateControlParams.HRDBufferSize;
+ pH264VEComp->pVidEncStaticParams->rateControlParams.rateControlParamsPreset = IH264_RATECONTROLPARAMS_USERDEFINED;
+
+ if( pH264VEComp->pVidEncStaticParams->videnc2Params.maxHeight & 0x01 ) {
+ eError = OMX_ErrorUnsupportedSetting;
+ OSAL_ErrorTrace("Incorrect Height Settings");
+ OSAL_ErrorTrace("for Progressive Port Def Height need be multiple of 2");
+ OSAL_ErrorTrace("for Interlace Port Def Height need be multiple of 4");
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+
+ /* Create H264 Encoder Instance */
+ pH264VEComp->pVidEncHandle = VIDENC2_create(pH264VEComp->pCEhandle,
+ OMX_H264V_ENCODER_NAME,
+ (VIDENC2_Params *)(pH264VEComp->pVidEncStaticParams));
+
+ OMX_CHECK(pH264VEComp->pVidEncHandle != NULL, OMX_ErrorInsufficientResources);
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCodecCreate=OMX_TRUE;
+ pH264VEComp->bCodecCreateSettingsChange=OMX_FALSE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ /* Set the Dynamic Parameters to the Codec */
+ eError = OMXH264VE_SetDynamicParamsToCodec(hComponent);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+ /* Get the Codec Status Parametrs and Update the Component private Params accordingly */
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_GETSTATUS,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval == VIDENC2_EFAIL ) {
+ OSAL_Info("Got error from the Codec GetbufInfo call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+ eError= OMXH264VE_UpdateParams(pHandle);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ /* get bufffer information:
+ * control->XDM_GETBUFINFO call always has to ensure the control->XDM_SETPARAMS call has done before
+ * Get the Buf Info from the Codec */
+ OSAL_Info("call to xDM GetBufInfo");
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_GETBUFINFO,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval == VIDENC2_EFAIL ) {
+ OSAL_Info("Got error from the Codec GetbufInfo call");
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ /* Initialize the Inputbufs and Outputbufs with the values that Codec Expects */
+ eError=OMXH264VE_SetBufferDesc(pHandle, OMX_H264VE_INPUT_PORT);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+ eError=OMXH264VE_SetBufferDesc(pHandle, OMX_H264VE_OUTPUT_PORT);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace("in fn OMXH264VE_SetEncCodecReady");
+ }
+
+ return (eError);
+
+}
+
+OMX_ERRORTYPE OMXH264VE_UpdateParams(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_STATETYPE tState;
+
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ OSAL_Info("Update the OMX Component structures with Codec Structures");
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.encodingPreset = pH264VEComp->pVidEncStatus->videnc2Status.encodingPreset;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.rateControlPreset = pH264VEComp->pVidEncStatus->videnc2Status.rateControlPreset;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.maxInterFrameInterval = pH264VEComp->pVidEncStatus->videnc2Status.maxInterFrameInterval;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.inputChromaFormat = pH264VEComp->pVidEncStatus->videnc2Status.inputChromaFormat;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.inputContentType = pH264VEComp->pVidEncStatus->videnc2Status.inputContentType;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.operatingMode = pH264VEComp->pVidEncStatus->videnc2Status.operatingMode;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.profile = pH264VEComp->pVidEncStatus->videnc2Status.profile;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.level = pH264VEComp->pVidEncStatus->videnc2Status.level;
+
+ pH264VEComp->pVidEncStaticParams->videnc2Params.inputDataMode = pH264VEComp->pVidEncStatus->videnc2Status.inputDataMode;
+ pH264VEComp->pVidEncStaticParams->videnc2Params.outputDataMode = pH264VEComp->pVidEncStatus->videnc2Status.outputDataMode;
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams), &(pH264VEComp->pVidEncStatus->videnc2Status.encDynamicParams),
+ sizeof (IVIDENC2_DynamicParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->rateControlParams), &(pH264VEComp->pVidEncStatus->rateControlParams),
+ sizeof (IH264ENC_RateControlParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->interCodingParams), &(pH264VEComp->pVidEncStatus->interCodingParams),
+ sizeof (IH264ENC_InterCodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->intraCodingParams), &(pH264VEComp->pVidEncStatus->intraCodingParams),
+ sizeof (IH264ENC_IntraCodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->nalUnitControlParams), &(pH264VEComp->pVidEncStatus->nalUnitControlParams),
+ sizeof (IH264ENC_NALUControlParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncDynamicParams->sliceCodingParams), &(pH264VEComp->pVidEncStatus->sliceCodingParams),
+ sizeof (IH264ENC_SliceCodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->loopFilterParams), &(pH264VEComp->pVidEncStatus->loopFilterParams),
+ sizeof (IH264ENC_LoopFilterParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->fmoCodingParams), &(pH264VEComp->pVidEncStatus->fmoCodingParams),
+ sizeof (IH264ENC_FMOCodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->vuiCodingParams), &(pH264VEComp->pVidEncStatus->vuiCodingParams),
+ sizeof (IH264ENC_VUICodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->stereoInfoParams), &(pH264VEComp->pVidEncStatus->stereoInfoParams),
+ sizeof (IH264ENC_StereoInfoParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->framePackingSEIParams), &(pH264VEComp->pVidEncStatus->framePackingSEIParams),
+ sizeof (IH264ENC_FramePackingSEIParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->svcCodingParams), &(pH264VEComp->pVidEncStatus->svcCodingParams),
+ sizeof (IH264ENC_SVCCodingParams));
+
+ pH264VEComp->pVidEncStaticParams->interlaceCodingType = pH264VEComp->pVidEncStatus->interlaceCodingType;
+
+ pH264VEComp->pVidEncStaticParams->bottomFieldIntra = pH264VEComp->pVidEncStatus->bottomFieldIntra;
+
+ pH264VEComp->pVidEncStaticParams->gopStructure = pH264VEComp->pVidEncStatus->gopStructure;
+
+ pH264VEComp->pVidEncStaticParams->entropyCodingMode = pH264VEComp->pVidEncStatus->entropyCodingMode;
+
+ pH264VEComp->pVidEncStaticParams->transformBlockSize =pH264VEComp->pVidEncStatus->transformBlockSize;
+
+ pH264VEComp->pVidEncStaticParams->log2MaxFNumMinus4 = pH264VEComp->pVidEncStatus->log2MaxFNumMinus4;
+
+ pH264VEComp->pVidEncStaticParams->picOrderCountType = pH264VEComp->pVidEncStatus->picOrderCountType;
+
+ pH264VEComp->pVidEncStaticParams->enableWatermark = pH264VEComp->pVidEncStatus->enableWatermark;
+
+ pH264VEComp->pVidEncStaticParams->IDRFrameInterval =pH264VEComp->pVidEncStatus->IDRFrameInterval;
+
+ pH264VEComp->pVidEncStaticParams->maxIntraFrameInterval =pH264VEComp->pVidEncStatus->maxIntraFrameInterval;
+
+ pH264VEComp->pVidEncStaticParams->debugTraceLevel = pH264VEComp->pVidEncStatus->debugTraceLevel;
+
+ pH264VEComp->pVidEncStaticParams->lastNFramesToLog = pH264VEComp->pVidEncStatus->lastNFramesToLog;
+
+ pH264VEComp->pVidEncStaticParams->enableAnalyticinfo =pH264VEComp->pVidEncStatus->enableAnalyticinfo;
+
+ pH264VEComp->pVidEncStaticParams->enableGMVSei =pH264VEComp->pVidEncStatus->enableGMVSei;
+
+ pH264VEComp->pVidEncStaticParams->constraintSetFlags =pH264VEComp->pVidEncStatus->constraintSetFlags;
+
+ pH264VEComp->pVidEncStaticParams->enableRCDO =pH264VEComp->pVidEncStatus->enableRCDO;
+
+ pH264VEComp->pVidEncStaticParams->enableLongTermRefFrame =pH264VEComp->pVidEncStatus->enableLongTermRefFrame;
+
+ pH264VEComp->pVidEncStaticParams->LTRPPeriod =pH264VEComp->pVidEncStatus->LTRPPeriod;
+
+ pH264VEComp->pVidEncStaticParams->numTemporalLayer =pH264VEComp->pVidEncStatus->numTemporalLayer;
+
+ pH264VEComp->pVidEncStaticParams->referencePicMarking =pH264VEComp->pVidEncStatus->referencePicMarking;
+
+ pH264VEComp->pVidEncDynamicParams->searchCenter.x = pH264VEComp->pVidEncStatus->searchCenter.x;
+
+ pH264VEComp->pVidEncDynamicParams->searchCenter.x = pH264VEComp->pVidEncStatus->searchCenter.y;
+
+ pH264VEComp->pVidEncDynamicParams->enableStaticMBCount =pH264VEComp->pVidEncStatus->enableStaticMBCount;
+
+ pH264VEComp->pVidEncDynamicParams->enableROI = pH264VEComp->pVidEncStatus->enableROI;
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ tState=pH264VEComp->sBase.tCurState;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ if((tState == OMX_StateLoaded) || (tState == OMX_StateIdle)) {
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->rateControlParams), &(pH264VEComp->pVidEncStatus->rateControlParams),
+ sizeof (IH264ENC_RateControlParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->interCodingParams), &(pH264VEComp->pVidEncStatus->interCodingParams),
+ sizeof (IH264ENC_InterCodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->sliceCodingParams), &(pH264VEComp->pVidEncStatus->sliceCodingParams),
+ sizeof (IH264ENC_SliceCodingParams));
+
+ OSAL_Memcpy(&(pH264VEComp->pVidEncStaticParams->intraCodingParams), &(pH264VEComp->pVidEncStatus->intraCodingParams),
+ sizeof (IH264ENC_IntraCodingParams));
+ }
+
+EXIT:
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace("in fn OMXH264VE_UpdateParams");
+ }
+
+ return (eError);
+}
+
+OMX_ERRORTYPE OMXH264VE_FLUSHLockedBuffers(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_U32 i;
+
+ /* Check the input parameters */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) {
+ if((pH264VEComp->pCodecInBufferArray[i]) &&
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt == OWNED_BY_CODEC ) {
+ pH264VEComp->pCodecInBufferArray[i]->nOffset= 0;
+ /*update the status to free*/
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt = OWNED_BY_US;
+ pH264VEComp->sBase.pPvtData->fpDioSend(hComponent, OMX_H264VE_INPUT_PORT, pH264VEComp->pCodecInBufferArray[i]);
+ }
+ }
+
+EXIT:
+ return (eError);
+}
+
+OMX_ERRORTYPE OMXH264VE_GetNextFreeBufHdr(OMX_HANDLETYPE hComponent, OMX_S32 *nBuffIndex, OMX_U32 nPortIndex)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_BOOL bFreeBuffFound = OMX_FALSE;
+ OMX_S32 LBufIndex = -1;
+ OMX_U32 i;
+
+ /* Check the input parameters */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ if( nPortIndex == OMX_H264VE_INPUT_PORT ) {
+ for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) {
+ if(!pH264VEComp->pCodecInBufferArray[i] ||
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt != OWNED_BY_CODEC ) {
+ bFreeBuffFound=OMX_TRUE;
+ LBufIndex=i;
+ break;
+ }
+ }
+ } else {
+ eError = OMX_ErrorBadParameter;
+ }
+
+EXIT:
+
+ if( bFreeBuffFound ) {
+ *nBuffIndex=LBufIndex;
+ } else {
+ *nBuffIndex=-1;
+ }
+ return (eError);
+}
+
+OMX_ERRORTYPE OMXH264VE_SetDynamicParamsToCodec(OMX_HANDLETYPE hComponent)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ XDAS_Int32 retval = 0;
+
+ /* Check the input parameters */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.size = sizeof(IH264ENC_DynamicParams);
+ pH264VEComp->pVidEncStatus->videnc2Status.size = sizeof(IH264ENC_Status);
+
+ if((pH264VEComp->bSendCodecConfig)) {
+ pH264VEComp->pVidEncDynamicParams->videnc2DynamicParams.generateHeader = XDM_GENERATE_HEADER;
+ pH264VEComp->nCodecConfigSize = 0;
+ pH264VEComp->bAfterGenHeader = OMX_FALSE;
+ }
+
+ pH264VEComp->pVidEncDynamicParams->rateControlParams.rateControlParamsPreset = 2; //Existing
+
+ pH264VEComp->pVidEncDynamicParams->interCodingParams.interCodingPreset = 2; //Existing
+
+ pH264VEComp->pVidEncDynamicParams->intraCodingParams.intraCodingPreset = IH264_INTRACODING_EXISTING;
+
+ pH264VEComp->pVidEncDynamicParams->sliceCodingParams.sliceCodingPreset = 2; //Existing
+
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams=PARAMS_UPDATED_AT_CODEC;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ eError = OMXH264VE_VISACONTROL(pH264VEComp->pVidEncHandle, XDM_SETPARAMS,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus), hComponent, &retval);
+ if( retval == VIDENC2_EFAIL ) {
+ ALOGE("pH264VEComp->pVidEncStatus->videnc2Status.extendedError = %x", pH264VEComp->pVidEncStatus->videnc2Status.extendedError);
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncStatus->videnc2Status.extendedError, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, eError);
+ }
+
+
+EXIT:
+ return (eError);
+}
+
+OMX_ERRORTYPE OMXH264VE_GetNumCodecLockedBuffers(OMX_HANDLETYPE hComponent, OMX_U32 *nLockedBuffCount)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMX_U32 LBuffLockedCount = 0;
+ OMX_U32 i;
+
+ /* Check the input parameters */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+
+ for( i=0; i < pH264VEComp->sBase.pPorts[OMX_H264VE_INPUT_PORT]->sPortDef.nBufferCountActual; i++ ) {
+ if((pH264VEComp->pCodecInBufferArray[i]) &&
+ ((OMXBase_BufHdrPvtData *)(pH264VEComp->pCodecInBufferArray[i]->pPlatformPrivate))->bufSt == OWNED_BY_CODEC ) {
+ LBuffLockedCount++;
+
+ }
+ }
+
+ *nLockedBuffCount=LBuffLockedCount;
+
+EXIT:
+ return (eError);
+}
+
+OMX_ERRORTYPE OMXH264VE_VISACONTROL(VIDENC2_Handle handle, IVIDENC2_Cmd id, IVIDENC2_DynamicParams *dynParams,
+ IVIDENC2_Status *status, OMX_HANDLETYPE hComponent, XDAS_Int32 *retval)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+
+ /*Check for the Params*/
+ OMX_CHECK(((hComponent != NULL) && (dynParams != NULL) && (status != NULL) && (retval != NULL)), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = pHandle->pComponentPrivate;
+
+ (*retval) = VIDENC2_control(pH264VEComp->pVidEncHandle, id, dynParams, status);
+
+EXIT:
+ return (eError);
+}
+
+
+OMX_ERRORTYPE OMXH264VE_VISAPROCESS_AND_UPDATEPARAMS(OMX_HANDLETYPE hComponent, XDAS_Int32 *retval)
+{
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ PARAMS_UPDATE_STATUS bLCallxDMSetParams = NO_PARAM_CHANGE;
+ OMX_U32 sLretval;
+
+ /*Check for the Params*/
+ OMX_CHECK(((hComponent != NULL) && (retval != NULL)), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = pHandle->pComponentPrivate;
+
+ OSAL_Info("Before the Codec Process call");
+ sLretval = VIDENC2_process(pH264VEComp->pVidEncHandle,
+ (pH264VEComp->pVedEncInBufs),
+ (pH264VEComp->pVedEncOutBufs),
+ (IVIDENC2_InArgs *)(pH264VEComp->pVidEncInArgs),
+ (IVIDENC2_OutArgs *)(pH264VEComp->pVidEncOutArgs));
+
+ if( sLretval == VIDENC2_EFAIL ) {
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncOutArgs->videnc2OutArgs.extendedError, eError);
+ if( eError != OMX_ErrorNone ) {
+ ALOGE("Got error 0x%x from the Codec Process call", eError);
+ goto UPDATE_PARAMS;
+ }
+ }
+
+ /* Get the Codec Status Parameters if there has been a setconfig which has been translated to the codec */
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ bLCallxDMSetParams=pH264VEComp->bCallxDMSetParams;
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+
+ if( bLCallxDMSetParams == PARAMS_UPDATED_AT_CODEC ) {
+ OSAL_Info("Update the Codec Params after Codec Process call: call xDM control->GetStatus");
+ sLretval = VIDENC2_control(pH264VEComp->pVidEncHandle, XDM_GETSTATUS,
+ (VIDENC2_DynamicParams *)(pH264VEComp->pVidEncDynamicParams),
+ (IVIDENC2_Status *)(pH264VEComp->pVidEncStatus));
+ if( sLretval == VIDENC2_EFAIL ) {
+ OMX_TI_GET_ERROR(pH264VEComp, pH264VEComp->pVidEncOutArgs->videnc2OutArgs.extendedError, eError);
+ if( eError != OMX_ErrorNone ) {
+ OSAL_ErrorTrace("Got error 0x%x from the Codec Get Status Control call", eError);
+ goto UPDATE_PARAMS;
+ }
+ }
+ }
+
+UPDATE_PARAMS:
+ if( eError == OMX_ErrorNone ) {
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ bLCallxDMSetParams = pH264VEComp->bCallxDMSetParams;
+ if( bLCallxDMSetParams == PARAMS_UPDATED_AT_CODEC ) {
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ eError= OMXH264VE_UpdateParams(hComponent);
+ OSAL_ObtainMutex(pH264VEComp->sBase.pMutex, OSAL_SUSPEND);
+ pH264VEComp->bCallxDMSetParams = NO_PARAM_CHANGE;
+ }
+ OSAL_ReleaseMutex(pH264VEComp->sBase.pMutex);
+ }
+
+EXIT:
+ if( retval ) {
+ *retval = sLretval;
+ }
+
+ return (eError);
+}
+
+/* Function to check the max bit rate supported as per profile & level settings*/
+OMX_ERRORTYPE OMXH264VE_CheckBitRateCap(OMX_U32 targetBitRate, OMX_HANDLETYPE hComponent)
+{
+ OMX_COMPONENTTYPE *pHandle = NULL;
+ OMXH264VidEncComp *pH264VEComp = NULL;
+ OMX_ERRORTYPE eError = OMX_ErrorNone;
+ OMX_VIDEO_AVCLEVELTYPE eOMXLevel;
+ OMX_U32 nTableIndex = 0xFFFFFFFF;
+
+ /* Check the input parameters */
+ OMX_CHECK((hComponent != NULL), OMX_ErrorBadParameter);
+ pHandle = (OMX_COMPONENTTYPE *)hComponent;
+ pH264VEComp = (OMXH264VidEncComp *)pHandle->pComponentPrivate;
+ OMX_CHECK((pH264VEComp != NULL), OMX_ErrorBadParameter);
+
+ MAP_CODEC_TO_OMX_AVCLEVEL(pH264VEComp->pVidEncStaticParams->videnc2Params.level, eOMXLevel, nTableIndex, eError);
+ OMX_CHECK(eError == OMX_ErrorNone, OMX_ErrorUnsupportedSetting);
+ OMX_CHECK(nTableIndex != 0xFFFFFFFF, OMX_ErrorUnsupportedSetting);
+
+ if( pH264VEComp->pVidEncStaticParams->videnc2Params.profile == IH264_HIGH_PROFILE ) {
+ OSAL_Info(" HIGH PROFILE, Level %d Max Bit Rate Supported = %d", eOMXLevel, OMX_H264_HP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport);
+ OMX_CHECK(targetBitRate <= OMX_H264_HP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport, OMX_ErrorUnsupportedSetting);
+ } else {
+ OSAL_Info(" BASE/MAIN PROFILE, Level %d Max Bit Rate Supported = %d", eOMXLevel, OMX_H264_BP_MP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport);
+ OMX_CHECK(targetBitRate <= OMX_H264_BP_MP_BITRATE_SUPPORT[nTableIndex].nMaxBitRateSupport, OMX_ErrorUnsupportedSetting);
+ }
+
+EXIT:
+ return (eError);
+}
+
+