From fbda0b5b736386a776be95f25661167919626296 Mon Sep 17 00:00:00 2001 From: Deepak Kushwah Date: Mon, 21 Nov 2016 13:18:17 +0530 Subject: [PATCH] mm-video: venc: Expose OMX_QTIIndexParamIframeSizeType OMX_QTIIndexParamIframeSizeType allows clients to control the size of I-frames. Change-Id: I091f425a26c28207b208f1737904a0176f45bb0b CRs-Fixed: 1082285 --- mm-core/inc/OMX_QCOMExtns.h | 14 ++++++ .../vidc/venc/inc/video_encoder_device_v4l2.h | 1 + .../vidc/venc/src/omx_video_encoder.cpp | 10 ++++ .../venc/src/video_encoder_device_v4l2.cpp | 49 +++++++++++++++++++ 4 files changed, 74 insertions(+) diff --git a/mm-core/inc/OMX_QCOMExtns.h b/mm-core/inc/OMX_QCOMExtns.h index 614753db..c0d91dae 100644 --- a/mm-core/inc/OMX_QCOMExtns.h +++ b/mm-core/inc/OMX_QCOMExtns.h @@ -636,6 +636,8 @@ enum OMX_QCOM_EXTN_INDEXTYPE /* Dither control for 10bit */ OMX_QTIIndexParamDitherControl = 0x7F000069, + /* Suggest how big Iframe sizes should be */ + OMX_QTIIndexParamIframeSizeType = 0x7F000070, }; /** @@ -1907,6 +1909,18 @@ typedef struct QOMX_VIDEO_H264ENTROPYCODINGTYPE { OMX_U32 nCabacInitIdc; } QOMX_VIDEO_H264ENTROPYCODINGTYPE; +typedef enum QOMX_VIDEO_IFRAMESIZE_TYPE { + QOMX_IFRAMESIZE_DEFAULT, + QOMX_IFRAMESIZE_MEDIUM, + QOMX_IFRAMESIZE_HUGE, + QOMX_IFRAMESIZE_UNLIMITED, +} QOMX_VIDEO_IFRAMESIZE_TYPE; + +typedef struct QOMX_VIDEO_IFRAMESIZE { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + QOMX_VIDEO_IFRAMESIZE_TYPE eType; +} QOMX_VIDEO_IFRAMESIZE; /* VIDEO POSTPROCESSING CTRLS AND ENUMS */ /* MUST KEEP SAME AS IN vpp.h */ diff --git a/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h b/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h index b13d6133..1e64ec08 100644 --- a/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h +++ b/mm-video-v4l2/vidc/venc/inc/video_encoder_device_v4l2.h @@ -575,6 +575,7 @@ class venc_dev bool venc_set_colorspace(OMX_U32 primaries, OMX_U32 range, OMX_U32 transfer_chars, OMX_U32 matrix_coeffs); OMX_ERRORTYPE venc_set_temporal_layers(OMX_VIDEO_PARAM_ANDROID_TEMPORALLAYERINGTYPE *pTemporalParams); OMX_ERRORTYPE venc_set_temporal_layers_internal(); + bool venc_set_iframesize_type(QOMX_VIDEO_IFRAMESIZE_TYPE type); #ifdef MAX_RES_1080P OMX_U32 pmem_free(); diff --git a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp index d5ac1d9b..a23218f4 100644 --- a/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp +++ b/mm-video-v4l2/vidc/venc/src/omx_video_encoder.cpp @@ -1727,6 +1727,16 @@ OMX_ERRORTYPE omx_venc::set_parameter(OMX_IN OMX_HANDLETYPE hComp, (OMX_INDEXTYPE)OMX_QTIIndexParamDisablePQ); break; } + case OMX_QTIIndexParamIframeSizeType: + { + VALIDATE_OMX_PARAM_DATA(paramData, QOMX_VIDEO_IFRAMESIZE); + if (!handle->venc_set_param(paramData, + (OMX_INDEXTYPE)OMX_QTIIndexParamIframeSizeType)) { + DEBUG_PRINT_ERROR("ERROR: Setting OMX_QTIIndexParamIframeSizeType failed"); + return OMX_ErrorUnsupportedSetting; + } + break; + } case OMX_IndexParamVideoSliceFMO: default: { diff --git a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp index 73e7cf71..6e1f1167 100644 --- a/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp +++ b/mm-video-v4l2/vidc/venc/src/video_encoder_device_v4l2.cpp @@ -1707,6 +1707,7 @@ bool venc_dev::venc_set_param(void *paramData, OMX_INDEXTYPE index) struct v4l2_format fmt; struct v4l2_requestbuffers bufreq; int ret; + bool isCBR; switch ((int)index) { case OMX_IndexParamPortDefinition: @@ -2516,6 +2517,23 @@ bool venc_dev::venc_set_param(void *paramData, OMX_INDEXTYPE index) #endif break; } + case OMX_QTIIndexParamIframeSizeType: + { + QOMX_VIDEO_IFRAMESIZE* pParam = + (QOMX_VIDEO_IFRAMESIZE *)paramData; + isCBR = rate_ctrl.rcmode == V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_VFR || + rate_ctrl.rcmode == V4L2_CID_MPEG_VIDC_VIDEO_RATE_CONTROL_CBR_CFR; + if (!isCBR) { + DEBUG_PRINT_ERROR("venc_set_param: OMX_QTIIndexParamIframeSizeType not allowed for this configuration isCBR(%d)", + isCBR); + return OMX_ErrorUnsupportedSetting; + } + if (!venc_set_iframesize_type(pParam->eType)) { + DEBUG_PRINT_ERROR("ERROR: Setting OMX_QTIIndexParamIframeSizeType failed"); + return OMX_ErrorUnsupportedSetting; + } + break; + } case OMX_IndexParamVideoSliceFMO: default: DEBUG_PRINT_ERROR("ERROR: Unsupported parameter in venc_set_param: %u", @@ -6549,6 +6567,37 @@ bool venc_dev::venc_set_low_latency(OMX_BOOL enable) return true; } +bool venc_dev::venc_set_iframesize_type(QOMX_VIDEO_IFRAMESIZE_TYPE type) +{ + struct v4l2_control control; + control.id = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_TYPE; + + switch (type) { + case QOMX_IFRAMESIZE_DEFAULT: + control.value = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_DEFAULT; + break; + case QOMX_IFRAMESIZE_MEDIUM: + control.value = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_MEDIUM; + break; + case QOMX_IFRAMESIZE_HUGE: + control.value = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_HUGE; + break; + case QOMX_IFRAMESIZE_UNLIMITED: + control.value = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_UNLIMITED; + break; + default: + DEBUG_PRINT_INFO("Unknown Iframe Size found setting it to default"); + control.value = V4L2_CID_MPEG_VIDC_VIDEO_IFRAME_SIZE_DEFAULT; + } + + if (ioctl(m_nDriver_fd, VIDIOC_S_CTRL, &control)) { + DEBUG_PRINT_ERROR("Failed to set iframe size hint"); + return false; + } + + return true; +} + bool venc_dev::venc_set_baselayerid(OMX_U32 baseid) { struct v4l2_control control;