Skip to content

Commit

Permalink
[Encode] Reapply "[Encode] Refine AV1 error check and header packer (…
Browse files Browse the repository at this point in the history
…#7959)" and a dependent PR, with a Linux bug fix (#6311)

Co-authored-by: walter-bai <[email protected]>
  • Loading branch information
gfxVPLsdm and walter-bai authored Dec 19, 2023
1 parent 2faa96b commit 62a0310
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3108,7 +3108,8 @@ mfxStatus General::CheckShift(mfxVideoParam & par)

if (bVideoMem && !fi.Shift)
{
if (fi.FourCC == MFX_FOURCC_P010 || fi.FourCC == MFX_FOURCC_P210)
if (fi.FourCC == MFX_FOURCC_P010
)
{
fi.Shift = 1;
return MFX_WRN_INCOMPATIBLE_VIDEO_PARAM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,9 +1127,6 @@ class CheckAndFix
pCO3->TargetChromaFormatPlus1 = defPar.base.GetTargetChromaFormatPlus1(defPar);
}


MFX_CHECK(!invalid, MFX_ERR_UNSUPPORTED);

//check targetChromaFormat By FourCC and profile
mfxU16 profile = defPar.base.GetProfile(defPar);
mfxU32 fourCC = par.mfx.FrameInfo.FourCC;
Expand All @@ -1151,7 +1148,7 @@ class CheckAndFix

MFX_CHECK(!invalid, MFX_ERR_UNSUPPORTED);

std::vector<mfxU32> supportFourCC = compatible.at(pCO3->TargetChromaFormatPlus1).at(profile);
const auto& supportFourCC = compatible.at(pCO3->TargetChromaFormatPlus1).at(profile);
invalid += (std::find(supportFourCC.begin(), supportFourCC.end(), fourCC) == supportFourCC.end());

MFX_CHECK(!invalid, MFX_ERR_UNSUPPORTED);
Expand Down Expand Up @@ -1230,11 +1227,10 @@ class CheckAndFix
|| !Compatible[tbdl == 10].count(tcf)
|| !Compatible[tbdl == 10].at(tcf).count(par.mfx.FrameInfo.FourCC);

assert(!bUndefinedTargetFormat);

par.mfx.FrameInfo.FourCC *= !bUndefinedTargetFormat;

MFX_CHECK(!bUndefinedTargetFormat, MFX_ERR_UNSUPPORTED);

return MFX_ERR_NONE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,8 @@ class IDDI
virtual void QueryTask(const FeatureBlocks& blocks, TPushQT Push) override = 0;
virtual void ResetState(const FeatureBlocks& blocks, TPushRS Push) override = 0;

virtual mfxStatus SetDDIID(const mfxU16 bitDepth
, const mfxU16 chromFormat
, const mfxU32 fourCC
, const mfxU16 targetChromaForamt) = 0;
virtual mfxStatus SetDDIID(mfxU16 targetBitDepth, mfxU16 targetChromaFormat) = 0;

};

} //Base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,13 @@ inline void PackFrameSizeInfo(BitstreamWriter& bs, FH const& fh)

inline void PackColorConfig(BitstreamWriter& bs, SH const& sh)
{
bs.PutBit(sh.color_config.BitDepth == BITDEPTH_10 ? 1 : 0); //high_bitdepth

const bool high_bitdepth = sh.color_config.BitDepth == BITDEPTH_10;
bs.PutBit(high_bitdepth ? 1 : 0); //high_bitdepth

if (sh.seq_profile == 2 && high_bitdepth)
bs.PutBit(0); //twelve_bit

if (sh.seq_profile != 1)
bs.PutBit(0); //mono_chrome

Expand Down
19 changes: 5 additions & 14 deletions _studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_lin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace AV1EHW;
using namespace AV1EHW::Base;
using namespace AV1EHW::Linux::Base;

mfxStatus DDI_VA::SetDDIID(const mfxU16 bitDepth, const mfxU16 chromFormat, const mfxU32 /*fourCC*/, const mfxU16/* targetChromaFormat*/)
mfxStatus DDI_VA::SetDDIID(mfxU16 targetBitDepth, mfxU16 targetChromaFormat)
{
MFX_CHECK(!m_vaid, MFX_ERR_NONE);

Expand Down Expand Up @@ -71,13 +71,13 @@ mfxStatus DDI_VA::SetDDIID(const mfxU16 bitDepth, const mfxU16 chromFormat, cons

// Check that list of VAIDs contains VAID for resulting BitDepth, ChromaFormat
bool bSupported =
VAIDSupported[bEncSliceLPSupported].count(bitDepth)
&& VAIDSupported[bEncSliceLPSupported].at(bitDepth).count(chromFormat);
VAIDSupported[bEncSliceLPSupported].count(targetBitDepth)
&& VAIDSupported[bEncSliceLPSupported].at(targetBitDepth).count(targetChromaFormat);

MFX_CHECK(bSupported, MFX_ERR_UNSUPPORTED);

// Choose and return VAID
m_vaid = const_cast<VAID *>(&VAIDSupported[bEncSliceLPSupported].at(bitDepth).at(chromFormat));
m_vaid = const_cast<VAID *>(&VAIDSupported[bEncSliceLPSupported].at(targetBitDepth).at(targetChromaFormat));

return MFX_ERR_NONE;
}
Expand Down Expand Up @@ -115,18 +115,9 @@ void DDI_VA::Query1NoCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push)
m_hw = Glob::VideoCore::Get(strg).GetHWType();
const mfxU16 bitDepth = m_pDefaults->base.GetBitDepthLuma(*m_pDefaults);
const mfxU16 chromaFormat = par.mfx.FrameInfo.ChromaFormat;
const mfxU32 fourCC = par.mfx.FrameInfo.FourCC;
const mfxU16 profile = par.mfx.CodecProfile;
const mfxExtCodingOption3* pCO3 = ExtBuffer::Get(m_pDefaults->mvp);
mfxU16 targetChromaFormat = MFX_CHROMAFORMAT_YUV420;

SetIf(targetChromaFormat, profile == MFX_PROFILE_AV1_HIGH, MFX_CHROMAFORMAT_YUV444);
if (pCO3)
{
SetIf(targetChromaFormat, !pCO3->TargetChromaFormatPlus1, pCO3->TargetChromaFormatPlus1 - 1);
}

MFX_SAFE_CALL(SetDDIID(bitDepth, chromaFormat, fourCC, targetChromaFormat));
MFX_SAFE_CALL(SetDDIID(bitDepth, chromaFormat));

return MFX_ERR_NONE;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ class DDI_VA
virtual void ResetState(const FeatureBlocks& blocks, TPushRS Push) override;
virtual void SetDefaults(const FeatureBlocks& blocks, TPushSD Push) override;

virtual mfxStatus SetDDIID(const mfxU16 bitDepth
, const mfxU16 chromFormat
, const mfxU32 fourCC
, const mfxU16 targetChromaFormat) override;
virtual mfxStatus SetDDIID(mfxU16 targetBitDepth, mfxU16 targetChromaFormat) override;

mfxStatus CreateVABuffers(
const std::list<DDIExecParam>& par
Expand Down

0 comments on commit 62a0310

Please sign in to comment.