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 63bf907e94..016713ad99 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 @@ -840,11 +840,6 @@ namespace Base mfxI32 PrevRAP = -1; mfxU16 NumRecode = 0; mfxU8 QpY = 0; - mfxI8 YDcDeltaQ = 0; - mfxI8 UDcDeltaQ = 0; - mfxI8 UAcDeltaQ = 0; - mfxI8 VDcDeltaQ = 0; - mfxI8 VAcDeltaQ = 0; mfxU32 InsertHeaders = 0; mfxU32 StatusReportId = mfxU32(-1); DpbRefreshType RefreshFrameFlags = {}; 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 c96b882d98..c43d2e4b02 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 @@ -1481,9 +1481,9 @@ void General::PostReorderTask(const FeatureBlocks& blocks, TPushPostRT Push) MFX_CHECK(task.Rec.Idx != IDX_INVALID, MFX_ERR_UNDEFINED_BEHAVIOR); MFX_CHECK(task.Rec.Mid && task.BS.Mid, MFX_ERR_UNDEFINED_BEHAVIOR); - auto& fh = Glob::FH::Get(global); + auto& glob_fh = Glob::FH::Get(global); auto def = GetRTDefaults(global); - ConfigureTask(task, def, recPool, encodedInfo); + ConfigureTask(task, def, recPool, encodedInfo, glob_fh); auto& framesToShowInfo = Glob::FramesToShowInfo::Get(global); SetTaskFramesToShow(task, framesToShowInfo); @@ -1492,7 +1492,8 @@ void General::PostReorderTask(const FeatureBlocks& blocks, TPushPostRT Push) SetTaskRepeatedFramesSize(task, repeatFrameSizeInfo); auto& sh = Glob::SH::Get(global); - auto sts = GetCurrentFrameHeader(task, def, sh, fh, Task::FH::Get(s_task)); + auto& task_fh = Task::FH::Get(s_task); + auto sts = GetCurrentFrameHeader(task, def, sh, glob_fh, task_fh); MFX_CHECK_STS(sts); return sts; @@ -2075,11 +2076,13 @@ inline std::tuple GetMaxRefs( inline void SetTaskQp( TaskCommonPar& task - , const mfxVideoParam& par) + , const mfxVideoParam& par + , FH& fh) { if (par.mfx.RateControlMethod != MFX_RATECONTROL_CQP) { task.QpY = 128; + fh.quantization_params.base_q_idx = task.QpY; return; } @@ -2106,9 +2109,11 @@ inline void SetTaskQp( } SetIf(task.QpY, !!task.ctrl.QP, static_cast(task.ctrl.QP)); + fh.quantization_params.base_q_idx = task.QpY; } -inline bool CheckQpInRangeOrClip(mfxI32 qp, mfxI8& delta) +template +inline bool CheckQpInRangeOrClip(mfxI32 qp, T& delta) { mfxI32 clipQp = static_cast(delta); @@ -2127,13 +2132,11 @@ inline bool CheckQpInRangeOrClip(mfxI32 qp, mfxI8& delta) std::ignore = CheckRangeOrClip(clipQp, -63, 63); - delta = static_cast(clipQp); + delta = static_cast(clipQp); return true; } -inline void ClipTaskDeltaQp( - TaskCommonPar& task - ,const mfxVideoParam& par) +inline void ClipDeltaQp(const mfxVideoParam& par, FH& fh) { if (par.mfx.RateControlMethod != MFX_RATECONTROL_CQP) { @@ -2142,17 +2145,19 @@ inline void ClipTaskDeltaQp( const mfxExtAV1AuxData& auxPar = ExtBuffer::Get(par); mfxU32 changed = 0; - task.YDcDeltaQ = auxPar.QP.YDcDeltaQ; - task.UDcDeltaQ = auxPar.QP.UDcDeltaQ; - task.UAcDeltaQ = auxPar.QP.UAcDeltaQ; - task.VDcDeltaQ = auxPar.QP.VDcDeltaQ; - task.VAcDeltaQ = auxPar.QP.VAcDeltaQ; + fh.quantization_params.DeltaQYDc = static_cast(auxPar.QP.YDcDeltaQ); + fh.quantization_params.DeltaQUDc = static_cast(auxPar.QP.UDcDeltaQ); + fh.quantization_params.DeltaQUAc = static_cast(auxPar.QP.UAcDeltaQ); + fh.quantization_params.DeltaQVDc = static_cast(auxPar.QP.VDcDeltaQ); + fh.quantization_params.DeltaQVAc = static_cast(auxPar.QP.VAcDeltaQ); - changed += CheckQpInRangeOrClip(task.QpY, task.YDcDeltaQ); - changed += CheckQpInRangeOrClip(task.QpY, task.UDcDeltaQ); - changed += CheckQpInRangeOrClip(task.QpY, task.UAcDeltaQ); - changed += CheckQpInRangeOrClip(task.QpY, task.VDcDeltaQ); - changed += CheckQpInRangeOrClip(task.QpY, task.VAcDeltaQ); + auto qp = fh.quantization_params.base_q_idx; + + changed += CheckQpInRangeOrClip(qp, fh.quantization_params.DeltaQYDc); + changed += CheckQpInRangeOrClip(qp, fh.quantization_params.DeltaQUDc); + changed += CheckQpInRangeOrClip(qp, fh.quantization_params.DeltaQUAc); + changed += CheckQpInRangeOrClip(qp, fh.quantization_params.DeltaQVDc); + changed += CheckQpInRangeOrClip(qp, fh.quantization_params.DeltaQVAc); std::ignore = changed; @@ -2681,13 +2686,14 @@ void General::ConfigureTask( TaskCommonPar& task , const Defaults::Param& dflts , IAllocation& recPool - , EncodedInfoAv1& encodedInfo) + , EncodedInfoAv1& encodedInfo + , FH& fh) { task.StatusReportId = std::max(1, m_prevTask.StatusReportId + 1); const auto& par = dflts.mvp; - SetTaskQp(task, par); - ClipTaskDeltaQp(task, par); + SetTaskQp(task, par, fh); + ClipDeltaQp(par, fh); SetTaskBRCParams(task, par); SetTaskEncodeOrders(task, m_prevTask); @@ -4560,14 +4566,6 @@ mfxStatus General::GetCurrentFrameHeader( SetRefFrameFlags(task, currFH, frameIsIntra); SetRefFrameIndex(task, currFH, frameIsIntra); - currFH.quantization_params.base_q_idx = task.QpY; - - currFH.quantization_params.DeltaQYDc = task.YDcDeltaQ; - currFH.quantization_params.DeltaQUDc = task.UDcDeltaQ; - currFH.quantization_params.DeltaQUAc = task.UAcDeltaQ; - currFH.quantization_params.DeltaQVDc = task.VDcDeltaQ; - currFH.quantization_params.DeltaQVAc = task.VAcDeltaQ; - if (IsLossless(currFH)) { currFH.CodedLossless = 1; 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 07ae492333..f2ef972d71 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 @@ -208,7 +208,8 @@ namespace Base TaskCommonPar& task , const Defaults::Param& dflts , IAllocation& recPool - , EncodedInfoAv1& encodedInfo); + , EncodedInfoAv1& encodedInfo + , FH& fh); mfxStatus GetCurrentFrameHeader( const TaskCommonPar& task diff --git a/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp b/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp index 3884565d93..f6853c6e00 100644 --- a/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp +++ b/_studio/mfx_lib/encode_hw/av1/linux/base/av1ehw_base_va_packer_lin.cpp @@ -364,11 +364,11 @@ void UpdatePPS( pps.min_base_qindex = task.MinBaseQIndex; pps.max_base_qindex = task.MaxBaseQIndex; - pps.y_dc_delta_q = task.YDcDeltaQ; - pps.u_dc_delta_q = task.UDcDeltaQ; - pps.u_ac_delta_q = task.UAcDeltaQ; - pps.v_dc_delta_q = task.VDcDeltaQ; - pps.v_ac_delta_q = task.VAcDeltaQ; + pps.y_dc_delta_q = static_cast(bs_fh.quantization_params.DeltaQYDc); + pps.u_dc_delta_q = static_cast(bs_fh.quantization_params.DeltaQUDc); + pps.u_ac_delta_q = static_cast(bs_fh.quantization_params.DeltaQUAc); + pps.v_dc_delta_q = static_cast(bs_fh.quantization_params.DeltaQVDc); + pps.v_ac_delta_q = static_cast(bs_fh.quantization_params.DeltaQVAc); pps.order_hint = static_cast(bs_fh.order_hint);