Skip to content

Commit

Permalink
[Encode/av1e] Report LTR info for AV1 (#6412)
Browse files Browse the repository at this point in the history
Update LTR info to output ext buffer
Fix Linux case failure

Co-authored-by: minjian <[email protected]>
  • Loading branch information
gfxVPLsdm and LesterMinGSE authored Jan 15, 2024
1 parent 7bc1f13 commit 3369891
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1390,6 +1390,9 @@ namespace Base
TUsedRefList UsedRefListL0 = {};
TUsedRefList UsedRefListL1 = {};
mfxU16 QpY = 0;
mfxU32 DisplayOrder = 0;
mfxU16 LongTermIdx = MFX_LONGTERM_IDX_NO_IDX;
bool isLTR = false;
};

struct Task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,21 @@ void EncodedFrameInfo::Query1WithCaps(const FeatureBlocks& /*blocks*/, TPushQ1 P
});
}

void EncodedFrameInfo::AllocTask(const FeatureBlocks& blocks, TPushAT Push)
void EncodedFrameInfo::InitTask(const FeatureBlocks& blocks, TPushIT Push)
{
Push(BLK_AllocTask
Push(BLK_InitTask
, [this, &blocks](
StorageR& /*global*/
, StorageRW& task) -> mfxStatus
{
task.Insert(Task::EncodedInfo::Key, new MakeStorable<Task::EncodedInfo::TRef>);
return MFX_ERR_NONE;
});
mfxEncodeCtrl* /*pCtrl*/
, mfxFrameSurface1* /*pSurf*/
, mfxBitstream* /*pBs*/
, StorageW& /*global*/
, StorageW& task) -> mfxStatus
{
auto& encodedInfo = Task::EncodedInfo::Get(task);
encodedInfo = EncodedInfoAv1();

return MFX_ERR_NONE;
});
}

void EncodedFrameInfo::QueryTask(const FeatureBlocks& /*blocks*/, TPushQT Push)
Expand Down Expand Up @@ -110,7 +115,7 @@ void EncodedFrameInfo::QueryTask(const FeatureBlocks& /*blocks*/, TPushQT Push)
auto& src = task.DPB[idx % task.DPB.size()];

dst.FrameOrder = src->DisplayOrder;
dst.LongTermIdx = mfxU16(MFX_LONGTERM_IDX_NO_IDX * !src->isLTR);
dst.LongTermIdx = src->isLTR ? src->LongTermIdx : MFX_LONGTERM_IDX_NO_IDX;
dst.PicStruct = MFX_PICSTRUCT_PROGRESSIVE;

return dst;
Expand Down Expand Up @@ -149,7 +154,7 @@ void EncodedFrameInfo::QueryTask(const FeatureBlocks& /*blocks*/, TPushQT Push)
std::copy(std::begin(encodedInfo.UsedRefListL1), std::end(encodedInfo.UsedRefListL1),
std::begin(pInfo->UsedRefListL1));
pInfo->FrameOrder = (task.FrameOrderIn == mfxU32(-1)) ? task.DisplayOrder : task.FrameOrderIn;
pInfo->LongTermIdx = mfxU16(MFX_LONGTERM_IDX_NO_IDX * !task.isLTR);
pInfo->LongTermIdx = encodedInfo.isLTR ? encodedInfo.LongTermIdx : MFX_LONGTERM_IDX_NO_IDX;
pInfo->PicStruct = MFX_PICSTRUCT_PROGRESSIVE;
pInfo->QP = encodedInfo.QpY;
pInfo->BRCPanicMode = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Base
public:
#define DECL_BLOCK_LIST\
DECL_BLOCK(CheckMAD )\
DECL_BLOCK(AllocTask )\
DECL_BLOCK(InitTask )\
DECL_BLOCK(QueryInfo )\
DECL_BLOCK(ReportInfo)
#define DECL_FEATURE_NAME "Base_EncodedFrameInfo"
Expand All @@ -49,7 +49,7 @@ namespace Base
protected:
virtual void SetSupported(ParamSupport& par) override;
virtual void Query1WithCaps(const FeatureBlocks& /*blocks*/, TPushQ1 Push) override;
virtual void AllocTask(const FeatureBlocks& blocks, TPushAT Push) override;
virtual void InitTask(const FeatureBlocks& blocks, TPushIT Push) override;
virtual void QueryTask(const FeatureBlocks& /*blocks*/, TPushQT Push) override;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,7 @@ void General::AllocTask(const FeatureBlocks& blocks, TPushAT Push)
{
task.Insert(Task::Common::Key, new Task::Common::TRef);
task.Insert(Task::FH::Key, new MakeStorable<Task::FH::TRef>);
task.Insert(Task::EncodedInfo::Key, new MakeStorable<Task::EncodedInfo::TRef>);
return MFX_ERR_NONE;
});
}
Expand Down Expand Up @@ -1452,6 +1453,7 @@ void General::PostReorderTask(const FeatureBlocks& blocks, TPushPostRT Push)
, StorageW& s_task) -> mfxStatus
{
auto& task = Task::Common::Get(s_task);
auto& encodedInfo = Task::EncodedInfo::Get(s_task);

if (global.Contains(Glob::AllocRaw::Key))
{
Expand All @@ -1468,7 +1470,7 @@ void General::PostReorderTask(const FeatureBlocks& blocks, TPushPostRT Push)

auto& fh = Glob::FH::Get(global);
auto def = GetRTDefaults(global);
ConfigureTask(task, def, recPool);
ConfigureTask(task, def, recPool, encodedInfo);

auto& framesToShowInfo = Glob::FramesToShowInfo::Get(global);
SetTaskFramesToShow(task, framesToShowInfo);
Expand Down Expand Up @@ -2162,6 +2164,22 @@ inline void MarkLTR(TaskCommonPar& task)
}
}

inline void UpdateLTRInfo(TaskCommonPar& task, EncodedInfoAv1& encodedInfo)
{
encodedInfo.DisplayOrder = task.DisplayOrder;

auto LTRframe = std::find_if(
task.DPB.begin()
, task.DPB.end()
, [encodedInfo](const DpbType::value_type& f) {
return f && f->isLTR && f->DisplayOrder == encodedInfo.DisplayOrder;});
if (LTRframe != task.DPB.end())
{
encodedInfo.isLTR = true;
encodedInfo.LongTermIdx = (*LTRframe)->LongTermIdx;
}
}

// task - [in/out] Current task object, task.DPB may be modified
// Return - N/A
inline void MarkRejected(TaskCommonPar& task)
Expand Down Expand Up @@ -2405,7 +2423,8 @@ inline void SetTaskTCBRC(
void General::ConfigureTask(
TaskCommonPar& task
, const Defaults::Param& dflts
, IAllocation& recPool)
, IAllocation& recPool
, EncodedInfoAv1& encodedInfo)
{
task.StatusReportId = std::max<mfxU32>(1, m_prevTask.StatusReportId + 1);

Expand All @@ -2430,6 +2449,7 @@ void General::ConfigureTask(

UpdateDPB(m_prevTask.DPB, reinterpret_cast<DpbFrame&>(task), task.RefreshFrameFlags, DpbFrameReleaser(recPool));
MarkLTR(m_prevTask);
UpdateLTRInfo(m_prevTask, encodedInfo);
}

static bool HaveL1(DpbType const & dpb, mfxI32 displayOrderInGOP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,10 @@ namespace Base
, FH& fh);

void ConfigureTask(
TaskCommonPar & task
TaskCommonPar& task
, const Defaults::Param& dflts
, IAllocation& recPool);
, IAllocation& recPool
, EncodedInfoAv1& encodedInfo);

mfxStatus GetCurrentFrameHeader(
const TaskCommonPar& task
Expand Down

0 comments on commit 3369891

Please sign in to comment.