Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3c1e738

Browse files
committedJul 21, 2021
Add 3DLUT filter in VPP.
1. Add 3DLUT interface and Linux implementation. 2. Add tutorials for 3DLUT VPP and transcode. Signed-off-by: Furong Zhang <furong.zhang@intel.com>
1 parent 510d19d commit 3c1e738

38 files changed

+2799
-49
lines changed
 

‎_studio/mfx_lib/vpp/include/mfx_vpp_defs.h

+20
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,26 @@ typedef enum {
132132

133133
} PicStructMode;
134134

135+
typedef enum {
136+
MFX_COLOUR_PRIMARY_RESERVED = 0,
137+
MFX_COLOUR_PRIMARY_BT709 = 1,
138+
MFX_COLOUR_PRIMARY_UNSPECIFIED = 2,
139+
MFX_COLOUR_PRIMARY_BT601_625 = 5, // BT601-7 625-line system
140+
MFX_COLOUR_PRIMARY_BT601_525 = 6, // BT601-7 525-line system
141+
MFX_COLOUR_PRIMARY_BT2020 = 9, // BT2100 shares this same value
142+
} mfxColourPrimary;
143+
144+
typedef enum {
145+
MFX_TRANSFER_CHARACTERISTIC_RESERVED = 0,
146+
MFX_TRANSFER_CHARACTERISTIC_BT709 = 1,
147+
MFX_TRANSFER_CHARACTERISTIC_UNSPECIFIED = 2,
148+
MFX_TRANSFER_CHARACTERISTIC_DISPLAY_GAMMA_2P2 = 4,
149+
MFX_TRANSFER_CHARACTERISTIC_DISPLAY_GAMMA_2P8 = 5,
150+
MFX_TRANSFER_CHARACTERISTIC_BT601 = 6, // BT601-7 625-line or 525-line system
151+
MFX_TRANSFER_CHARACTERISTIC_LINEAR = 8, // Linear transfer characteristic
152+
MFX_TRANSFER_CHARACTERISTIC_ST2084 = 16, // ST2084 transfer characteristic
153+
} mfxTransferCharacteristic;
154+
135155
typedef enum
136156
{
137157
// gamut compression

‎_studio/mfx_lib/vpp/include/mfx_vpp_utils.h

+17
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,23 @@ size_t GetConfigSize( mfxU32 filterId );
195195

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

198+
__inline mfxU16 GetTransferCharacteristic(mfxU16 transferMatrix)
199+
{
200+
mfxTransferCharacteristic ret = MFX_TRANSFER_CHARACTERISTIC_BT709;
201+
switch (transferMatrix)
202+
{
203+
case MFX_TRANSFERMATRIX_BT709:
204+
ret = MFX_TRANSFER_CHARACTERISTIC_BT709;
205+
break;
206+
case MFX_TRANSFERMATRIX_BT601:
207+
ret = MFX_TRANSFER_CHARACTERISTIC_BT601;
208+
break;
209+
default:
210+
break;
211+
}
212+
return (mfxU16)ret;
213+
}
214+
198215
//mfxStatus QueryExtParams()
199216

200217
#endif // __MFX_VPP_UTILS_H

‎_studio/mfx_lib/vpp/src/mfx_vpp_hw.cpp

+103-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2008-2020 Intel Corporation
1+
// Copyright (c) 2008-2021 Intel Corporation
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy
44
// of this software and associated documentation files (the "Software"), to deal
@@ -148,6 +148,7 @@ static void MemSetZero4mfxExecuteParams (mfxExecuteParams *pMfxExecuteParams )
148148
#endif
149149
pMfxExecuteParams->bEOS = false;
150150
pMfxExecuteParams->scene = VPP_NO_SCENE_CHANGE;
151+
pMfxExecuteParams->lut3DInfo = {};
151152
} /*void MemSetZero4mfxExecuteParams (mfxExecuteParams *pMfxExecuteParams )*/
152153

153154

@@ -2036,6 +2037,19 @@ mfxStatus VideoVPPHW::GetVideoParams(mfxVideoParam *par) const
20362037
bufSc->InterpolationMethod = m_executeParams.interpolationMethod;
20372038
#endif
20382039
}
2040+
else if (MFX_EXTBUFF_VPP_3DLUT == bufferId)
2041+
{
2042+
mfxExtVPP3DLut *bufSc = reinterpret_cast<mfxExtVPP3DLut *>(par->ExtParam[i]);
2043+
MFX_CHECK_NULL_PTR1(bufSc);
2044+
bufSc->ChannelMapping = m_executeParams.lut3DInfo.ChannelMapping;
2045+
bufSc->BufferType = m_executeParams.lut3DInfo.BufferType;
2046+
if (bufSc->BufferType == MFX_RESOURCE_VA_SURFACE)
2047+
{
2048+
bufSc->VideoBuffer.DataType = m_executeParams.lut3DInfo.DataType;
2049+
bufSc->VideoBuffer.MemLayout = m_executeParams.lut3DInfo.MemLayout;
2050+
bufSc->VideoBuffer.MemId = m_executeParams.lut3DInfo.MemId;
2051+
}
2052+
}
20392053
#if (MFX_VERSION >= 1025)
20402054
else if (MFX_EXTBUFF_VPP_COLOR_CONVERSION == bufferId)
20412055
{
@@ -3733,7 +3747,7 @@ mfxStatus VideoVPPHW::MergeRuntimeParams(const DdiTask *pTask, MfxHwVideoProcess
37333747
/* Params look good */
37343748
execParams->VideoSignalInfo[i].enabled = true;
37353749
execParams->VideoSignalInfo[i].NominalRange = vsi->NominalRange;
3736-
execParams->VideoSignalInfo[i].TransferMatrix = vsi->TransferMatrix;
3750+
execParams->VideoSignalInfo[i].TransferMatrix = GetTransferCharacteristic(vsi->TransferMatrix);
37373751
}
37383752
}
37393753

@@ -3866,10 +3880,9 @@ mfxStatus VideoVPPHW::SyncTaskSubmission(DdiTask* pTask)
38663880
if (m_executeParams.iFieldProcessingMode != 0)
38673881
{
38683882
mfxFrameSurface1 * pInputSurface = m_IOPattern & MFX_IOPATTERN_IN_OPAQUE_MEMORY ?
3869-
m_pCore->GetOpaqSurface(surfQueue[0].pSurf->Data.MemId):
3870-
surfQueue[0].pSurf;
3883+
m_pCore->GetOpaqSurface(surfQueue[0].pSurf->Data.MemId):
3884+
surfQueue[0].pSurf;
38713885
MFX_CHECK(pInputSurface, MFX_ERR_NULL_PTR);
3872-
38733886
/* Mean filter was configured as DOUSE, but no ExtBuf in VPP Init()
38743887
* And ... no any parameters in runtime. This is an error! */
38753888
if (((m_executeParams.iFieldProcessingMode -1) == FROM_RUNTIME_EXTBUFF_FIELD_PROC) && (pInputSurface->Data.NumExtParam == 0))
@@ -3961,6 +3974,52 @@ mfxStatus VideoVPPHW::SyncTaskSubmission(DdiTask* pTask)
39613974
}
39623975
}
39633976

3977+
mfxFrameSurface1 * pInputSurface = pTask->input.pSurf;
3978+
if (pTask->input.pSurf )
3979+
{
3980+
for ( mfxU32 jj = 0; jj < pInputSurface->Data.NumExtParam; jj++ )
3981+
{
3982+
if (pInputSurface->Data.ExtParam[jj])
3983+
{
3984+
if ( (pInputSurface->Data.ExtParam[jj]->BufferId == MFX_EXTBUFF_VIDEO_SIGNAL_INFO) &&
3985+
(pInputSurface->Data.ExtParam[jj]->BufferSz == sizeof(mfxExtVideoSignalInfo)) )
3986+
{
3987+
mfxExtVideoSignalInfo* videoSignallInfo = (mfxExtVideoSignalInfo *)(pInputSurface->Data.ExtParam[jj]);
3988+
if (videoSignallInfo)
3989+
{
3990+
m_executeParams.VideoSignalInfoIn.enabled = TRUE;
3991+
m_executeParams.VideoSignalInfoIn.ColourPrimary = videoSignallInfo->ColourPrimaries;
3992+
m_executeParams.VideoSignalInfoIn.TransferMatrix = videoSignallInfo->TransferCharacteristics;
3993+
m_executeParams.VideoSignalInfoIn.MatrixCoeffs = videoSignallInfo->MatrixCoefficients;
3994+
m_executeParams.VideoSignalInfoIn.NominalRange = videoSignallInfo->VideoFullRange ? MFX_NOMINALRANGE_0_255 : MFX_NOMINALRANGE_16_235;
3995+
}
3996+
}
3997+
}
3998+
}
3999+
}
4000+
4001+
mfxFrameSurface1 * pOutputSurface = pTask->output.pSurf;
4002+
MFX_CHECK(pOutputSurface, MFX_ERR_NULL_PTR);
4003+
for ( mfxU32 jj = 0; jj < pOutputSurface->Data.NumExtParam; jj++ )
4004+
{
4005+
if (pOutputSurface->Data.ExtParam[jj])
4006+
{
4007+
if ( (pOutputSurface->Data.ExtParam[jj]->BufferId == MFX_EXTBUFF_VIDEO_SIGNAL_INFO) &&
4008+
(pOutputSurface->Data.ExtParam[jj]->BufferSz == sizeof(mfxExtVideoSignalInfo)) )
4009+
{
4010+
mfxExtVideoSignalInfo* videoSignallInfo = (mfxExtVideoSignalInfo *)(pOutputSurface->Data.ExtParam[jj]);
4011+
if (videoSignallInfo)
4012+
{
4013+
m_executeParams.VideoSignalInfoOut.enabled = TRUE;
4014+
m_executeParams.VideoSignalInfoOut.ColourPrimary = videoSignallInfo->ColourPrimaries;
4015+
m_executeParams.VideoSignalInfoOut.TransferMatrix = videoSignallInfo->TransferCharacteristics;
4016+
m_executeParams.VideoSignalInfoOut.MatrixCoeffs = videoSignallInfo->MatrixCoefficients;
4017+
m_executeParams.VideoSignalInfoOut.NominalRange = videoSignallInfo->VideoFullRange ? MFX_NOMINALRANGE_0_255 : MFX_NOMINALRANGE_16_235;
4018+
}
4019+
}
4020+
}
4021+
}
4022+
39644023
if ((m_executeParams.iFieldProcessingMode != 0) && /* If Mode is enabled*/
39654024
((imfxFPMode - 1) != (mfxU32)FRAME2FRAME)) /* And we don't do copy frame to frame lets call our FieldCopy*/
39664025
/* And remember our previous line imfxFPMode++;*/
@@ -5664,6 +5723,41 @@ mfxStatus ConfigureExecuteParams(
56645723
bIsFilterSkipped = true;
56655724
}
56665725

5726+
break;
5727+
}
5728+
case MFX_EXTBUFF_VPP_3DLUT:
5729+
{
5730+
if (caps.u3DLut)
5731+
{
5732+
for (mfxU32 i = 0; i < videoParam.NumExtParam; i++)
5733+
{
5734+
if (videoParam.ExtParam[i]->BufferId == MFX_EXTBUFF_VPP_3DLUT)
5735+
{
5736+
mfxExtVPP3DLut *ext3DLUT = (mfxExtVPP3DLut*) videoParam.ExtParam[i];
5737+
if (ext3DLUT)
5738+
{
5739+
executeParams.lut3DInfo.Enabled = true;
5740+
executeParams.lut3DInfo.ChannelMapping = ext3DLUT->ChannelMapping;
5741+
executeParams.lut3DInfo.BufferType = ext3DLUT->BufferType;
5742+
if (ext3DLUT->BufferType == MFX_RESOURCE_VA_SURFACE)
5743+
{
5744+
executeParams.lut3DInfo.DataType = ext3DLUT->VideoBuffer.DataType;
5745+
executeParams.lut3DInfo.MemLayout = ext3DLUT->VideoBuffer.MemLayout;
5746+
executeParams.lut3DInfo.MemId = ext3DLUT->VideoBuffer.MemId;
5747+
}
5748+
else
5749+
{
5750+
return MFX_ERR_UNSUPPORTED;
5751+
}
5752+
}
5753+
}
5754+
}
5755+
}
5756+
else
5757+
{
5758+
bIsFilterSkipped = true;
5759+
}
5760+
56675761
break;
56685762
}
56695763
#if (MFX_VERSION >= 1025)
@@ -6252,6 +6346,10 @@ mfxStatus ConfigureExecuteParams(
62526346
{
62536347
executeParams.scalingMode = MFX_SCALING_MODE_DEFAULT;
62546348
}
6349+
else if (MFX_EXTBUFF_VPP_3DLUT == bufferId)
6350+
{
6351+
executeParams.lut3DInfo.Enabled = false;
6352+
}
62556353
#if (MFX_VERSION >= 1025)
62566354
else if (MFX_EXTBUFF_VPP_COLOR_CONVERSION == bufferId)
62576355
{

‎_studio/mfx_lib/vpp/src/mfx_vpp_sw_internal.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2020 Intel Corporation
1+
// Copyright (c) 2018-2021 Intel Corporation
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy
44
// of this software and associated documentation files (the "Software"), to deal
@@ -151,6 +151,11 @@ mfxStatus GetExternalFramesCount(VideoCORE* core,
151151
break;
152152
}
153153

154+
case (mfxU32)MFX_EXTBUFF_VPP_3DLUT:
155+
{
156+
break;
157+
}
158+
154159
case (mfxU32)MFX_EXTBUFF_VPP_DEINTERLACING:
155160
{
156161
break;

‎_studio/mfx_lib/vpp/src/mfx_vpp_utils.cpp

+41-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2018-2020 Intel Corporation
1+
// Copyright (c) 2018-2021 Intel Corporation
22
//
33
// Permission is hereby granted, free of charge, to any person obtaining a copy
44
// of this software and associated documentation files (the "Software"), to deal
@@ -45,7 +45,8 @@ const mfxU32 g_TABLE_DO_NOT_USE [] =
4545
#endif
4646
MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO,
4747
MFX_EXTBUFF_VPP_FIELD_PROCESSING,
48-
MFX_EXTBUFF_VPP_MIRRORING
48+
MFX_EXTBUFF_VPP_MIRRORING,
49+
MFX_EXTBUFF_VPP_3DLUT
4950
};
5051

5152

@@ -69,7 +70,8 @@ const mfxU32 g_TABLE_DO_USE [] =
6970
MFX_EXTBUFF_VPP_DEINTERLACING,
7071
MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO,
7172
MFX_EXTBUFF_VPP_FIELD_PROCESSING,
72-
MFX_EXTBUFF_VPP_MIRRORING
73+
MFX_EXTBUFF_VPP_MIRRORING,
74+
MFX_EXTBUFF_VPP_3DLUT
7375
};
7476

7577

@@ -94,7 +96,8 @@ const mfxU32 g_TABLE_CONFIG [] =
9496
#if (MFX_VERSION >= 1025)
9597
MFX_EXTBUFF_VPP_COLOR_CONVERSION,
9698
#endif
97-
MFX_EXTBUFF_VPP_MIRRORING
99+
MFX_EXTBUFF_VPP_MIRRORING,
100+
MFX_EXTBUFF_VPP_3DLUT
98101
};
99102

100103

@@ -125,7 +128,8 @@ const mfxU32 g_TABLE_EXT_PARAM [] =
125128
#if (MFX_VERSION >= 1025)
126129
MFX_EXTBUFF_VPP_COLOR_CONVERSION,
127130
#endif
128-
MFX_EXTBUFF_VPP_MIRRORING
131+
MFX_EXTBUFF_VPP_MIRRORING,
132+
MFX_EXTBUFF_VPP_3DLUT
129133
};
130134

131135
PicStructMode GetPicStructMode(mfxU16 inPicStruct, mfxU16 outPicStruct)
@@ -674,6 +678,11 @@ void ShowPipeline( std::vector<mfxU32> pipelineList )
674678
break;
675679
}
676680
#endif
681+
case (mfxU32)MFX_EXTBUFF_VPP_3DLUT:
682+
{
683+
fprintf(stderr, "MFX_EXTBUFF_VPP_3DLUT\n");
684+
break;
685+
}
677686
default:
678687
{
679688
fprintf(stderr, "UNKNOWN Filter ID!!! \n");
@@ -793,6 +802,12 @@ void ReorderPipelineListForQuality( std::vector<mfxU32> & pipelineList )
793802
index++;
794803
}
795804

805+
if( IsFilterFound( &pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_3DLUT ) )
806+
{
807+
newList[index] = MFX_EXTBUFF_VPP_3DLUT;
808+
index++;
809+
}
810+
796811
if( IsFilterFound( &pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_SCENE_ANALYSIS ) )
797812
{
798813
newList[index] = MFX_EXTBUFF_VPP_SCENE_ANALYSIS;
@@ -1253,6 +1268,14 @@ mfxStatus GetPipelineList(
12531268
}
12541269
}
12551270

1271+
if( IsFilterFound( &configList[0], configCount, MFX_EXTBUFF_VPP_3DLUT ) && !IsFilterFound(&pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_3DLUT) )
1272+
{
1273+
if( !IsFilterFound( &pipelineList[0], (mfxU32)pipelineList.size(), MFX_EXTBUFF_VPP_3DLUT ) )
1274+
{
1275+
pipelineList.push_back( MFX_EXTBUFF_VPP_3DLUT );
1276+
}
1277+
}
1278+
12561279
searchCount = sizeof(g_TABLE_CONFIG) / sizeof(*g_TABLE_CONFIG);
12571280
fCount = configCount;
12581281
for(fIdx = 0; fIdx < fCount; fIdx++)
@@ -1404,8 +1427,14 @@ mfxStatus CheckFrameInfo(mfxFrameInfo* info, mfxU32 request, eMFXHWType platform
14041427
}
14051428

14061429
/* checking Height based on PicStruct filed */
1407-
if (MFX_PICSTRUCT_PROGRESSIVE & info->PicStruct ||
1408-
MFX_PICSTRUCT_FIELD_SINGLE & info->PicStruct)
1430+
if (MFX_PICSTRUCT_PROGRESSIVE & info->PicStruct)
1431+
{
1432+
if ((info->Height & 4) !=0)
1433+
{
1434+
return MFX_ERR_INVALID_VIDEO_PARAM;
1435+
}
1436+
}
1437+
else if (MFX_PICSTRUCT_FIELD_SINGLE & info->PicStruct)
14091438
{
14101439
if ((info->Height & 15) !=0)
14111440
{
@@ -2288,6 +2317,11 @@ void ConvertCaps2ListDoUse(MfxHwVideoProcessing::mfxVppCaps& caps, std::vector<m
22882317
list.push_back(MFX_EXTBUFF_VPP_SCALING);
22892318
}
22902319

2320+
if(caps.u3DLut)
2321+
{
2322+
list.push_back(MFX_EXTBUFF_VPP_3DLUT);
2323+
}
2324+
22912325
#if (MFX_VERSION >= 1025)
22922326
if (caps.uChromaSiting)
22932327
{

‎_studio/shared/include/mfx_utils_defs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <vector>
2626
#include <memory>
2727
#include <assert.h>
28-
28+
#define MFX_DEBUG_TRACE
2929
#ifndef MFX_DEBUG_TRACE
3030
#define MFX_STS_TRACE(sts) sts
3131
#else

0 commit comments

Comments
 (0)