diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_basic_feature_xe2_lpm.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_basic_feature_xe2_lpm.cpp new file mode 100644 index 0000000000..ee29cb9cfe --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_basic_feature_xe2_lpm.cpp @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2021 - 2024, 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. +*/ +//! +//! \file encode_avc_basic_feature_xe2_lpm.cpp +//! \brief Defines the common interface for encode avc Xe2_LPM parameter +//! + +#include "encode_avc_basic_feature_xe2_lpm.h" +#include "mhw_vdbox_vdenc_hwcmd_xe2_lpm.h" + +namespace encode +{ + +MOS_STATUS AvcBasicFeatureXe2_Lpm::Update(void *params) +{ + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(params); + + ENCODE_CHK_STATUS_RETURN(AvcBasicFeature::Update(params)); + + EncoderParams* encodeParams = (EncoderParams*)params; + + // raw surface + if (IS_RGB_FORMAT(m_rawSurface.Format)) + { + ENCODE_CHK_STATUS_RETURN(m_allocator->UpdateResourceUsageType(&m_rawSurface.OsResource, MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_NOCACHE)); + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_PIPE_MODE_SELECT, AvcBasicFeatureXe2_Lpm) +{ + AvcBasicFeature::MHW_SETPAR_F(VDENC_PIPE_MODE_SELECT)(params); + + if (m_seqParam->EnableStreamingBufferLLC || m_seqParam->EnableStreamingBufferDDR) + { + params.streamingBufferConfig = mhw::vdbox::vdenc::xe2_lpm_base::xe2_lpm::Cmd::VDENC_PIPE_MODE_SELECT_CMD::STREAMING_BUFFER_64; + params.captureMode = mhw::vdbox::vdenc::xe2_lpm_base::xe2_lpm::Cmd::VDENC_PIPE_MODE_SELECT_CMD::CAPTURE_MODE_PARALLEFROMCAMERAPIPE; + } + + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_basic_feature_xe2_lpm.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_basic_feature_xe2_lpm.h new file mode 100644 index 0000000000..5c15b00aca --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_basic_feature_xe2_lpm.h @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2021 - 2024, 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. +*/ +//! +//! \file encode_avc_basic_feature_xe2_lpm.h +//! \brief Defines the common interface for encode avc Xe2_LPM basic feature +//! +#ifndef __ENCODE_AVC_BASIC_FEATURE_XE2_LPM_H__ +#define __ENCODE_AVC_BASIC_FEATURE_XE2_LPM_H__ + +#include "encode_avc_basic_feature.h" + +namespace encode +{ + +class AvcBasicFeatureXe2_Lpm : public AvcBasicFeature +{ +public: + AvcBasicFeatureXe2_Lpm(EncodeAllocator * allocator, + CodechalHwInterfaceNext *hwInterface, + TrackedBuffer *trackedBuf, + RecycleResource *recycleBuf, + MediaCopyWrapper *mediaCopyWrapper, + void *constSettings = nullptr) : + AvcBasicFeature(allocator, hwInterface, trackedBuf, recycleBuf, mediaCopyWrapper, constSettings) {} + + virtual ~AvcBasicFeatureXe2_Lpm() {} + + virtual MOS_STATUS Update(void *params) override; + + MHW_SETPAR_DECL_HDR(VDENC_PIPE_MODE_SELECT); + +MEDIA_CLASS_DEFINE_END(encode__AvcBasicFeatureXe2_Lpm) +}; + +} // namespace encode + +#endif // !__ENCODE_AVC_BASIC_FEATURE_XE2_LPM_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm.cpp new file mode 100644 index 0000000000..557184aa8d --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm.cpp @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2021, 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. + */ + +//! +//! \file encode_avc_vdenc_const_settings_xe2_lpm.cpp +//! \brief Defines the common interface for Xe2_LPM avc vdenc const settings +//! + +#include "encode_avc_vdenc_const_settings_xe2_lpm.h" +#include "encode_utils.h" + +namespace encode +{ + +const uint8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_global_rate_ratio_threshold_Xe2_Lpm[7] = {40, 75, 97, 103, 125, 160, 0}; +const uint8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_slwin_global_rate_ratio_threshold_Xe2_Lpm[7] = {40, 75, 97, 103, 125, 160, 0}; +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_global_rate_ratio_threshold_qp_Xe2_Lpm[8] = {-3, -2, -1, 0, 1, 2, 3, 0}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_GlobalRateQPAdjTabI_U8_Xe2_Lpm[64] = +{ + 1, 2, 3, 5, 6, + 1, 1, 2, 3, 5, + 0, 0, 1, 2, 3, + -1, 0, 0, 1, 2, + -1, 0, 0, 0, 1, + -2, -2, -1, 0, 1, + -3, -3, -1, -1, 0, + -5, -3, -2, -1, -1, + -6, -5, -3, -2, -1, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_GlobalRateQPAdjTabP_U8_Xe2_Lpm[64] = +{ + 1, 2, 3, 5, 6, + 1, 1, 2, 3, 5, + 0, 1, 1, 2, 3, + -1, 0, 0, 1, 2, + -1, 0, 0, 0, 1, + -1, -1, -1, 0, 1, + -2, -1, -1, -1, 0, + -4, -2, -1, -1, 0, + -5, -4, -2, -1, -1, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, +}; + +// P picture global rate QP Adjustment table for sliding window BRC +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_SlWinGlobalRateQPAdjTabP_U8_Xe2_Lpm[64] = +{ + 1, 2, 3, 5, 6, + 1, 1, 2, 3, 5, + 0, 1, 1, 2, 3, + -1, 0, 0, 1, 2, + -1, 0, 0, 0, 1, + -1, -1, -1, 0, 1, + -2, -1, -1, -1, 0, + -4, -2, -1, -1, 0, + -5, -4, -2, -1, -1, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_GlobalRateQPAdjTabB_U8_Xe2_Lpm[64] = +{ + 1, 1, 2, 4, 5, + 1, 1, 1, 2, 4, + 0, 0, 1, 1, 2, + -1, 0, 0, 1, 1, + -1, 0, 0, 0, 0, + -1, -1, -1, 0, 1, + -2, -1, -1, -1, 0, + -3, -2, -1, -1, 0, + -5, -4, -2, -1, -1, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, + 0, 0, 0, 0, +}; + +const uint8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_DistThreshldI_U8_Xe2_Lpm[10] = {4, 30, 60, 80, 120, 140, 200, 255, 0, 0}; +const uint8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_DistThreshldP_U8_Xe2_Lpm[10] = {4, 30, 60, 80, 120, 140, 200, 255, 0, 0}; +const uint8_t AvcVdencBrcConstSettingsXe2_Lpm::m_BRC_UPD_DistThreshldB_U8_Xe2_Lpm[10] = {2, 20, 40, 70, 130, 160, 200, 255, 0, 0}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_CBR_UPD_DistQPAdjTabI_U8_Xe2_Lpm[81] = +{ + 0, 0, 0, 0, 0, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 2, 3, 3, 4, + -1, 0, 0, 0, 0, 2, 2, 3, 3, + -1, -1, 0, 0, 0, 1, 2, 2, 2, + -1, -1, -1, 0, 0, 0, 1, 2, 2, + -2, -1, -1, 0, 0, 0, 1, 1, 2, + -2, -1, -1, -1, 0, 0, 1, 1, 2, + -2, -2, -1, -1, 0, 0, 0, 1, 1, + -2, -2, -1, -1, 0, 0, 0, 1, 1, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_CBR_UPD_DistQPAdjTabP_U8_Xe2_Lpm[81] = +{ + 0, 0, 0, 0, 0, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 2, 3, 3, 4, + -1, 0, 0, 0, 0, 2, 2, 3, 3, + -1, -1, 0, 0, 0, 1, 2, 2, 2, + -1, -1, -1, 0, 0, 0, 1, 2, 2, + -2, -1, -1, 0, 0, 0, 1, 1, 2, + -2, -1, -1, -1, 0, 0, 1, 1, 2, + -2, -2, -1, -1, 0, 0, 0, 1, 1, + -2, -2, -1, -1, 0, 0, 0, 1, 1, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_CBR_UPD_DistQPAdjTabB_U8_Xe2_Lpm[81] = +{ + 0, 0, 0, 0, 0, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 2, 3, 3, 4, + -1, 0, 0, 0, 0, 2, 2, 3, 3, + -1, -1, 0, 0, 0, 1, 2, 2, 2, + -1, -1, -1, 0, 0, 0, 1, 2, 2, + -2, -1, -1, 0, 0, 0, 1, 1, 2, + -2, -1, -1, -1, 0, 0, 1, 1, 2, + -2, -2, -1, -1, 0, 0, 0, 1, 1, + -2, -2, -1, -1, 0, 0, 0, 1, 1, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_VBR_UPD_DistQPAdjTabI_U8_Xe2_Lpm[81] = +{ + 0, 0, 0, 0, 0, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 2, 3, 3, 4, + -1, 0, 0, 0, 0, 2, 2, 3, 3, + -1, -1, 0, 0, 0, 1, 2, 2, 2, + -1, -1, -1, 0, 0, 0, 1, 2, 2, + -2, -1, -1, 0, 0, 0, 1, 1, 2, + -2, -1, -1, -1, 0, 0, 1, 1, 2, + -2, -2, -1, -1, 0, 0, 0, 1, 1, + -2, -2, -1, -1, 0, 0, 0, 1, 1, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_VBR_UPD_DistQPAdjTabP_U8_Xe2_Lpm[81] = +{ + 0, 0, 0, 0, 0, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 2, 3, 3, 4, + -1, 0, 0, 0, 0, 2, 2, 3, 3, + -1, -1, 0, 0, 0, 1, 2, 2, 2, + -1, -1, -1, 0, 0, 0, 1, 2, 2, + -2, -1, -1, 0, 0, 0, 1, 1, 2, + -2, -1, -1, -1, 0, 0, 1, 1, 2, + -2, -2, -1, -1, 0, 0, 0, 1, 1, + -2, -2, -1, -1, 0, 0, 0, 1, 1, +}; + +const int8_t AvcVdencBrcConstSettingsXe2_Lpm::m_VBR_UPD_DistQPAdjTabB_U8_Xe2_Lpm[81] = +{ + 0, 0, 0, 0, 0, 2, 3, 3, 4, + 0, 0, 0, 0, 0, 2, 3, 3, 4, + -1, 0, 0, 0, 0, 2, 2, 3, 3, + -1, -1, 0, 0, 0, 1, 2, 2, 2, + -1, -1, -1, 0, 0, 0, 1, 2, 2, + -2, -1, -1, 0, 0, 0, 1, 1, 2, + -2, -1, -1, -1, 0, 0, 1, 1, 2, + -2, -2, -1, -1, 0, 0, 0, 1, 1, + -2, -2, -1, -1, 0, 0, 0, 1, 1, +}; + + +MOS_STATUS EncodeAvcVdencConstSettingsXe2_Lpm::SetVdencAvcImgStateSettings() +{ + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(m_featureSetting); + + auto setting = static_cast(m_featureSetting); + ENCODE_CHK_NULL_RETURN(setting); + +#if _MEDIA_RESERVED +#define VDENC_AVC_IMGSTATE_SETTINGS_EXT +#include "encode_avc_vdenc_const_settings_xe2_lpm_ext.h" +#undef VDENC_AVC_IMGSTATE_SETTINGS_EXT +#else +#define VDENC_AVCIMGSTATE_SETTINGS_OPEN +#include "encode_avc_vdenc_const_settings_xe2_lpm_open.h" +#undef VDENC_AVCIMGSTATE_SETTINGS_OPEN +#endif // !(_MEDIA_RESERVED) + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeAvcVdencConstSettingsXe2_Lpm::SetBrcSettings() +{ + ENCODE_FUNC_CALL(); + EncodeAvcVdencConstSettings::SetBrcSettings(); + + ENCODE_CHK_NULL_RETURN(m_featureSetting); + + auto setting = static_cast(m_featureSetting); + ENCODE_CHK_NULL_RETURN(setting); + + setting->brcSettings.BRC_UPD_global_rate_ratio_threshold = (uint8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_global_rate_ratio_threshold_Xe2_Lpm; + setting->brcSettings.BRC_UPD_slwin_global_rate_ratio_threshold = (uint8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_slwin_global_rate_ratio_threshold_Xe2_Lpm; + setting->brcSettings.BRC_UPD_global_rate_ratio_threshold_qp = (int8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_global_rate_ratio_threshold_qp_Xe2_Lpm; + + setting->brcSettings.BRC_UPD_GlobalRateQPAdjTabI_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_GlobalRateQPAdjTabI_U8_Xe2_Lpm; + setting->brcSettings.BRC_UPD_GlobalRateQPAdjTabP_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_GlobalRateQPAdjTabP_U8_Xe2_Lpm; + setting->brcSettings.BRC_UPD_SlWinGlobalRateQPAdjTabP_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_SlWinGlobalRateQPAdjTabP_U8_Xe2_Lpm; + setting->brcSettings.BRC_UPD_GlobalRateQPAdjTabB_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_GlobalRateQPAdjTabB_U8_Xe2_Lpm; + + setting->brcSettings.BRC_UPD_DistThreshldI_U8 = (uint8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_DistThreshldI_U8_Xe2_Lpm; + setting->brcSettings.BRC_UPD_DistThreshldP_U8 = (uint8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_DistThreshldP_U8_Xe2_Lpm; + setting->brcSettings.BRC_UPD_DistThreshldB_U8 = (uint8_t *)m_brcSettings_Xe2_Lpm.m_BRC_UPD_DistThreshldB_U8_Xe2_Lpm; + + setting->brcSettings.CBR_UPD_DistQPAdjTabI_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_CBR_UPD_DistQPAdjTabI_U8_Xe2_Lpm; + setting->brcSettings.CBR_UPD_DistQPAdjTabP_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_CBR_UPD_DistQPAdjTabP_U8_Xe2_Lpm; + setting->brcSettings.CBR_UPD_DistQPAdjTabB_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_CBR_UPD_DistQPAdjTabB_U8_Xe2_Lpm; + setting->brcSettings.VBR_UPD_DistQPAdjTabI_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_VBR_UPD_DistQPAdjTabI_U8_Xe2_Lpm; + setting->brcSettings.VBR_UPD_DistQPAdjTabP_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_VBR_UPD_DistQPAdjTabP_U8_Xe2_Lpm; + setting->brcSettings.VBR_UPD_DistQPAdjTabB_U8 = (int8_t *)m_brcSettings_Xe2_Lpm.m_VBR_UPD_DistQPAdjTabB_U8_Xe2_Lpm; + + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm.h new file mode 100644 index 0000000000..b79d86109a --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm.h @@ -0,0 +1,74 @@ +/* +* Copyright (c) 2021, 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. +*/ + +//! +//! \file encode_avc_vdenc_const_settings_xe2_lpm.h +//! \brief Defines the common interface for Xe2_LPM avc vdenc const settings +//! + +#ifndef __ENCODE_AVC_VDENC_CONST_SETTINGS_XE2_LPM_H__ +#define __ENCODE_AVC_VDENC_CONST_SETTINGS_XE2_LPM_H__ + +#include "encode_avc_vdenc_const_settings.h" + +namespace encode +{ +struct AvcVdencBrcConstSettingsXe2_Lpm +{ + static const uint8_t m_BRC_UPD_global_rate_ratio_threshold_Xe2_Lpm[7]; //!< Global Rate Ratio Threshold + static const uint8_t m_BRC_UPD_slwin_global_rate_ratio_threshold_Xe2_Lpm[7]; //!< Slide Window Global Rate Ratio Threshold + static const int8_t m_BRC_UPD_global_rate_ratio_threshold_qp_Xe2_Lpm[8]; //!< Global Rate Ratio QP Threshold + + static const int8_t m_BRC_UPD_GlobalRateQPAdjTabI_U8_Xe2_Lpm[64]; //!< I Picture Global Rate QP Adjustment Table. + static const int8_t m_BRC_UPD_GlobalRateQPAdjTabP_U8_Xe2_Lpm[64]; //!< P Picture Global Rate QP Adjustment Table. + static const int8_t m_BRC_UPD_SlWinGlobalRateQPAdjTabP_U8_Xe2_Lpm[64]; //!< P picture Global Rate QP Adjustment Table for Sliding Window BRC + static const int8_t m_BRC_UPD_GlobalRateQPAdjTabB_U8_Xe2_Lpm[64]; //!< B Picture Global Rate QP Adjustment Table. + + static const uint8_t m_BRC_UPD_DistThreshldI_U8_Xe2_Lpm[10]; //!< I Picture Distortion THreshold. + static const uint8_t m_BRC_UPD_DistThreshldP_U8_Xe2_Lpm[10]; //!< P Picture Distortion THreshold. + static const uint8_t m_BRC_UPD_DistThreshldB_U8_Xe2_Lpm[10]; //!< P Picture Distortion THreshold. + + static const int8_t m_CBR_UPD_DistQPAdjTabI_U8_Xe2_Lpm[81]; //!< I Picture Distortion QP Adjustment Table under CBR Mode. + static const int8_t m_CBR_UPD_DistQPAdjTabP_U8_Xe2_Lpm[81]; //!< P Picture Distortion QP Adjustment Table under CBR Mode. + static const int8_t m_CBR_UPD_DistQPAdjTabB_U8_Xe2_Lpm[81]; //!< B Picture Distortion QP Adjustment Table under CBR Mode. + static const int8_t m_VBR_UPD_DistQPAdjTabI_U8_Xe2_Lpm[81]; //!< I Picture Distortion QP Adjustment Table under VBR Mode. + static const int8_t m_VBR_UPD_DistQPAdjTabP_U8_Xe2_Lpm[81]; //!< P Picture Distortion QP Adjustment Table under VBR Mode. + static const int8_t m_VBR_UPD_DistQPAdjTabB_U8_Xe2_Lpm[81]; //!< B Picture Distortion QP Adjustment Table under VBR Mode. + +}; +class EncodeAvcVdencConstSettingsXe2_Lpm : public EncodeAvcVdencConstSettings +{ +public: + EncodeAvcVdencConstSettingsXe2_Lpm() = default; + EncodeAvcVdencConstSettingsXe2_Lpm(PMOS_INTERFACE osInterface) : + EncodeAvcVdencConstSettings (osInterface) {} + virtual ~EncodeAvcVdencConstSettingsXe2_Lpm() {} + +protected: + MOS_STATUS SetVdencAvcImgStateSettings() override; + virtual MOS_STATUS SetBrcSettings() override; + + AvcVdencBrcConstSettingsXe2_Lpm m_brcSettings_Xe2_Lpm; +MEDIA_CLASS_DEFINE_END(encode__EncodeAvcVdencConstSettingsXe2_Lpm) +}; +} // namespace encode +#endif // !__ENCODE_AVC_VDENC_CONST_SETTINGS_XE2_LPM_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm_open.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm_open.h new file mode 100644 index 0000000000..a6ea705c78 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_const_settings_xe2_lpm_open.h @@ -0,0 +1,110 @@ +/* +* Copyright (c) 2024, 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. +*/ + +//! +//! \file encode_avc_vdenc_const_settings_xe2_hpm_open.h +//! \brief Defines the opensource avc const settings +//! \details The encode feature manager is further sub-divided by platform type +//! this file is for the base interface which is shared by all components. +//! + +#ifdef VDENC_AVCIMGSTATE_SETTINGS_OPEN + +setting->vdencAvcImgStateSettings.emplace_back( + VDENC_AVC_IMG_STATE_LAMBDA() + { + par.extSettings.emplace_back( + [this, &par](uint32_t *data) { + auto waTable = m_osItf->pfnGetWaTable(m_osItf); + ENCODE_CHK_NULL_RETURN(waTable); + + uint32_t CodingTypeMinus1 = m_avcPicParams->CodingType - 1; + uint32_t tu = m_avcSeqParams->TargetUsage; + uint32_t EnableRollingIntraRefresh = m_avcPicParams->EnableRollingIntraRefresh; + uint32_t Level = m_avcSeqParams->Level; + uint32_t RefPicFlag = m_avcPicParams->RefPicFlag; + uint32_t Wa_18011246551 = MEDIA_IS_WA(waTable, Wa_18011246551); + uint32_t LowDelayMode = m_avcSeqParams->LowDelayMode; + uint32_t EnableSliceLevelRateCtrl = m_avcSeqParams->EnableSliceLevelRateCtrl; + + static const uint32_t dw1Lut = 0x301; + data[1] |= dw1Lut; + + static const uint32_t dw2Lut[3][8][2][2] = { { { { 0x70028000, 0x70028000,}, { 0x70028000, 0x70028000,},}, { { 0xc0029400, 0xc0029400,}, { 0xc0029400, 0xc0029400,},}, { { 0x70029400, 0x70029400,}, { 0x70029400, 0x70029400,},}, { { 0x40028240, 0x40028240,}, { 0x40028240, 0x40028240,},}, { { 0x40028240, 0x40028240,}, { 0x40028240, 0x40028240,},}, { { 0x40028240, 0x40028240,}, { 0x40028240, 0x40028240,},}, { { 0x400281e0, 0x40028160,}, { 0x400281e0, 0x40028160,},}, { { 0x400281e0, 0x40028160,}, { 0x400281e0, 0x40028160,},},}, { { { 0x70028000, 0x70028000,}, { 0x70028000, 0x70028000,},}, { { 0xc0029407, 0xc0029407,}, { 0xc0029407, 0xc0029407,},}, { { 0x70029407, 0x70029407,}, { 0x70029407, 0x70029407,},}, { { 0x40028247, 0x40028247,}, { 0x40028247, 0x40028247,},}, { { 0x40028247, 0x40028247,}, { 0x40028247, 0x40028247,},}, { { 0x40028247, 0x40028247,}, { 0x40028247, 0x40028247,},}, { { 0x400281e4, 0x40028164,}, { 0x400281e4, 0x40028164,},}, { { 0x400281e4, 0x40028164,}, { 0x400281e4, 0x40028164,},},}, { { { 0x70028000, 0x70028000,}, { 0x70028000, 0x70028000,},}, { { 0xc0029407, 0xc0029407,}, { 0xc0029407, 0xc0029407,},}, { { 0x70029407, 0x70029407,}, { 0x72029207, 0x72029207,},}, { { 0x40028244, 0x40028244,}, { 0x40028244, 0x40028244,},}, { { 0x40028243, 0x40028243,}, { 0x40028243, 0x40028243,},}, { { 0x40028243, 0x40028243,}, { 0x40028243, 0x40028243,},}, { { 0x400281e2, 0x40028162,}, { 0x400281e2, 0x40028162,},}, { { 0x400281e2, 0x40028162,}, { 0x400281e2, 0x40028162,},},},}; + data[2] |= dw2Lut[CodingTypeMinus1][tu][RefPicFlag][EnableSliceLevelRateCtrl]; + + static const uint32_t dw4Lut[3][8][4][2] = { { { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0x800, 0x800,}, { 0x800, 0x800,}, { 0x800, 0x800,}, { 0x800, 0x800,},}, { { 0x800, 0x800,}, { 0x800, 0x800,}, { 0x800, 0x800,}, { 0x800, 0x800,},},}, { { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0x800, 0x800,}, { 0x800, 0xbd0888,}, { 0x800, 0x800,}, { 0x800, 0x800,},}, { { 0x800, 0x800,}, { 0x800, 0xbd0888,}, { 0x800, 0x800,}, { 0x800, 0x800,},},}, { { { 0, 0,}, { 0, 0,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0, 0,}, { 0, 0xbd0088,}, { 0, 0,}, { 0, 0,},}, { { 0x800, 0x800,}, { 0x800, 0xbd0888,}, { 0x800, 0x800,}, { 0x800, 0x800,},}, { { 0x800, 0x800,}, { 0x800, 0xbd0888,}, { 0x800, 0x800,}, { 0x800, 0x800,},},},}; + data[4] |= dw4Lut[CodingTypeMinus1][tu][EnableRollingIntraRefresh][Wa_18011246551]; + + static const uint32_t dw5Lut[3][8] = { { 0, 0, 0, 0, 0, 0, 0, 0,}, { 0, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000,}, { 0, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000, 0x80000000,},}; + data[5] |= dw5Lut[CodingTypeMinus1][tu]; + + static const uint32_t dw7Lut = 0xffff0000; + data[7] |= dw7Lut; + + static const uint32_t dw8Lut[53] = { 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x1002000, 0x1002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x4002000, 0x4002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x4002000, 0x8002000, 0x8002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x8002000, 0x8002000, 0x8002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x2002000, 0x8002000, 0x8002000, 0x8002000,}; + data[8] |= dw8Lut[Level]; + + static const uint32_t dw10Lut[3] = { 0x3e80000, 0x3200000, 0x2580000,}; + data[10] |= dw10Lut[CodingTypeMinus1]; + + static const uint32_t dw11Lut[3] = { 0xbb807d0, 0x9600640, 0x70804b0,}; + data[11] |= dw11Lut[CodingTypeMinus1]; + + static const uint32_t dw12Lut[3][8] = { { 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000,}, { 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xfff0000, 0xfff0000,}, { 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xf000000, 0xfff0000, 0xfff0000,},}; + data[12] |= dw12Lut[CodingTypeMinus1][tu]; + + static const uint32_t dw13Lut[3][8][2] = { { { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,}, { 0x7d00000, 0x7d00000,},}, { { 0x6400000, 0x6400000,}, { 0x6400000, 0x64000c0,}, { 0x6400000, 0x6400000,}, { 0x6400000, 0x6400000,}, { 0x6400000, 0x6400000,}, { 0x6400000, 0x6400000,}, { 0x6400000, 0x6400000,}, { 0x6400000, 0x6400000,},}, { { 0x4b00000, 0x4b00000,}, { 0x4b000c0, 0x4b000c0,}, { 0x4b00000, 0x4b00000,}, { 0x4b00000, 0x4b00000,}, { 0x4b00000, 0x4b00000,}, { 0x4b00000, 0x4b00000,}, { 0x4b00000, 0x4b00000,}, { 0x4b00000, 0x4b00000,},},}; + data[13] |= dw13Lut[CodingTypeMinus1][tu][LowDelayMode]; + + static const uint32_t dw14Lut[3][8] = { { 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000,}, { 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xffe00000, 0xffe00000,}, { 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xff200000, 0xffe00000, 0xffe00000,},}; + data[14] |= dw14Lut[CodingTypeMinus1][tu]; + + static const uint32_t dw15Lut = 0xbb80002; + data[15] |= dw15Lut; + + static const uint32_t dw16Lut = 0xe100004; + data[16] |= dw16Lut; + + static const uint32_t dw17Lut = 0x13880006; + data[17] |= dw17Lut; + + static const uint32_t dw18Lut = 0x1f40000a; + data[18] |= dw18Lut; + + static const uint32_t dw19Lut = 0x23280012; + data[19] |= dw19Lut; + + static const uint32_t dw22Lut = 0x33000000; + data[22] |= dw22Lut; + + static const uint32_t dw25Lut[8] = { 0x6000c0, 0x6000c0, 0, 0x6000c0, 0x6000c0, 0x6000c0, 0x6000c0, 0x6000c0,}; + data[25] |= dw25Lut[tu]; + + return MOS_STATUS_SUCCESS; + + }); + + return MOS_STATUS_SUCCESS; + }); + +#endif // VDENC_AVCIMGSTATE_SETTINGS_OPEN \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_feature_manager_xe2_lpm.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_feature_manager_xe2_lpm.cpp new file mode 100644 index 0000000000..2e3d0d606c --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_feature_manager_xe2_lpm.cpp @@ -0,0 +1,136 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_avc_vdenc_feature_manager_xe2_lpm.cpp +//! \brief Defines the common interface for avc Xe2_LPM vdenc feature manager +//! + +#include "encode_avc_vdenc_feature_manager_xe2_lpm.h" +#include "encode_avc_basic_feature_xe2_lpm.h" +#include "encode_avc_vdenc_const_settings_xe2_lpm.h" +#include "encode_avc_vdenc_stream_in_feature.h" +#include "encode_avc_vdenc_cqp_roi_feature.h" +#include "encode_avc_vdenc_brc_roi_feature.h" +#include "encode_avc_vdenc_weighted_prediction.h" +#include "encode_avc_brc.h" +#include "encode_avc_trellis.h" +#include "encode_avc_rounding.h" +#include "media_avc_feature_defs.h" +#include "encode_avc_vdenc_fullenc.h" +#include "encode_avc_aqm.h" +#include "encode_avc_vdenc_preenc.h" +#include "encode_avc_vdenc_pipeline.h" + +namespace encode +{ + +MOS_STATUS EncodeAvcVdencFeatureManagerXe2_Lpm::CreateConstSettings() +{ + ENCODE_FUNC_CALL(); + m_featureConstSettings = MOS_New(EncodeAvcVdencConstSettingsXe2_Lpm, m_hwInterface->GetOsInterface()); + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeAvcVdencFeatureManagerXe2_Lpm::CreateFeatures(void *constSettings) +{ + ENCODE_FUNC_CALL(); + + auto setting = static_cast(m_featureConstSettings); + ENCODE_CHK_NULL_RETURN(setting); + setting->SetOsInterface(m_hwInterface->GetOsInterface()); + + EncodeBasicFeature *encBasic = MOS_New(AvcBasicFeatureXe2_Lpm, m_allocator, m_hwInterface, m_trackedBuf, m_recycleResource, m_mediaCopyWrapper, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::basicFeature, encBasic, {AvcVdencPipeline::encodePreEncPacket})); + + AvcVdencStreamInFeature *streamInFeature = MOS_New(AvcVdencStreamInFeature, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcVdencStreamInFeature, streamInFeature, {AvcVdencPipeline::encodePreEncPacket})); + + AvcEncodeTrellis *encTrellis = MOS_New(AvcEncodeTrellis, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcTrellisFeature, encTrellis, {AvcVdencPipeline::encodePreEncPacket})); + + AvcEncodeRounding *rounding = MOS_New(AvcEncodeRounding, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcRoundingFeature, rounding, {AvcVdencPipeline::encodePreEncPacket})); + + AvcEncodeBRC *brc = MOS_New(AvcEncodeBRC, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcBrcFeature, brc, {AvcVdencPipeline::encodePreEncPacket})); + + AvcVdencRoiInterface::SupportedModes supportedRoiModes; + supportedRoiModes.DirtyROI = 1; + supportedRoiModes.ROI_Native = 1; + supportedRoiModes.ROI_NonNative = 1; + supportedRoiModes.MBQP_ForceQP = 1; + supportedRoiModes.MBQP_DeltaQP = 1; + AvcVdencCqpRoiFeature *cqpRoiFeature = MOS_New(AvcVdencCqpRoiFeature, this, m_allocator, m_hwInterface, constSettings, supportedRoiModes); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcCqpRoiFeature, cqpRoiFeature, {AvcVdencPipeline::encodePreEncPacket})); + + MOS_ZeroMemory(&supportedRoiModes, sizeof(supportedRoiModes)); + supportedRoiModes.DirtyROI = 1; + supportedRoiModes.ROI_Native = 1; + supportedRoiModes.ROI_NonNative = 1; + supportedRoiModes.ArbROI = 1; + AvcVdencBrcRoiFeature *brcRoiFeature = MOS_New(AvcVdencBrcRoiFeature, this, m_allocator, m_hwInterface, constSettings, supportedRoiModes); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcBrcRoiFeature, brcRoiFeature, {AvcVdencPipeline::encodePreEncPacket})); + + AvcVdencWeightedPred *avcWeightedPred = MOS_New(AvcVdencWeightedPred, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcVdencWpFeature, avcWeightedPred, {AvcVdencPipeline::encodePreEncPacket})); + + //for pre-enc + AvcVdencPreEnc *avcPreenc = MOS_New(AvcVdencPreEnc, this, m_allocator, m_hwInterface, m_trackedBuf, m_recycleResource, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(FeatureIDs::preEncFeature, avcPreenc, {AvcVdencPipeline::encodePreEncPacket}, LIST_TYPE::ALLOW_LIST)); // only encodePreEncPacket + AvcVdencFullEnc *avcFullEnc = MOS_New(AvcVdencFullEnc, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcVdencFullEncFeature, avcFullEnc, {AvcVdencPipeline::encodePreEncPacket})); + + AvcEncodeAqm *encAqm = MOS_New(AvcEncodeAqm, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(AvcFeatureIDs::avcAqm, encAqm, {AvcVdencPipeline::encodePreEncPacket})); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeAvcVdencFeatureManagerXe2_Lpm::MapTargetUsage(uint8_t &targetUsage) +{ + ENCODE_FUNC_CALL(); + + switch (targetUsage) + { + case 1: + targetUsage = 1; + break; + case 2: + targetUsage = 2; + break; + case 3: + case 4: + case 5: + targetUsage = 4; + break; + case 6: + case 7: + targetUsage = 7; + break; + default: + targetUsage = 4; + break; + } + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_feature_manager_xe2_lpm.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_feature_manager_xe2_lpm.h new file mode 100644 index 0000000000..556bde83ac --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/encode_avc_vdenc_feature_manager_xe2_lpm.h @@ -0,0 +1,77 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_avc_vdenc_feature_manager_xe2_lpm.h +//! \brief Defines the common interface for avc Xe2_LPM_base vdenc feature manager +//! +#ifndef __ENCODE_AVC_VDENC_FEATURE_MANAGER_XE2_LPM_H__ +#define __ENCODE_AVC_VDENC_FEATURE_MANAGER_XE2_LPM_H__ + +#include "encode_avc_vdenc_feature_manager.h" + +namespace encode +{ + +class EncodeAvcVdencFeatureManagerXe2_Lpm : public EncodeAvcVdencFeatureManager +{ +public: + + EncodeAvcVdencFeatureManagerXe2_Lpm( + EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + TrackedBuffer *trackedBuf, + RecycleResource *recycleBuf, + MediaCopyWrapper *mediaCopyWrapper) : + EncodeAvcVdencFeatureManager(allocator, hwInterface, trackedBuf, recycleBuf, mediaCopyWrapper) {} + + virtual ~EncodeAvcVdencFeatureManagerXe2_Lpm() {} + +protected: + + //! + //! \brief Create feature const settings + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + virtual MOS_STATUS CreateConstSettings() override; + + //! + //! \brief Create features + //! \param [in] constsettings + //! feature const settings + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + virtual MOS_STATUS CreateFeatures(void *constSettings) override; + + //! + //! \brief Map target usage + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS MapTargetUsage(uint8_t &targetUsage) override; + +MEDIA_CLASS_DEFINE_END(encode__EncodeAvcVdencFeatureManagerXe2_Lpm) +}; + +} +#endif // !__ENCODE_AVC_VDENC_FEATURE_MANAGER_XE2_LPM_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/media_srcs.cmake new file mode 100644 index 0000000000..7e0f462762 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/features/media_srcs.cmake @@ -0,0 +1,55 @@ +# Copyright (c) 2021-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. + +if ("${AVC_Encode_VDEnc_Supported}" STREQUAL "yes") +set(TMP_SOURCES_ + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_basic_feature_xe2_lpm.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_feature_manager_xe2_lpm.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_const_settings_xe2_lpm.cpp +) + +set(TMP_HEADERS_ + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_basic_feature_xe2_lpm.h + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_feature_manager_xe2_lpm.h + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_const_settings_xe2_lpm.h + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_const_settings_xe2_lpm_open.h +) + +set(SOFTLET_ENCODE_AVC_HEADERS_ + ${SOFTLET_ENCODE_AVC_HEADERS_} + ${TMP_HEADERS_} +) + +set(SOFTLET_ENCODE_AVC_SOURCES_ + ${SOFTLET_ENCODE_AVC_SOURCES_} + ${TMP_SOURCES_} +) + +source_group( CodecHalNext\\Xe2_LPM\\Encode FILES ${TMP_SOURCES_} ${TMP_HEADERS_} ) + +set(TMP_SOURCES_ "") +set(TMP_HEADERS_ "") + +endif() + +set(SOFTLET_ENCODE_AVC_PRIVATE_INCLUDE_DIRS_ + ${SOFTLET_ENCODE_AVC_PRIVATE_INCLUDE_DIRS_} + ${CMAKE_CURRENT_LIST_DIR} +) \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/media_srcs.cmake new file mode 100644 index 0000000000..5666539caa --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/media_srcs.cmake @@ -0,0 +1,23 @@ +# Copyright (c) 2021, 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. + +media_include_subdirectory(features) +media_include_subdirectory(packet) +media_include_subdirectory(pipeline) diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/encode_avc_vdenc_packet_xe2_lpm.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/encode_avc_vdenc_packet_xe2_lpm.cpp new file mode 100644 index 0000000000..d8fb43a1d1 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/encode_avc_vdenc_packet_xe2_lpm.cpp @@ -0,0 +1,178 @@ +/* +* Copyright (c) 2021-2024, 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. +*/ +//! +//! \file encode_avc_vdenc_packet_xe2_lpm.cpp +//! \brief Defines the interface for avc encode vdenc packet of Xe2_LPM +//! + +#include "encode_avc_vdenc_packet_xe2_lpm.h" +#include "encode_avc_brc.h" +#include "encode_avc_vdenc_const_settings.h" +#include "encode_avc_aqm.h" + +#include "media_avc_feature_defs.h" +#include "mhw_vdbox_xe2_lpm_base.h" +#include "mhw_vdbox_vdenc_hwcmd_xe2_lpm.h" +#include "mhw_vdbox_mfx_impl_xe2_lpm.h" + +using namespace mhw::vdbox::xe2_lpm_base; + +namespace encode +{ + + MOS_STATUS AvcVdencPktXe2_Lpm::Completed(void *mfxStatus, void *rcsStatus, void *statusReport) + { + ENCODE_FUNC_CALL(); + auto eStatus = MOS_STATUS_SUCCESS; + eStatus = AvcVdencPkt::Completed(mfxStatus, rcsStatus, statusReport); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(AvcFeatureIDs::avcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + EncodeStatusReportData *statusReportData = (EncodeStatusReportData *)statusReport; + uint32_t statBufIdx = statusReportData->currOriginalPic.FrameIdx; + if (m_basicFeature->m_picParam->QualityInfoSupportFlags.fields.enable_frame) + { + ENCODE_CHK_STATUS_RETURN(aqmFeature->ReportQualityInfoFrame(statBufIdx, *statusReportData)); + } +#if _MEDIA_RESERVED +#if USE_CODECHAL_DEBUG_TOOL + ENCODE_CHK_STATUS_RETURN(aqmFeature->DumpVdaqmOutput(statBufIdx, *statusReportData)); + + CodechalDebugInterface *debugInterface = m_pipeline->GetStatusReportDebugInterface(); + ENCODE_CHK_NULL_RETURN(debugInterface); + + if (debugInterface->DumpIsEnabled(CodechalDbgAttr::attrQualityReport)) + { + std::ostringstream oss; + oss.setf(std::ios::showbase | std::ios::uppercase); + + aqmFeature->DumpVdaqmFrameStatVerbose(statBufIdx, oss); + + // Dump per frame VDAQM frame statistic file + const char *fileName = debugInterface->CreateFileName("EncodeFrame", "VDAQMFrameStat", CodechalDbgExtType::txt); + + std::ofstream ofs(fileName, std::ios::out); + ofs << oss.str(); + ofs.close(); + } +#endif +#endif + } + + return eStatus; + } + + MOS_STATUS AvcVdencPktXe2_Lpm::AddPictureVdencCommands(MOS_COMMAND_BUFFER &cmdBuffer) + { + ENCODE_FUNC_CALL(); + + AvcVdencPkt::AddPictureVdencCommands(cmdBuffer); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(AvcFeatureIDs::avcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + SETPAR_AND_ADDCMD(AQM_VD_CONTROL_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_PIPE_BUF_ADDR_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_PIC_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_FRAME_START, m_aqmItf, &cmdBuffer); + } + + return MOS_STATUS_SUCCESS; + } + + MOS_STATUS AvcVdencPktXe2_Lpm::SendSlice(PMOS_COMMAND_BUFFER cmdBuffer) + { + ENCODE_FUNC_CALL(); + + AvcVdencPkt::SendSlice(cmdBuffer); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(AvcFeatureIDs::avcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + SETPAR_AND_ADDCMD(AQM_SLICE_STATE, m_aqmItf, cmdBuffer); + } + + return MOS_STATUS_SUCCESS; + } + + MHW_SETPAR_DECL_SRC(VD_PIPELINE_FLUSH, AvcVdencPktXe2_Lpm) + { + AvcVdencPkt::MHW_SETPAR_F(VD_PIPELINE_FLUSH)(params); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(AvcFeatureIDs::avcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + params.waitDoneVDAQM = m_lastSlice ? true : false; + } + + return MOS_STATUS_SUCCESS; + } + + MOS_STATUS AvcVdencPktXe2_Lpm::EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER &cmdBuffer) + { + ENCODE_FUNC_CALL(); + + // Send MI_FLUSH command + auto &flushDwParams = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)(); + flushDwParams = {}; + flushDwParams.bVideoPipelineCacheInvalidate = true; + + auto *skuTable = m_hwInterface->GetSkuTable(); + if (skuTable && MEDIA_IS_SKU(skuTable, FtrEnablePPCFlush)) + { + // Add PPC fulsh + flushDwParams.bEnablePPCFlush = true; + } + + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(&cmdBuffer)); + + return MOS_STATUS_SUCCESS; + } + + MOS_STATUS AvcVdencPktXe2_Lpm::EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER *cmdBuffer) + { + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(cmdBuffer); + ENCODE_CHK_STATUS_RETURN(AvcVdencPkt::EndStatusReport(srType, cmdBuffer)); + + MediaPerfProfiler *perfProfiler = MediaPerfProfiler::Instance(); + ENCODE_CHK_NULL_RETURN(perfProfiler); + + //store bitstream size to UMD profiler + ENCODE_CHK_STATUS_RETURN(ValidateVdboxIdx(m_vdboxIndex)); + MmioRegistersMfx *mmioRegisters = SelectVdboxAndGetMmioRegister(m_vdboxIndex, cmdBuffer); + CODEC_HW_CHK_NULL_RETURN(mmioRegisters); + ENCODE_CHK_STATUS_RETURN(perfProfiler->AddStoreBitstreamSizeCmd( + (void *)m_pipeline, m_osInterface, m_miItf, cmdBuffer, mmioRegisters->mfcBitstreamBytecountFrameRegOffset)); +#if _MEDIA_RESERVED + //store quality metric to UMD profiler + RUN_FEATURE_INTERFACE_RETURN(AvcEncodeAqm, AvcFeatureIDs::avcAqm, AddStoreQualityMetricCmd, (void *)m_pipeline, m_osInterface, m_miItf, cmdBuffer); +#endif + return MOS_STATUS_SUCCESS; + } +} + diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/encode_avc_vdenc_packet_xe2_lpm.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/encode_avc_vdenc_packet_xe2_lpm.h new file mode 100644 index 0000000000..a25b2fbaa0 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/encode_avc_vdenc_packet_xe2_lpm.h @@ -0,0 +1,64 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_avc_vdenc_packet_xe2_lpm.h +//! \brief Defines the interface to adapt to avc vdenc encode pipeline Xe2_LPM +//! + +#ifndef __CODECHAL_AVC_VDENC_PACKET_XE2_LPM_H__ +#define __CODECHAL_AVC_VDENC_PACKET_XE2_LPM_H__ + +#include "encode_avc_vdenc_packet.h" +#include "mhw_vdbox_aqm_impl_xe2_lpm.h" +#include "mhw_vdbox_aqm_itf.h" + +namespace encode +{ + class AvcVdencPktXe2_Lpm : public AvcVdencPkt, public mhw::vdbox::aqm::Itf::ParSetting + { + protected: + std::shared_ptr m_aqmItf = nullptr; + + public: + AvcVdencPktXe2_Lpm(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) : + AvcVdencPkt(pipeline, task, hwInterface) + { + m_aqmItf = std::make_shared(m_osInterface); + }; + + virtual ~AvcVdencPktXe2_Lpm() {} + virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override; + + protected: + virtual MOS_STATUS AddPictureVdencCommands(MOS_COMMAND_BUFFER &cmdBuffer); + virtual MOS_STATUS SendSlice(PMOS_COMMAND_BUFFER cmdBuffer); + virtual MOS_STATUS EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER *cmdBuffer) override; + + MHW_SETPAR_DECL_HDR(VD_PIPELINE_FLUSH); + + MEDIA_CLASS_DEFINE_END(encode__AvcVdencPktXe2_Lpm) + }; + +} // namespace encode + +#endif // !__CODECHAL_AVC_VDENC_PACKET_XE2_LPM_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/media_srcs.cmake new file mode 100644 index 0000000000..982f38bda6 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/packet/media_srcs.cmake @@ -0,0 +1,50 @@ +# Copyright (c) 2021-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. + +if ("${AVC_Encode_VDEnc_Supported}" STREQUAL "yes") +set(TMP_SOURCES_ + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_packet_xe2_lpm.cpp +) + +set(TMP_HEADERS_ + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_packet_xe2_lpm.h +) + +set(SOFTLET_ENCODE_AVC_HEADERS_ + ${SOFTLET_ENCODE_AVC_HEADERS_} + ${TMP_HEADERS_} +) + +set(SOFTLET_ENCODE_AVC_SOURCES_ + ${SOFTLET_ENCODE_AVC_SOURCES_} + ${TMP_SOURCES_} +) + +source_group( CodecHalNext\\Xe2_LPM\\Encode FILES ${TMP_SOURCES_} ${TMP_HEADERS_} ) + +set(TMP_SOURCES_ "") +set(TMP_HEADERS_ "") + +endif() + +set(SOFTLET_ENCODE_AVC_PRIVATE_INCLUDE_DIRS_ + ${SOFTLET_ENCODE_AVC_PRIVATE_INCLUDE_DIRS_} + ${CMAKE_CURRENT_LIST_DIR} +) \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_adapter_xe2_lpm.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_adapter_xe2_lpm.cpp new file mode 100644 index 0000000000..8f0173291a --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_adapter_xe2_lpm.cpp @@ -0,0 +1,45 @@ +/* +* Copyright (c) 2021-2024, 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. +*/ +//! +//! \file encode_avc_vdenc_pipeline_adapter_xe2_lpm.cpp +//! \brief Defines the interface to adapt to avc vdenc encode pipeline Xe2_LPM +//! + +#include "encode_avc_vdenc_pipeline_adapter_xe2_lpm.h" +#include "encode_avc_vdenc_pipeline_xe2_lpm.h" + +MOS_STATUS EncodeAvcVdencPipelineAdapterXe2_Lpm::Allocate(CodechalSetting *codecHalSettings) +{ + ENCODE_FUNC_CALL(); + + m_encoder = std::make_shared(m_hwInterface, m_debugInterface); + ENCODE_CHK_NULL_RETURN(m_encoder); + + return m_encoder->Init(codecHalSettings); +} + +MOS_STATUS EncodeAvcVdencPipelineAdapterXe2_Lpm::ResolveMetaData(PMOS_RESOURCE pInput, PMOS_RESOURCE pOutput) +{ + ENCODE_FUNC_CALL(); + + return m_encoder->ExecuteResolveMetaData(pInput, pOutput); +} \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_adapter_xe2_lpm.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_adapter_xe2_lpm.h new file mode 100644 index 0000000000..9ae80798af --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_adapter_xe2_lpm.h @@ -0,0 +1,49 @@ +/* +* Copyright (c) 2021-2024, 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. +*/ +//! +//! \file encode_avc_vdenc_pipeline_adapter_xe2_lpm.h +//! \brief Defines the interface to adapt to avc vdenc encode pipeline Xe2_LPM +//! + +#ifndef __ENCODE_AVC_VDENC_PIPELINE_ADAPTER_XE2_LPM_H__ +#define __ENCODE_AVC_VDENC_PIPELINE_ADAPTER_XE2_LPM_H__ + +#include "encode_avc_vdenc_pipeline_adapter.h" + +class EncodeAvcVdencPipelineAdapterXe2_Lpm : public EncodeAvcVdencPipelineAdapter +{ +public: + EncodeAvcVdencPipelineAdapterXe2_Lpm( + CodechalHwInterfaceNext * hwInterface, + CodechalDebugInterface *debugInterface) : EncodeAvcVdencPipelineAdapter(hwInterface, debugInterface) {} + + virtual ~EncodeAvcVdencPipelineAdapterXe2_Lpm() {} + + virtual MOS_STATUS Allocate(CodechalSetting *codecHalSettings) override; + + virtual MOS_STATUS ResolveMetaData(PMOS_RESOURCE pInput, PMOS_RESOURCE pOutput) override; + +MEDIA_CLASS_DEFINE_END(EncodeAvcVdencPipelineAdapterXe2_Lpm) +}; + +#endif // !__ENCODE_AVC_VDENC_PIPELINE_ADAPTER_XE2_LPM_H__ + diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_xe2_lpm.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_xe2_lpm.cpp new file mode 100644 index 0000000000..4d5d50ca11 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_xe2_lpm.cpp @@ -0,0 +1,133 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_avc_vdenc_pipeline_xe2_lpm.cpp +//! \brief Defines the interface for avc vdenc encode pipeline Xe2_LPM +//! + +#include "encode_avc_vdenc_pipeline_xe2_lpm.h" +#include "encode_avc_vdenc_packet_xe2_lpm.h" +#include "encode_avc_huc_brc_init_packet.h" +#include "encode_avc_huc_brc_update_packet.h" +#include "encode_avc_vdenc_feature_manager_xe2_lpm.h" +#include "codechal_debug.h" +#include "encode_mem_compression_xe_lpm_plus_base.h" +#include "encode_avc_vdenc_preenc.h" +#include "encode_avc_vdenc_pipeline.h" +#include "encode_preenc_packet.h" + +namespace encode { + +MOS_STATUS AvcVdencPipelineXe2_Lpm::Init(void *settings) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(settings); + + ENCODE_CHK_STATUS_RETURN(Initialize(settings)); + + MediaTask* task = CreateTask(MediaTask::TaskType::cmdTask); + ENCODE_CHK_NULL_RETURN(task); + + RUN_FEATURE_INTERFACE_RETURN(AvcVdencPreEnc, FeatureIDs::preEncFeature, IsEnabled, m_preEncEnabled); + if (m_preEncEnabled) + { + EncodePreEncPacket *avcPreEncpkt = MOS_New(EncodePreEncPacket, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(encodePreEncPacket, avcPreEncpkt)); + ENCODE_CHK_STATUS_RETURN(avcPreEncpkt->Init()); + + RUN_FEATURE_INTERFACE_RETURN(AvcVdencPreEnc, FeatureIDs::preEncFeature, GetEncodeMode, m_encodeMode); + if (m_encodeMode == MediaEncodeMode::MANUAL_RES_PRE_ENC || m_encodeMode == MediaEncodeMode::AUTO_RES_PRE_ENC) + { + return MOS_STATUS_SUCCESS; + } + } + + AvcHucBrcInitPkt *brcInitpkt = MOS_New(AvcHucBrcInitPkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucBrcInit, brcInitpkt)); + ENCODE_CHK_STATUS_RETURN(brcInitpkt->Init()); + + AvcHucBrcUpdatePkt *brcUpdatepkt = MOS_New(AvcHucBrcUpdatePkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucBrcUpdate, brcUpdatepkt)); + ENCODE_CHK_STATUS_RETURN(brcUpdatepkt->Init()); + + AvcVdencPktXe2_Lpm *avcVdencpkt = MOS_New(AvcVdencPktXe2_Lpm, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(VdencPacket, avcVdencpkt)); + ENCODE_CHK_STATUS_RETURN(avcVdencpkt->Init()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS AvcVdencPipelineXe2_Lpm::Initialize(void *settings) +{ + ENCODE_FUNC_CALL(); + + CodechalSetting *codecSettings = (CodechalSetting *)settings; + ENCODE_CHK_NULL_RETURN(m_hwInterface); + ENCODE_CHK_STATUS_RETURN(m_hwInterface->Initialize(codecSettings)); + ENCODE_CHK_STATUS_RETURN(InitMmcState()); + ENCODE_CHK_STATUS_RETURN(AvcVdencPipeline::Initialize(settings)); + + CODECHAL_DEBUG_TOOL( + if (m_debugInterface != nullptr) { + MOS_Delete(m_debugInterface); + } + m_debugInterface = MOS_New(CodechalDebugInterface); + ENCODE_CHK_NULL_RETURN(m_debugInterface); + ENCODE_CHK_NULL_RETURN(m_mediaCopyWrapper); + ENCODE_CHK_STATUS_RETURN( + m_debugInterface->Initialize(m_hwInterface, m_codecFunction, m_mediaCopyWrapper)); + + if (m_statusReportDebugInterface != nullptr) { + MOS_Delete(m_statusReportDebugInterface); + } + m_statusReportDebugInterface = MOS_New(CodechalDebugInterface); + ENCODE_CHK_NULL_RETURN(m_statusReportDebugInterface); + ENCODE_CHK_STATUS_RETURN( + m_statusReportDebugInterface->Initialize(m_hwInterface, m_codecFunction, m_mediaCopyWrapper));); + + ENCODE_CHK_STATUS_RETURN(GetSystemVdboxNumber()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS AvcVdencPipelineXe2_Lpm::CreateFeatureManager() +{ + ENCODE_FUNC_CALL(); + + m_featureManager = MOS_New(EncodeAvcVdencFeatureManagerXe2_Lpm, m_allocator, m_hwInterface, m_trackedBuf, m_recycleBuf, m_mediaCopyWrapper); + ENCODE_CHK_NULL_RETURN(m_featureManager); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS AvcVdencPipelineXe2_Lpm::InitMmcState() +{ +#ifdef _MMC_SUPPORTED + ENCODE_CHK_NULL_RETURN(m_hwInterface); + m_mmcState = MOS_New(EncodeMemCompXe_Lpm_Plus_Base, m_hwInterface); + ENCODE_CHK_NULL_RETURN(m_mmcState); +#endif + return MOS_STATUS_SUCCESS; +} + +} diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_xe2_lpm.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_xe2_lpm.h new file mode 100644 index 0000000000..781beb616b --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/encode_avc_vdenc_pipeline_xe2_lpm.h @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_avc_vdenc_pipeline_xe2_lpm.h +//! \brief Defines the interface for avc vdenc encode pipeline Xe2_LPM +//! +#ifndef __ENCODE_AVC_VDENC_PIPELINE_XE2_LPM_H__ +#define __ENCODE_AVC_VDENC_PIPELINE_XE2_LPM_H__ + +#include "encode_avc_vdenc_pipeline.h" + +namespace encode { + +class AvcVdencPipelineXe2_Lpm : public AvcVdencPipeline +{ +public: + //! + //! \brief EncodePipeline constructor + //! \param [in] hwInterface + //! Pointer to CodechalHwInterface + //! \param [in] debugInterface + //! Pointer to CodechalDebugInterface + //! + AvcVdencPipelineXe2_Lpm( + CodechalHwInterfaceNext * hwInterface, + CodechalDebugInterface *debugInterface) : AvcVdencPipeline(hwInterface, debugInterface) {} + + virtual ~AvcVdencPipelineXe2_Lpm() {} + + virtual MOS_STATUS Init(void *settings) override; + + MOS_STATUS InitMmcState(); + +protected: + virtual MOS_STATUS Initialize(void *settings) override; + virtual MOS_STATUS CreateFeatureManager() override; + +MEDIA_CLASS_DEFINE_END(encode__AvcVdencPipelineXe2_Lpm) +}; + +} +#endif // !__ENCODE_AVC_VDENC_PIPELINE_XE2_LPM_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/media_srcs.cmake new file mode 100644 index 0000000000..a13b169067 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/avc/pipeline/media_srcs.cmake @@ -0,0 +1,52 @@ +# Copyright (c) 2021-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. + +if ("${AVC_Encode_VDEnc_Supported}" STREQUAL "yes") +set(TMP_SOURCES_ + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_pipeline_xe2_lpm.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_pipeline_adapter_xe2_lpm.cpp +) + +set(TMP_HEADERS_ + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_pipeline_xe2_lpm.h + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_pipeline_adapter_xe2_lpm.h +) + +set(SOFTLET_ENCODE_AVC_HEADERS_ + ${SOFTLET_ENCODE_AVC_HEADERS_} + ${TMP_HEADERS_} +) + +set(SOFTLET_ENCODE_AVC_SOURCES_ + ${SOFTLET_ENCODE_AVC_SOURCES_} + ${TMP_SOURCES_} +) + +source_group( CodecHalNext\\Xe2_LPM\\Encode FILES ${TMP_SOURCES_} ${TMP_HEADERS_} ) + +set(TMP_SOURCES_ "") +set(TMP_HEADERS_ "") + +endif() + +set(SOFTLET_ENCODE_AVC_PRIVATE_INCLUDE_DIRS_ + ${SOFTLET_ENCODE_AVC_PRIVATE_INCLUDE_DIRS_} + ${CMAKE_CURRENT_LIST_DIR} +) \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/media_srcs.cmake new file mode 100644 index 0000000000..35c76eeb5e --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/enc/media_srcs.cmake @@ -0,0 +1,21 @@ +# Copyright (c) 2021, 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. + +media_include_subdirectory(avc) diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/media_srcs.cmake index 8bac862833..0d5c64bcf1 100644 --- a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/media_srcs.cmake +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM/codec/hal/media_srcs.cmake @@ -19,3 +19,4 @@ # OTHER DEALINGS IN THE SOFTWARE. media_include_subdirectory(dec) +media_include_subdirectory(enc) \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_basic_feature_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_basic_feature_xe2_lpm_base.cpp new file mode 100644 index 0000000000..d1952a9eae --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_basic_feature_xe2_lpm_base.cpp @@ -0,0 +1,50 @@ +/* +* Copyright (c) 2024, 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. +*/ +//! +//! \file encode_hevc_basic_feature_xe2_lpm_base.cpp +//! \brief Defines the common interface for encode hevc Xe2_LPM base parameter +//! + +#include "encode_hevc_basic_feature_xe2_lpm_base.h" + +namespace encode +{ + +MOS_STATUS HevcBasicFeatureXe2_Lpm_Base::Update(void *params) +{ + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(params); + + ENCODE_CHK_STATUS_RETURN(HevcBasicFeature::Update(params)); + + EncoderParams* encodeParams = (EncoderParams*)params; + + // raw surface + if (IS_RGB_FORMAT(m_rawSurface.Format)) + { + ENCODE_CHK_STATUS_RETURN(m_allocator->UpdateResourceUsageType(&m_rawSurface.OsResource, MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_NOCACHE)); + } + + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_basic_feature_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_basic_feature_xe2_lpm_base.h new file mode 100644 index 0000000000..d36495bcbb --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_basic_feature_xe2_lpm_base.h @@ -0,0 +1,54 @@ +/* +* Copyright (c) 2024, 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. +*/ +//! +//! \file encode_hevc_basic_feature_xe2_lpm_base.h +//! \brief Defines the common interface for encode hevc Xe2_LPM basic feature +//! +#ifndef __ENCODE_HEVC_BASIC_FEATURE_XE2_LPM_BASE_H__ +#define __ENCODE_HEVC_BASIC_FEATURE_XE2_LPM_BASE_H__ + +#include "encode_hevc_basic_feature.h" +#include "encode_allocator.h" + +namespace encode +{ + +class HevcBasicFeatureXe2_Lpm_Base : public HevcBasicFeature +{ +public: + HevcBasicFeatureXe2_Lpm_Base(EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + TrackedBuffer *trackedBuf, + RecycleResource *recycleBuf, + void *constSettings = nullptr) : + HevcBasicFeature(allocator, hwInterface, trackedBuf, recycleBuf, constSettings) {} + + virtual ~HevcBasicFeatureXe2_Lpm_Base() {} + + virtual MOS_STATUS Update(void *params) override; + +MEDIA_CLASS_DEFINE_END(encode__HevcBasicFeatureXe2_Lpm_Base) +}; + +} // namespace encode + +#endif // !__ENCODE_HEVC_BASIC_FEATURE_XE2_LPM_BASE_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base.cpp new file mode 100644 index 0000000000..54ec610b11 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base.cpp @@ -0,0 +1,523 @@ +/* +* Copyright (c) 2021, 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. +*/ + +//! +//! \file encode_hevc_vdenc_const_settings_xe2_lpm_base.cpp +//! \brief Defines the common interface for Xe2_LPM+ Base hevc vdenc const settings +//! + +#include "codec_def_common.h" +#include "encode_hevc_vdenc_const_settings_xe2_lpm_base.h" +#include "encode_utils.h" +#include "mos_solo_generic.h" + +namespace encode +{ +MOS_STATUS EncodeHevcVdencConstSettingsXe2_Lpm_Base::SetTUSettings() +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(m_featureSetting); + MOS_STATUS eStatus = MOS_STATUS_SUCCESS; + + auto setting = static_cast(m_featureSetting); + ENCODE_CHK_NULL_RETURN(setting); + + setting->rdoqEnable = {true, true, true, true, true, true, true, false}; + setting->acqpEnable = {true, true, true, true, true, true, true, false}; + + return eStatus; +} + +MOS_STATUS EncodeHevcVdencConstSettingsXe2_Lpm_Base::SetVdencStreaminStateSettings() +{ + ENCODE_FUNC_CALL(); + + auto setting = static_cast(m_featureSetting); + ENCODE_CHK_NULL_RETURN(setting); + + setting->vdencStreaminStateSettings.emplace_back( + VDENC_STREAMIN_STATE_LAMBDA() { + static const std::array< + std::array< + uint8_t, + NUM_TARGET_USAGE_MODES + 1>, + 4> + numMergeCandidates = {{ + {3, 3, 3, 2, 2, 2, 1, 1}, + {3, 3, 3, 2, 2, 2, 2, 2}, + {4, 4, 3, 2, 2, 2, 2, 1}, + {3, 3, 3, 2, 2, 2, 2, 2}, + }}; + + static const std::array< + uint8_t, + NUM_TARGET_USAGE_MODES + 1> + numImePredictors = {12, 12, 8, 8, 8, 8, 4, 3}; + + par.maxTuSize = 3; //Maximum TU Size allowed, restriction to be set to 3 + par.maxCuSize = (cu64Align) ? 3 : 2; + par.numMergeCandidateCu64x64 = numMergeCandidates[3][m_hevcSeqParams->TargetUsage]; + par.numMergeCandidateCu32x32 = numMergeCandidates[2][m_hevcSeqParams->TargetUsage]; + par.numMergeCandidateCu16x16 = numMergeCandidates[1][m_hevcSeqParams->TargetUsage]; + par.numMergeCandidateCu8x8 = numMergeCandidates[0][m_hevcSeqParams->TargetUsage]; + par.numImePredictors = numImePredictors[m_hevcSeqParams->TargetUsage]; + + auto waTable = m_osItf == nullptr ? nullptr : m_osItf->pfnGetWaTable(m_osItf); + if (waTable) + { + if (MEDIA_IS_WA(waTable, WaHEVCVDEncROINumMergeCandidateSetting) && m_hevcSeqParams->TargetUsage == 4) + { + par.numMergeCandidateCu64x64 = 3; + par.numMergeCandidateCu32x32 = 3; + par.numMergeCandidateCu16x16 = 2; + par.numMergeCandidateCu8x8 = 1; + } + + ENCODE_CHK_NULL_RETURN(m_osItf); + if (MEDIA_IS_WA(waTable, Wa_22011549751) && m_hevcPicParams->CodingType == I_TYPE && !m_osItf->bSimIsActive && !Mos_Solo_Extension((MOS_CONTEXT_HANDLE)m_osItf->pOsContext) && !m_hevcPicParams->pps_curr_pic_ref_enabled_flag) + { + par.numMergeCandidateCu64x64 = 0; + par.numMergeCandidateCu32x32 = 0; + par.numMergeCandidateCu16x16 = 0; + par.numMergeCandidateCu8x8 = 2; + par.numImePredictors = 0; + } + } + + return MOS_STATUS_SUCCESS; + }); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeHevcVdencConstSettingsXe2_Lpm_Base::SetVdencCmd1Settings() +{ + ENCODE_FUNC_CALL(); + + EncodeHevcVdencConstSettings::SetVdencCmd1Settings(); + + auto setting = static_cast(m_featureSetting); + ENCODE_CHK_NULL_RETURN(setting); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 7) + { + par.vdencCmd1Par2[6] = 143; + par.vdencCmd1Par2[7] = 143; + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + static const std::array data = { + 3, 10, 16, 22, 29, 35, 42, 48, 54, 61, 67, 74}; + + for (size_t i = 0; i < data.size(); i++) + { + par.vdencCmd1Par4[i] = data[i]; + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + static const std::array data = { + 11, 14, 15, 17, + 14, 17, 18, 19, + 11, 17, 18, 19, + 0, 23, 24, 25 + }; + + for (size_t i = 0; i < 4; i++) + { + par.vdencCmd1Par8[i] = data[i]; + par.vdencCmd1Par9[i] = data[i + 4]; + par.vdencCmd1Par10[i] = data[i + 8]; + par.vdencCmd1Par11[i] = data[i + 12]; + } + + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par8[0] = 0; + par.vdencCmd1Par9[0] = 0; + par.vdencCmd1Par10[0] = 0; + par.vdencCmd1Par11[0] = 0; + } + } + else + { + static const std::array data = { + 11, 14, 15, 17, + 14, 17, 18, 19, + 14, 17, 18, 19, + 20, 23, 24, 25, + }; + + for (size_t i = 0; i < 4; i++) + { + par.vdencCmd1Par8[i] = data[i]; + par.vdencCmd1Par9[i] = data[i + 4]; + par.vdencCmd1Par10[i] = data[i + 8]; + par.vdencCmd1Par11[i] = data[i + 12]; + + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + static const std::array data = { + 23, 26, 27, 29, + 26, 29, 30, 31, + 21, 29, 30, 31, + 0, 41, 42, 43 + }; + + for (size_t i = 0; i < 4; i++) + { + par.vdencCmd1Par12[i] = data[i]; + par.vdencCmd1Par13[i] = data[i + 4]; + par.vdencCmd1Par14[i] = data[i + 8]; + par.vdencCmd1Par15[i] = data[i + 12]; + } + + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par12[0] = 0; + par.vdencCmd1Par13[0] = 0; + par.vdencCmd1Par14[0] = 0; + par.vdencCmd1Par15[0] = 0; + } + } + else + { + static const std::array data = { + 23, 26, 27, 29, + 26, 29, 30, 31, + 26, 29, 30, 31, + 38, 41, 42, 43, + }; + + for (size_t i = 0; i < 4; i++) + { + par.vdencCmd1Par12[i] = data[i]; + par.vdencCmd1Par13[i] = data[i + 4]; + par.vdencCmd1Par14[i] = data[i + 8]; + par.vdencCmd1Par15[i] = data[i + 12]; + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + if (m_hevcPicParams->CodingType == P_TYPE) + { + par.vdencCmd1Par16 = 82; + par.vdencCmd1Par17 = 20; + par.vdencCmd1Par18 = 83; + par.vdencCmd1Par19 = 17; + par.vdencCmd1Par20 = 15; + par.vdencCmd1Par21 = 0; + } + else if (m_hevcPicParams->CodingType == B_TYPE) + { + par.vdencCmd1Par16 = 99; + par.vdencCmd1Par17 = 23; + par.vdencCmd1Par18 = 99; + par.vdencCmd1Par19 = 19; + par.vdencCmd1Par20 = 17; + par.vdencCmd1Par21 = 0; + } + } + else + { + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par16 = 92; + par.vdencCmd1Par17 = 23; + par.vdencCmd1Par18 = 92; + par.vdencCmd1Par19 = 21; + par.vdencCmd1Par20 = 23; + par.vdencCmd1Par21 = 0; + } + else if (m_hevcPicParams->CodingType == B_TYPE) + { + par.vdencCmd1Par16 = 110; + par.vdencCmd1Par17 = 26; + par.vdencCmd1Par18 = 110; + par.vdencCmd1Par19 = 24; + par.vdencCmd1Par20 = 26; + par.vdencCmd1Par21 = 0; + } + else if (m_hevcPicParams->CodingType == P_TYPE) + { + par.vdencCmd1Par16 = 110; + par.vdencCmd1Par17 = 26; + par.vdencCmd1Par18 = 110; + par.vdencCmd1Par19 = 24; + par.vdencCmd1Par20 = 26; + par.vdencCmd1Par21 = 0; + } + } + + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par23 = 42; + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + par.vdencCmd1Par23 = 63; + } + } + else if (m_hevcPicParams->CodingType == B_TYPE) + { + par.vdencCmd1Par23 = 54; + } + else if (m_hevcPicParams->CodingType == P_TYPE) + { + par.vdencCmd1Par23 = 54; + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par30 = 12; + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par36 = 17; + par.vdencCmd1Par37 = 47; + par.vdencCmd1Par38 = 20; + par.vdencCmd1Par39 = 9; + par.vdencCmd1Par40 = 17; + par.vdencCmd1Par41 = m_hevcPicParams->NumROI ? 0 : 30; + } + else + { + par.vdencCmd1Par36 = 7; + par.vdencCmd1Par37 = 18; + par.vdencCmd1Par38 = 18; + par.vdencCmd1Par39 = 18; + par.vdencCmd1Par40 = 27; + par.vdencCmd1Par41 = m_hevcPicParams->NumROI ? 0 : 68; + } + } + else + { + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par36 = 21; + par.vdencCmd1Par37 = 47; + par.vdencCmd1Par38 = 16; + par.vdencCmd1Par39 = 16; + par.vdencCmd1Par40 = 30; + par.vdencCmd1Par41 = m_hevcPicParams->NumROI ? 0 : 30; + } + else if (m_hevcPicParams->CodingType == B_TYPE) + { + par.vdencCmd1Par36 = 7; + par.vdencCmd1Par37 = 20; + par.vdencCmd1Par38 = 20; + par.vdencCmd1Par39 = 20; + par.vdencCmd1Par40 = 30; + par.vdencCmd1Par41 = m_hevcPicParams->NumROI ? 0 : 68; + } + else if (m_hevcPicParams->CodingType == P_TYPE) + { + par.vdencCmd1Par36 = 7; + par.vdencCmd1Par37 = 20; + par.vdencCmd1Par38 = 20; + par.vdencCmd1Par39 = 20; + par.vdencCmd1Par40 = 30; + par.vdencCmd1Par41 = m_hevcPicParams->NumROI ? 0 : 68; + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + if (m_hevcPicParams->CodingType == P_TYPE) + { + par.vdencCmd1Par48 = 0; + par.vdencCmd1Par49 = 32; + par.vdencCmd1Par50 = 68; + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + par.vdencCmd1Par55 = 0x0E; + par.vdencCmd1Par56 = 0x0E; + par.vdencCmd1Par57 = 0x0C; + par.vdencCmd1Par58 = 0x0B; + + par.vdencCmd1Par59 = 0x10; + par.vdencCmd1Par60 = 0x10; + par.vdencCmd1Par61 = 0x0F; + par.vdencCmd1Par62 = 0x0F; + + par.vdencCmd1Par63 = 0x10; + par.vdencCmd1Par64 = 0x10; + par.vdencCmd1Par65 = 0x10; + par.vdencCmd1Par66 = 0x10; + + par.vdencCmd1Par67 = 0x14; + par.vdencCmd1Par68 = 0x10; + par.vdencCmd1Par69 = 0x10; + par.vdencCmd1Par70 = 0x10; + + par.vdencCmd1Par71 = 0x0C; + par.vdencCmd1Par72 = 0x0C; + par.vdencCmd1Par73 = 0x0A; + par.vdencCmd1Par74 = 0x0A; + + par.vdencCmd1Par75 = 0x10; + par.vdencCmd1Par76 = 0x10; + par.vdencCmd1Par77 = 0x10; + par.vdencCmd1Par78 = 0x10; + + par.vdencCmd1Par79 = 0x10; + par.vdencCmd1Par80 = 0x10; + par.vdencCmd1Par81 = 0x10; + par.vdencCmd1Par82 = 0x10; + + par.vdencCmd1Par83 = 0x10; + par.vdencCmd1Par84 = 0x10; + par.vdencCmd1Par85 = 0x0E; + par.vdencCmd1Par86 = 0x0F; + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + if (m_hevcSeqParams->TargetUsage == 2 || m_hevcSeqParams->TargetUsage == 6) + { + static constexpr std::array< + std::array, 3> + data = {{{20, 35, 35}, + {20, 35, 35}, + {47, 16, 16} + }}; + + if (m_hevcPicParams->CodingType == I_TYPE) + { + par.vdencCmd1Par87 = data[2][2]; + par.vdencCmd1Par88 = data[2][1]; + par.vdencCmd1Par89 = data[2][0]; + } + else if (m_hevcPicParams->CodingType == P_TYPE) + { + par.vdencCmd1Par87 = data[1][2]; + par.vdencCmd1Par88 = data[1][1]; + par.vdencCmd1Par89 = data[1][0]; + } + else if (m_hevcPicParams->CodingType == B_TYPE) + { + par.vdencCmd1Par87 = data[0][2]; + par.vdencCmd1Par88 = data[0][1]; + par.vdencCmd1Par89 = data[0][0]; + } + } + + return MOS_STATUS_SUCCESS; + }); + + setting->vdencCmd1Settings.emplace_back( + VDENC_CMD1_LAMBDA() { + par.vdencCmd1Par95 = 50; + + return MOS_STATUS_SUCCESS; + }); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeHevcVdencConstSettingsXe2_Lpm_Base::SetVdencCmd2Settings() +{ + ENCODE_FUNC_CALL(); + + auto setting = static_cast(m_featureSetting); + ENCODE_CHK_NULL_RETURN(setting); + +#if _MEDIA_RESERVED +#define VDENC_CMD2_SETTINGS_EXT +#include "encode_hevc_vdenc_const_settings_xe2_lpm_base_ext.h" +#undef VDENC_CMD2_SETTINGS_EXT +#else +#define VDENC_CMD2_SETTINGS_OPEN +#include "encode_hevc_vdenc_const_settings_xe2_lpm_base_open.h" +#undef VDENC_CMD2_SETTINGS_OPEN +#endif // !(_MEDIA_RESERVED) + + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base.h new file mode 100644 index 0000000000..894995781b --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base.h @@ -0,0 +1,65 @@ +/* +* Copyright (c) 2021, 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. +*/ + +//! +//! \file encode_hevc_vdenc_const_settings_xe2_lpm_base.h +//! \brief Defines the common interface for Xe2_LPM+ Base henvc vdenc const settings +//! + +#ifndef __ENCODE_HEVC_VDENC_CONST_SETTINGS_XE2_LPM_BASE_H__ +#define __ENCODE_HEVC_VDENC_CONST_SETTINGS_XE2_LPM_BASE_H__ + +#include "encode_hevc_vdenc_const_settings.h" +#include "codec_def_common_encode.h" +namespace encode +{ + +class EncodeHevcVdencConstSettingsXe2_Lpm_Base : public EncodeHevcVdencConstSettings +{ +public: + + //! + //! \brief EncodeHevcVdencConstSettingsXe2_Lpm_Base deconstructor + //! + virtual ~EncodeHevcVdencConstSettingsXe2_Lpm_Base() {} +protected: + + //! + //! \brief Prepare TU related settings + //! \param [in] targetUsage + //! target usage + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS SetTUSettings() override; + + MOS_STATUS SetVdencStreaminStateSettings() override; + + MOS_STATUS SetVdencCmd1Settings() override; + + MOS_STATUS SetVdencCmd2Settings() override; + +MEDIA_CLASS_DEFINE_END(encode__EncodeHevcVdencConstSettingsXe2_Lpm_Base) +}; + +} +#endif // !__ENCODE_HEVC_VDENC_CONST_SETTINGS_XE2_LPM_BASE_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base_open.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base_open.h new file mode 100644 index 0000000000..f9c1c09a3f --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_const_settings_xe2_lpm_base_open.h @@ -0,0 +1,280 @@ +/* +* Copyright (c) 2024, 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. +*/ + +//! +//! \file encode_hevc_vdenc_const_settings_xe2_lpm_base_open.h +//! \brief Defines the opensource hevc cmd2 const settings +//! \details The encode feature manager is further sub-divided by platform type +//! this file is for the base interface which is shared by all components. +//! + +#ifdef VDENC_CMD2_SETTINGS_OPEN +setting->vdencCmd2Settings.emplace_back( +VDENC_CMD2_LAMBDA() +{ + par.extSettings.emplace_back( + [this, isLowDelay, &par](uint32_t *data) { + + uint32_t CodingTypeMinus1 = m_hevcPicParams->CodingType - 1; + uint32_t tu = m_hevcSeqParams->TargetUsage; + uint32_t numL0Minus1Is0 = m_hevcSliceParams->num_ref_idx_l0_active_minus1 == 0; + uint32_t lowDelay = isLowDelay; + uint32_t currPicRef = m_hevcPicParams->pps_curr_pic_ref_enabled_flag; + uint32_t paletteMode = m_hevcSeqParams->palette_mode_enabled_flag; + uint32_t depthMinus8 = m_hevcSeqParams->bit_depth_luma_minus8; + uint32_t rdoq = m_hevcRdoqEnabled; + uint32_t numRef0 = par.numRefL0; + uint32_t numRef1 = par.numRefL1; + uint32_t LowDelayMode = m_hevcSeqParams->LowDelayMode; + uint32_t chroma_format_idc = m_hevcSeqParams->chroma_format_idc; + + static const uint32_t dw2Lut[3][2] = { { 0x3, 0x2,}, { 0x3, 0x3,}, { 0x3, 0x3,},}; + data[2] |= dw2Lut[CodingTypeMinus1][currPicRef]; + + static const uint32_t dw5Lut[3] = { 0xc0a000, 0xc1a000, 0xc0a000,}; + data[5] |= dw5Lut[CodingTypeMinus1]; + + static const uint32_t dw7Lut[3][2][2] = { { { 0x64003, 0x64003,}, { 0x64003, 0x64003,},}, { { 0x64003, 0x64003,}, { 0x64003, 0xe4003,},}, { { 0x64003, 0x64003,}, { 0x64003, 0xe4003,},},}; + data[7] |= dw7Lut[CodingTypeMinus1][numL0Minus1Is0][lowDelay]; + + static const uint32_t dw8Lut[3][8][2][2][2] = { { { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x54555555, 0x54555555,}, { 0x90908090, 0x90908090,},}, { { 0, 0,}, { 0x90908090, 0x90908090,},},}, { { { 0x54555555, 0x54555555,}, { 0xfffdccaa, 0xfffdccaa,},}, { { 0, 0,}, { 0xfffdccaa, 0xfffdccaa,},},}, { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x54555555, 0x54555555,}, { 0x55550000, 0x55550000,},}, { { 0, 0,}, { 0x55550000, 0x55550000,},},}, { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x54555555, 0x54555555,}, { 0x55550000, 0x55550000,},}, { { 0, 0,}, { 0x55550000, 0x55550000,},},}, { { { 0x54555555, 0x54555555,}, { 0x55550000, 0x55550000,},}, { { 0, 0,}, { 0x55550000, 0x55550000,},},},}, { { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x90908090, 0x90908090,}, { 0x90908090, 0x90908090,},}, { { 0x90908090, 0x90908090,}, { 0x90908090, 0x90908090,},},}, { { { 0xfffdccaa, 0xfffdccaa,}, { 0xfffdccaa, 0xfffdccaa,},}, { { 0xfffdccaa, 0xfffdccaa,}, { 0xfffdccaa, 0xfffdccaa,},},}, { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},}, { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},},}, { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},}, { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},},}, { { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},}, { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},},},}, { { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x90908090, 0x90908090,}, { 0x90908090, 0x90908090,},}, { { 0x90908090, 0x90908090,}, { 0x90908090, 0x90908090,},},}, { { { 0xfffdfcaa, 0xfffdccaa,}, { 0xfffdfcaa, 0xfffdccaa,},}, { { 0xfffdfcaa, 0xfffdccaa,}, { 0xfffdfcaa, 0xfffdccaa,},},}, { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},}, { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},},}, { { { 0x54555555, 0x54555555,}, { 0x54555555, 0x54555555,},}, { { 0, 0,}, { 0, 0,},},}, { { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},}, { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},},}, { { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},}, { { 0x55550000, 0x55550000,}, { 0x55550000, 0x55550000,},},},},}; + data[8] |= dw8Lut[CodingTypeMinus1][tu][lowDelay][currPicRef][LowDelayMode]; + + static const uint32_t dw9Lut[3][8][2][2][2] = { { { { { 0xc45555, 0xc45555,}, { 0xc45555, 0xc45555,},}, { { 0xc40000, 0xc40000,}, { 0xc40000, 0xc40000,},},}, { { { 0xc45555, 0xc45555,}, { 0xc461e4, 0xc461e4,},}, { { 0xc40000, 0xc40000,}, { 0xc461e4, 0xc461e4,},},}, { { { 0x845555, 0x845555,}, { 0x84ffff, 0x84ffff,},}, { { 0x840000, 0x840000,}, { 0x84ffff, 0x84ffff,},},}, { { { 0x835555, 0x835555,}, { 0x835555, 0x835555,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x835555, 0x835555,}, { 0x830000, 0x830000,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x835555, 0x835555,}, { 0x835555, 0x835555,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x425555, 0x425555,}, { 0x420000, 0x420000,},}, { { 0x420000, 0x420000,}, { 0x420000, 0x420000,},},}, { { { 0x325555, 0x325555,}, { 0x320000, 0x320000,},}, { { 0x320000, 0x320000,}, { 0x320000, 0x320000,},},},}, { { { { 0xc45555, 0xc45555,}, { 0xc45555, 0xc45555,},}, { { 0xc40000, 0xc40000,}, { 0xc40000, 0xc40000,},},}, { { { 0xc461e4, 0xc461e4,}, { 0xc461e4, 0xc461e4,},}, { { 0xc461e4, 0xc461e4,}, { 0xc461e4, 0xc461e4,},},}, { { { 0x84ffff, 0x84ffff,}, { 0x84ffff, 0x84ffff,},}, { { 0x84ffff, 0x84ffff,}, { 0x84ffff, 0x84ffff,},},}, { { { 0x835555, 0x835555,}, { 0x835555, 0x835555,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x835555, 0x835555,}, { 0x835555, 0x835555,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x420000, 0x420000,}, { 0x420000, 0x420000,},}, { { 0x420000, 0x420000,}, { 0x420000, 0x420000,},},}, { { { 0x320000, 0x320000,}, { 0x320000, 0x320000,},}, { { 0x320000, 0x320000,}, { 0x320000, 0x320000,},},},}, { { { { 0xc45555, 0xc45555,}, { 0xc45555, 0xc45555,},}, { { 0xc40000, 0xc40000,}, { 0xc40000, 0xc40000,},},}, { { { 0xc461e4, 0xc461e4,}, { 0xc461e4, 0xc461e4,},}, { { 0xc461e4, 0xc461e4,}, { 0xc461e4, 0xc461e4,},},}, { { { 0x84fcff, 0x84ffff,}, { 0x84fcff, 0x84ffff,},}, { { 0x84fcff, 0x84ffff,}, { 0x84fcff, 0x84ffff,},},}, { { { 0x835555, 0x835555,}, { 0x835555, 0x835555,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x835555, 0x835555,}, { 0x835555, 0x835555,},}, { { 0x830000, 0x830000,}, { 0x830000, 0x830000,},},}, { { { 0x420000, 0x420000,}, { 0x420000, 0x420000,},}, { { 0x420000, 0x420000,}, { 0x420000, 0x420000,},},}, { { { 0x320000, 0x320000,}, { 0x320000, 0x320000,},}, { { 0x320000, 0x320000,}, { 0x320000, 0x320000,},},},},}; + data[9] |= dw9Lut[CodingTypeMinus1][tu][lowDelay][currPicRef][LowDelayMode]; + + static const uint32_t dw11Lut = 0x80000000; + data[11] |= dw11Lut; + + static const uint32_t dw12Lut[8] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xce4014a0, 0xce4014a0, 0xce4014a0, 0x89800dc0, 0x89800dc0,}; + data[12] |= dw12Lut[tu]; + + static const uint32_t dw16Lut = 0xf000000; + data[16] |= dw16Lut; + + static const uint32_t dw19Lut = 0x98000000; + data[19] |= dw19Lut; + + static const uint32_t dw23Lut = 0xcccc0000; + data[23] |= dw23Lut; + + static const uint32_t dw28Lut = 0x7d00fa0; + data[28] |= dw28Lut; + + static const uint32_t dw29Lut = 0x2bc0bb8; + data[29] |= dw29Lut; + + static const uint32_t dw30Lut = 0x32003e8; + data[30] |= dw30Lut; + + static const uint32_t dw31Lut = 0x1f4012c; + data[31] |= dw31Lut; + + static const uint32_t dw32Lut = 0x190; + data[32] |= dw32Lut; + + static const uint32_t dw35Lut = 0xecc; + data[35] |= dw35Lut; + + static const uint32_t dw37Lut[2] = { 0, 0x40,}; + data[37] |= dw37Lut[currPicRef]; + + static const uint32_t dw39Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x8000fc, 0x10001f8, 0x20003f0, 0x40007e0, 0x8000fc0,},}; + data[39] |= dw39Lut[paletteMode][depthMinus8]; + + static const uint32_t dw40Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0xb10080, 0x1620100, 0x2c40200, 0x5880400, 0xb100800,},}; + data[40] |= dw40Lut[paletteMode][depthMinus8]; + + static const uint32_t dw41Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x300aa, 0x60154, 0xc02a8, 0x180550, 0x300aa0,},}; + data[41] |= dw41Lut[paletteMode][depthMinus8]; + + static const uint32_t dw42Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0xd30069, 0x1a600d2, 0x34c01a4, 0x6980348, 0xd300690,},}; + data[42] |= dw42Lut[paletteMode][depthMinus8]; + + static const uint32_t dw43Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0xe000e9, 0x1c001d2, 0x38003a4, 0x7000748, 0xe000e90,},}; + data[43] |= dw43Lut[paletteMode][depthMinus8]; + + static const uint32_t dw44Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x940003, 0x1280006, 0x250000c, 0x4a00018, 0x9400030,},}; + data[44] |= dw44Lut[paletteMode][depthMinus8]; + + static const uint32_t dw45Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x56004d, 0xac009a, 0x1580134, 0x2b00268, 0x56004d0,},}; + data[45] |= dw45Lut[paletteMode][depthMinus8]; + + static const uint32_t dw46Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x9500fd, 0x12a01fa, 0x25403f4, 0x4a807e8, 0x9500fd0,},}; + data[46] |= dw46Lut[paletteMode][depthMinus8]; + + static const uint32_t dw47Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x17002d, 0x2e005a, 0x5c00b4, 0xb80168, 0x17002d0,},}; + data[47] |= dw47Lut[paletteMode][depthMinus8]; + + static const uint32_t dw48Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0xfd001f, 0x1fa003e, 0x3f4007c, 0x7e800f8, 0xfd001f0,},}; + data[48] |= dw48Lut[paletteMode][depthMinus8]; + + static const uint32_t dw49Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x2006c, 0x400d8, 0x801b0, 0x100360, 0x2006c0,},}; + data[49] |= dw49Lut[paletteMode][depthMinus8]; + + static const uint32_t dw50Lut[2][5] = { { 0, 0, 0, 0, 0,}, { 0x800080, 0x1000100, 0x2000200, 0x4000400, 0x8000800,},}; + data[50] |= dw50Lut[paletteMode][depthMinus8]; + + static const uint32_t dw51Lut[8][2][2] = { { { 0x33430aa0, 0x33430a90,}, { 0x33430a90, 0x33430a90,},}, { { 0x33430952, 0x33430952,}, { 0x33430952, 0x33430952,},}, { { 0x33331552, 0x33331552,}, { 0x33331552, 0x33331552,},}, { { 0x22223552, 0x22223552,}, { 0x22223552, 0x22223552,},}, { { 0x22223552, 0x22223552,}, { 0x22223552, 0x22223552,},}, { { 0x22223552, 0x22223552,}, { 0x22223552, 0x22223552,},}, { { 0x12227146, 0x12227152,}, { 0x12227152, 0x12227152,},}, { { 0x12127006, 0x12127012,}, { 0x12127012, 0x12127012,},},}; + data[51] |= dw51Lut[tu][currPicRef][paletteMode]; + + static const uint32_t dw52Lut[8] = { 0x77fdb5b, 0x77f5b5b, 0x77f5bdb, 0x72d5959, 0x72d5959, 0x72d5959, 0x9295a5a, 0x9294a5a,}; + data[52] |= dw52Lut[tu]; + + static const uint32_t dw53Lut[8] = { 0xffff, 0xffff, 0xffffffff, 0xff000000, 0xff000000, 0xff000000, 0xffff0000, 0x8000,}; + data[53] |= dw53Lut[tu]; + + static const uint32_t dw54Lut[8][2][2][4] = { { { { 0x10080c0, 0x10080c0, 0x1008000, 0x1008000,}, { 0x1008000, 0x1008000, 0x1008000, 0x1008000,},}, { { 0x1008000, 0x1008000, 0x1008000, 0x1008000,}, { 0x1008000, 0x1008000, 0x1008000, 0x1008000,},},}, { { { 0x10080c0, 0x10080c0, 0x1008000, 0x1008000,}, { 0x1008000, 0x1008000, 0x1008000, 0x1008000,},}, { { 0x1008000, 0x1008000, 0x1008000, 0x1008000,}, { 0x1008000, 0x1008000, 0x1008000, 0x1008000,},},}, { { { 0x1008000, 0x1008000, 0x1008000, 0x1008000,}, { 0x1008000, 0x1008000, 0x1008000, 0x1008000,},}, { { 0x1008000, 0x1008000, 0x1008000, 0x1008000,}, { 0x1008000, 0x1008000, 0x1008000, 0x1008000,},},}, { { { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,}, { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,},}, { { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,}, { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,},},}, { { { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,}, { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,},}, { { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,}, { 0xc5008000, 0xc5008000, 0xc5008000, 0xc5008000,},},}, { { { 0x85008000, 0x85008000, 0x85008000, 0x85008000,}, { 0x85008000, 0x85008000, 0x85008000, 0x85008000,},}, { { 0x85008000, 0x85008000, 0x85008000, 0x85008000,}, { 0x85008000, 0x85008000, 0x85008000, 0x85008000,},},}, { { { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,}, { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,},}, { { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,}, { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,},},}, { { { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,}, { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,},}, { { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,}, { 0xbd00800c, 0xbd00800c, 0xbd00800c, 0xbd00800c,},},},}; + data[54] |= dw54Lut[tu][currPicRef][paletteMode][chroma_format_idc]; + + static const uint32_t dw55Lut[2] = { 0, 0xcdef0123,}; + data[55] |= dw55Lut[rdoq]; + + static const uint32_t dw56Lut[3][2][2][5][4] = { { { { { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0x300, 0, 0,}, { 0, 0, 0, 0x300,}, { 0, 0, 0, 0,},}, { { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0x30b, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0x30b,}, { 0xb, 0xb, 0xb, 0xb,},},}, { { { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0x300,},}, { { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0x30b,},},},}, { { { { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0x300, 0x300, 0x300, 0x300,}, { 0, 0, 0, 0,},}, { { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0x30b, 0x30b, 0x30b, 0x30b,}, { 0xb, 0xb, 0xb, 0xb,},},}, { { { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0x300, 0x300, 0x300, 0x300,},}, { { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0x30b, 0x30b, 0x30b, 0x30b,},},},}, { { { { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0x300, 0, 0,}, { 0, 0, 0, 0x300,}, { 0, 0, 0, 0,},}, { { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0x30b, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0x30b,}, { 0xb, 0xb, 0xb, 0xb,},},}, { { { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0,}, { 0, 0, 0, 0x300,},}, { { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0xb,}, { 0xb, 0xb, 0xb, 0x30b,},},},},}; + data[56] |= dw56Lut[CodingTypeMinus1][currPicRef][rdoq][numRef0][numRef1]; + + static const uint32_t dw57Lut[2] = { 0, 0x508c23,}; + data[57] |= dw57Lut[rdoq]; + + static const uint32_t dw58Lut[2] = { 0, 0x466419,}; + data[58] |= dw58Lut[rdoq]; + + static const uint32_t dw59Lut[2] = { 0, 0x7d6c5c4b,}; + data[59] |= dw59Lut[rdoq]; + + static const uint32_t dw60Lut[2] = { 0, 0xbfaf9e8e,}; + data[60] |= dw60Lut[rdoq]; + + return MOS_STATUS_SUCCESS; + }); + + return MOS_STATUS_SUCCESS; +}); + +setting->vdencCmd2Settings.emplace_back( + VDENC_CMD2_LAMBDA() + { + par.extSettings.emplace_back( + [this](uint32_t *data) { + + if (!m_hevcVdencRoundingPrecisionEnabled) + { + return MOS_STATUS_SUCCESS; + } + + uint8_t tmp0 = 0; + uint8_t tmp1 = 0; + + if (m_hevcPicParams->CustomRoundingOffsetsParams.fields.EnableCustomRoudingIntra) + { + tmp0 = m_hevcPicParams->CustomRoundingOffsetsParams.fields.RoundingOffsetIntra; + } + else + { + if (m_hevcPicParams->CodingType == I_TYPE) + { + tmp0 = 10; + } + else if (m_hevcSeqParams->HierarchicalFlag && m_hevcPicParams->HierarchLevelPlus1 > 0) + { + //Hierachical GOP + if (m_hevcPicParams->HierarchLevelPlus1 == 1) + { + tmp0 = 10; + } + else if (m_hevcPicParams->HierarchLevelPlus1 == 2) + { + tmp0 = 9; + } + else + { + tmp0 = 8; + } + } + else + { + tmp0 = 10; + } + } + + if (m_hevcPicParams->CustomRoundingOffsetsParams.fields.EnableCustomRoudingInter) + { + tmp1 = m_hevcPicParams->CustomRoundingOffsetsParams.fields.RoundingOffsetInter; + } + else + { + if (m_hevcPicParams->CodingType == I_TYPE) + { + tmp1 = 4; + } + else if (m_hevcSeqParams->HierarchicalFlag && m_hevcPicParams->HierarchLevelPlus1 > 0) + { + //Hierachical GOP + if (m_hevcPicParams->HierarchLevelPlus1 == 1) + { + tmp1 = 4; + } + else if (m_hevcPicParams->HierarchLevelPlus1 == 2) + { + tmp1 = 3; + } + else + { + tmp1 = 2; + } + } + else + { + tmp1 = 4; + } + } + tmp0 &= 0xf; + tmp1 &= 0xf; + + data[32] |= (tmp1 << 16); + data[32] |= (tmp1 << 20); + data[32] |= (tmp0 << 24); + data[32] |= (tmp0 << 28); + + data[33] |= tmp1; + data[33] |= (tmp1 << 4); + data[33] |= (tmp1 << 8); + data[33] |= (tmp1 << 12); + data[33] |= (tmp0 << 16); + data[33] |= (tmp0 << 20); + data[33] |= (tmp1 << 24); + data[33] |= (tmp1 << 28); + + data[34] |= tmp1; + data[34] |= (tmp1 << 4); + data[34] |= (tmp0 << 8); + data[34] |= (tmp0 << 12); + data[34] |= (tmp1 << 16); + data[34] |= (tmp1 << 20); + + return MOS_STATUS_SUCCESS; + }); + + return MOS_STATUS_SUCCESS; +}); + +#endif // VDENC_CMD2_SETTINGS_OPEN \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe2_lpm_base.cpp new file mode 100644 index 0000000000..2267816621 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe2_lpm_base.cpp @@ -0,0 +1,162 @@ +/* +* Copyright (c) 2024, 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. +*/ + +//! +//! \file encode_hevc_vdenc_feature_manager_xe2_lpm_base.cpp +//! \brief Defines the common interface for hevc Xe2_LPM+ encode feature manager +//! + +#include "encode_vdenc_lpla_analysis.h" +#include "encode_hevc_vdenc_lpla_enc.h" +#include "encode_hevc_vdenc_feature_manager_xe2_lpm_base.h" +#include "encode_hevc_aqm.h" +#include "encode_hevc_basic_feature_xe2_lpm_base.h" + +namespace encode +{ + +MOS_STATUS EncodeHevcVdencFeatureManagerXe2_Lpm_Base::CreateConstSettings() +{ + ENCODE_FUNC_CALL(); + m_featureConstSettings = MOS_New(EncodeHevcVdencConstSettingsXe2_Lpm_Base); + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeHevcVdencFeatureManagerXe2_Lpm_Base::CreateFeatures(void *constSettings) +{ + ENCODE_FUNC_CALL(); + + auto setting = static_cast(m_featureConstSettings); + ENCODE_CHK_NULL_RETURN(setting); + setting->SetOsInterface(m_hwInterface->GetOsInterface()); + + EncodeBasicFeature *encBasic = MOS_New(HevcBasicFeatureXe2_Lpm_Base, m_allocator, m_hwInterface, m_trackedBuf, m_recycleResource, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::basicFeature, encBasic, {HevcPipeline::encodePreEncPacket})); + + HevcEncodeCqp *encCqp = MOS_New(HevcEncodeCqp, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcCqpFeature, encCqp, {HevcPipeline::encodePreEncPacket})); + + HevcEncodeTile *encTile = MOS_New(HevcEncodeTile, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::encodeTile, encTile, {HevcPipeline::encodePreEncPacket})); + + HevcVdencSccXe2_Lpm_Base *hevcScc = MOS_New(HevcVdencSccXe2_Lpm_Base, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcVdencSccFeature, hevcScc, {HevcPipeline::encodePreEncPacket})); + + HevcVdencPreEnc *hevcPreenc = MOS_New(HevcVdencPreEnc, this, m_allocator, m_hwInterface, m_trackedBuf, m_recycleResource, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(FeatureIDs::preEncFeature, hevcPreenc, {HevcPipeline::encodePreEncPacket}, LIST_TYPE::ALLOW_LIST)); // only encodePreEncPacket + + HevcVdencFullEnc *hevcFullenc = MOS_New(HevcVdencFullEnc, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcFullEncFeature, hevcFullenc, {HevcPipeline::encodePreEncPacket})); + + HEVCEncodeBRC *brc = MOS_New(HEVCEncodeBRC, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcBrcFeature, brc, {HevcPipeline::encodePreEncPacket})); + + HevcVdencRoi *hevcRoi = MOS_New(HevcVdencRoi, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcVdencRoiFeature, hevcRoi, {HevcPipeline::encodePreEncPacket})); + + HevcVdencWeightedPred *hevcWeightedPred = MOS_New(HevcVdencWeightedPred, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcVdencWpFeature, hevcWeightedPred, {HevcPipeline::encodePreEncPacket})); + + HevcEncodeDss *hevcDss = MOS_New(HevcEncodeDss, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcVdencDssFeature, hevcDss, {HevcPipeline::encodePreEncPacket})); + + VdencLplaAnalysis *lplaAnalysis = MOS_New(VdencLplaAnalysis, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::vdencLplaAnalysisFeature, lplaAnalysis, {HevcPipeline::encodePreEncPacket})); + + HEVCVdencLplaEnc *lplaEnc = MOS_New(HEVCVdencLplaEnc, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcVdencLplaEncFeature, lplaEnc, {HevcPipeline::encodePreEncPacket})); + + HevcEncodeAqm *hevcAqm = MOS_New(HevcEncodeAqm, this, m_allocator, m_hwInterface, constSettings); + ENCODE_CHK_STATUS_RETURN(RegisterFeatures(HevcFeatureIDs::hevcAqm, hevcAqm, {HevcPipeline::encodePreEncPacket})); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeHevcVdencFeatureManagerXe2_Lpm_Base::MapTargetUsage(uint8_t &targetUsage) +{ + ENCODE_FUNC_CALL(); + + switch (targetUsage) + { + case 1: + targetUsage = 1; + break; + case 2: + targetUsage = 2; + break; + case 3: case 4: case 5: + targetUsage = 4; + break; + case 6: + targetUsage = 6; + break; + case 7: + targetUsage = 7; + break; + default: + targetUsage = 4; + break; + } + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS EncodeHevcVdencFeatureManagerXe2_Lpm_Base::CheckPlatformCapability( + PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, + PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams, + PCODEC_HEVC_ENCODE_SLICE_PARAMS hevcSliceParams) +{ + MOS_STATUS eStatus = MOS_STATUS_SUCCESS; + + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(hevcSeqParams); + ENCODE_CHK_NULL_RETURN(hevcPicParams); + ENCODE_CHK_NULL_RETURN(hevcSliceParams); + + if (hevcSeqParams->bit_depth_luma_minus8 >= 4 || hevcSeqParams->bit_depth_chroma_minus8 >= 4 || hevcSeqParams->SourceBitDepth >= 2) + { + eStatus = MOS_STATUS_INVALID_PARAMETER; + ENCODE_ASSERTMESSAGE("12bit input or encoding is not supported on HEVC VDENC"); + } + + if (hevcSeqParams->ParallelBRC) + { + eStatus = MOS_STATUS_INVALID_PARAMETER; + ENCODE_ASSERTMESSAGE("Parallel BRC is not supported on VDENC"); + } + + if (hevcSeqParams->log2_max_coding_block_size_minus3 != 3) + { + eStatus = MOS_STATUS_INVALID_PARAMETER; + ENCODE_ASSERTMESSAGE("HEVC VDEnc only supports LCU64"); + } + + uint16_t numLCUsInFrameWidth = MOS_ALIGN_CEIL((hevcSeqParams->wFrameWidthInMinCbMinus1 + 1) * (1 << (hevcSeqParams->log2_min_coding_block_size_minus3 + 3)), CODECHAL_HEVC_MAX_LCU_SIZE_G10) / CODECHAL_HEVC_MAX_LCU_SIZE_G10; + if (hevcSliceParams->NumLCUsInSlice % numLCUsInFrameWidth != 0 && hevcPicParams->num_tile_columns_minus1 == 0) + { + eStatus = MOS_STATUS_INVALID_PARAMETER; + ENCODE_ASSERTMESSAGE("Row unaligned slice is not supported on HEVC VDEnc"); + } + + return eStatus; +} + +} diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe2_lpm_base.h new file mode 100644 index 0000000000..5402a58ffd --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe2_lpm_base.h @@ -0,0 +1,114 @@ +/* +* Copyright (c) 2021, 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. +*/ + +//! +//! \file encode_hevc_vdenc_feature_manager_xe2_lpm_base.h +//! \brief Defines the Xe2_LPM+ interface for encode feature manager +//! \details The encode feature manager is further sub-divided by codec type +//! this file is for the base interface which is shared by all components. +//! + +#ifndef __ENCODE_HEVC_VDENC_FEATURE_MANAGER_XE2_LPM_BASE_H__ +#define __ENCODE_HEVC_VDENC_FEATURE_MANAGER_XE2_LPM_BASE_H__ +#include +#include "encode_hevc_vdenc_feature_manager.h" +#include "encode_hevc_vdenc_const_settings_xe2_lpm_base.h" +#include "encode_hevc_vdenc_weighted_prediction.h" +#include "encode_hevc_vdenc_scc_xe2_lpm_base.h" +#include "encode_hevc_vdenc_preenc.h" +#include "encode_hevc_vdenc_fullenc.h" + +namespace encode +{ + +class EncodeHevcVdencFeatureManagerXe2_Lpm_Base : public EncodeHevcVdencFeatureManager +{ +public: + //! + //! \brief EncodeHevcVdencFeatureManagerXe2_Lpm_Base constructor + //! \param [in] allocator + //! Pointer to EncodeAllocator + //! \param [in] hwInterface + //! Pointer to CodechalHwInterface + //! \param [in] trackedBuf + //! Pointer to TrackedBuffer + //! \param [in] recycleBuf + //! Pointer to RecycleResource + //! + EncodeHevcVdencFeatureManagerXe2_Lpm_Base(EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + TrackedBuffer *trackedBuf, + RecycleResource *recycleBuf): + EncodeHevcVdencFeatureManager(allocator, hwInterface, trackedBuf, recycleBuf){}; + + //! + //! \brief EncodeHevcVdencFeatureManagerXe2_Lpm_Base deconstructor + //! + virtual ~EncodeHevcVdencFeatureManagerXe2_Lpm_Base(){}; + +protected: + //! + //! \brief Create feature const settings + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS CreateConstSettings() override; + + //! + //! \brief Create features + //! \param [in] constsettings + //! feature const settings + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS CreateFeatures(void *constSettings) override; + + //! + //! \brief Map target usage + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS MapTargetUsage(uint8_t &targetUsage) override; + + //! + //! \brief Check Platform Capabilities + //! \param [in] hevcSeqParams + //! sequese parameters from DDI + //! \param [in] hevcPictureParams + //! picture parameters from DDI + //! \param [in] hevcSliceParams + //! slice parameters from DDI + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + MOS_STATUS CheckPlatformCapability( + PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, + PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams, + PCODEC_HEVC_ENCODE_SLICE_PARAMS hevcSliceParams) override; + +MEDIA_CLASS_DEFINE_END(encode__EncodeHevcVdencFeatureManagerXe2_Lpm_Base) +}; + + +} +#endif // !__ENCODE_HEVC_VDENC_FEATURE_MANAGER_XE2_LPM_BASE_H__ + diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_scc_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_scc_xe2_lpm_base.cpp new file mode 100644 index 0000000000..5078f51f5c --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_scc_xe2_lpm_base.cpp @@ -0,0 +1,251 @@ +/* +* Copyright (c) 2024, 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. +*/ +//! +//! \file encode_hevc_vdenc_scc_xe2_lpm_base.cpp +//! \brief Defines the Xe2_LPM+ Base interface for hevc encode scc features +//! + +#include "encode_hevc_basic_feature.h" +#include "encode_hevc_vdenc_scc_xe2_lpm_base.h" +#include "encode_hevc_vdenc_feature_manager.h" +namespace encode +{ + +HevcVdencSccXe2_Lpm_Base::HevcVdencSccXe2_Lpm_Base( + MediaFeatureManager *featureManager, + EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + void *constSettings) : HevcVdencScc(featureManager, allocator, hwInterface, constSettings) +{ +} + +MHW_SETPAR_DECL_SRC(VDENC_CMD2, HevcVdencSccXe2_Lpm_Base) +{ + ENCODE_CHK_STATUS_RETURN(HevcVdencScc::MHW_SETPAR_F(VDENC_CMD2)(params)); + + if (m_enableSCC) + { +#if _MEDIA_RESERVED + params.vdencCmd2Par102 = false; + params.vdencCmd2Par101 = false; +#else + params.extSettings.emplace_back( + [this](uint32_t *data) { + data[54] &= 0xFFFFFF3F; + return MOS_STATUS_SUCCESS; + }); +#endif // _MEDIA_RESERVED + + if (m_basicFeature->m_targetUsage == 1) + { +#if _MEDIA_RESERVED + params.vdencCmd2Par87[2] = 3; + params.vdencCmd2Par135[1] = 1; + params.vdencCmd2Par88[1][0] = 3; + params.vdencCmd2Par93 = 65535; + params.vdencCmd2Par135[0] = 1; +#else + params.extSettings.emplace_back( + [this](uint32_t *data) { + data[51] = data[51] & 0xFF0FC3FF | 0x301400; + data[52] |= 0xC0; + data[53] |= 0xFFFF0000; + return MOS_STATUS_SUCCESS; + }); +#endif // _MEDIA_RESERVED + } + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_HEVC_VP9_TILE_SLICE_STATE, HevcVdencSccXe2_Lpm_Base) +{ + auto hevcFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(hevcFeature); + + uint32_t IbcControl = 0; + if (hevcFeature->m_hevcPicParams->pps_curr_pic_ref_enabled_flag) + { + IbcControl = m_enableLBCOnly ? 1 : 3; + } + else + { + IbcControl = 0; + } + uint32_t PaletteModeEnable = (hevcFeature->m_hevcSeqParams->palette_mode_enabled_flag != 0) ? 1 : 0; + uint32_t SliceQP = hevcFeature->m_hevcPicParams->QpY + hevcFeature->m_hevcSliceParams->slice_qp_delta; + uint32_t BitDepthLumaMinus8 = hevcFeature->m_hevcSeqParams->bit_depth_luma_minus8; + uint8_t TargetUsage = hevcFeature->m_hevcSeqParams->TargetUsage; + + // For IBC + params.VdencHEVCVP9TileSlicePar0 = 0; + params.ibcControl = IbcControl; + + // For palette mode + params.paletteModeEnable = PaletteModeEnable; + params.VdencHEVCVP9TileSlicePar1 = 1; //to be aligned with C model + + uint32_t tableIdx; + if (SliceQP <= 12) + { + tableIdx = 0; + } + else if (SliceQP > 12 && SliceQP <= 17) + { + tableIdx = 1; + } + else if (SliceQP > 17 && SliceQP <= 22) + { + tableIdx = 2; + } + else if (SliceQP > 22 && SliceQP <= 27) + { + tableIdx = 3; + } + else if (SliceQP > 27 && SliceQP <= 32) + { + tableIdx = 4; + } + else if (SliceQP > 32 && SliceQP <= 37) + { + tableIdx = 5; + } + else if (SliceQP > 37 && SliceQP <= 42) + { + tableIdx = 6; + } + else if (SliceQP > 42 && SliceQP <= 47) + { + tableIdx = 7; + } + else if (SliceQP > 47 && SliceQP <= 49) + { + tableIdx = 8; + } + else + { + tableIdx = 9; + } + + static const uint32_t table[3][10][11] = + { + { + {16, 16, 2, 4, 10, 16, 128, 1, 1, 1, 0}, + {16, 16, 2, 4, 10, 16, 128, 1, 1, 1, 0}, + {16, 16, 2, 4, 10, 16, 128, 1, 1, 1, 0}, + {16, 16, 4, 8, 10, 12, 128, 2, 1, 1, 0}, + {32, 32, 8, 4, 10, 4, 128, 2, 2, 1, 0}, + {48, 32, 12, 6, 16, 4, 128, 2, 2, 1, 0}, + {64, 63, 12, 6, 24, 1, 128, 2, 2, 1, 0}, + {96, 63, 12, 6, 24, 1, 128, 2, 3, 1, 0}, + {128, 63, 16, 12, 32, 1, 128, 2, 6, 1, 0}, + {256, 48, 24, 6, 48, 1, 128, 3, 8, 1, 0}, + }, + { + {16, 16, 2, 4, 10, 16, 128, 1, 1, 1, 0}, + {16, 16, 2, 4, 10, 16, 128, 1, 1, 1, 0}, + {16, 16, 2, 4, 10, 16, 128, 1, 1, 1, 0}, + {16, 16, 4, 8, 10, 12, 128, 2, 1, 1, 0}, + {32, 32, 8, 4, 10, 4, 128, 2, 2, 1, 0}, + {48, 32, 12, 6, 16, 4, 128, 2, 2, 1, 0}, + {64, 63, 12, 6, 24, 1, 128, 2, 2, 1, 0}, + {96, 63, 12, 6, 24, 1, 128, 2, 3, 1, 0}, + {128, 63, 16, 12, 32, 1, 128, 2, 6, 1, 0}, + {256, 48, 24, 6, 48, 1, 128, 3, 8, 1, 0}, + }, + { + {256, 24, 4, 4, 12, 8, 128, 2, 1, 1, 0}, + {256, 32, 4, 4, 12, 8, 128, 2, 1, 1, 0}, + {256, 32, 4, 4, 16, 8, 128, 2, 1, 1, 0}, + {256, 32, 8, 4, 16, 8, 128, 2, 1, 1, 0}, + {256, 32, 8, 4, 32, 4, 128, 3, 1, 1, 0}, + {768, 32, 8, 4, 32, 4, 128, 3, 1, 1, 0}, + {768, 63, 32, 8, 64, 1, 128, 3, 4, 1, 0}, + {768, 63, 48, 8, 128, 1, 128, 3, 12, 1, 0}, + {768, 63, 48, 8, 128, 1, 128, 3, 24, 1, 0}, + {768, 63, 64, 8, 128, 1, 128, 4, 32, 0, 0}, + }, + }; + + params.VdencHEVCVP9TileSlicePar14 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][0]; + params.VdencHEVCVP9TileSlicePar8 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][1]; + params.VdencHEVCVP9TileSlicePar6 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][2]; + params.VdencHEVCVP9TileSlicePar9 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][3]; + params.VdencHEVCVP9TileSlicePar7 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][4]; + params.VdencHEVCVP9TileSlicePar10 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][5]; + + params.VdencHEVCVP9TileSlicePar5 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][7]; + params.VdencHEVCVP9TileSlicePar2 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][8]; + params.VdencHEVCVP9TileSlicePar3 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][9]; + params.VdencHEVCVP9TileSlicePar15 = 0; + + if (BitDepthLumaMinus8 > 0 && PaletteModeEnable) + { + uint32_t shift = BitDepthLumaMinus8; + params.VdencHEVCVP9TileSlicePar5 += shift; + params.VdencHEVCVP9TileSlicePar6 <<= shift; + params.VdencHEVCVP9TileSlicePar7 <<= shift; + if (params.VdencHEVCVP9TileSlicePar14 >= 256) + { + params.VdencHEVCVP9TileSlicePar14 = 255; + } + params.VdencHEVCVP9TileSlicePar14 <<= shift; + } + + params.VdencHEVCVP9TileSlicePar4 = 6; + params.VdencHEVCVP9TileSlicePar11 = 1; + params.VdencHEVCVP9TileSlicePar12 = 72; + params.VdencHEVCVP9TileSlicePar13 = 2; + + params.VdencHEVCVP9TileSlicePar16[2] = 1; + params.VdencHEVCVP9TileSlicePar16[1] = 0; + params.VdencHEVCVP9TileSlicePar16[0] = 1; + params.VdencHEVCVP9TileSlicePar23 = 6; + + if (TargetUsage == 7 || TargetUsage == 6) + { + params.VdencHEVCVP9TileSlicePar17[2] = 49; + params.VdencHEVCVP9TileSlicePar17[1] = 49; + params.VdencHEVCVP9TileSlicePar17[0] = 49; + } + else + { + params.VdencHEVCVP9TileSlicePar17[2] = 63; + params.VdencHEVCVP9TileSlicePar17[1] = 63; + params.VdencHEVCVP9TileSlicePar17[0] = 63; + } + + return MOS_STATUS_SUCCESS; +} + +bool HevcVdencSccXe2_Lpm_Base::IsCompressFlagNeeded() +{ + auto skuTable = m_osInterface->pfnGetSkuTable(m_osInterface); + if (skuTable && MEDIA_IS_SKU(skuTable, FtrXe2Compression)) + { + return false; + } + return true; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_scc_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_scc_xe2_lpm_base.h new file mode 100644 index 0000000000..d08b50c83b --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/encode_hevc_vdenc_scc_xe2_lpm_base.h @@ -0,0 +1,56 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_hevc_vdenc_scc_xe2_lpm_base.h +//! \brief Defines for Xe2_LPM+ hevc screen content coding feature +//! +#ifndef __ENCODE_HEVC_VDENC_SCC_XE2_LPM_BASE_H__ +#define __ENCODE_HEVC_VDENC_SCC_XE2_LPM_BASE_H__ + +#include "encode_hevc_vdenc_scc.h" + +namespace encode +{ +class HevcVdencSccXe2_Lpm_Base : public HevcVdencScc +{ +public: + HevcVdencSccXe2_Lpm_Base( + MediaFeatureManager *featureManager, + EncodeAllocator * allocator, + CodechalHwInterfaceNext *hwInterface, + void * constSettings); + + ~HevcVdencSccXe2_Lpm_Base() {} + + MHW_SETPAR_DECL_HDR(VDENC_CMD2); + MHW_SETPAR_DECL_HDR(VDENC_HEVC_VP9_TILE_SLICE_STATE); + + bool IsCompressFlagNeeded() override; + +protected: + +MEDIA_CLASS_DEFINE_END(encode__HevcVdencSccXe2_Lpm_Base) +}; + +} // namespace encode + +#endif // !__ENCODE_HEVC_VDENC_SCC_XE2_LPM_BASE_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/media_srcs.cmake new file mode 100644 index 0000000000..d244a841d5 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/features/media_srcs.cmake @@ -0,0 +1,59 @@ +# Copyright (c) 2024, 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. + +#encode + +if("${HEVC_Encode_VDEnc_Supported}" STREQUAL "yes") +set(TMP_SOURCES_ + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_scc_xe2_lpm_base.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_feature_manager_xe2_lpm_base.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_const_settings_xe2_lpm_base.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_basic_feature_xe2_lpm_base.cpp +) + +set(TMP_HEADERS_ + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_scc_xe2_lpm_base.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_feature_manager_xe2_lpm_base.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_const_settings_xe2_lpm_base.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_basic_feature_xe2_lpm_base.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_const_settings_xe2_lpm_base_open.h +) + +set(SOFTLET_ENCODE_HEVC_HEADERS_ + ${SOFTLET_ENCODE_HEVC_HEADERS_} + ${TMP_HEADERS_} +) + +set(SOFTLET_ENCODE_HEVC_SOURCES_ + ${SOFTLET_ENCODE_HEVC_SOURCES_} + ${TMP_SOURCES_} +) + +source_group( CodecHalNext\\Xe2_LPM_base\\Encode FILES ${TMP_SOURCES_} ${TMP_HEADERS_} ) + +set(TMP_SOURCES_ "") +set(TMP_HEADERS_ "") + +endif() + +set(SOFTLET_ENCODE_HEVC_PRIVATE_INCLUDE_DIRS_ + ${SOFTLET_ENCODE_HEVC_PRIVATE_INCLUDE_DIRS_} + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/media_srcs.cmake new file mode 100644 index 0000000000..569229406b --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/media_srcs.cmake @@ -0,0 +1,23 @@ +# Copyright (c) 2021-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. + +media_include_subdirectory(features) +media_include_subdirectory(packet) +media_include_subdirectory(pipeline) \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_xe2_lpm_base.cpp new file mode 100644 index 0000000000..789af1d7bc --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_xe2_lpm_base.cpp @@ -0,0 +1,309 @@ +/* +* Copyright (c) 2021-2024, 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. +*/ +//! +//! \file encode_hevc_vdenc_packet_xe2_lpm_base.cpp +//! \brief Defines the interface for hevc encode vdenc packet of Xe2 LPM Base +//! + +#include "encode_hevc_vdenc_packet_xe2_lpm_base.h" +#include "encode_hevc_aqm.h" +#include "hal_oca_interface_next.h" + +namespace encode +{ +MOS_STATUS HevcVdencPktXe2_Lpm_Base::AddPicStateWithNoTile( + MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + auto eStatus = MOS_STATUS_SUCCESS; + + bool tileEnabled = false; + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, IsEnabled, tileEnabled); + if (tileEnabled) + { + return MOS_STATUS_SUCCESS; + } + + eStatus = HevcVdencPkt::AddPicStateWithNoTile(cmdBuffer); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(HevcFeatureIDs::hevcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + SETPAR_AND_ADDCMD(AQM_VD_CONTROL_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_PIPE_BUF_ADDR_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_PIC_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_TILE_CODING, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_FRAME_START, m_aqmItf, &cmdBuffer); + } + + return eStatus; +} + +MOS_STATUS HevcVdencPktXe2_Lpm_Base::AddAQMCommands( + MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + auto eStatus = MOS_STATUS_SUCCESS; + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(HevcFeatureIDs::hevcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + SETPAR_AND_ADDCMD(AQM_VD_CONTROL_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_PIPE_BUF_ADDR_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_PIC_STATE, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_TILE_CODING, m_aqmItf, &cmdBuffer); + SETPAR_AND_ADDCMD(AQM_FRAME_START, m_aqmItf, &cmdBuffer); + } + + return eStatus; +} + +MOS_STATUS HevcVdencPktXe2_Lpm_Base::AddOneTileCommands( + MOS_COMMAND_BUFFER &cmdBuffer, + uint32_t tileRow, + uint32_t tileCol, + uint32_t tileRowPass) +{ + ENCODE_FUNC_CALL(); + PMOS_COMMAND_BUFFER tempCmdBuffer = &cmdBuffer; + PMHW_BATCH_BUFFER tileLevelBatchBuffer = nullptr; + auto eStatus = MOS_STATUS_SUCCESS; + MOS_COMMAND_BUFFER constructTileBatchBuf = {}; + + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, SetCurrentTile, tileRow, tileCol, m_pipeline); + + if ((m_pipeline->GetPipeNum() > 1) && (tileCol != m_pipeline->GetCurrentPipe())) + { + return MOS_STATUS_SUCCESS; + } + + if (!m_osInterface->bUsesPatchList) + { + // Begin patching tile level batch cmds + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, BeginPatchTileLevelBatch, tileRowPass, constructTileBatchBuf); + + // Add batch buffer start for tile + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, GetTileLevelBatchBuffer, tileLevelBatchBuffer); + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_BATCH_BUFFER_START)(&cmdBuffer, tileLevelBatchBuffer)); + + tempCmdBuffer = &constructTileBatchBuf; + MHW_MI_MMIOREGISTERS mmioRegister; + if (m_vdencItf->ConvertToMiRegister(MHW_VDBOX_NODE_1, mmioRegister)) + { + HalOcaInterfaceNext::On1stLevelBBStart( + *tempCmdBuffer, + (MOS_CONTEXT_HANDLE)m_osInterface->pOsContext, + m_osInterface->CurrentGpuContextHandle, + m_miItf, + mmioRegister); + } + } + + // HCP Lock for multiple pipe mode + if (m_pipeline->GetPipeNum() > 1) + { + auto &vdControlStateParams = m_miItf->MHW_GETPAR_F(VD_CONTROL_STATE)(); + vdControlStateParams = {}; + vdControlStateParams.scalableModePipeLock = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(VD_CONTROL_STATE)(tempCmdBuffer)); + } + + SETPAR_AND_ADDCMD(VDENC_PIPE_MODE_SELECT, m_vdencItf, tempCmdBuffer); + + // for Gen11+, we need to add MFX wait for both KIN and VRT before and after HCP Pipemode select... + auto &mfxWaitParams = m_miItf->MHW_GETPAR_F(MFX_WAIT)(); + mfxWaitParams = {}; + mfxWaitParams.iStallVdboxPipeline = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MFX_WAIT)(tempCmdBuffer)); + SETPAR_AND_ADDCMD(HCP_PIPE_MODE_SELECT, m_hcpItf, tempCmdBuffer); + mfxWaitParams = {}; + mfxWaitParams.iStallVdboxPipeline = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MFX_WAIT)(tempCmdBuffer)); + + ENCODE_CHK_STATUS_RETURN(AddPicStateWithTile(*tempCmdBuffer)); + + SETPAR_AND_ADDCMD(HCP_TILE_CODING, m_hcpItf, tempCmdBuffer); + + ENCODE_CHK_STATUS_RETURN(AddAQMCommands(*tempCmdBuffer)); + ENCODE_CHK_STATUS_RETURN(AddSlicesCommandsInTile(*tempCmdBuffer)); + + //HCP unLock for multiple pipe mode + if (m_pipeline->GetPipeNum() > 1) + { + auto &vdControlStateParams = m_miItf->MHW_GETPAR_F(VD_CONTROL_STATE)(); + vdControlStateParams = {}; + vdControlStateParams.scalableModePipeUnlock = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(VD_CONTROL_STATE)(tempCmdBuffer)); + } + + m_flushCmd = waitHevc; + SETPAR_AND_ADDCMD(VD_PIPELINE_FLUSH, m_vdencItf, tempCmdBuffer); + + ENCODE_CHK_STATUS_RETURN(EnsureAllCommandsExecuted(*tempCmdBuffer)); + + if (!m_osInterface->bUsesPatchList) + { + // For 2nd level BB, we must use tileLevelBatchBuffer to prevent adding Epilogue before MI_BATCH_BUFFER_END + ENCODE_CHK_NULL_RETURN(tileLevelBatchBuffer); + tileLevelBatchBuffer->iCurrent = tempCmdBuffer->iOffset; + tileLevelBatchBuffer->iRemaining = tempCmdBuffer->iRemaining; + ENCODE_CHK_STATUS_RETURN(m_miItf->AddMiBatchBufferEnd(nullptr, tileLevelBatchBuffer)); + HalOcaInterfaceNext::OnSubLevelBBStart( + cmdBuffer, + m_osInterface->pOsContext, + &tempCmdBuffer->OsResource, + 0, + false, + tempCmdBuffer->iOffset); + HalOcaInterfaceNext::On1stLevelBBEnd(*tempCmdBuffer, *m_osInterface); + +#if USE_CODECHAL_DEBUG_TOOL + if (tempCmdBuffer->pCmdPtr && tempCmdBuffer->pCmdBase && + tempCmdBuffer->pCmdPtr > tempCmdBuffer->pCmdBase) + { + CodechalDebugInterface *debugInterface = m_pipeline->GetDebugInterface(); + std::string name("TileLevelBatchBuffer"); + name += "Row" + std::to_string(tileRow) + "Col" + std::to_string(tileCol); + + ENCODE_CHK_STATUS_RETURN(debugInterface->DumpData( + tempCmdBuffer->pCmdBase, + (uint32_t)(4 * (tempCmdBuffer->pCmdPtr - tempCmdBuffer->pCmdBase)), + CodechalDbgAttr::attrCmdBufferMfx, + name.c_str())); + } +#endif + } + + // End patching tile level batch cmds + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, EndPatchTileLevelBatch); + + return eStatus; +} + +MOS_STATUS HevcVdencPktXe2_Lpm_Base::SendHwSliceEncodeCommand(const PCODEC_ENCODER_SLCDATA slcData, const uint32_t currSlcIdx, MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + auto eStatus = MOS_STATUS_SUCCESS; + eStatus = HevcVdencPkt::SendHwSliceEncodeCommand(slcData, currSlcIdx, cmdBuffer); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(HevcFeatureIDs::hevcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + SETPAR_AND_ADDCMD(AQM_SLICE_STATE, m_aqmItf, &cmdBuffer); + } + + return eStatus; +} + +MOS_STATUS HevcVdencPktXe2_Lpm_Base::Completed(void *mfxStatus, void *rcsStatus, void *statusReport) +{ + ENCODE_FUNC_CALL(); + auto eStatus = MOS_STATUS_SUCCESS; + eStatus = HevcVdencPkt::Completed(mfxStatus, rcsStatus, statusReport); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(HevcFeatureIDs::hevcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + EncodeStatusReportData *statusReportData = (EncodeStatusReportData *)statusReport; + uint32_t statBufIdx = statusReportData->currOriginalPic.FrameIdx; + if (m_basicFeature->m_hevcPicParams->QualityInfoSupportFlags.fields.enable_frame) + { + ENCODE_CHK_STATUS_RETURN(aqmFeature->ReportQualityInfoFrame(statBufIdx, *statusReportData)); + } +#if _MEDIA_RESERVED +#if USE_CODECHAL_DEBUG_TOOL + ENCODE_CHK_STATUS_RETURN(aqmFeature->DumpVdaqmOutput(statBufIdx, *statusReportData)); +#endif +#endif + } + + return eStatus; +} + +MOS_STATUS HevcVdencPktXe2_Lpm_Base::EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + + // Send MI_FLUSH command + auto &flushDwParams = m_miItf->MHW_GETPAR_F(MI_FLUSH_DW)(); + flushDwParams = {}; + flushDwParams.bVideoPipelineCacheInvalidate = true; + auto *skuTable = m_hwInterface->GetSkuTable(); + if (skuTable && MEDIA_IS_SKU(skuTable, FtrEnablePPCFlush)) + { + // Add PPC fulsh + flushDwParams.bEnablePPCFlush = true; + } + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FLUSH_DW)(&cmdBuffer)); + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VD_PIPELINE_FLUSH, HevcVdencPktXe2_Lpm_Base) +{ + HevcVdencPkt::MHW_SETPAR_F(VD_PIPELINE_FLUSH)(params); + + auto aqmFeature = dynamic_cast(m_featureManager->GetFeature(HevcFeatureIDs::hevcAqm)); + ENCODE_CHK_NULL_RETURN(aqmFeature); + if (aqmFeature->IsEnabled()) + { + switch (m_flushCmd) + { + case waitVdenc: + case waitHevcVdenc: + params.waitDoneVDAQM = true; + params.flushVDAQM = true; + break; + default: + break; + } + } + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktXe2_Lpm_Base::EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER *cmdBuffer) +{ + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(cmdBuffer); + ENCODE_CHK_STATUS_RETURN(HevcVdencPkt::EndStatusReport(srType, cmdBuffer)); + + MediaPerfProfiler *perfProfiler = MediaPerfProfiler::Instance(); + ENCODE_CHK_NULL_RETURN(perfProfiler); + + //store bitstream size to UMD profiler + ENCODE_CHK_NULL_RETURN(m_hcpItf); + auto mmioRegisters = m_hcpItf->GetMmioRegisters(m_vdboxIndex); + ENCODE_CHK_STATUS_RETURN(perfProfiler->AddStoreBitstreamSizeCmd( + (void *)m_pipeline, m_osInterface, m_miItf, cmdBuffer, mmioRegisters->hcpEncBitstreamBytecountFrameRegOffset)); +#if _MEDIA_RESERVED + //store quality metric to UMD profiler + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeAqm, HevcFeatureIDs::hevcAqm, AddStoreQualityMetricCmd, (void *)m_pipeline, m_osInterface, m_miItf, cmdBuffer); +#endif + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_xe2_lpm_base.h new file mode 100644 index 0000000000..1b23a69d13 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_xe2_lpm_base.h @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_hevc_vdenc_packet_xe2_lpm_base.h +//! \brief Defines the interface to adapt to hevc vdenc encode pipeline Xe2 HPM Base +//! + +#ifndef __CODECHAL_HEVC_VDENC_PACKET_XE2_LPM_BASE_H__ +#define __CODECHAL_HEVC_VDENC_PACKET_XE2_LPM_BASE_H__ + +#include "encode_hevc_vdenc_packet.h" +#include "mhw_vdbox_aqm_impl_xe2_lpm.h" + +namespace encode +{ +class HevcVdencPktXe2_Lpm_Base : public HevcVdencPkt, public mhw::vdbox::aqm::Itf::ParSetting +{ +public: + HevcVdencPktXe2_Lpm_Base(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) : HevcVdencPkt(pipeline, task, hwInterface) + { + m_aqmItf = std::make_shared(m_osInterface); + } + + MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override; + +protected: + MOS_STATUS AddPicStateWithNoTile(MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS AddAQMCommands(MOS_COMMAND_BUFFER &cmdBuffer); + MOS_STATUS AddOneTileCommands(MOS_COMMAND_BUFFER &cmdBuffer, uint32_t tileRow, uint32_t tileCol, uint32_t tileRowPass) override; + MOS_STATUS SendHwSliceEncodeCommand(const PCODEC_ENCODER_SLCDATA slcData, const uint32_t currSlcIdx, MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS EnsureAllCommandsExecuted(MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER *cmdBuffer) override; + + MHW_SETPAR_DECL_HDR(VD_PIPELINE_FLUSH); + + std::shared_ptr m_aqmItf = nullptr; + +MEDIA_CLASS_DEFINE_END(encode__HevcVdencPktXe2_Lpm_Base) +}; + +} + +#endif //__CODECHAL_HEVC_VDENC_PACKET_XE2_LPM_BASE_H__ diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/media_srcs.cmake new file mode 100644 index 0000000000..c61c32b481 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/packet/media_srcs.cmake @@ -0,0 +1,52 @@ +# Copyright (c) 2021, 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. + +#encode + +if("${HEVC_Encode_VDEnc_Supported}" STREQUAL "yes") +set(TMP_SOURCES_ + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_packet_xe2_lpm_base.cpp +) + +set(TMP_HEADERS_ + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_packet_xe2_lpm_base.h +) + +set(SOFTLET_ENCODE_HEVC_HEADERS_ + ${SOFTLET_ENCODE_HEVC_HEADERS_} + ${TMP_HEADERS_} +) + +set(SOFTLET_ENCODE_HEVC_SOURCES_ + ${SOFTLET_ENCODE_HEVC_SOURCES_} + ${TMP_SOURCES_} +) + +source_group( CodecHalNext\\Xe2_LPM_base\\Encode FILES ${TMP_SOURCES_} ${TMP_HEADERS_} ) + +set(TMP_SOURCES_ "") +set(TMP_HEADERS_ "") + +endif() + +set(SOFTLET_ENCODE_HEVC_PRIVATE_INCLUDE_DIRS_ + ${SOFTLET_ENCODE_HEVC_PRIVATE_INCLUDE_DIRS_} + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.cpp new file mode 100644 index 0000000000..b44a342e35 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.cpp @@ -0,0 +1,80 @@ +/* +* Copyright (c) 2021-2024, 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. +*/ +//! +//! \file encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.cpp +//! \brief Defines the interface to adapt to hevc vdenc encode pipeline Xe2_LPM+ +//! + +#include "encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h" +#include "encode_utils.h" + +EncodeHevcVdencPipelineAdapterXe2_Lpm_Base::EncodeHevcVdencPipelineAdapterXe2_Lpm_Base( + CodechalHwInterfaceNext *hwInterface, + CodechalDebugInterface *debugInterface) + : EncoderPipelineAdapter(hwInterface, debugInterface) +{ + ENCODE_CHK_NULL_NO_STATUS_RETURN(m_osInterface); + m_osInterface->pfnVirtualEngineSupported(m_osInterface, false, true); + Mos_SetVirtualEngineSupported(m_osInterface, true); + m_vdencEnabled = true; +} + +MOS_STATUS EncodeHevcVdencPipelineAdapterXe2_Lpm_Base::Allocate(CodechalSetting *codecHalSettings) +{ + ENCODE_FUNC_CALL(); + + m_encoder = std::make_shared(m_hwInterface, m_debugInterface); + ENCODE_CHK_NULL_RETURN(m_encoder); + + return m_encoder->Init(codecHalSettings); +} + +MOS_STATUS EncodeHevcVdencPipelineAdapterXe2_Lpm_Base::ResolveMetaData(PMOS_RESOURCE pInput, PMOS_RESOURCE pOutput) +{ + ENCODE_FUNC_CALL(); + + return m_encoder->ExecuteResolveMetaData(pInput, pOutput); +} + +MOS_STATUS EncodeHevcVdencPipelineAdapterXe2_Lpm_Base::Execute(void *params) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(m_encoder->Prepare(params)); + return m_encoder->Execute(); +} + +MOS_STATUS EncodeHevcVdencPipelineAdapterXe2_Lpm_Base::GetStatusReport( + void *status, + uint16_t numStatus) +{ + ENCODE_FUNC_CALL(); + + return m_encoder->GetStatusReport(status, numStatus); +} + +void EncodeHevcVdencPipelineAdapterXe2_Lpm_Base::Destroy() +{ + ENCODE_FUNC_CALL(); + + m_encoder->Destroy(); +} diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h new file mode 100644 index 0000000000..8aa5fea6d5 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h @@ -0,0 +1,59 @@ +/* +* Copyright (c) 2021-2024, 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. +*/ +//! +//! \file encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h +//! \brief Defines the interface to adapt to hevc vdenc encode pipeline Xe2_LPM+ +//! + +#ifndef __ENCODE_HEVC_VDENC_PIPELINE_ADAPTER_XE2_LPM_BASE_H__ +#define __ENCODE_HEVC_VDENC_PIPELINE_ADAPTER_XE2_LPM_BASE_H__ + +#include "encode_pipeline_adapter.h" +#include "encode_hevc_vdenc_pipeline_xe2_lpm_base.h" + +class EncodeHevcVdencPipelineAdapterXe2_Lpm_Base : public EncoderPipelineAdapter +{ +public: + EncodeHevcVdencPipelineAdapterXe2_Lpm_Base( + CodechalHwInterfaceNext * hwInterface, + CodechalDebugInterface *debugInterface); + + virtual ~EncodeHevcVdencPipelineAdapterXe2_Lpm_Base() {} + + virtual MOS_STATUS Allocate(CodechalSetting *codecHalSettings) override; + + virtual MOS_STATUS ResolveMetaData(PMOS_RESOURCE pInput, PMOS_RESOURCE pOutput) override; + + virtual MOS_STATUS Execute(void *params) override; + + virtual MOS_STATUS GetStatusReport(void *status, uint16_t numStatus) override; + + virtual void Destroy() override; + +protected: + std::shared_ptr m_encoder = nullptr; + +MEDIA_CLASS_DEFINE_END(EncodeHevcVdencPipelineAdapterXe2_Lpm_Base) +}; +#endif // !__ENCODE_HEVC_VDENC_PIPELINE_ADAPTER_XE2_LPM_BASE_H__ + + diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe2_lpm_base.cpp b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe2_lpm_base.cpp new file mode 100644 index 0000000000..9969a9e713 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe2_lpm_base.cpp @@ -0,0 +1,374 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_hevc_vdenc_pipeline_xe2_lpm_base.cpp +//! \brief Defines the interface for hevc vdenc encode pipeline Xe2_LPM+ +//! + +#include "encode_hevc_vdenc_pipeline_xe2_lpm_base.h" +#include "encode_utils.h" +#include "encode_hevc_tile_replay_packet.h" +#include "encode_hevc_vdenc_packet_xe2_lpm_base.h" +#include "encode_huc_la_init_packet.h" +#include "encode_huc_la_update_packet.h" +#include "encode_huc_brc_init_packet.h" +#include "encode_huc_brc_update_packet.h" +#include "encode_pak_integrate_packet.h" +#include "encode_status_report_defs.h" +#include "encode_scalability_defs.h" +#include "codechal_debug.h" +#include "encode_mem_compression_xe_lpm_plus_base.h" +#include "encode_hevc_vdenc_feature_manager_xe2_lpm_base.h" +#include "encode_preenc_packet.h" +#include "encode_vdenc_lpla_analysis.h" + +namespace encode { + +HevcVdencPipelineXe2_Lpm_Base::HevcVdencPipelineXe2_Lpm_Base( + CodechalHwInterfaceNext *hwInterface, + CodechalDebugInterface *debugInterface) + : HevcVdencPipeline(hwInterface, debugInterface) +{ + +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::Init(void *settings) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(settings); + + ENCODE_CHK_STATUS_RETURN(Initialize(settings)); + + MediaTask* task = CreateTask(MediaTask::TaskType::cmdTask); + ENCODE_CHK_NULL_RETURN(task); + + RUN_FEATURE_INTERFACE_RETURN(HevcVdencPreEnc, FeatureIDs::preEncFeature, IsEnabled, m_preEncEnabled); + if (m_preEncEnabled) + { + EncodePreEncPacket *hevcPreEncpkt = MOS_New(EncodePreEncPacket, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(encodePreEncPacket, hevcPreEncpkt)); + ENCODE_CHK_STATUS_RETURN(hevcPreEncpkt->Init()); + + RUN_FEATURE_INTERFACE_RETURN(HevcVdencPreEnc, HevcFeatureIDs::preEncFeature, GetEncodeMode, m_encodeMode); + if (m_encodeMode == MediaEncodeMode::MANUAL_RES_PRE_ENC) + { + return MOS_STATUS_SUCCESS; + } + } + + HucLaInitPkt *laInitpkt = MOS_New(HucLaInitPkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucLaInit, laInitpkt)); + ENCODE_CHK_STATUS_RETURN(laInitpkt->Init()); + + HucLaUpdatePkt *laUpdatepkt = MOS_New(HucLaUpdatePkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucLaUpdate, laUpdatepkt)); + ENCODE_CHK_STATUS_RETURN(laUpdatepkt->Init()); + + HucBrcInitPkt *brcInitpkt = MOS_New(HucBrcInitPkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucBrcInit, brcInitpkt)); + ENCODE_CHK_STATUS_RETURN(brcInitpkt->Init()); + + HucBrcUpdatePkt *brcUpdatepkt = MOS_New(HucBrcUpdatePkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucBrcUpdate, brcUpdatepkt)); + ENCODE_CHK_STATUS_RETURN(brcUpdatepkt->Init()); + + HevcVdencPktXe2_Lpm_Base *hevcVdencpkt = MOS_New(HevcVdencPktXe2_Lpm_Base, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(hevcVdencPacket, hevcVdencpkt)); + ENCODE_CHK_STATUS_RETURN(hevcVdencpkt->Init()); + + HevcPakIntegratePkt *pakIntPkt = MOS_New(HevcPakIntegratePkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(hevcPakIntegrate, pakIntPkt)); + ENCODE_CHK_STATUS_RETURN(pakIntPkt->Init()); + + HevcVdencPicPacket* hevcVdencPicPkt = MOS_New(HevcVdencPicPacket, task, hevcVdencpkt); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(hevcVdencPicPacket, hevcVdencPicPkt)); + ENCODE_CHK_STATUS_RETURN(hevcVdencPicPkt->Init()); + + /* + HucBrcTileRowUpdatePkt *brcTileRowUpdatePkt = MOS_New(HucBrcTileRowUpdatePkt, this, task, m_hwInterface); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(HucBrcTileRowUpdate, brcTileRowUpdatePkt)); + ENCODE_CHK_STATUS_RETURN(brcTileRowUpdatePkt->Init()); + */ + + HevcVdencTileRowPkt* hevcVdencTileRowPkt = MOS_New(HevcVdencTileRowPkt, task, hevcVdencpkt); + ENCODE_CHK_STATUS_RETURN(RegisterPacket(hevcVdencTileRowPacket, hevcVdencTileRowPkt)); + ENCODE_CHK_STATUS_RETURN(hevcVdencTileRowPkt->Init()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::CreateFeatureManager() +{ + ENCODE_FUNC_CALL(); + m_featureManager = MOS_New(EncodeHevcVdencFeatureManagerXe2_Lpm_Base, m_allocator, m_hwInterface, m_trackedBuf, m_recycleBuf); + ENCODE_CHK_NULL_RETURN(m_featureManager); + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::GetSystemVdboxNumber() +{ + MOS_STATUS eStatus = MOS_STATUS_SUCCESS; + + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(EncodePipeline::GetSystemVdboxNumber()); + + MediaUserSetting::Value outValue; + MOS_STATUS statusKey = MOS_STATUS_SUCCESS; + statusKey = ReadUserSetting( + m_userSettingPtr, + outValue, + "Disable Media Encode Scalability", + MediaUserSetting::Group::Sequence); + + bool disableScalability = false; + if (statusKey == MOS_STATUS_SUCCESS) + { + disableScalability = outValue.Get(); + } + + if (disableScalability) + { + m_numVdbox = 1; + } + + return eStatus; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::Prepare(void *params) +{ + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(params); + EncoderParams *encodeParams = (EncoderParams *)params; + + PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams = static_cast(encodeParams->pSeqParams); + ENCODE_CHK_NULL_RETURN(hevcSeqParams); + + ENCODE_CHK_STATUS_RETURN(HevcVdencPipeline::Prepare(params)); + + PCODEC_HEVC_ENCODE_PICTURE_PARAMS picParams = static_cast(encodeParams->pPicParams); + ENCODE_CHK_NULL_RETURN(picParams); + + auto feature = dynamic_cast(m_featureManager->GetFeature(FeatureIDs::basicFeature)); + ENCODE_CHK_NULL_RETURN(feature); + + uint16_t numTileRows = 0; + uint16_t numTileColumns = 0; + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, FeatureIDs::encodeTile, GetTileRowColumns, numTileRows, numTileColumns); + + bool enableTileReplay = false; + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, FeatureIDs::encodeTile, IsTileReplayEnabled, enableTileReplay); + + // ToDo: How to set the Media Function + ENCODE_CHK_STATUS_RETURN(SwitchContext(feature->m_outputChromaFormat, numTileRows, numTileColumns, enableTileReplay)); + + // Only multi-pipe contain tile report data + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, FeatureIDs::encodeTile, SetTileReportDataVaild, (GetPipeNum() > 1)); + + EncoderStatusParameters inputParameters = {}; + MOS_ZeroMemory(&inputParameters, sizeof(EncoderStatusParameters)); + + + inputParameters.statusReportFeedbackNumber = picParams->StatusReportFeedbackNumber; + inputParameters.codecFunction = encodeParams->ExecCodecFunction; + inputParameters.currRefList = feature->m_ref.GetCurrRefList(); + inputParameters.picWidthInMb = feature->m_picWidthInMb; + inputParameters.frameFieldHeightInMb = feature->m_frameFieldHeightInMb; + inputParameters.currOriginalPic = feature->m_currOriginalPic; + inputParameters.pictureCodingType = feature->m_pictureCodingType; + inputParameters.numUsedVdbox = m_numVdbox; + inputParameters.hwWalker = false; + inputParameters.maxNumSlicesAllowed = 0; + inputParameters.numberTilesInFrame = (picParams->num_tile_columns_minus1 + 1)*(picParams->num_tile_rows_minus1 + 1); + + m_statusReport->Init(&inputParameters); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::ActivateVdencVideoPackets() +{ + ENCODE_FUNC_CALL(); + + bool immediateSubmit = !m_singleTaskPhaseSupported; + + if (m_preEncEnabled) + { + ENCODE_CHK_STATUS_RETURN(ActivatePacket(encodePreEncPacket, immediateSubmit, 0, 0)); + if (m_encodeMode == MediaEncodeMode::MANUAL_RES_PRE_ENC) + { + m_activePacketList.back().immediateSubmit = true; + return MOS_STATUS_SUCCESS; + } + } + + return HevcVdencPipeline::ActivateVdencVideoPackets(); +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::Execute() +{ + ENCODE_FUNC_CALL(); + + PERF_UTILITY_AUTO(__FUNCTION__, PERF_ENCODE, PERF_LEVEL_HAL); + + bool isTileReplayEnabled = false; + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, FeatureIDs::encodeTile, IsTileReplayEnabled, isTileReplayEnabled); + if (isTileReplayEnabled) + { + ENCODE_CHK_STATUS_RETURN(ActivateVdencTileReplayVideoPackets()); + } + else + { + ENCODE_CHK_STATUS_RETURN(ActivateVdencVideoPackets()); + } + + ENCODE_CHK_STATUS_RETURN(ExecuteActivePackets()); + + ENCODE_CHK_STATUS_RETURN(ResetParams()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::GetStatusReport(void *status, uint16_t numStatus) +{ + ENCODE_FUNC_CALL(); + m_statusReport->GetReport(numStatus, status); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::Destroy() +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(Uninitialize()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::Initialize(void *settings) +{ + ENCODE_FUNC_CALL(); + + CodechalSetting *codecSettings = (CodechalSetting *)settings; + ENCODE_CHK_NULL_RETURN(m_hwInterface); + ENCODE_CHK_STATUS_RETURN(m_hwInterface->Initialize(codecSettings)); + ENCODE_CHK_STATUS_RETURN(InitMmcState()); + codecSettings ->isMmcEnabled = m_mmcState->IsMmcEnabled(); + ENCODE_CHK_STATUS_RETURN(HevcVdencPipeline::Initialize(settings)); + + CODECHAL_DEBUG_TOOL( + if (m_debugInterface != nullptr) { + MOS_Delete(m_debugInterface); + } + m_debugInterface = MOS_New(CodechalDebugInterface); + ENCODE_CHK_NULL_RETURN(m_debugInterface); + ENCODE_CHK_NULL_RETURN(m_mediaCopyWrapper); + ENCODE_CHK_STATUS_RETURN( + m_debugInterface->Initialize(m_hwInterface, m_codecFunction, m_mediaCopyWrapper)); + + if (m_statusReportDebugInterface != nullptr) { + MOS_Delete(m_statusReportDebugInterface); + } + m_statusReportDebugInterface = MOS_New(CodechalDebugInterface); + ENCODE_CHK_NULL_RETURN(m_statusReportDebugInterface); + ENCODE_CHK_STATUS_RETURN( + m_statusReportDebugInterface->Initialize(m_hwInterface, m_codecFunction, m_mediaCopyWrapper));); + ENCODE_CHK_STATUS_RETURN(GetSystemVdboxNumber()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::Uninitialize() +{ + ENCODE_FUNC_CALL(); + + if (m_mmcState != nullptr) + { + MOS_Delete(m_mmcState); + } + + ENCODE_CHK_STATUS_RETURN(HevcVdencPipeline::Uninitialize()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::ResetParams() +{ + ENCODE_FUNC_CALL(); + + m_currRecycledBufIdx = + (m_currRecycledBufIdx + 1) % CODECHAL_ENCODE_RECYCLED_BUFFER_NUM; + + if (m_currRecycledBufIdx == 0) + { + MOS_ZeroMemory(m_recycledBufStatusNum, sizeof(m_recycledBufStatusNum)); + } + + auto feature = dynamic_cast(m_featureManager->GetFeature(FeatureIDs::basicFeature)); + ENCODE_CHK_NULL_RETURN(feature); + + // Only update user features for first frame. + if (feature->m_frameNum == 0) + { + ENCODE_CHK_STATUS_RETURN(UserFeatureReport()); + } + + feature->m_frameNum++; + + RUN_FEATURE_INTERFACE_RETURN(VdencLplaAnalysis, HevcFeatureIDs::vdencLplaAnalysisFeature, UpdateLaDataIdx); + + ENCODE_CHK_STATUS_RETURN(m_statusReport->Reset()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::UserFeatureReport() +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(HevcVdencPipeline::UserFeatureReport()); + +#if (_DEBUG || _RELEASE_INTERNAL) + ReportUserSettingForDebug( + m_userSettingPtr, + "Enable Encode VE CtxBasedScheduling", + MOS_VE_CTXBASEDSCHEDULING_SUPPORTED(m_osInterface), + MediaUserSetting::Group::Sequence); +#endif + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPipelineXe2_Lpm_Base::InitMmcState() +{ +#ifdef _MMC_SUPPORTED + ENCODE_CHK_NULL_RETURN(m_hwInterface); + m_mmcState = MOS_New(EncodeMemCompXe_Lpm_Plus_Base, m_hwInterface); + ENCODE_CHK_NULL_RETURN(m_mmcState); +#endif + return MOS_STATUS_SUCCESS; +} + +} + diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe2_lpm_base.h b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe2_lpm_base.h new file mode 100644 index 0000000000..d02eee82d1 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe2_lpm_base.h @@ -0,0 +1,81 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_hevc_vdenc_pipeline_xe2_lpm_base.h +//! \brief Defines the interface for hevc vdenc encode pipeline Xe2_LPM+ +//! +#ifndef __ENCODE_HEVC_VDENC_PIPELINE_XE2_LPM_BASE_H__ +#define __ENCODE_HEVC_VDENC_PIPELINE_XE2_LPM_BASE_H__ + +#include "encode_hevc_vdenc_pipeline.h" + +namespace encode { + +class HevcVdencPipelineXe2_Lpm_Base : public HevcVdencPipeline +{ +public: + //! + //! \brief EncodePipeline constructor + //! \param [in] hwInterface + //! Pointer to CodechalHwInterface + //! \param [in] debugInterface + //! Pointer to CodechalDebugInterface + //! + HevcVdencPipelineXe2_Lpm_Base( + CodechalHwInterfaceNext * hwInterface, + CodechalDebugInterface *debugInterface); + + virtual ~HevcVdencPipelineXe2_Lpm_Base() {} + + virtual MOS_STATUS Init(void *settings) override; + + virtual MOS_STATUS Prepare(void *params) override; + + virtual MOS_STATUS Execute() override; + + virtual MOS_STATUS GetStatusReport(void *status, uint16_t numStatus) override; + + virtual MOS_STATUS Destroy() override; + + virtual MOS_STATUS InitMmcState(); + +protected: + virtual MOS_STATUS CreateFeatureManager() override; + virtual MOS_STATUS Initialize(void *settings) override; + virtual MOS_STATUS Uninitialize() override; + virtual MOS_STATUS ResetParams(); + virtual MOS_STATUS ActivateVdencVideoPackets() override; + virtual MOS_STATUS GetSystemVdboxNumber() override; + + virtual MOS_STATUS UserFeatureReport() override; + + static const uint32_t m_brcHistoryBufSize = 2304; //!< BRC history buffer size + + bool m_preEncEnabled = false; + uint32_t m_encodeMode = 0; + +MEDIA_CLASS_DEFINE_END(encode__HevcVdencPipelineXe2_Lpm_Base) +}; + +} +#endif // !__ENCODE_HEVC_VDENC_PIPELINE_XE2_LPM_BASE_H__ + diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/media_srcs.cmake new file mode 100644 index 0000000000..fd67d12f32 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/hevc/pipeline/media_srcs.cmake @@ -0,0 +1,53 @@ +# Copyright (c) 2021, 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. + +if ("${HEVC_Encode_VDEnc_Supported}" STREQUAL "yes") +set(TMP_SOURCES_ + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_pipeline_xe2_lpm_base.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.cpp + +) + +set(TMP_HEADERS_ + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_pipeline_xe2_lpm_base.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h +) + +set(SOFTLET_ENCODE_HEVC_HEADERS_ + ${SOFTLET_ENCODE_HEVC_HEADERS_} + ${TMP_HEADERS_} +) + +set(SOFTLET_ENCODE_HEVC_SOURCES_ + ${SOFTLET_ENCODE_HEVC_SOURCES_} + ${TMP_SOURCES_} +) + +source_group( CodecHalNext\\Xe2_LPM_base\\Encode FILES ${TMP_SOURCES_} ${TMP_HEADERS_} ) + +set(TMP_SOURCES_ "") +set(TMP_HEADERS_ "") + +endif() + +set(SOFTLET_ENCODE_HEVC_PRIVATE_INCLUDE_DIRS_ + ${SOFTLET_ENCODE_HEVC_PRIVATE_INCLUDE_DIRS_} + ${CMAKE_CURRENT_LIST_DIR} +) diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/media_srcs.cmake new file mode 100644 index 0000000000..7d5c984c96 --- /dev/null +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/enc/media_srcs.cmake @@ -0,0 +1,21 @@ +# Copyright (c) 2021, 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. + +media_include_subdirectory(hevc) \ No newline at end of file diff --git a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/media_srcs.cmake b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/media_srcs.cmake index 6d33f0d773..ee8f49f4a2 100644 --- a/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/media_srcs.cmake +++ b/media_softlet/agnostic/Xe2_M_plus/Xe2_LPM_base/codec/hal/media_srcs.cmake @@ -20,3 +20,4 @@ media_include_subdirectory(dec) media_include_subdirectory(shared) +media_include_subdirectory(enc) \ No newline at end of file diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_aqm.cpp b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_aqm.cpp new file mode 100644 index 0000000000..8ab2e8be05 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_aqm.cpp @@ -0,0 +1,141 @@ +/* +* Copyright (c) 2021-2024, 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,Av1EncodeTile +* 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. +*/ +//! +//! \file encode_avc_aqm.cpp +//! \brief Defines the common interface for avc aqm +//! + +#include "encode_avc_aqm.h" +#include "encode_avc_vdenc_feature_manager.h" +#include "encode_avc_basic_feature.h" + +namespace encode +{ +AvcEncodeAqm::AvcEncodeAqm(MediaFeatureManager *featureManager, + EncodeAllocator * allocator, + CodechalHwInterfaceNext * hwInterface, + void * constSettings) : EncodeAqmFeature(featureManager, allocator, hwInterface, constSettings) +{ + auto encFeatureManager = dynamic_cast(featureManager); + ENCODE_CHK_NULL_NO_STATUS_RETURN(encFeatureManager); + + m_basicFeature = dynamic_cast(encFeatureManager->GetFeature(FeatureIDs::basicFeature)); + ENCODE_CHK_NULL_NO_STATUS_RETURN(m_basicFeature); + + m_numTiles = 1; +}; + +MOS_STATUS AvcEncodeAqm::Update(void* params) +{ + auto basicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(basicFeature); + if (basicFeature->m_picParam->QualityInfoSupportFlags.fields.enable_frame) + { + m_enabled = true; + basicFeature->m_suppressReconPicSupported = false; + } + m_numTiles = 1; + m_tile_width[0] = (uint16_t)m_basicFeature->m_oriFrameWidth; + m_tile_height[0] = (uint16_t)m_basicFeature->m_oriFrameHeight; +#if USE_CODECHAL_DEBUG_TOOL + UpdateFrameDisplayOrder(basicFeature->m_pictureCodingType, basicFeature->m_picParam->CurrFieldOrderCnt[0] / 2, basicFeature->m_seqParam->GopPicSize); +#endif + ENCODE_CHK_STATUS_RETURN(EncodeAqmFeature::Update(params)); + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS AvcEncodeAqm::Init(void *setting) +{ + ENCODE_FUNC_CALL(); + ENCODE_CHK_NULL_RETURN(setting); + + ENCODE_CHK_STATUS_RETURN(EncodeAqmFeature::Init(setting)); + + auto basicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(basicFeature); + + if (m_enabled) + { + // Assuming AvcBasicFeature is already initialized, if VDAQM is in use, enable deblocking/recon generation for all frames + basicFeature->m_suppressReconPicSupported = false; + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(AQM_PIC_STATE, AvcEncodeAqm) +{ + ENCODE_CHK_STATUS_RETURN(EncodeAqmFeature::MHW_SETPAR_F(AQM_PIC_STATE)(params)); + if (m_enabled) + { + params.frameWidthInPixelMinus1 = MOS_ALIGN_CEIL(m_basicFeature->m_oriFrameWidth, 16) - 1; + params.FrameHeightInPixelMinus1 = MOS_ALIGN_CEIL(m_basicFeature->m_oriFrameHeight, 16) - 1; + params.lcuSize = LCU_SIZE_16X16; + params.codectype = CODECTYPE_AVC; + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(AQM_SLICE_STATE, AvcEncodeAqm) +{ + auto basicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(basicFeature); + + auto sliceParams = &basicFeature->m_sliceParams[basicFeature->m_curNumSlices]; + auto frameHeight = static_cast(CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(basicFeature->m_seqParam->FrameHeight)); + auto frameWidth = static_cast(CODECHAL_GET_WIDTH_IN_MACROBLOCKS(basicFeature->m_seqParam->FrameWidth)); + auto nextsliceMbStartYPosition = (sliceParams->first_mb_in_slice + sliceParams->NumMbsForSlice) / frameWidth; + + params.tileSliceStartLcuMbX = 0; + params.tileSliceStartLcuMbY = sliceParams->first_mb_in_slice / frameWidth; + params.nextTileSliceStartLcuMbX = 0; + params.nextTileSliceStartLcuMbY = nextsliceMbStartYPosition > frameHeight ? frameHeight : nextsliceMbStartYPosition; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(MFX_AVC_IMG_STATE, AvcEncodeAqm) +{ + params.vdaqmEnable = m_enabled; + + return MOS_STATUS_SUCCESS; +} + +#if USE_CODECHAL_DEBUG_TOOL +MOS_STATUS AvcEncodeAqm::UpdateFrameDisplayOrder(const uint16_t pictureCodingType, const uint32_t framePOC, const uint32_t gopPicSize) +{ + auto basicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(basicFeature); + if (basicFeature->m_picParam->bIdrPic == 1) + { + m_frameNumPrevious += m_gopSizePrevious; + } + uint32_t displayOrderInGOP = framePOC; + uint32_t displayOrderInSeq = displayOrderInGOP + m_frameNumPrevious; + m_gopSizePrevious = gopPicSize; + m_frameIdxQueue.push(displayOrderInSeq); + return MOS_STATUS_SUCCESS; +} +#endif + +} // namespace encode \ No newline at end of file diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_aqm.h b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_aqm.h new file mode 100644 index 0000000000..5dded08640 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_aqm.h @@ -0,0 +1,62 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_avc_aqm.h +//! \brief Defines the common interface for avc aqm +//! +#ifndef __ENCODE_AVC_AQM_H__ +#define __ENCODE_AVC_AQM_H__ + +#include "encode_aqm_feature.h" +#include "mhw_vdbox_vdenc_itf.h" +#include "mhw_vdbox_mfx_itf.h" + +namespace encode +{ +class AvcEncodeAqm : public EncodeAqmFeature, public mhw::vdbox::mfx::Itf::ParSetting, public mhw::vdbox::vdenc::Itf::ParSetting +{ +public: + AvcEncodeAqm(MediaFeatureManager *featureManager, + EncodeAllocator * allocator, + CodechalHwInterfaceNext * hwInterface, + void * constSettings); + + virtual ~AvcEncodeAqm(){}; + + virtual MOS_STATUS Update(void *params) override; + + virtual MOS_STATUS Init(void *setting) override; + +#if USE_CODECHAL_DEBUG_TOOL + virtual MOS_STATUS UpdateFrameDisplayOrder(const uint16_t pictureCodingType, const uint32_t framePOC, const uint32_t gopPicSize) override; +#endif + + MHW_SETPAR_DECL_HDR(AQM_PIC_STATE); + MHW_SETPAR_DECL_HDR(AQM_SLICE_STATE); + MHW_SETPAR_DECL_HDR(MFX_AVC_IMG_STATE); + +MEDIA_CLASS_DEFINE_END(encode__AvcEncodeAqm) +}; + +} // namespace encode + +#endif // !__ENCODE_AVC_AQM_H__ diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_fastpass.cpp b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_fastpass.cpp new file mode 100644 index 0000000000..b9dd74a2ad --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_fastpass.cpp @@ -0,0 +1,266 @@ +/* +* Copyright (c) 2023, 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. +*/ +//! +//! \file encode_avc_vdenc_fast_pass.cpp +//! \brief Defines the common interface for encode avc Xe2_HPM+ fast pass feature +//! + +#include "encode_avc_vdenc_fastpass.h" +#include "encode_avc_vdenc_feature_manager.h" +#include + +namespace encode +{ + +AvcVdencFastPass::AvcVdencFastPass( + MediaFeatureManager *featureManager, + EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + void *constSettings) : + MediaFeature(constSettings) +{ + auto encFeatureManager = dynamic_cast(featureManager); + ENCODE_CHK_NULL_NO_STATUS_RETURN(encFeatureManager); + + m_basicFeature = dynamic_cast(encFeatureManager->GetFeature(FeatureIDs::basicFeature)); + ENCODE_CHK_NULL_NO_STATUS_RETURN(m_basicFeature); + if (hwInterface) + { + m_userSettingPtr = hwInterface->GetOsInterface()->pfnGetUserSettingInstance(hwInterface->GetOsInterface()); + } + //regkey to control fast pass encode settings + MediaUserSetting::Value outValue; + ReadUserSetting(m_userSettingPtr, + outValue, + "Enable Fast Pass Encode", + MediaUserSetting::Group::Sequence); + + m_enabled = outValue.Get(); + if (m_enabled) + { + MediaUserSetting::Value outValue_ratio; + MediaUserSetting::Value outValue_type; +#if (_DEBUG || _RELEASE_INTERNAL) + + ReadUserSetting(m_userSettingPtr, + outValue_ratio, + "Fast Pass Encode Downscale Ratio", + MediaUserSetting::Group::Sequence); + ReadUserSetting(m_userSettingPtr, + outValue_type, + "Fast Pass Encode Downscale Type", + MediaUserSetting::Group::Sequence); +#endif + + if (outValue_ratio.Get() == 0) + { + m_fastPassShiftIndex = 2; + } + else if (outValue_ratio.Get() == 1) + { + m_fastPassShiftIndex = 1; + } + else + m_fastPassShiftIndex = 2; + m_fastPassDownScaleType = (uint8_t)outValue_type.Get(); + } +} + +MOS_STATUS AvcVdencFastPass::Update(void *params) +{ + if (!m_enabled) + { + return MOS_STATUS_SUCCESS; + } + PCODEC_AVC_ENCODE_SEQUENCE_PARAMS avcSeqParams = m_basicFeature->m_seqParam; + ENCODE_CHK_NULL_RETURN(avcSeqParams); + + m_dsWidth = MOS_ALIGN_FLOOR(avcSeqParams->FrameWidth >> m_fastPassShiftIndex, 16); + m_dsHeight = MOS_ALIGN_FLOOR(avcSeqParams->FrameHeight >> m_fastPassShiftIndex, 16); + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_PIPE_MODE_SELECT, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + params.fastPassEn = m_enabled; + params.fastPassScale = m_fastPassShiftIndex == 2 ? 0 : 1; // fastPassScale:0 indicates 4x4 ds, fastPassScale:1 indicates 2x2 ds + params.DownScaleType = m_fastPassDownScaleType; // DownScaleType:0 indicates bilinear, DownScaleType:1 indicates NN + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_REF_SURFACE_STATE, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + params.width = MOS_ALIGN_FLOOR(m_basicFeature->m_reconSurface.dwWidth >> m_fastPassShiftIndex, 16); + params.height = MOS_ALIGN_FLOOR(m_basicFeature->m_reconSurface.dwHeight >> m_fastPassShiftIndex, 16); + } + + return MOS_STATUS_SUCCESS; +} +MHW_SETPAR_DECL_SRC(VDENC_AVC_IMG_STATE, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + params.pictureHeightMinusOne = (m_dsHeight / 16) - 1; + params.pictureWidth = m_dsWidth / 16; + } + + return MOS_STATUS_SUCCESS; +} +MHW_SETPAR_DECL_SRC(VDENC_WALKER_STATE, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + auto frameHeight = m_dsHeight / 16; + auto frameWidth = m_dsWidth / 16; + + auto sliceParams = &(m_basicFeature->m_sliceParams[m_basicFeature->m_curNumSlices]); + uint32_t MbNums = frameHeight * frameWidth; + auto nextsliceMbStartYPosition = (sliceParams->first_mb_in_slice + MbNums) / frameWidth; + params.tileSliceStartLcuMbY = sliceParams->first_mb_in_slice / frameWidth; + params.nextTileSliceStartLcuMbY = nextsliceMbStartYPosition > frameHeight ? frameHeight : nextsliceMbStartYPosition; + } + + return MOS_STATUS_SUCCESS; +} +MHW_SETPAR_DECL_SRC(MFX_AVC_IMG_STATE, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + uint32_t numMBs = (m_dsWidth / 16) * (m_dsHeight / 16); + params.frameSize = (numMBs > 0xFFFF) ? 0xFFFF : numMBs; + params.frameHeight = (m_dsHeight / 16) - 1; + params.frameWidth = (m_dsWidth / 16) - 1; + } + + return MOS_STATUS_SUCCESS; +} +MHW_SETPAR_DECL_SRC(MFX_AVC_SLICE_STATE, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + auto sliceParams = &(m_basicFeature->m_sliceParams[m_basicFeature->m_curNumSlices]); + uint32_t startMbNum = sliceParams->first_mb_in_slice * (1 + m_basicFeature->m_seqParam->mb_adaptive_frame_field_flag); + uint16_t widthInMb = m_dsWidth / 16; + uint16_t heightInMb = m_dsHeight / 16; + uint16_t MbNums = widthInMb * heightInMb; + + params.sliceHorizontalPosition = startMbNum % widthInMb; + params.sliceVerticalPosition = startMbNum / widthInMb; + params.nextSliceHorizontalPosition = (startMbNum + MbNums) % widthInMb; + params.nextSliceVerticalPosition = (startMbNum + MbNums) / widthInMb; + params.isLastSlice = (startMbNum + MbNums) >= (uint32_t)(widthInMb * heightInMb); + } + + return MOS_STATUS_SUCCESS; +} +MHW_SETPAR_DECL_SRC(VDENC_DS_REF_SURFACE_STATE, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + uint32_t dsWidth4x = m_dsWidth / 4; + uint32_t dsHeight4x = m_dsHeight / 4; + + params.heightStage1 = dsHeight4x; + params.widthStage1 = dsWidth4x; + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_CMD3, AvcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (m_enabled) + { + PCODEC_AVC_ENCODE_SEQUENCE_PARAMS avcSeqParams = m_basicFeature->m_seqParam; + ENCODE_CHK_NULL_RETURN(avcSeqParams); + PCODEC_AVC_ENCODE_PIC_PARAMS avcPicParams = m_basicFeature->m_picParam; + ENCODE_CHK_NULL_RETURN(avcPicParams); + PCODEC_AVC_ENCODE_SLICE_PARAMS avcSliceParams = m_basicFeature->m_sliceParams; + ENCODE_CHK_NULL_RETURN(avcSliceParams); + + auto pictureType = CodecHal_Clip3(0, 2, avcPicParams->CodingType - 1); + uint16_t picWidthInMb = CODECHAL_GET_WIDTH_IN_MACROBLOCKS(m_dsWidth); + uint16_t picHeightInMb = CODECHAL_GET_HEIGHT_IN_MACROBLOCKS(m_dsHeight); + auto fastpass_qp = CodecHal_Clip3(10, 51, avcPicParams->QpY + avcSliceParams->slice_qp_delta); + auto codingType = avcPicParams->CodingType; + // Only do this lambda offset for lower resolution and high QP range. + uint16_t gopP = (avcSeqParams->GopRefDist) ? ((avcSeqParams->GopPicSize - 1) / avcSeqParams->GopRefDist) : 0; + uint16_t gopB = avcSeqParams->GopPicSize - 1 - gopP; + uint16_t numB = ((gopP > 0) ? (gopB / gopP) : 0); + if ((numB != 0) && (picWidthInMb * 16 < 1920) && (picHeightInMb * 16 < 1080) && (fastpass_qp >= 32)) + { + uint8_t index0 = avcPicParams->RefPicFlag ? 0 : 1; + static const std::array< + std::array< + uint8_t, + 3>, + 2> + table = {{ + {0, 1, 1}, + {0, 1, 2}, + }}; + fastpass_qp += table[index0][pictureType]; + fastpass_qp = CodecHal_Clip3(0, 51, fastpass_qp); + + for (auto i = 0; i < 8; i++) + { + params.vdencCmd3Par0[i] = m_CMD3Settings.AvcVdencCMD3ConstSettings_0[i][fastpass_qp]; + } + + if (codingType == I_TYPE || codingType == P_TYPE) + params.vdencCmd3Par19 = m_CMD3Settings.AvcVdencCMD3ConstSettings_3[pictureType][fastpass_qp]; + + uint8_t isIPGOP = avcSeqParams->GopRefDist == 1 ? 1 : 0; + uint8_t codingTypeMinus1 = avcPicParams->CodingType - 1; + uint8_t refPic = avcPicParams->RefPicFlag; + + params.vdencCmd3Par31 = m_CMD3Settings.par31Table[isIPGOP][codingTypeMinus1][refPic][fastpass_qp]; + params.vdencCmd3Par32 = m_CMD3Settings.par32Table[isIPGOP][codingTypeMinus1][refPic][fastpass_qp]; + } + } + + return MOS_STATUS_SUCCESS; +} + +} // namespace encode \ No newline at end of file diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_fastpass.h b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_fastpass.h new file mode 100644 index 0000000000..103ab347fd --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/encode_avc_vdenc_fastpass.h @@ -0,0 +1,91 @@ +/* +* Copyright (c) 2023, 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. +*/ +//! +//! \file encode_avc_vdenc_fastpass.h +//! \brief Defines the common interface for encode avc Xe2_HPM+ basic feature +//! +#ifndef __ENCODE_AVC_VDENC_FASTPASS_H__ +#define __ENCODE_AVC_VDENC_FASTPASS_H__ + +#include "media_feature.h" +#include "encode_allocator.h" +#include "encode_basic_feature.h" +#include "mhw_vdbox_vdenc_itf.h" +#include "encode_avc_basic_feature.h" +#include "encode_avc_vdenc_const_settings.h" + +namespace encode +{ + +class AvcVdencFastPass : public MediaFeature, public mhw::vdbox::vdenc::Itf::ParSetting, public mhw::vdbox::mfx::Itf::ParSetting +{ +public: + AvcVdencFastPass(MediaFeatureManager *featureManager, + EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + void *constSettings); + + virtual ~AvcVdencFastPass() {} + + //! + //! \brief Update encode parameter + //! \param [in] params + //! Pointer to parameters + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + virtual MOS_STATUS Update(void *params) override; + + MHW_SETPAR_DECL_HDR(VDENC_PIPE_MODE_SELECT); + + MHW_SETPAR_DECL_HDR(VDENC_REF_SURFACE_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_AVC_IMG_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_WALKER_STATE); + + MHW_SETPAR_DECL_HDR(MFX_AVC_IMG_STATE); + + MHW_SETPAR_DECL_HDR(MFX_AVC_SLICE_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_DS_REF_SURFACE_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_CMD3); + +protected: + PMOS_INTERFACE m_osInterface = nullptr; //!< Os Inteface + MOS_RESOURCE m_vdencRecDownScaledBuffer = {}; + uint32_t m_dsWidth = 0; + uint32_t m_dsHeight = 0; + + uint8_t m_fastPassShiftIndex = 0; //!< shift index for fast pass encode + uint8_t m_fastPassDownScaleType = 0; //!< downscaleType for fast pass encode + + AvcBasicFeature *m_basicFeature = nullptr; //!< AvcBasicFeature + AvcVdencCMD3ConstSettings m_CMD3Settings; + +MEDIA_CLASS_DEFINE_END(encode__AvcVdencFastPass) +}; + +} // namespace encode + +#endif // !__ENCODE_AVC_VDENC_FASTPASS_H__ \ No newline at end of file diff --git a/media_softlet/agnostic/common/codec/hal/enc/avc/features/media_srcs.cmake b/media_softlet/agnostic/common/codec/hal/enc/avc/features/media_srcs.cmake index e83b3912bf..afd7248f49 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/avc/features/media_srcs.cmake +++ b/media_softlet/agnostic/common/codec/hal/enc/avc/features/media_srcs.cmake @@ -33,6 +33,8 @@ set(TMP_SOURCES_ ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_feature_manager.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_preenc.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_fullenc.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_aqm.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_fastpass.cpp ) set(TMP_HEADERS_ @@ -48,6 +50,8 @@ set(TMP_HEADERS_ ${CMAKE_CURRENT_LIST_DIR}/media_avc_feature_defs.h ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_preenc.h ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_fullenc.h + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_aqm.h + ${CMAKE_CURRENT_LIST_DIR}/encode_avc_vdenc_fastpass.h ) set(SOFTLET_ENCODE_AVC_HEADERS_ diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_aqm.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_aqm.cpp new file mode 100644 index 0000000000..194aaf13b9 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_aqm.cpp @@ -0,0 +1,196 @@ +/* +* Copyright (c) 2021-2024, 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,HevcEncodeTile +* 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. +*/ +//! +//! \file encode_hevc_aqm.cpp +//! \brief Defines the common interface for hevc aqm +//! + +#include "encode_hevc_aqm.h" +#include "encode_hevc_vdenc_feature_manager.h" +#include "encode_hevc_basic_feature.h" + +namespace encode +{ +HevcEncodeAqm::HevcEncodeAqm(MediaFeatureManager *featureManager, + EncodeAllocator * allocator, + CodechalHwInterfaceNext * hwInterface, + void * constSettings) : EncodeAqmFeature(featureManager, allocator, hwInterface, constSettings) +{ + auto encFeatureManager = dynamic_cast(featureManager); + ENCODE_CHK_NULL_NO_STATUS_RETURN(encFeatureManager); + + m_basicFeature = dynamic_cast(encFeatureManager->GetFeature(HevcFeatureIDs::basicFeature)); + ENCODE_CHK_NULL_NO_STATUS_RETURN(m_basicFeature); + + if (HCP_CHROMA_FORMAT_YUV422 == m_basicFeature->m_chromaFormat) + { + m_enabled = false; + ENCODE_VERBOSEMESSAGE("422 is not supported for VDAQM feature!"); + } +}; + +MOS_STATUS HevcEncodeAqm::Update(void *params) +{ + auto basicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(basicFeature); + if (basicFeature->m_hevcPicParams->QualityInfoSupportFlags.fields.enable_frame) + { + m_enabled = true; + } + m_numTiles = (basicFeature->m_hevcPicParams->num_tile_rows_minus1 + 1) * (basicFeature->m_hevcPicParams->num_tile_columns_minus1 + 1); + m_tileBasedEngine = m_numTiles > 1 ? true : false; + uint32_t minCodingBlkSize = basicFeature->m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3; + if (!basicFeature->m_hevcPicParams->tiles_enabled_flag) + { + m_tile_width[0] = (1 << minCodingBlkSize) * (basicFeature->m_hevcSeqParams->wFrameWidthInMinCbMinus1 + 1); + m_tile_height[0] = (1 << minCodingBlkSize) * (basicFeature->m_hevcSeqParams->wFrameHeightInMinCbMinus1 + 1); + } + else + { + for (uint32_t tileIdx = 0; tileIdx < m_numTiles && tileIdx < ENCODE_VDENC_MAX_TILE_NUM; tileIdx++) + { + EncodeTileData tileData = {}; + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, GetTileByIndex, tileData, tileIdx); + m_tile_width[tileIdx] = ((tileData.tileWidthInMinCbMinus1 + 1) << minCodingBlkSize); + m_tile_height[tileIdx] = ((tileData.tileHeightInMinCbMinus1 + 1) << minCodingBlkSize); + } + } +#if USE_CODECHAL_DEBUG_TOOL + UpdateFrameDisplayOrder(basicFeature->m_pictureCodingType, basicFeature->m_hevcPicParams->CurrPicOrderCnt, basicFeature->m_hevcSeqParams->GopPicSize); +#endif + if (basicFeature->m_hevcPicParams->num_tile_columns_minus1 == 1) + { + m_numRowStore = 2; + } + ENCODE_CHK_STATUS_RETURN(EncodeAqmFeature::Update(params)); + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(AQM_PIC_STATE, HevcEncodeAqm) +{ + ENCODE_CHK_STATUS_RETURN(EncodeAqmFeature::MHW_SETPAR_F(AQM_PIC_STATE)(params)); + + params.lcuSize = LCU_SIZE_64X64; + params.codectype = CODECTYPE_HEVC; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HCP_PIC_STATE, HevcEncodeAqm) +{ + + params.vdaqmEnable = m_enabled; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(AQM_TILE_CODING, HevcEncodeAqm) +{ + auto encFeatureManager = dynamic_cast(m_featureManager); + ENCODE_CHK_NULL_RETURN(encFeatureManager); + + auto hevcTile = dynamic_cast(encFeatureManager->GetFeature(HevcFeatureIDs::encodeTile)); + ENCODE_CHK_NULL_RETURN(hevcTile); + + HevcTileInfo hevcTileInfo; + + hevcTile->GetTileInfo(&hevcTileInfo); + + params.tileId = hevcTileInfo.tileId; + params.tileColPositionInSb = hevcTileInfo.tileColPositionInSb; + params.tileRowPositionInSb = hevcTileInfo.tileRowPositionInSb; + params.tileWidthInSbMinus1 = hevcTileInfo.tileWidthInSbMinus1; + params.tileHeightInSbMinus1 = hevcTileInfo.tileHeightInSbMinus1; + params.tileNum = hevcTileInfo.tileNum; + params.tileGroupId = hevcTileInfo.tileGroupId; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(AQM_SLICE_STATE, HevcEncodeAqm) +{ + auto encFeatureManager = dynamic_cast(m_featureManager); + ENCODE_CHK_NULL_RETURN(encFeatureManager); + + auto hevcTile = dynamic_cast(encFeatureManager->GetFeature(HevcFeatureIDs::encodeTile)); + ENCODE_CHK_NULL_RETURN(hevcTile); + + HevcTileInfo hevcTileInfo; + + hevcTile->GetTileInfo(&hevcTileInfo); + + auto hevcBasicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(hevcBasicFeature); + auto picParams = hevcBasicFeature->m_hevcPicParams; + ENCODE_CHK_NULL_RETURN(picParams); + auto seqParams = hevcBasicFeature->m_hevcSeqParams; + ENCODE_CHK_NULL_RETURN(seqParams); + auto t_sliceParams = hevcBasicFeature->m_hevcSliceParams; + ENCODE_CHK_NULL_RETURN(t_sliceParams); + CODEC_HEVC_ENCODE_SLICE_PARAMS *sliceParams = (CODEC_HEVC_ENCODE_SLICE_PARAMS *)&t_sliceParams[hevcBasicFeature->m_curNumSlices]; + + uint32_t ctbSize = 1 << (seqParams->log2_max_coding_block_size_minus3 + 3); + uint32_t widthInPix = (1 << (seqParams->log2_min_coding_block_size_minus3 + 3)) * (seqParams->wFrameWidthInMinCbMinus1 + 1); + uint32_t widthInCtb = (widthInPix / ctbSize) + ((widthInPix % ctbSize) ? 1 : 0); // round up + uint32_t heightInPix = (1 << (seqParams->log2_min_coding_block_size_minus3 + 3)) * (seqParams->wFrameHeightInMinCbMinus1 + 1); + uint32_t heightInCtb = (heightInPix / ctbSize) + ((heightInPix % ctbSize) ? 1 : 0); // round up + uint32_t shift = seqParams->log2_max_coding_block_size_minus3 - seqParams->log2_min_coding_block_size_minus3; + + bool m_enabled = false; + ENCODE_CHK_STATUS_RETURN(hevcTile->IsEnabled(m_enabled)); + if (!m_enabled) + { + params.firstSuperSlice = 0; + // No tiling support + params.tileSliceStartLcuMbY = sliceParams->slice_segment_address / widthInCtb; + params.nextTileSliceStartLcuMbX = (sliceParams->slice_segment_address + sliceParams->NumLCUsInSlice) / heightInCtb; + params.nextTileSliceStartLcuMbY = (sliceParams->slice_segment_address + sliceParams->NumLCUsInSlice) / widthInCtb; + } + else + { + params.tileSliceStartLcuMbX = hevcTileInfo.tileStartXInLCU; + params.tileSliceStartLcuMbY = hevcTileInfo.tileStartYInLCU; + params.nextTileSliceStartLcuMbX = hevcTileInfo.tileEndXInLCU; + params.nextTileSliceStartLcuMbY = hevcTileInfo.tileEndYInLCU; + } + + return MOS_STATUS_SUCCESS; +} + +#if USE_CODECHAL_DEBUG_TOOL +MOS_STATUS HevcEncodeAqm::UpdateFrameDisplayOrder(const uint16_t pictureCodingType, const uint32_t framePOC, const uint32_t gopPicSize) +{ + auto basicFeature = dynamic_cast(m_basicFeature); + ENCODE_CHK_NULL_RETURN(basicFeature); + if (basicFeature->m_hevcPicParams->CurrPicOrderCnt == 0) + { + m_frameNumPrevious += m_gopSizePrevious; + } + uint32_t displayOrderInGOP = framePOC; + uint32_t displayOrderInSeq = displayOrderInGOP + m_frameNumPrevious; + m_gopSizePrevious = gopPicSize; + m_frameIdxQueue.push(displayOrderInSeq); + return MOS_STATUS_SUCCESS; +} +#endif + +} // namespace encode diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_aqm.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_aqm.h new file mode 100644 index 0000000000..8fc2c83b47 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_aqm.h @@ -0,0 +1,63 @@ +/* +* Copyright (c) 2021, 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. +*/ +//! +//! \file encode_hevc_aqm.h +//! \brief Defines the common interface for hevc aqm +//! +#ifndef __ENCODE_HEVC_AQM_H__ +#define __ENCODE_HEVC_AQM_H__ +#include "encode_aqm_feature.h" +#include "mhw_vdbox_hcp_itf.h" + +namespace encode +{ +class HevcEncodeAqm : public EncodeAqmFeature, public mhw::vdbox::hcp::Itf::ParSetting +{ +public: + HevcEncodeAqm(MediaFeatureManager *featureManager, + EncodeAllocator * allocator, + CodechalHwInterfaceNext * hwInterface, + void * constSettings); + + virtual ~HevcEncodeAqm(){}; + + virtual MOS_STATUS Update(void *params) override; + + MHW_SETPAR_DECL_HDR(AQM_PIC_STATE); + + MHW_SETPAR_DECL_HDR(HCP_PIC_STATE); + + MHW_SETPAR_DECL_HDR(AQM_TILE_CODING); + + MHW_SETPAR_DECL_HDR(AQM_SLICE_STATE); + +#if USE_CODECHAL_DEBUG_TOOL + virtual MOS_STATUS UpdateFrameDisplayOrder(const uint16_t pictureCodingType, const uint32_t framePOC, const uint32_t gopPicSize) override; +#endif + +MEDIA_CLASS_DEFINE_END(encode__HevcEncodeAqm) +}; + +} // namespace encode + +#endif // !__ENCODE_HEVC_AQM_H__ + diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_vdenc_hevc_fastpass.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_vdenc_hevc_fastpass.cpp new file mode 100644 index 0000000000..c371fbc7e1 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_vdenc_hevc_fastpass.cpp @@ -0,0 +1,413 @@ +/* +* Copyright (c) 2023, 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. +*/ +//! +//! \file encode_hevc_vdenc_fastpass.cpp +//! \brief Defines the Xe2_HPM+ Base interface for hevc encode fastpass features +//! + +#include "encode_vdenc_hevc_fastpass.h" +#include "encode_hevc_vdenc_feature_manager.h" + +namespace encode +{ + +HevcVdencFastPass::HevcVdencFastPass( + MediaFeatureManager *featureManager, + EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + void* constSettings): + MediaFeature(constSettings,hwInterface ? hwInterface->GetOsInterface() : nullptr) +{ + ENCODE_FUNC_CALL(); + auto encFeatureManager = dynamic_cast(featureManager); + ENCODE_CHK_NULL_NO_STATUS_RETURN(encFeatureManager); + + m_hevcFeature = dynamic_cast(encFeatureManager->GetFeature(FeatureIDs::basicFeature)); + ENCODE_CHK_NULL_NO_STATUS_RETURN(m_hevcFeature); + + //regkey to control fast pass encode settings + MediaUserSetting::Value outValue; + ReadUserSetting(m_userSettingPtr, + outValue, + "Enable Fast Pass Encode", + MediaUserSetting::Group::Sequence); + + m_enableFastPass = outValue.Get(); + if (m_enableFastPass) + { + MediaUserSetting::Value outValue_ratio; + MediaUserSetting::Value outValue_type; +#if (_DEBUG || _RELEASE_INTERNAL) + + ReadUserSetting(m_userSettingPtr, + outValue_ratio, + "Fast Pass Encode Downscale Ratio", + MediaUserSetting::Group::Sequence); + ReadUserSetting(m_userSettingPtr, + outValue_type, + "Fast Pass Encode Downscale Type", + MediaUserSetting::Group::Sequence); +#endif + + if (outValue_ratio.Get() == 0) + { + m_fastPassShiftIndex = 2; + } + else if (outValue_ratio.Get() == 1) + { + m_fastPassShiftIndex = 1; + } + else + m_fastPassShiftIndex = 2; + m_fastPassDownScaleType = (uint8_t)outValue_type.Get(); + } +} + +MOS_STATUS HevcVdencFastPass::Update(void *params) +{ + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + ENCODE_CHK_NULL_RETURN(m_hevcFeature); + m_hevcSeqParams = m_hevcFeature->m_hevcSeqParams; + ENCODE_CHK_NULL_RETURN(m_hevcSeqParams); + + // hevc needs 8-pixels aligned + m_dsWidth = MOS_ALIGN_FLOOR((m_hevcSeqParams->wFrameWidthInMinCbMinus1 + 1) << (m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3) >> m_fastPassShiftIndex, 8); + m_dsHeight = MOS_ALIGN_FLOOR((m_hevcSeqParams->wFrameHeightInMinCbMinus1 + 1) << (m_hevcSeqParams->log2_min_coding_block_size_minus3 + 3) >> m_fastPassShiftIndex, 8); + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_PIPE_MODE_SELECT, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + params.fastPassEn = m_enableFastPass; + params.fastPassScale = m_fastPassShiftIndex == 2 ? 0 : 1; // fastPassScale:0 indicates 4x4 ds, fastPassScale:1 indicates 2x2 ds + params.DownScaleType = m_fastPassDownScaleType; // DownScaleType:0 indicates bilinear, DownScaleType:1 indicates NN + params.chromaType = 1; // Fast pass uses 420 type + params.bitDepthMinus8 = 0; // Fast pass uses bitdepth 8 + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_CMD2, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + params.width = m_dsWidth; + params.height = m_dsHeight; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_HEVC_VP9_TILE_SLICE_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + uint32_t widthInPix = m_dsWidth; + uint32_t heightInPix = m_dsHeight; + //no tiling + params.tileWidth = widthInPix; + params.tileHeight = heightInPix; + + if (m_hevcSeqParams->palette_mode_enabled_flag && m_hevcSeqParams->bit_depth_luma_minus8 == 2) + { + uint32_t SliceQP = m_hevcFeature->m_hevcPicParams->QpY + m_hevcFeature->m_hevcSliceParams->slice_qp_delta; + uint32_t tableIdx; + if (SliceQP <= 12) + { + tableIdx = 0; + } + else if (SliceQP > 12 && SliceQP <= 17) + { + tableIdx = 1; + } + else if (SliceQP > 17 && SliceQP <= 22) + { + tableIdx = 2; + } + else if (SliceQP > 22 && SliceQP <= 27) + { + tableIdx = 3; + } + else if (SliceQP > 27 && SliceQP <= 32) + { + tableIdx = 4; + } + else if (SliceQP > 32 && SliceQP <= 37) + { + tableIdx = 5; + } + else if (SliceQP > 37 && SliceQP <= 42) + { + tableIdx = 6; + } + else if (SliceQP > 42 && SliceQP <= 47) + { + tableIdx = 7; + } + else if (SliceQP > 47 && SliceQP <= 49) + { + tableIdx = 8; + } + else + { + tableIdx = 9; + } + + static const uint32_t table[3][10][11] = + { + { + {16}, + {16}, + {16}, + {16}, + {32}, + {48}, + {64}, + {96}, + {128}, + {256}, + }, + { + {16}, + {16}, + {16}, + {16}, + {32}, + {48}, + {64}, + {96}, + {128}, + {256}, + }, + { + {256}, + {256}, + {256}, + {256}, + {256}, + {768}, + {768}, + {768}, + {768}, + {768}, + }, + }; + + params.VdencHEVCVP9TileSlicePar5 = 4; + params.VdencHEVCVP9TileSlicePar14 = table[params.VdencHEVCVP9TileSlicePar1][tableIdx][0]; + params.VdencHEVCVP9TileSlicePar6 >>= 2; + params.VdencHEVCVP9TileSlicePar7 >>= 2; + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_WALKER_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + auto t_sliceParams = m_hevcFeature->m_hevcSliceParams; + CODEC_HEVC_ENCODE_SLICE_PARAMS *sliceParams = (CODEC_HEVC_ENCODE_SLICE_PARAMS *)&t_sliceParams[m_hevcFeature->m_curNumSlices]; + + uint32_t ctbSize = 1 << (m_hevcSeqParams->log2_max_coding_block_size_minus3 + 3); + uint32_t widthInCtb = (m_dsWidth / ctbSize) + ((m_dsWidth % ctbSize) ? 1 : 0); // round up + uint32_t heightInCtb = (m_dsHeight / ctbSize) + ((m_dsHeight % ctbSize) ? 1 : 0); // round up + //no tiling + params.tileSliceStartLcuMbY = sliceParams->slice_segment_address / widthInCtb; + params.nextTileSliceStartLcuMbX = (sliceParams->slice_segment_address + widthInCtb * heightInCtb) / heightInCtb; + params.nextTileSliceStartLcuMbY = (sliceParams->slice_segment_address + widthInCtb * heightInCtb) / widthInCtb; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_REF_SURFACE_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + params.width = m_dsWidth; + params.height = m_dsHeight; + + //Fast pass uses 420 type + if (m_hevcSeqParams->chroma_format_idc != 1) + { + params.format = Format_NV12; + params.vOffset = params.uOffset; + } + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(VDENC_DS_REF_SURFACE_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + uint32_t dsWidth4x = m_dsWidth / SCALE_FACTOR_4x; + uint32_t dsHeight4x = m_dsHeight / SCALE_FACTOR_4x; + + params.heightStage1 = dsHeight4x >> 1; + params.widthStage1 = dsWidth4x >> 1; + params.heightStage2 = dsHeight4x; + params.widthStage2 = dsWidth4x; + + return MOS_STATUS_SUCCESS; +} +MHW_SETPAR_DECL_SRC(HCP_PIC_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + params.framewidthinmincbminus1 = (m_dsWidth >> 3) - 1; + params.frameheightinmincbminus1 = (m_dsHeight >> 3) - 1; + + //Fast pass uses 420 type, bitdepth 8 + if (m_hevcSeqParams->chroma_format_idc != 1) + { + params.chromaSubsampling = 1; + params.lcuMaxBitSizeAllowedMsb2its >>= 1; + params.lcuMaxBitsizeAllowed >>= 1; + } + if (m_hevcSeqParams->bit_depth_luma_minus8 == 2) + { + params.bitDepthChromaMinus8 = 0; + params.bitDepthLumaMinus8 = 0; + } + + //RDOQ TU7 is related to framesize, it needs to be downscaled. + if (m_hevcFeature->m_targetUsage == 7) + { + uint32_t frameSize_ds = m_dsWidth * m_dsHeight; + params.rdoqintratuthreshold = MOS_MIN(((frameSize_ds * 30) / 100) >> 8, 0xffff); + } + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HCP_SURFACE_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + using namespace mhw::vdbox; + + //Fast pass uses 420 type, bitdepth 8 + if (m_hevcSeqParams->chroma_format_idc != 1) + { + params.yOffsetForVCr = (uint16_t)params.yOffsetForUCbInPixel; + } + params.surfaceFormat = hcp::SURFACE_FORMAT::SURFACE_FORMAT_PLANAR4208; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HEVC_VP9_RDOQ_STATE, HevcVdencFastPass) +{ + ENCODE_FUNC_CALL(); + + if (!m_enableFastPass) + { + return MOS_STATUS_SUCCESS; + } + + PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams = m_hevcFeature->m_hevcPicParams; + ENCODE_CHK_NULL_RETURN(hevcPicParams); + + //Fast pass uses bitdepth 8 + uint8_t bitDepthLumaMinus8 = 0; + uint8_t bitDepthChromaMinus8 = 0; + uint8_t codingType = hevcPicParams->CodingType; + auto settings = static_cast(m_constSettings); + ENCODE_CHK_NULL_RETURN(settings); + + uint32_t sliceTypeIdx = (codingType == I_TYPE) ? 0 : 1; + + //Intra lambda + MOS_ZeroMemory(params.lambdaTab, sizeof(params.lambdaTab)); + if (bitDepthLumaMinus8 == 0) + { + std::copy(settings->rdoqLamdas8bits[sliceTypeIdx][0][0].begin(), + settings->rdoqLamdas8bits[sliceTypeIdx][0][0].end(), + std::begin(params.lambdaTab[0][0])); + + std::copy(settings->rdoqLamdas8bits[sliceTypeIdx][0][1].begin(), + settings->rdoqLamdas8bits[sliceTypeIdx][0][1].end(), + std::begin(params.lambdaTab[0][1])); + + std::copy(settings->rdoqLamdas8bits[sliceTypeIdx][1][0].begin(), + settings->rdoqLamdas8bits[sliceTypeIdx][1][0].end(), + std::begin(params.lambdaTab[1][0])); + + std::copy(settings->rdoqLamdas8bits[sliceTypeIdx][1][1].begin(), + settings->rdoqLamdas8bits[sliceTypeIdx][1][1].end(), + std::begin(params.lambdaTab[1][1])); + } + + if (m_hevcFeature->m_hevcRDOQPerfDisabled) + { + params.disableHtqPerformanceFix0 = true; + params.disableHtqPerformanceFix1 = true; + } + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_vdenc_hevc_fastpass.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_vdenc_hevc_fastpass.h new file mode 100644 index 0000000000..0c5b071b02 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_vdenc_hevc_fastpass.h @@ -0,0 +1,90 @@ +/* +* Copyright (c) 2023, 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. +*/ +//! +//! \file encode_hevc_vdenc_fastpass.h +//! \brief Defines for Xe2_HPM+ hevc fast pass encode feature +//! +#ifndef __ENCODE_HEVC_VDENC_FASTPASS_H__ +#define __ENCODE_HEVC_VDENC_FASTPASS_H__ + +#include "encode_allocator.h" +#include "encode_hevc_basic_feature.h" + +namespace encode +{ +class HevcVdencFastPass : public MediaFeature, public mhw::vdbox::vdenc::Itf::ParSetting, public mhw::vdbox::hcp::Itf::ParSetting +{ +public: + HevcVdencFastPass( + MediaFeatureManager *featureManager, + EncodeAllocator *allocator, + CodechalHwInterfaceNext *hwInterface, + void *constSettings); + + ~HevcVdencFastPass() {} + + //! + //! \brief Update encode parameter + //! \param [in] params + //! Pointer to parameters + //! \return MOS_STATUS + //! MOS_STATUS_SUCCESS if success, else fail reason + //! + virtual MOS_STATUS Update(void *params) override; + + MHW_SETPAR_DECL_HDR(VDENC_PIPE_MODE_SELECT); + + MHW_SETPAR_DECL_HDR(VDENC_CMD2); + + MHW_SETPAR_DECL_HDR(VDENC_HEVC_VP9_TILE_SLICE_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_WALKER_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_REF_SURFACE_STATE); + + MHW_SETPAR_DECL_HDR(VDENC_DS_REF_SURFACE_STATE); + + MHW_SETPAR_DECL_HDR(HCP_PIC_STATE); + + MHW_SETPAR_DECL_HDR(HCP_SURFACE_STATE); + + MHW_SETPAR_DECL_HDR(HEVC_VP9_RDOQ_STATE); + +protected: + PMOS_INTERFACE m_osInterface = nullptr; //!< Os Inteface + MOS_RESOURCE m_vdencRecDownScaledBuffer = {}; + + bool m_enableFastPass = false; //!< Flag to indicate if HEVC fastpass is enabled. + uint8_t m_fastPassShiftIndex = 0; //!< downscale shift index for fast pass encode + uint8_t m_fastPassDownScaleType = 0; //!< downscaleType for fast pass encode + + HevcBasicFeature *m_hevcFeature = nullptr; + PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS m_hevcSeqParams = nullptr; + uint32_t m_dsWidth = 0; + uint32_t m_dsHeight = 0; + + MEDIA_CLASS_DEFINE_END(encode__HevcVdencFastPass) +}; + +} // namespace encode + +#endif // !__ENCODE_HEVC_VDENC_FASTPASS_H__ \ No newline at end of file diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/media_srcs.cmake b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/media_srcs.cmake index 79398156d0..47b05a675c 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/media_srcs.cmake +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/media_srcs.cmake @@ -36,6 +36,8 @@ set(TMP_SOURCES_ ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_basic_feature_422.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_fullenc.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_preenc.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_aqm.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_hevc_fastpass.cpp ) set(TMP_HEADERS_ @@ -54,6 +56,8 @@ set(TMP_HEADERS_ ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_basic_feature_422.h ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_fullenc.h ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_preenc.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_aqm.h + ${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_hevc_fastpass.h ) set(SOFTLET_ENCODE_HEVC_HEADERS_ diff --git a/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.cpp b/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.cpp index 1f0fcda036..9e258d36bf 100644 --- a/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.cpp +++ b/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.cpp @@ -411,7 +411,6 @@ MOS_STATUS CodechalInterfacesXe2_Lpm::Initialize( } else if (CodecHalIsEncode(CodecFunction)) { -#ifdef _MEDIA_RESERVED #if defined (_AVC_ENCODE_VDENC_SUPPORTED) if (info->Mode == CODECHAL_ENCODE_MODE_AVC) { @@ -428,6 +427,7 @@ MOS_STATUS CodechalInterfacesXe2_Lpm::Initialize( } else #endif +#ifdef _MEDIA_RESERVED #ifdef _VP9_ENCODE_VDENC_SUPPORTED if (info->Mode == CODECHAL_ENCODE_MODE_VP9) { @@ -442,20 +442,6 @@ MOS_STATUS CodechalInterfacesXe2_Lpm::Initialize( else #endif -#ifdef _JPEG_ENCODE_SUPPORTED - if (info->Mode == CODECHAL_ENCODE_MODE_JPEG) - { - m_codechalDevice = MOS_New(EncodeJpegPipelineAdapter, hwInterface, debugInterface); - if (m_codechalDevice == nullptr) - { - CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); - CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func); - } - return MOS_STATUS_SUCCESS; - } - else -#endif - #if defined(_AV1_ENCODE_VDENC_SUPPORTED) if (info->Mode == codechalEncodeModeAv1) { @@ -476,6 +462,21 @@ MOS_STATUS CodechalInterfacesXe2_Lpm::Initialize( } else #endif +#endif + +#ifdef _JPEG_ENCODE_SUPPORTED + if (info->Mode == CODECHAL_ENCODE_MODE_JPEG) + { + m_codechalDevice = MOS_New(EncodeJpegPipelineAdapter, hwInterface, debugInterface); + if (m_codechalDevice == nullptr) + { + CODECHAL_PUBLIC_ASSERTMESSAGE("Encode state creation failed!"); + CODECHAL_PUBLIC_CHK_STATUS_WITH_DESTROY_RETURN(MOS_STATUS_INVALID_PARAMETER, release_func); + } + return MOS_STATUS_SUCCESS; + } + else +#endif #if defined(_HEVC_ENCODE_VDENC_SUPPORTED) if (info->Mode == CODECHAL_ENCODE_MODE_HEVC) @@ -492,7 +493,6 @@ MOS_STATUS CodechalInterfacesXe2_Lpm::Initialize( } } else -#endif #endif { CODECHAL_PUBLIC_ASSERTMESSAGE("Unsupported encode function requested."); diff --git a/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.h b/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.h index 3968216ab1..95ff3d0bc4 100644 --- a/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.h +++ b/media_softlet/media_interface/media_interfaces_lnl/media_interfaces_lnl.h @@ -89,19 +89,20 @@ #include "encode_jpeg_pipeline_adapter.h" #endif -#ifdef _MEDIA_RESERVED +#ifdef _AVC_ENCODE_VDENC_SUPPORTED +#include "encode_avc_vdenc_pipeline_adapter_xe2_lpm.h" +#endif + #ifdef _HEVC_ENCODE_VDENC_SUPPORTED #include "encode_hevc_vdenc_pipeline_adapter_xe2_lpm_base.h" #endif +#ifdef _MEDIA_RESERVED + #ifdef _AV1_ENCODE_VDENC_SUPPORTED #include "encode_av1_vdenc_pipeline_adapter_xe2_lpm.h" #endif -#ifdef _AVC_ENCODE_VDENC_SUPPORTED -#include "encode_avc_vdenc_pipeline_adapter_xe2_lpm.h" -#endif - #ifdef _VP9_ENCODE_VDENC_SUPPORTED #include "encode_vp9_vdenc_pipeline_adapter_xe2_lpm.h" #endif