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

Commit

Permalink
Add 3DLUT filter in VPP.
Browse files Browse the repository at this point in the history
1. Add 3DLUT interface and Linux implementation.
2. Add tutorials for 3DLUT VPP and transcode.

Signed-off-by: Furong Zhang <[email protected]>
  • Loading branch information
FurongZhang committed Apr 24, 2021
1 parent 510d19d commit 85472c5
Show file tree
Hide file tree
Showing 36 changed files with 2,679 additions and 44 deletions.
55 changes: 54 additions & 1 deletion _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 @@ -5664,6 +5678,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 +6301,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
18 changes: 17 additions & 1 deletion _studio/shared/include/mfx_vpp_interface.h
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 @@ -186,6 +186,8 @@ namespace MfxHwVideoProcessing

mfxU32 uMirroring;

mfxU32 u3DLut;

mfxVppCaps()
: uAdvancedDI(0)
, uSimpleDI(0)
Expand Down Expand Up @@ -213,6 +215,7 @@ namespace MfxHwVideoProcessing
, uChromaSiting(0)
, mFormatSupport()
, uMirroring(0)
, u3DLut(0)
{
};
};
Expand Down Expand Up @@ -253,6 +256,15 @@ namespace MfxHwVideoProcessing
}
};

struct Lut3DInfo {
bool Enabled;
mfxMemId MemId;
mfxDataType DataType;
mfxResourceType BufferType;
mfx3DLutMemoryLayout MemLayout;
mfx3DLutChannelMapping ChannelMapping;
};

public:
mfxExecuteParams():
targetSurface()
Expand Down Expand Up @@ -328,6 +340,7 @@ namespace MfxHwVideoProcessing

VideoSignalInfo.clear();
VideoSignalInfo.assign(1, VideoSignalInfoIn);
lut3DInfo= {};
};

bool IsDoNothing()
Expand Down Expand Up @@ -362,6 +375,7 @@ namespace MfxHwVideoProcessing
#ifdef MFX_ENABLE_MCTF
|| bEnableMctf != false
#endif
|| lut3DInfo.Enabled != false
)
return false;
if (VideoSignalInfoIn != VideoSignalInfoOut)
Expand Down Expand Up @@ -457,6 +471,8 @@ namespace MfxHwVideoProcessing
#endif
#endif
bool reset;

Lut3DInfo lut3DInfo;
};

class DriverVideoProcessing
Expand Down
5 changes: 4 additions & 1 deletion _studio/shared/include/mfx_vpp_vaapi.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2020 Intel Corporation
// Copyright (c) 2017-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 @@ -161,6 +161,9 @@ namespace MfxHwVideoProcessing

UMC::Mutex m_guard;

VAProcFilterCap3DLUT *m_3dlutCaps;
VABufferID m_3dlutFilterID;

mfxStatus Init( _mfxPlatformAccelerationService* pVADisplay, mfxVideoParam *pParams);

mfxStatus Close( void );
Expand Down
Loading

0 comments on commit 85472c5

Please sign in to comment.