hardware: exynos5: update exynos_omx dir
Change-Id: Iff18ccb439407e68c8f898ac6499eb3669644716
Signed-off-by: Dima Zavin <dima@android.com>
diff --git a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/dec/src/ExynosVideoDecoder.c b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/dec/src/ExynosVideoDecoder.c
index 2a4bf6f..ee5077e 100644
--- a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/dec/src/ExynosVideoDecoder.c
+++ b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/dec/src/ExynosVideoDecoder.c
@@ -76,7 +76,7 @@
pixelformat = V4L2_PIX_FMT_VC1_ANNEX_L;
break;
case VIDEO_CODING_MPEG2:
- pixelformat = V4L2_PIX_FMT_MPEG1;
+ pixelformat = V4L2_PIX_FMT_MPEG2;
break;
default:
pixelformat = V4L2_PIX_FMT_H264;
@@ -282,29 +282,6 @@
}
/*
- * [Decoder OPS] Set Cacheable
- */
-static ExynosVideoErrorType MFC_Decoder_Enable_Cacheable(void *pHandle)
-{
- ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
- ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
-
- if (pCtx == NULL) {
- ALOGE("%s: Video context info must be supplied", __func__);
- ret = VIDEO_ERROR_BADPARAM;
- goto EXIT;
- }
-
- if (exynos_v4l2_s_ctrl(pCtx->hDec, V4L2_CID_CACHEABLE, 1)) {
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
- }
-
-EXIT:
- return ret;
-}
-
-/*
* [Decoder OPS] Set Display Delay
*/
static ExynosVideoErrorType MFC_Decoder_Set_DisplayDelay(
@@ -399,6 +376,140 @@
}
/*
+ * [Decoder OPS] Enable SEI Parsing
+ */
+static ExynosVideoErrorType MFC_Decoder_Enable_SEIParsing(void *pHandle)
+{
+ ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ if (exynos_v4l2_s_ctrl(pCtx->hDec, V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING, 1)) {
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+
+EXIT:
+ return ret;
+}
+
+/*
+ * [Decoder OPS] Get Frame Packing information
+ */
+static ExynosVideoErrorType MFC_Decoder_Get_FramePackingInfo(
+ void *pHandle,
+ ExynosVideoFramePacking *pFramePacking)
+{
+ ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ struct v4l2_ext_control ext_ctrl[FRAME_PACK_SEI_INFO_NUM];
+ struct v4l2_ext_controls ext_ctrls;
+
+ int seiAvailable, seiInfo, seiGridPos, i;
+ unsigned int seiArgmtId;
+
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ memset(pFramePacking, 0, sizeof(*pFramePacking));
+ memset(ext_ctrl, 0, (sizeof(struct v4l2_ext_control) * FRAME_PACK_SEI_INFO_NUM));
+
+ ext_ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
+ ext_ctrls.count = FRAME_PACK_SEI_INFO_NUM;
+ ext_ctrls.controls = ext_ctrl;
+ ext_ctrl[0].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_AVAIL;
+ ext_ctrl[1].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRGMENT_ID;
+ ext_ctrl[2].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_INFO;
+ ext_ctrl[3].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_GRID_POS;
+
+ if (exynos_v4l2_g_ext_ctrl(pCtx->hDec, &ext_ctrls)) {
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+
+ seiAvailable = ext_ctrl[0].value;
+ seiArgmtId = ext_ctrl[1].value;
+ seiInfo = ext_ctrl[2].value;
+ seiGridPos = ext_ctrl[3].value;
+
+ pFramePacking->available = seiAvailable;
+ pFramePacking->arrangement_id = seiArgmtId;
+
+ pFramePacking->arrangement_cancel_flag = OPERATE_BIT(seiInfo, 0x1, 0);
+ pFramePacking->arrangement_type = OPERATE_BIT(seiInfo, 0x3f, 1);
+ pFramePacking->quincunx_sampling_flag = OPERATE_BIT(seiInfo, 0x1, 8);
+ pFramePacking->content_interpretation_type = OPERATE_BIT(seiInfo, 0x3f, 9);
+ pFramePacking->spatial_flipping_flag = OPERATE_BIT(seiInfo, 0x1, 15);
+ pFramePacking->frame0_flipped_flag = OPERATE_BIT(seiInfo, 0x1, 16);
+ pFramePacking->field_views_flag = OPERATE_BIT(seiInfo, 0x1, 17);
+ pFramePacking->current_frame_is_frame0_flag = OPERATE_BIT(seiInfo, 0x1, 18);
+
+ pFramePacking->frame0_grid_pos_x = OPERATE_BIT(seiGridPos, 0xf, 0);
+ pFramePacking->frame0_grid_pos_y = OPERATE_BIT(seiGridPos, 0xf, 4);
+ pFramePacking->frame1_grid_pos_x = OPERATE_BIT(seiGridPos, 0xf, 8);
+ pFramePacking->frame1_grid_pos_y = OPERATE_BIT(seiGridPos, 0xf, 12);
+
+EXIT:
+ return ret;
+}
+
+/*
+ * [Decoder Buffer OPS] Enable Cacheable (Input)
+ */
+static ExynosVideoErrorType MFC_Decoder_Enable_Cacheable_Inbuf(void *pHandle)
+{
+ ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ if (exynos_v4l2_s_ctrl(pCtx->hDec, V4L2_CID_CACHEABLE, 2)) {
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+
+EXIT:
+ return ret;
+}
+
+/*
+ * [Decoder Buffer OPS] Enable Cacheable (Output)
+ */
+static ExynosVideoErrorType MFC_Decoder_Enable_Cacheable_Outbuf(void *pHandle)
+{
+ ExynosVideoDecContext *pCtx = (ExynosVideoDecContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ if (exynos_v4l2_s_ctrl(pCtx->hDec, V4L2_CID_CACHEABLE, 1)) {
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+
+EXIT:
+ return ret;
+}
+
+/*
* [Decoder Buffer OPS] Set Shareable Buffer (Input)
*/
static ExynosVideoErrorType MFC_Decoder_Set_Shareable_Inbuf(void *pHandle)
@@ -707,21 +818,20 @@
return ret;
EXIT:
- if (pCtx->bShareInbuf == VIDEO_FALSE) {
- for (i = 0; i < pCtx->nInbufs; i++) {
- pVideoPlane = &pCtx->pInbuf[i].planes[0];
- if (pVideoPlane->addr == MAP_FAILED) {
- pVideoPlane->addr = NULL;
- break;
+ if ((pCtx != NULL) && (pCtx->pInbuf != NULL)) {
+ if (pCtx->bShareInbuf == VIDEO_FALSE) {
+ for (i = 0; i < pCtx->nInbufs; i++) {
+ pVideoPlane = &pCtx->pInbuf[i].planes[0];
+ if (pVideoPlane->addr == MAP_FAILED) {
+ pVideoPlane->addr = NULL;
+ break;
+ }
+
+ munmap(pVideoPlane->addr, pVideoPlane->allocSize);
}
-
- munmap(pVideoPlane->addr, pVideoPlane->allocSize);
- pVideoPlane->allocSize = 0;
- pVideoPlane->dataSize = 0;
-
- pCtx->pInbuf[i].pGeometry = NULL;
- pCtx->pInbuf[i].bQueued = VIDEO_FALSE;
}
+
+ free(pCtx->pInbuf);
}
return ret;
@@ -818,23 +928,22 @@
return ret;
EXIT:
- if (pCtx->bShareOutbuf == VIDEO_FALSE) {
- for (i = 0; i < pCtx->nOutbufs; i++) {
- for (j = 0; j < VIDEO_DECODER_OUTBUF_PLANES; j++) {
- pVideoPlane = &pCtx->pOutbuf[i].planes[j];
- if (pVideoPlane->addr == MAP_FAILED) {
- pVideoPlane->addr = NULL;
- break;
+ if ((pCtx != NULL) && (pCtx->pOutbuf != NULL)) {
+ if (pCtx->bShareOutbuf == VIDEO_FALSE) {
+ for (i = 0; i < pCtx->nOutbufs; i++) {
+ for (j = 0; j < VIDEO_DECODER_OUTBUF_PLANES; j++) {
+ pVideoPlane = &pCtx->pOutbuf[i].planes[j];
+ if (pVideoPlane->addr == MAP_FAILED) {
+ pVideoPlane->addr = NULL;
+ break;
+ }
+
+ munmap(pVideoPlane->addr, pVideoPlane->allocSize);
}
-
- munmap(pVideoPlane->addr, pVideoPlane->allocSize);
- pVideoPlane->allocSize = 0;
- pVideoPlane->dataSize = 0;
}
-
- pCtx->pOutbuf[i].pGeometry = NULL;
- pCtx->pOutbuf[i].bQueued = VIDEO_FALSE;
}
+
+ free(pCtx->pOutbuf);
}
return ret;
@@ -1087,6 +1196,13 @@
goto EXIT;
}
+ if (VIDEO_DECODER_INBUF_PLANES < nPlanes) {
+ ALOGE("%s: Number of max planes : %d, nPlanes : %d", __func__,
+ VIDEO_DECODER_INBUF_PLANES, nPlanes);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
memset(&buf, 0, sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
@@ -1185,7 +1301,7 @@
buf.memory = V4L2_MEMORY_MMAP;
}
- if (exynos_v4l2_qbuf(pCtx->hDec, &buf)) {
+ if ((pCtx->pOutbuf[buf.index].bQueued == VIDEO_FALSE) && exynos_v4l2_qbuf(pCtx->hDec, &buf)) {
ALOGE("%s: Failed to enqueue output buffer", __func__);
ret = VIDEO_ERROR_APIFAIL;
goto EXIT;
@@ -1358,7 +1474,6 @@
.nSize = 0,
.Init = MFC_Decoder_Init,
.Finalize = MFC_Decoder_Finalize,
- .Enable_Cacheable = MFC_Decoder_Enable_Cacheable,
.Set_DisplayDelay = MFC_Decoder_Set_DisplayDelay,
.Enable_PackedPB = MFC_Decoder_Enable_PackedPB,
.Enable_LoopFilter = MFC_Decoder_Enable_LoopFilter,
@@ -1366,6 +1481,8 @@
.Get_ActualBufferCount = MFC_Decoder_Get_ActualBufferCount,
.Set_FrameTag = MFC_Decoder_Set_FrameTag,
.Get_FrameTag = MFC_Decoder_Get_FrameTag,
+ .Enable_SEIParsing = MFC_Decoder_Enable_SEIParsing,
+ .Get_FramePackingInfo = MFC_Decoder_Get_FramePackingInfo,
};
/*
@@ -1373,6 +1490,7 @@
*/
static ExynosVideoDecBufferOps defInbufOps = {
.nSize = 0,
+ .Enable_Cacheable = MFC_Decoder_Enable_Cacheable_Inbuf,
.Set_Shareable = MFC_Decoder_Set_Shareable_Inbuf,
.Get_BufferInfo = MFC_Decoder_Get_BufferInfo_Inbuf,
.Set_Geometry = MFC_Decoder_Set_Geometry_Inbuf,
@@ -1390,6 +1508,7 @@
*/
static ExynosVideoDecBufferOps defOutbufOps = {
.nSize = 0,
+ .Enable_Cacheable = MFC_Decoder_Enable_Cacheable_Outbuf,
.Set_Shareable = MFC_Decoder_Set_Shareable_Outbuf,
.Get_BufferInfo = MFC_Decoder_Get_BufferInfo_Outbuf,
.Set_Geometry = MFC_Decoder_Set_Geometry_Outbuf,
diff --git a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/enc/src/ExynosVideoEncoder.c b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/enc/src/ExynosVideoEncoder.c
index d38e0ea..8186838 100644
--- a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/enc/src/ExynosVideoEncoder.c
+++ b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/enc/src/ExynosVideoEncoder.c
@@ -51,8 +51,8 @@
#define LOG_TAG "ExynosVideoEncoder"
#include <utils/Log.h>
-#define MAX_CTRL_NUM 92
-#define H264_CTRL_NUM 92
+#define MAX_CTRL_NUM 91
+#define H264_CTRL_NUM 91
#define MPEG4_CTRL_NUM 26
#define H263_CTRL_NUM 18
@@ -143,6 +143,9 @@
goto EXIT_QUERYCAP_FAIL;
}
+ pCtx->bStreamonInbuf = VIDEO_FALSE;
+ pCtx->bStreamonOutbuf = VIDEO_FALSE;
+
return (void *)pCtx;
EXIT_QUERYCAP_FAIL:
@@ -225,7 +228,7 @@
/*
* [Encoder OPS] Enable Frame Skip
*/
-static ExynosVideoErrorType MFC_Decoder_Enable_FrameSkip(
+static ExynosVideoErrorType MFC_Encoder_Enable_FrameSkip(
void *pHandle,
ExynosVideoEncParam*encParam,
ExynosVideoFrameSkipMode frameSkip)
@@ -286,13 +289,15 @@
ext_ctrl[4].value |= (pCommonParam->LumaPadVal << 16);
ext_ctrl[5].id = V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE;
ext_ctrl[5].value = pCommonParam->EnableFRMRateControl;
- ext_ctrl[6].id = V4L2_CID_MPEG_VIDEO_BITRATE;
+ ext_ctrl[6].id = V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE;
+ ext_ctrl[6].value = pCommonParam->EnableMBRateControl;
+ ext_ctrl[7].id = V4L2_CID_MPEG_VIDEO_BITRATE;
/* FIXME temporary fix */
if (pCommonParam->Bitrate)
- ext_ctrl[6].value = pCommonParam->Bitrate;
+ ext_ctrl[7].value = pCommonParam->Bitrate;
else
- ext_ctrl[6].value = 1; /* just for testing Movie studio */
+ ext_ctrl[7].value = 1; /* just for testing Movie studio */
/* codec specific parameters */
switch (pEncParam->eCompressionFormat) {
@@ -300,41 +305,39 @@
pH264Param = &pEncParam->codecParam.h264;
/* common parameters but id is depends on codec */
- ext_ctrl[7].id = V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP;
- ext_ctrl[7].value = pCommonParam->FrameQp;
- ext_ctrl[8].id = V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP;
- ext_ctrl[8].value = pCommonParam->FrameQp_P;
- ext_ctrl[9].id = V4L2_CID_MPEG_VIDEO_H264_MAX_QP;
- ext_ctrl[9].value = pCommonParam->QSCodeMax;
- ext_ctrl[10].id = V4L2_CID_MPEG_VIDEO_H264_MIN_QP;
- ext_ctrl[10].value = pCommonParam->QSCodeMin;
- ext_ctrl[11].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF;
- ext_ctrl[11].value = pCommonParam->CBRPeriodRf;
+ ext_ctrl[8].id = V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP;
+ ext_ctrl[8].value = pCommonParam->FrameQp;
+ ext_ctrl[9].id = V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP;
+ ext_ctrl[9].value = pCommonParam->FrameQp_P;
+ ext_ctrl[10].id = V4L2_CID_MPEG_VIDEO_H264_MAX_QP;
+ ext_ctrl[10].value = pCommonParam->QSCodeMax;
+ ext_ctrl[11].id = V4L2_CID_MPEG_VIDEO_H264_MIN_QP;
+ ext_ctrl[11].value = pCommonParam->QSCodeMin;
+ ext_ctrl[12].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF;
+ ext_ctrl[12].value = pCommonParam->CBRPeriodRf;
/* H.264 specific parameters */
if (pCommonParam->SliceMode == 0) {
- ext_ctrl[12].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
- ext_ctrl[12].value = 1; /* default */
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
- ext_ctrl[13].value = 2800; /* based on MFC6.x */
+ ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
+ ext_ctrl[13].value = 1; /* default */
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[14].value = 2800; /* based on MFC6.x */
} else if (pCommonParam->SliceMode == 1) {
- ext_ctrl[12].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
- ext_ctrl[12].value = pH264Param->SliceArgument;
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
- ext_ctrl[13].value = 2800; /* based on MFC6.x */
- } else if (pCommonParam->SliceMode == 3) {
- ext_ctrl[12].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
- ext_ctrl[12].value = 1; /* default */
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
ext_ctrl[13].value = pH264Param->SliceArgument;
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[14].value = 2800; /* based on MFC6.x */
+ } else if (pCommonParam->SliceMode == 3) {
+ ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
+ ext_ctrl[13].value = 1; /* default */
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[14].value = pH264Param->SliceArgument;
}
- ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_H264_PROFILE;
- ext_ctrl[14].value = pH264Param->ProfileIDC;
- ext_ctrl[15].id = V4L2_CID_MPEG_VIDEO_H264_LEVEL;
- ext_ctrl[15].value = pH264Param->LevelIDC;
- ext_ctrl[16].id = V4L2_CID_MPEG_VIDEO_MAX_REF_PIC;
- ext_ctrl[16].value = pH264Param->NumberReferenceFrames;
+ ext_ctrl[15].id = V4L2_CID_MPEG_VIDEO_H264_PROFILE;
+ ext_ctrl[15].value = pH264Param->ProfileIDC;
+ ext_ctrl[16].id = V4L2_CID_MPEG_VIDEO_H264_LEVEL;
+ ext_ctrl[16].value = pH264Param->LevelIDC;
ext_ctrl[17].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P;
ext_ctrl[17].value = pH264Param->NumberRefForPframes;
/*
@@ -354,99 +357,97 @@
ext_ctrl[23].value = pH264Param->PictureInterlace;
ext_ctrl[24].id = V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM;
ext_ctrl[24].value = pH264Param->Transform8x8Mode;
- ext_ctrl[25].id = V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE;
- ext_ctrl[25].value = pH264Param->EnableMBRateControl;
- ext_ctrl[26].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_RC_FRAME_RATE;
- ext_ctrl[26].value = pH264Param->FrameRate;
- ext_ctrl[27].id = V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP;
- ext_ctrl[27].value = pH264Param->FrameQp_B;
- ext_ctrl[28].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK;
- ext_ctrl[28].value = pH264Param->DarkDisable;
- ext_ctrl[29].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH;
- ext_ctrl[29].value = pH264Param->SmoothDisable;
- ext_ctrl[30].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC;
- ext_ctrl[30].value = pH264Param->StaticDisable;
- ext_ctrl[31].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY;
- ext_ctrl[31].value = pH264Param->ActivityDisable;
+ ext_ctrl[25].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_RC_FRAME_RATE;
+ ext_ctrl[25].value = pH264Param->FrameRate;
+ ext_ctrl[26].id = V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP;
+ ext_ctrl[26].value = pH264Param->FrameQp_B;
+ ext_ctrl[27].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK;
+ ext_ctrl[27].value = pH264Param->DarkDisable;
+ ext_ctrl[28].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH;
+ ext_ctrl[28].value = pH264Param->SmoothDisable;
+ ext_ctrl[29].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC;
+ ext_ctrl[29].value = pH264Param->StaticDisable;
+ ext_ctrl[30].id = V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY;
+ ext_ctrl[30].value = pH264Param->ActivityDisable;
/* doesn't have to be set */
- ext_ctrl[32].id = V4L2_CID_MPEG_VIDEO_GOP_CLOSURE;
- ext_ctrl[32].value = 0;
- ext_ctrl[33].id = V4L2_CID_MPEG_VIDEO_H264_I_PERIOD;
- ext_ctrl[33].value = 10;
- ext_ctrl[34].id = V4L2_CID_MPEG_VIDEO_VBV_SIZE;
- ext_ctrl[34].value = 0;
- ext_ctrl[35].id = V4L2_CID_MPEG_VIDEO_HEADER_MODE;
- ext_ctrl[35].value = 0; /* 0: seperated header, 1: header + first frame */
- ext_ctrl[36].id = V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE;
- ext_ctrl[36].value = 0;
- ext_ctrl[37].id = V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC;
- ext_ctrl[37].value = V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_UNSPECIFIED;
- ext_ctrl[38].id = V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH;
+ ext_ctrl[31].id = V4L2_CID_MPEG_VIDEO_GOP_CLOSURE;
+ ext_ctrl[31].value = 0;
+ ext_ctrl[32].id = V4L2_CID_MPEG_VIDEO_H264_I_PERIOD;
+ ext_ctrl[32].value = 10;
+ ext_ctrl[33].id = V4L2_CID_MPEG_VIDEO_VBV_SIZE;
+ ext_ctrl[33].value = 0;
+ ext_ctrl[34].id = V4L2_CID_MPEG_VIDEO_HEADER_MODE;
+ ext_ctrl[34].value = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE; /* 0: seperated header, 1: header + first frame */
+ ext_ctrl[35].id = V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE;
+ ext_ctrl[35].value = 0;
+ ext_ctrl[36].id = V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC;
+ ext_ctrl[36].value = V4L2_MPEG_VIDEO_H264_VUI_SAR_IDC_UNSPECIFIED;
+ ext_ctrl[37].id = V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH;
+ ext_ctrl[37].value = 0;
+ ext_ctrl[38].id = V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT;
ext_ctrl[38].value = 0;
- ext_ctrl[39].id = V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT;
- ext_ctrl[39].value = 0;
/* Initial parameters : Frame Skip */
if (pInitParam->FrameSkip == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT) {
- ext_ctrl[40].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
- ext_ctrl[40].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT;
+ ext_ctrl[39].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
+ ext_ctrl[39].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT;
} else if (pInitParam->FrameSkip == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
- ext_ctrl[40].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
- ext_ctrl[40].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT;
+ ext_ctrl[39].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
+ ext_ctrl[39].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT;
} else {
/* ENC_FRAME_SKIP_MODE_DISABLE (default) */
- ext_ctrl[40].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
- ext_ctrl[40].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED;
+ ext_ctrl[39].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
+ ext_ctrl[39].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_DISABLED;
}
/* SVC is not supported yet */
- ext_ctrl[41].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING;
- ext_ctrl[41].value = 0;
- ext_ctrl[42].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE;
- ext_ctrl[42].value = V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_B;
- ext_ctrl[43].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER;
- ext_ctrl[43].value = 3;
+ ext_ctrl[40].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING;
+ ext_ctrl[40].value = 0;
+ ext_ctrl[41].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE;
+ ext_ctrl[41].value = V4L2_MPEG_VIDEO_H264_HIERARCHICAL_CODING_B;
+ ext_ctrl[42].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER;
+ ext_ctrl[42].value = 3;
+ ext_ctrl[43].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP;
+ ext_ctrl[43].value = (0 << 16 | 0);
ext_ctrl[44].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP;
- ext_ctrl[44].value = (0 << 16 | 0);
+ ext_ctrl[44].value = (1 << 16 | 0);
ext_ctrl[45].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP;
- ext_ctrl[45].value = (1 << 16 | 0);
- ext_ctrl[46].id = V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP;
- ext_ctrl[46].value = (2 << 16 | 0);
+ ext_ctrl[45].value = (2 << 16 | 0);
- ext_ctrl[47].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING;
+ ext_ctrl[46].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING;
+ ext_ctrl[46].value = 0;
+ ext_ctrl[47].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0;
ext_ctrl[47].value = 0;
- ext_ctrl[48].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0;
- ext_ctrl[48].value = 0;
- ext_ctrl[49].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE;
- ext_ctrl[49].value = V4L2_MPEG_VIDEO_H264_SEI_FP_TYPE_SIDE_BY_SIDE;
+ ext_ctrl[48].id = V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE;
+ ext_ctrl[48].value = V4L2_MPEG_VIDEO_H264_SEI_FP_TYPE_SIDE_BY_SIDE;
/* FMO is not supported yet */
- ext_ctrl[50].id = V4L2_CID_MPEG_VIDEO_H264_FMO;
- ext_ctrl[50].value = 0;
- ext_ctrl[51].id = V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE;
- ext_ctrl[51].value = V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES;
- ext_ctrl[52].id = V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP;
- ext_ctrl[52].value = 4;
+ ext_ctrl[49].id = V4L2_CID_MPEG_VIDEO_H264_FMO;
+ ext_ctrl[49].value = 0;
+ ext_ctrl[50].id = V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE;
+ ext_ctrl[50].value = V4L2_MPEG_VIDEO_H264_FMO_MAP_TYPE_INTERLEAVED_SLICES;
+ ext_ctrl[51].id = V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP;
+ ext_ctrl[51].value = 4;
+ ext_ctrl[52].id = V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH;
+ ext_ctrl[52].value = (0 << 30 | 0);
ext_ctrl[53].id = V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH;
- ext_ctrl[53].value = (0 << 30 | 0);
+ ext_ctrl[53].value = (1 << 30 | 0);
ext_ctrl[54].id = V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH;
- ext_ctrl[54].value = (1 << 30 | 0);
+ ext_ctrl[54].value = (2 << 30 | 0);
ext_ctrl[55].id = V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH;
- ext_ctrl[55].value = (2 << 30 | 0);
- ext_ctrl[56].id = V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH;
- ext_ctrl[56].value = (3 << 30 | 0);
- ext_ctrl[57].id = V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION;
- ext_ctrl[57].value = V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_RIGHT;
- ext_ctrl[58].id = V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE;
- ext_ctrl[58].value = 0;
+ ext_ctrl[55].value = (3 << 30 | 0);
+ ext_ctrl[56].id = V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION;
+ ext_ctrl[56].value = V4L2_MPEG_VIDEO_H264_FMO_CHANGE_DIR_RIGHT;
+ ext_ctrl[57].id = V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE;
+ ext_ctrl[57].value = 0;
/* ASO is not supported yet */
- ext_ctrl[59].id = V4L2_CID_MPEG_VIDEO_H264_ASO;
- ext_ctrl[59].value = 0;
+ ext_ctrl[58].id = V4L2_CID_MPEG_VIDEO_H264_ASO;
+ ext_ctrl[58].value = 0;
for (i = 0; i < 32; i++) {
- ext_ctrl[60 + i].id = V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER;
- ext_ctrl[60 + i].value = (i << 16 | 0);
+ ext_ctrl[59 + i].id = V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER;
+ ext_ctrl[59 + i].value = (i << 16 | 0);
}
break;
@@ -454,70 +455,66 @@
pMpeg4Param = &pEncParam->codecParam.mpeg4;
/* common parameters but id is depends on codec */
- ext_ctrl[7].id = V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP;
- ext_ctrl[7].value = pCommonParam->FrameQp;
- ext_ctrl[8].id = V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP;
- ext_ctrl[8].value = pCommonParam->FrameQp_P;
- ext_ctrl[9].id = V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP;
- ext_ctrl[9].value = pCommonParam->QSCodeMax;
- ext_ctrl[10].id = V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP;
- ext_ctrl[10].value = pCommonParam->QSCodeMin;
- ext_ctrl[11].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF;
- ext_ctrl[11].value = pCommonParam->CBRPeriodRf;
+ ext_ctrl[8].id = V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP;
+ ext_ctrl[8].value = pCommonParam->FrameQp;
+ ext_ctrl[9].id = V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP;
+ ext_ctrl[9].value = pCommonParam->FrameQp_P;
+ ext_ctrl[10].id = V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP;
+ ext_ctrl[10].value = pCommonParam->QSCodeMax;
+ ext_ctrl[11].id = V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP;
+ ext_ctrl[11].value = pCommonParam->QSCodeMin;
+ ext_ctrl[12].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF;
+ ext_ctrl[12].value = pCommonParam->CBRPeriodRf;
/* MPEG4 specific parameters */
if (pCommonParam->SliceMode == 0) {
- ext_ctrl[12].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
- ext_ctrl[12].value = 1; /* default */
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
- ext_ctrl[13].value = 2800; /* based on MFC6.x */
+ ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
+ ext_ctrl[13].value = 1; /* default */
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[14].value = 2800; /* based on MFC6.x */
} else if (pCommonParam->SliceMode == 1) {
- ext_ctrl[12].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
- ext_ctrl[12].value = pMpeg4Param->SliceArgument;
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
- ext_ctrl[13].value = 2800; /* based on MFC6.x */
- } else if (pCommonParam->SliceMode == 3) {
- ext_ctrl[12].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
- ext_ctrl[12].value = 1; /* default */
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
ext_ctrl[13].value = pMpeg4Param->SliceArgument;
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[14].value = 2800; /* based on MFC6.x */
+ } else if (pCommonParam->SliceMode == 3) {
+ ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB;
+ ext_ctrl[13].value = 1; /* default */
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES;
+ ext_ctrl[14].value = pMpeg4Param->SliceArgument;
}
- ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE;
- ext_ctrl[14].value = pMpeg4Param->ProfileIDC;
- ext_ctrl[15].id = V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL;
- ext_ctrl[15].value = pMpeg4Param->LevelIDC;
- ext_ctrl[16].id = V4L2_CID_MPEG_VIDEO_MPEG4_QPEL;
- ext_ctrl[16].value = pMpeg4Param->DisableQpelME;
+ ext_ctrl[15].id = V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE;
+ ext_ctrl[15].value = pMpeg4Param->ProfileIDC;
+ ext_ctrl[16].id = V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL;
+ ext_ctrl[16].value = pMpeg4Param->LevelIDC;
+ ext_ctrl[17].id = V4L2_CID_MPEG_VIDEO_MPEG4_QPEL;
+ ext_ctrl[17].value = pMpeg4Param->DisableQpelME;
/*
* It should be set using mpeg4Param->NumberBFrames after being handled by appl.
*/
- ext_ctrl[17].id = V4L2_CID_MPEG_VIDEO_B_FRAMES;
- ext_ctrl[17].value = pMpeg4Param->NumberBFrames;
+ ext_ctrl[18].id = V4L2_CID_MPEG_VIDEO_B_FRAMES;
+ ext_ctrl[18].value = pMpeg4Param->NumberBFrames;
- ext_ctrl[18].id = V4L2_CID_MPEG_MFC51_VIDEO_MPEG4_VOP_TIME_RES;
- ext_ctrl[18].value = pMpeg4Param->TimeIncreamentRes;
- ext_ctrl[19].id = V4L2_CID_MPEG_MFC51_VIDEO_MPEG4_VOP_FRM_DELTA;
- ext_ctrl[19].value = pMpeg4Param->VopTimeIncreament;
- ext_ctrl[20].id = V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP;
- ext_ctrl[20].value = pMpeg4Param->FrameQp_B;
- ext_ctrl[21].id = V4L2_CID_MPEG_VIDEO_VBV_SIZE;
- ext_ctrl[21].value = 0;
- ext_ctrl[22].id = V4L2_CID_MPEG_VIDEO_HEADER_MODE;
+ ext_ctrl[19].id = V4L2_CID_MPEG_MFC51_VIDEO_MPEG4_VOP_TIME_RES;
+ ext_ctrl[19].value = pMpeg4Param->TimeIncreamentRes;
+ ext_ctrl[20].id = V4L2_CID_MPEG_MFC51_VIDEO_MPEG4_VOP_FRM_DELTA;
+ ext_ctrl[20].value = pMpeg4Param->VopTimeIncreament;
+ ext_ctrl[21].id = V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP;
+ ext_ctrl[21].value = pMpeg4Param->FrameQp_B;
+ ext_ctrl[22].id = V4L2_CID_MPEG_VIDEO_VBV_SIZE;
ext_ctrl[22].value = 0;
- ext_ctrl[23].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT;
- ext_ctrl[23].value = 1;
-
- /* MFC 6.x Only */
- ext_ctrl[24].id = V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE;
- ext_ctrl[24].value = pMpeg4Param->EnableMBRateControl;
+ ext_ctrl[23].id = V4L2_CID_MPEG_VIDEO_HEADER_MODE;
+ ext_ctrl[23].value = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE;
+ ext_ctrl[24].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT;
+ ext_ctrl[24].value = 1;
/* Initial parameters : Frame Skip */
if (pInitParam->FrameSkip == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT) {
ext_ctrl[25].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
ext_ctrl[25].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT;
- } else if (pInitParam->FrameSkip == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
+ } else if (pInitParam->FrameSkip ==V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT) {
ext_ctrl[25].id = V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE;
ext_ctrl[25].value = V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_BUF_LIMIT;
} else {
@@ -532,30 +529,26 @@
pH263Param = &pEncParam->codecParam.h263;
/* common parameters but id is depends on codec */
- ext_ctrl[7].id = V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP;
- ext_ctrl[7].value = pCommonParam->FrameQp;
- ext_ctrl[8].id = V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP;
- ext_ctrl[8].value = pCommonParam->FrameQp_P;
- ext_ctrl[9].id = V4L2_CID_MPEG_VIDEO_H263_MAX_QP;
- ext_ctrl[9].value = pCommonParam->QSCodeMax;
- ext_ctrl[10].id = V4L2_CID_MPEG_VIDEO_H263_MIN_QP;
- ext_ctrl[10].value = pCommonParam->QSCodeMin;
- ext_ctrl[11].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF;
- ext_ctrl[11].value = pCommonParam->CBRPeriodRf;
+ ext_ctrl[8].id = V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP;
+ ext_ctrl[8].value = pCommonParam->FrameQp;
+ ext_ctrl[9].id = V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP;
+ ext_ctrl[9].value = pCommonParam->FrameQp_P;
+ ext_ctrl[10].id = V4L2_CID_MPEG_VIDEO_H263_MAX_QP;
+ ext_ctrl[10].value = pCommonParam->QSCodeMax;
+ ext_ctrl[11].id = V4L2_CID_MPEG_VIDEO_H263_MIN_QP;
+ ext_ctrl[11].value = pCommonParam->QSCodeMin;
+ ext_ctrl[12].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF;
+ ext_ctrl[12].value = pCommonParam->CBRPeriodRf;
/* H263 specific parameters */
- ext_ctrl[12].id = V4L2_CID_MPEG_MFC51_VIDEO_H263_RC_FRAME_RATE;
- ext_ctrl[12].value = pH263Param->FrameRate;
- ext_ctrl[13].id = V4L2_CID_MPEG_VIDEO_VBV_SIZE;
- ext_ctrl[13].value = 0;
- ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_HEADER_MODE;
- ext_ctrl[14].value = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE;
- ext_ctrl[15].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT;
- ext_ctrl[15].value = 1;
-
- /* MFC 6.x Only */
- ext_ctrl[16].id = V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE;
- ext_ctrl[16].value = pH263Param->EnableMBRateControl;
+ ext_ctrl[13].id = V4L2_CID_MPEG_MFC51_VIDEO_H263_RC_FRAME_RATE;
+ ext_ctrl[13].value = pH263Param->FrameRate;
+ ext_ctrl[14].id = V4L2_CID_MPEG_VIDEO_VBV_SIZE;
+ ext_ctrl[14].value = 0;
+ ext_ctrl[15].id = V4L2_CID_MPEG_VIDEO_HEADER_MODE;
+ ext_ctrl[15].value = V4L2_MPEG_VIDEO_HEADER_MODE_SEPARATE;
+ ext_ctrl[16].id = V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT;
+ ext_ctrl[16].value = 1;
/* Initial parameters : Frame Skip */
if (pInitParam->FrameSkip == V4L2_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE_LEVEL_LIMIT) {
@@ -778,6 +771,51 @@
return ret;
}
+/*
+ * [Encoder Buffer OPS] Enable Cacheable (Input)
+ */
+static ExynosVideoErrorType MFC_Encoder_Enable_Cacheable_Inbuf(void *pHandle)
+{
+ ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ if (exynos_v4l2_s_ctrl(pCtx->hEnc, V4L2_CID_CACHEABLE, 2)) {
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+
+EXIT:
+ return ret;
+}
+
+/*
+ * [Encoder Buffer OPS] Enable Cacheable (Output)
+ */
+static ExynosVideoErrorType MFC_Encoder_Enable_Cacheable_Outbuf(void *pHandle)
+{
+ ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ if (exynos_v4l2_s_ctrl(pCtx->hEnc, V4L2_CID_CACHEABLE, 1)) {
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+
+EXIT:
+ return ret;
+}
/*
* [Encoder Buffer OPS] Set Shareable Buffer (Input)
@@ -1128,27 +1166,22 @@
return ret;
EXIT:
- if (pCtx->bShareInbuf == VIDEO_FALSE) {
- for (i = 0; i < pCtx->nInbufs; i++) {
- for (j = 0; j < VIDEO_ENCODER_INBUF_PLANES; j++) {
- pVideoPlane = &pCtx->pInbuf[i].planes[j];
- if (pVideoPlane->addr == MAP_FAILED) {
- pVideoPlane->addr = NULL;
- break;
+ if ((pCtx != NULL) && (pCtx->pInbuf != NULL)) {
+ if (pCtx->bShareInbuf == VIDEO_FALSE) {
+ for (i = 0; i < pCtx->nInbufs; i++) {
+ for (j = 0; j < VIDEO_ENCODER_INBUF_PLANES; j++) {
+ pVideoPlane = &pCtx->pInbuf[i].planes[j];
+ if (pVideoPlane->addr == MAP_FAILED) {
+ pVideoPlane->addr = NULL;
+ break;
+ }
+
+ munmap(pVideoPlane->addr, pVideoPlane->allocSize);
}
}
- munmap(pVideoPlane->addr, pVideoPlane->allocSize);
- pVideoPlane->allocSize = 0;
- pVideoPlane->dataSize = 0;
+ }
- pCtx->pInbuf[i].pGeometry = NULL;
- pCtx->pInbuf[i].bQueued = VIDEO_FALSE;
- }
- } else {
- for (i = 0; i < pCtx->nInbufs; i++) {
- pCtx->pInbuf[i].pGeometry = NULL;
- pCtx->pInbuf[i].bQueued = VIDEO_FALSE;
- }
+ free(pCtx->pInbuf);
}
return ret;
@@ -1242,33 +1275,31 @@
pCtx->pOutbuf[i].bQueued = VIDEO_FALSE;
}
} else {
- pCtx->pOutbuf[i].pGeometry = &pCtx->outbufGeometry;
- pCtx->pOutbuf[i].bQueued = VIDEO_FALSE;
+ for (i = 0; i < pCtx->nOutbufs; i++ ) {
+ pCtx->pOutbuf[i].pGeometry = &pCtx->outbufGeometry;
+ pCtx->pOutbuf[i].bQueued = VIDEO_FALSE;
+ }
}
return ret;
EXIT:
- if (pCtx->bShareOutbuf == VIDEO_FALSE) {
- for (i = 0; i < pCtx->nOutbufs; i++) {
- for (j = 0; j < VIDEO_ENCODER_OUTBUF_PLANES; j++) {
- pVideoPlane = &pCtx->pOutbuf[i].planes[j];
- if (pVideoPlane->addr == MAP_FAILED) {
- pVideoPlane->addr = NULL;
- break;
+ if ((pCtx != NULL) && (pCtx->pOutbuf != NULL)) {
+ if (pCtx->bShareOutbuf == VIDEO_FALSE) {
+ for (i = 0; i < pCtx->nOutbufs; i++) {
+ for (j = 0; j < VIDEO_ENCODER_OUTBUF_PLANES; j++) {
+ pVideoPlane = &pCtx->pOutbuf[i].planes[j];
+ if (pVideoPlane->addr == MAP_FAILED) {
+ pVideoPlane->addr = NULL;
+ break;
+ }
+
+ munmap(pVideoPlane->addr, pVideoPlane->allocSize);
}
-
- munmap(pVideoPlane->addr, pVideoPlane->allocSize);
- pVideoPlane->allocSize = 0;
- pVideoPlane->dataSize = 0;
}
-
- pCtx->pOutbuf[i].pGeometry = NULL;
- pCtx->pOutbuf[i].bQueued = VIDEO_FALSE;
}
- } else {
- pCtx->pOutbuf[i].pGeometry = NULL;
- pCtx->pOutbuf[i].bQueued = VIDEO_FALSE;
+
+ free(pCtx->pOutbuf);
}
return ret;
@@ -1288,10 +1319,13 @@
goto EXIT;
}
- if (exynos_v4l2_streamon(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) {
- ALOGE("%s: Failed to streamon for input buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
+ if (pCtx->bStreamonInbuf == VIDEO_FALSE) {
+ if (exynos_v4l2_streamon(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) {
+ ALOGE("%s: Failed to streamon for input buffer", __func__);
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+ pCtx->bStreamonInbuf = VIDEO_TRUE;
}
EXIT:
@@ -1312,10 +1346,13 @@
goto EXIT;
}
- if (exynos_v4l2_streamon(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
- ALOGE("%s: Failed to streamon for output buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
+ if (pCtx->bStreamonOutbuf == VIDEO_FALSE) {
+ if (exynos_v4l2_streamon(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
+ ALOGE("%s: Failed to streamon for output buffer", __func__);
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+ pCtx->bStreamonOutbuf = VIDEO_TRUE;
}
EXIT:
@@ -1336,10 +1373,13 @@
goto EXIT;
}
- if (exynos_v4l2_streamoff(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) {
- ALOGE("%s: Failed to streamoff for input buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
+ if (pCtx->bStreamonInbuf == VIDEO_TRUE) {
+ if (exynos_v4l2_streamoff(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE)) {
+ ALOGE("%s: Failed to streamoff for input buffer", __func__);
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+ pCtx->bStreamonInbuf = VIDEO_FALSE;
}
EXIT:
@@ -1360,10 +1400,13 @@
goto EXIT;
}
- if (exynos_v4l2_streamoff(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
- ALOGE("%s: Failed to streamoff for output buffer", __func__);
- ret = VIDEO_ERROR_APIFAIL;
- goto EXIT;
+ if (pCtx->bStreamonOutbuf == VIDEO_TRUE) {
+ if (exynos_v4l2_streamoff(pCtx->hEnc, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE)) {
+ ALOGE("%s: Failed to streamoff for output buffer", __func__);
+ ret = VIDEO_ERROR_APIFAIL;
+ goto EXIT;
+ }
+ pCtx->bStreamonOutbuf = VIDEO_FALSE;
}
EXIT:
@@ -1623,6 +1666,13 @@
goto EXIT;
}
+ if (VIDEO_ENCODER_OUTBUF_PLANES < nPlanes) {
+ ALOGE("%s: Number of max planes : %d, nPlanes : %d", __func__,
+ VIDEO_ENCODER_OUTBUF_PLANES, nPlanes);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
memset(&buf, 0, sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
@@ -1634,7 +1684,6 @@
else
index = MFC_Encoder_Find_Outbuf(pCtx, pBuffer[0]);
-
if (index == -1) {
ret = VIDEO_ERROR_NOBUFFERS;
goto EXIT;
@@ -1668,6 +1717,29 @@
}
/*
+ * [Encoder Buffer OPS] Enqueue All (Dst)
+ */
+static ExynosVideoErrorType MFC_Encoder_Enqueue_All_Outbuf(void *pHandle)
+{
+ ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
+ ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
+
+ int i;
+
+ if (pCtx == NULL) {
+ ALOGE("%s: Video context info must be supplied", __func__);
+ ret = VIDEO_ERROR_BADPARAM;
+ goto EXIT;
+ }
+
+ for (i = 0; i < pCtx->nOutbufs; i++)
+ MFC_Encoder_Enqueue_Outbuf(pCtx, NULL, NULL, 0, NULL);
+
+EXIT:
+ return ret;
+}
+
+/*
* [Encoder Buffer OPS] Dequeue (Src)
*/
static ExynosVideoBuffer *MFC_Encoder_Dequeue_Inbuf(void *pHandle)
@@ -1683,6 +1755,11 @@
goto EXIT;
}
+ if (pCtx->bStreamonInbuf == VIDEO_FALSE) {
+ ALOGE("%s: Input buffer stream is off", __func__);
+ goto EXIT;
+ }
+
memset(&buf, 0, sizeof(buf));
buf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
@@ -1723,6 +1800,11 @@
goto EXIT;
}
+ if (pCtx->bStreamonOutbuf == VIDEO_FALSE) {
+ ALOGE("%s: Output buffer stream is off", __func__);
+ goto EXIT;
+ }
+
if (MFC_Encoder_Wait_Outbuf(pCtx) != VIDEO_ERROR_NONE) {
ALOGE("%s: Failed to poll for output buffer", __func__);
pOutbuf = NULL;
@@ -1741,7 +1823,10 @@
buf.memory = V4L2_MEMORY_MMAP;
/* no error case for output buffer dequeue in encoder */
- exynos_v4l2_dqbuf(pCtx->hEnc, &buf);
+ if (exynos_v4l2_dqbuf(pCtx->hEnc, &buf) < 0) {
+ ALOGE("%s: Failed to dequeue buffer for output", __func__);
+ goto EXIT;
+ }
pOutbuf = &pCtx->pOutbuf[buf.index];
pOutbuf->planes[0].dataSize = buf.m.planes[0].bytesused;
@@ -1769,30 +1854,6 @@
}
/*
- * [Encoder Buffer OPS] Enqueue All (Dst)
- */
-static ExynosVideoErrorType MFC_Encoder_Enqueue_All_Outbuf(void *pHandle)
-{
- ExynosVideoEncContext *pCtx = (ExynosVideoEncContext *)pHandle;
- ExynosVideoErrorType ret = VIDEO_ERROR_NONE;
-
- int i;
-
- if (pCtx == NULL) {
- ALOGE("%s: Video context info must be supplied", __func__);
- ret = VIDEO_ERROR_BADPARAM;
- goto EXIT;
- }
-
- for (i = 0; i < pCtx->nOutbufs; i++)
- MFC_Encoder_Enqueue_Outbuf(pCtx, NULL, NULL, 0, NULL);
-
-EXIT:
- return ret;
-}
-
-
-/*
* [Encoder OPS] Common
*/
static ExynosVideoEncOps defEncOps = {
@@ -1814,6 +1875,7 @@
*/
static ExynosVideoEncBufferOps defInbufOps = {
.nSize = 0,
+ .Enable_Cacheable = MFC_Encoder_Enable_Cacheable_Inbuf,
.Set_Shareable = MFC_Encoder_Set_Shareable_Inbuf,
.Get_BufferInfo = MFC_Encoder_Get_BufferInfo_Inbuf,
.Set_Geometry = MFC_Encoder_Set_Geometry_Inbuf,
@@ -1831,6 +1893,7 @@
*/
static ExynosVideoEncBufferOps defOutbufOps = {
.nSize = 0,
+ .Enable_Cacheable = MFC_Encoder_Enable_Cacheable_Outbuf,
.Set_Shareable = MFC_Encoder_Set_Shareable_Outbuf,
.Get_BufferInfo = MFC_Encoder_Get_BufferInfo_Outbuf,
.Set_Geometry = MFC_Encoder_Set_Geometry_Outbuf,
diff --git a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoApi.h b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoApi.h
index 89bb6d6..c4525c2 100644
--- a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoApi.h
+++ b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoApi.h
@@ -118,6 +118,23 @@
void *pPrivate;
} ExynosVideoBuffer;
+typedef struct _ExynosVideoFramePacking{
+ int available;
+ unsigned int arrangement_id;
+ int arrangement_cancel_flag;
+ unsigned char arrangement_type;
+ int quincunx_sampling_flag;
+ unsigned char content_interpretation_type;
+ int spatial_flipping_flag;
+ int frame0_flipped_flag;
+ int field_views_flag;
+ int current_frame_is_frame0_flag;
+ unsigned char frame0_grid_pos_x;
+ unsigned char frame0_grid_pos_y;
+ unsigned char frame1_grid_pos_x;
+ unsigned char frame1_grid_pos_y;
+} ExynosVideoFramePacking;
+
typedef struct _ExynosVideoEncInitParam{
/* Initial parameters */
ExynosVideoFrameSkipMode FrameSkip; /* [IN] frame skip mode */
@@ -133,6 +150,7 @@
int SliceMode; /* [IN] Multi slice mode */
int RandomIntraMBRefresh; /* [IN] cyclic intra refresh */
int EnableFRMRateControl; /* [IN] frame based rate control enable */
+ int EnableMBRateControl; /* [IN] Enable macroblock-level rate control */
int Bitrate; /* [IN] rate control parameter(bit rate) */
int FrameQp; /* [IN] The quantization parameter of the frame */
int FrameQp_P; /* [IN] The quantization parameter of the P frame */
@@ -162,7 +180,6 @@
int SymbolMode; /* [IN] The mode of entropy coding(CABAC, CAVLC) */
int PictureInterlace; /* [IN] Enables the interlace mode */
int Transform8x8Mode; /* [IN] Allow 8x8 transform(This is allowed only for high profile) */
- int EnableMBRateControl; /* [IN] Enable macroblock-level rate control */
int DarkDisable; /* [IN] Disable adaptive rate control on dark region */
int SmoothDisable; /* [IN] Disable adaptive rate control on smooth region */
int StaticDisable; /* [IN] Disable adaptive rate control on static region */
@@ -170,7 +187,6 @@
} ExynosVideoEncH264Param;
typedef struct _ExynosVideoEncMpeg4Param {
- int EnableMBRateControl; /* [IN] Enable macroblock-level rate control, MFC6.x Only */
/* MPEG4 specific parameters */
int ProfileIDC; /* [IN] profile */
int LevelIDC; /* [IN] level */
@@ -183,7 +199,6 @@
} ExynosVideoEncMpeg4Param;
typedef struct _ExynosVideoEncH263Param {
- int EnableMBRateControl; /* [IN] Enable macroblock-level rate control, MFC6.x Only */
/* H.263 specific parameters */
int FrameRate; /* [IN] rate control parameter(frame rate) */
} ExynosVideoEncH263Param;
@@ -211,11 +226,12 @@
ExynosVideoErrorType (*Set_FrameTag)(void *pHandle, int frameTag);
int (*Get_FrameTag)(void *pHandle);
int (*Get_ActualBufferCount)(void *pHandle);
- ExynosVideoErrorType (*Enable_Cacheable)(void *pHandle);
ExynosVideoErrorType (*Set_DisplayDelay)(void *pHandle, int delay);
ExynosVideoErrorType (*Enable_PackedPB)(void *pHandle);
ExynosVideoErrorType (*Enable_LoopFilter)(void *pHandle);
ExynosVideoErrorType (*Enable_SliceMode)(void *pHandle);
+ ExynosVideoErrorType (*Enable_SEIParsing)(void *pHandle);
+ ExynosVideoErrorType (*Get_FramePackingInfo)(void *pHandle, ExynosVideoFramePacking *pFramepacking);
} ExynosVideoDecOps;
typedef struct _ExynosVideoEncOps {
@@ -238,6 +254,7 @@
unsigned int nSize;
/* Add new ops at the end of structure, no order change */
+ ExynosVideoErrorType (*Enable_Cacheable)(void *pHandle);
ExynosVideoErrorType (*Set_Shareable)(void *pHandle);
ExynosVideoErrorType (*Get_BufferInfo)(void *pHandle, int nIndex, ExynosVideoBuffer *pBuffer);
ExynosVideoErrorType (*Set_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
@@ -254,6 +271,7 @@
unsigned int nSize;
/* Add new ops at the end of structure, no order change */
+ ExynosVideoErrorType (*Enable_Cacheable)(void *pHandle);
ExynosVideoErrorType (*Set_Shareable)(void *pHandle);
ExynosVideoErrorType (*Get_BufferInfo)(void *pHandle, int nIndex, ExynosVideoBuffer *pBuffer);
ExynosVideoErrorType (*Set_Geometry)(void *pHandle, ExynosVideoGeometry *bufferConf);
diff --git a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoDec.h b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoDec.h
index c218469..d40571f 100644
--- a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoDec.h
+++ b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoDec.h
@@ -31,6 +31,10 @@
#define VIDEO_DECODER_OUTBUF_PLANES 2
#define VIDEO_DECODER_POLL_TIMEOUT 25
+#define OPERATE_BIT(x, mask, shift) ((x & (mask << shift)) >> shift)
+#define FRAME_PACK_SEI_INFO_NUM 4
+
+
typedef struct _ExynosVideoDecContext {
int hDec;
ExynosVideoBoolType bShareInbuf;
diff --git a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoEnc.h b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoEnc.h
index 2411b4d..a0d8383 100644
--- a/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoEnc.h
+++ b/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include/ExynosVideoEnc.h
@@ -42,6 +42,8 @@
ExynosVideoGeometry outbufGeometry;
int nInbufs;
int nOutbufs;
+ ExynosVideoBoolType bStreamonInbuf;
+ ExynosVideoBoolType bStreamonOutbuf;
void *pPrivate;
} ExynosVideoEncContext;
diff --git a/exynos_omx/openmax/exynos_omx/Android.mk b/exynos_omx/openmax/exynos_omx/Android.mk
index dc5facd..9874df8 100644
--- a/exynos_omx/openmax/exynos_omx/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/Android.mk
@@ -19,6 +19,7 @@
include $(EXYNOS_OMX_COMPONENT)/video/enc/Android.mk
include $(EXYNOS_OMX_COMPONENT)/video/enc/h264/Android.mk
+include $(EXYNOS_OMX_COMPONENT)/video/enc/mpeg4/Android.mk
ifeq ($(BOARD_USE_ALP_AUDIO), true)
include $(EXYNOS_OMX_COMPONENT)/audio/dec/Android.mk
diff --git a/exynos_omx/openmax/exynos_omx/component/audio/dec/Exynos_OMX_Adec.c b/exynos_omx/openmax/exynos_omx/component/audio/dec/Exynos_OMX_Adec.c
index 18f1b21..b1524e2 100644
--- a/exynos_omx/openmax/exynos_omx/component/audio/dec/Exynos_OMX_Adec.c
+++ b/exynos_omx/openmax/exynos_omx/component/audio/dec/Exynos_OMX_Adec.c
@@ -808,7 +808,6 @@
OMX_ERRORTYPE ret = OMX_ErrorNone;
OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_AUDIODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_AUDIODEC_COMPONENT *)pExynosComponent->hComponentHandle;
EXYNOS_OMX_BASEPORT *exynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
EXYNOS_OMX_BASEPORT *exynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
EXYNOS_OMX_DATABUFFER *inputUseBuffer = &pExynosComponent->exynosDataBuffer[INPUT_PORT_INDEX];
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.c b/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.c
index a5785a1..665fad4 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.c
@@ -239,15 +239,29 @@
goto EXIT;
}
- temp_buffer = Exynos_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes);
- if (temp_buffer == NULL) {
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
+ if ((OMX_TRUE == pVideoDec->bDRMPlayerMode) && (INPUT_PORT_INDEX == nPortIndex)) {
+ if (nSizeBytes < (DEFAULT_MFC_INPUT_BUFFER_SIZE / 2))
+ nSizeBytes = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+
+ ret = pExynosComponent->exynos_allocSecureInputBuffer(hComponent, sizeof(OMX_U8) * nSizeBytes, &temp_buffer);
+ if (OMX_ErrorNone != ret)
+ goto EXIT;
+ } else {
+ temp_buffer = Exynos_OSAL_Malloc(sizeof(OMX_U8) * nSizeBytes);
+ if (temp_buffer == NULL) {
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
}
temp_bufferHeader = (OMX_BUFFERHEADERTYPE *)Exynos_OSAL_Malloc(sizeof(OMX_BUFFERHEADERTYPE));
if (temp_bufferHeader == NULL) {
- Exynos_OSAL_Free(temp_buffer);
+ if ((OMX_TRUE == pVideoDec->bDRMPlayerMode) && (INPUT_PORT_INDEX == nPortIndex))
+ ret = pExynosComponent->exynos_freeSecureInputBuffer(hComponent, temp_buffer);
+ if (OMX_ErrorNone != ret)
+ goto EXIT;
+ else
+ Exynos_OSAL_Free(temp_buffer);
temp_buffer = NULL;
ret = OMX_ErrorInsufficientResources;
@@ -281,7 +295,13 @@
}
Exynos_OSAL_Free(temp_bufferHeader);
- Exynos_OSAL_Free(temp_buffer);
+ if ((OMX_TRUE == pVideoDec->bDRMPlayerMode) && (INPUT_PORT_INDEX == nPortIndex)) {
+ ret = pExynosComponent->exynos_freeSecureInputBuffer(hComponent, temp_buffer);
+ if (OMX_ErrorNone != ret)
+ goto EXIT;
+ } else {
+ Exynos_OSAL_Free(temp_buffer);
+ }
ret = OMX_ErrorInsufficientResources;
@@ -342,7 +362,13 @@
if (((pExynosPort->bufferStateAllocate[i] | BUFFER_STATE_FREE) != 0) && (pExynosPort->bufferHeader[i] != NULL)) {
if (pExynosPort->bufferHeader[i]->pBuffer == pBufferHdr->pBuffer) {
if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ALLOCATED) {
- Exynos_OSAL_Free(pExynosPort->bufferHeader[i]->pBuffer);
+ if ((OMX_TRUE == pVideoDec->bDRMPlayerMode) && (INPUT_PORT_INDEX == nPortIndex)) {
+ ret = pExynosComponent->exynos_freeSecureInputBuffer(hComponent, pExynosPort->bufferHeader[i]->pBuffer);
+ if (OMX_ErrorNone != ret)
+ goto EXIT;
+ } else {
+ Exynos_OSAL_Free(pExynosPort->bufferHeader[i]->pBuffer);
+ }
pExynosPort->bufferHeader[i]->pBuffer = NULL;
pBufferHdr->pBuffer = NULL;
} else if (pExynosPort->bufferStateAllocate[i] & BUFFER_STATE_ASSIGNED) {
@@ -712,8 +738,12 @@
} else {
previousFrameEOF = OMX_FALSE;
}
- if ((pExynosComponent->bUseFlagEOF == OMX_TRUE) &&
- !(inputUseBuffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) {
+
+ if (OMX_TRUE == pVideoDec->bDRMPlayerMode) {
+ flagEOF = OMX_TRUE;
+ checkedSize = checkInputStreamLen;
+ } else if ((pExynosComponent->bUseFlagEOF == OMX_TRUE) &&
+ !(inputUseBuffer->nFlags & OMX_BUFFERFLAG_CODECCONFIG)) {
flagEOF = OMX_TRUE;
checkedSize = checkInputStreamLen;
} else {
@@ -732,9 +762,69 @@
if (inputUseBuffer->nFlags & OMX_BUFFERFLAG_EOS)
pExynosComponent->bSaveFlagEOS = OMX_TRUE;
- if ((((inputData->allocSize) - (inputData->dataLen)) >= copySize)) {
- if (copySize > 0)
- Exynos_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize);
+ if ((((inputData->allocSize) - (inputData->dataLen)) >= copySize) || (OMX_TRUE == pVideoDec->bDRMPlayerMode)) {
+ if ((pVideoDec->bDRMPlayerMode == OMX_TRUE) && (copySize > 0)) {
+ void *pSrcBuf[3] = { NULL, }, *pDstBuf[3] = { NULL, };
+ OMX_U32 nFrameWidth, nFrameHeight;
+
+ /* width and height depend on input buffer size about mfc */
+ nFrameWidth = 1024;
+ nFrameHeight = 512;
+
+ pSrcBuf[0] = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, inputUseBuffer->bufferHeader->pBuffer);
+ if (NULL == pSrcBuf[0]) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to convert ION to Virt");
+ goto EXIT;
+ }
+ pDstBuf[0] = inputData->dataBuffer + inputData->dataLen;
+
+ if (OMX_TRUE != pVideoDec->bSetCscCopyFormat) {
+ unsigned int csc_src_color_format, csc_dst_color_format;
+ unsigned int cacheable = 1;
+
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatEncodedData);
+ csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatEncodedData);
+
+ csc_set_src_format(
+ pVideoDec->hCscCopy, /* handle */
+ nFrameWidth, /* width */
+ nFrameHeight, /* height */
+ 0, /* crop_left */
+ 0, /* crop_right */
+ nFrameWidth, /* crop_width */
+ nFrameHeight, /* crop_height */
+ csc_src_color_format, /* color_format */
+ cacheable); /* cacheable */
+ csc_set_dst_format(
+ pVideoDec->hCscCopy, /* handle */
+ nFrameWidth, /* width */
+ nFrameHeight, /* height */
+ 0, /* crop_left */
+ 0, /* crop_right */
+ nFrameWidth, /* crop_width */
+ nFrameHeight, /* crop_height */
+ csc_dst_color_format, /* color_format */
+ cacheable); /* cacheable */
+ pVideoDec->bSetCscCopyFormat = OMX_TRUE;
+ }
+
+ csc_set_src_buffer(
+ pVideoDec->hCscCopy, /* handle */
+ pSrcBuf[0], /* y addr */
+ NULL, /* u addr or uv addr */
+ NULL, /* v addr or none */
+ 0); /* ion fd */
+ csc_set_dst_buffer(
+ pVideoDec->hCscCopy, /* handle */
+ pDstBuf[0], /* y addr */
+ NULL, /* u addr or uv addr */
+ NULL, /* v addr or none */
+ 0); /* ion fd */
+ csc_convert(pVideoDec->hCscCopy);
+ } else {
+ if (copySize > 0)
+ Exynos_OSAL_Memcpy(inputData->dataBuffer + inputData->dataLen, checkInputStream, copySize);
+ }
inputUseBuffer->dataLen -= copySize;
inputUseBuffer->remainDataLen -= copySize;
@@ -809,6 +899,7 @@
ret = OMX_FALSE;
}
+EXIT:
FunctionOut();
return ret;
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.h b/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.h
index 911515e..b9b31e5 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.h
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/Exynos_OMX_Vdec.h
@@ -94,6 +94,14 @@
/* CSC handle */
OMX_PTR csc_handle;
OMX_U32 csc_set_format;
+
+ /* For DRM Play */
+ OMX_PTR hCscCopy;
+ OMX_BOOL bSetCscCopyFormat;
+ OMX_BOOL bDRMPlayerMode;
+
+ /* Shared Memory Handle */
+ OMX_HANDLETYPE hSharedMemory;
} EXYNOS_OMX_VIDEODEC_COMPONENT;
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Android.mk b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Android.mk
index 5676fe9..c6c7a98 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Android.mk
@@ -34,30 +34,28 @@
endif
endif
+ifeq ($(BOARD_USE_S3D_SUPPORT), true)
+LOCAL_CFLAGS += -DS3D_SUPPORT
+endif
+
LOCAL_ARM_MODE := arm
LOCAL_STATIC_LIBRARIES := libExynosOMX_Vdec libExynosOMX_OSAL libExynosOMX_Basecomponent \
libswconverter libExynosVideoApi
LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
- libExynosOMX_Resourcemanager libcsc
-
-ifeq ($(filter-out exynos5,$(TARGET_BOARD_PLATFORM)),)
-LOCAL_SHARED_LIBRARIES += libexynosgscaler
-endif
+ libExynosOMX_Resourcemanager libcsc libexynosv4l2 libion_exynos libexynosgscaler
ifeq ($(BOARD_USES_MFC_FPS),true)
LOCAL_CFLAGS += -DCONFIG_MFC_FPS
endif
-LOCAL_SHARED_LIBRARIES += libexynosv4l2
-
LOCAL_C_INCLUDES := $(EXYNOS_OMX_INC)/khronos \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_COMPONENT)/common \
$(EXYNOS_OMX_COMPONENT)/video/dec \
- $(EXYNOS_OMX_TOP)/../../../include \
+ hardware/samsung_slsi/exynos5/include \
hardware/samsung_slsi/exynos5/libcsc \
hardware/samsung_slsi/exynos5/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c
index 5f341a8..8caa517 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.c
@@ -38,12 +38,13 @@
#include "library_register.h"
#include "Exynos_OMX_H264dec.h"
#include "ExynosVideoApi.h"
+#include "Exynos_OSAL_SharedMemory.h"
#ifdef USE_ANB
#include "Exynos_OSAL_Android.h"
#endif
-/* To use CSC_METHOD_PREFER_HW or CSC_METHOD_HW in SEC OMX, gralloc should allocate physical memory using FIMC */
+/* To use CSC_METHOD_HW in SEC OMX, gralloc should allocate physical memory using FIMC */
/* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
#include "csc.h"
@@ -54,7 +55,11 @@
#define H264_DEC_NUM_OF_EXTRA_BUFFERS 7
-//#define ADD_SPS_PPS_I_FRAME
+#ifdef S3D_SUPPORT
+#define ADD_SPS_PPS_I_FRAME
+#else
+#undef ADD_SPS_PPS_I_FRAME
+#endif
//#define FULL_FRAME_SEARCH
/* H.264 Decoder Supported Levels & profiles */
@@ -71,6 +76,8 @@
{OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31},
{OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32},
{OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b},
@@ -84,6 +91,8 @@
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel41},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel42},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b},
@@ -96,10 +105,12 @@
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
- {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}};
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel41},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel42}};
-static int Check_H264_Frame(
+int Check_H264_Frame(
OMX_U8 *pInputStream,
OMX_U32 buffSize,
OMX_U32 flag,
@@ -178,7 +189,7 @@
return accessUnitSize;
}
-OMX_BOOL Check_H264_StartCode(
+static OMX_BOOL Check_H264_StartCode(
OMX_U8 *pInputStream,
OMX_U32 streamSize)
{
@@ -200,7 +211,72 @@
}
}
-OMX_ERRORTYPE Exynos_MFC_H264Dec_GetParameter(
+OMX_ERRORTYPE Exynos_H264Dec_Alloc_SecureInputBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_U32 nBufferSize,
+ OMX_INOUT OMX_PTR *pInputHandle)
+{
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_H264DEC_HANDLE *pH264Dec = pVideoDec->hCodecHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_PTR pStreamBuffer = NULL;
+
+ FunctionIn();
+
+ if (NULL == pH264Dec) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ pStreamBuffer = (OMX_PTR)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nBufferSize, SECURE_MEMORY);
+ if (NULL == pStreamBuffer) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate a secure input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ *pInputHandle = (OMX_PTR)Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pStreamBuffer);
+
+EXIT:
+ FunctionOut();
+ return ret;
+}
+
+OMX_ERRORTYPE Exynos_H264Dec_Free_SecureInputBuffer(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_INOUT OMX_PTR pInputHandle)
+{
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_H264DEC_HANDLE *pH264Dec = pVideoDec->hCodecHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_PTR pStreamBuffer = NULL;
+
+ FunctionIn();
+
+ if (NULL == pH264Dec) {
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ pStreamBuffer = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, pInputHandle);
+ if (NULL == pStreamBuffer) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to convert ION to Virt");
+ ret = OMX_ErrorInvalidState;
+ goto EXIT;
+ }
+
+ Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pStreamBuffer);
+
+EXIT:
+ FunctionOut();
+ return ret;
+}
+
+OMX_ERRORTYPE Exynos_H264Dec_GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure)
@@ -353,7 +429,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Dec_SetParameter(
+OMX_ERRORTYPE Exynos_H264Dec_SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure)
@@ -565,7 +641,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Dec_GetConfig(
+OMX_ERRORTYPE Exynos_H264Dec_GetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
OMX_PTR pComponentConfigStructure)
@@ -643,7 +719,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Dec_SetConfig(
+OMX_ERRORTYPE Exynos_H264Dec_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
OMX_PTR pComponentConfigStructure)
@@ -691,7 +767,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Dec_GetExtensionIndex(
+OMX_ERRORTYPE Exynos_H264Dec_GetExtensionIndex(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_STRING cParameterName,
OMX_OUT OMX_INDEXTYPE *pIndexType)
@@ -743,7 +819,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Dec_ComponentRoleEnum(
+OMX_ERRORTYPE Exynos_H264Dec_ComponentRoleEnum(
OMX_HANDLETYPE hComponent,
OMX_U8 *cRole,
OMX_U32 nIndex)
@@ -771,7 +847,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_DecodeThread(OMX_HANDLETYPE hComponent)
+static OMX_ERRORTYPE Exynos_H264Dec_DecodeThread(OMX_HANDLETYPE hComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
@@ -797,19 +873,6 @@
Exynos_OSAL_PerfStart(PERF_ID_DEC);
#endif
if (pVideoDec->NBDecThread.oneFrameSize > 0) {
- /* queue work for input buffer */
- pInbufOps->Enqueue(pH264Dec->hMFCH264Handle.hMFCHandle,
- (unsigned char **)&pH264Dec->hMFCH264Handle.pMFCStreamBuffer,
- (unsigned int *)&pVideoDec->NBDecThread.oneFrameSize,
- 1, NULL);
-
- pVideoDec->indexInputBuffer++;
- pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
- pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
- pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
- pExynosComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
- pExynosComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
-
pInbufOps->Dequeue(pH264Dec->hMFCH264Handle.hMFCHandle);
pVideoDec->pOutbuf = pOutbufOps->Dequeue(pH264Dec->hMFCH264Handle.hMFCHandle);
}
@@ -830,7 +893,7 @@
}
/* MFC Init */
-OMX_ERRORTYPE Exynos_MFC_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
+OMX_ERRORTYPE Exynos_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -842,8 +905,6 @@
ExynosVideoDecBufferOps *pOutbufOps = NULL;
OMX_PTR pStreamBuffer = NULL;
- OMX_PTR pStreamPhyBuffer = NULL;
- OMX_PTR hMFCHandle;
ExynosVideoBuffer bufferInfo;
ExynosVideoGeometry bufferConf;
@@ -863,55 +924,84 @@
pExynosComponent->bUseFlagEOF = OMX_FALSE;
pExynosComponent->bSaveFlagEOS = OMX_FALSE;
- /* alloc ops structure */
- pDecOps = (ExynosVideoDecOps *)malloc(sizeof(*pDecOps));
- pInbufOps = (ExynosVideoDecBufferOps *)malloc(sizeof(*pInbufOps));
- pOutbufOps = (ExynosVideoDecBufferOps *)malloc(sizeof(*pOutbufOps));
+ if (pVideoDec->bDRMPlayerMode == OMX_FALSE) {
+ /* alloc ops structure */
+ pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(*pDecOps));
+ pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pInbufOps));
+ pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pOutbufOps));
- if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
+ if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
+ ret = OMX_ErrorInsufficientResources;
+
+ if (pDecOps)
+ Exynos_OSAL_Free(pDecOps);
+
+ if (pInbufOps)
+ Exynos_OSAL_Free(pInbufOps);
+
+ if (pOutbufOps)
+ Exynos_OSAL_Free(pOutbufOps);
+
+ goto EXIT;
+ }
+
+ pVideoDec->pDecOps = pDecOps;
+ pVideoDec->pInbufOps = pInbufOps;
+ pVideoDec->pOutbufOps = pOutbufOps;
+
+ /* function pointer mapping */
+ pDecOps->nSize = sizeof(*pDecOps);
+ pInbufOps->nSize = sizeof(*pInbufOps);
+ pOutbufOps->nSize = sizeof(*pOutbufOps);
+
+ Exynos_Video_Register_Decoder(pDecOps, pInbufOps, pOutbufOps);
+
+ /* check mandatory functions for decoder ops */
+ if ((pDecOps->Init == NULL) || (pDecOps->Finalize == NULL) ||
+ (pDecOps->Get_ActualBufferCount == NULL) || (pDecOps->Set_FrameTag == NULL) ||
+#ifdef S3D_SUPPORT
+ (pDecOps->Enable_SEIParsing == NULL) || (pDecOps->Get_FramePackingInfo == NULL) ||
+#endif
+ (pDecOps->Get_FrameTag == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* check mandatory functions for buffer ops */
+ if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) ||
+ (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) ||
+ (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) ||
+ (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) ||
+ (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* alloc context, open, querycap */
+ pH264Dec->hMFCH264Handle.hMFCHandle = pVideoDec->pDecOps->Init();
+ if (pH264Dec->hMFCH264Handle.hMFCHandle == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ } else {
+ pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
+ pDecOps = pVideoDec->pDecOps;
+ pInbufOps = pVideoDec->pInbufOps;
+ pExynosComponent->bUseFlagEOF = OMX_TRUE;
+ }
+
+#ifdef S3D_SUPPORT
+ /*S3D: Enable SEI parsing to check Frame Packing */
+ if (pDecOps->Enable_SEIParsing(pH264Dec->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Enable SEI Parsing");
ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
-
- pVideoDec->pDecOps = pDecOps;
- pVideoDec->pInbufOps = pInbufOps;
- pVideoDec->pOutbufOps = pOutbufOps;
-
- /* function pointer mapping */
- pDecOps->nSize = sizeof(*pDecOps);
- pInbufOps->nSize = sizeof(*pInbufOps);
- pOutbufOps->nSize = sizeof(*pOutbufOps);
-
- Exynos_Video_Register_Decoder(pDecOps, pInbufOps, pOutbufOps);
-
- /* check mandatory functions for decoder ops */
- if ((pDecOps->Init == NULL) || (pDecOps->Finalize == NULL) ||
- (pDecOps->Get_ActualBufferCount == NULL) || (pDecOps->Set_FrameTag == NULL) ||
- (pDecOps->Get_FrameTag == NULL)) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
-
- /* check mandatory functions for buffer ops */
- if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) ||
- (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) ||
- (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) ||
- (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) ||
- (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
-
- /* alloc context, open, querycap */
- pH264Dec->hMFCH264Handle.hMFCHandle = pVideoDec->pDecOps->Init();
- if (pH264Dec->hMFCH264Handle.hMFCHandle == NULL) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
+#endif
Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
@@ -928,6 +1018,12 @@
}
}
+ /* cacheable for source */
+ if (pInbufOps->Enable_Cacheable) {
+ if (pInbufOps->Enable_Cacheable(pH264Dec->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for input buffer");
+ }
+
/* setup input buffer */
if (pInbufOps->Setup(pH264Dec->hMFCH264Handle.hMFCHandle, MFC_INPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
@@ -962,7 +1058,7 @@
Exynos_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
Exynos_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
if (OMX_ErrorNone == Exynos_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
- Exynos_MFC_DecodeThread,
+ Exynos_H264Dec_DecodeThread,
pOMXComponent)) {
pH264Dec->hMFCH264Handle.returnCodec = VIDEO_TRUE;
}
@@ -979,15 +1075,35 @@
pExynosComponent->getAllDelayBuffer = OMX_FALSE;
-#ifdef USE_ANB
#if defined(USE_CSC_FIMC) || defined(USE_CSC_GSCALER)
+ if (OMX_FALSE != pVideoDec->bDRMPlayerMode) {
+ pVideoDec->hCscCopy = csc_init(CSC_METHOD_HW);
+ pVideoDec->bSetCscCopyFormat = OMX_FALSE;
+ csc_method = CSC_METHOD_HW;
+#ifdef USE_CSC_GSCALER
+ csc_set_hw_property(pVideoDec->hCscCopy, CSC_HW_PROPERTY_FIXED_NODE, 2);
+ csc_set_hw_property(pVideoDec->hCscCopy, CSC_HW_PROPERTY_MODE_DRM, pVideoDec->bDRMPlayerMode);
+#endif
+ } else {
+#if defined(USE_ANB)
if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) {
- csc_method = CSC_METHOD_PREFER_HW;
+ csc_method = CSC_METHOD_HW;
}
#endif
+ }
#endif
- pVideoDec->csc_handle = csc_init(&csc_method);
+
+ if (OMX_SEC_COLOR_FormatNV12TPhysicalAddress !=
+ pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ pVideoDec->csc_handle = csc_init(csc_method);
pVideoDec->csc_set_format = OMX_FALSE;
+#ifdef USE_CSC_GSCALER
+ if (CSC_METHOD_HW == csc_method) {
+ csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 1);
+ csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_MODE_DRM, pVideoDec->bDRMPlayerMode);
+ }
+#endif
+ }
EXIT:
FunctionOut();
@@ -996,7 +1112,7 @@
}
/* MFC Terminate */
-OMX_ERRORTYPE Exynos_MFC_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+OMX_ERRORTYPE Exynos_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -1039,16 +1155,18 @@
pVideoDec->NBDecThread.hDecFrameStart = NULL;
}
- if (hMFCHandle != NULL) {
- pInbufOps->Stop(hMFCHandle);
- pOutbufOps->Stop(hMFCHandle);
- pDecOps->Finalize(hMFCHandle);
+ if (pVideoDec->bDRMPlayerMode == OMX_FALSE) {
+ if (hMFCHandle != NULL) {
+ pInbufOps->Stop(hMFCHandle);
+ pOutbufOps->Stop(hMFCHandle);
+ pDecOps->Finalize(hMFCHandle);
- free(pInbufOps);
- free(pOutbufOps);
- free(pDecOps);
+ Exynos_OSAL_Free(pInbufOps);
+ Exynos_OSAL_Free(pOutbufOps);
+ Exynos_OSAL_Free(pDecOps);
- pH264Dec->hMFCH264Handle.hMFCHandle = NULL;
+ pH264Dec->hMFCH264Handle.hMFCHandle = NULL;
+ }
}
if (pVideoDec->csc_handle != NULL) {
@@ -1056,13 +1174,138 @@
pVideoDec->csc_handle = NULL;
}
+ if (NULL != pVideoDec->hCscCopy) {
+ csc_deinit(pVideoDec->hCscCopy);
+ pVideoDec->hCscCopy = NULL;
+ }
+
EXIT:
FunctionOut();
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264_Decode_Configure(
+#ifdef S3D_SUPPORT
+static OMX_BOOL Exynos_H264Dec_Check_FramePacking(OMX_COMPONENTTYPE *pOMXComponent)
+{
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+ ExynosVideoDecOps *pDecOps = pVideoDec->pDecOps;
+ OMX_BOOL ret = OMX_FALSE;
+ ExynosVideoFramePacking framePacking;
+
+ /* Get Frame packing information*/
+ if (pDecOps->Get_FramePackingInfo(pH264Dec->hMFCH264Handle.hMFCHandle, &framePacking) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Get Frame Packing Information");
+ ret = OMX_FALSE;
+ goto EXIT;
+ }
+
+ if (framePacking.available) {
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "arrangement ID: 0x%08x", framePacking.arrangement_id);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "arrangement_type: %d", framePacking.arrangement_type);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "content_interpretation_type: %d", framePacking.content_interpretation_type);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "current_frame_is_frame0_flag: %d", framePacking.current_frame_is_frame0_flag);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "spatial_flipping_flag: %d", framePacking.spatial_flipping_flag);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "fr0X:%d fr0Y:%d fr0X:%d fr0Y:%d", framePacking.frame0_grid_pos_x,
+ framePacking.frame0_grid_pos_y, framePacking.frame1_grid_pos_x, framePacking.frame1_grid_pos_y);
+
+ /* Change Outport eColorFormat based on Framepacking information*/
+ if (framePacking.arrangement_type == 3) {
+ if (framePacking.content_interpretation_type == 1) {
+ switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR;
+ break;
+ }
+ } else if (framePacking.content_interpretation_type == 2) {
+ switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL;
+ break;
+ }
+ }
+ } else if (framePacking.arrangement_type == 4) {
+ if (framePacking.content_interpretation_type == 1) {
+ switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_TB_LR;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_TB_LR;
+ break;
+ }
+ } else if (framePacking.content_interpretation_type == 2) {
+ switch (pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ case OMX_SEC_COLOR_FormatNV12Tiled:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatNV12Tiled_TB_RL;
+ break;
+ case OMX_COLOR_FormatYUV420SemiPlanar:
+ case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL;
+ break;
+ case OMX_COLOR_FormatYUV420Planar:
+ default:
+ pExynosOutputPort->portDefinition.format.video.eColorFormat = OMX_SEC_COLOR_FormatYUV420Planar_TB_RL;
+ break;
+ }
+ }
+ }
+
+ /** Send Port Settings changed call back - output color format change */
+ (*(pExynosComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pExynosComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ 0,
+ NULL);
+
+ if ((pExynosOutputPort->cropRectangle.nTop != 0) || (pExynosOutputPort->cropRectangle.nLeft != 0)) {
+ /** Send crop info call back **/
+ (*(pExynosComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pExynosComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ OMX_IndexConfigCommonOutputCrop,
+ NULL);
+ }
+ pH264Dec->hMFCH264Handle.bS3DMode = OMX_TRUE;
+ Exynos_OSAL_SleepMillisec(0);
+ ret = OMX_TRUE;
+ }
+
+EXIT:
+ return ret;
+}
+#endif
+
+static OMX_ERRORTYPE Exynos_H264Dec_Configure(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1111,6 +1354,14 @@
}
}
+ /* cacheable for dest */
+ if (pExynosOutputPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ if (pOutbufOps->Enable_Cacheable) {
+ if (pOutbufOps->Enable_Cacheable(pH264Dec->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for output buffer");
+ }
+ }
+
/* input buffer enqueue for header parsing */
if (pInbufOps->Enqueue(pH264Dec->hMFCH264Handle.hMFCHandle,
(unsigned char **)&pH264Dec->hMFCH264Handle.pMFCStreamBuffer,
@@ -1138,59 +1389,6 @@
}
}
- pExynosOutputPort->cropRectangle.nTop = bufferConf.cropRect.nTop;
- pExynosOutputPort->cropRectangle.nLeft = bufferConf.cropRect.nLeft;
- pExynosOutputPort->cropRectangle.nWidth = bufferConf.cropRect.nWidth;
- pExynosOutputPort->cropRectangle.nHeight = bufferConf.cropRect.nHeight;
-
- if ((bufferConf.nFrameWidth != bufferConf.cropRect.nWidth) ||
- (bufferConf.nFrameHeight != bufferConf.cropRect.nHeight)) {
- pExynosInputPort->portDefinition.format.video.nFrameWidth = bufferConf.nFrameWidth;
- pExynosInputPort->portDefinition.format.video.nFrameHeight = bufferConf.nFrameHeight;
- pExynosInputPort->portDefinition.format.video.nStride = ((bufferConf.nFrameWidth + 15) & (~15));
- pExynosInputPort->portDefinition.format.video.nSliceHeight = ((bufferConf.nFrameHeight + 15) & (~15));
-
- Exynos_UpdateFrameSize(pOMXComponent);
-
- /** Send crop info call back **/
- (*(pExynosComponent->pCallbacks->EventHandler))
- (pOMXComponent,
- pExynosComponent->callbackData,
- OMX_EventPortSettingsChanged, /* The command was completed */
- OMX_DirOutput, /* This is the port index */
- OMX_IndexConfigCommonOutputCrop,
- NULL);
- }
-
- if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != bufferConf.nFrameWidth) ||
- (pExynosInputPort->portDefinition.format.video.nFrameHeight != bufferConf.nFrameHeight)) {
- pExynosInputPort->portDefinition.format.video.nFrameWidth = bufferConf.nFrameWidth;
- pExynosInputPort->portDefinition.format.video.nFrameHeight = bufferConf.nFrameHeight;
- pExynosInputPort->portDefinition.format.video.nStride = ((bufferConf.nFrameWidth + 15) & (~15));
- pExynosInputPort->portDefinition.format.video.nSliceHeight = ((bufferConf.nFrameHeight + 15) & (~15));
-
- Exynos_UpdateFrameSize(pOMXComponent);
-
- /** Send Port Settings changed call back **/
- (*(pExynosComponent->pCallbacks->EventHandler))
- (pOMXComponent,
- pExynosComponent->callbackData,
- OMX_EventPortSettingsChanged, /* The command was completed */
- OMX_DirOutput, /* This is the port index */
- 0,
- NULL);
- }
-
- /* should be done before prepare output buffer */
- if (pExynosOutputPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
- if (pVideoDec->pDecOps->Enable_Cacheable) {
- if (pVideoDec->pDecOps->Enable_Cacheable(pH264Dec->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
- }
-
/* get dpb count */
nOutbufs = pDecOps->Get_ActualBufferCount(pH264Dec->hMFCH264Handle.hMFCHandle);
if (nOutbufs < 0) {
@@ -1236,14 +1434,57 @@
ret = OMX_ErrorNone;
#endif
- pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE;
+ pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_TRUE; /* Set bConfiguredMFC to OMX_TRUE before rising Crop Event */
+
+ pExynosOutputPort->cropRectangle.nTop = bufferConf.cropRect.nTop;
+ pExynosOutputPort->cropRectangle.nLeft = bufferConf.cropRect.nLeft;
+ pExynosOutputPort->cropRectangle.nWidth = bufferConf.cropRect.nWidth;
+ pExynosOutputPort->cropRectangle.nHeight = bufferConf.cropRect.nHeight;
+
+ if ((bufferConf.nFrameWidth != bufferConf.cropRect.nWidth) ||
+ (bufferConf.nFrameHeight != bufferConf.cropRect.nHeight)) {
+ pExynosInputPort->portDefinition.format.video.nFrameWidth = bufferConf.nFrameWidth;
+ pExynosInputPort->portDefinition.format.video.nFrameHeight = bufferConf.nFrameHeight;
+ pExynosInputPort->portDefinition.format.video.nStride = ((bufferConf.nFrameWidth + 15) & (~15));
+ pExynosInputPort->portDefinition.format.video.nSliceHeight = ((bufferConf.nFrameHeight + 15) & (~15));
+
+ Exynos_UpdateFrameSize(pOMXComponent);
+
+ /** Send crop info call back **/
+ (*(pExynosComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pExynosComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ OMX_IndexConfigCommonOutputCrop,
+ NULL);
+ } else if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != bufferConf.nFrameWidth) ||
+ (pExynosInputPort->portDefinition.format.video.nFrameHeight != bufferConf.nFrameHeight)) {
+ pExynosInputPort->portDefinition.format.video.nFrameWidth = bufferConf.nFrameWidth;
+ pExynosInputPort->portDefinition.format.video.nFrameHeight = bufferConf.nFrameHeight;
+ pExynosInputPort->portDefinition.format.video.nStride = ((bufferConf.nFrameWidth + 15) & (~15));
+ pExynosInputPort->portDefinition.format.video.nSliceHeight = ((bufferConf.nFrameHeight + 15) & (~15));
+
+ Exynos_UpdateFrameSize(pOMXComponent);
+
+ /** Send Port Settings changed call back **/
+ (*(pExynosComponent->pCallbacks->EventHandler))
+ (pOMXComponent,
+ pExynosComponent->callbackData,
+ OMX_EventPortSettingsChanged, /* The command was completed */
+ OMX_DirOutput, /* This is the port index */
+ 0,
+ NULL);
+ }
+
pH264Dec->hMFCH264Handle.returnCodec = VIDEO_TRUE;
EXIT:
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264_Decode_Nonblock(
+/* nonblock */
+static OMX_ERRORTYPE Exynos_H264Dec_Decode(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1264,13 +1505,14 @@
OMX_U32 FrameBufferUVSize = 0;
OMX_BOOL outputDataValid = OMX_FALSE;
- OMX_PTR outputYPhyAddr, outputCPhyAddr, outputYVirAddr, outputCVirAddr;
+ OMX_PTR outputPhyAddr[2], outputVirAddr[2];
+ unsigned int outputDataSize[2];
int outputImgWidth, outputImgHeight;
FunctionIn();
if (pH264Dec->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
- ret = Exynos_MFC_H264_Decode_Configure(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_H264Dec_Configure(pOMXComponent, pInputData, pOutputData);
goto EXIT;
}
@@ -1297,10 +1539,24 @@
if (pVideoDec->pOutbuf != NULL) {
status = pVideoDec->pOutbuf->displayStatus;
- outputYVirAddr = pVideoDec->pOutbuf->planes[0].addr;
- outputCVirAddr = pVideoDec->pOutbuf->planes[1].addr;
+ outputVirAddr[0] = pVideoDec->pOutbuf->planes[0].addr;
+ outputVirAddr[1] = pVideoDec->pOutbuf->planes[1].addr;
+ outputDataSize[0] = pVideoDec->pOutbuf->planes[0].dataSize;
+ outputDataSize[1] = pVideoDec->pOutbuf->planes[1].dataSize;
+ } else {
+ status = VIDEO_FRAME_STATUS_DECODING_ONLY;
}
+#ifdef S3D_SUPPORT
+ /* Check Whether frame packing information is available */
+ if (pVideoDec->bThumbnailMode == OMX_FALSE && pH264Dec->hMFCH264Handle.bS3DMode == OMX_FALSE) {
+ if (Exynos_H264Dec_Check_FramePacking(pOMXComponent)) {
+ ret = OMX_ErrorInputDataDecodeYet;
+ goto EXIT;
+ }
+ }
+#endif
+
outputImgWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth;
outputImgHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight;
@@ -1314,10 +1570,8 @@
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
- /* For timestamp correction. if mfc support frametype detect */
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoDec->pOutbuf->frameType);
#ifdef NEED_TIMESTAMP_REORDER
- if ((pVideoDec->pOutbuf->frameType == VIDEO_FRAME_I) ||
+ if ((pVideoDec->pOutbuf != NULL) && (pVideoDec->pOutbuf->frameType == VIDEO_FRAME_I) ||
(pH264Dec->hMFCH264Handle.bFlashPlayerMode == OMX_TRUE)) {
pOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
pOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
@@ -1408,7 +1662,7 @@
oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
}
- if ((Check_H264_StartCode(pInputData->dataBuffer, oneFrameSize) == OMX_TRUE) &&
+ if ((((pVideoDec->bDRMPlayerMode != OMX_FALSE) && (oneFrameSize > 0)) || (Check_H264_StartCode(pInputData->dataBuffer, oneFrameSize) == OMX_TRUE)) &&
((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
if ((ret != OMX_ErrorInputDataDecodeYet) || (pExynosComponent->getAllDelayBuffer == OMX_TRUE)) {
pDecOps->Set_FrameTag(pH264Dec->hMFCH264Handle.hMFCHandle, pH264Dec->hMFCH264Handle.indexTimestamp);
@@ -1419,6 +1673,11 @@
pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+ pInbufOps->Enqueue(pH264Dec->hMFCH264Handle.hMFCHandle,
+ (unsigned char **)&pH264Dec->hMFCH264Handle.pMFCStreamBuffer,
+ (unsigned int *)&pVideoDec->NBDecThread.oneFrameSize,
+ 1, NULL);
+
/* mfc decode start */
Exynos_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
@@ -1426,6 +1685,13 @@
Exynos_OSAL_SleepMillisec(0);
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pH264Dec->hMFCH264Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pH264Dec->hMFCH264Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pExynosComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pExynosComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
(pExynosComponent->bSaveFlagEOS == OMX_TRUE) &&
(outputDataValid == OMX_FALSE)) {
@@ -1452,8 +1718,8 @@
int actualHeight = outputImgHeight;
int actualImageSize = actualWidth * actualHeight;
- pSrcBuf[0] = outputYVirAddr;
- pSrcBuf[1] = outputCVirAddr;
+ pSrcBuf[0] = outputVirAddr[0];
+ pSrcBuf[1] = outputVirAddr[1];
pYUVBuf[0] = (unsigned char *)pOutputBuf;
pYUVBuf[1] = (unsigned char *)pOutputBuf + actualImageSize;
@@ -1472,10 +1738,10 @@
if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
(pExynosOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
/* if use Post copy address structure */
- Exynos_OSAL_Memcpy(pYUVBuf[0], &(outputYPhyAddr), sizeof(outputYPhyAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 1), &(outputCPhyAddr), sizeof(outputCPhyAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 2), &(outputYVirAddr), sizeof(outputYVirAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 3), &(outputCVirAddr), sizeof(outputCVirAddr));
+ Exynos_OSAL_Memcpy(pYUVBuf[0], &(outputPhyAddr[0]), sizeof(outputPhyAddr[0]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 1), &(outputPhyAddr[1]), sizeof(outputPhyAddr[1]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 2), &(outputVirAddr[0]), sizeof(outputVirAddr[0]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 3), &(outputVirAddr[1]), sizeof(outputVirAddr[1]));
pOutputData->dataLen = (actualWidth * actualHeight * 3) / 2;
} else {
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "YUV420p out for ThumbnailMode/Flash player mode");
@@ -1484,16 +1750,34 @@
#endif
switch (pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
case OMX_SEC_COLOR_FormatNV12Tiled:
- Exynos_OSAL_Memcpy(pOutputBuf, outputYVirAddr, FrameBufferYSize);
- Exynos_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputCVirAddr, FrameBufferUVSize);
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_RL:
+#endif
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
+ csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
break;
case OMX_COLOR_FormatYUV420SemiPlanar:
case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL:
+#endif
csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
break;
case OMX_COLOR_FormatYUV420Planar:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_RL:
+#endif
default:
csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420Planar);
@@ -1503,9 +1787,10 @@
csc_get_method(pVideoDec->csc_handle, &csc_method);
#ifdef ENABLE_PHYSICAL_ADDRESS
if ((pExynosOutputPort->bIsANBEnabled == OMX_TRUE) && (csc_method == CSC_METHOD_HW)) {
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12TPhysicalAddress);
Exynos_OSAL_GetPhysANB(pOutputData->dataBuffer, pYUVBuf);
- pSrcBuf[0] = outputYPhyAddr;
- pSrcBuf[1] = outputCPhyAddr;
+ pSrcBuf[0] = outputPhyAddr[0];
+ pSrcBuf[1] = outputPhyAddr[1];
}
#endif
if (pVideoDec->csc_set_format == OMX_FALSE) {
@@ -1554,8 +1839,10 @@
Exynos_OSAL_UnlockANB(pOutputData->dataBuffer);
}
#endif
- /* enqueue all available output buffers */
- pOutbufOps->Enqueue_All(pH264Dec->hMFCH264Handle.hMFCHandle);
+ pOutbufOps->Enqueue(pH264Dec->hMFCH264Handle.hMFCHandle,
+ (unsigned char **)&outputVirAddr,
+ (unsigned int *)&outputDataSize,
+ 2, NULL);
} else {
pOutputData->dataLen = 0;
}
@@ -1567,7 +1854,7 @@
}
/* MFC Decode */
-OMX_ERRORTYPE Exynos_MFC_H264Dec_bufferProcess(
+OMX_ERRORTYPE Exynos_H264Dec_BufferProcess(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1592,7 +1879,7 @@
goto EXIT;
}
- ret = Exynos_MFC_H264_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_H264Dec_Decode(pOMXComponent, pInputData, pOutputData);
if (ret != OMX_ErrorNone) {
if (ret == OMX_ErrorInputDataDecodeYet) {
@@ -1620,6 +1907,87 @@
return ret;
}
+OMX_ERRORTYPE Exynos_H264Dec_DRM_Open(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
+ ExynosVideoDecOps *pDecOps = NULL;
+ ExynosVideoDecBufferOps *pInbufOps = NULL;
+ ExynosVideoDecBufferOps *pOutbufOps = NULL;
+
+ FunctionIn();
+
+ pH264Dec->hMFCH264Handle.bConfiguredMFC = OMX_FALSE;
+ pExynosComponent->bUseFlagEOF = OMX_FALSE;
+ pExynosComponent->bSaveFlagEOS = OMX_FALSE;
+
+ /* alloc ops structure */
+ pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(*pDecOps));
+ pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pInbufOps));
+ pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pOutbufOps));
+
+ if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
+ ret = OMX_ErrorInsufficientResources;
+
+ if (pDecOps)
+ Exynos_OSAL_Free(pDecOps);
+
+ if (pInbufOps)
+ Exynos_OSAL_Free(pInbufOps);
+
+ if (pOutbufOps)
+ Exynos_OSAL_Free(pOutbufOps);
+
+ goto EXIT;
+ }
+
+ pVideoDec->pDecOps = pDecOps;
+ pVideoDec->pInbufOps = pInbufOps;
+ pVideoDec->pOutbufOps = pOutbufOps;
+
+ /* function pointer mapping */
+ pDecOps->nSize = sizeof(*pDecOps);
+ pInbufOps->nSize = sizeof(*pInbufOps);
+ pOutbufOps->nSize = sizeof(*pOutbufOps);
+
+ Exynos_Video_Register_Decoder(pDecOps, pInbufOps, pOutbufOps);
+
+ /* check mandatory functions for decoder ops */
+ if ((pDecOps->Init == NULL) || (pDecOps->Finalize == NULL) ||
+ (pDecOps->Get_ActualBufferCount == NULL) || (pDecOps->Set_FrameTag == NULL) ||
+ (pDecOps->Get_FrameTag == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* check mandatory functions for buffer ops */
+ if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) ||
+ (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) ||
+ (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) ||
+ (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) ||
+ (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ /* alloc context, open, querycap */
+ pH264Dec->hMFCH264Handle.hMFCHandle = pVideoDec->pDecOps->Init();
+ if (pH264Dec->hMFCH264Handle.hMFCHandle == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+EXIT:
+ FunctionOut();
+
+ return ret;
+}
+
OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(
OMX_HANDLETYPE hComponent,
OMX_STRING componentName)
@@ -1632,6 +2000,7 @@
EXYNOS_H264DEC_HANDLE *pH264Dec = NULL;
OMX_BOOL bFlashPlayerMode = OMX_FALSE;
+ OMX_BOOL bDRMPlayerMode = OMX_FALSE;
int i = 0;
FunctionIn();
@@ -1641,11 +2010,12 @@
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__);
goto EXIT;
}
- if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DEC, componentName) == 0) {
- bFlashPlayerMode = OMX_FALSE;
+
+ if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DRM_DEC, componentName) == 0) {
+ bDRMPlayerMode = OMX_TRUE;
} else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_FP_DEC, componentName) == 0) {
bFlashPlayerMode = OMX_TRUE;
- } else {
+ } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DEC, componentName) != 0) {
ret = OMX_ErrorBadParameter;
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__);
goto EXIT;
@@ -1680,12 +2050,18 @@
pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle;
pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pH264Dec;
- if (bFlashPlayerMode == OMX_TRUE)
+ if (OMX_TRUE == bDRMPlayerMode)
+ Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DRM_DEC);
+ else if (bFlashPlayerMode == OMX_TRUE)
Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_FP_DEC);
else
Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DEC);
+ pVideoDec->bDRMPlayerMode = bDRMPlayerMode;
pH264Dec->hMFCH264Handle.bFlashPlayerMode = bFlashPlayerMode;
+#ifdef S3D_SUPPORT
+ pH264Dec->hMFCH264Handle.bS3DMode = OMX_FALSE;
+#endif
/* Set componentVersion */
pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER;
@@ -1725,6 +2101,9 @@
if (bFlashPlayerMode != OMX_FALSE) {
pExynosPort->portDefinition.nBufferCountActual = MAX_H264_FP_VIDEO_INPUTBUFFER_NUM;
pExynosPort->portDefinition.nBufferCountMin = MAX_H264_FP_VIDEO_INPUTBUFFER_NUM;
+ } else if(bDRMPlayerMode != OMX_FALSE) {
+ pExynosPort->portDefinition.nBufferCountActual = MAX_H264_DRM_VIDEO_INPUTBUFFER_NUM;
+ pExynosPort->portDefinition.nBufferCountMin = MAX_H264_DRM_VIDEO_INPUTBUFFER_NUM;
}
/* Output port */
@@ -1753,21 +2132,36 @@
pH264Dec->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel4;
}
- pOMXComponent->GetParameter = &Exynos_MFC_H264Dec_GetParameter;
- pOMXComponent->SetParameter = &Exynos_MFC_H264Dec_SetParameter;
- pOMXComponent->GetConfig = &Exynos_MFC_H264Dec_GetConfig;
- pOMXComponent->SetConfig = &Exynos_MFC_H264Dec_SetConfig;
- pOMXComponent->GetExtensionIndex = &Exynos_MFC_H264Dec_GetExtensionIndex;
- pOMXComponent->ComponentRoleEnum = &Exynos_MFC_H264Dec_ComponentRoleEnum;
+ pOMXComponent->GetParameter = &Exynos_H264Dec_GetParameter;
+ pOMXComponent->SetParameter = &Exynos_H264Dec_SetParameter;
+ pOMXComponent->GetConfig = &Exynos_H264Dec_GetConfig;
+ pOMXComponent->SetConfig = &Exynos_H264Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Exynos_H264Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Exynos_H264Dec_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
- pExynosComponent->exynos_mfc_componentInit = &Exynos_MFC_H264Dec_Init;
- pExynosComponent->exynos_mfc_componentTerminate = &Exynos_MFC_H264Dec_Terminate;
- pExynosComponent->exynos_mfc_bufferProcess = &Exynos_MFC_H264Dec_bufferProcess;
+ pExynosComponent->exynos_mfc_componentInit = &Exynos_H264Dec_Init;
+ pExynosComponent->exynos_mfc_componentTerminate = &Exynos_H264Dec_Terminate;
+ pExynosComponent->exynos_mfc_bufferProcess = &Exynos_H264Dec_BufferProcess;
pExynosComponent->exynos_checkInputFrame = &Check_H264_Frame;
- pExynosComponent->exynos_allocSecureInputBuffer = NULL;
- pExynosComponent->exynos_freeSecureInputBuffer = NULL;
+ pExynosComponent->exynos_allocSecureInputBuffer = &Exynos_H264Dec_Alloc_SecureInputBuffer;
+ pExynosComponent->exynos_freeSecureInputBuffer = &Exynos_H264Dec_Free_SecureInputBuffer;
+
+ if (OMX_TRUE == bDRMPlayerMode) {
+ pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open();
+ if (NULL == pVideoDec->hSharedMemory) {
+ Exynos_OSAL_Free(pH264Dec);
+ pH264Dec = pVideoDec->hCodecHandle = NULL;
+ Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent);
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ ret = Exynos_H264Dec_DRM_Open(pExynosComponent);
+ if (OMX_ErrorNone != ret)
+ goto EXIT;
+ }
pExynosComponent->currentState = OMX_StateLoaded;
@@ -1779,6 +2173,35 @@
return ret;
}
+OMX_ERRORTYPE Exynos_H264Dec_DRM_Close(OMX_HANDLETYPE hComponent)
+{
+ EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)hComponent;
+ EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle;
+ ExynosVideoDecOps *pDecOps = pVideoDec->pDecOps;
+ ExynosVideoDecBufferOps *pInbufOps = pVideoDec->pInbufOps;
+ ExynosVideoDecBufferOps *pOutbufOps = pVideoDec->pOutbufOps;
+ OMX_PTR hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+
+ FunctionIn();
+
+ if (hMFCHandle != NULL) {
+ pInbufOps->Stop(hMFCHandle);
+ pOutbufOps->Stop(hMFCHandle);
+ pDecOps->Finalize(hMFCHandle);
+
+ Exynos_OSAL_Free(pInbufOps);
+ Exynos_OSAL_Free(pOutbufOps);
+ Exynos_OSAL_Free(pDecOps);
+
+ pH264Dec->hMFCH264Handle.hMFCHandle = NULL;
+ }
+
+EXIT:
+ FunctionOut();
+ return ret;
+}
+
OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -1802,6 +2225,15 @@
pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
if (pH264Dec != NULL) {
+ OMX_PTR hMFCHandle = NULL;
+ hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle;
+ if ((hMFCHandle != NULL) && (pVideoDec->bDRMPlayerMode == OMX_TRUE)) {
+ Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory);
+ ret = Exynos_H264Dec_DRM_Close(pVideoDec);
+ if (OMX_ErrorNone != ret)
+ goto EXIT;
+ }
+
Exynos_OSAL_Free(pH264Dec);
pH264Dec = ((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL;
}
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.h b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.h
index f18e6c4..4442d8f 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.h
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/h264/Exynos_OMX_H264dec.h
@@ -35,6 +35,8 @@
#define MAX_H264_FP_VIDEO_INPUTBUFFER_NUM 4
#define MAX_H264_FP_VIDEO_OUTPUTBUFFER_NUM 4
+#define MAX_H264_DRM_VIDEO_INPUTBUFFER_NUM 3
+
typedef struct _EXYNOS_MFC_H264DEC_HANDLE
{
OMX_HANDLETYPE hMFCHandle;
@@ -44,6 +46,9 @@
OMX_U32 outputIndexTimestamp;
OMX_BOOL bConfiguredMFC;
OMX_BOOL bFlashPlayerMode;
+#ifdef S3D_SUPPORT
+ OMX_BOOL bS3DMode;
+#endif
OMX_S32 returnCodec;
} EXYNOS_MFC_H264DEC_HANDLE;
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Android.mk b/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Android.mk
index a0f9161..5ee99ec 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Android.mk
@@ -35,25 +35,19 @@
LOCAL_STATIC_LIBRARIES := libExynosOMX_Vdec libExynosOMX_OSAL libExynosOMX_Basecomponent \
libswconverter libExynosVideoApi
LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
- libExynosOMX_Resourcemanager libcsc
-
-ifeq ($(filter-out exynos5,$(TARGET_BOARD_PLATFORM)),)
-LOCAL_SHARED_LIBRARIES += libexynosgscaler
-endif
+ libExynosOMX_Resourcemanager libcsc libexynosv4l2 libion_exynos libexynosgscaler
ifeq ($(BOARD_USES_MFC_FPS),true)
LOCAL_CFLAGS += -DCONFIG_MFC_FPS
endif
-LOCAL_SHARED_LIBRARIES += libexynosv4l2
-
LOCAL_C_INCLUDES := $(EXYNOS_OMX_INC)/khronos \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_COMPONENT)/common \
$(EXYNOS_OMX_COMPONENT)/video/dec \
- $(EXYNOS_OMX_TOP)/../../../include \
+ hardware/samsung_slsi/exynos5/include \
hardware/samsung_slsi/exynos5/libcsc \
hardware/samsung_slsi/exynos5/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c b/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c
index a50cb82..fabd4fa 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/mpeg4/Exynos_OMX_Mpeg4dec.c
@@ -43,7 +43,7 @@
#include "Exynos_OSAL_Android.h"
#endif
-/* To use CSC_METHOD_PREFER_HW or CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
+/* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
/* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
#include "csc.h"
@@ -116,7 +116,7 @@
static OMX_BOOL gbFIMV1 = OMX_FALSE;
-static int Check_Mpeg4_Frame(
+int Check_Mpeg4_Frame(
OMX_U8 *pInputStream,
OMX_U32 buffSize,
OMX_U32 flag,
@@ -189,7 +189,7 @@
return --len;
}
-static int Check_H263_Frame(
+int Check_H263_Frame(
OMX_U8 *pInputStream,
OMX_U32 buffSize,
OMX_U32 flag,
@@ -255,7 +255,7 @@
return --len;
}
-OMX_BOOL Check_Stream_PrefixCode(
+static OMX_BOOL Check_Stream_StartCode(
OMX_U8 *pInputStream,
OMX_U32 streamSize,
CODEC_TYPE codecType)
@@ -277,17 +277,41 @@
}
break;
case CODEC_TYPE_H263:
- if (streamSize > 0)
- return OMX_TRUE;
- else
+ if (streamSize > 0) {
+ unsigned startCode = 0xFFFFFFFF;
+ unsigned pTypeMask = 0x03;
+ unsigned pType = 0;
+ OMX_U32 len = 0;
+ int readStream;
+ /* Check PSC(Picture Start Code) : 0000 0000 0000 0000 1000 00 */
+ while (((startCode << 8 >> 10) != 0x20) || (pType != 0x02)) {
+ readStream = *(pInputStream + len);
+ startCode = (startCode << 8) | readStream;
+
+ readStream = *(pInputStream + len + 1);
+ pType = readStream & pTypeMask;
+
+ len++;
+ if (len > 0x3)
+ break;
+ }
+
+ if (len > 0x3) {
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "[%s] Picture Start Code Missing", __FUNCTION__);
+ return OMX_FALSE;
+ } else {
+ return OMX_TRUE;
+ }
+ } else {
return OMX_FALSE;
+ }
default:
Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "%s: undefined codec type (%d)", __FUNCTION__, codecType);
return OMX_FALSE;
}
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_GetParameter(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure)
@@ -481,7 +505,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_SetParameter(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure)
@@ -734,7 +758,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_GetConfig(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_GetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure)
@@ -777,7 +801,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_SetConfig(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_SetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure)
@@ -820,7 +844,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_GetExtensionIndex(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_GetExtensionIndex(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_STRING cParameterName,
OMX_OUT OMX_INDEXTYPE *pIndexType)
@@ -872,7 +896,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_ComponentRoleEnum(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_ComponentRoleEnum(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_U8 *cRole,
OMX_IN OMX_U32 nIndex)
@@ -920,7 +944,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_DecodeThread(
+static OMX_ERRORTYPE Exynos_Mpeg4Dec_DecodeThread(
OMX_HANDLETYPE hComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -946,19 +970,6 @@
Exynos_OSAL_PerfStart(PERF_ID_DEC);
#endif
if (pVideoDec->NBDecThread.oneFrameSize > 0) {
- /* queue work for input buffer */
- pInbufOps->Enqueue(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle,
- (unsigned char **)&pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer,
- (unsigned int *)&pVideoDec->NBDecThread.oneFrameSize,
- 1, NULL);
-
- pVideoDec->indexInputBuffer++;
- pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
- pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
- pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
- pExynosComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
- pExynosComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
-
pInbufOps->Dequeue(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle);
pVideoDec->pOutbuf = pOutbufOps->Dequeue(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle);
}
@@ -979,7 +990,7 @@
}
/* MFC Init */
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_Init(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_Init(
OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -1011,13 +1022,23 @@
pExynosComponent->bSaveFlagEOS = OMX_FALSE;
/* alloc ops structure */
- pDecOps = (ExynosVideoDecOps *)malloc(sizeof(*pDecOps));
- pInbufOps = (ExynosVideoDecBufferOps *)malloc(sizeof(*pInbufOps));
- pOutbufOps = (ExynosVideoDecBufferOps *)malloc(sizeof(*pOutbufOps));
+ pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(*pDecOps));
+ pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pInbufOps));
+ pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pOutbufOps));
if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
ret = OMX_ErrorInsufficientResources;
+
+ if (pDecOps)
+ Exynos_OSAL_Free(pDecOps);
+
+ if (pInbufOps)
+ Exynos_OSAL_Free(pInbufOps);
+
+ if (pOutbufOps)
+ Exynos_OSAL_Free(pOutbufOps);
+
goto EXIT;
}
@@ -1078,6 +1099,12 @@
}
}
+ /* cacheable for source */
+ if (pInbufOps->Enable_Cacheable) {
+ if (pInbufOps->Enable_Cacheable(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for input buffer");
+ }
+
/* setup input buffer */
if (pInbufOps->Setup(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle, MFC_INPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
@@ -1112,7 +1139,7 @@
Exynos_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
Exynos_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
if (OMX_ErrorNone == Exynos_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
- Exynos_MFC_DecodeThread,
+ Exynos_Mpeg4Dec_DecodeThread,
pOMXComponent)) {
pMpeg4Dec->hMFCMpeg4Handle.returnCodec = VIDEO_TRUE;
}
@@ -1129,15 +1156,24 @@
pExynosComponent->getAllDelayBuffer = OMX_FALSE;
-#ifdef USE_ANB
+#if defined(USE_ANB)
#if defined(USE_CSC_FIMC) || defined(USE_CSC_GSCALER)
if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) {
- csc_method = CSC_METHOD_PREFER_HW;
+ csc_method = CSC_METHOD_HW;
}
#endif
#endif
- pVideoDec->csc_handle = csc_init(&csc_method);
+
+ if (OMX_SEC_COLOR_FormatNV12TPhysicalAddress !=
+ pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ pVideoDec->csc_handle = csc_init(csc_method);
pVideoDec->csc_set_format = OMX_FALSE;
+#ifdef USE_CSC_GSCALER
+ if (CSC_METHOD_HW == csc_method) {
+ csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 1);
+ }
+#endif
+ }
EXIT:
FunctionOut();
@@ -1146,7 +1182,7 @@
}
/* MFC Terminate */
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_Terminate(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_Terminate(
OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -1195,9 +1231,9 @@
pOutbufOps->Stop(hMFCHandle);
pDecOps->Finalize(hMFCHandle);
- free(pInbufOps);
- free(pOutbufOps);
- free(pDecOps);
+ Exynos_OSAL_Free(pInbufOps);
+ Exynos_OSAL_Free(pOutbufOps);
+ Exynos_OSAL_Free(pDecOps);
pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle = NULL;
}
@@ -1213,7 +1249,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4_Decode_Configure(
+static OMX_ERRORTYPE Exynos_Mpeg4Dec_Configure(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1268,6 +1304,14 @@
}
}
+ /* cacheable for dest */
+ if (pExynosOutputPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ if (pOutbufOps->Enable_Cacheable) {
+ if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for output buffer");
+ }
+ }
+
/* input buffer enqueue for header parsing */
if (pInbufOps->Enqueue(hMFCHandle,
(unsigned char **)&pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer,
@@ -1314,16 +1358,6 @@
NULL);
}
- /* should be done before prepare output buffer */
- if (pExynosOutputPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
- if (pVideoDec->pDecOps->Enable_Cacheable) {
- if (pVideoDec->pDecOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
- }
-
/* get dpb count */
nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
if (nOutbufs < 0) {
@@ -1377,7 +1411,8 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4_Decode_Nonblock(
+/* nonblock */
+static OMX_ERRORTYPE Exynos_Mpeg4Dec_Decode(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1397,14 +1432,15 @@
ExynosVideoDecBufferOps *pInbufOps = pVideoDec->pInbufOps;
ExynosVideoDecBufferOps *pOutbufOps = pVideoDec->pOutbufOps;
- OMX_PTR outputYPhyAddr, outputCPhyAddr, outputYVirAddr, outputCVirAddr;
+ OMX_PTR outputPhyAddr[2], outputVirAddr[2];
+ unsigned int outputDataSize[2];
int bufWidth, bufHeight, outputImgWidth, outputImgHeight;
OMX_S32 configValue;
FunctionIn();
if (pMpeg4Dec->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
- ret = Exynos_MFC_Mpeg4_Decode_Configure(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_Mpeg4Dec_Configure(pOMXComponent, pInputData, pOutputData);
goto EXIT;
}
@@ -1431,8 +1467,12 @@
if (pVideoDec->pOutbuf != NULL) {
status = pVideoDec->pOutbuf->displayStatus;
- outputYVirAddr = pVideoDec->pOutbuf->planes[0].addr;
- outputCVirAddr = pVideoDec->pOutbuf->planes[1].addr;
+ outputVirAddr[0] = pVideoDec->pOutbuf->planes[0].addr;
+ outputVirAddr[1] = pVideoDec->pOutbuf->planes[1].addr;
+ outputDataSize[0] = pVideoDec->pOutbuf->planes[0].dataSize;
+ outputDataSize[1] = pVideoDec->pOutbuf->planes[1].dataSize;
+ } else {
+ status = VIDEO_FRAME_STATUS_DECODING_ONLY;
}
outputImgWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth;
@@ -1448,10 +1488,8 @@
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
- /* For timestamp correction. if mfc support frametype detect */
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoDec->pOutbuf->frameType);
#ifdef NEED_TIMESTAMP_REORDER
- if (pVideoDec->pOutbuf->frameType == VIDEO_FRAME_I) {
+ if ((pVideoDec->pOutbuf != NULL) && (pVideoDec->pOutbuf->frameType == VIDEO_FRAME_I)) {
pOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
pOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
pMpeg4Dec->hMFCMpeg4Handle.outputIndexTimestamp = indexTimestamp;
@@ -1540,7 +1578,7 @@
oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
}
- if ((Check_Stream_PrefixCode(pInputData->dataBuffer, oneFrameSize, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) &&
+ if ((Check_Stream_StartCode(pInputData->dataBuffer, oneFrameSize, pMpeg4Dec->hMFCMpeg4Handle.codecType) == OMX_TRUE) &&
((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
if ((ret != OMX_ErrorInputDataDecodeYet) || (pExynosComponent->getAllDelayBuffer == OMX_TRUE)) {
pDecOps->Set_FrameTag(hMFCHandle, pMpeg4Dec->hMFCMpeg4Handle.indexTimestamp);
@@ -1551,6 +1589,11 @@
pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+ pInbufOps->Enqueue(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle,
+ (unsigned char **)&pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer,
+ (unsigned int *)&pVideoDec->NBDecThread.oneFrameSize,
+ 1, NULL);
+
/* mfc decode start */
Exynos_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
@@ -1558,6 +1601,13 @@
Exynos_OSAL_SleepMillisec(0);
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pMpeg4Dec->hMFCMpeg4Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pExynosComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pExynosComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
(pExynosComponent->bSaveFlagEOS == OMX_TRUE) &&
(outputDataValid == OMX_FALSE)) {
@@ -1583,8 +1633,8 @@
int height = outputImgHeight;
int imageSize = outputImgWidth * outputImgHeight;
- pSrcBuf[0] = outputYVirAddr;
- pSrcBuf[1] = outputCVirAddr;
+ pSrcBuf[0] = outputVirAddr[0];
+ pSrcBuf[1] = outputVirAddr[1];
pYUVBuf[0] = (unsigned char *)pOutputBuf;
pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
@@ -1602,10 +1652,10 @@
if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
(pExynosOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
/* if use Post copy address structure */
- Exynos_OSAL_Memcpy(pYUVBuf[0], &(outputYPhyAddr), sizeof(outputYPhyAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 1), &(outputCPhyAddr), sizeof(outputCPhyAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 2), &(outputYVirAddr), sizeof(outputYVirAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 3), &(outputCVirAddr), sizeof(outputCVirAddr));
+ Exynos_OSAL_Memcpy(pYUVBuf[0], &(outputPhyAddr[0]), sizeof(outputPhyAddr[0]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 1), &(outputPhyAddr[1]), sizeof(outputPhyAddr[1]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 2), &(outputVirAddr[0]), sizeof(outputVirAddr[0]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 3), &(outputVirAddr[1]), sizeof(outputVirAddr[1]));
pOutputData->dataLen = (width * height * 3) / 2;
} else {
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "YUV420 out for ThumbnailMode");
@@ -1614,8 +1664,8 @@
#endif
switch (pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
case OMX_SEC_COLOR_FormatNV12Tiled:
- Exynos_OSAL_Memcpy(pOutputBuf, outputYVirAddr, FrameBufferYSize);
- Exynos_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputCVirAddr, FrameBufferUVSize);
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
+ csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
break;
case OMX_COLOR_FormatYUV420SemiPlanar:
@@ -1633,9 +1683,10 @@
csc_get_method(pVideoDec->csc_handle, &csc_method);
#ifdef ENABLE_PHYSICAL_ADDRESS
if ((pExynosOutputPort->bIsANBEnabled == OMX_TRUE) && (csc_method == CSC_METHOD_HW)) {
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12TPhysicalAddress);
Exynos_OSAL_GetPhysANB(pOutputData->dataBuffer, pYUVBuf);
- pSrcBuf[0] = outputYPhyAddr;
- pSrcBuf[1] = outputCPhyAddr;
+ pSrcBuf[0] = outputPhyAddr[0];
+ pSrcBuf[1] = outputPhyAddr[1];
}
#endif
if (pVideoDec->csc_set_format == OMX_FALSE) {
@@ -1685,8 +1736,10 @@
Exynos_OSAL_UnlockANB(pOutputData->dataBuffer);
}
#endif
- /* enqueue all available output buffers */
- pOutbufOps->Enqueue_All(hMFCHandle);
+ pOutbufOps->Enqueue(pMpeg4Dec->hMFCMpeg4Handle.hMFCHandle,
+ (unsigned char **)&outputVirAddr,
+ (unsigned int *)&outputDataSize,
+ 2, NULL);
} else {
pOutputData->dataLen = 0;
}
@@ -1698,7 +1751,7 @@
}
/* MFC Decode */
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Dec_bufferProcess(
+OMX_ERRORTYPE Exynos_Mpeg4Dec_BufferProcess(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1722,7 +1775,7 @@
goto EXIT;
}
- ret = Exynos_MFC_Mpeg4_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_Mpeg4Dec_Decode(pOMXComponent, pInputData, pOutputData);
if (ret != OMX_ErrorNone) {
if (ret == OMX_ErrorInputDataDecodeYet) {
@@ -1889,17 +1942,17 @@
}
}
- pOMXComponent->GetParameter = &Exynos_MFC_Mpeg4Dec_GetParameter;
- pOMXComponent->SetParameter = &Exynos_MFC_Mpeg4Dec_SetParameter;
- pOMXComponent->GetConfig = &Exynos_MFC_Mpeg4Dec_GetConfig;
- pOMXComponent->SetConfig = &Exynos_MFC_Mpeg4Dec_SetConfig;
- pOMXComponent->GetExtensionIndex = &Exynos_MFC_Mpeg4Dec_GetExtensionIndex;
- pOMXComponent->ComponentRoleEnum = &Exynos_MFC_Mpeg4Dec_ComponentRoleEnum;
+ pOMXComponent->GetParameter = &Exynos_Mpeg4Dec_GetParameter;
+ pOMXComponent->SetParameter = &Exynos_Mpeg4Dec_SetParameter;
+ pOMXComponent->GetConfig = &Exynos_Mpeg4Dec_GetConfig;
+ pOMXComponent->SetConfig = &Exynos_Mpeg4Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Exynos_Mpeg4Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Exynos_Mpeg4Dec_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
- pExynosComponent->exynos_mfc_componentInit = &Exynos_MFC_Mpeg4Dec_Init;
- pExynosComponent->exynos_mfc_componentTerminate = &Exynos_MFC_Mpeg4Dec_Terminate;
- pExynosComponent->exynos_mfc_bufferProcess = &Exynos_MFC_Mpeg4Dec_bufferProcess;
+ pExynosComponent->exynos_mfc_componentInit = &Exynos_Mpeg4Dec_Init;
+ pExynosComponent->exynos_mfc_componentTerminate = &Exynos_Mpeg4Dec_Terminate;
+ pExynosComponent->exynos_mfc_bufferProcess = &Exynos_Mpeg4Dec_BufferProcess;
if (codecType == CODEC_TYPE_MPEG4)
pExynosComponent->exynos_checkInputFrame = &Check_Mpeg4_Frame;
else
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Android.mk b/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Android.mk
index ab32a6e..78b6d0e 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Android.mk
@@ -35,25 +35,19 @@
LOCAL_STATIC_LIBRARIES := libExynosOMX_Vdec libExynosOMX_OSAL libExynosOMX_Basecomponent \
libswconverter libExynosVideoApi
LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
- libExynosOMX_Resourcemanager libcsc
-
-ifeq ($(filter-out exynos5,$(TARGET_BOARD_PLATFORM)),)
-LOCAL_SHARED_LIBRARIES += libexynosgscaler
-endif
+ libExynosOMX_Resourcemanager libcsc libexynosv4l2 libion_exynos libexynosgscaler
ifeq ($(BOARD_USES_MFC_FPS),true)
LOCAL_CFLAGS += -DCONFIG_MFC_FPS
endif
-LOCAL_SHARED_LIBRARIES += libexynosv4l2
-
LOCAL_C_INCLUDES := $(EXYNOS_OMX_INC)/khronos \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_COMPONENT)/common \
$(EXYNOS_OMX_COMPONENT)/video/dec \
- $(EXYNOS_OMX_TOP)/../../../include \
+ hardware/samsung_slsi/exynos5/include \
hardware/samsung_slsi/exynos5/libcsc \
hardware/samsung_slsi/exynos5/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include
diff --git a/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Exynos_OMX_Vp8dec.c b/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Exynos_OMX_Vp8dec.c
index 1a43839..cc21e72 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Exynos_OMX_Vp8dec.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/dec/vp8/Exynos_OMX_Vp8dec.c
@@ -43,7 +43,7 @@
#include "Exynos_OSAL_Android.h"
#endif
-/* To use CSC_METHOD_PREFER_HW or CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
+/* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
/* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
#include "csc.h"
@@ -56,7 +56,7 @@
//#define FULL_FRAME_SEARCH /* Full frame search not support*/
-static int Check_VP8_Frame(
+int Check_Vp8_Frame(
OMX_U8 *pInputStream,
int buffSize,
OMX_U32 flag,
@@ -106,7 +106,7 @@
return buffSize;
}
-OMX_BOOL Check_VP8_StartCode(
+static OMX_BOOL Check_Vp8_StartCode(
OMX_U8 *pInputStream,
OMX_U32 streamSize)
{
@@ -127,7 +127,7 @@
return OMX_TRUE;
}
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_GetParameter(
+OMX_ERRORTYPE Exynos_Vp8Dec_GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure)
@@ -206,7 +206,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_SetParameter(
+OMX_ERRORTYPE Exynos_Vp8Dec_SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure)
@@ -374,7 +374,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_GetConfig(
+OMX_ERRORTYPE Exynos_Vp8Dec_GetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
OMX_PTR pComponentConfigStructure)
@@ -422,7 +422,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_SetConfig(
+OMX_ERRORTYPE Exynos_Vp8Dec_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
OMX_PTR pComponentConfigStructure)
@@ -470,7 +470,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_GetExtensionIndex(
+OMX_ERRORTYPE Exynos_Vp8Dec_GetExtensionIndex(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_STRING cParameterName,
OMX_OUT OMX_INDEXTYPE *pIndexType)
@@ -522,7 +522,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_ComponentRoleEnum(
+OMX_ERRORTYPE Exynos_Vp8Dec_ComponentRoleEnum(
OMX_HANDLETYPE hComponent,
OMX_U8 *cRole,
OMX_U32 nIndex)
@@ -550,7 +550,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_DecodeThread(
+static OMX_ERRORTYPE Exynos_Vp8Dec_DecodeThread(
OMX_HANDLETYPE hComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -577,19 +577,6 @@
Exynos_OSAL_PerfStart(PERF_ID_DEC);
#endif
if (pVideoDec->NBDecThread.oneFrameSize > 0) {
- /* queue work for input buffer */
- pInbufOps->Enqueue(pVp8Dec->hMFCVp8Handle.hMFCHandle,
- (unsigned char **)&pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer,
- (unsigned int *)&pVideoDec->NBDecThread.oneFrameSize,
- 1, NULL);
-
- pVideoDec->indexInputBuffer++;
- pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
- pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
- pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
- pExynosComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
- pExynosComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
-
pInbufOps->Dequeue(pVp8Dec->hMFCVp8Handle.hMFCHandle);
pVideoDec->pOutbuf = pOutbufOps->Dequeue(pVp8Dec->hMFCVp8Handle.hMFCHandle);
}
@@ -610,7 +597,7 @@
}
/* MFC Init */
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_Init(
+OMX_ERRORTYPE Exynos_Vp8Dec_Init(
OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -643,13 +630,23 @@
pExynosComponent->bSaveFlagEOS = OMX_FALSE;
/* alloc ops structure */
- pDecOps = (ExynosVideoDecOps *)malloc(sizeof(*pDecOps));
- pInbufOps = (ExynosVideoDecBufferOps *)malloc(sizeof(*pInbufOps));
- pOutbufOps = (ExynosVideoDecBufferOps *)malloc(sizeof(*pOutbufOps));
+ pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(*pDecOps));
+ pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pInbufOps));
+ pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(*pOutbufOps));
if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer");
ret = OMX_ErrorInsufficientResources;
+
+ if (pDecOps)
+ Exynos_OSAL_Free(pDecOps);
+
+ if (pInbufOps)
+ Exynos_OSAL_Free(pInbufOps);
+
+ if (pOutbufOps)
+ Exynos_OSAL_Free(pOutbufOps);
+
goto EXIT;
}
@@ -707,6 +704,12 @@
}
}
+ /* cacheable for source */
+ if (pInbufOps->Enable_Cacheable) {
+ if (pInbufOps->Enable_Cacheable(pVp8Dec->hMFCVp8Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for input buffer");
+ }
+
/* setup input buffer */
if (pInbufOps->Setup(pVp8Dec->hMFCVp8Handle.hMFCHandle, MFC_INPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
@@ -741,7 +744,7 @@
Exynos_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameStart));
Exynos_OSAL_SemaphoreCreate(&(pVideoDec->NBDecThread.hDecFrameEnd));
if (OMX_ErrorNone == Exynos_OSAL_ThreadCreate(&pVideoDec->NBDecThread.hNBDecodeThread,
- Exynos_MFC_DecodeThread,
+ Exynos_Vp8Dec_DecodeThread,
pOMXComponent)) {
pVp8Dec->hMFCVp8Handle.returnCodec = VIDEO_TRUE;
}
@@ -758,15 +761,24 @@
pExynosComponent->getAllDelayBuffer = OMX_FALSE;
-#ifdef USE_ANB
+#if defined(USE_ANB)
#if defined(USE_CSC_FIMC) || defined(USE_CSC_GSCALER)
if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) {
- csc_method = CSC_METHOD_PREFER_HW;
+ csc_method = CSC_METHOD_HW;
}
#endif
#endif
- pVideoDec->csc_handle = csc_init(&csc_method);
- pVideoDec->csc_set_format = OMX_FALSE;
+
+ if (OMX_SEC_COLOR_FormatNV12TPhysicalAddress !=
+ pExynosOutputPort->portDefinition.format.video.eColorFormat) {
+ pVideoDec->csc_handle = csc_init(csc_method);
+ pVideoDec->csc_set_format = OMX_FALSE;
+#ifdef USE_CSC_GSCALER
+ if (CSC_METHOD_HW == csc_method) {
+ csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 1);
+ }
+#endif
+ }
EXIT:
FunctionOut();
@@ -775,7 +787,7 @@
}
/* MFC Terminate */
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_Terminate(
+OMX_ERRORTYPE Exynos_Vp8Dec_Terminate(
OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
@@ -824,9 +836,9 @@
pOutbufOps->Stop(hMFCHandle);
pDecOps->Finalize(hMFCHandle);
- free(pInbufOps);
- free(pOutbufOps);
- free(pDecOps);
+ Exynos_OSAL_Free(pInbufOps);
+ Exynos_OSAL_Free(pOutbufOps);
+ Exynos_OSAL_Free(pDecOps);
pVp8Dec->hMFCVp8Handle.hMFCHandle = NULL;
}
@@ -842,7 +854,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8_Decode_Configure(
+static OMX_ERRORTYPE Exynos_Vp8Dec_Configure(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -890,6 +902,14 @@
}
}
+ /* cacheable for dest */
+ if (pExynosOutputPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
+ if (pOutbufOps->Enable_Cacheable) {
+ if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for output buffer");
+ }
+ }
+
/* input buffer enqueue for header parsing */
if (pInbufOps->Enqueue(hMFCHandle,
(unsigned char **)&pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer,
@@ -936,16 +956,6 @@
NULL);
}
- /* should be done before prepare output buffer */
- if (pExynosOutputPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV12TPhysicalAddress) {
- if (pVideoDec->pDecOps->Enable_Cacheable) {
- if (pVideoDec->pDecOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) {
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
- }
-
/* get dpb count */
nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle);
if (nOutbufs < 0) {
@@ -994,7 +1004,9 @@
FunctionOut();
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_VP8_Decode_Nonblock(
+
+/* nonblock */
+static OMX_ERRORTYPE Exynos_Vp8Dec_Decode(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1015,13 +1027,14 @@
ExynosVideoDecBufferOps *pInbufOps = pVideoDec->pInbufOps;
ExynosVideoDecBufferOps *pOutbufOps = pVideoDec->pOutbufOps;
- OMX_PTR outputYPhyAddr, outputCPhyAddr, outputYVirAddr, outputCVirAddr;
+ OMX_PTR outputPhyAddr[2], outputVirAddr[2];
+ unsigned int outputDataSize[2];
int bufWidth, bufHeight, outputImgWidth, outputImgHeight;
FunctionIn();
if (pVp8Dec->hMFCVp8Handle.bConfiguredMFC == OMX_FALSE) {
- ret = Exynos_MFC_VP8_Decode_Configure(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_Vp8Dec_Configure(pOMXComponent, pInputData, pOutputData);
goto EXIT;
}
@@ -1048,8 +1061,12 @@
if (pVideoDec->pOutbuf != NULL) {
status = pVideoDec->pOutbuf->displayStatus;
- outputYVirAddr = pVideoDec->pOutbuf->planes[0].addr;
- outputCVirAddr = pVideoDec->pOutbuf->planes[1].addr;
+ outputVirAddr[0] = pVideoDec->pOutbuf->planes[0].addr;
+ outputVirAddr[1] = pVideoDec->pOutbuf->planes[1].addr;
+ outputDataSize[0] = pVideoDec->pOutbuf->planes[0].dataSize;
+ outputDataSize[1] = pVideoDec->pOutbuf->planes[1].dataSize;
+ } else {
+ status = VIDEO_FRAME_STATUS_DECODING_ONLY;
}
outputImgWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth;
@@ -1065,10 +1082,8 @@
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
- /* For timestamp correction. if mfc support frametype detect */
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoDec->pOutbuf->frameType);
#ifdef NEED_TIMESTAMP_REORDER
- if (pVideoDec->pOutbuf->frameType == VIDEO_FRAME_I) {
+ if ((pVideoDec->pOutbuf != NULL) && (pVideoDec->pOutbuf->frameType == VIDEO_FRAME_I)) {
pOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
pOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
pVp8Dec->hMFCVp8Handle.outputIndexTimestamp = indexTimestamp;
@@ -1158,7 +1173,7 @@
oneFrameSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize;
}
- if ((Check_VP8_StartCode(pInputData->dataBuffer, oneFrameSize) == OMX_TRUE) &&
+ if ((Check_Vp8_StartCode(pInputData->dataBuffer, oneFrameSize) == OMX_TRUE) &&
((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) {
if ((ret != OMX_ErrorInputDataDecodeYet) || (pExynosComponent->getAllDelayBuffer == OMX_TRUE)) {
pDecOps->Set_FrameTag(hMFCHandle, pVp8Dec->hMFCVp8Handle.indexTimestamp);
@@ -1169,6 +1184,11 @@
pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].dataSize = oneFrameSize;
pVideoDec->NBDecThread.oneFrameSize = oneFrameSize;
+ pInbufOps->Enqueue(pVp8Dec->hMFCVp8Handle.hMFCHandle,
+ (unsigned char **)&pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer,
+ (unsigned int *)&pVideoDec->NBDecThread.oneFrameSize,
+ 1, NULL);
+
/* mfc decode start */
Exynos_OSAL_SemaphorePost(pVideoDec->NBDecThread.hDecFrameStart);
pVideoDec->NBDecThread.bDecoderRun = OMX_TRUE;
@@ -1176,6 +1196,13 @@
Exynos_OSAL_SleepMillisec(0);
+ pVideoDec->indexInputBuffer++;
+ pVideoDec->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pVp8Dec->hMFCVp8Handle.pMFCStreamPhyBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].PhyAddr;
+ pExynosComponent->processData[INPUT_PORT_INDEX].dataBuffer = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].VirAddr;
+ pExynosComponent->processData[INPUT_PORT_INDEX].allocSize = pVideoDec->MFCDecInputBuffer[pVideoDec->indexInputBuffer].bufferSize;
+
if ((pVideoDec->bFirstFrame == OMX_TRUE) &&
(pExynosComponent->bSaveFlagEOS == OMX_TRUE) &&
(outputDataValid == OMX_FALSE)) {
@@ -1201,8 +1228,8 @@
int height = outputImgHeight;
int imageSize = outputImgWidth * outputImgHeight;
- pSrcBuf[0] = outputYVirAddr;
- pSrcBuf[1] = outputCVirAddr;
+ pSrcBuf[0] = outputVirAddr[0];
+ pSrcBuf[1] = outputVirAddr[1];
pYUVBuf[0] = (unsigned char *)pOutputBuf;
pYUVBuf[1] = (unsigned char *)pOutputBuf + imageSize;
@@ -1220,10 +1247,10 @@
if ((pVideoDec->bThumbnailMode == OMX_FALSE) &&
(pExynosOutputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12TPhysicalAddress)) {
/* if use Post copy address structure */
- Exynos_OSAL_Memcpy(pYUVBuf[0], &(outputYPhyAddr), sizeof(outputYPhyAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 1), &(outputCPhyAddr), sizeof(outputCPhyAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 2), &(outputYVirAddr), sizeof(outputYVirAddr));
- Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 3), &(outputCVirAddr), sizeof(outputCVirAddr));
+ Exynos_OSAL_Memcpy(pYUVBuf[0], &(outputPhyAddr[0]), sizeof(outputPhyAddr[0]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 1), &(outputPhyAddr[1]), sizeof(outputPhyAddr[1]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 2), &(outputVirAddr[0]), sizeof(outputVirAddr[0]));
+ Exynos_OSAL_Memcpy((unsigned char *)pYUVBuf[0] + (sizeof(void *) * 3), &(outputVirAddr[1]), sizeof(outputVirAddr[1]));
pOutputData->dataLen = (width * height * 3) / 2;
} else {
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "YUV420 SP/P Output mode");
@@ -1232,8 +1259,8 @@
#endif
switch (pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX].portDefinition.format.video.eColorFormat) {
case OMX_SEC_COLOR_FormatNV12Tiled:
- Exynos_OSAL_Memcpy(pOutputBuf, outputYVirAddr, FrameBufferYSize);
- Exynos_OSAL_Memcpy((unsigned char *)pOutputBuf + FrameBufferYSize, outputCVirAddr, FrameBufferUVSize);
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
+ csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12Tiled);
pOutputData->dataLen = FrameBufferYSize + FrameBufferUVSize;
break;
case OMX_COLOR_FormatYUV420SemiPlanar:
@@ -1251,9 +1278,10 @@
csc_get_method(pVideoDec->csc_handle, &csc_method);
#ifdef ENABLE_PHYSICAL_ADDRESS
if ((pExynosOutputPort->bIsANBEnabled == OMX_TRUE) && (csc_method == CSC_METHOD_HW)) {
+ csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_SEC_COLOR_FormatNV12TPhysicalAddress);
Exynos_OSAL_GetPhysANB(pOutputData->dataBuffer, pYUVBuf);
- pSrcBuf[0] = outputYPhyAddr;
- pSrcBuf[1] = outputCPhyAddr;
+ pSrcBuf[0] = outputPhyAddr[0];
+ pSrcBuf[1] = outputPhyAddr[1];
}
#endif
if (pVideoDec->csc_set_format == OMX_FALSE) {
@@ -1302,8 +1330,10 @@
Exynos_OSAL_UnlockANB(pOutputData->dataBuffer);
}
#endif
- /* enqueue all available output buffers */
- pOutbufOps->Enqueue_All(hMFCHandle);
+ pOutbufOps->Enqueue(pVp8Dec->hMFCVp8Handle.hMFCHandle,
+ (unsigned char **)&outputVirAddr,
+ (unsigned int *)&outputDataSize,
+ 2, NULL);
} else {
pOutputData->dataLen = 0;
}
@@ -1315,7 +1345,7 @@
}
/* MFC Decode */
-OMX_ERRORTYPE Exynos_MFC_VP8Dec_bufferProcess(
+OMX_ERRORTYPE Exynos_Vp8Dec_BufferProcess(
OMX_COMPONENTTYPE *pOMXComponent,
EXYNOS_OMX_DATA *pInputData,
EXYNOS_OMX_DATA *pOutputData)
@@ -1339,7 +1369,7 @@
goto EXIT;
}
- ret = Exynos_MFC_VP8_Decode_Nonblock(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_Vp8Dec_Decode(pOMXComponent, pInputData, pOutputData);
if (ret != OMX_ErrorNone) {
if (ret == OMX_ErrorInputDataDecodeYet) {
pOutputData->usedDataLen = 0;
@@ -1474,18 +1504,18 @@
pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar;
pExynosPort->portDefinition.bEnabled = OMX_TRUE;
- pOMXComponent->GetParameter = &Exynos_MFC_VP8Dec_GetParameter;
- pOMXComponent->SetParameter = &Exynos_MFC_VP8Dec_SetParameter;
- pOMXComponent->GetConfig = &Exynos_MFC_VP8Dec_GetConfig;
- pOMXComponent->SetConfig = &Exynos_MFC_VP8Dec_SetConfig;
- pOMXComponent->GetExtensionIndex = &Exynos_MFC_VP8Dec_GetExtensionIndex;
- pOMXComponent->ComponentRoleEnum = &Exynos_MFC_VP8Dec_ComponentRoleEnum;
+ pOMXComponent->GetParameter = &Exynos_Vp8Dec_GetParameter;
+ pOMXComponent->SetParameter = &Exynos_Vp8Dec_SetParameter;
+ pOMXComponent->GetConfig = &Exynos_Vp8Dec_GetConfig;
+ pOMXComponent->SetConfig = &Exynos_Vp8Dec_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Exynos_Vp8Dec_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Exynos_Vp8Dec_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
- pExynosComponent->exynos_mfc_componentInit = &Exynos_MFC_VP8Dec_Init;
- pExynosComponent->exynos_mfc_componentTerminate = &Exynos_MFC_VP8Dec_Terminate;
- pExynosComponent->exynos_mfc_bufferProcess = &Exynos_MFC_VP8Dec_bufferProcess;
- pExynosComponent->exynos_checkInputFrame = &Check_VP8_Frame;
+ pExynosComponent->exynos_mfc_componentInit = &Exynos_Vp8Dec_Init;
+ pExynosComponent->exynos_mfc_componentTerminate = &Exynos_Vp8Dec_Terminate;
+ pExynosComponent->exynos_mfc_bufferProcess = &Exynos_Vp8Dec_BufferProcess;
+ pExynosComponent->exynos_checkInputFrame = &Check_Vp8_Frame;
pExynosComponent->currentState = OMX_StateLoaded;
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/Android.mk b/exynos_omx/openmax/exynos_omx/component/video/enc/Android.mk
index b2a4865..4ae6783 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/Android.mk
@@ -13,7 +13,7 @@
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_COMPONENT)/common \
- $(EXYNOS_OMX_COMPONENT)/video/dec \
+ $(EXYNOS_OMX_COMPONENT)/video/enc \
hardware/samsung_slsi/exynos5/libcsc \
hardware/samsung_slsi/exynos5/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
index a807353..52a219f 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/Exynos_OMX_Venc.c
@@ -762,7 +762,8 @@
(pExynosPort->portDefinition.format.video.eColorFormat != OMX_SEC_COLOR_FormatNV21LPhysicalAddress)) {
if (flagEOF == OMX_TRUE) {
OMX_U32 width, height;
- unsigned int csc_src_color_format, csc_dst_color_format;
+ unsigned int csc_src_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
+ unsigned int csc_dst_color_format = omx_2_hal_pixel_format((unsigned int)OMX_COLOR_FormatYUV420SemiPlanar);
unsigned int cacheable = 1;
unsigned char *pSrcBuf[3] = {NULL, };
unsigned char *pDstBuf[3] = {NULL, };
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Android.mk b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Android.mk
index fb5ca54..bbcd940 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Android.mk
@@ -23,9 +23,7 @@
libswconverter libExynosVideoApi
LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
- libExynosOMX_Resourcemanager libcsc
-
-LOCAL_SHARED_LIBRARIES += libexynosv4l2
+ libExynosOMX_Resourcemanager libcsc libexynosv4l2
LOCAL_C_INCLUDES := $(EXYNOS_OMX_INC)/khronos \
$(EXYNOS_OMX_INC)/exynos \
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c
index 5f7852b..f561ac4 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/h264/Exynos_OMX_H264enc.c
@@ -60,6 +60,8 @@
{OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31},
{OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32},
{OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41},
+ {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b},
@@ -73,6 +75,8 @@
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32},
{OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel41},
+ {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel42},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b},
@@ -85,56 +89,62 @@
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31},
{OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32},
- {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}};
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel41},
+ {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel42}};
-OMX_U32 OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile)
+static OMX_U32 OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile)
{
- OMX_U32 ret = 0; //default OMX_VIDEO_AVCProfileMain
+ OMX_U32 ret = 0;
- if (profile == OMX_VIDEO_AVCProfileMain)
+ if (profile == OMX_VIDEO_AVCProfileBaseline)
ret = 0;
- else if (profile == OMX_VIDEO_AVCProfileHigh)
- ret = 1;
- else if (profile == OMX_VIDEO_AVCProfileBaseline)
+ else if (profile == OMX_VIDEO_AVCProfileMain)
ret = 2;
+ else if (profile == OMX_VIDEO_AVCProfileHigh)
+ ret = 4;
return ret;
}
-OMX_U32 OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level)
+static OMX_U32 OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level)
{
- OMX_U32 ret = 40; //default OMX_VIDEO_AVCLevel4
+ OMX_U32 ret = 11; //default OMX_VIDEO_AVCLevel4
if (level == OMX_VIDEO_AVCLevel1)
- ret = 10;
+ ret = 0;
else if (level == OMX_VIDEO_AVCLevel1b)
- ret = 9;
+ ret = 1;
else if (level == OMX_VIDEO_AVCLevel11)
- ret = 11;
+ ret = 2;
else if (level == OMX_VIDEO_AVCLevel12)
- ret = 12;
+ ret = 3;
else if (level == OMX_VIDEO_AVCLevel13)
- ret = 13;
+ ret = 4;
else if (level == OMX_VIDEO_AVCLevel2)
- ret = 20;
+ ret = 5;
else if (level == OMX_VIDEO_AVCLevel21)
- ret = 21;
+ ret = 6;
else if (level == OMX_VIDEO_AVCLevel22)
- ret = 22;
+ ret = 7;
else if (level == OMX_VIDEO_AVCLevel3)
- ret = 30;
+ ret = 8;
else if (level == OMX_VIDEO_AVCLevel31)
- ret = 31;
+ ret = 9;
else if (level == OMX_VIDEO_AVCLevel32)
- ret = 32;
+ ret = 10;
else if (level == OMX_VIDEO_AVCLevel4)
- ret = 40;
+ ret = 11;
+ else if (level == OMX_VIDEO_AVCLevel41)
+ ret = 12;
+ else if (level == OMX_VIDEO_AVCLevel42)
+ ret = 13;
return ret;
}
-OMX_U8 *FindDelimiter(OMX_U8 *pBuffer, OMX_U32 size)
+static OMX_U8 *FindDelimiter(OMX_U8 *pBuffer, OMX_U32 size)
{
OMX_U32 i;
@@ -149,7 +159,7 @@
return NULL;
}
-void Print_H264Enc_Param(ExynosVideoEncParam *pEncParam)
+static void Print_H264Enc_Param(ExynosVideoEncParam *pEncParam)
{
ExynosVideoEncCommonParam *pCommonParam = &pEncParam->commonParam;
ExynosVideoEncH264Param *pH264Param = &pEncParam->codecParam.h264;
@@ -193,11 +203,11 @@
/* rate control related parameters */
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d", pCommonParam->EnableFRMRateControl);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableMBRateControl : %d", pH264Param->EnableMBRateControl);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableMBRateControl : %d", pCommonParam->EnableMBRateControl);
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d", pCommonParam->CBRPeriodRf);
}
-void Set_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+static void Set_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
@@ -284,20 +294,20 @@
case OMX_Video_ControlRateVariable:
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
pCommonParam->EnableFRMRateControl = 0; /* 0: Disable, 1: Frame level RC */
- pH264Param->EnableMBRateControl = 0; /* 0: Disable, 1:MB level RC */
+ pCommonParam->EnableMBRateControl = 0; /* 0: Disable, 1:MB level RC */
pCommonParam->CBRPeriodRf = 100;
break;
case OMX_Video_ControlRateConstant:
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode CBR");
pCommonParam->EnableFRMRateControl = 1; /* 0: Disable, 1: Frame level RC */
- pH264Param->EnableMBRateControl = 1; /* 0: Disable, 1:MB level RC */
+ pCommonParam->EnableMBRateControl = 1; /* 0: Disable, 1:MB level RC */
pCommonParam->CBRPeriodRf = 10;
break;
case OMX_Video_ControlRateDisable:
default: /*Android default */
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
pCommonParam->EnableFRMRateControl = 0;
- pH264Param->EnableMBRateControl = 0;
+ pCommonParam->EnableMBRateControl = 0;
pCommonParam->CBRPeriodRf = 100;
break;
}
@@ -306,7 +316,7 @@
}
-void Change_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+static void Change_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
@@ -351,7 +361,7 @@
Set_H264Enc_Param(pExynosComponent);
}
-OMX_ERRORTYPE Exynos_MFC_H264Enc_GetParameter(
+OMX_ERRORTYPE Exynos_H264Enc_GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure)
@@ -504,7 +514,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Enc_SetParameter(
+OMX_ERRORTYPE Exynos_H264Enc_SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure)
@@ -639,7 +649,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Enc_GetConfig(
+OMX_ERRORTYPE Exynos_H264Enc_GetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
OMX_PTR pComponentConfigStructure)
@@ -698,7 +708,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Enc_SetConfig(
+OMX_ERRORTYPE Exynos_H264Enc_SetConfig(
OMX_HANDLETYPE hComponent,
OMX_INDEXTYPE nIndex,
OMX_PTR pComponentConfigStructure)
@@ -777,7 +787,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Enc_GetExtensionIndex(
+OMX_ERRORTYPE Exynos_H264Enc_GetExtensionIndex(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_STRING cParameterName,
OMX_OUT OMX_INDEXTYPE *pIndexType)
@@ -825,7 +835,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
+OMX_ERRORTYPE Exynos_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
OMX_COMPONENTTYPE *pOMXComponent = NULL;
@@ -850,7 +860,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_EncodeThread(OMX_HANDLETYPE hComponent)
+static OMX_ERRORTYPE Exynos_H264Enc_EncodeThread(OMX_HANDLETYPE hComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
@@ -900,7 +910,7 @@
}
/* MFC Init */
-OMX_ERRORTYPE Exynos_MFC_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
+OMX_ERRORTYPE Exynos_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -929,12 +939,22 @@
pExynosComponent->bSaveFlagEOS = OMX_FALSE;
/* alloc ops structure */
- pEncOps = (ExynosVideoEncOps *)malloc(sizeof(*pEncOps));
- pInbufOps = (ExynosVideoEncBufferOps *)malloc(sizeof(*pInbufOps));
- pOutbufOps = (ExynosVideoEncBufferOps *)malloc(sizeof(*pOutbufOps));
+ pEncOps = (ExynosVideoEncOps *)Exynos_OSAL_Malloc(sizeof(*pEncOps));
+ pInbufOps = (ExynosVideoEncBufferOps *)Exynos_OSAL_Malloc(sizeof(*pInbufOps));
+ pOutbufOps = (ExynosVideoEncBufferOps *)Exynos_OSAL_Malloc(sizeof(*pOutbufOps));
if ((pEncOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate encoder ops buffer");
ret = OMX_ErrorInsufficientResources;
+
+ if (pEncOps)
+ Exynos_OSAL_Free(pEncOps);
+
+ if (pInbufOps)
+ Exynos_OSAL_Free(pInbufOps);
+
+ if (pOutbufOps)
+ Exynos_OSAL_Free(pOutbufOps);
+
goto EXIT;
}
@@ -1002,7 +1022,7 @@
/* input buffer info: only 3 config values needed */
bufferConf.nFrameWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth;
bufferConf.nFrameHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight;
- bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12;
+ bufferConf.eColorFormat = pVideoEnc->encParam.commonParam.FrameMap;
/* set input buffer geometry */
if (pInbufOps->Set_Geometry) {
@@ -1013,6 +1033,12 @@
}
}
+ /* cacheable for input */
+ if (pInbufOps->Enable_Cacheable) {
+ if (pInbufOps->Enable_Cacheable(pH264Enc->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for input buffer");
+ }
+
/* setup input buffer */
if (pInbufOps->Setup(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_INPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
@@ -1043,8 +1069,8 @@
Exynos_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameStart));
Exynos_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameEnd));
if (OMX_ErrorNone == Exynos_OSAL_ThreadCreate(&pVideoEnc->NBEncThread.hNBEncodeThread,
- Exynos_MFC_EncodeThread,
- pOMXComponent)) {
+ Exynos_H264Enc_EncodeThread,
+ pOMXComponent)) {
pH264Enc->hMFCH264Handle.returnCodec = VIDEO_TRUE;
}
@@ -1052,7 +1078,7 @@
Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
pH264Enc->hMFCH264Handle.indexTimestamp = 0;
- pVideoEnc->csc_handle = csc_init(&csc_method);
+ pVideoEnc->csc_handle = csc_init(csc_method);
EXIT:
FunctionOut();
@@ -1061,7 +1087,7 @@
}
/* MFC Terminate */
-OMX_ERRORTYPE Exynos_MFC_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+OMX_ERRORTYPE Exynos_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -1102,9 +1128,9 @@
pOutbufOps->Stop(hMFCHandle);
pEncOps->Finalize(hMFCHandle);
- free(pInbufOps);
- free(pOutbufOps);
- free(pEncOps);
+ Exynos_OSAL_Free(pInbufOps);
+ Exynos_OSAL_Free(pOutbufOps);
+ Exynos_OSAL_Free(pEncOps);
pH264Enc->hMFCH264Handle.hMFCHandle = NULL;
}
@@ -1120,7 +1146,7 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_H264_Encode_Configure(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
+static OMX_ERRORTYPE Exynos_H264Enc_Configure(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -1150,6 +1176,12 @@
}
}
+ /* cacheable for output */
+ if (pOutbufOps->Enable_Cacheable) {
+ if (pOutbufOps->Enable_Cacheable(pH264Enc->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for output buffer");
+ }
+
if (pOutbufOps->Setup(pH264Enc->hMFCH264Handle.hMFCHandle, MFC_OUTPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
ret = OMX_ErrorInsufficientResources;
@@ -1172,6 +1204,11 @@
}
pVideoEnc->pOutbuf = pOutbufOps->Dequeue(pH264Enc->hMFCH264Handle.hMFCHandle);
+ if (pVideoEnc->pOutbuf == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to dequeue output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
pOutputData->dataBuffer= pVideoEnc->pOutbuf->planes[0].addr;
pOutputData->allocSize = pVideoEnc->pOutbuf->planes[0].allocSize;
@@ -1187,8 +1224,8 @@
return ret;
}
-
-OMX_ERRORTYPE Exynos_MFC_H264_Encode(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
+/* nonblock */
+static OMX_ERRORTYPE Exynos_H264Enc_Encode(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -1207,7 +1244,7 @@
FunctionIn();
if (pH264Enc->hMFCH264Handle.bConfiguredMFC == OMX_FALSE) {
- ret = Exynos_MFC_H264_Encode_Configure(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_H264Enc_Configure(pOMXComponent, pInputData, pOutputData);
if (ret != OMX_ErrorNone) {
Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: failed to configure encoder", __func__);
ret = OMX_ErrorUndefined;
@@ -1239,15 +1276,6 @@
}
}
- /* enqueue all available output buffers */
- if (pOutbufOps->Enqueue_All) {
- if (pOutbufOps->Enqueue_All(pH264Enc->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to flush all output buffer");
- ret = OMX_ErrorInsufficientResources;
- goto EXIT;
- }
- }
-
if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) && (pExynosComponent->bUseFlagEOF == OMX_FALSE))
pExynosComponent->bUseFlagEOF = OMX_TRUE;
@@ -1271,13 +1299,13 @@
case OMX_SEC_COLOR_FormatNV21LPhysicalAddress:
#ifndef USE_METADATABUFFERTYPE
/* USE_FIMC_FRAME_BUFFER */
- Exynos_OSAL_Memcpy(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[0], pInputData->dataBuffer, sizeof(OMX_PTR));
- Exynos_OSAL_Memcpy(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[1], pInputData->dataBuffer + sizeof(OMX_PTR), sizeof(OMX_PTR));
+ Exynos_OSAL_Memcpy(&(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[0]), pInputData->dataBuffer, sizeof(OMX_PTR));
+ Exynos_OSAL_Memcpy(&(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[1]), pInputData->dataBuffer + sizeof(OMX_PTR), sizeof(OMX_PTR));
#else
Exynos_OSAL_GetInfoFromMetaData(pInputData, ppBuf);
- Exynos_OSAL_Memcpy(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[0], ppBuf[0], sizeof(OMX_PTR));
- Exynos_OSAL_Memcpy(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[1], ppBuf[1], sizeof(OMX_PTR));
+ Exynos_OSAL_Memcpy(&(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[0]), ppBuf[0], sizeof(OMX_PTR));
+ Exynos_OSAL_Memcpy(&(pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer[1]), ppBuf[1], sizeof(OMX_PTR));
#endif
break;
case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
@@ -1334,12 +1362,12 @@
if (pVideoEnc->pOutbuf->frameType == VIDEO_FRAME_I)
pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "MFC Encode OK!");
ret = OMX_ErrorNone;
} else {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, pH264Enc->hMFCH264Handle.returnCodec);
- ret = OMX_ErrorUndefined;
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: failed to get output buffer, ret:%d", __FUNCTION__, pH264Enc->hMFCH264Handle.returnCodec);
+ ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
@@ -1362,18 +1390,6 @@
}
}
- if (pInbufOps->Enqueue(pH264Enc->hMFCH264Handle.hMFCHandle,
- (unsigned char **)pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer,
- (unsigned int *)pH264Enc->hMFCH264Handle.pMFCYUVDataSize,
- 2, NULL) != VIDEO_ERROR_NONE) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer");
- ret = OMX_ErrorUndefined;
- goto EXIT;
- } else {
- pVideoEnc->indexInputBuffer++;
- pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
- }
-
if (pVideoEnc->configChange == OMX_TRUE) {
Change_H264Enc_Param(pExynosComponent);
pVideoEnc->configChange = OMX_FALSE;
@@ -1385,6 +1401,27 @@
goto EXIT;
}
+ if (pOutbufOps->Enqueue(pH264Enc->hMFCH264Handle.hMFCHandle,
+ (unsigned char **)&pVideoEnc->pOutbuf->planes[0].addr,
+ (unsigned int *)&pVideoEnc->pOutbuf->planes[0].dataSize,
+ 1, NULL) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ if (pInbufOps->Enqueue(pH264Enc->hMFCH264Handle.hMFCHandle,
+ (unsigned char **)pH264Enc->hMFCH264Handle.pMFCYUVVirBuffer,
+ (unsigned int *)pH264Enc->hMFCH264Handle.pMFCYUVDataSize,
+ 2, NULL) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ } else {
+ pVideoEnc->indexInputBuffer++;
+ pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
+ }
+
/* mfc encode start */
Exynos_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
pVideoEnc->NBEncThread.bEncoderRun = OMX_TRUE;
@@ -1400,7 +1437,7 @@
}
/* MFC Encode */
-OMX_ERRORTYPE Exynos_MFC_H264Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
+OMX_ERRORTYPE Exynos_H264Enc_BufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
{
OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
@@ -1422,7 +1459,7 @@
goto EXIT;
}
- ret = Exynos_MFC_H264_Encode(pOMXComponent, pInputData, pOutputData);
+ ret = Exynos_H264Enc_Encode(pOMXComponent, pInputData, pOutputData);
if (ret != OMX_ErrorNone) {
if (ret == OMX_ErrorInputDataEncodeYet) {
pOutputData->usedDataLen = 0;
@@ -1555,17 +1592,17 @@
pH264Enc->AVCComponent[i].nPFrames = 20;
}
- pOMXComponent->GetParameter = &Exynos_MFC_H264Enc_GetParameter;
- pOMXComponent->SetParameter = &Exynos_MFC_H264Enc_SetParameter;
- pOMXComponent->GetConfig = &Exynos_MFC_H264Enc_GetConfig;
- pOMXComponent->SetConfig = &Exynos_MFC_H264Enc_SetConfig;
- pOMXComponent->GetExtensionIndex = &Exynos_MFC_H264Enc_GetExtensionIndex;
- pOMXComponent->ComponentRoleEnum = &Exynos_MFC_H264Enc_ComponentRoleEnum;
+ pOMXComponent->GetParameter = &Exynos_H264Enc_GetParameter;
+ pOMXComponent->SetParameter = &Exynos_H264Enc_SetParameter;
+ pOMXComponent->GetConfig = &Exynos_H264Enc_GetConfig;
+ pOMXComponent->SetConfig = &Exynos_H264Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Exynos_H264Enc_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Exynos_H264Enc_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
- pExynosComponent->exynos_mfc_componentInit = &Exynos_MFC_H264Enc_Init;
- pExynosComponent->exynos_mfc_componentTerminate = &Exynos_MFC_H264Enc_Terminate;
- pExynosComponent->exynos_mfc_bufferProcess = &Exynos_MFC_H264Enc_bufferProcess;
+ pExynosComponent->exynos_mfc_componentInit = &Exynos_H264Enc_Init;
+ pExynosComponent->exynos_mfc_componentTerminate = &Exynos_H264Enc_Terminate;
+ pExynosComponent->exynos_mfc_bufferProcess = &Exynos_H264Enc_BufferProcess;
pExynosComponent->exynos_checkInputFrame = NULL;
pExynosComponent->currentState = OMX_StateLoaded;
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Android.mk b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Android.mk
index 0b8255c..6e6960f 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Android.mk
@@ -13,10 +13,6 @@
LOCAL_CFLAGS :=
-ifeq ($(BOARD_NONBLOCK_MODE_PROCESS), true)
-LOCAL_CFLAGS += -DNONBLOCK_MODE_PROCESS
-endif
-
ifeq ($(BOARD_USE_METADATABUFFERTYPE), true)
LOCAL_CFLAGS += -DUSE_METADATABUFFERTYPE
endif
@@ -24,15 +20,17 @@
LOCAL_ARM_MODE := arm
LOCAL_STATIC_LIBRARIES := libExynosOMX_Venc libExynosOMX_OSAL libExynosOMX_Basecomponent \
- libseccscapi libExynosVideoApi
+ libswconverter libExynosVideoApi
LOCAL_SHARED_LIBRARIES := libc libdl libcutils libutils libui \
- libExynosOMX_Resourcemanager
+ libExynosOMX_Resourcemanager libcsc libexynosv4l2
LOCAL_C_INCLUDES := $(EXYNOS_OMX_INC)/khronos \
$(EXYNOS_OMX_INC)/exynos \
$(EXYNOS_OMX_TOP)/osal \
$(EXYNOS_OMX_TOP)/core \
$(EXYNOS_OMX_COMPONENT)/common \
- $(EXYNOS_OMX_COMPONENT)/video/enc
+ $(EXYNOS_OMX_COMPONENT)/video/enc \
+ hardware/samsung_slsi/exynos5/exynos_omx/codecs/exynos_codecs/video/exynos5/mfc_v4l2/include \
+ hardware/samsung_slsi/exynos5/libcsc
include $(BUILD_SHARED_LIBRARY)
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c
index 120012a..b143b3c 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.c
@@ -24,7 +24,6 @@
* 2010.7.15 : Create
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -39,8 +38,8 @@
#include "Exynos_OSAL_Android.h"
#include "library_register.h"
#include "Exynos_OMX_Mpeg4enc.h"
-#include "SsbSipMfcApi.h"
-#include "color_space_convertor.h"
+#include "ExynosVideoApi.h"
+#include "csc.h"
#undef EXYNOS_LOG_TAG
#define EXYNOS_LOG_TAG "EXYNOS_MPEG4_ENC"
@@ -78,7 +77,7 @@
{OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level60},
{OMX_VIDEO_H263ProfileBaseline, OMX_VIDEO_H263Level70}};
-OMX_U32 OMXMpeg4ProfileToMFCProfile(OMX_VIDEO_MPEG4PROFILETYPE profile)
+static OMX_U32 OMXMpeg4ProfileToMFCProfile(OMX_VIDEO_MPEG4PROFILETYPE profile)
{
OMX_U32 ret;
@@ -95,7 +94,8 @@
return ret;
}
-OMX_U32 OMXMpeg4LevelToMFCLevel(OMX_VIDEO_MPEG4LEVELTYPE level)
+
+static OMX_U32 OMXMpeg4LevelToMFCLevel(OMX_VIDEO_MPEG4LEVELTYPE level)
{
OMX_U32 ret;
@@ -104,23 +104,23 @@
ret = 0;
break;
case OMX_VIDEO_MPEG4Level0b:
- ret = 9;
- break;
- case OMX_VIDEO_MPEG4Level1:
ret = 1;
break;
- case OMX_VIDEO_MPEG4Level2:
+ case OMX_VIDEO_MPEG4Level1:
ret = 2;
break;
- case OMX_VIDEO_MPEG4Level3:
+ case OMX_VIDEO_MPEG4Level2:
ret = 3;
break;
+ case OMX_VIDEO_MPEG4Level3:
+ ret = 4;
+ break;
case OMX_VIDEO_MPEG4Level4:
case OMX_VIDEO_MPEG4Level4a:
- ret = 4;
+ ret = 6;
break;
case OMX_VIDEO_MPEG4Level5:
- ret = 5;
+ ret = 7;
break;
default:
ret = 0;
@@ -129,310 +129,361 @@
return ret;
}
-void Mpeg4PrintParams(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param)
+static void Print_Mpeg4Enc_Param(ExynosVideoEncParam *pEncParam)
{
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceWidth : %d\n", pMpeg4Param->SourceWidth);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceHeight : %d\n", pMpeg4Param->SourceHeight);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "IDRPeriod : %d\n", pMpeg4Param->IDRPeriod);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceMode : %d\n", pMpeg4Param->SliceMode);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh : %d\n", pMpeg4Param->RandomIntraMBRefresh);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d\n", pMpeg4Param->EnableFRMRateControl);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Bitrate : %d\n", pMpeg4Param->Bitrate);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp : %d\n", pMpeg4Param->FrameQp);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_P : %d\n", pMpeg4Param->FrameQp_P);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMax : %d\n", pMpeg4Param->QSCodeMax);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMin : %d\n", pMpeg4Param->QSCodeMin);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d\n", pMpeg4Param->CBRPeriodRf);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PadControlOn : %d\n", pMpeg4Param->PadControlOn);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LumaPadVal : %d\n", pMpeg4Param->LumaPadVal);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CbPadVal : %d\n", pMpeg4Param->CbPadVal);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CrPadVal : %d\n", pMpeg4Param->CrPadVal);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameMap : %d\n", pMpeg4Param->FrameMap);
+ ExynosVideoEncCommonParam *pCommonParam = &pEncParam->commonParam;
+ ExynosVideoEncMpeg4Param *pMpeg4Param = &pEncParam->codecParam.mpeg4;
- /* MPEG4 specific parameters */
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "ProfileIDC : %d\n", pMpeg4Param->ProfileIDC);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LevelIDC : %d\n", pMpeg4Param->LevelIDC);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_B : %d\n", pMpeg4Param->FrameQp_B);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "TimeIncreamentRes : %d\n", pMpeg4Param->TimeIncreamentRes);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "VopTimeIncreament : %d\n", pMpeg4Param->VopTimeIncreament);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceArgument : %d\n", pMpeg4Param->SliceArgument);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NumberBFrames : %d\n", pMpeg4Param->NumberBFrames);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "DisableQpelME : %d\n", pMpeg4Param->DisableQpelME);
+ /* common parameters */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceWidth : %d", pCommonParam->SourceWidth);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceHeight : %d", pCommonParam->SourceHeight);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "IDRPeriod : %d", pCommonParam->IDRPeriod);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceMode : %d", pCommonParam->SliceMode);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh : %d", pCommonParam->RandomIntraMBRefresh);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Bitrate : %d", pCommonParam->Bitrate);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp : %d", pCommonParam->FrameQp);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_P : %d", pCommonParam->FrameQp_P);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMax : %d", pCommonParam->QSCodeMax);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMin : %d", pCommonParam->QSCodeMin);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PadControlOn : %d", pCommonParam->PadControlOn);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LumaPadVal : %d", pCommonParam->LumaPadVal);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CbPadVal : %d", pCommonParam->CbPadVal);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CrPadVal : %d", pCommonParam->CrPadVal);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameMap : %d", pCommonParam->FrameMap);
+
+ /* Mpeg4 specific parameters */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "ProfileIDC : %d", pMpeg4Param->ProfileIDC);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LevelIDC : %d", pMpeg4Param->LevelIDC);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_B : %d", pMpeg4Param->FrameQp_B);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "TimeIncreamentRes : %d", pMpeg4Param->TimeIncreamentRes);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "VopTimeIncreament : %d", pMpeg4Param->VopTimeIncreament);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceArgument : %d", pMpeg4Param->SliceArgument);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NumberBFrames : %d", pMpeg4Param->NumberBFrames);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "DisableQpelME : %d", pMpeg4Param->DisableQpelME);
+
+ /* rate control related parameters */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d", pCommonParam->EnableFRMRateControl);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableMBRateControl : %d", pCommonParam->EnableMBRateControl);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d", pCommonParam->CBRPeriodRf);
}
-void H263PrintParams(SSBSIP_MFC_ENC_H263_PARAM *pH263Param)
+static void Print_H263Enc_Param(ExynosVideoEncParam *pEncParam)
{
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceWidth : %d\n", pH263Param->SourceWidth);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceHeight : %d\n", pH263Param->SourceHeight);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "IDRPeriod : %d\n", pH263Param->IDRPeriod);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceMode : %d\n", pH263Param->SliceMode);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh : %d\n", pH263Param->RandomIntraMBRefresh);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d\n", pH263Param->EnableFRMRateControl);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Bitrate : %d\n", pH263Param->Bitrate);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp : %d\n", pH263Param->FrameQp);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_P : %d\n", pH263Param->FrameQp_P);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMax : %d\n", pH263Param->QSCodeMax);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMin : %d\n", pH263Param->QSCodeMin);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d\n", pH263Param->CBRPeriodRf);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PadControlOn : %d\n", pH263Param->PadControlOn);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LumaPadVal : %d\n", pH263Param->LumaPadVal);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CbPadVal : %d\n", pH263Param->CbPadVal);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CrPadVal : %d\n", pH263Param->CrPadVal);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameMap : %d\n", pH263Param->FrameMap);
+ ExynosVideoEncCommonParam *pCommonParam = &pEncParam->commonParam;
+ ExynosVideoEncH263Param *pH263Param = &pEncParam->codecParam.h263;
- /* H.263 specific parameters */
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameRate : %d\n", pH263Param->FrameRate);
+ /* common parameters */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceWidth : %d", pCommonParam->SourceWidth);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SourceHeight : %d", pCommonParam->SourceHeight);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "IDRPeriod : %d", pCommonParam->IDRPeriod);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SliceMode : %d", pCommonParam->SliceMode);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh : %d", pCommonParam->RandomIntraMBRefresh);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Bitrate : %d", pCommonParam->Bitrate);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp : %d", pCommonParam->FrameQp);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameQp_P : %d", pCommonParam->FrameQp_P);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMax : %d", pCommonParam->QSCodeMax);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "QSCodeMin : %d", pCommonParam->QSCodeMin);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "PadControlOn : %d", pCommonParam->PadControlOn);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "LumaPadVal : %d", pCommonParam->LumaPadVal);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CbPadVal : %d", pCommonParam->CbPadVal);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CrPadVal : %d", pCommonParam->CrPadVal);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameMap : %d", pCommonParam->FrameMap);
+
+ /* H263 specific parameters */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "FrameRate : %d", pH263Param->FrameRate);
+
+ /* rate control related parameters */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableFRMRateControl : %d", pCommonParam->EnableFRMRateControl);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "EnableMBRateControl : %d", pCommonParam->EnableMBRateControl);
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "CBRPeriodRf : %d", pCommonParam->CBRPeriodRf);
}
-void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+static void Set_Mpeg4Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
- EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ ExynosVideoEncParam *pEncParam = NULL;
+ ExynosVideoEncCommonParam *pCommonParam = NULL;
+ ExynosVideoEncMpeg4Param *pMpeg4Param = NULL;
pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ pMpeg4Enc = pVideoEnc->hCodecHandle;
+ pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
- pMpeg4Param->codecType = MPEG4_ENC;
- pMpeg4Param->SourceWidth = pExynosOutputPort->portDefinition.format.video.nFrameWidth;
- pMpeg4Param->SourceHeight = pExynosOutputPort->portDefinition.format.video.nFrameHeight;
- pMpeg4Param->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1;
- pMpeg4Param->SliceMode = 0;
- pMpeg4Param->RandomIntraMBRefresh = 0;
- pMpeg4Param->Bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate;
- pMpeg4Param->QSCodeMax = 30;
- pMpeg4Param->QSCodeMin = 10;
- pMpeg4Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */
- pMpeg4Param->LumaPadVal = 0;
- pMpeg4Param->CbPadVal = 0;
- pMpeg4Param->CrPadVal = 0;
+ pEncParam = &pVideoEnc->encParam;
+ pCommonParam = &pEncParam->commonParam;
+ pMpeg4Param = &pEncParam->codecParam.mpeg4;
+ pEncParam->eCompressionFormat = VIDEO_CODING_MPEG4;
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "eCompressionFormat: %d", pEncParam->eCompressionFormat);
- pMpeg4Param->ProfileIDC = OMXMpeg4ProfileToMFCProfile(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eProfile);
- pMpeg4Param->LevelIDC = OMXMpeg4LevelToMFCLevel(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eLevel);
- pMpeg4Param->TimeIncreamentRes = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
- pMpeg4Param->VopTimeIncreament = 1;
- pMpeg4Param->SliceArgument = 0; /* MB number or byte number */
- pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */
- pMpeg4Param->DisableQpelME = 1;
-
- pMpeg4Param->FrameQp = pVideoEnc->quantization.nQpI;
- pMpeg4Param->FrameQp_P = pVideoEnc->quantization.nQpP;
- pMpeg4Param->FrameQp_B = pVideoEnc->quantization.nQpB;
-
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
- switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
- case OMX_Video_ControlRateVariable:
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
- pMpeg4Param->EnableFRMRateControl = 0; // 0: Disable, 1: Frame level RC
- pMpeg4Param->CBRPeriodRf = 100;
- break;
- case OMX_Video_ControlRateConstant:
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode CBR");
- pMpeg4Param->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC
- pMpeg4Param->CBRPeriodRf = 10;
- break;
- case OMX_Video_ControlRateDisable:
- default: //Android default
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
- pMpeg4Param->EnableFRMRateControl = 0;
- pMpeg4Param->CBRPeriodRf = 100;
- break;
- }
+ /* common parameters */
+ pCommonParam->SourceWidth = pExynosOutputPort->portDefinition.format.video.nFrameWidth;
+ pCommonParam->SourceHeight = pExynosOutputPort->portDefinition.format.video.nFrameHeight;
+ pCommonParam->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pCommonParam->SliceMode = 0;
+ pCommonParam->RandomIntraMBRefresh = 0;
+ pCommonParam->Bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate;
+ pCommonParam->FrameQp = pVideoEnc->quantization.nQpI;
+ pCommonParam->FrameQp_P = pVideoEnc->quantization.nQpP;
+ pCommonParam->QSCodeMax = 30;
+ pCommonParam->QSCodeMin = 10;
+ pCommonParam->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */
+ pCommonParam->LumaPadVal = 0;
+ pCommonParam->CbPadVal = 0;
+ pCommonParam->CrPadVal = 0;
switch ((EXYNOS_OMX_COLOR_FORMATTYPE)pExynosInputPort->portDefinition.format.video.eColorFormat) {
case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
case OMX_COLOR_FormatYUV420SemiPlanar:
case OMX_COLOR_FormatYUV420Planar:
-#ifdef METADATABUFFERTYPE
+#ifdef USE_METADATABUFFERTYPE
case OMX_COLOR_FormatAndroidOpaque:
#endif
- pMpeg4Param->FrameMap = NV12_LINEAR;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12;
break;
case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
case OMX_SEC_COLOR_FormatNV12Tiled:
- pMpeg4Param->FrameMap = NV12_TILE;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED;
break;
case OMX_SEC_COLOR_FormatNV21LPhysicalAddress:
case OMX_SEC_COLOR_FormatNV21Linear:
- pMpeg4Param->FrameMap = NV21_LINEAR;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV21;
break;
default:
- pMpeg4Param->FrameMap = NV12_TILE;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED;
break;
}
- Mpeg4PrintParams(pMpeg4Param);
-}
-
-void Change_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
-{
- EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
- EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
-
- pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
- pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
-
- if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) {
- int set_conf_IntraRefreshVOP = 1;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_FRAME_TYPE,
- &set_conf_IntraRefreshVOP);
- pVideoEnc->IntraRefreshVOP = OMX_FALSE;
- }
-
- if (pMpeg4Param->IDRPeriod != (int)pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1) {
- int set_conf_IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_I_PERIOD,
- &set_conf_IDRPeriod);
- }
- if (pMpeg4Param->Bitrate != (int)pExynosOutputPort->portDefinition.format.video.nBitrate) {
- int set_conf_bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_CHANGE_BIT_RATE,
- &set_conf_bitrate);
- }
- if (pMpeg4Param->TimeIncreamentRes != (int)((pExynosOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
- int set_conf_framerate = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_CHANGE_FRAME_RATE,
- &set_conf_framerate);
- }
-
- Set_Mpeg4Enc_Param(pMpeg4Param, pExynosComponent);
- Mpeg4PrintParams(pMpeg4Param);
-}
-
-void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
-{
- EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
- EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
-
- pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
- pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
-
- pH263Param->codecType = H263_ENC;
- pH263Param->SourceWidth = pExynosOutputPort->portDefinition.format.video.nFrameWidth;
- pH263Param->SourceHeight = pExynosOutputPort->portDefinition.format.video.nFrameHeight;
- pH263Param->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1;
- pH263Param->SliceMode = 0;
- pH263Param->RandomIntraMBRefresh = 0;
- pH263Param->Bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate;
- pH263Param->QSCodeMax = 30;
- pH263Param->QSCodeMin = 10;
- pH263Param->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */
- pH263Param->LumaPadVal = 0;
- pH263Param->CbPadVal = 0;
- pH263Param->CrPadVal = 0;
-
- pH263Param->FrameRate = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
-
- pH263Param->FrameQp = pVideoEnc->quantization.nQpI;
- pH263Param->FrameQp_P = pVideoEnc->quantization.nQpP;
+ /* Mpeg4 specific parameters */
+ pMpeg4Param->ProfileIDC = OMXMpeg4ProfileToMFCProfile(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eProfile);
+ pMpeg4Param->LevelIDC = OMXMpeg4LevelToMFCLevel(pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].eLevel);
+ pMpeg4Param->FrameQp_B = pVideoEnc->quantization.nQpB;
+ pMpeg4Param->TimeIncreamentRes = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
+ pMpeg4Param->VopTimeIncreament = 1;
+ pMpeg4Param->SliceArgument = 0; /* MB number or byte number */
+ pMpeg4Param->NumberBFrames = 0; /* 0(not used) ~ 2 */
+ pMpeg4Param->DisableQpelME = 1;
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ /* rate control related parameters */
switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
case OMX_Video_ControlRateVariable:
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
- pH263Param->EnableFRMRateControl = 0; // 0: Disable, 1: Frame level RC
- pH263Param->CBRPeriodRf = 100;
+ pCommonParam->EnableFRMRateControl = 0; /* 0: Disable, 1: Frame level RC */
+ pCommonParam->EnableMBRateControl = 0; /* 0: Disable, 1:MB level RC */
+ pCommonParam->CBRPeriodRf = 100;
break;
case OMX_Video_ControlRateConstant:
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode CBR");
- pH263Param->EnableFRMRateControl = 1; // 0: Disable, 1: Frame level RC
- pH263Param->CBRPeriodRf = 10;
+ pCommonParam->EnableFRMRateControl = 1; /* 0: Disable, 1: Frame level RC */
+ pCommonParam->EnableMBRateControl = 1; /* 0: Disable, 1:MB level RC */
+ pCommonParam->CBRPeriodRf = 10;
break;
case OMX_Video_ControlRateDisable:
- default: //Android default
+ default: /*Android default */
Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
- pH263Param->EnableFRMRateControl = 0;
- pH263Param->CBRPeriodRf = 100;
+ pCommonParam->EnableFRMRateControl = 0;
+ pCommonParam->EnableMBRateControl = 0;
+ pCommonParam->CBRPeriodRf = 100;
break;
}
+ Print_Mpeg4Enc_Param(pEncParam);
+}
+
+static void Set_H263Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+{
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
+ EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ ExynosVideoEncParam *pEncParam = NULL;
+ ExynosVideoEncCommonParam *pCommonParam = NULL;
+ ExynosVideoEncH263Param *pH263Param = NULL;
+
+ pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ pMpeg4Enc = pVideoEnc->hCodecHandle;
+ pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+
+ pEncParam = &pVideoEnc->encParam;
+ pCommonParam = &pEncParam->commonParam;
+ pH263Param = &pEncParam->codecParam.h263;
+ pEncParam->eCompressionFormat = VIDEO_CODING_H263;
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "eCompressionFormat: %d", pEncParam->eCompressionFormat);
+
+ /* common parameters */
+ pCommonParam->SourceWidth = pExynosOutputPort->portDefinition.format.video.nFrameWidth;
+ pCommonParam->SourceHeight = pExynosOutputPort->portDefinition.format.video.nFrameHeight;
+ pCommonParam->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pCommonParam->SliceMode = 0;
+ pCommonParam->RandomIntraMBRefresh = 0;
+ pCommonParam->Bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate;
+ pCommonParam->FrameQp = pVideoEnc->quantization.nQpI;
+ pCommonParam->FrameQp_P = pVideoEnc->quantization.nQpP;
+ pCommonParam->QSCodeMax = 30;
+ pCommonParam->QSCodeMin = 10;
+ pCommonParam->PadControlOn = 0; /* 0: Use boundary pixel, 1: Use the below setting value */
+ pCommonParam->LumaPadVal = 0;
+ pCommonParam->CbPadVal = 0;
+ pCommonParam->CrPadVal = 0;
+
switch ((EXYNOS_OMX_COLOR_FORMATTYPE)pExynosInputPort->portDefinition.format.video.eColorFormat) {
case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
case OMX_COLOR_FormatYUV420SemiPlanar:
- pH263Param->FrameMap = NV12_LINEAR;
+ case OMX_COLOR_FormatYUV420Planar:
+#ifdef USE_METADATABUFFERTYPE
+ case OMX_COLOR_FormatAndroidOpaque:
+#endif
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12;
break;
case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
case OMX_SEC_COLOR_FormatNV12Tiled:
- pH263Param->FrameMap = NV12_TILE;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED;
break;
case OMX_SEC_COLOR_FormatNV21LPhysicalAddress:
case OMX_SEC_COLOR_FormatNV21Linear:
- pH263Param->FrameMap = NV21_LINEAR;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV21;
break;
default:
- pH263Param->FrameMap = NV12_TILE;
+ pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED;
break;
}
- H263PrintParams(pH263Param);
+ /* H263 specific parameters */
+ pH263Param->FrameRate = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
+
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]);
+ /* rate control related parameters */
+ switch (pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]) {
+ case OMX_Video_ControlRateVariable:
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
+ pCommonParam->EnableFRMRateControl = 0; /* 0: Disable, 1: Frame level RC */
+ pCommonParam->EnableMBRateControl = 0; /* 0: Disable, 1:MB level RC */
+ pCommonParam->CBRPeriodRf = 100;
+ break;
+ case OMX_Video_ControlRateConstant:
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode CBR");
+ pCommonParam->EnableFRMRateControl = 1; /* 0: Disable, 1: Frame level RC */
+ pCommonParam->EnableMBRateControl = 1; /* 0: Disable, 1:MB level RC */
+ pCommonParam->CBRPeriodRf = 10;
+ break;
+ case OMX_Video_ControlRateDisable:
+ default: /*Android default */
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Video Encode VBR");
+ pCommonParam->EnableFRMRateControl = 0;
+ pCommonParam->EnableMBRateControl = 0;
+ pCommonParam->CBRPeriodRf = 100;
+ break;
+ }
+
+ Print_H263Enc_Param(pEncParam);
}
-void Change_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+static void Change_Mpeg4Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
{
- EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ ExynosVideoEncOps *pEncOps = NULL;
+ ExynosVideoEncParam *pEncParam = NULL;
+ ExynosVideoEncCommonParam *pCommonParam = NULL;
+ ExynosVideoEncMpeg4Param *pMpeg4Param = NULL;
+
+ int setParam = 0;
pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ pMpeg4Enc = pVideoEnc->hCodecHandle;
+ pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+ pEncOps = pVideoEnc->pEncOps;
+
+ pEncParam = &pVideoEnc->encParam;
+ pCommonParam = &pEncParam->commonParam;
+ pMpeg4Param = &pEncParam->codecParam.mpeg4;
if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) {
- int set_conf_IntraRefreshVOP = 1;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_FRAME_TYPE,
- &set_conf_IntraRefreshVOP);
+ setParam = VIDEO_FRAME_I;
+ pEncOps->Set_FrameType(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
pVideoEnc->IntraRefreshVOP = OMX_FALSE;
}
- if (pH263Param->IDRPeriod != (int)pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1) {
- int set_conf_IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_I_PERIOD,
- &set_conf_IDRPeriod);
+ if (pCommonParam->IDRPeriod != (int)pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1) {
+ setParam = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pEncOps->Set_IDRPeriod(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
}
- if (pH263Param->Bitrate != (int)pExynosOutputPort->portDefinition.format.video.nBitrate) {
- int set_conf_bitrate = pExynosOutputPort->portDefinition.format.video.nBitrate;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_CHANGE_BIT_RATE,
- &set_conf_bitrate);
+ if (pCommonParam->Bitrate != (int)pExynosOutputPort->portDefinition.format.video.nBitrate) {
+ setParam = pExynosOutputPort->portDefinition.format.video.nBitrate;
+ pEncOps->Set_BitRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
}
- if (pH263Param->FrameRate != (int)((pExynosOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
- int set_conf_framerate = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
- SsbSipMfcEncSetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
- MFC_ENC_SETCONF_CHANGE_FRAME_RATE,
- &set_conf_framerate);
+ if (pMpeg4Param->TimeIncreamentRes != (int)((pExynosOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
+ setParam = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
+ pEncOps->Set_FrameRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
}
- Set_H263Enc_Param(pH263Param, pExynosComponent);
- H263PrintParams(pH263Param);
+ Set_Mpeg4Enc_Param(pExynosComponent);
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_GetParameter(
+static void Change_H263Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent)
+{
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = NULL;
+ EXYNOS_OMX_BASEPORT *pExynosOutputPort = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+
+ ExynosVideoEncOps *pEncOps = NULL;
+ ExynosVideoEncParam *pEncParam = NULL;
+ ExynosVideoEncCommonParam *pCommonParam = NULL;
+ ExynosVideoEncH263Param *pH263Param = NULL;
+
+ int setParam = 0;
+
+ pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ pMpeg4Enc = pVideoEnc->hCodecHandle;
+ pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+ pEncOps = pVideoEnc->pEncOps;
+
+ pEncParam = &pVideoEnc->encParam;
+ pCommonParam = &pEncParam->commonParam;
+ pH263Param = &pEncParam->codecParam.h263;
+
+ if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) {
+ setParam = VIDEO_FRAME_I;
+ pEncOps->Set_FrameType(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
+ pVideoEnc->IntraRefreshVOP = OMX_FALSE;
+ }
+ if (pCommonParam->IDRPeriod != (int)pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1) {
+ setParam = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1;
+ pEncOps->Set_IDRPeriod(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
+ }
+ if (pCommonParam->Bitrate != (int)pExynosOutputPort->portDefinition.format.video.nBitrate) {
+ setParam = pExynosOutputPort->portDefinition.format.video.nBitrate;
+ pEncOps->Set_BitRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
+ }
+ if (pH263Param->FrameRate != (int)((pExynosOutputPort->portDefinition.format.video.xFramerate) >> 16)) {
+ setParam = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16;
+ pEncOps->Set_FrameRate(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, setParam);
+ }
+
+ Set_H263Enc_Param(pExynosComponent);
+}
+
+OMX_ERRORTYPE Exynos_Mpeg4Enc_GetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nParamIndex,
OMX_INOUT OMX_PTR pComponentParameterStructure)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
FunctionIn();
@@ -460,46 +511,46 @@
switch (nParamIndex) {
case OMX_IndexParamVideoMpeg4:
{
- OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
- OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Component = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Component = NULL;
EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- ret = Exynos_OMX_Check_SizeVersion(pDstMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ ret = Exynos_OMX_Check_SizeVersion(pDstMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
if (ret != OMX_ErrorNone) {
goto EXIT;
}
- if (pDstMpeg4Param->nPortIndex >= ALL_PORT_NUM) {
+ if (pDstMpeg4Component->nPortIndex >= ALL_PORT_NUM) {
ret = OMX_ErrorBadPortIndex;
goto EXIT;
}
pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstMpeg4Param->nPortIndex];
+ pSrcMpeg4Component = &pMpeg4Enc->mpeg4Component[pDstMpeg4Component->nPortIndex];
- Exynos_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ Exynos_OSAL_Memcpy(pDstMpeg4Component, pSrcMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
}
break;
case OMX_IndexParamVideoH263:
{
- OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure;
- OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pDstH263Component = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_H263TYPE *pSrcH263Component = NULL;
EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- ret = Exynos_OMX_Check_SizeVersion(pDstH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ ret = Exynos_OMX_Check_SizeVersion(pDstH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE));
if (ret != OMX_ErrorNone) {
goto EXIT;
}
- if (pDstH263Param->nPortIndex >= ALL_PORT_NUM) {
+ if (pDstH263Component->nPortIndex >= ALL_PORT_NUM) {
ret = OMX_ErrorBadPortIndex;
goto EXIT;
}
pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pSrcH263Param = &pMpeg4Enc->h263Component[pDstH263Param->nPortIndex];
+ pSrcH263Component = &pMpeg4Enc->h263Component[pDstH263Component->nPortIndex];
- Exynos_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ Exynos_OSAL_Memcpy(pDstH263Component, pSrcH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE));
}
break;
case OMX_IndexParamStandardComponentRole:
@@ -558,8 +609,8 @@
case OMX_IndexParamVideoProfileLevelCurrent:
{
OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
- OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = NULL;
- OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = NULL;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Component = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pSrcH263Component = NULL;
EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
OMX_S32 codecType;
@@ -576,13 +627,13 @@
pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
codecType = pMpeg4Enc->hMFCMpeg4Handle.codecType;
if (codecType == CODEC_TYPE_MPEG4) {
- pSrcMpeg4Param = &pMpeg4Enc->mpeg4Component[pDstProfileLevel->nPortIndex];
- pDstProfileLevel->eProfile = pSrcMpeg4Param->eProfile;
- pDstProfileLevel->eLevel = pSrcMpeg4Param->eLevel;
+ pSrcMpeg4Component = &pMpeg4Enc->mpeg4Component[pDstProfileLevel->nPortIndex];
+ pDstProfileLevel->eProfile = pSrcMpeg4Component->eProfile;
+ pDstProfileLevel->eLevel = pSrcMpeg4Component->eLevel;
} else {
- pSrcH263Param = &pMpeg4Enc->h263Component[pDstProfileLevel->nPortIndex];
- pDstProfileLevel->eProfile = pSrcH263Param->eProfile;
- pDstProfileLevel->eLevel = pSrcH263Param->eLevel;
+ pSrcH263Component = &pMpeg4Enc->h263Component[pDstProfileLevel->nPortIndex];
+ pDstProfileLevel->eProfile = pSrcH263Component->eProfile;
+ pDstProfileLevel->eLevel = pSrcH263Component->eLevel;
}
}
break;
@@ -622,13 +673,13 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_SetParameter(
+OMX_ERRORTYPE Exynos_Mpeg4Enc_SetParameter(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentParameterStructure)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
FunctionIn();
@@ -656,46 +707,46 @@
switch (nIndex) {
case OMX_IndexParamVideoMpeg4:
{
- OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL;
- OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Param = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Component = NULL;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pSrcMpeg4Component = (OMX_VIDEO_PARAM_MPEG4TYPE *)pComponentParameterStructure;
EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- ret = Exynos_OMX_Check_SizeVersion(pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ ret = Exynos_OMX_Check_SizeVersion(pSrcMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
if (ret != OMX_ErrorNone) {
goto EXIT;
}
- if (pSrcMpeg4Param->nPortIndex >= ALL_PORT_NUM) {
+ if (pSrcMpeg4Component->nPortIndex >= ALL_PORT_NUM) {
ret = OMX_ErrorBadPortIndex;
goto EXIT;
}
pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcMpeg4Param->nPortIndex];
+ pDstMpeg4Component = &pMpeg4Enc->mpeg4Component[pSrcMpeg4Component->nPortIndex];
- Exynos_OSAL_Memcpy(pDstMpeg4Param, pSrcMpeg4Param, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
+ Exynos_OSAL_Memcpy(pDstMpeg4Component, pSrcMpeg4Component, sizeof(OMX_VIDEO_PARAM_MPEG4TYPE));
}
break;
case OMX_IndexParamVideoH263:
{
- OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL;
- OMX_VIDEO_PARAM_H263TYPE *pSrcH263Param = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure;
+ OMX_VIDEO_PARAM_H263TYPE *pDstH263Component = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pSrcH263Component = (OMX_VIDEO_PARAM_H263TYPE *)pComponentParameterStructure;
EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- ret = Exynos_OMX_Check_SizeVersion(pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ ret = Exynos_OMX_Check_SizeVersion(pSrcH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE));
if (ret != OMX_ErrorNone) {
goto EXIT;
}
- if (pSrcH263Param->nPortIndex >= ALL_PORT_NUM) {
+ if (pSrcH263Component->nPortIndex >= ALL_PORT_NUM) {
ret = OMX_ErrorBadPortIndex;
goto EXIT;
}
pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- pDstH263Param = &pMpeg4Enc->h263Component[pSrcH263Param->nPortIndex];
+ pDstH263Component = &pMpeg4Enc->h263Component[pSrcH263Component->nPortIndex];
- Exynos_OSAL_Memcpy(pDstH263Param, pSrcH263Param, sizeof(OMX_VIDEO_PARAM_H263TYPE));
+ Exynos_OSAL_Memcpy(pDstH263Component, pSrcH263Component, sizeof(OMX_VIDEO_PARAM_H263TYPE));
}
break;
case OMX_IndexParamStandardComponentRole:
@@ -727,8 +778,8 @@
case OMX_IndexParamVideoProfileLevelCurrent:
{
OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure;
- OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Param = NULL;
- OMX_VIDEO_PARAM_H263TYPE *pDstH263Param = NULL;
+ OMX_VIDEO_PARAM_MPEG4TYPE *pDstMpeg4Component = NULL;
+ OMX_VIDEO_PARAM_H263TYPE *pDstH263Component = NULL;
EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
OMX_S32 codecType;
@@ -749,17 +800,17 @@
* To do: Check validity of profile & level parameters
*/
- pDstMpeg4Param = &pMpeg4Enc->mpeg4Component[pSrcProfileLevel->nPortIndex];
- pDstMpeg4Param->eProfile = pSrcProfileLevel->eProfile;
- pDstMpeg4Param->eLevel = pSrcProfileLevel->eLevel;
+ pDstMpeg4Component = &pMpeg4Enc->mpeg4Component[pSrcProfileLevel->nPortIndex];
+ pDstMpeg4Component->eProfile = pSrcProfileLevel->eProfile;
+ pDstMpeg4Component->eLevel = pSrcProfileLevel->eLevel;
} else {
/*
* To do: Check validity of profile & level parameters
*/
- pDstH263Param = &pMpeg4Enc->h263Component[pSrcProfileLevel->nPortIndex];
- pDstH263Param->eProfile = pSrcProfileLevel->eProfile;
- pDstH263Param->eLevel = pSrcProfileLevel->eLevel;
+ pDstH263Component = &pMpeg4Enc->h263Component[pSrcProfileLevel->nPortIndex];
+ pDstH263Component->eProfile = pSrcProfileLevel->eProfile;
+ pDstH263Component->eLevel = pSrcProfileLevel->eLevel;
}
}
break;
@@ -767,7 +818,7 @@
{
OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure;
OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE));
if (ret != OMX_ErrorNone) {
@@ -799,13 +850,13 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_GetConfig(
+OMX_ERRORTYPE Exynos_Mpeg4Enc_GetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
FunctionIn();
@@ -842,16 +893,16 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_SetConfig(
+OMX_ERRORTYPE Exynos_Mpeg4Enc_SetConfig(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_IN OMX_INDEXTYPE nIndex,
OMX_IN OMX_PTR pComponentConfigStructure)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
FunctionIn();
@@ -875,13 +926,12 @@
goto EXIT;
}
- pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
+ pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle;
switch (nIndex) {
case OMX_IndexConfigVideoIntraPeriod:
{
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVEncBase = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
OMX_U32 nPFrames = (*((OMX_U32 *)pComponentConfigStructure)) - 1;
if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
@@ -906,13 +956,13 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_GetExtensionIndex(
- OMX_IN OMX_HANDLETYPE hComponent,
- OMX_IN OMX_STRING cParameterName,
- OMX_OUT OMX_INDEXTYPE *pIndexType)
+OMX_ERRORTYPE Exynos_Mpeg4Enc_GetExtensionIndex(
+ OMX_IN OMX_HANDLETYPE hComponent,
+ OMX_IN OMX_STRING cParameterName,
+ OMX_OUT OMX_INDEXTYPE *pIndexType)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
FunctionIn();
@@ -947,19 +997,20 @@
} else {
ret = Exynos_OMX_VideoEncodeGetExtensionIndex(hComponent, cParameterName, pIndexType);
}
+
EXIT:
FunctionOut();
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_ComponentRoleEnum(
+OMX_ERRORTYPE Exynos_Mpeg4Enc_ComponentRoleEnum(
OMX_IN OMX_HANDLETYPE hComponent,
OMX_OUT OMX_U8 *cRole,
OMX_IN OMX_U32 nIndex)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
OMX_S32 codecType;
@@ -969,7 +1020,7 @@
ret = OMX_ErrorBadParameter;
goto EXIT;
}
- if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) {
+ if (nIndex != (MAX_COMPONENT_ROLE_NUM - 1)) { /* supports only one role */
ret = OMX_ErrorNoMore;
goto EXIT;
}
@@ -1001,13 +1052,16 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_EncodeThread(OMX_HANDLETYPE hComponent)
+static OMX_ERRORTYPE Exynos_Mpeg4Enc_EncodeThread(OMX_HANDLETYPE hComponent)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = (OMX_COMPONENTTYPE *)hComponent;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle;
+ ExynosVideoEncOps *pEncOps = pVideoEnc->pEncOps;
+ ExynosVideoEncBufferOps *pInbufOps = pVideoEnc->pInbufOps;
+ ExynosVideoEncBufferOps *pOutbufOps = pVideoEnc->pOutbufOps;
FunctionIn();
@@ -1020,7 +1074,22 @@
Exynos_OSAL_SemaphoreWait(pVideoEnc->NBEncThread.hEncFrameStart);
if (pVideoEnc->NBEncThread.bExitEncodeThread == OMX_FALSE) {
- pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncExe(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle);
+ if (pVideoEnc->NBEncThread.oneFrameSize > 0) {
+ if (pVideoEnc->bInputRun == OMX_FALSE) {
+ if (pInbufOps->Run(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ pVideoEnc->bInputRun = OMX_TRUE;
+ }
+
+ pVideoEnc->pOutbuf = pOutbufOps->Dequeue(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle);
+ pInbufOps->Dequeue(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle);
+ }
+
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = VIDEO_TRUE;
Exynos_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameEnd);
}
}
@@ -1033,109 +1102,178 @@
}
/* MFC Init */
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
+OMX_ERRORTYPE Exynos_Mpeg4Enc_Init(OMX_COMPONENTTYPE *pOMXComponent)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle;
EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- OMX_HANDLETYPE hMFCHandle = NULL;
- OMX_S32 returnCodec = 0;
+ ExynosVideoEncOps *pEncOps = NULL;
+ ExynosVideoEncBufferOps *pInbufOps = NULL;
+ ExynosVideoEncBufferOps *pOutbufOps = NULL;
+
+ OMX_HANDLETYPE hMFCHandle = NULL;
+ OMX_S32 returnCodec = 0;
+ int i;
+
+ ExynosVideoEncParam encParam;
+ ExynosVideoBuffer bufferInfo;
+ ExynosVideoGeometry bufferConf;
+
+ CSC_METHOD csc_method = CSC_METHOD_SW;
FunctionIn();
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_FALSE;
pExynosComponent->bUseFlagEOF = OMX_FALSE;
pExynosComponent->bSaveFlagEOS = OMX_FALSE;
- /* MFC(Multi Format Codec) encoder and CMM(Codec Memory Management) driver open */
- switch (pExynosInputPort->portDefinition.format.video.eColorFormat) {
- case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
- case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
- case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
- case OMX_SEC_COLOR_FormatNV21LPhysicalAddress:
- hMFCHandle = (OMX_PTR)SsbSipMfcEncOpen();
- break;
- default: {
- SSBIP_MFC_BUFFER_TYPE buf_type = CACHE;
- hMFCHandle = (OMX_PTR)SsbSipMfcEncOpenExt(&buf_type);
- break;
- }
- }
-
- if (hMFCHandle == NULL) {
+ /* alloc ops structure */
+ pEncOps = (ExynosVideoEncOps *)Exynos_OSAL_Malloc(sizeof(*pEncOps));
+ pInbufOps = (ExynosVideoEncBufferOps *)Exynos_OSAL_Malloc(sizeof(*pInbufOps));
+ pOutbufOps = (ExynosVideoEncBufferOps *)Exynos_OSAL_Malloc(sizeof(*pOutbufOps));
+ if ((pEncOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate encoder ops buffer");
ret = OMX_ErrorInsufficientResources;
+
+ if (pEncOps)
+ Exynos_OSAL_Free(pEncOps);
+
+ if (pInbufOps)
+ Exynos_OSAL_Free(pInbufOps);
+
+ if (pOutbufOps)
+ Exynos_OSAL_Free(pOutbufOps);
+
goto EXIT;
}
- pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = hMFCHandle;
- /* set MFC ENC VIDEO PARAM and initialize MFC encoder instance */
- if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4) {
- Set_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pExynosComponent);
- returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam));
- } else {
- Set_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pExynosComponent);
- returnCodec = SsbSipMfcEncInit(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam));
- }
- if (returnCodec != MFC_RET_OK) {
+ pVideoEnc->pEncOps = pEncOps;
+ pVideoEnc->pInbufOps = pInbufOps;
+ pVideoEnc->pOutbufOps = pOutbufOps;
+
+ /* function pointer mapping */
+ pEncOps->nSize = sizeof(*pEncOps);
+ pInbufOps->nSize = sizeof(*pInbufOps);
+ pOutbufOps->nSize = sizeof(*pOutbufOps);
+
+ Exynos_Video_Register_Encoder(pEncOps, pInbufOps, pOutbufOps);
+
+ /* check mandatory functions for encoder ops */
+ if ((pEncOps->Init == NULL) || (pEncOps->Finalize == NULL) ||
+ (pEncOps->Set_FrameTag == NULL) || (pEncOps->Get_FrameTag == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
- /* Allocate encoder's input buffer */
- returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo));
- if (returnCodec != MFC_RET_OK) {
+ /* check mandatory functions for buffer ops */
+ if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) ||
+ (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) ||
+ (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) ||
+ (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) ||
+ (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied");
ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
- pVideoEnc->MFCEncInputBuffer[0].YPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YPhyAddr;
- pVideoEnc->MFCEncInputBuffer[0].CPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CPhyAddr;
- pVideoEnc->MFCEncInputBuffer[0].YVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr;
- pVideoEnc->MFCEncInputBuffer[0].CVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr;
- pVideoEnc->MFCEncInputBuffer[0].YBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YSize;
- pVideoEnc->MFCEncInputBuffer[0].CBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CSize;
- pVideoEnc->MFCEncInputBuffer[0].YDataSize = 0;
- pVideoEnc->MFCEncInputBuffer[0].CDataSize = 0;
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr);
- returnCodec = SsbSipMfcEncGetInBuf(hMFCHandle, &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo));
- if (returnCodec != MFC_RET_OK) {
+ /* alloc context, open, querycap */
+ pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = pVideoEnc->pEncOps->Init();
+ if (pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer");
ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
- pVideoEnc->MFCEncInputBuffer[1].YPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YPhyAddr;
- pVideoEnc->MFCEncInputBuffer[1].CPhyAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CPhyAddr;
- pVideoEnc->MFCEncInputBuffer[1].YVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr;
- pVideoEnc->MFCEncInputBuffer[1].CVirAddr = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr;
- pVideoEnc->MFCEncInputBuffer[1].YBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YSize;
- pVideoEnc->MFCEncInputBuffer[1].CBufferSize = pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CSize;
- pVideoEnc->MFCEncInputBuffer[1].YDataSize = 0;
- pVideoEnc->MFCEncInputBuffer[1].CDataSize = 0;
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.YVirAddr);
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr : 0x%x", pMpeg4Enc->hMFCMpeg4Handle.inputInfo.CVirAddr);
+
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
+ Set_Mpeg4Enc_Param(pExynosComponent);
+ else
+ Set_H263Enc_Param(pExynosComponent);
+
+ encParam = pVideoEnc->encParam;
+ if (pEncOps->Set_EncParam) {
+ if(pEncOps->Set_EncParam(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &encParam) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+
+ /* set input buffer shareable */
+ if(pExynosInputPort->portDefinition.format.video.eColorFormat == OMX_SEC_COLOR_FormatNV12LVirtualAddress) {
+ if (pInbufOps->Set_Shareable) {
+ if (pInbufOps->Set_Shareable(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set input buffer shareable");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+ }
+
+ Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
+
+ /* input buffer info: only 3 config values needed */
+ bufferConf.nFrameWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth;
+ bufferConf.nFrameHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight;
+ bufferConf.eColorFormat = pVideoEnc->encParam.commonParam.FrameMap;
+
+ /* set input buffer geometry */
+ if (pInbufOps->Set_Geometry) {
+ if (pInbufOps->Set_Geometry(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+
+ /* cacheable for input */
+ if (pInbufOps->Enable_Cacheable) {
+ if (pInbufOps->Enable_Cacheable(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for input buffer");
+ }
+
+ /* setup input buffer */
+ if (pInbufOps->Setup(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, MFC_INPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) {
+ pInbufOps->Get_BufferInfo(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, i, &bufferInfo);
+
+ pVideoEnc->MFCEncInputBuffer[i].YPhyAddr = NULL;
+ pVideoEnc->MFCEncInputBuffer[i].CPhyAddr = NULL;
+ pVideoEnc->MFCEncInputBuffer[i].YVirAddr = bufferInfo.planes[0].addr;
+ pVideoEnc->MFCEncInputBuffer[i].CVirAddr = bufferInfo.planes[1].addr;
+ pVideoEnc->MFCEncInputBuffer[i].YBufferSize = bufferInfo.planes[0].allocSize;
+ pVideoEnc->MFCEncInputBuffer[i].CBufferSize = bufferInfo.planes[1].allocSize;
+ pVideoEnc->MFCEncInputBuffer[i].YDataSize = bufferInfo.planes[0].dataSize;
+ pVideoEnc->MFCEncInputBuffer[i].CDataSize = bufferInfo.planes[1].dataSize;
+ }
pVideoEnc->indexInputBuffer = 0;
-
pVideoEnc->bFirstFrame = OMX_TRUE;
+ pVideoEnc->bInputRun = OMX_FALSE;
-#ifdef NONBLOCK_MODE_PROCESS
pVideoEnc->NBEncThread.bExitEncodeThread = OMX_FALSE;
pVideoEnc->NBEncThread.bEncoderRun = OMX_FALSE;
Exynos_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameStart));
Exynos_OSAL_SemaphoreCreate(&(pVideoEnc->NBEncThread.hEncFrameEnd));
if (OMX_ErrorNone == Exynos_OSAL_ThreadCreate(&pVideoEnc->NBEncThread.hNBEncodeThread,
- Exynos_MFC_EncodeThread,
- pOMXComponent)) {
- pMpeg4Enc->hMFCMpeg4Handle.returnCodec = MFC_RET_OK;
+ Exynos_Mpeg4Enc_EncodeThread,
+ pOMXComponent)) {
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = VIDEO_TRUE;
}
-#endif
+
Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP);
Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS);
pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp = 0;
+ pVideoEnc->csc_handle = csc_init(csc_method);
+
EXIT:
FunctionOut();
@@ -1143,18 +1281,19 @@
}
/* MFC Terminate */
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
+OMX_ERRORTYPE Exynos_Mpeg4Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- OMX_HANDLETYPE hMFCHandle = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle;
+ ExynosVideoEncOps *pEncOps = pVideoEnc->pEncOps;
+ ExynosVideoEncBufferOps *pInbufOps = pVideoEnc->pInbufOps;
+ ExynosVideoEncBufferOps *pOutbufOps = pVideoEnc->pOutbufOps;
+ OMX_HANDLETYPE hMFCHandle = NULL;
FunctionIn();
- pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
-#ifdef NONBLOCK_MODE_PROCESS
if (pVideoEnc->NBEncThread.hNBEncodeThread != NULL) {
pVideoEnc->NBEncThread.bExitEncodeThread = OMX_TRUE;
Exynos_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
@@ -1171,12 +1310,23 @@
Exynos_OSAL_SemaphoreTerminate(pVideoEnc->NBEncThread.hEncFrameStart);
pVideoEnc->NBEncThread.hEncFrameStart = NULL;
}
-#endif
hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle;
if (hMFCHandle != NULL) {
- SsbSipMfcEncClose(hMFCHandle);
- hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = NULL;
+ pInbufOps->Stop(hMFCHandle);
+ pOutbufOps->Stop(hMFCHandle);
+ pEncOps->Finalize(hMFCHandle);
+
+ Exynos_OSAL_Free(pInbufOps);
+ Exynos_OSAL_Free(pOutbufOps);
+ Exynos_OSAL_Free(pEncOps);
+
+ pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle = NULL;
+ }
+
+ if (pVideoEnc->csc_handle != NULL) {
+ csc_deinit(pVideoEnc->csc_handle);
+ pVideoEnc->csc_handle = NULL;
}
EXIT:
@@ -1185,33 +1335,120 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4_Encode_Nonblock(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
+static OMX_ERRORTYPE Exynos_Mpeg4Enc_Configure(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ EXYNOS_OMX_DATA *pInputData,
+ EXYNOS_OMX_DATA *pOutputData)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- OMX_HANDLETYPE hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle;
- SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo);
- SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo;
- EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
- MFC_ENC_ADDR_INFO addrInfo;
- OMX_U32 oneFrameSize = pInputData->dataLen;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle;
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+ ExynosVideoEncOps *pEncOps = pVideoEnc->pEncOps;
+ ExynosVideoEncBufferOps *pInbufOps = pVideoEnc->pInbufOps;
+ ExynosVideoEncBufferOps *pOutbufOps = pVideoEnc->pOutbufOps;
+
+ OMX_S32 setConfVal = 0;
+ ExynosVideoGeometry bufferConf;
+ int i;
+
+ Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf));
+
+ /* set geometry for output (dst) */
+ if (pOutbufOps->Set_Geometry) {
+ /* input buffer info: only 2 config values needed */
+ bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE / 2;
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
+ bufferConf.eCompressionFormat = VIDEO_CODING_MPEG4;
+ else
+ bufferConf.eCompressionFormat = VIDEO_CODING_H263;
+ if (pOutbufOps->Set_Geometry(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+
+ /* cacheable for output */
+ if (pOutbufOps->Enable_Cacheable) {
+ if (pOutbufOps->Enable_Cacheable(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE)
+ Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "Failed to enable cacheable property for output buffer");
+ }
+
+ if (pOutbufOps->Setup(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, MFC_OUTPUT_BUFFER_NUM_MAX) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ if (pOutbufOps->Enqueue_All) {
+ if (pOutbufOps->Enqueue_All(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to flush all output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+ }
+
+ /* start header encoding */
+ if (pOutbufOps->Run(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer for header parsing");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ pVideoEnc->pOutbuf = pOutbufOps->Dequeue(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle);
+ if (pVideoEnc->pOutbuf == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to dequeue output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ pOutputData->dataBuffer= pVideoEnc->pOutbuf->planes[0].addr;
+ pOutputData->allocSize = pVideoEnc->pOutbuf->planes[0].allocSize;
+ pOutputData->dataLen = pVideoEnc->pOutbuf->planes[0].dataSize;
+ pOutputData->usedDataLen = 0;
+
+ ret = OMX_ErrorNone;
+
+ pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE;
+ pMpeg4Enc->hMFCMpeg4Handle.returnCodec = VIDEO_TRUE;
+
+EXIT:
+ return ret;
+}
+
+/* nonblock */
+static OMX_ERRORTYPE Exynos_Mpeg4Enc_Encode(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ EXYNOS_OMX_DATA *pInputData,
+ EXYNOS_OMX_DATA *pOutputData)
+{
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)pVideoEnc->hCodecHandle;
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+ EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
+ ExynosVideoEncOps *pEncOps = pVideoEnc->pEncOps;
+ ExynosVideoEncBufferOps *pInbufOps = pVideoEnc->pInbufOps;
+ ExynosVideoEncBufferOps *pOutbufOps = pVideoEnc->pOutbufOps;
+
+ pVideoEnc->NBEncThread.oneFrameSize = pInputData->dataLen;
+ OMX_PTR ppBuf[3];
FunctionIn();
if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
- pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
- if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec != MFC_RET_OK)
- {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
+ ret = Exynos_Mpeg4Enc_Configure(pOMXComponent, pInputData, pOutputData);
+ if (ret != OMX_ErrorNone) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: failed to configure encoder", __FUNCTION__);
ret = OMX_ErrorUndefined;
goto EXIT;
}
- pOutputData->dataBuffer = outputInfo.StrmVirAddr;
- pOutputData->allocSize = outputInfo.headerSize;
- pOutputData->dataLen = outputInfo.headerSize;
pOutputData->timeStamp = 0;
pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
@@ -1226,7 +1463,7 @@
(pExynosComponent->bUseFlagEOF == OMX_FALSE))
pExynosComponent->bUseFlagEOF = OMX_TRUE;
- if (oneFrameSize <= 0) {
+ if (pVideoEnc->NBEncThread.oneFrameSize <= 0) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
@@ -1235,53 +1472,51 @@
}
pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+
if (((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) ||
(pExynosComponent->getAllDelayBuffer == OMX_TRUE)){
/* Dummy input data for get out encoded last frame */
- pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
- pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
- pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
- pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[0] = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[1] = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
} else {
switch (pExynosPort->portDefinition.format.video.eColorFormat) {
case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
- case OMX_SEC_COLOR_FormatNV21LPhysicalAddress: {
+ case OMX_SEC_COLOR_FormatNV21LPhysicalAddress:
#ifndef USE_METADATABUFFERTYPE
/* USE_FIMC_FRAME_BUFFER */
- Exynos_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
- Exynos_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
+ Exynos_OSAL_Memcpy(&(pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[0]), pInputData->dataBuffer, sizeof(OMX_PTR));
+ Exynos_OSAL_Memcpy(&(pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[1]), pInputData->dataBuffer + sizeof(OMX_PTR), sizeof(OMX_PTR));
#else
- OMX_PTR ppBuf[3];
Exynos_OSAL_GetInfoFromMetaData(pInputData, ppBuf);
- Exynos_OSAL_Memcpy(&addrInfo.pAddrY, ppBuf[0], sizeof(addrInfo.pAddrY));
- Exynos_OSAL_Memcpy(&addrInfo.pAddrC, ppBuf[1], sizeof(addrInfo.pAddrC));
+ Exynos_OSAL_Memcpy(&(pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[0]), ppBuf[0], sizeof(OMX_PTR));
+ Exynos_OSAL_Memcpy(&(pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[1]), ppBuf[1], sizeof(OMX_PTR));
#endif
- pInputInfo->YPhyAddr = addrInfo.pAddrY;
- pInputInfo->CPhyAddr = addrInfo.pAddrC;
break;
- }
case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
- addrInfo.pAddrY = *((void **)pInputData->dataBuffer);
- addrInfo.pAddrC = (void *)((char *)addrInfo.pAddrY + pInputInfo->YSize);
-
- pInputInfo->YPhyAddr = addrInfo.pAddrY;
- pInputInfo->CPhyAddr = addrInfo.pAddrC;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[0] = *((void **)pInputData->dataBuffer);
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[1] = (char *)pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[0] +
+ (ALIGN_TO_16B(pExynosPort->portDefinition.format.video.nFrameWidth) *
+ ALIGN_TO_16B(pExynosPort->portDefinition.format.video.nFrameHeight));
break;
default:
- pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
- pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
- pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
- pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVPhyBuffer[0] = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[0] = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVPhyBuffer[1] = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer[1] = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
break;
}
}
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVDataSize[0] = ALIGN_TO_16B(pExynosPort->portDefinition.format.video.nFrameWidth) *
+ ALIGN_TO_16B(pExynosPort->portDefinition.format.video.nFrameHeight);
+ pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVDataSize[1] = pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVDataSize[0] / 2;
+
pExynosComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
pExynosComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
- if ((pMpeg4Enc->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) &&
+ if ((pMpeg4Enc->hMFCMpeg4Handle.returnCodec == VIDEO_TRUE) &&
(pVideoEnc->bFirstFrame == OMX_FALSE)) {
OMX_S32 indexTimestamp = 0;
@@ -1292,9 +1527,9 @@
}
Exynos_OSAL_SleepMillisec(0);
- pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncGetOutBuf(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, &outputInfo);
- if ((SsbSipMfcEncGetConfig(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
- (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))){
+
+ indexTimestamp = pEncOps->Get_FrameTag(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle);
+ if (indexTimestamp < 0 || indexTimestamp >= MAX_TIMESTAMP) {
pOutputData->timeStamp = pInputData->timeStamp;
pOutputData->nFlags = pInputData->nFlags;
} else {
@@ -1302,34 +1537,36 @@
pOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
}
- if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec == MFC_RET_OK) {
+ if (pVideoEnc->pOutbuf != NULL) {
/** Fill Output Buffer **/
- pOutputData->dataBuffer = outputInfo.StrmVirAddr;
- pOutputData->allocSize = outputInfo.dataSize;
- pOutputData->dataLen = outputInfo.dataSize;
+ pOutputData->dataBuffer = pVideoEnc->pOutbuf->planes[0].addr;
+ pOutputData->allocSize = pVideoEnc->pOutbuf->planes[0].allocSize;
+ pOutputData->dataLen = pVideoEnc->pOutbuf->planes[0].dataSize;
pOutputData->usedDataLen = 0;
pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
- if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME)
+ if (pVideoEnc->pOutbuf->frameType == VIDEO_FRAME_I)
pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
- Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "MFC Encode OK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "MFC Encode OK!");
ret = OMX_ErrorNone;
} else {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
- ret = OMX_ErrorUndefined;
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: failed to get output buffer, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
+ ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
if (pExynosComponent->getAllDelayBuffer == OMX_TRUE) {
ret = OMX_ErrorInputDataEncodeYet;
}
+
if ((pInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
pInputData->nFlags = (pOutputData->nFlags & (~OMX_BUFFERFLAG_EOS));
pExynosComponent->getAllDelayBuffer = OMX_TRUE;
ret = OMX_ErrorInputDataEncodeYet;
}
+
if ((pOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) {
pExynosComponent->getAllDelayBuffer = OMX_FALSE;
pOutputData->dataLen = 0;
@@ -1338,32 +1575,43 @@
ret = OMX_ErrorNone;
}
}
- if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec != MFC_RET_OK) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "In %s : SsbSipMfcEncExe Failed!!!\n", __func__);
- ret = OMX_ErrorUndefined;
+
+ if (pVideoEnc->configChange == OMX_TRUE) {
+ if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
+ Change_Mpeg4Enc_Param(pExynosComponent);
+ else
+ Change_H263Enc_Param(pExynosComponent);
+ pVideoEnc->configChange = OMX_FALSE;
+ }
+
+ if (pEncOps->Set_FrameTag(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set frame tag");
+ ret = OMX_ErrorInsufficientResources;
goto EXIT;
}
- pMpeg4Enc->hMFCMpeg4Handle.returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo);
- if (pMpeg4Enc->hMFCMpeg4Handle.returnCodec != MFC_RET_OK) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, pMpeg4Enc->hMFCMpeg4Handle.returnCodec);
- ret = OMX_ErrorUndefined;
- goto EXIT;
+ if (pOutbufOps->Enqueue(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ (unsigned char **)&pVideoEnc->pOutbuf->planes[0].addr,
+ (unsigned int *)&pVideoEnc->pOutbuf->planes[0].dataSize,
+ 1, NULL) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue output buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
+ }
+
+ if (pInbufOps->Enqueue(pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle,
+ (unsigned char **)pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVVirBuffer,
+ (unsigned int *)pMpeg4Enc->hMFCMpeg4Handle.pMFCYUVDataSize,
+ 2, NULL) != VIDEO_ERROR_NONE) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer");
+ ret = OMX_ErrorInsufficientResources;
+ goto EXIT;
} else {
pVideoEnc->indexInputBuffer++;
pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
}
- if (pVideoEnc->configChange == OMX_TRUE) {
- if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
- Change_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pExynosComponent);
- else
- Change_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pExynosComponent);
- pVideoEnc->configChange = OMX_FALSE;
- }
-
- SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp));
-
/* mfc encode start */
Exynos_OSAL_SemaphorePost(pVideoEnc->NBEncThread.hEncFrameStart);
pVideoEnc->NBEncThread.bEncoderRun = OMX_TRUE;
@@ -1378,179 +1626,33 @@
return ret;
}
-OMX_ERRORTYPE Exynos_MFC_Mpeg4_Encode_Block(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
+/* MFC Encode */
+OMX_ERRORTYPE Exynos_Mpeg4Enc_BufferProcess(
+ OMX_COMPONENTTYPE *pOMXComponent,
+ EXYNOS_OMX_DATA *pInputData,
+ EXYNOS_OMX_DATA *pOutputData)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle);
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
- OMX_HANDLETYPE hMFCHandle = pMpeg4Enc->hMFCMpeg4Handle.hMFCHandle;
- SSBSIP_MFC_ENC_INPUT_INFO *pInputInfo = &(pMpeg4Enc->hMFCMpeg4Handle.inputInfo);
- SSBSIP_MFC_ENC_OUTPUT_INFO outputInfo;
- EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
- MFC_ENC_ADDR_INFO addrInfo;
- OMX_U32 oneFrameSize = pInputData->dataLen;
- OMX_S32 returnCodec = 0;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = (EXYNOS_MPEG4ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle;
+ EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
+ EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
+ OMX_BOOL endOfFrame = OMX_FALSE;
+ OMX_BOOL flagEOS = OMX_FALSE;
FunctionIn();
- if (pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC == OMX_FALSE) {
- returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
- if (returnCodec != MFC_RET_OK)
- {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec);
- ret = OMX_ErrorUndefined;
- goto EXIT;
- }
-
- pOutputData->dataBuffer = outputInfo.StrmVirAddr;
- pOutputData->allocSize = outputInfo.headerSize;
- pOutputData->dataLen = outputInfo.headerSize;
- pOutputData->timeStamp = 0;
- pOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
- pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
-
- pMpeg4Enc->hMFCMpeg4Handle.bConfiguredMFC = OMX_TRUE;
-
- ret = OMX_ErrorInputDataEncodeYet;
+ if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_ENABLED(pExynosOutputPort)) ||
+ (!CHECK_PORT_POPULATED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) {
+ ret = OMX_ErrorNone;
goto EXIT;
}
-
- if ((pInputData->nFlags & OMX_BUFFERFLAG_ENDOFFRAME) &&
- (pExynosComponent->bUseFlagEOF == OMX_FALSE))
- pExynosComponent->bUseFlagEOF = OMX_TRUE;
-
- if (oneFrameSize <= 0) {
- pOutputData->timeStamp = pInputData->timeStamp;
- pOutputData->nFlags = pInputData->nFlags;
-
+ if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent)) {
ret = OMX_ErrorNone;
goto EXIT;
}
- pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
- switch (pExynosPort->portDefinition.format.video.eColorFormat) {
- case OMX_SEC_COLOR_FormatNV12TPhysicalAddress:
- case OMX_SEC_COLOR_FormatNV12LPhysicalAddress:
- case OMX_SEC_COLOR_FormatNV21LPhysicalAddress: {
-#ifndef USE_METADATABUFFERTYPE
- /* USE_FIMC_FRAME_BUFFER */
- Exynos_OSAL_Memcpy(&addrInfo.pAddrY, pInputData->dataBuffer, sizeof(addrInfo.pAddrY));
- Exynos_OSAL_Memcpy(&addrInfo.pAddrC, pInputData->dataBuffer + sizeof(addrInfo.pAddrY), sizeof(addrInfo.pAddrC));
-#else
- OMX_PTR ppBuf[3];
- Exynos_OSAL_GetInfoFromMetaData(pInputData,ppBuf);
-
- Exynos_OSAL_Memcpy(&addrInfo.pAddrY, ppBuf[0], sizeof(addrInfo.pAddrY));
- Exynos_OSAL_Memcpy(&addrInfo.pAddrC, ppBuf[1], sizeof(addrInfo.pAddrC));
-#endif
- pInputInfo->YPhyAddr = addrInfo.pAddrY;
- pInputInfo->CPhyAddr = addrInfo.pAddrC;
- break;
- }
- case OMX_SEC_COLOR_FormatNV12LVirtualAddress:
- addrInfo.pAddrY = *((void **)pInputData->dataBuffer);
- addrInfo.pAddrC = (void *)((char *)addrInfo.pAddrY + pInputInfo->YSize);
-
- pInputInfo->YPhyAddr = addrInfo.pAddrY;
- pInputInfo->CPhyAddr = addrInfo.pAddrC;
- break;
- default:
- pInputInfo->YPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YPhyAddr;
- pInputInfo->CPhyAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CPhyAddr;
- pInputInfo->YVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].YVirAddr;
- pInputInfo->CVirAddr = pVideoEnc->MFCEncInputBuffer[pVideoEnc->indexInputBuffer].CVirAddr;
- break;
- }
-
- returnCodec = SsbSipMfcEncSetInBuf(hMFCHandle, pInputInfo);
- if (returnCodec != MFC_RET_OK) {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncSetInBuf failed, ret:%d", __FUNCTION__, returnCodec);
- ret = OMX_ErrorUndefined;
- goto EXIT;
- } else {
- pVideoEnc->indexInputBuffer++;
- pVideoEnc->indexInputBuffer %= MFC_INPUT_BUFFER_NUM_MAX;
- }
-
- if (pVideoEnc->configChange == OMX_TRUE) {
- if (pMpeg4Enc->hMFCMpeg4Handle.codecType == CODEC_TYPE_MPEG4)
- Change_Mpeg4Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.mpeg4MFCParam), pExynosComponent);
- else
- Change_H263Enc_Param(&(pMpeg4Enc->hMFCMpeg4Handle.h263MFCParam), pExynosComponent);
- pVideoEnc->configChange = OMX_FALSE;
- }
-
- pExynosComponent->timeStamp[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->timeStamp;
- pExynosComponent->nFlags[pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp] = pInputData->nFlags;
- SsbSipMfcEncSetConfig(hMFCHandle, MFC_ENC_SETCONF_FRAME_TAG, &(pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp));
-
- returnCodec = SsbSipMfcEncExe(hMFCHandle);
- if (returnCodec == MFC_RET_OK) {
- OMX_S32 indexTimestamp = 0;
-
- pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp++;
- pMpeg4Enc->hMFCMpeg4Handle.indexTimestamp %= MAX_TIMESTAMP;
-
- returnCodec = SsbSipMfcEncGetOutBuf(hMFCHandle, &outputInfo);
-
- if ((SsbSipMfcEncGetConfig(hMFCHandle, MFC_ENC_GETCONF_FRAME_TAG, &indexTimestamp) != MFC_RET_OK) ||
- (((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)))) {
- pOutputData->timeStamp = pInputData->timeStamp;
- pOutputData->nFlags = pInputData->nFlags;
- } else {
- pOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp];
- pOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp];
- }
-
- if (returnCodec == MFC_RET_OK) {
- /** Fill Output Buffer **/
- pOutputData->dataBuffer = outputInfo.StrmVirAddr;
- pOutputData->allocSize = outputInfo.dataSize;
- pOutputData->dataLen = outputInfo.dataSize;
- pOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
- if (outputInfo.frameType == MFC_FRAME_TYPE_I_FRAME)
- pOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
-
- ret = OMX_ErrorNone;
- } else {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncGetOutBuf failed, ret:%d", __FUNCTION__, returnCodec);
- ret = OMX_ErrorUndefined;
- }
- } else {
- Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: SsbSipMfcEncExe failed, ret:%d", __FUNCTION__, returnCodec);
- ret = OMX_ErrorUndefined;
- }
-
-EXIT:
- FunctionOut();
-
- return ret;
-}
-
-/* MFC Encode */
-OMX_ERRORTYPE Exynos_MFC_Mpeg4Enc_bufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pInputData, EXYNOS_OMX_DATA *pOutputData)
-{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate;
- EXYNOS_OMX_BASEPORT *pInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX];
- EXYNOS_OMX_BASEPORT *pOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX];
-
- FunctionIn();
-
- if ((!CHECK_PORT_ENABLED(pInputPort)) || (!CHECK_PORT_ENABLED(pOutputPort)) ||
- (!CHECK_PORT_POPULATED(pInputPort)) || (!CHECK_PORT_POPULATED(pOutputPort))) {
- goto EXIT;
- }
- if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent)) {
- goto EXIT;
- }
-
-#ifdef NONBLOCK_MODE_PROCESS
- ret = Exynos_MFC_Mpeg4_Encode_Nonblock(pOMXComponent, pInputData, pOutputData);
-#else
- ret = Exynos_MFC_Mpeg4_Encode_Block(pOMXComponent, pInputData, pOutputData);
-#endif
+ ret = Exynos_Mpeg4Enc_Encode(pOMXComponent, pInputData, pOutputData);
if (ret != OMX_ErrorNone) {
if (ret == OMX_ErrorInputDataEncodeYet) {
pOutputData->usedDataLen = 0;
@@ -1566,8 +1668,7 @@
pInputData->dataLen -= pInputData->usedDataLen;
pInputData->usedDataLen = 0;
- pOutputData->usedDataLen = 0;
- pOutputData->remainDataLen = pOutputData->dataLen;
+ pOutputData->remainDataLen = pOutputData->dataLen - pOutputData->usedDataLen;
}
EXIT:
@@ -1576,15 +1677,17 @@
return ret;
}
-OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName)
+OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(
+ OMX_HANDLETYPE hComponent,
+ OMX_STRING componentName)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
- EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
- EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
- OMX_S32 codecType = -1;
+ EXYNOS_OMX_BASEPORT *pExynosPort = NULL;
+ EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ OMX_S32 codecType = -1;
int i = 0;
FunctionIn();
@@ -1727,17 +1830,17 @@
}
}
- pOMXComponent->GetParameter = &Exynos_MFC_Mpeg4Enc_GetParameter;
- pOMXComponent->SetParameter = &Exynos_MFC_Mpeg4Enc_SetParameter;
- pOMXComponent->GetConfig = &Exynos_MFC_Mpeg4Enc_GetConfig;
- pOMXComponent->SetConfig = &Exynos_MFC_Mpeg4Enc_SetConfig;
- pOMXComponent->GetExtensionIndex = &Exynos_MFC_Mpeg4Enc_GetExtensionIndex;
- pOMXComponent->ComponentRoleEnum = &Exynos_MFC_Mpeg4Enc_ComponentRoleEnum;
+ pOMXComponent->GetParameter = &Exynos_Mpeg4Enc_GetParameter;
+ pOMXComponent->SetParameter = &Exynos_Mpeg4Enc_SetParameter;
+ pOMXComponent->GetConfig = &Exynos_Mpeg4Enc_GetConfig;
+ pOMXComponent->SetConfig = &Exynos_Mpeg4Enc_SetConfig;
+ pOMXComponent->GetExtensionIndex = &Exynos_Mpeg4Enc_GetExtensionIndex;
+ pOMXComponent->ComponentRoleEnum = &Exynos_Mpeg4Enc_ComponentRoleEnum;
pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit;
- pExynosComponent->exynos_mfc_componentInit = &Exynos_MFC_Mpeg4Enc_Init;
- pExynosComponent->exynos_mfc_componentTerminate = &Exynos_MFC_Mpeg4Enc_Terminate;
- pExynosComponent->exynos_mfc_bufferProcess = &Exynos_MFC_Mpeg4Enc_bufferProcess;
+ pExynosComponent->exynos_mfc_componentInit = &Exynos_Mpeg4Enc_Init;
+ pExynosComponent->exynos_mfc_componentTerminate = &Exynos_Mpeg4Enc_Terminate;
+ pExynosComponent->exynos_mfc_bufferProcess = &Exynos_Mpeg4Enc_BufferProcess;
pExynosComponent->exynos_checkInputFrame = NULL;
pExynosComponent->currentState = OMX_StateLoaded;
@@ -1752,10 +1855,10 @@
OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent)
{
- OMX_ERRORTYPE ret = OMX_ErrorNone;
- OMX_COMPONENTTYPE *pOMXComponent = NULL;
+ OMX_ERRORTYPE ret = OMX_ErrorNone;
+ OMX_COMPONENTTYPE *pOMXComponent = NULL;
EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL;
- EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
+ EXYNOS_MPEG4ENC_HANDLE *pMpeg4Enc = NULL;
FunctionIn();
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h
index e8032d4..f71b60d 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/Exynos_OMX_Mpeg4enc.h
@@ -29,7 +29,7 @@
#include "Exynos_OMX_Def.h"
#include "OMX_Component.h"
-#include "SsbSipMfcApi.h"
+#include "OMX_Video.h"
typedef enum _CODEC_TYPE
@@ -41,9 +41,10 @@
typedef struct _EXYNOS_MFC_MPEG4ENC_HANDLE
{
OMX_HANDLETYPE hMFCHandle;
- SSBSIP_MFC_ENC_MPEG4_PARAM mpeg4MFCParam;
- SSBSIP_MFC_ENC_H263_PARAM h263MFCParam;
- SSBSIP_MFC_ENC_INPUT_INFO inputInfo;
+
+ OMX_PTR pMFCYUVVirBuffer[2];
+ OMX_PTR pMFCYUVPhyBuffer[2];
+ OMX_U32 pMFCYUVDataSize[2];
OMX_U32 indexTimestamp;
OMX_BOOL bConfiguredMFC;
CODEC_TYPE codecType;
@@ -66,7 +67,6 @@
extern "C" {
#endif
-
OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName);
OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent);
diff --git a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/library_register.c b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/library_register.c
index a4e49f8..2ea95ec 100644
--- a/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/library_register.c
+++ b/exynos_omx/openmax/exynos_omx/component/video/enc/mpeg4/library_register.c
@@ -24,7 +24,6 @@
* 2010.7.15 : Create
*/
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -39,7 +38,6 @@
#define EXYNOS_LOG_OFF
#include "Exynos_OSAL_Log.h"
-
OSCL_EXPORT_REF int Exynos_OMX_COMPONENT_Library_Register(ExynosRegisterComponentType **ppExynosComponent)
{
FunctionIn();
@@ -59,6 +57,6 @@
EXIT:
FunctionOut();
+
return MAX_COMPONENT_NUM;
}
-
diff --git a/exynos_omx/openmax/exynos_omx/include/exynos/Exynos_OMX_Def.h b/exynos_omx/openmax/exynos_omx/include/exynos/Exynos_OMX_Def.h
index 2d54e46..cc17f0f 100644
--- a/exynos_omx/openmax/exynos_omx/include/exynos/Exynos_OMX_Def.h
+++ b/exynos_omx/openmax/exynos_omx/include/exynos/Exynos_OMX_Def.h
@@ -115,9 +115,25 @@
OMX_SEC_COLOR_FormatNV12LPhysicalAddress = 0x7F000002,
OMX_SEC_COLOR_FormatNV12LVirtualAddress = 0x7F000003,
OMX_SEC_COLOR_FormatNV12Tiled = 0x7FC00002, /* 0x7FC00002 */
+#ifdef S3D_SUPPORT
+ OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR = 0x7FC00003, /* 0x7FC00003 */
+ OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL = 0x7FC00004, /* 0x7FC00004 */
+ OMX_SEC_COLOR_FormatNV12Tiled_TB_LR = 0x7FC00005, /* 0x7FC00005 */
+ OMX_SEC_COLOR_FormatNV12Tiled_TB_RL = 0x7FC00006, /* 0x7FC00006 */
+ OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR = 0x7FC00007, /* 0x7FC00007 */
+ OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL = 0x7FC00008, /* 0x7FC00008 */
+ OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR = 0x7FC00009, /* 0x7FC00009 */
+ OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL = 0x7FC0000A, /* 0x7FC0000A */
+ OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR = 0x7FC0000B, /* 0x7FC0000B */
+ OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL = 0x7FC0000C, /* 0x7FC0000C */
+ OMX_SEC_COLOR_FormatYUV420Planar_TB_LR = 0x7FC0000D, /* 0x7FC0000D */
+ OMX_SEC_COLOR_FormatYUV420Planar_TB_RL = 0x7FC0000E, /* 0x7FC0000E */
+#endif
OMX_SEC_COLOR_FormatNV21LPhysicalAddress = 0x7F000010,
OMX_SEC_COLOR_FormatNV21Linear = 0x7F000011,
+ /* to copy a encoded data for drm component using gsc or fimc */
+ OMX_SEC_COLOR_FormatEncodedData = OMX_COLOR_FormatYCbYCr,
/* for Android Native Window */
OMX_SEC_COLOR_FormatANBYUV420SemiPlanar = 0x100,
/* for Android SurfaceMediaSource*/
diff --git a/exynos_omx/openmax/exynos_omx/osal/Android.mk b/exynos_omx/openmax/exynos_omx/osal/Android.mk
index 47b983a..4abcd31 100644
--- a/exynos_omx/openmax/exynos_omx/osal/Android.mk
+++ b/exynos_omx/openmax/exynos_omx/osal/Android.mk
@@ -13,13 +13,19 @@
Exynos_OSAL_Memory.c \
Exynos_OSAL_Semaphore.c \
Exynos_OSAL_Library.c \
- Exynos_OSAL_Log.c
+ Exynos_OSAL_Log.c \
+ Exynos_OSAL_SharedMemory.c
+
LOCAL_PRELINK_MODULE := false
LOCAL_MODULE := libExynosOMX_OSAL
LOCAL_CFLAGS :=
+ifeq ($(BOARD_USE_S3D_SUPPORT), true)
+LOCAL_CFLAGS += -DS3D_SUPPORT
+endif
+
LOCAL_STATIC_LIBRARIES := liblog libcutils
LOCAL_C_INCLUDES := $(EXYNOS_OMX_INC)/khronos \
diff --git a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
index 6a3ecb3..dccf2bc 100644
--- a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
+++ b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_Android.cpp
@@ -146,6 +146,20 @@
case OMX_COLOR_FormatYUV420Planar:
case OMX_COLOR_FormatYUV420SemiPlanar:
case OMX_SEC_COLOR_FormatANBYUV420SemiPlanar:
+#ifdef S3D_SUPPORT
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_SBS_RL:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_LR:
+ case OMX_SEC_COLOR_FormatNV12Tiled_TB_RL:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420SemiPlanar_TB_RL:
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_SBS_RL:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_LR:
+ case OMX_SEC_COLOR_FormatYUV420Planar_TB_RL:
+#endif
usage = GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN | GRALLOC_USAGE_YUV_ADDR;
break;
default:
diff --git a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c
new file mode 100644
index 0000000..552395e
--- /dev/null
+++ b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.c
@@ -0,0 +1,297 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file Exynos_OSAL_SharedMemory.c
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Taehwan Kim (t_h.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <pthread.h>
+#include <cutils/log.h>
+#include <cutils/atomic.h>
+#include <fcntl.h>
+
+#include "Exynos_OSAL_SharedMemory.h"
+#include "ion.h"
+
+#define EXYNOS_LOG_OFF
+#include "Exynos_OSAL_Log.h"
+
+
+static int mem_cnt = 0;
+
+
+struct SEC_OMX_SHAREDMEM_LIST;
+typedef struct _SEC_OMX_SHAREDMEM_LIST
+{
+ OMX_U32 ion_buffer;
+ OMX_PTR mapAddr;
+ OMX_U32 allocSize;
+ struct _SEC_OMX_SHAREDMEM_LIST *nextMemory;
+} SEC_OMX_SHAREDMEM_LIST;
+
+typedef struct _EXYNOS_OMX_SHARE_MEMORY
+{
+ OMX_HANDLETYPE pIONHandle;
+ SEC_OMX_SHAREDMEM_LIST *pAllocMemory;
+ OMX_HANDLETYPE SMMutex;
+} EXYNOS_OMX_SHARE_MEMORY;
+
+
+OMX_HANDLETYPE Exynos_OSAL_SharedMemory_Open()
+{
+ EXYNOS_OMX_SHARE_MEMORY *pHandle = NULL;
+ ion_client IONClient = 0;
+ pHandle = (EXYNOS_OMX_SHARE_MEMORY *)Exynos_OSAL_Malloc(sizeof(EXYNOS_OMX_SHARE_MEMORY));
+ Exynos_OSAL_Memset(pHandle, 0, sizeof(EXYNOS_OMX_SHARE_MEMORY));
+ if (pHandle == NULL)
+ goto EXIT;
+
+ IONClient = (OMX_HANDLETYPE)ion_client_create();
+ if (IONClient <= 0) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "ion_client_create Error: %d", IONClient);
+ Exynos_OSAL_Free((void *)pHandle);
+ pHandle = NULL;
+ goto EXIT;
+ }
+
+ pHandle->pIONHandle = IONClient;
+
+ Exynos_OSAL_MutexCreate(&pHandle->SMMutex);
+
+EXIT:
+ return (OMX_HANDLETYPE)pHandle;
+}
+
+void Exynos_OSAL_SharedMemory_Close(OMX_HANDLETYPE handle)
+{
+ EXYNOS_OMX_SHARE_MEMORY *pHandle = (EXYNOS_OMX_SHARE_MEMORY *)handle;
+
+ Exynos_OSAL_MutexTerminate(pHandle->SMMutex);
+ pHandle->SMMutex = NULL;
+
+ ion_client_destroy((ion_client)pHandle->pIONHandle);
+ pHandle->pIONHandle = NULL;
+
+ Exynos_OSAL_Free(pHandle);
+
+ return;
+}
+
+OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMORY_TYPE memoryType)
+{
+ EXYNOS_OMX_SHARE_MEMORY *pHandle = (EXYNOS_OMX_SHARE_MEMORY *)handle;
+ SEC_OMX_SHAREDMEM_LIST *SMList = NULL;
+ SEC_OMX_SHAREDMEM_LIST *Element = NULL;
+ SEC_OMX_SHAREDMEM_LIST *currentElement = NULL;
+ ion_buffer IONBuffer = 0;
+ OMX_PTR pBuffer = NULL;
+
+ if (pHandle == NULL)
+ goto EXIT;
+
+ Element = (SEC_OMX_SHAREDMEM_LIST *)Exynos_OSAL_Malloc(sizeof(SEC_OMX_SHAREDMEM_LIST));
+ Exynos_OSAL_Memset(Element, 0, sizeof(SEC_OMX_SHAREDMEM_LIST));
+
+ if (SECURE_MEMORY == memoryType)
+ IONBuffer = (OMX_PTR)ion_alloc((ion_client)pHandle->pIONHandle, size, 0, ION_HEAP_EXYNOS_VIDEO_MASK);
+ else
+ IONBuffer = (OMX_PTR)ion_alloc((ion_client)pHandle->pIONHandle, size, 0, ION_HEAP_EXYNOS_MASK);
+
+ if (IONBuffer <= 0) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "ion_alloc Error: %d", IONBuffer);
+ Exynos_OSAL_Free((void*)Element);
+ goto EXIT;
+ }
+
+ pBuffer = ion_map(IONBuffer, size, 0);
+ if (pBuffer == NULL) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "ion_map Error");
+ ion_free(IONBuffer);
+ Exynos_OSAL_Free((void*)Element);
+ goto EXIT;
+ }
+
+ Element->ion_buffer = IONBuffer;
+ Element->mapAddr = pBuffer;
+ Element->allocSize = size;
+ Element->nextMemory = NULL;
+
+ Exynos_OSAL_MutexLock(pHandle->SMMutex);
+ SMList = pHandle->pAllocMemory;
+ if (SMList == NULL) {
+ pHandle->pAllocMemory = SMList = Element;
+ } else {
+ currentElement = SMList;
+ while (currentElement->nextMemory != NULL) {
+ currentElement = currentElement->nextMemory;
+ }
+ currentElement->nextMemory = Element;
+ }
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+
+ mem_cnt++;
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SharedMemory alloc count: %d", mem_cnt);
+
+EXIT:
+ return pBuffer;
+}
+
+void Exynos_OSAL_SharedMemory_Free(OMX_HANDLETYPE handle, OMX_PTR pBuffer)
+{
+ EXYNOS_OMX_SHARE_MEMORY *pHandle = (EXYNOS_OMX_SHARE_MEMORY *)handle;
+ SEC_OMX_SHAREDMEM_LIST *SMList = NULL;
+ SEC_OMX_SHAREDMEM_LIST *currentElement = NULL;
+ SEC_OMX_SHAREDMEM_LIST *deleteElement = NULL;
+
+ if (pHandle == NULL)
+ goto EXIT;
+
+ Exynos_OSAL_MutexLock(pHandle->SMMutex);
+ SMList = pHandle->pAllocMemory;
+ if (SMList == NULL) {
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+ goto EXIT;
+ }
+
+ currentElement = SMList;
+ if (SMList->mapAddr == pBuffer) {
+ deleteElement = SMList;
+ pHandle->pAllocMemory = SMList = SMList->nextMemory;
+ } else {
+ while ((currentElement != NULL) && (((SEC_OMX_SHAREDMEM_LIST *)(currentElement->nextMemory))->mapAddr != pBuffer))
+ currentElement = currentElement->nextMemory;
+
+ if (((SEC_OMX_SHAREDMEM_LIST *)(currentElement->nextMemory))->mapAddr == pBuffer) {
+ deleteElement = currentElement->nextMemory;
+ currentElement->nextMemory = deleteElement->nextMemory;
+ } else if (currentElement == NULL) {
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find SharedMemory");
+ goto EXIT;
+ }
+ }
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+
+ if (ion_unmap(deleteElement->mapAddr, deleteElement->allocSize)) {
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "ion_unmap fail");
+ goto EXIT;
+ }
+ deleteElement->mapAddr = NULL;
+ deleteElement->allocSize = 0;
+
+ ion_free(deleteElement->ion_buffer);
+ deleteElement->ion_buffer = 0;
+
+ Exynos_OSAL_Free(deleteElement);
+
+ mem_cnt--;
+ Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SharedMemory free count: %d", mem_cnt);
+
+EXIT:
+ return;
+}
+
+int Exynos_OSAL_SharedMemory_VirtToION(OMX_HANDLETYPE handle, OMX_PTR pBuffer)
+{
+ EXYNOS_OMX_SHARE_MEMORY *pHandle = (EXYNOS_OMX_SHARE_MEMORY *)handle;
+ SEC_OMX_SHAREDMEM_LIST *SMList = NULL;
+ SEC_OMX_SHAREDMEM_LIST *currentElement = NULL;
+ SEC_OMX_SHAREDMEM_LIST *findElement = NULL;
+ int ion_addr = 0;
+ if (pHandle == NULL)
+ goto EXIT;
+
+ Exynos_OSAL_MutexLock(pHandle->SMMutex);
+ SMList = pHandle->pAllocMemory;
+ if (SMList == NULL) {
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+ goto EXIT;
+ }
+
+ currentElement = SMList;
+ if (SMList->mapAddr == pBuffer) {
+ findElement = SMList;
+ } else {
+ while ((currentElement != NULL) && (((SEC_OMX_SHAREDMEM_LIST *)(currentElement->nextMemory))->mapAddr != pBuffer))
+ currentElement = currentElement->nextMemory;
+
+ if (((SEC_OMX_SHAREDMEM_LIST *)(currentElement->nextMemory))->mapAddr == pBuffer) {
+ findElement = currentElement->nextMemory;
+ } else if (currentElement == NULL) {
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find SharedMemory");
+ goto EXIT;
+ }
+ }
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+
+ ion_addr = findElement->ion_buffer;
+
+EXIT:
+ return ion_addr;
+}
+
+OMX_PTR Exynos_OSAL_SharedMemory_IONToVirt(OMX_HANDLETYPE handle, int ion_addr)
+{
+ EXYNOS_OMX_SHARE_MEMORY *pHandle = (EXYNOS_OMX_SHARE_MEMORY *)handle;
+ SEC_OMX_SHAREDMEM_LIST *SMList = NULL;
+ SEC_OMX_SHAREDMEM_LIST *currentElement = NULL;
+ SEC_OMX_SHAREDMEM_LIST *findElement = NULL;
+ OMX_PTR pBuffer = NULL;
+ if (pHandle == NULL)
+ goto EXIT;
+
+ Exynos_OSAL_MutexLock(pHandle->SMMutex);
+ SMList = pHandle->pAllocMemory;
+ if (SMList == NULL) {
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+ goto EXIT;
+ }
+
+ currentElement = SMList;
+ if (SMList->ion_buffer == ion_addr) {
+ findElement = SMList;
+ } else {
+ while ((currentElement != NULL) && (((SEC_OMX_SHAREDMEM_LIST *)(currentElement->nextMemory))->ion_buffer != ion_addr))
+ currentElement = currentElement->nextMemory;
+
+ if (((SEC_OMX_SHAREDMEM_LIST *)(currentElement->nextMemory))->ion_buffer == ion_addr) {
+ findElement = currentElement->nextMemory;
+ } else if (currentElement == NULL) {
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+ Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find SharedMemory");
+ goto EXIT;
+ }
+ }
+ Exynos_OSAL_MutexUnlock(pHandle->SMMutex);
+
+ pBuffer = findElement->mapAddr;
+
+EXIT:
+ return pBuffer;
+}
+
diff --git a/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.h b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.h
new file mode 100644
index 0000000..8964145
--- /dev/null
+++ b/exynos_omx/openmax/exynos_omx/osal/Exynos_OSAL_SharedMemory.h
@@ -0,0 +1,55 @@
+/*
+ *
+ * Copyright 2010 Samsung Electronics S.LSI Co. LTD
+ *
+ * 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.
+ */
+
+/*
+ * @file Exynos_OSAL_SharedMemory.h
+ * @brief
+ * @author SeungBeom Kim (sbcrux.kim@samsung.com)
+ * Taehwan Kim (t_h.kim@samsung.com)
+ * @version 1.1.0
+ * @history
+ * 2010.7.15 : Create
+ */
+
+#ifndef EXYNOS_OSAL_SHAREDMEMORY
+#define EXYNOS_OSAL_SHAREDMEMORY
+
+#include "OMX_Types.h"
+
+typedef enum _MEMORY_TYPE
+{
+ NORMAL_MEMORY = 0x00,
+ SECURE_MEMORY
+} MEMORY_TYPE;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+OMX_HANDLETYPE Exynos_OSAL_SharedMemory_Open();
+void Exynos_OSAL_SharedMemory_Close(OMX_HANDLETYPE handle);
+OMX_PTR Exynos_OSAL_SharedMemory_Alloc(OMX_HANDLETYPE handle, OMX_U32 size, MEMORY_TYPE memoryType);
+void Exynos_OSAL_SharedMemory_Free(OMX_HANDLETYPE handle, OMX_PTR pBuffer);
+int Exynos_OSAL_SharedMemory_VirtToION(OMX_HANDLETYPE handle, OMX_PTR pBuffer);
+OMX_PTR Exynos_OSAL_SharedMemory_IONToVirt(OMX_HANDLETYPE handle, int ion_addr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+