Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<VAConfigAttrib>& attributes) override;

protected:
mfxPXPCtxHDL m_PXPCtxHdl;
Expand Down
24 changes: 12 additions & 12 deletions _studio/mfx_lib/pxp/src/mfx_pxp_video_accelerator_vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VAConfigAttrib>& 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<VAConfigAttrib *>(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;
}
}

Expand Down
3 changes: 1 addition & 2 deletions _studio/shared/umc/io/umc_va/include/umc_va_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ namespace UMC
{

#define UMC_VA_LINUX_INDEX_UNDEF -1
#define UMC_VA_LINUX_ATTRIB_SIZE 4

/* VACompBuffer --------------------------------------------------------------*/

Expand Down Expand Up @@ -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<VAConfigAttrib>& attributes);

protected:

Expand Down
61 changes: 27 additions & 34 deletions _studio/shared/umc/io/umc_va/src/umc_va_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VAConfigAttrib> va_attributes;

LinuxVideoAcceleratorParams* pParams = DynamicCast<LinuxVideoAcceleratorParams>(pInfo);
int32_t width = 0, height = 0;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
Expand Down Expand Up @@ -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<VAConfigAttrib>& 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;
}
}
}

Expand Down