From d748abcecfbeb6a14b93ebc8aac5f3e0d33dbc45 Mon Sep 17 00:00:00 2001 From: madhuri_nagaraj Date: Thu, 18 Oct 2018 05:10:12 +0800 Subject: [PATCH] [Encode] Enable REXT(CL#808610) Implement REXT Change-Id: I9626f9b926ac563f3973260d879a030d7b2a3270 --- .../codec/hal/codechal_encode_hevc_base.cpp | 3 +- .../codec/ddi/media_ddi_encode_hevc.cpp | 61 +++++----- .../common/codec/ddi/media_libva_encoder.cpp | 3 +- media_driver/linux/common/ddi/media_libva.cpp | 11 +- .../linux/common/ddi/media_libva_caps.cpp | 105 +++++++++++++++++- .../linux/common/os/linux_system_info.h | 1 + .../linux/gen10/ddi/media_sku_wa_g10.cpp | 1 + .../linux/gen11/ddi/media_sku_wa_g11.cpp | 1 + 8 files changed, 144 insertions(+), 42 deletions(-) diff --git a/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp b/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp index d7f1baede5f..b1ebac6f4c0 100644 --- a/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp +++ b/media_driver/agnostic/common/codec/hal/codechal_encode_hevc_base.cpp @@ -2210,8 +2210,7 @@ void CodechalEncodeHevcBase::SetHcpSrcSurfaceParams(MHW_VDBOX_SURFACE_PARAMS& sr srcSurfaceParams.ucBitDepthChromaMinus8 = m_hevcSeqParams->bit_depth_chroma_minus8; srcSurfaceParams.bDisplayFormatSwizzle = m_hevcPicParams->bDisplayFormatSwizzle; srcSurfaceParams.ChromaType = m_outputChromaFormat; - srcSurfaceParams.bSrc8Pak10Mode = (!m_hevcSeqParams->SourceBitDepth) && - (m_hevcSeqParams->bit_depth_luma_minus8 == 2); + srcSurfaceParams.bSrc8Pak10Mode = false; //No usage for 8->10 bit encode srcSurfaceParams.dwActualHeight = ((m_hevcSeqParams->wFrameHeightInMinCbMinus1 + 1) << (m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3)); } diff --git a/media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.cpp b/media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.cpp index fa1e2fadf78..4854eb4e385 100644 --- a/media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.cpp +++ b/media_driver/linux/common/codec/ddi/media_ddi_encode_hevc.cpp @@ -96,6 +96,7 @@ VAStatus DdiEncodeHevc::ContextInitialize( { codecHalSettings->codecFunction = CODECHAL_FUNCTION_ENC_VDENC_PAK; codecHalSettings->disableUltraHME = true; + codecHalSettings->disableSuperHME = true; } else { @@ -105,11 +106,31 @@ VAStatus DdiEncodeHevc::ContextInitialize( codecHalSettings->width = m_encodeCtx->dworiFrameWidth; codecHalSettings->mode = m_encodeCtx->wModeType; codecHalSettings->standard = CODECHAL_HEVC; - codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420; - codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_8_BITS; - if (m_is10Bit) + + if(m_encodeCtx->vaProfile==VAProfileHEVCMain) + { + codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420; + codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_8_BITS; + } + else if(m_encodeCtx->vaProfile==VAProfileHEVCMain10) + { + codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420; + codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_10_BITS; + } + else if(m_encodeCtx->vaProfile == VAProfileHEVCMain12) + { + codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV420; + codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_12_BITS; + } + else if(m_encodeCtx->vaProfile == VAProfileHEVCMain422_10) + { + codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV422; + codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_10_BITS; + } + else if(m_encodeCtx->vaProfile == VAProfileHEVCMain422_12) { - codecHalSettings->lumaChromaDepth |= CODECHAL_LUMA_CHROMA_DEPTH_10_BITS; + codecHalSettings->chromaFormat = HCP_CHROMA_FORMAT_YUV422; + codecHalSettings->lumaChromaDepth = CODECHAL_LUMA_CHROMA_DEPTH_12_BITS; } VAStatus eStatus = VA_STATUS_SUCCESS; @@ -264,22 +285,6 @@ VAStatus DdiEncodeHevc::EncodeInCodecHal(uint32_t numSlices) MOS_SURFACE rawSurface; MOS_ZeroMemory(&rawSurface, sizeof(rawSurface)); rawSurface.dwOffset = 0; - if (m_encodeCtx->vaProfile == VAProfileHEVCMain10) - { - rawSurface.Format = Format_P010; - } - else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444) - { - rawSurface.Format = Format_AYUV; - } - else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444_10) - { - rawSurface.Format = Format_Y410; - } - else //VAProfileHEVCMain - { - rawSurface.Format = Format_NV12; - } DdiMedia_MediaSurfaceToMosResource(rtTbl->pCurrentRT, &(rawSurface.OsResource)); @@ -287,22 +292,6 @@ VAStatus DdiEncodeHevc::EncodeInCodecHal(uint32_t numSlices) MOS_SURFACE reconSurface; MOS_ZeroMemory(&reconSurface, sizeof(reconSurface)); reconSurface.dwOffset = 0; - if (m_encodeCtx->vaProfile == VAProfileHEVCMain10) - { - reconSurface.Format = Format_P010; - } - else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444) - { - reconSurface.Format = Format_AYUV; - } - else if (m_encodeCtx->vaProfile == VAProfileHEVCMain444_10) - { - reconSurface.Format = Format_Y410; - } - else //VAProfileHEVCMain - { - reconSurface.Format = Format_NV12; - } DdiMedia_MediaSurfaceToMosResource(rtTbl->pCurrentReconTarget, &(reconSurface.OsResource)); diff --git a/media_driver/linux/common/codec/ddi/media_libva_encoder.cpp b/media_driver/linux/common/codec/ddi/media_libva_encoder.cpp index 3699686ea60..d5caf5c8f1d 100644 --- a/media_driver/linux/common/codec/ddi/media_libva_encoder.cpp +++ b/media_driver/linux/common/codec/ddi/media_libva_encoder.cpp @@ -303,8 +303,7 @@ VAStatus DdiEncode_CreateContext( // - HEVCMain10 profile // - VAProfileVP9Profile2 // - VAProfileVP9Profile3 - if (profile == VAProfileHEVCMain10 || - profile == VAProfileVP9Profile2 || + if (profile == VAProfileVP9Profile2 || profile == VAProfileVP9Profile3) { encCtx->m_encode->m_is10Bit = true; diff --git a/media_driver/linux/common/ddi/media_libva.cpp b/media_driver/linux/common/ddi/media_libva.cpp index 306bcb4a1a1..e5322a06f6b 100644 --- a/media_driver/linux/common/ddi/media_libva.cpp +++ b/media_driver/linux/common/ddi/media_libva.cpp @@ -1950,8 +1950,17 @@ DdiMedia_CreateSurfaces2( case VA_RT_FORMAT_YUV420: expected_fourcc = VA_FOURCC_NV12; break; + case VA_RT_FORMAT_YUV420_12: + expected_fourcc = VA_FOURCC_P016; + break; case VA_RT_FORMAT_YUV422: - expected_fourcc = VA_FOURCC_422H; + expected_fourcc = VA_FOURCC_YUY2; + break; + case VA_RT_FORMAT_YUV422_10: + expected_fourcc = VA_FOURCC_Y210; + break; + case VA_RT_FORMAT_YUV422_12: + expected_fourcc = VA_FOURCC_Y216; break; case VA_RT_FORMAT_YUV444: expected_fourcc = VA_FOURCC_444P; diff --git a/media_driver/linux/common/ddi/media_libva_caps.cpp b/media_driver/linux/common/ddi/media_libva_caps.cpp index 5f152928f70..07fc02f5122 100644 --- a/media_driver/linux/common/ddi/media_libva_caps.cpp +++ b/media_driver/linux/common/ddi/media_libva_caps.cpp @@ -115,6 +115,8 @@ const VAImageFormat MediaLibvaCaps::m_supportedImageformats[] = {VA_FOURCC_UYVY, VA_LSB_FIRST, 16, 0,0,0,0,0}, {VA_FOURCC_YV12, VA_LSB_FIRST, 12, 0,0,0,0,0}, {VA_FOURCC_IYUV, VA_LSB_FIRST, 12, 0,0,0,0,0}, + {VA_FOURCC_Y210, VA_LSB_FIRST, 16, 0,0,0,0,0}, + {VA_FOURCC_Y216, VA_LSB_FIRST, 16, 0,0,0,0,0}, {VA_FOURCC_422H, VA_LSB_FIRST, 16, 0,0,0,0,0}, {VA_FOURCC_422V, VA_LSB_FIRST, 16, 0,0,0,0,0}, {VA_FOURCC_Y800, VA_LSB_FIRST, 8, 0,0,0,0,0}, @@ -124,6 +126,7 @@ const VAImageFormat MediaLibvaCaps::m_supportedImageformats[] = {VA_FOURCC_RGBP, VA_LSB_FIRST, 24, 24, 0xff0000, 0x00ff00, 0x0000ff, 0}, {VA_FOURCC_BGRP, VA_LSB_FIRST, 24, 24, 0x0000ff, 0x00ff00, 0xff0000, 0}, {VA_FOURCC_P208, VA_LSB_FIRST, 8, 0,0,0,0,0}, + {VA_FOURCC_P016, VA_LSB_FIRST, 12, 0,0,0,0,0}, {VA_FOURCC('P','0','1','0'), VA_LSB_FIRST, 24, 0,0,0,0,0}, {VA_FOURCC_AYUV, VA_LSB_FIRST, 24, 0,0,0,0,0}, {VA_FOURCC_Y410, VA_LSB_FIRST, 24, 0,0,0,0,0} @@ -395,6 +398,18 @@ VAStatus MediaLibvaCaps::CheckEncRTFormat( { attrib->value = VA_RT_FORMAT_YUV420_10; } + else if(profile == VAProfileHEVCMain12) + { + attrib->value = VA_RT_FORMAT_YUV420_12; + } + else if(profile == VAProfileHEVCMain422_10) + { + attrib->value = VA_RT_FORMAT_YUV422_10; + } + else if(profile == VAProfileHEVCMain422_12) + { + attrib->value = VA_RT_FORMAT_YUV422_12; + } else if(profile == VAProfileHEVCMain444) { attrib->value = VA_RT_FORMAT_YUV444; @@ -403,7 +418,7 @@ VAStatus MediaLibvaCaps::CheckEncRTFormat( { attrib->value = VA_RT_FORMAT_YUV444_10; } - else + else { attrib->value = VA_RT_FORMAT_YUV420; } @@ -1530,6 +1545,57 @@ VAStatus MediaLibvaCaps::LoadHevcEncProfileEntrypoints() AddProfileEntry(VAProfileHEVCMain10, VAEntrypointEncSlice, attributeList, configStartIdx, m_encConfigs.size() - configStartIdx); } + + if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit)) + { + status = CreateEncAttributes(VAProfileHEVCMain12, VAEntrypointEncSlice, &attributeList); + DDI_CHK_RET(status, "Failed to initialize Caps!"); + DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); + + uint32_t configStartIdx = m_encConfigs.size(); + AddEncConfig(VA_RC_CQP); + for (int32_t j = 1; j < 7; j++) + { + AddEncConfig(m_encRcMode[j]); + AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); + } + AddProfileEntry(VAProfileHEVCMain12, VAEntrypointEncSlice, attributeList, + configStartIdx, m_encConfigs.size() - configStartIdx); + } + + if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC10bit422)) + { + status = CreateEncAttributes(VAProfileHEVCMain422_10, VAEntrypointEncSlice, &attributeList); + DDI_CHK_RET(status, "Failed to initialize Caps!"); + DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); + + uint32_t configStartIdx = m_encConfigs.size(); + AddEncConfig(VA_RC_CQP); + for (int32_t j = 1; j < 7; j++) + { + AddEncConfig(m_encRcMode[j]); + AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); + } + AddProfileEntry(VAProfileHEVCMain422_10, VAEntrypointEncSlice, attributeList, + configStartIdx, m_encConfigs.size() - configStartIdx); + } + + if (MEDIA_IS_SKU(&(m_mediaCtx->SkuTable), FtrEncodeHEVC12bit422)) + { + status = CreateEncAttributes(VAProfileHEVCMain422_12, VAEntrypointEncSlice, &attributeList); + DDI_CHK_RET(status, "Failed to initialize Caps!"); + DDI_CHK_NULL(attributeList, "Null pointer", VA_STATUS_ERROR_INVALID_PARAMETER); + + uint32_t configStartIdx = m_encConfigs.size(); + AddEncConfig(VA_RC_CQP); + for (int32_t j = 1; j < 7; j++) + { + AddEncConfig(m_encRcMode[j]); + AddEncConfig(m_encRcMode[j] | VA_RC_PARALLEL); + } + AddProfileEntry(VAProfileHEVCMain422_12, VAEntrypointEncSlice, attributeList, + configStartIdx, m_encConfigs.size() - configStartIdx); + } #endif return status; @@ -2428,6 +2494,37 @@ VAStatus MediaLibvaCaps::QuerySurfaceAttributes( attribs[i].value.value.i = VA_FOURCC('P', '0', '1', '0'); i++; } + else if(profile == VAProfileHEVCMain12) + { + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i].value.value.i = VA_FOURCC_P016; + i++; + } + else if(profile == VAProfileHEVCMain422_10) + { + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i].value.value.i = VA_FOURCC_YUY2; + i++; + + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i].value.value.i = VA_FOURCC_Y210; + i++; + } + else if(profile == VAProfileHEVCMain422_12) + { + //hevc rext: Y216 12/16bit 422 + attribs[i].type = VASurfaceAttribPixelFormat; + attribs[i].value.type = VAGenericValueTypeInteger; + attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE; + attribs[i].value.value.i = VA_FOURCC_Y216; + i++; + } else if (profile == VAProfileJPEGBaseline) { for (uint32_t j = 0; j < m_numJpegEncSurfaceAttr; j++) @@ -2663,6 +2760,9 @@ CODECHAL_MODE MediaLibvaCaps::GetEncodeCodecMode(VAProfile profile, VAEntrypoint return CODECHAL_ENCODE_MODE_VP9; case VAProfileHEVCMain: case VAProfileHEVCMain10: + case VAProfileHEVCMain12: + case VAProfileHEVCMain422_10: + case VAProfileHEVCMain422_12: return CODECHAL_ENCODE_MODE_HEVC; default: DDI_ASSERTMESSAGE("Invalid Encode Mode"); @@ -2768,6 +2868,9 @@ std::string MediaLibvaCaps::GetEncodeCodecKey(VAProfile profile, VAEntrypoint en return ENCODE_ID_VP9; case VAProfileHEVCMain: case VAProfileHEVCMain10: + case VAProfileHEVCMain12: + case VAProfileHEVCMain422_10: + case VAProfileHEVCMain422_12: if (IsEncFei(entrypoint)) { return ENCODE_ID_HEVCFEI; diff --git a/media_driver/linux/common/os/linux_system_info.h b/media_driver/linux/common/os/linux_system_info.h index f62ad6354b7..8a4bf38359b 100644 --- a/media_driver/linux/common/os/linux_system_info.h +++ b/media_driver/linux/common/os/linux_system_info.h @@ -65,6 +65,7 @@ struct LinuxCodecInfo uint32_t hevc10Decoding : 1; uint32_t vp9b10Decoding : 1; uint32_t hevc10Encoding : 1; + uint32_t hevc12Encoding : 1; uint32_t vp8Encoding : 1; uint32_t hevcVdenc : 1; uint32_t vp9Vdenc : 1; diff --git a/media_driver/linux/gen10/ddi/media_sku_wa_g10.cpp b/media_driver/linux/gen10/ddi/media_sku_wa_g10.cpp index fac0ba61774..eed3e496dcc 100644 --- a/media_driver/linux/gen10/ddi/media_sku_wa_g10.cpp +++ b/media_driver/linux/gen10/ddi/media_sku_wa_g10.cpp @@ -51,6 +51,7 @@ static struct LinuxCodecInfo cnlCodecInfo = .hevc10Decoding = 1, .vp9b10Decoding = 1, .hevc10Encoding = SET_STATUS_BY_FULL_OPEN_SOURCE(1, 0), + .hevc12Encoding = 0, .vp8Encoding = 1, .hevcVdenc = 1, .vp9Vdenc = 1, diff --git a/media_driver/linux/gen11/ddi/media_sku_wa_g11.cpp b/media_driver/linux/gen11/ddi/media_sku_wa_g11.cpp index 1406e2e0003..a5814db92f0 100644 --- a/media_driver/linux/gen11/ddi/media_sku_wa_g11.cpp +++ b/media_driver/linux/gen11/ddi/media_sku_wa_g11.cpp @@ -51,6 +51,7 @@ static struct LinuxCodecInfo iclCodecInfo = .hevc10Decoding = 1, .vp9b10Decoding = 1, .hevc10Encoding = SET_STATUS_BY_FULL_OPEN_SOURCE(1, 0), + .hevc12Encoding = 0, .vp8Encoding = 1, .hevcVdenc = 1, .vp9Vdenc = 1,