From 240eb35cca2134affedc5b4d95a118cfa4445612 Mon Sep 17 00:00:00 2001 From: gfxVPLsdm Date: Mon, 11 Sep 2023 23:17:30 +0800 Subject: [PATCH] Remove All SW EncTools/Linux ACQM Code from Non-Enctools (#5788) Co-authored-by: Chandler Brown --- _studio/mfx_lib/encode_hw/CMakeLists.txt | 2 ++ .../agnostic/base/hevcehw_base_legacy.cpp | 1 + .../agnostic/base/hevcehw_base_packer.cpp | 4 ++- .../hevcehw_base_enctools_qmatrix_lin.cpp | 23 ++++++++++++++ .../base/hevcehw_base_enctools_qmatrix_lin.h | 30 +++++++++++++++++++ .../hevc/linux/base/hevcehw_base_lin.cpp | 11 ------- .../linux/base/hevcehw_base_va_packer_lin.cpp | 8 ----- .../linux/base/hevcehw_base_va_packer_lin.h | 5 ---- 8 files changed, 59 insertions(+), 25 deletions(-) create mode 100644 _studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.cpp create mode 100644 _studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.h diff --git a/_studio/mfx_lib/encode_hw/CMakeLists.txt b/_studio/mfx_lib/encode_hw/CMakeLists.txt index a9fdec9a0a..f2282d4897 100644 --- a/_studio/mfx_lib/encode_hw/CMakeLists.txt +++ b/_studio/mfx_lib/encode_hw/CMakeLists.txt @@ -88,6 +88,7 @@ if (MFX_ENABLE_H265_VIDEO_ENCODE) hevc/linux/base/hevcehw_base_roi_lin.h hevc/linux/base/hevcehw_base_va_lin.h hevc/linux/base/hevcehw_base_va_packer_lin.h + hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.h hevc/linux/base/hevcehw_base_weighted_prediction_lin.h hevc/linux/base/hevcehw_base_max_frame_size_lin.h hevc/linux/base/hevcehw_base_dirty_rect_lin.h @@ -134,6 +135,7 @@ if (MFX_ENABLE_H265_VIDEO_ENCODE) hevc/linux/base/hevcehw_base_va_lin.cpp hevc/linux/base/hevcehw_base_va_packer_lin.cpp hevc/linux/base/hevcehw_base_weighted_prediction_lin.cpp + hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.cpp hevc/linux/base/hevcehw_base_max_frame_size_lin.cpp hevc/linux/base/hevcehw_base_dirty_rect_lin.cpp hevc/linux/base/hevcehw_base_rext_lin.cpp diff --git a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_legacy.cpp b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_legacy.cpp index 4363d49941..09f734d6be 100644 --- a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_legacy.cpp +++ b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_legacy.cpp @@ -193,6 +193,7 @@ void Legacy::SetSupported(ParamSupport& blocks) MFX_COPY_FIELD(LowDelayBRC); MFX_COPY_FIELD(BRCPanicMode); MFX_COPY_FIELD(ScenarioInfo); + MFX_COPY_FIELD(ContentInfo); MFX_COPY_FIELD(AdaptiveCQM); }); blocks.m_ebCopyPtrs[MFX_EXTBUFF_CODING_OPTION_SPSPPS].emplace_back( diff --git a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_packer.cpp b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_packer.cpp index 485a121344..b5ddaaecad 100644 --- a/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_packer.cpp +++ b/_studio/mfx_lib/encode_hw/hevc/agnostic/base/hevcehw_base_packer.cpp @@ -1984,12 +1984,14 @@ mfxStatus Packer::Reset( sts = PackHeader(rbsp, pESBegin, pESEnd, ph.PPS); MFX_CHECK_STS(sts); pESBegin += ph.PPS.BitLen / 8; + bool bPackedCqmPPS = false; // Pack cqm PPS header for adaptive cqm. - if (m_pGlob->Contains(CC::Key) && + if (!bPackedCqmPPS && m_pGlob->Contains(CC::Key) && CC::Get(*m_pGlob).PackAdaptiveCqmHeader && CC::Get(*m_pGlob).PackAdaptiveCqmHeader(m_pGlob)) { + bPackedCqmPPS = true; ph.CqmPPS.resize(CQM_HINT_NUM_CUST_MATRIX); for (mfxU8 idx = 0; idx < CQM_HINT_NUM_CUST_MATRIX && idx < cqmpps.size(); idx++) { diff --git a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.cpp b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.cpp new file mode 100644 index 0000000000..32d23d49a4 --- /dev/null +++ b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2019-2022 Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#include "mfx_common.h" +#if defined(MFX_ENABLE_H265_VIDEO_ENCODE) +#endif // defined(MFX_ENABLE_H265_VIDEO_ENCODE) diff --git a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.h b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.h new file mode 100644 index 0000000000..e4db940f92 --- /dev/null +++ b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_enctools_qmatrix_lin.h @@ -0,0 +1,30 @@ +// Copyright (c) 2019-2022 Intel Corporation +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +#pragma once + +#include "mfx_common.h" +#include + +#include "hevcehw_base.h" +#include "hevcehw_base_data.h" + +#if defined(MFX_ENABLE_H265_VIDEO_ENCODE) +#endif // defined(MFX_ENABLE_H265_VIDEO_ENCODE) diff --git a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_lin.cpp b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_lin.cpp index aa5d917d18..a13afcb6cb 100644 --- a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_lin.cpp +++ b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_lin.cpp @@ -40,9 +40,6 @@ #if defined(MFX_ENABLE_HEVCE_WEIGHTED_PREDICTION) #include "hevcehw_base_weighted_prediction_lin.h" #endif -#if defined (MFX_ENABLE_HEVC_CUSTOM_QMATRIX) -#include "hevcehw_base_qmatrix_lin.h" -#endif #if defined(MFX_ENABLE_HEVCE_ROI) #include "hevcehw_base_roi_lin.h" #endif @@ -92,9 +89,6 @@ Linux::Base::MFXVideoENCODEH265_HW::MFXVideoENCODEH265_HW( #if defined(MFX_ENABLE_HEVCE_WEIGHTED_PREDICTION) m_features.emplace_back(new WeightPred(FEATURE_WEIGHTPRED)); #endif //defined(MFX_ENABLE_HEVCE_WEIGHTED_PREDICTION) -#if defined (MFX_ENABLE_HEVC_CUSTOM_QMATRIX) - m_features.emplace_back(new QMatrix(FEATURE_QMATRIX)); -#endif #if defined(MFX_ENABLE_HEVCE_ROI) m_features.emplace_back(new ROI(FEATURE_ROI)); #endif @@ -137,11 +131,6 @@ mfxStatus Linux::Base::MFXVideoENCODEH265_HW::Init(mfxVideoParam *par) } { auto& queue = BQ::Get(*this); -#if defined (MFX_ENABLE_HEVC_CUSTOM_QMATRIX) - Reorder(queue - , { FEATURE_DDI, IDDI::BLK_SubmitTask } - , { FEATURE_QMATRIX, QMatrix::BLK_PatchDDITask }); -#endif //defined(MFX_ENABLE_HEVC_CUSTOM_QMATRIX) } diff --git a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.cpp b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.cpp index 97d5f6657f..4c569732e6 100644 --- a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.cpp +++ b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.cpp @@ -910,14 +910,6 @@ void VAPacker::SubmitTask(const FeatureBlocks& /*blocks*/, TPushST Push) AddPackedHeaderIf(!!(task.InsertHeaders & INSERT_PPS) , ph.PPS, par, VAEncPackedHeaderHEVC_PPS); - if (cc.PackAdaptiveCqmPPS && cc.PackAdaptiveCqmPPS(global, s_task)) - { - for (mfxU32 i = 0; i < CQM_HINT_NUM_CUST_MATRIX; ++i) - { - AddPackedHeaderIf(true, ph.CqmPPS.at(i), par, VAEncPackedHeaderHEVC_PPS); - } - } - AddPackedHeaderIf((!!(task.InsertHeaders & INSERT_SEI) || task.ctrl.NumPayload) && ph.PrefixSEI.BitLen , ph.PrefixSEI, par/*, VAEncPackedHeaderHEVC_SEI*/); diff --git a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.h b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.h index a86362954c..ab7b1b463f 100644 --- a/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.h +++ b/_studio/mfx_lib/encode_hw/hevc/linux/base/hevcehw_base_va_packer_lin.h @@ -82,11 +82,6 @@ class VAPacker , const VACodedBufferSegment&>; TUpdateCqmHint UpdateCqmHint; - using TPackAdaptiveCqmPPS = CallChain; //task - TPackAdaptiveCqmPPS PackAdaptiveCqmPPS; - using TUpdateEncQP = CallChain