From 9b8dd7312dce4f665ca2a0233e2b95bce208cf82 Mon Sep 17 00:00:00 2001 From: qijinquan Date: Thu, 3 Nov 2022 17:21:11 +0800 Subject: [PATCH] feat: Use the definition of vp9 in Codec instead of that in local. Signed-off-by: qijinquan --- .../component/video/dec/Rkvpu_OMX_Vdec.c | 10 +-- .../video/dec/Rkvpu_OMX_VdecControl.c | 30 +++++-- .../video/enc/Rkvpu_OMX_VencControl.c | 78 ++++++++++++------- .../omx_il/include/khronos/VideoExt.h | 1 - .../omx_il/osal/Rockchip_OSAL_OHOS.cpp | 8 +- 5 files changed, 83 insertions(+), 44 deletions(-) diff --git a/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_Vdec.c b/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_Vdec.c index df35c41a..3fbd9b11 100644 --- a/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_Vdec.c +++ b/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_Vdec.c @@ -80,7 +80,7 @@ static const CodeMap kCodeMap[] = { {OMX_RK_VIDEO_CodingVP8, (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP8EXT}, {OMX_RK_VIDEO_CodingWMV, OMX_VIDEO_CodingWMV}, {OMX_RK_VIDEO_CodingHEVC, (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingHEVC}, - {OMX_RK_VIDEO_CodingVP9, (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9}, + {OMX_RK_VIDEO_CodingVP9, (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9}, /* * remove copyright coding type * @@ -1668,17 +1668,17 @@ OMX_ERRORTYPE Rockchip_OMX_ComponentConstructor(OMX_HANDLETYPE hComponent, OMX_S } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP9_DEC)) { Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/x-vnd.on2.vp9"); - pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9; - pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9; + pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9; + pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9; } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP9_DRM_DEC)) { omx_err("Rockchip_OMX_ComponentConstructor VP9 secure"); Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); Rockchip_OSAL_Strcpy(pRockchipPort->portDefinition.format.video.cMIMEType, "video/x-vnd.on2.vp9"); - pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9; + pVideoDec->codecId = (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9; #ifdef HAVE_L1_SVP_MODE pVideoDec->bDRMPlayerMode = OMX_TRUE; #endif - pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9; + pRockchipPort->portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9; } else if (!strcmp(componentName, RK_OMX_COMPONENT_VP8_DRM_DEC)) { omx_err("Rockchip_OMX_ComponentConstructor VP8 secure"); Rockchip_OSAL_Memset(pRockchipPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); diff --git a/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_VdecControl.c b/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_VdecControl.c index 93f41d4a..6657441a 100644 --- a/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_VdecControl.c +++ b/rk3568/hardware/omx_il/component/video/dec/Rkvpu_OMX_VdecControl.c @@ -1484,14 +1484,30 @@ OMX_ERRORTYPE Rkvpu_OMX_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OM } ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex]; OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = &pRockchipPort->portDefinition; + OMX_U32 index = videoFormat->codecColorIndex; if (portIndex == INPUT_PORT_INDEX) { + if (index > supportFormat_0) { + omx_err_f("nomore index supported"); + ret = OMX_ErrorNoMore; + } videoFormat->codecColorFormat = Rockchip_OSAL_OmxColorFormat2CodecFormat(portDefinition->format.video.eColorFormat); videoFormat->codecCompressFormat = portDefinition->format.video.eCompressionFormat; videoFormat->framerate = portDefinition->format.video.xFramerate; } else { - videoFormat->codecColorFormat = - Rockchip_OSAL_OmxColorFormat2CodecFormat(OMX_COLOR_FormatYUV420SemiPlanar); + switch (index) { + case supportFormat_0: { + videoFormat->codecColorFormat = + Rockchip_OSAL_OmxColorFormat2CodecFormat(OMX_COLOR_FormatYUV420SemiPlanar); + break; + } + default: { + omx_err_f("nomore index supported"); + ret = OMX_ErrorNoMore; + goto EXIT; + } + } + videoFormat->framerate = portDefinition->format.video.xFramerate; videoFormat->codecCompressFormat = OMX_VIDEO_CodingUnused; } @@ -1595,7 +1611,7 @@ OMX_ERRORTYPE Rkvpu_OMX_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, OMX_IN OM Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_WMV3_DEC_ROLE); } else if (pVideoDec->codecId == OMX_VIDEO_CodingRV) { Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_RMVB_DEC_ROLE); - } else if (pVideoDec->codecId == OMX_VIDEO_CodingVP9) { + } else if (pVideoDec->codecId == CODEC_OMX_VIDEO_CodingVP9) { Rockchip_OSAL_Strcpy((char *)pComponentRole->cRole, RK_OMX_COMPONENT_VP9_DEC_ROLE); } } @@ -1966,7 +1982,7 @@ OMX_ERRORTYPE Rkvpu_OMX_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP8EXT; } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_VP9_DEC_ROLE)) { pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = - (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9; + (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9; } else if (!Rockchip_OSAL_Strcmp((char*)pComponentRole->cRole, RK_OMX_COMPONENT_HEVC_DEC_ROLE)) { pRockchipComponent->pRockchipPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingHEVC; @@ -2027,7 +2043,7 @@ OMX_ERRORTYPE Rkvpu_OMX_SetParameter(OMX_IN OMX_HANDLETYPE hComponent, if (params->eProfile == OMX_VIDEO_AVCProfileHigh10) { pVideoDec->bIs10bit = OMX_TRUE; } - } else if (pVideoDec->codecId == OMX_VIDEO_CodingVP9) { + } else if (pVideoDec->codecId == CODEC_OMX_VIDEO_CodingVP9) { } } } @@ -2576,7 +2592,7 @@ OMX_U32 Rkvpu_GetCompressRatioByCodingtype( nCompressRatio = 2; // 2:value of nCompressRatio break; case CODEC_OMX_VIDEO_CodingHEVC: - case OMX_VIDEO_CodingVP9: + case CODEC_OMX_VIDEO_CodingVP9: nCompressRatio = 4; // 4:value of nCompressRatio break; default: @@ -2630,7 +2646,7 @@ OMX_ERRORTYPE Rkvpu_CheckPortDefinition( } if (pNewPortDefinition->format.video.eCompressionFormat == CODEC_OMX_VIDEO_CodingHEVC || pNewPortDefinition->format.video.eCompressionFormat == OMX_VIDEO_CodingAVC || - pNewPortDefinition->format.video.eCompressionFormat == OMX_VIDEO_CodingVP9) { + pNewPortDefinition->format.video.eCompressionFormat == CODEC_OMX_VIDEO_CodingVP9) { nSupportWidthMax = 4096; // 4096:value of nSupportWidthMax } else { omx_err("decoder width %d big than support width %d return error", diff --git a/rk3568/hardware/omx_il/component/video/enc/Rkvpu_OMX_VencControl.c b/rk3568/hardware/omx_il/component/video/enc/Rkvpu_OMX_VencControl.c index 1124dd72..338c7391 100644 --- a/rk3568/hardware/omx_il/component/video/enc/Rkvpu_OMX_VencControl.c +++ b/rk3568/hardware/omx_il/component/video/enc/Rkvpu_OMX_VencControl.c @@ -1019,12 +1019,9 @@ OMX_ERRORTYPE Rkvpu_OMX_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, break; } default: { - if (index > supportFormat_0) { - omx_err_f("index is large than supportFormat_0"); - ret = OMX_ErrorNoMore; - goto EXIT; - } - break; + omx_err_f("index is large than supportFormat_0"); + ret = OMX_ErrorNoMore; + goto EXIT; } } } else if (portIndex == OUTPUT_PORT_INDEX) { @@ -1090,30 +1087,57 @@ OMX_ERRORTYPE Rkvpu_OMX_GetParameter(OMX_IN OMX_HANDLETYPE hComponent, break; } case OMX_IndexCodecVideoPortFormat: { - struct CodecVideoPortFormatParam *videoFormat = (struct CodecVideoPortFormatParam *)ComponentParameterStructure; - if (videoFormat == NULL) { - omx_err_f("videoFormat is null"); - ret = OMX_ErrorBadParameter; - goto EXIT; - } - OMX_U32 portIndex = videoFormat->portIndex; - if (portIndex >= pRockchipComponent->portParam.nPorts) { - ret = OMX_ErrorBadPortIndex; - goto EXIT; - } - - ret = Rockchip_OMX_Check_SizeVersion(videoFormat, sizeof(struct CodecVideoPortFormatParam)); - if (ret != OMX_ErrorNone) { - goto EXIT; - } - ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex]; - OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = &pRockchipPort->portDefinition; - if (portIndex == INPUT_PORT_INDEX) { - videoFormat->codecColorFormat = - Rockchip_OSAL_OmxColorFormat2CodecFormat(OMX_COLOR_FormatYUV420SemiPlanar); + struct CodecVideoPortFormatParam *videoFormat = + (struct CodecVideoPortFormatParam *)ComponentParameterStructure; + if (videoFormat == NULL) { + omx_err_f("videoFormat is null"); + ret = OMX_ErrorBadParameter; + goto EXIT; + } + OMX_U32 portIndex = videoFormat->portIndex; + if (portIndex >= pRockchipComponent->portParam.nPorts) { + ret = OMX_ErrorBadPortIndex; + goto EXIT; + } + + ret = Rockchip_OMX_Check_SizeVersion(videoFormat, sizeof(struct CodecVideoPortFormatParam)); + if (ret != OMX_ErrorNone) { + goto EXIT; + } + ROCKCHIP_OMX_BASEPORT *pRockchipPort = &pRockchipComponent->pRockchipPort[portIndex]; + OMX_PARAM_PORTDEFINITIONTYPE *portDefinition = &pRockchipPort->portDefinition; + uint32_t index = videoFormat->codecColorIndex; + if (portIndex == INPUT_PORT_INDEX) { + switch (index) { + case supportFormat_0: { + videoFormat->codecColorFormat = + Rockchip_OSAL_OmxColorFormat2CodecFormat(OMX_COLOR_FormatYUV420SemiPlanar); + break; + } + case supportFormat_1: { + videoFormat->codecColorFormat = + Rockchip_OSAL_OmxColorFormat2CodecFormat((OMX_COLOR_FORMATTYPE)CODEC_COLOR_FORMAT_RGBA8888); + break; + } + case supportFormat_2: { + videoFormat->codecColorFormat = + Rockchip_OSAL_OmxColorFormat2CodecFormat(OMX_COLOR_Format32bitBGRA8888); + break; + } + default: { + omx_err_f("index is large than supportFormat_0"); + ret = OMX_ErrorNoMore; + goto EXIT; + } + } videoFormat->codecCompressFormat = OMX_VIDEO_CodingUnused; videoFormat->framerate = portDefinition->format.video.xFramerate; } else { + if (index > supportFormat_0) { + omx_err_f("index is too large"); + ret = OMX_ErrorNoMore; + goto EXIT; + } videoFormat->codecColorFormat = Rockchip_OSAL_OmxColorFormat2CodecFormat(portDefinition->format.video.eColorFormat); videoFormat->framerate = portDefinition->format.video.xFramerate; diff --git a/rk3568/hardware/omx_il/include/khronos/VideoExt.h b/rk3568/hardware/omx_il/include/khronos/VideoExt.h index 6caba039..c8da1b3c 100644 --- a/rk3568/hardware/omx_il/include/khronos/VideoExt.h +++ b/rk3568/hardware/omx_il/include/khronos/VideoExt.h @@ -91,7 +91,6 @@ typedef struct OMX_CONFIG_DESCRIBECOLORASPECTSPARAMS { typedef enum OMX_VIDEO_CODINGTYPEEXT { OMX_VIDEO_CodingVP8EXT = 9, /**< Google VP8, formerly known as On2 VP8 */ - OMX_VIDEO_CodingVP9, /**< Google VP9 */ OMX_VIDEO_AVCLevel52 = 0x10000, }OMX_VIDEO_CODINGTYPEEXT; diff --git a/rk3568/hardware/omx_il/osal/Rockchip_OSAL_OHOS.cpp b/rk3568/hardware/omx_il/osal/Rockchip_OSAL_OHOS.cpp index 0530937b..04356e5f 100644 --- a/rk3568/hardware/omx_il/osal/Rockchip_OSAL_OHOS.cpp +++ b/rk3568/hardware/omx_il/osal/Rockchip_OSAL_OHOS.cpp @@ -69,7 +69,7 @@ OMX_U32 Get_Video_HorAlign(OMX_VIDEO_CODINGTYPE codecId, OMX_U32 width, OMX_U32 } else // 255:byte alignment, 256:byte alignment stride = ((width + 255) & (~255)) | (256); - } else if (codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9) { + } else if (codecId == (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9) { #ifdef AVS100 // 255:byte alignment, 256:byte alignment stride = ((width + 255) & (~255)) | (256); @@ -112,7 +112,7 @@ OMX_U32 Get_Video_VerAlign(OMX_VIDEO_CODINGTYPE codecId, OMX_U32 height, OMX_U32 stride = (height + 15) & (~15); // 15:byte alignment else stride = (height + 7) & (~7); // 7:byte alignment - } else if (codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9) { + } else if (codecId == (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9) { stride = (height + 63) & (~63); // 63:byte alignment } else { stride = ((height + 15) & (~15)); // 15:byte alignment @@ -144,7 +144,7 @@ OMX_BOOL Rockchip_OSAL_Check_Use_FBCMode(OMX_VIDEO_CODINGTYPE codecId, int32_t d if ((depth == OMX_DEPTH_BIT_10) || ((width * height > 1920 * 1088) // 1920:Resolution size, 1088:Resolution size && (codecId == OMX_VIDEO_CodingAVC || codecId == (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingHEVC - || codecId == (OMX_VIDEO_CODINGTYPE)OMX_VIDEO_CodingVP9))) { + || codecId == (OMX_VIDEO_CODINGTYPE)CODEC_OMX_VIDEO_CodingVP9))) { fbcMode = OMX_TRUE; } #else @@ -873,7 +873,7 @@ OMX_U32 Rockchip_OSAL_CalculateTotalRefFrames( nRefFramesNum = 6; } } break; - case OMX_VIDEO_CodingVP9: { + case CODEC_OMX_VIDEO_CodingVP9: { nRefFramesNum = 4096 * 2176 * 4 / (width * height);/* 4096:Resolution size, 2176:Resolution size, 4:frame number */ if (nRefFramesNum > 8) { // 8:frame number -- Gitee