Skip to content
This repository has been archived by the owner on May 17, 2023. It is now read-only.

Add 3DLUT filter in VPP. #2656

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
20 changes: 20 additions & 0 deletions _studio/mfx_lib/vpp/include/mfx_vpp_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,26 @@ typedef enum {

} PicStructMode;

typedef enum {
MFX_COLOUR_PRIMARY_RESERVED = 0,
MFX_COLOUR_PRIMARY_BT709 = 1,
MFX_COLOUR_PRIMARY_UNSPECIFIED = 2,
MFX_COLOUR_PRIMARY_BT601_625 = 5, // BT601-7 625-line system
MFX_COLOUR_PRIMARY_BT601_525 = 6, // BT601-7 525-line system
MFX_COLOUR_PRIMARY_BT2020 = 9, // BT2100 shares this same value
} mfxColourPrimary;

typedef enum {
MFX_TRANSFER_CHARACTERISTIC_RESERVED = 0,
MFX_TRANSFER_CHARACTERISTIC_BT709 = 1,
MFX_TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2,
MFX_TRANSFER_CHARACTERISTIC_DISPLAY_GAMMA_2P2 = 4,
MFX_TRANSFER_CHARACTERISTIC_DISPLAY_GAMMA_2P8 = 5,
MFX_TRANSFER_CHARACTERISTIC_BT601 = 6, // BT601-7 625-line or 525-line system
MFX_TRANSFER_CHARACTERISTIC_LINEAR = 8, // Linear transfer characteristic
MFX_TRANSFER_CHARACTERISTIC_ST2084 = 16, // ST2084 transfer characteristic
} mfxTransferCharacteristic;

typedef enum
{
// gamut compression
Expand Down
17 changes: 17 additions & 0 deletions _studio/mfx_lib/vpp/include/mfx_vpp_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,23 @@ size_t GetConfigSize( mfxU32 filterId );

void ConvertCaps2ListDoUse(MfxHwVideoProcessing::mfxVppCaps& caps, std::vector<mfxU32>& list);

__inline mfxU16 GetTransferCharacteristic(mfxU16 transferMatrix)
{
mfxTransferCharacteristic ret = MFX_TRANSFER_CHARACTERISTIC_BT709;
switch (transferMatrix)
{
case MFX_TRANSFERMATRIX_BT709:
ret = MFX_TRANSFER_CHARACTERISTIC_BT709;
break;
case MFX_TRANSFERMATRIX_BT601:
ret = MFX_TRANSFER_CHARACTERISTIC_BT601;
break;
default:
break;
}
return (mfxU16)ret;
}

//mfxStatus QueryExtParams()

#endif // __MFX_VPP_UTILS_H
Expand Down
108 changes: 103 additions & 5 deletions _studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2008-2020 Intel Corporation
// Copyright (c) 2008-2021 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -148,6 +148,7 @@ static void MemSetZero4mfxExecuteParams (mfxExecuteParams *pMfxExecuteParams )
#endif
pMfxExecuteParams->bEOS = false;
pMfxExecuteParams->scene = VPP_NO_SCENE_CHANGE;
pMfxExecuteParams->lut3DInfo = {};
} /*void MemSetZero4mfxExecuteParams (mfxExecuteParams *pMfxExecuteParams )*/


Expand Down Expand Up @@ -2036,6 +2037,19 @@ mfxStatus VideoVPPHW::GetVideoParams(mfxVideoParam *par) const
bufSc->InterpolationMethod = m_executeParams.interpolationMethod;
#endif
}
else if (MFX_EXTBUFF_VPP_3DLUT == bufferId)
{
mfxExtVPP3DLut *bufSc = reinterpret_cast<mfxExtVPP3DLut *>(par->ExtParam[i]);
MFX_CHECK_NULL_PTR1(bufSc);
bufSc->ChannelMapping = m_executeParams.lut3DInfo.ChannelMapping;
bufSc->BufferType = m_executeParams.lut3DInfo.BufferType;
if (bufSc->BufferType == MFX_RESOURCE_VA_SURFACE)
{
bufSc->VideoBuffer.DataType = m_executeParams.lut3DInfo.DataType;
bufSc->VideoBuffer.MemLayout = m_executeParams.lut3DInfo.MemLayout;
bufSc->VideoBuffer.MemId = m_executeParams.lut3DInfo.MemId;
}
}
#if (MFX_VERSION >= 1025)
else if (MFX_EXTBUFF_VPP_COLOR_CONVERSION == bufferId)
{
Expand Down Expand Up @@ -3733,7 +3747,7 @@ mfxStatus VideoVPPHW::MergeRuntimeParams(const DdiTask *pTask, MfxHwVideoProcess
/* Params look good */
execParams->VideoSignalInfo[i].enabled = true;
execParams->VideoSignalInfo[i].NominalRange = vsi->NominalRange;
execParams->VideoSignalInfo[i].TransferMatrix = vsi->TransferMatrix;
execParams->VideoSignalInfo[i].TransferMatrix = GetTransferCharacteristic(vsi->TransferMatrix);
}
}

Expand Down Expand Up @@ -3866,10 +3880,9 @@ mfxStatus VideoVPPHW::SyncTaskSubmission(DdiTask* pTask)
if (m_executeParams.iFieldProcessingMode != 0)
{
mfxFrameSurface1 * pInputSurface = m_IOPattern & MFX_IOPATTERN_IN_OPAQUE_MEMORY ?
m_pCore->GetOpaqSurface(surfQueue[0].pSurf->Data.MemId):
surfQueue[0].pSurf;
m_pCore->GetOpaqSurface(surfQueue[0].pSurf->Data.MemId):
surfQueue[0].pSurf;
MFX_CHECK(pInputSurface, MFX_ERR_NULL_PTR);

/* Mean filter was configured as DOUSE, but no ExtBuf in VPP Init()
* And ... no any parameters in runtime. This is an error! */
if (((m_executeParams.iFieldProcessingMode -1) == FROM_RUNTIME_EXTBUFF_FIELD_PROC) && (pInputSurface->Data.NumExtParam == 0))
Expand Down Expand Up @@ -3961,6 +3974,52 @@ mfxStatus VideoVPPHW::SyncTaskSubmission(DdiTask* pTask)
}
}

mfxFrameSurface1 * pInputSurface = pTask->input.pSurf;
if (pTask->input.pSurf )
{
for ( mfxU32 jj = 0; jj < pInputSurface->Data.NumExtParam; jj++ )
{
if (pInputSurface->Data.ExtParam[jj])
{
if ( (pInputSurface->Data.ExtParam[jj]->BufferId == MFX_EXTBUFF_VIDEO_SIGNAL_INFO) &&
(pInputSurface->Data.ExtParam[jj]->BufferSz == sizeof(mfxExtVideoSignalInfo)) )
{
mfxExtVideoSignalInfo* videoSignallInfo = (mfxExtVideoSignalInfo *)(pInputSurface->Data.ExtParam[jj]);
if (videoSignallInfo)
{
m_executeParams.VideoSignalInfoIn.enabled = TRUE;
m_executeParams.VideoSignalInfoIn.ColourPrimary = videoSignallInfo->ColourPrimaries;
m_executeParams.VideoSignalInfoIn.TransferMatrix = videoSignallInfo->TransferCharacteristics;
m_executeParams.VideoSignalInfoIn.MatrixCoeffs = videoSignallInfo->MatrixCoefficients;
m_executeParams.VideoSignalInfoIn.NominalRange = videoSignallInfo->VideoFullRange ? MFX_NOMINALRANGE_0_255 : MFX_NOMINALRANGE_16_235;
}
}
}
}
}

mfxFrameSurface1 * pOutputSurface = pTask->output.pSurf;
MFX_CHECK(pOutputSurface, MFX_ERR_NULL_PTR);
for ( mfxU32 jj = 0; jj < pOutputSurface->Data.NumExtParam; jj++ )
{
if (pOutputSurface->Data.ExtParam[jj])
{
if ( (pOutputSurface->Data.ExtParam[jj]->BufferId == MFX_EXTBUFF_VIDEO_SIGNAL_INFO) &&
(pOutputSurface->Data.ExtParam[jj]->BufferSz == sizeof(mfxExtVideoSignalInfo)) )
{
mfxExtVideoSignalInfo* videoSignallInfo = (mfxExtVideoSignalInfo *)(pOutputSurface->Data.ExtParam[jj]);
if (videoSignallInfo)
{
m_executeParams.VideoSignalInfoOut.enabled = TRUE;
m_executeParams.VideoSignalInfoOut.ColourPrimary = videoSignallInfo->ColourPrimaries;
m_executeParams.VideoSignalInfoOut.TransferMatrix = videoSignallInfo->TransferCharacteristics;
m_executeParams.VideoSignalInfoOut.MatrixCoeffs = videoSignallInfo->MatrixCoefficients;
m_executeParams.VideoSignalInfoOut.NominalRange = videoSignallInfo->VideoFullRange ? MFX_NOMINALRANGE_0_255 : MFX_NOMINALRANGE_16_235;
}
}
}
}

if ((m_executeParams.iFieldProcessingMode != 0) && /* If Mode is enabled*/
((imfxFPMode - 1) != (mfxU32)FRAME2FRAME)) /* And we don't do copy frame to frame lets call our FieldCopy*/
/* And remember our previous line imfxFPMode++;*/
Expand Down Expand Up @@ -5664,6 +5723,41 @@ mfxStatus ConfigureExecuteParams(
bIsFilterSkipped = true;
}

break;
}
case MFX_EXTBUFF_VPP_3DLUT:
{
if (caps.u3DLut)
{
for (mfxU32 i = 0; i < videoParam.NumExtParam; i++)
{
if (videoParam.ExtParam[i]->BufferId == MFX_EXTBUFF_VPP_3DLUT)
{
mfxExtVPP3DLut *ext3DLUT = (mfxExtVPP3DLut*) videoParam.ExtParam[i];
if (ext3DLUT)
{
executeParams.lut3DInfo.Enabled = true;
executeParams.lut3DInfo.ChannelMapping = ext3DLUT->ChannelMapping;
executeParams.lut3DInfo.BufferType = ext3DLUT->BufferType;
if (ext3DLUT->BufferType == MFX_RESOURCE_VA_SURFACE)
{
executeParams.lut3DInfo.DataType = ext3DLUT->VideoBuffer.DataType;
executeParams.lut3DInfo.MemLayout = ext3DLUT->VideoBuffer.MemLayout;
executeParams.lut3DInfo.MemId = ext3DLUT->VideoBuffer.MemId;
}
else
{
return MFX_ERR_UNSUPPORTED;
}
}
}
}
}
else
{
bIsFilterSkipped = true;
}

break;
}
#if (MFX_VERSION >= 1025)
Expand Down Expand Up @@ -6252,6 +6346,10 @@ mfxStatus ConfigureExecuteParams(
{
executeParams.scalingMode = MFX_SCALING_MODE_DEFAULT;
}
else if (MFX_EXTBUFF_VPP_3DLUT == bufferId)
{
executeParams.lut3DInfo.Enabled = false;
}
#if (MFX_VERSION >= 1025)
else if (MFX_EXTBUFF_VPP_COLOR_CONVERSION == bufferId)
{
Expand Down
7 changes: 6 additions & 1 deletion _studio/mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2020 Intel Corporation
// Copyright (c) 2018-2021 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -151,6 +151,11 @@ mfxStatus GetExternalFramesCount(VideoCORE* core,
break;
}

case (mfxU32)MFX_EXTBUFF_VPP_3DLUT:
{
break;
}

case (mfxU32)MFX_EXTBUFF_VPP_DEINTERLACING:
{
break;
Expand Down
48 changes: 41 additions & 7 deletions _studio/mfx_lib/vpp/src/mfx_vpp_utils.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018-2020 Intel Corporation
// Copyright (c) 2018-2021 Intel Corporation
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -45,7 +45,8 @@ const mfxU32 g_TABLE_DO_NOT_USE [] =
#endif
MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO,
MFX_EXTBUFF_VPP_FIELD_PROCESSING,
MFX_EXTBUFF_VPP_MIRRORING
MFX_EXTBUFF_VPP_MIRRORING,
MFX_EXTBUFF_VPP_3DLUT
};


Expand All @@ -69,7 +70,8 @@ const mfxU32 g_TABLE_DO_USE [] =
MFX_EXTBUFF_VPP_DEINTERLACING,
MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO,
MFX_EXTBUFF_VPP_FIELD_PROCESSING,
MFX_EXTBUFF_VPP_MIRRORING
MFX_EXTBUFF_VPP_MIRRORING,
MFX_EXTBUFF_VPP_3DLUT
};


Expand All @@ -94,7 +96,8 @@ const mfxU32 g_TABLE_CONFIG [] =
#if (MFX_VERSION >= 1025)
MFX_EXTBUFF_VPP_COLOR_CONVERSION,
#endif
MFX_EXTBUFF_VPP_MIRRORING
MFX_EXTBUFF_VPP_MIRRORING,
MFX_EXTBUFF_VPP_3DLUT
};


Expand Down Expand Up @@ -125,7 +128,8 @@ const mfxU32 g_TABLE_EXT_PARAM [] =
#if (MFX_VERSION >= 1025)
MFX_EXTBUFF_VPP_COLOR_CONVERSION,
#endif
MFX_EXTBUFF_VPP_MIRRORING
MFX_EXTBUFF_VPP_MIRRORING,
MFX_EXTBUFF_VPP_3DLUT
};

PicStructMode GetPicStructMode(mfxU16 inPicStruct, mfxU16 outPicStruct)
Expand Down Expand Up @@ -674,6 +678,11 @@ void ShowPipeline( std::vector<mfxU32> pipelineList )
break;
}
#endif
case (mfxU32)MFX_EXTBUFF_VPP_3DLUT:
{
fprintf(stderr, "MFX_EXTBUFF_VPP_3DLUT\n");
break;
}
default:
{
fprintf(stderr, "UNKNOWN Filter ID!!! \n");
Expand Down Expand Up @@ -793,6 +802,12 @@ void ReorderPipelineListForQuality( std::vector<mfxU32> & pipelineList )
index++;
}

if( IsFilterFound( &pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_3DLUT ) )
{
newList[index] = MFX_EXTBUFF_VPP_3DLUT;
index++;
}

if( IsFilterFound( &pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_SCENE_ANALYSIS ) )
{
newList[index] = MFX_EXTBUFF_VPP_SCENE_ANALYSIS;
Expand Down Expand Up @@ -1253,6 +1268,14 @@ mfxStatus GetPipelineList(
}
}

if( IsFilterFound( &configList[0], configCount, MFX_EXTBUFF_VPP_3DLUT ) && !IsFilterFound(&pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_3DLUT) )
{
if( !IsFilterFound( &pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_3DLUT ) )
{
pipelineList.push_back( MFX_EXTBUFF_VPP_3DLUT );
}
}

searchCount = sizeof(g_TABLE_CONFIG) / sizeof(*g_TABLE_CONFIG);
fCount = configCount;
for(fIdx = 0; fIdx < fCount; fIdx++)
Expand Down Expand Up @@ -1404,8 +1427,14 @@ mfxStatus CheckFrameInfo(mfxFrameInfo* info, mfxU32 request, eMFXHWType platform
}

/* checking Height based on PicStruct filed */
if (MFX_PICSTRUCT_PROGRESSIVE & info->PicStruct ||
MFX_PICSTRUCT_FIELD_SINGLE & info->PicStruct)
if (MFX_PICSTRUCT_PROGRESSIVE & info->PicStruct)
{
if ((info->Height & 4) !=0)
{
return MFX_ERR_INVALID_VIDEO_PARAM;
}
}
else if (MFX_PICSTRUCT_FIELD_SINGLE & info->PicStruct)
{
if ((info->Height & 15) !=0)
{
Expand Down Expand Up @@ -2288,6 +2317,11 @@ void ConvertCaps2ListDoUse(MfxHwVideoProcessing::mfxVppCaps& caps, std::vector<m
list.push_back(MFX_EXTBUFF_VPP_SCALING);
}

if(caps.u3DLut)
{
list.push_back(MFX_EXTBUFF_VPP_3DLUT);
}

#if (MFX_VERSION >= 1025)
if (caps.uChromaSiting)
{
Expand Down
2 changes: 1 addition & 1 deletion _studio/shared/include/mfx_utils_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <vector>
#include <memory>
#include <assert.h>

#define MFX_DEBUG_TRACE
#ifndef MFX_DEBUG_TRACE
#define MFX_STS_TRACE(sts) sts
#else
Expand Down
Loading