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 f4f065a809..3d64e63be9 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 b530265285..f479b0bf4d 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,33 @@ 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)++; + found->type = pxpAttrib->type; + found->value = 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 cef4e7c184..a113b4bd77 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 @@ -31,7 +31,6 @@ namespace UMC { #define UMC_VA_LINUX_INDEX_UNDEF -1 -#define UMC_VA_LINUX_ATTRIB_SIZE 4 /* VACompBuffer --------------------------------------------------------------*/ @@ -144,7 +143,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); protected: 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 f59f785c0e..5f5bea5606 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 @@ -356,7 +356,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; @@ -497,27 +497,20 @@ 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}); + va_attributes.push_back({VAConfigAttribEncryption, 0}); 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); } - int32_t attribsNumber = 2; if (UMC_OK == umcRes) { - umcRes = SetAttributes(va_profile, pParams, va_attributes, &attribsNumber); + umcRes = SetAttributes(va_profile, pParams, va_attributes); } if (UMC_OK == umcRes) @@ -526,7 +519,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; } @@ -559,34 +552,34 @@ 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; + } } }