From 601bcef48ecbd156207f0b38cd526f0e14699d3a Mon Sep 17 00:00:00 2001 From: Dheeraj CVR Date: Thu, 12 Mar 2015 08:11:11 +0530 Subject: [PATCH] exynos: multimedia: add support for OMX_IndexParamVideoIntraRefresh parameter filiprrs: This fixes miracast, and possibly resolves issues with features like chromecast, screen recording, wifi display etc. Change-Id: I35f789a9ae29df0198b21c98dc866d8886799893 --- .../component/video/enc/SEC_OMX_Venc.c | 53 +++++++++++++++++++ .../component/video/enc/SEC_OMX_Venc.h | 1 + .../video/enc/h264/SEC_OMX_H264enc.c | 10 +++- .../video/enc/mpeg4/SEC_OMX_Mpeg4enc.c | 20 ++++++- 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c index 94ba5a4..cbc3858 100644 --- a/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c +++ b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.c @@ -1243,6 +1243,30 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeGetParameter( portDefinition->nBufferSize = MAX_INPUT_METADATA_BUFFER_SIZE; } #endif + } + break; + case OMX_IndexParamVideoIntraRefresh: + { + OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)ComponentParameterStructure; + OMX_U32 nPortIndex = pIntraRefresh->nPortIndex; + SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); + if (ret != OMX_ErrorNone) + goto EXIT; + + if (nPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle; + pIntraRefresh->eRefreshMode = pVideoEnc->intraRefresh.eRefreshMode; + pIntraRefresh->nAirMBs = pVideoEnc->intraRefresh.nAirMBs; + pIntraRefresh->nAirRef = pVideoEnc->intraRefresh.nAirRef; + pIntraRefresh->nCirMBs = pVideoEnc->intraRefresh.nCirMBs; + + ret = OMX_ErrorNone; } break; default: @@ -1414,6 +1438,35 @@ OMX_ERRORTYPE SEC_OMX_VideoEncodeSetParameter( } break; #endif + case OMX_IndexParamVideoIntraRefresh: + { + OMX_VIDEO_PARAM_INTRAREFRESHTYPE *pIntraRefresh = (OMX_VIDEO_PARAM_INTRAREFRESHTYPE *)ComponentParameterStructure; + OMX_U32 nPortIndex = pIntraRefresh->nPortIndex; + SEC_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; + + ret = SEC_OMX_Check_SizeVersion(pIntraRefresh, sizeof(OMX_VIDEO_PARAM_INTRAREFRESHTYPE)); + if (ret != OMX_ErrorNone) + goto EXIT; + + if (nPortIndex != OUTPUT_PORT_INDEX) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + pVideoEnc = (SEC_OMX_VIDEOENC_COMPONENT *)pSECComponent->hComponentHandle; + if (pIntraRefresh->eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) { + pVideoEnc->intraRefresh.eRefreshMode = pIntraRefresh->eRefreshMode; + pVideoEnc->intraRefresh.nCirMBs = pIntraRefresh->nCirMBs; + SEC_OSAL_Log(SEC_LOG_TRACE, "OMX_VIDEO_IntraRefreshCyclic Enable, nCirMBs: %d", + pVideoEnc->intraRefresh.nCirMBs); + } else { + ret = OMX_ErrorUnsupportedSetting; + goto EXIT; + } + + ret = OMX_ErrorNone; + } + break; default: { ret = SEC_OMX_SetParameter(hComponent, nIndex, ComponentParameterStructure); diff --git a/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h index 7403544..40ded5b 100644 --- a/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h +++ b/exynos/multimedia/openmax/component/video/enc/SEC_OMX_Venc.h @@ -92,6 +92,7 @@ typedef struct _SEC_OMX_VIDEOENC_COMPONENT OMX_BOOL IntraRefreshVOP; OMX_VIDEO_CONTROLRATETYPE eControlRate[ALL_PORT_NUM]; OMX_VIDEO_PARAM_QUANTIZATIONTYPE quantization; + OMX_VIDEO_PARAM_INTRAREFRESHTYPE intraRefresh; OMX_BOOL bFirstFrame; MFC_ENC_INPUT_BUFFER MFCEncInputBuffer[MFC_INPUT_BUFFER_NUM_MAX]; OMX_U32 indexInputBuffer; diff --git a/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c b/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c index f8b4585..a7e6e7e 100644 --- a/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c +++ b/exynos/multimedia/openmax/component/video/enc/h264/SEC_OMX_H264enc.c @@ -205,7 +205,6 @@ void Set_H264Enc_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONEN pH264Arg->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; pH264Arg->IDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1; pH264Arg->SliceMode = 0; - pH264Arg->RandomIntraMBRefresh = 0; pH264Arg->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; pH264Arg->QSCodeMax = 51; pH264Arg->QSCodeMin = 10; @@ -259,6 +258,15 @@ void Set_H264Enc_Param(SSBSIP_MFC_ENC_H264_PARAM *pH264Arg, SEC_OMX_BASECOMPONEN break; } + if (pVideoEnc->intraRefresh.eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) { + /* Cyclic Mode */ + pH264Arg->RandomIntraMBRefresh = pVideoEnc->intraRefresh.nCirMBs; + SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh: %d", pH264Arg->RandomIntraMBRefresh); + } else { + /* Don't support "Adaptive" and "Cyclic + Adaptive" */ + pH264Arg->RandomIntraMBRefresh = 0; + } + switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) { case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: case OMX_SEC_COLOR_FormatNV12LVirtualAddress: diff --git a/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c b/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c index ebfbe6e..760fc37 100644 --- a/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c +++ b/exynos/multimedia/openmax/component/video/enc/mpeg4/SEC_OMX_Mpeg4enc.c @@ -201,7 +201,6 @@ void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOM pMpeg4Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; pMpeg4Param->IDRPeriod = pMpeg4Enc->mpeg4Component[OUTPUT_PORT_INDEX].nPFrames + 1; pMpeg4Param->SliceMode = 0; - pMpeg4Param->RandomIntraMBRefresh = 0; pMpeg4Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; pMpeg4Param->QSCodeMax = 30; pMpeg4Param->QSCodeMin = 10; @@ -242,6 +241,15 @@ void Set_Mpeg4Enc_Param(SSBSIP_MFC_ENC_MPEG4_PARAM *pMpeg4Param, SEC_OMX_BASECOM break; } + if (pVideoEnc->intraRefresh.eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) { + /* Cyclic Mode */ + pMpeg4Param->RandomIntraMBRefresh = pVideoEnc->intraRefresh.nCirMBs; + SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh: %d", pMpeg4Param->RandomIntraMBRefresh); + } else { + /* Don't support "Adaptive" and "Cyclic + Adaptive" */ + pMpeg4Param->RandomIntraMBRefresh = 0; + } + switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) { case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: case OMX_SEC_COLOR_FormatNV12LVirtualAddress: @@ -322,7 +330,6 @@ void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPON pH263Param->SourceHeight = pSECOutputPort->portDefinition.format.video.nFrameHeight; pH263Param->IDRPeriod = pMpeg4Enc->h263Component[OUTPUT_PORT_INDEX].nPFrames + 1; pH263Param->SliceMode = 0; - pH263Param->RandomIntraMBRefresh = 0; pH263Param->Bitrate = pSECOutputPort->portDefinition.format.video.nBitrate; pH263Param->QSCodeMax = 30; pH263Param->QSCodeMin = 10; @@ -356,6 +363,15 @@ void Set_H263Enc_Param(SSBSIP_MFC_ENC_H263_PARAM *pH263Param, SEC_OMX_BASECOMPON break; } + if (pVideoEnc->intraRefresh.eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) { + /* Cyclic Mode */ + pH263Param->RandomIntraMBRefresh = pVideoEnc->intraRefresh.nCirMBs; + SEC_OSAL_Log(SEC_LOG_TRACE, "RandomIntraMBRefresh: %d", pH263Param->RandomIntraMBRefresh); + } else { + /* Don't support "Adaptive" and "Cyclic + Adaptive" */ + pH263Param->RandomIntraMBRefresh = 0; + } + switch ((SEC_OMX_COLOR_FORMATTYPE)pSECInputPort->portDefinition.format.video.eColorFormat) { case OMX_SEC_COLOR_FormatNV12LPhysicalAddress: case OMX_SEC_COLOR_FormatNV12LVirtualAddress: -- 2.20.1