diff --git a/_studio/mfx_lib/pxp/include/mfx_pxp_video_accelerator_vaapi.h b/_studio/mfx_lib/pxp/include/mfx_pxp_video_accelerator_vaapi.h index f4f065a8..3d64e63b 100644 --- a/_studio/mfx_lib/pxp/include/mfx_pxp_video_accelerator_vaapi.h +++ b/_studio/mfx_lib/pxp/include/mfx_pxp_video_accelerator_vaapi.h @@ -39,7 +39,8 @@ class PXPLinuxVideoAccelerator : public UMC::LinuxVideoAccelerator // VideoAccelerator methods virtual UMC::Status Init (UMC::VideoAcceleratorParams* pInfo) override; virtual UMC::Status Execute () override; - virtual UMC::Status SetAttributes(VAProfile va_profile, UMC::LinuxVideoAcceleratorParams* pParams, VAConfigAttrib *attribute, int32_t *attribsNumber) override; + virtual UMC::Status SetAttributes(VAProfile va_profile, UMC::LinuxVideoAcceleratorParams* pParams, + std::vector& attributes) override; protected: mfxPXPCtxHDL m_PXPCtxHdl; diff --git a/_studio/mfx_lib/pxp/src/mfx_pxp_video_accelerator_vaapi.cpp b/_studio/mfx_lib/pxp/src/mfx_pxp_video_accelerator_vaapi.cpp index b5302652..f1b9508c 100644 --- a/_studio/mfx_lib/pxp/src/mfx_pxp_video_accelerator_vaapi.cpp +++ b/_studio/mfx_lib/pxp/src/mfx_pxp_video_accelerator_vaapi.cpp @@ -58,33 +58,32 @@ UMC::Status PXPLinuxVideoAccelerator::Init(UMC::VideoAcceleratorParams* pInfo) return umcRes; } -UMC::Status PXPLinuxVideoAccelerator::SetAttributes(VAProfile va_profile, UMC::LinuxVideoAcceleratorParams* pParams, VAConfigAttrib *attribute, int32_t *attribsNumber) +UMC::Status PXPLinuxVideoAccelerator::SetAttributes(VAProfile va_profile, UMC::LinuxVideoAcceleratorParams* pParams, + std::vector& attributes) { MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_HOTSPOTS, "PXPLinuxVideoAccelerator::SetAttributes"); UMC_CHECK(pParams != nullptr, UMC::UMC_ERR_INVALID_PARAMS); - UMC_CHECK(attribute != nullptr, UMC::UMC_ERR_INVALID_PARAMS); - UMC_CHECK(attribsNumber != nullptr, UMC::UMC_ERR_INVALID_PARAMS); - UMC_CHECK((*attribsNumber >= 0 && *attribsNumber < UMC_VA_LINUX_ATTRIB_SIZE), UMC::UMC_ERR_INVALID_PARAMS); + UMC_CHECK(attributes.size() > 0, UMC::UMC_ERR_INVALID_PARAMS); // Check PXP handle and secure decode context handle UMC_CHECK(m_PXPCtxHdl != nullptr, UMC::UMC_ERR_INVALID_PARAMS); - UMC::Status umcRes = LinuxVideoAccelerator::SetAttributes(va_profile, pParams, attribute, attribsNumber); + UMC::Status umcRes = LinuxVideoAccelerator::SetAttributes(va_profile, pParams, attributes); if (UMC::UMC_OK == umcRes) { //check pxp capablity by attribute[3], and set pxp attribute to attribute[*attribsNumber] VAConfigAttrib *pxpAttrib = reinterpret_cast(m_PXPCtxHdl->secureDecodeCfg.pxpAttributesHdl); - if (pxpAttrib - && (attribute[3].value & - (VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR | VA_ENCRYPTION_TYPE_SUBSAMPLE_CBC | VA_ENCRYPTION_TYPE_FULLSAMPLE_CTR | VA_ENCRYPTION_TYPE_FULLSAMPLE_CBC)) - ) + auto found = std::find_if(attributes.begin(), attributes.end(), [](const VAConfigAttrib& item) { + return item.value & (VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR | VA_ENCRYPTION_TYPE_SUBSAMPLE_CBC | + VA_ENCRYPTION_TYPE_FULLSAMPLE_CTR | VA_ENCRYPTION_TYPE_FULLSAMPLE_CBC); + }); + + if (pxpAttrib && found != attributes.end()) { - attribute[*attribsNumber].type = pxpAttrib->type; - attribute[*attribsNumber].value = pxpAttrib->value; - (*attribsNumber)++; + attributes.push_back({pxpAttrib->type, pxpAttrib->value}); } } diff --git a/_studio/shared/umc/io/umc_va/include/umc_va_linux.h b/_studio/shared/umc/io/umc_va/include/umc_va_linux.h index a3d77d7a..88c842ca 100644 --- a/_studio/shared/umc/io/umc_va/include/umc_va_linux.h +++ b/_studio/shared/umc/io/umc_va/include/umc_va_linux.h @@ -32,7 +32,6 @@ namespace UMC { #define UMC_VA_LINUX_INDEX_UNDEF -1 -#define UMC_VA_LINUX_ATTRIB_SIZE 4 /* VACompBuffer --------------------------------------------------------------*/ @@ -152,7 +151,7 @@ class LinuxVideoAccelerator : public VideoAccelerator uint16_t GetDecodingError(VASurfaceID *surface); void SetTraceStrings(uint32_t umc_codec); - virtual Status SetAttributes(VAProfile va_profile, LinuxVideoAcceleratorParams* pParams, VAConfigAttrib *attribute, int32_t *attribsNumber); + virtual Status SetAttributes(VAProfile va_profile, LinuxVideoAcceleratorParams* pParams, std::vector& attributes); #ifdef ENABLE_WIDEVINE VAProtectedSessionID CreateProtectedSession(uint32_t session_mode, diff --git a/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp b/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp index 648966b7..9e44b26d 100644 --- a/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp +++ b/_studio/shared/umc/io/umc_va/src/umc_va_linux.cpp @@ -365,7 +365,7 @@ Status LinuxVideoAccelerator::Init(VideoAcceleratorParams* pInfo) MFX_AUTO_LTRACE(MFX_TRACE_LEVEL_HOTSPOTS, "LinuxVideoAccelerator::Init"); Status umcRes = UMC_OK; VAStatus va_res = VA_STATUS_SUCCESS; - VAConfigAttrib va_attributes[UMC_VA_LINUX_ATTRIB_SIZE]; + std::vector va_attributes; LinuxVideoAcceleratorParams* pParams = DynamicCast(pInfo); int32_t width = 0, height = 0; @@ -508,42 +508,25 @@ Status LinuxVideoAccelerator::Init(VideoAcceleratorParams* pInfo) } if (UMC_OK == umcRes) { - int nattr = 0; // Assuming finding VLD, find out the format for the render target - va_attributes[nattr++].type = VAConfigAttribRTFormat; - - va_attributes[nattr].type = VAConfigAttribDecSliceMode; - va_attributes[nattr].value = VA_DEC_SLICE_MODE_NORMAL; - nattr++; - - va_attributes[nattr++].type = VAConfigAttribDecProcessing; - - va_attributes[nattr++].type = VAConfigAttribEncryption; + va_attributes.push_back({VAConfigAttribRTFormat, 0}); + va_attributes.push_back({VAConfigAttribDecSliceMode, VA_DEC_SLICE_MODE_NORMAL}); + va_attributes.push_back({VAConfigAttribDecProcessing, 0}); +#ifdef ENABLE_WIDEVINE + if (m_secure) { + MFX_LTRACE_MSG(MFX_TRACE_LEVEL_EXTCALL, "set VAConfigAttribEncryption = VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR"); + va_attributes.push_back({VAConfigAttribEncryption, VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR}); + } +#endif PERF_UTILITY_AUTO("vaGetConfigAttributes", PERF_LEVEL_DDI); - va_res = vaGetConfigAttributes(m_dpy, va_profile, va_entrypoint, va_attributes, nattr); + va_res = vaGetConfigAttributes(m_dpy, va_profile, va_entrypoint, va_attributes.data(), va_attributes.size()); umcRes = va_to_umc_res(va_res); } -#ifdef ENABLE_WIDEVINE - int32_t attribsNumber = 2; - if (m_secure) - attribsNumber = 4; -#else - int32_t attribsNumber = 2; -#endif + if (UMC_OK == umcRes) { - umcRes = SetAttributes(va_profile, pParams, va_attributes, &attribsNumber); -#ifdef ENABLE_WIDEVINE - for (int i = 0; i < UMC_VA_LINUX_ATTRIB_SIZE; i++) - { - if (va_attributes[i].type == VAConfigAttribEncryption) - { - MFX_LTRACE_MSG(MFX_TRACE_LEVEL_EXTCALL, "set VAConfigAttribEncryption = VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR"); - va_attributes[i].value = VA_ENCRYPTION_TYPE_SUBSAMPLE_CTR; - } - } -#endif + umcRes = SetAttributes(va_profile, pParams, va_attributes); } if (UMC_OK == umcRes) @@ -552,7 +535,7 @@ Status LinuxVideoAccelerator::Init(VideoAcceleratorParams* pInfo) if (*m_pConfigId == VA_INVALID_ID) { PERF_UTILITY_AUTO("vaCreateConfig", PERF_LEVEL_DDI); - va_res = vaCreateConfig(m_dpy, va_profile, va_entrypoint, va_attributes, attribsNumber, m_pConfigId); + va_res = vaCreateConfig(m_dpy, va_profile, va_entrypoint, va_attributes.data(), va_attributes.size(), m_pConfigId); umcRes = va_to_umc_res(va_res); needRecreateContext = true; } @@ -598,34 +581,35 @@ Status LinuxVideoAccelerator::Init(VideoAcceleratorParams* pInfo) return umcRes; } -Status LinuxVideoAccelerator::SetAttributes(VAProfile va_profile, LinuxVideoAcceleratorParams* pParams, VAConfigAttrib *attribute, int32_t *attribsNumber) +Status LinuxVideoAccelerator::SetAttributes(VAProfile va_profile, LinuxVideoAcceleratorParams* pParams, + std::vector& attributes) { MFX_CHECK(pParams != nullptr, UMC_ERR_INVALID_PARAMS); - MFX_CHECK(attribute != nullptr, UMC_ERR_INVALID_PARAMS); - MFX_CHECK(attribsNumber != nullptr, UMC_ERR_INVALID_PARAMS); - attribute[1].value = VA_DEC_SLICE_MODE_NORMAL; + attributes.push_back({VAConfigAttribDecSliceMode, VA_DEC_SLICE_MODE_NORMAL}); if (pParams->m_needVideoProcessingVA) { - if (attribute[2].value == VA_DEC_PROCESSING) + auto found = std::find_if(attributes.begin(), attributes.end(), [](const VAConfigAttrib& item) { + return item.type == VAConfigAttribDecProcessing; + }); + + if (found != attributes.end()) { + if (VA_DEC_PROCESSING == (*found).value) + { #ifndef MFX_DEC_VIDEO_POSTPROCESS_DISABLE - m_videoProcessingVA = new VideoProcessingVA(); + m_videoProcessingVA = new VideoProcessingVA(); #endif - (*attribsNumber)++; - } - // VA_DEC_PROCESSING_NONE returned, but for VAProfileJPEGBaseline - // current driver doesn't report VAConfigAttribDecProcessing status correctly: - // decoding and CSC to ARGB in SFC mode works despite VA_DEC_PROCESSING_NONE. - // Do not create m_videoProcessingVA in this case, because it's not used during jpeg decode. - else if (va_profile == VAProfileJPEGBaseline) - { - (*attribsNumber)++; - } - else - { - return UMC_ERR_FAILED; + } + // VA_DEC_PROCESSING_NONE returned, but for VAProfileJPEGBaseline + // current driver doesn't report VAConfigAttribDecProcessing status correctly: + // decoding and CSC to ARGB in SFC mode works despite VA_DEC_PROCESSING_NONE. + // Do not create m_videoProcessingVA in this case, because it's not used during jpeg decode. + else if (va_profile != VAProfileJPEGBaseline) + { + return UMC_ERR_FAILED; + } } }