Skip to content

Commit

Permalink
[HEVCe] Support Dynamic Slice Size in refactor code
Browse files Browse the repository at this point in the history
To enable dynamic slice size, use MaxSliceSize to specify maximum slice size in
bytes.

Signed-off-by: Jeremy Shang <jeremy.shang@intel.com>
  • Loading branch information
JeremyShang authored and dmitryermilov committed Dec 2, 2020
1 parent afddf32 commit 97dc82e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void VAPacker::Query1WithCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push)
caps.TUSupport = 73;
caps.SliceStructure = 4;
caps.ParallelBRC = bLP ? 0 : 1;
caps.SliceByteSizeCtrl = 1;

caps.MaxEncodedBitDepth |= (!caps.BitDepth8Only);
caps.YUV444ReconSupport |= (!caps.Color420Only && IsOn(par.mfx.LowPower));
Expand Down Expand Up @@ -379,6 +380,16 @@ void AddVaMiscQualityParams(
quality_param.PanicModeDisable = IsOff(CO3.BRCPanicMode);
}

void AddVaMiscMaxSliceSize(
const Glob::VideoParam::TRef& par
, std::list<std::vector<mfxU8>>& buf)
{
const mfxExtCodingOption2& CO2 = ExtBuffer::Get(par);
auto& maxSliceSize_param = AddVaMisc<VAEncMiscParameterMaxSliceSize>(VAEncMiscParameterTypeMaxSliceSize, buf);

maxSliceSize_param.max_slice_size = CO2.MaxSliceSize;
}

void CUQPMap::Init (mfxU32 picWidthInLumaSamples, mfxU32 picHeightInLumaSamples, mfxU32 blockSize)
{
mfxU32 blkSz = 8 << blockSize;
Expand Down Expand Up @@ -452,6 +463,7 @@ void UpdatePPS(
pps.decoded_curr_pic.picture_id = rec.at(task.Rec.Idx);
pps.decoded_curr_pic.pic_order_cnt = task.POC;
pps.decoded_curr_pic.flags = 0;
pps.nal_unit_type = task.SliceNUT;

auto pDpbBegin = task.DPB.Active;
auto pDpbEnd = task.DPB.Active + Size(task.DPB.Active);
Expand Down Expand Up @@ -519,6 +531,7 @@ void VAPacker::InitAlloc(const FeatureBlocks& /*blocks*/, TPushIA Push)

const auto& par = Glob::VideoParam::Get(strg);
const auto& bs_pps = Glob::PPS::Get(strg);
const mfxExtCodingOption2& CO2 = ExtBuffer::Get(par);

auto& cc = CC::GetOrConstruct(strg);
cc.InitSPS(strg, m_sps);
Expand Down Expand Up @@ -574,6 +587,18 @@ void VAPacker::InitAlloc(const FeatureBlocks& /*blocks*/, TPushIA Push)
AddVaMiscQualityParams(par, m_vaPerSeqMiscData);
return true;
});
if (CO2.MaxSliceSize)
{
cc.AddPerSeqMiscData[VAEncMiscParameterTypeMaxSliceSize].Push([this, &par](
VAPacker::CallChains::TAddMiscData::TExt
, const StorageR&
, const StorageR&
, std::list<std::vector<mfxU8>>& data)
{
AddVaMiscMaxSliceSize(par, m_vaPerSeqMiscData);
return true;
});
}

auto& vaInitPar = Tmp::DDI_InitParam::GetOrConstruct(local);
auto& bsInfo = Glob::AllocBS::Get(strg);
Expand Down Expand Up @@ -668,6 +693,7 @@ void VAPacker::ResetState(const FeatureBlocks& /*blocks*/, TPushRS Push)
{
const auto& par = Glob::VideoParam::Get(strg);
const auto& bs_pps = Glob::PPS::Get(strg);
const mfxExtCodingOption2& CO2 = ExtBuffer::Get(par);

auto& cc = CC::GetOrConstruct(strg);
cc.InitSPS(strg, m_sps);
Expand Down Expand Up @@ -728,6 +754,18 @@ void VAPacker::ResetState(const FeatureBlocks& /*blocks*/, TPushRS Push)
AddVaMiscQualityParams(par, m_vaPerSeqMiscData);
return true;
});
if (CO2.MaxSliceSize)
{
cc.AddPerSeqMiscData[VAEncMiscParameterTypeMaxSliceSize].Push([this, &par](
VAPacker::CallChains::TAddMiscData::TExt
, const StorageR&
, const StorageR&
, std::list<std::vector<mfxU8>>& data)
{
AddVaMiscMaxSliceSize(par, m_vaPerSeqMiscData);
return true;
});
}

auto& vaInitPar = Tmp::DDI_InitParam::GetOrConstruct(local);
vaInitPar.clear();
Expand Down
2 changes: 1 addition & 1 deletion _studio/mfx_lib/encode_hw/shared/ehw_utils_vaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ bool VAAPIParPacker::AddPackedHeaderIf(

xPar.Function = VAEncPackedHeaderDataBufferType;
xPar.In.pData = pd.pData;
xPar.In.Size = pd.BitLen / 8;
xPar.In.Size = (pd.BitLen + 7) / 8;
xPar.In.Num = 1;
par.push_back(xPar);

Expand Down

0 comments on commit 97dc82e

Please sign in to comment.