Skip to content

Commit

Permalink
[AV1e/lib] update code style (#5190)
Browse files Browse the repository at this point in the history
remove unnecessary check for global and mv default value seting to a
common function for global/frame_ctrl

Co-authored-by: Ma, Caihong <[email protected]>
  • Loading branch information
gfxVPLsdm and Christa03 authored May 18, 2023
1 parent 9e61afa commit ad1c93f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 33 deletions.
113 changes: 80 additions & 33 deletions _studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_hdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,52 @@
using namespace AV1EHW;
using namespace AV1EHW::Base;

inline void SetDefaultMasteringDisplayColourVolume(mfxExtMasteringDisplayColourVolume* pMDCV)
{
SetDefault<mfxU32>(pMDCV->MaxDisplayMasteringLuminance, 1u);
SetDefault<mfxU32>(pMDCV->MinDisplayMasteringLuminance, 1u);
}

inline void SetDefaultContentLightLevel(mfxExtContentLightLevelInfo* pCLLI)
{
SetDefault<mfxU16>(pCLLI->MaxContentLightLevel, 1u);
SetDefault<mfxU16>(pCLLI->MaxPicAverageLightLevel, 1u);
}

inline mfxStatus CheckAndFixMasteringDisplayColourVolumeInfo(mfxExtMasteringDisplayColourVolume* pMDCV)
{
mfxU32 changed = 0;

changed += CheckOrZero<mfxU16, MFX_PAYLOAD_OFF, MFX_PAYLOAD_IDR>(pMDCV->InsertPayloadToggle);
changed += CheckMaxOrClip(pMDCV->WhitePointX, 50000u);
changed += CheckMaxOrClip(pMDCV->WhitePointY, 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesX[0], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesX[1], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesX[2], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesY[0], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesY[1], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesY[2], 50000u);
changed += CheckMinOrClip(pMDCV->MaxDisplayMasteringLuminance, 1u);
changed += CheckMaxOrClip(pMDCV->MaxDisplayMasteringLuminance, 65535u);
changed += CheckMinOrClip(pMDCV->MinDisplayMasteringLuminance, 1u);
changed += CheckMaxOrClip(pMDCV->MinDisplayMasteringLuminance, 65535u);

return changed ? MFX_WRN_INCOMPATIBLE_VIDEO_PARAM : MFX_ERR_NONE;
}

inline mfxStatus CheckAndFixContentLightLevelInfo(mfxExtContentLightLevelInfo* pCLLI)
{
mfxU32 changed = 0;

changed += CheckOrZero<mfxU16, MFX_PAYLOAD_OFF, MFX_PAYLOAD_IDR>(pCLLI->InsertPayloadToggle);
changed += CheckMinOrClip(pCLLI->MaxContentLightLevel, 1u);
changed += CheckMaxOrClip(pCLLI->MaxContentLightLevel, 65535u);
changed += CheckMinOrClip(pCLLI->MaxPicAverageLightLevel, 1u);
changed += CheckMaxOrClip(pCLLI->MaxPicAverageLightLevel, 65535u);

return changed ? MFX_WRN_INCOMPATIBLE_VIDEO_PARAM : MFX_ERR_NONE;
}

void Hdr::SetSupported(ParamSupport& blocks)
{
blocks.m_ebCopySupported[MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO].emplace_back(
Expand Down Expand Up @@ -126,10 +172,7 @@ void Hdr::SetDefaults(const FeatureBlocks& /*blocks*/, TPushSD Push)
{
mfxExtMasteringDisplayColourVolume* pMDCV = ExtBuffer::Get(par);
MFX_CHECK(pMDCV, MFX_ERR_NONE);

SetDefault<mfxU16>(pMDCV->InsertPayloadToggle, MFX_PAYLOAD_OFF);
SetDefault<mfxU32>(pMDCV->MaxDisplayMasteringLuminance, 65535u);
SetDefault<mfxU32>(pMDCV->MinDisplayMasteringLuminance, 1u);
SetDefaultMasteringDisplayColourVolume(pMDCV);

return MFX_ERR_NONE;
});
Expand All @@ -139,10 +182,7 @@ void Hdr::SetDefaults(const FeatureBlocks& /*blocks*/, TPushSD Push)
{
mfxExtContentLightLevelInfo* pCLLI = ExtBuffer::Get(par);
MFX_CHECK(pCLLI, MFX_ERR_NONE);

SetDefault<mfxU16>(pCLLI->InsertPayloadToggle, MFX_PAYLOAD_OFF);
SetDefault<mfxU16>(pCLLI->MaxContentLightLevel, 65535u);
SetDefault<mfxU16>(pCLLI->MaxPicAverageLightLevel, 65535u);
SetDefaultContentLightLevel(pCLLI);

return MFX_ERR_NONE;
});
Expand All @@ -155,40 +195,47 @@ void Hdr::Query1WithCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push)
{
mfxExtMasteringDisplayColourVolume* pMDCV = ExtBuffer::Get(par);
MFX_CHECK(pMDCV, MFX_ERR_NONE);
mfxU32 changed = 0;

changed += CheckOrZero<mfxU16, MFX_PAYLOAD_OFF, MFX_PAYLOAD_IDR>(pMDCV->InsertPayloadToggle);
changed += CheckMaxOrClip(pMDCV->WhitePointX, 50000u);
changed += CheckMaxOrClip(pMDCV->WhitePointY, 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesX[0], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesX[1], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesX[2], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesY[0], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesY[1], 50000u);
changed += CheckMaxOrClip(pMDCV->DisplayPrimariesY[2], 50000u);
changed += CheckMinOrClip(pMDCV->MaxDisplayMasteringLuminance, 1u);
changed += CheckMaxOrClip(pMDCV->MaxDisplayMasteringLuminance, 65535u);
changed += CheckMinOrClip(pMDCV->MinDisplayMasteringLuminance, 1u);
changed += CheckMaxOrClip(pMDCV->MinDisplayMasteringLuminance, 65535u);

return changed ? MFX_WRN_INCOMPATIBLE_VIDEO_PARAM : MFX_ERR_NONE;
return CheckAndFixMasteringDisplayColourVolumeInfo(pMDCV);
});

Push(BLK_CheckAndFixCLLI
, [](const mfxVideoParam& /*in*/, mfxVideoParam& par, StorageW& /*global*/) -> mfxStatus
{
mfxExtContentLightLevelInfo* pCLLI = ExtBuffer::Get(par);
MFX_CHECK(pCLLI, MFX_ERR_NONE);
mfxU32 changed = 0;
return CheckAndFixContentLightLevelInfo(pCLLI);
});
}

changed += CheckOrZero<mfxU16, MFX_PAYLOAD_OFF, MFX_PAYLOAD_IDR>(pCLLI->InsertPayloadToggle);
changed += CheckMinOrClip(pCLLI->MaxContentLightLevel, 1u);
changed += CheckMaxOrClip(pCLLI->MaxContentLightLevel, 65535u);
changed += CheckMinOrClip(pCLLI->MaxPicAverageLightLevel, 1u);
changed += CheckMaxOrClip(pCLLI->MaxPicAverageLightLevel, 65535u);
void Hdr::InitTask(const FeatureBlocks& blocks, TPushIT Push)
{
Push(BLK_InitTaskMDCV
, [this, &blocks](
mfxEncodeCtrl* /*pCtrl*/
, mfxFrameSurface1* /*pSurf*/
, mfxBitstream* /*pBs*/
, StorageW& /*global*/
, StorageW& task) -> mfxStatus
{
mfxExtMasteringDisplayColourVolume* pMDCV = ExtBuffer::Get(Task::Common::Get(task).ctrl);
MFX_CHECK(pMDCV, MFX_ERR_NONE);
SetDefaultMasteringDisplayColourVolume(pMDCV);
return CheckAndFixMasteringDisplayColourVolumeInfo(pMDCV);
});

return changed ? MFX_WRN_INCOMPATIBLE_VIDEO_PARAM : MFX_ERR_NONE;
});
Push(BLK_InitTaskCLLI
, [this, &blocks](
mfxEncodeCtrl* /*pCtrl*/
, mfxFrameSurface1* /*pSurf*/
, mfxBitstream* /*pBs*/
, StorageW& /*global*/
, StorageW& task) -> mfxStatus
{
mfxExtContentLightLevelInfo* pCLLI = ExtBuffer::Get(Task::Common::Get(task).ctrl);
MFX_CHECK(pCLLI, MFX_ERR_NONE);
SetDefaultContentLightLevel(pCLLI);
return CheckAndFixContentLightLevelInfo(pCLLI);
});
}

void Hdr::SubmitTask(const FeatureBlocks& /*blocks*/, TPushST Push)
Expand Down
3 changes: 3 additions & 0 deletions _studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_hdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ namespace AV1EHW
DECL_BLOCK(CheckAndFixCLLI)\
DECL_BLOCK(SetDefaultsMDCV)\
DECL_BLOCK(SetDefaultsCLLI)\
DECL_BLOCK(InitTaskMDCV)\
DECL_BLOCK(InitTaskCLLI)\
DECL_BLOCK(InsertPayloads)
#define DECL_FEATURE_NAME "Base_Hdr"
#include "av1ehw_decl_blocks.h"
Expand All @@ -57,6 +59,7 @@ namespace AV1EHW
virtual void SetSupported(ParamSupport& par) override;
virtual void SetDefaults(const FeatureBlocks& blocks, TPushSD Push) override;
virtual void Query1WithCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push) override;
virtual void InitTask(const FeatureBlocks& blocks, TPushIT Push) override;
virtual void SubmitTask(const FeatureBlocks& /*blocks*/, TPushST Push) override;

void PackHDR(BitstreamWriter& bs, const ObuExtensionHeader& oeh, const mfxExtContentLightLevelInfo& LightLevel);
Expand Down

0 comments on commit ad1c93f

Please sign in to comment.