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

Commit cad248a

Browse files
committedApr 13, 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 cad248a

28 files changed

+2385
-45
lines changed
 

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

+45-1
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+
memset(&pMfxExecuteParams->lut3DInfo, 0, sizeof(pMfxExecuteParams->lut3DInfo));
151152
} /*void MemSetZero4mfxExecuteParams (mfxExecuteParams *pMfxExecuteParams )*/
152153

153154

@@ -2036,6 +2037,16 @@ 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->MemID = m_executeParams.lut3DInfo.MemID;
2045+
bufSc->Size = m_executeParams.lut3DInfo.Size;
2046+
bufSc->DataPrecision = m_executeParams.lut3DInfo.DataPrecision;
2047+
bufSc->MemoryLayout = m_executeParams.lut3DInfo.MemoryLayout;
2048+
bufSc->ChannelMapping = m_executeParams.lut3DInfo.ChannelMapping;
2049+
}
20392050
#if (MFX_VERSION >= 1025)
20402051
else if (MFX_EXTBUFF_VPP_COLOR_CONVERSION == bufferId)
20412052
{
@@ -5664,6 +5675,35 @@ mfxStatus ConfigureExecuteParams(
56645675
bIsFilterSkipped = true;
56655676
}
56665677

5678+
break;
5679+
}
5680+
case MFX_EXTBUFF_VPP_3DLUT:
5681+
{
5682+
if (caps.u3DLut)
5683+
{
5684+
for (mfxU32 i = 0; i < videoParam.NumExtParam; i++)
5685+
{
5686+
if (videoParam.ExtParam[i]->BufferId == MFX_EXTBUFF_VPP_3DLUT)
5687+
{
5688+
mfxExtVPP3DLut *ext3DLUT = (mfxExtVPP3DLut*) videoParam.ExtParam[i];
5689+
if (ext3DLUT)
5690+
{
5691+
executeParams.lut3DInfo.enabled = true;
5692+
executeParams.lut3DInfo.MemID = ext3DLUT->MemID;
5693+
executeParams.lut3DInfo.Size = ext3DLUT->Size;
5694+
executeParams.lut3DInfo.DataPrecision = ext3DLUT->DataPrecision;
5695+
executeParams.lut3DInfo.MemoryLayout = ext3DLUT->MemoryLayout;
5696+
executeParams.lut3DInfo.ChannelMapping = ext3DLUT->ChannelMapping;
5697+
executeParams.lut3DInfo.IOPattern = videoParam.IOPattern;
5698+
}
5699+
}
5700+
}
5701+
}
5702+
else
5703+
{
5704+
bIsFilterSkipped = true;
5705+
}
5706+
56675707
break;
56685708
}
56695709
#if (MFX_VERSION >= 1025)
@@ -6252,6 +6292,10 @@ mfxStatus ConfigureExecuteParams(
62526292
{
62536293
executeParams.scalingMode = MFX_SCALING_MODE_DEFAULT;
62546294
}
6295+
else if (MFX_EXTBUFF_VPP_3DLUT == bufferId)
6296+
{
6297+
executeParams.lut3DInfo.enabled = false;
6298+
}
62556299
#if (MFX_VERSION >= 1025)
62566300
else if (MFX_EXTBUFF_VPP_COLOR_CONVERSION == bufferId)
62576301
{

‎_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

‎_studio/shared/include/mfx_vpp_interface.h

+18-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
@@ -186,6 +186,8 @@ namespace MfxHwVideoProcessing
186186

187187
mfxU32 uMirroring;
188188

189+
mfxU32 u3DLut;
190+
189191
mfxVppCaps()
190192
: uAdvancedDI(0)
191193
, uSimpleDI(0)
@@ -213,6 +215,7 @@ namespace MfxHwVideoProcessing
213215
, uChromaSiting(0)
214216
, mFormatSupport()
215217
, uMirroring(0)
218+
, u3DLut(0)
216219
{
217220
};
218221
};
@@ -253,6 +256,16 @@ namespace MfxHwVideoProcessing
253256
}
254257
};
255258

259+
struct Lut3DInfo {
260+
bool enabled;
261+
mfxMemId MemID;
262+
mfxU16 IOPattern;
263+
mfxU16 Size;
264+
mfxVariantType DataPrecision;
265+
mfx3DLutMemoryLayout MemoryLayout;
266+
mfx3DLutChannelMapping ChannelMapping;
267+
};
268+
256269
public:
257270
mfxExecuteParams():
258271
targetSurface()
@@ -328,6 +341,7 @@ namespace MfxHwVideoProcessing
328341

329342
VideoSignalInfo.clear();
330343
VideoSignalInfo.assign(1, VideoSignalInfoIn);
344+
memset(&lut3DInfo, 0, sizeof(Lut3DInfo));
331345
};
332346

333347
bool IsDoNothing()
@@ -362,6 +376,7 @@ namespace MfxHwVideoProcessing
362376
#ifdef MFX_ENABLE_MCTF
363377
|| bEnableMctf != false
364378
#endif
379+
|| lut3DInfo.enabled != false
365380
)
366381
return false;
367382
if (VideoSignalInfoIn != VideoSignalInfoOut)
@@ -457,6 +472,8 @@ namespace MfxHwVideoProcessing
457472
#endif
458473
#endif
459474
bool reset;
475+
476+
Lut3DInfo lut3DInfo;
460477
};
461478

462479
class DriverVideoProcessing

‎_studio/shared/include/mfx_vpp_vaapi.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2020 Intel Corporation
1+
// Copyright (c) 2017-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
@@ -161,6 +161,9 @@ namespace MfxHwVideoProcessing
161161

162162
UMC::Mutex m_guard;
163163

164+
VAProcFilterCap3DLUT *m_3dlutCaps;
165+
VABufferID m_3dlutFilterID;
166+
164167
mfxStatus Init( _mfxPlatformAccelerationService* pVADisplay, mfxVideoParam *pParams);
165168

166169
mfxStatus Close( void );

0 commit comments

Comments
 (0)