diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h index 15991286ff..53fe6651fe 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_data.h @@ -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 diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.cpp b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.cpp index 19d9c63e90..587e512645 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.cpp +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.cpp @@ -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); - 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) @@ -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; @@ -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; diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.h b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.h index eed835d774..b1d345ffd8 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.h +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_encoded_frame_info.h @@ -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" @@ -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; }; diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.cpp b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.cpp index 7a06bb129d..07d4adea29 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.cpp +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.cpp @@ -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.Insert(Task::EncodedInfo::Key, new MakeStorable); return MFX_ERR_NONE; }); } @@ -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)) { @@ -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); @@ -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) @@ -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(1, m_prevTask.StatusReportId + 1); @@ -2430,6 +2449,7 @@ void General::ConfigureTask( UpdateDPB(m_prevTask.DPB, reinterpret_cast(task), task.RefreshFrameFlags, DpbFrameReleaser(recPool)); MarkLTR(m_prevTask); + UpdateLTRInfo(m_prevTask, encodedInfo); } static bool HaveL1(DpbType const & dpb, mfxI32 displayOrderInGOP) diff --git a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.h b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.h index 6874eb7be5..831bbb8c03 100644 --- a/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.h +++ b/_studio/mfx_lib/encode_hw/av1/agnostic/base/av1ehw_base_general.h @@ -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