diff --git a/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_hevc_g12.cpp b/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_hevc_g12.cpp index 1e1f525c64..48c0d5e9f7 100644 --- a/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_hevc_g12.cpp +++ b/media_driver/agnostic/gen12/codec/hal/codechal_vdenc_hevc_g12.cpp @@ -561,12 +561,6 @@ MOS_STATUS CodechalVdencHevcStateG12::PlatformCapabilityCheck() CODECHAL_ENCODE_CHK_STATUS_MESSAGE_RETURN(eStatus, "12bit encoding is not supported on VDENC"); } - if (m_hevcSeqParams->chroma_format_idc == 2) - { - eStatus = MOS_STATUS_INVALID_PARAMETER; - CODECHAL_ENCODE_CHK_STATUS_MESSAGE_RETURN(eStatus, "422 recon format encoding is not supported on HEVC VDENC"); - } - // TU configuration for RDOQ if (m_hevcRdoqEnabled) { diff --git a/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp b/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp index 0b275df6af..fdeb263342 100644 --- a/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp +++ b/media_driver/media_interface/media_interfaces_dg2/media_interfaces_dg2.cpp @@ -572,7 +572,7 @@ MOS_STATUS CodechalInterfacesXe_Hpm::Initialize( if (CodecHalIsDecode(CodecFunction)) { - if(osInterface->bHcpDecScalabilityMode = MOS_SCALABILITY_ENABLE_MODE_USER_FORCE) + if(osInterface->bHcpDecScalabilityMode == MOS_SCALABILITY_ENABLE_MODE_USER_FORCE) { disableScalability = false; } diff --git a/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe_hpm.cpp b/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe_hpm.cpp index e39cf8e8f7..9be166c2ce 100644 --- a/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe_hpm.cpp +++ b/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager_xe_hpm.cpp @@ -27,6 +27,7 @@ #include "encode_hevc_vdenc_feature_manager_xe_hpm.h" #include "encode_hevc_vdenc_scc.h" +#include "encode_hevc_basic_feature_rsvd.h" namespace encode { MOS_STATUS EncodeHevcVdencFeatureManagerXe_Hpm::CreateFeatures(void *constSettings) @@ -54,19 +55,17 @@ MOS_STATUS EncodeHevcVdencFeatureManagerXe_Hpm::CheckFeatures(void* params) PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams = static_cast(encodeParams->pSeqParams); ENCODE_CHK_NULL_RETURN(hevcSeqParams); - -#ifdef _ENCODE_RESERVED + PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams = + static_cast(encodeParams->pPicParams); + ENCODE_CHK_NULL_RETURN(hevcPicParams); if (m_basicFeature->m_rsvdState) { - ENCODE_CHK_STATUS_RETURN(m_basicFeature->m_rsvdState->Init(hevcSeqParams)); + ENCODE_CHK_STATUS_RETURN(m_basicFeature->m_rsvdState->Init(hevcSeqParams,hevcPicParams)); } -#endif if (MEDIA_IS_WA(waTable, WaEnableOnlyASteppingFeatures)) { - PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams = - static_cast(encodeParams->pPicParams); - ENCODE_CHK_NULL_RETURN(hevcPicParams); + ENCODE_CHK_STATUS_RETURN(ValidateASteppingNotSupportedFeatures(hevcSeqParams, hevcPicParams)); } diff --git a/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/media_srcs.cmake b/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/media_srcs.cmake index c967ec9d38..4e5a02858b 100644 --- a/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/media_srcs.cmake +++ b/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/media_srcs.cmake @@ -20,3 +20,4 @@ media_include_subdirectory(features) media_include_subdirectory(pipeline) +media_include_subdirectory(packet) diff --git a/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe_hpm.cpp b/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe_hpm.cpp index 31a97fc6fa..5f20ce3a6c 100644 --- a/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe_hpm.cpp +++ b/media_driver/media_softlet/agnostic/Xe_M/Xe_HPM/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline_xe_hpm.cpp @@ -33,10 +33,8 @@ #include "encode_huc_la_init_packet.h" #include "encode_huc_la_update_packet.h" -#ifdef _ENCODE_RESERVED + #include "encode_hevc_vdenc_packet_rsvd.h" -#include "encode_hevc_vdenc_packet_xe_hpm_ext.h" -#endif namespace encode { @@ -85,10 +83,9 @@ MOS_STATUS HevcVdencPipelineXe_Hpm::Init(void *settings) return vdencPkt == nullptr ? nullptr : MOS_New(HevcVdencTileRowPkt, task, vdencPkt); }); -#ifdef _ENCODE_RESERVED - RegisterPacket(hevcVdencPacketRsvd, [=]() -> MediaPacket * { return MOS_New(HevcVdencPktRsvd, this, task, m_hwInterface); }); -#endif + RegisterPacket(hevcVdencPacketRsvd, [=]() -> MediaPacket * { return MOS_New(HevcVdencPktRsvd, this, task, m_hwInterface); }); + return MOS_STATUS_SUCCESS; } diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp index c7204f64dc..36cadfb3fc 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.cpp @@ -37,13 +37,11 @@ namespace encode { HevcBasicFeature::~HevcBasicFeature() { -#ifdef _ENCODE_RESERVED if (m_rsvdState) { MOS_Delete(m_rsvdState); m_rsvdState = nullptr; } -#endif } MOS_STATUS HevcBasicFeature::Init(void *setting) @@ -107,9 +105,9 @@ MOS_STATUS HevcBasicFeature::Init(void *setting) #endif // _DEBUG || _RELEASE_INTERNAL m_hevcRDOQPerfDisabled = outValue.Get(); -#ifdef _ENCODE_RESERVED + ENCODE_CHK_STATUS_RETURN(InitRsvdState()); -#endif + return MOS_STATUS_SUCCESS; } @@ -125,6 +123,7 @@ MOS_STATUS HevcBasicFeature::Update(void *params) m_hevcSeqParams = static_cast(encodeParams->pSeqParams); ENCODE_CHK_NULL_RETURN(m_hevcSeqParams); + m_hevcPicParams = static_cast(encodeParams->pPicParams); ENCODE_CHK_NULL_RETURN(m_hevcPicParams); m_hevcSliceParams = static_cast(encodeParams->pSliceParams); @@ -135,12 +134,10 @@ MOS_STATUS HevcBasicFeature::Update(void *params) ENCODE_CHK_NULL_RETURN(m_nalUnitParams); m_NumNalUnits = encodeParams->uiNumNalUnits; -#ifdef _ENCODE_RESERVED if (m_rsvdState && m_rsvdState->GetFeatureRsvdFlag()) { ENCODE_CHK_STATUS_RETURN(m_rsvdState->UpdateRsvdFormat(m_hevcSeqParams, m_outputChromaFormat, m_reconSurface.Format, m_is10Bit)); } -#endif if (encodeParams->bAcceleratorHeaderPackingCaps) { @@ -353,12 +350,10 @@ MOS_STATUS HevcBasicFeature::UpdateTrackedBufferParameters() ENCODE_CHK_STATUS_RETURN(m_trackedBuf->RegisterParam(encode::BufferType::mvTemporalBuffer, allocParams)); } -#ifdef _ENCODE_RESERVED if (m_rsvdState && m_rsvdState->GetFeatureRsvdFlag()) { ENCODE_CHK_STATUS_RETURN(m_rsvdState->RegisterMbCodeBuffer(m_trackedBuf, m_isMbCodeRegistered, m_mbCodeSize)); } -#endif ENCODE_CHK_STATUS_RETURN(EncodeBasicFeature::UpdateTrackedBufferParameters()); @@ -648,7 +643,6 @@ MOS_STATUS HevcBasicFeature::SetRoundingValues() return eStatus; } -#ifdef _ENCODE_RESERVED MOS_STATUS HevcBasicFeature::InitRsvdState() { ENCODE_FUNC_CALL(); @@ -658,7 +652,6 @@ MOS_STATUS HevcBasicFeature::InitRsvdState() return MOS_STATUS_SUCCESS; } -#endif MOS_STATUS HevcBasicFeature::GetSurfaceMmcInfo(PMOS_SURFACE surface, MOS_MEMCOMP_STATE &mmcState, uint32_t &compressionFormat) const { diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.h index cafd323902..c25f552d67 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.h +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature.h @@ -35,11 +35,7 @@ #include "mhw_vdbox_vdenc_itf.h" #include "mhw_vdbox_hcp_itf.h" #include "encode_mem_compression.h" - -#ifdef _ENCODE_RESERVED #include "encode_hevc_basic_feature_rsvd.h" -#endif - namespace encode { #define CODECHAL_HEVC_VDENC_LCU_SIZE 64 @@ -139,10 +135,8 @@ class HevcBasicFeature : public EncodeBasicFeature, public mhw::vdbox::vdenc::It uint32_t m_picStateCmdStartInBytes = 0; //!< Offset of PIC_STATE cmd in batch buffer -#ifdef _ENCODE_RESERVED HevcBasicFeatureRsvd *m_rsvdState = nullptr; MOS_STATUS InitRsvdState(); -#endif std::deque m_recycleBufferIdxes; diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature_rsvd.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature_rsvd.cpp new file mode 100644 index 0000000000..09f6ca92d1 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature_rsvd.cpp @@ -0,0 +1,101 @@ +/* +* 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_basic_feature_rsvd.cpp +//! \brief Defines the common interface for encode hevc basic feature rsvd +//! +#include "encode_hevc_basic_feature_rsvd.h" + +namespace encode +{ + MOS_STATUS HevcBasicFeatureRsvd::Init(PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams) + { + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(hevcSeqParams); + ENCODE_CHK_NULL_RETURN(hevcPicParams); + if (hevcSeqParams->chroma_format_idc == HCP_CHROMA_FORMAT_YUV422) + { + m_is422WA = true; + } + + if (m_is422WA && hevcPicParams->tiles_enabled_flag ) + { + ENCODE_ASSERTMESSAGE(" 422 with multi tiles is not supported."); + return MOS_STATUS_INVALID_PARAMETER; + } + + return MOS_STATUS_SUCCESS; + } + + MOS_STATUS HevcBasicFeatureRsvd::RegisterMbCodeBuffer(TrackedBuffer *trackedBuf, bool &isRegistered, uint32_t mbCodeSize) + { + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(trackedBuf); + + MOS_ALLOC_GFXRES_PARAMS allocParamsForLinear; + MOS_ZeroMemory(&allocParamsForLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS)); + allocParamsForLinear.Type = MOS_GFXRES_BUFFER; + allocParamsForLinear.TileType = MOS_TILE_LINEAR; + allocParamsForLinear.Format = Format_Buffer; + allocParamsForLinear.dwMemType = MOS_MEMPOOL_SYSTEMMEMORY; + allocParamsForLinear.Flags.bCacheable = true; + // set the ResUsageType to enable coherency in gmm + allocParamsForLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_OUTPUT_BITSTREAM; + + if (mbCodeSize > 0) + { + allocParamsForLinear.pBufName = "mbCodeBuffer"; + allocParamsForLinear.dwBytes = mbCodeSize + 8 * CODECHAL_CACHELINE_SIZE; + ENCODE_CHK_STATUS_RETURN(trackedBuf->RegisterParam(encode::BufferType::mbCodedBuffer, allocParamsForLinear)); + isRegistered = true; + } + + return MOS_STATUS_SUCCESS; + } + + MOS_STATUS HevcBasicFeatureRsvd::UpdateRsvdFormat(PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, uint8_t &outputChromaFormat, MOS_FORMAT &reconFormat, bool is10Bit) + { + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(hevcSeqParams); + hevcSeqParams->chroma_format_idc = + outputChromaFormat = HCP_CHROMA_FORMAT_YUV420; + reconFormat = is10Bit ? Format_P010 : Format_NV12; + + return MOS_STATUS_SUCCESS; + } + + MOS_STATUS HevcBasicFeatureRsvd::RevertRsvdFormat(PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, uint8_t &outputChromaFormat, MOS_FORMAT &reconFormat, bool is10Bit) + { + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(hevcSeqParams); + hevcSeqParams->chroma_format_idc = + outputChromaFormat = HCP_CHROMA_FORMAT_YUV422; + reconFormat = is10Bit ? Format_Y216 : Format_YUY2; + + return MOS_STATUS_SUCCESS; + } + +} diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature_rsvd.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature_rsvd.h new file mode 100644 index 0000000000..fe14f86820 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_basic_feature_rsvd.h @@ -0,0 +1,57 @@ +/* +* 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_basic_feature_rsvd.h +//! \brief Defines the common interface for encode hevc basic feature rsvd +//! +#ifndef __ENCODE_HEVC_BASIC_FEATURE_RSVD_H__ +#define __ENCODE_HEVC_BASIC_FEATURE_RSVD_H__ + +#include "encode_basic_feature.h" + +namespace encode +{ +class HevcBasicFeatureRsvd +{ +public: + HevcBasicFeatureRsvd() { }; + + ~HevcBasicFeatureRsvd() { }; + + bool GetFeatureRsvdFlag(){ return m_is422WA; } + + MOS_STATUS Init(PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams); + + MOS_STATUS RegisterMbCodeBuffer(TrackedBuffer *trackedBuf, bool &isRegistered, uint32_t mbCodeSize); + + MOS_STATUS UpdateRsvdFormat(PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, uint8_t &outputChromaFormat, MOS_FORMAT &reconFormat, bool is10Bit); + + MOS_STATUS RevertRsvdFormat(PCODEC_HEVC_ENCODE_SEQUENCE_PARAMS hevcSeqParams, uint8_t &outputChromaFormat, MOS_FORMAT &reconFormat, bool is10Bit); + +protected: + bool m_is422WA = false; + +MEDIA_CLASS_DEFINE_END(encode__HevcBasicFeatureRsvd) +}; +} + +#endif // !__ENCODE_BASIC_FEATURE_RSVD_H__ diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager.cpp index dbfcd6f3be..881032807f 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/features/encode_hevc_vdenc_feature_manager.cpp @@ -280,14 +280,14 @@ MOS_STATUS EncodeHevcVdencFeatureManager::ValidatePassNum( auto brcFeature = dynamic_cast(GetFeature(HevcFeatureIDs::hevcBrcFeature)); -#ifdef _ENCODE_RESERVED + auto basicFeature = dynamic_cast(GetFeature(FeatureIDs::basicFeature)); ENCODE_CHK_NULL_RETURN(basicFeature); if (basicFeature->m_rsvdState && basicFeature->m_rsvdState->GetFeatureRsvdFlag()) { hevcPicParams->BRCPrecision = 1; } -#endif + // dynamic slice size control and brc to be added later here if (((hevcPicParams->weighted_pred_flag || 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 ee03419a8d..c4aecde72b 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 @@ -34,6 +34,7 @@ set(TMP_SOURCES_ ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_scc.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_lpla_analysis.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_lpla_enc.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_basic_feature_rsvd.cpp ) set(TMP_HEADERS_ @@ -50,6 +51,7 @@ set(TMP_HEADERS_ ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_scc.h ${CMAKE_CURRENT_LIST_DIR}/encode_vdenc_lpla_analysis.h ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_lpla_enc.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_basic_feature_rsvd.h ) endif() diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp index bfd2ca1475..d19fffc390 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet.cpp @@ -528,9 +528,7 @@ namespace encode } } else if (m_osInterface->bInlineCodecStatusUpdate -#ifdef _ENCODE_RESERVED && !(m_basicFeature->m_rsvdState && m_basicFeature->m_rsvdState->GetFeatureRsvdFlag()) -#endif ) { ENCODE_CHK_STATUS_RETURN(UpdateStatusReport(statusReportGlobalCount, &cmdBuffer)); @@ -2170,9 +2168,7 @@ namespace encode // needs to be enabled for 1st pass in multi-pass case // This bit is ignored if PAK only second pass is enabled. if ((m_pipeline->GetCurrentPass() == 0) && !m_pipeline->IsLastPass() -#ifdef _ENCODE_RESERVED || (m_basicFeature->m_rsvdState && m_basicFeature->m_rsvdState->GetFeatureRsvdFlag()) -#endif ) { params.pakObjCmdStreamOut = true; diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_rsvd.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_rsvd.cpp new file mode 100644 index 0000000000..23c8ce6cbb --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_rsvd.cpp @@ -0,0 +1,463 @@ +/* +* 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_rsvd.cpp +//! \brief Defines the interface to adapt to HEVC VDENC pipeline +//! + +#include "encode_hevc_vdenc_packet_rsvd.h" + +namespace encode +{ +MOS_STATUS HevcVdencPktRsvd::AllocateResources() +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(HevcVdencPkt::AllocateResources()); + + const uint32_t picWidthInLCU = MOS_ROUNDUP_DIVIDE(m_basicFeature->m_frameWidth, 64); + const uint32_t picHeightInLCU = MOS_ROUNDUP_DIVIDE(m_basicFeature->m_frameHeight, 64); + m_422maxNumLCUs = picWidthInLCU * picHeightInLCU; + m_422mvOffset = MOS_ALIGN_CEIL((m_422maxNumLCUs * (MOS_BYTES_TO_DWORDS(sizeof(InputLcuInfo))) * sizeof(uint32_t)), CODECHAL_PAGE_SIZE); + m_422mbCodeSize = m_422mvOffset + MOS_ALIGN_CEIL((m_422maxNumLCUs * 64 * sizeof(InputCuInfo)), CODECHAL_PAGE_SIZE); + + MOS_ALLOC_GFXRES_PARAMS allocParamsForBufferLinear; + MOS_ZeroMemory(&allocParamsForBufferLinear, sizeof(MOS_ALLOC_GFXRES_PARAMS)); + allocParamsForBufferLinear.Type = MOS_GFXRES_BUFFER; + allocParamsForBufferLinear.TileType = MOS_TILE_LINEAR; + allocParamsForBufferLinear.Format = Format_Buffer; + allocParamsForBufferLinear.dwMemType = MOS_MEMPOOL_SYSTEMMEMORY; + allocParamsForBufferLinear.Flags.bCacheable = true; + // for now we set ResUsageType to MOS_HW_RESOURCE_USAGE_ENCODE_OUTPUT_BITSTREAM rather than + // MOS_HW_RESOURCE_USAGE_ENCODE_INTERNAL_READ_WRITE_CACHE to enable coherency in gmm + allocParamsForBufferLinear.ResUsageType = MOS_HW_RESOURCE_USAGE_ENCODE_OUTPUT_BITSTREAM; + + allocParamsForBufferLinear.dwBytes = m_422mbCodeSize; + allocParamsForBufferLinear.pBufName = "Standalone PAK Input Buffer"; + m_res422MbCodeBuffer = m_allocator->AllocateResource(allocParamsForBufferLinear, false); + ENCODE_CHK_NULL_RETURN(m_res422MbCodeBuffer); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::Conversion() +{ + ENCODE_FUNC_CALL(); + + MOS_LOCK_PARAMS lockFlags; + MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS)); + lockFlags.ReadOnly = 1; + uint8_t *mbCode420Buffer = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, m_basicFeature->m_resMbCodeBuffer, &lockFlags); + ENCODE_CHK_NULL_RETURN(mbCode420Buffer); + lockFlags.ReadOnly = 0; + lockFlags.WriteOnly = 1; + uint8_t *mbCode422Buffer = (uint8_t *)m_osInterface->pfnLockResource(m_osInterface, m_res422MbCodeBuffer, &lockFlags); + ENCODE_CHK_NULL_RETURN(mbCode422Buffer); + + uint8_t *data = mbCode420Buffer; + uint8_t *tempPakObj = mbCode422Buffer; + uint8_t *tempCuRecord = mbCode422Buffer + m_422mvOffset; + + // To find vdenc pakObj buf start pos by its opcode + uint32_t opcode = 0x73A10000; + while ((uint32_t)(data - mbCode420Buffer) < m_basicFeature->m_mbCodeSize) + { + if (*((uint32_t *)data) == opcode) + break; + else + data += 4; + } + + for (uint32_t i = 0; i < m_422maxNumLCUs; i++) + { + if (*((uint32_t *)data) != opcode) + { + ENCODE_ASSERTMESSAGE("VDEnc 420 pass not finished."); + break; + } + + OutputInfoLCU *lcuInfo = (OutputInfoLCU *)data; + data += sizeof(OutputInfoLCU); + for (int j = 0; j < 5; j++) + { + uint32_t *tempdata = (uint32_t *)tempPakObj + j; + *tempdata = j ? lcuInfo->DW[j].DW0 : 0x73A10003; + } + InputLcuInfo *inputLcuInfo = (InputLcuInfo *)tempPakObj; + tempPakObj += sizeof(InputLcuInfo); + + // Add 0x05000000 to indicate each slice end + if ((inputLcuInfo->DW1>>31)&0x01) + { + inputLcuInfo->DW5 = 0x05000000; + } + + uint32_t cuCount = 0; + for (; cuCount < 64; cuCount++) + { + OutputCuInfo *cuInfo = (OutputCuInfo *)data; + data += sizeof(OutputCuInfo); + for (int j = 0; j < 8; j++) + { + uint32_t *tempdata = (uint32_t *)tempCuRecord + j; + *tempdata = cuInfo->DW[j].DW0; + } + InputCuInfo *inputCuInfo = (InputCuInfo *)tempCuRecord; + tempCuRecord += sizeof(InputCuInfo); + inputCuInfo->DW7 &= 0xFF7FFFFF; + + inputCuInfo->DW6 &= 0xFFBFFFFF; + inputCuInfo->DW4 &= 0x0000FFFF; + + if(((inputCuInfo->DW6>>23)&0X01) || cuCount == 63) + { + inputLcuInfo->DW1 &=0xC0FFFFFF; + inputLcuInfo->DW1 += ((cuCount&0x3F)<<24); + inputCuInfo->DW6 &= 0xFF7FFFFF; + break; + } + inputCuInfo->DW6 &= 0xFF7FFFFF; + } + tempCuRecord += (63 - cuCount) * sizeof(InputCuInfo); + } + InputLcuInfo *inputLcuInfo = (InputLcuInfo *)tempPakObj; + inputLcuInfo--; + inputLcuInfo->DW5 = 0x05000000; // Add 0x05000000 to indicate frame end + + ENCODE_CHK_STATUS_RETURN(m_osInterface->pfnUnlockResource(m_osInterface, m_basicFeature->m_resMbCodeBuffer)); + ENCODE_CHK_STATUS_RETURN(m_osInterface->pfnUnlockResource(m_osInterface, m_res422MbCodeBuffer)); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::Prepare() +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(m_basicFeature); + ENCODE_CHK_NULL_RETURN(m_basicFeature->m_rsvdState); + ENCODE_CHK_STATUS_RETURN(m_basicFeature->m_rsvdState->RevertRsvdFormat(m_basicFeature->m_hevcSeqParams, + m_basicFeature->m_outputChromaFormat, + m_basicFeature->m_reconSurface.Format, + m_basicFeature->m_is10Bit)); + + ENCODE_CHK_STATUS_RETURN(HevcVdencPkt::Prepare()); + + ENCODE_CHK_STATUS_RETURN(Conversion()); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::Completed(void *mfxStatus, void *rcsStatus, void *statusReport) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(m_basicFeature); + ENCODE_CHK_NULL_RETURN(m_basicFeature->m_rsvdState); + + if (m_basicFeature->m_rsvdState && m_basicFeature->m_rsvdState->GetFeatureRsvdFlag()) + { + ENCODE_CHK_STATUS_RETURN(HevcVdencPkt::Completed(mfxStatus, rcsStatus, statusReport)); + } + else + { + // When 422 wa feature is not enabled, not need above complete options + return MOS_STATUS_SUCCESS; + } + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::PatchPictureLevelCommands(const uint8_t &packetPhase, MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(m_miItf->SetWatchdogTimerThreshold(m_basicFeature->m_frameWidth, m_basicFeature->m_frameHeight, true)); + + SetPerfTag(CODECHAL_ENCODE_PERFTAG_CALL_PAK_ENGINE, (uint16_t)m_basicFeature->m_mode, m_basicFeature->m_pictureCodingType); + + ENCODE_CHK_STATUS_RETURN(AddForceWakeup(cmdBuffer)); + + // Send command buffer header at the beginning (OS dependent) + ENCODE_CHK_STATUS_RETURN(SendPrologCmds(cmdBuffer)); + + ENCODE_CHK_STATUS_RETURN(StartStatusReport(statusReportMfx, &cmdBuffer)); + + ENCODE_CHK_STATUS_RETURN(AddPictureHcpCommands(cmdBuffer)); + + ENCODE_CHK_STATUS_RETURN(AddPicStateWithNoTile(cmdBuffer)); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::PatchSliceLevelCommands(MOS_COMMAND_BUFFER &cmdBuffer, uint8_t packetPhase) +{ + ENCODE_FUNC_CALL(); + + if (m_hevcPicParams->tiles_enabled_flag) + { + return MOS_STATUS_SUCCESS; + } + ENCODE_CHK_STATUS_RETURN(SetBatchBufferForPakSlices()); + + PCODEC_ENCODER_SLCDATA slcData = m_basicFeature->m_slcData; + for (uint32_t startLcu = 0, slcCount = 0; slcCount < m_basicFeature->m_numSlices; slcCount++) + { + if (m_pipeline->IsFirstPass()) + { + slcData[slcCount].CmdOffset = startLcu * (m_hcpItf->GetHcpPakObjSize()) * sizeof(uint32_t); + } + + m_basicFeature->m_curNumSlices = slcCount; + + ENCODE_CHK_STATUS_RETURN(SendHwSliceEncodeCommand(slcData, slcCount, cmdBuffer)); + + startLcu += m_hevcSliceParams[slcCount].NumLCUsInSlice; + + m_batchBufferForPakSlicesStartOffset = (uint32_t)m_batchBufferForPakSlices[m_basicFeature->m_currPakSliceIdx].iCurrent; + } + + if (m_useBatchBufferForPakSlices) + { + ENCODE_CHK_STATUS_RETURN(Mhw_UnlockBb( + m_osInterface, + &m_batchBufferForPakSlices[m_basicFeature->m_currPakSliceIdx], + m_lastTaskInPhase)); + } + + // Insert end of sequence/stream if set + if (m_basicFeature->m_lastPicInSeq || m_basicFeature->m_lastPicInStream) + { + ENCODE_CHK_STATUS_RETURN(InsertSeqStreamEnd(cmdBuffer)); + } + + ENCODE_CHK_STATUS_RETURN(ReadHcpStatus(m_vdboxIndex, m_statusReport, cmdBuffer)); + ENCODE_CHK_STATUS_RETURN(ReadExtStatistics(cmdBuffer)); + ENCODE_CHK_STATUS_RETURN(ReadSliceSize(cmdBuffer)); + + ENCODE_CHK_STATUS_RETURN(EndStatusReport(statusReportMfx, &cmdBuffer)); + + if (m_osInterface->bInlineCodecStatusUpdate) + { + ENCODE_CHK_STATUS_RETURN(UpdateStatusReportNext(statusReportGlobalCount, &cmdBuffer)); + } + + CODECHAL_DEBUG_TOOL( + if (m_mmcState) { + m_mmcState->UpdateUserFeatureKey(&(m_basicFeature->m_reconSurface)); + }) + // Reset parameters for next PAK execution + if (false == m_pipeline->IsFrameTrackingEnabled() && m_pipeline->IsLastPass() && m_pipeline->IsLastPipe()) + { + UpdateParameters(); + } + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::AddPicStateWithNoTile(MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + + bool tileEnabled = false; + RUN_FEATURE_INTERFACE_RETURN(HevcEncodeTile, HevcFeatureIDs::encodeTile, IsEnabled, tileEnabled); + if (tileEnabled) + { + return MOS_STATUS_SUCCESS; + } + + SETPAR_AND_ADDCMD(HCP_PIC_STATE, m_hcpItf, &cmdBuffer); + + SETPAR_AND_ADDCMD(HEVC_VP9_RDOQ_STATE, m_hcpItf, &cmdBuffer); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::SendHwSliceEncodeCommand(const PCODEC_ENCODER_SLCDATA slcData, const uint32_t currSlcIdx, MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + + PMHW_BATCH_BUFFER batchBufferInUse = nullptr; + PMOS_COMMAND_BUFFER cmdBufferInUse = nullptr; + + if (m_useBatchBufferForPakSlices) + { + batchBufferInUse = &m_batchBufferForPakSlices[m_basicFeature->m_currPakSliceIdx]; + ENCODE_CHK_NULL_RETURN(batchBufferInUse); + } + else + { + cmdBufferInUse = &cmdBuffer; + } + + ENCODE_CHK_STATUS_RETURN(AddAllCmds_HCP_REF_IDX_STATE(&cmdBuffer)); + + ENCODE_CHK_STATUS_RETURN(AddAllCmds_HCP_WEIGHTOFFSET_STATE(&cmdBuffer)); + + m_basicFeature->m_useDefaultRoundingForHcpSliceState = true; + SETPAR_AND_ADDCMD(HCP_SLICE_STATE, m_hcpItf, &cmdBuffer); + + ENCODE_CHK_STATUS_RETURN(AddAllCmds_HCP_PAK_INSERT_OBJECT(&cmdBuffer)); + + if (m_useBatchBufferForPakSlices && batchBufferInUse) + { + ENCODE_CHK_STATUS_RETURN(m_miItf->AddMiBatchBufferEnd(nullptr, batchBufferInUse)); + + MHW_BATCH_BUFFER secondLevelBatchBuffer; + MOS_ZeroMemory(&secondLevelBatchBuffer, sizeof(MHW_BATCH_BUFFER)); + secondLevelBatchBuffer.OsResource = batchBufferInUse->OsResource; + secondLevelBatchBuffer.dwOffset = m_batchBufferForPakSlicesStartOffset; + secondLevelBatchBuffer.bSecondLevel = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_BATCH_BUFFER_START(&cmdBuffer, &secondLevelBatchBuffer))); + } + + // Insert Batch Buffer Start command to send HCP_PAK_OBJ data for LCUs in this slice + MHW_BATCH_BUFFER secondLevelBatchBuffer; + MOS_ZeroMemory(&secondLevelBatchBuffer, sizeof(MHW_BATCH_BUFFER)); + secondLevelBatchBuffer.OsResource = *m_res422MbCodeBuffer; + secondLevelBatchBuffer.dwOffset = slcData[currSlcIdx].CmdOffset; + secondLevelBatchBuffer.bSecondLevel = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_BATCH_BUFFER_START(&cmdBuffer, &secondLevelBatchBuffer))); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + + auto &forceWakeupParams = m_miItf->MHW_GETPAR_F(MI_FORCE_WAKEUP)(); + forceWakeupParams = {}; + forceWakeupParams.bMFXPowerWellControl = false; + forceWakeupParams.bMFXPowerWellControlMask = true; + forceWakeupParams.bHEVCPowerWellControl = true; + forceWakeupParams.bHEVCPowerWellControlMask = true; + + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MI_FORCE_WAKEUP)(&cmdBuffer)); + + return MOS_STATUS_SUCCESS; +} + +MOS_STATUS HevcVdencPktRsvd::AddHcpPipeModeSelect(MOS_COMMAND_BUFFER &cmdBuffer) +{ + ENCODE_FUNC_CALL(); + + auto &vdControlStateParams = m_miItf->MHW_GETPAR_F(VD_CONTROL_STATE)(); + vdControlStateParams = {}; + vdControlStateParams.initialization = true; + + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(VD_CONTROL_STATE)(&cmdBuffer)); + + // 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)(&cmdBuffer)); + + SETPAR_AND_ADDCMD(HCP_PIPE_MODE_SELECT, m_hcpItf, &cmdBuffer); + + mfxWaitParams = {}; + mfxWaitParams.iStallVdboxPipeline = true; + ENCODE_CHK_STATUS_RETURN(m_miItf->MHW_ADDCMD_F(MFX_WAIT)(&cmdBuffer)); + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HCP_PIPE_MODE_SELECT, HevcVdencPktRsvd) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_STATUS_RETURN(HevcVdencPkt::MHW_SETPAR_F(HCP_PIPE_MODE_SELECT)(params)); + + params.bVdencEnabled = false; + params.bBRCEnabled = false; + params.bAdvancedRateControlEnable = false; + + ENCODE_CHK_NULL_RETURN(m_basicFeature); + ENCODE_CHK_NULL_RETURN(m_basicFeature->m_hevcSeqParams); + params.bStreamOutEnabled = m_basicFeature->m_hevcSeqParams->RateControlMethod != RATECONTROL_CQP; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HCP_SLICE_STATE, HevcVdencPktRsvd) +{ + ENCODE_FUNC_CALL(); + + ENCODE_CHK_NULL_RETURN(m_basicFeature); + uint32_t currSlcIdx = m_basicFeature->m_curNumSlices; + PCODEC_HEVC_ENCODE_PICTURE_PARAMS hevcPicParams = (CODEC_HEVC_ENCODE_PICTURE_PARAMS *)m_hevcPicParams; + + params.cabaczerowordinsertionenable = 1; + params.intrareffetchdisable = false; + params.tailInsertionEnable = (hevcPicParams->bLastPicInSeq || hevcPicParams->bLastPicInStream) && ((currSlcIdx == m_basicFeature->m_numSlices - 1)); + params.roundintra = m_basicFeature->m_roundingIntra; + params.roundinter = m_basicFeature->m_roundingInter; + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HCP_IND_OBJ_BASE_ADDR_STATE, HevcVdencPktRsvd) +{ + ENCODE_FUNC_CALL(); + + params.presMvObjectBuffer = m_res422MbCodeBuffer; + params.dwMvObjectOffset = m_422mvOffset; + params.dwMvObjectSize = m_422mbCodeSize - m_422mvOffset; + params.presPakBaseObjectBuffer = &m_basicFeature->m_resBitstreamBuffer; + params.dwPakBaseObjectSize = m_basicFeature->m_bitstreamSize; + + return MOS_STATUS_SUCCESS; +} + +MHW_SETPAR_DECL_SRC(HCP_PIC_STATE, HevcVdencPktRsvd) +{ + params.sseEnable = false; + params.rhodomainRateControlEnable = false; + params.fractionalQpAdjustmentEnable = false; + + ENCODE_CHK_NULL_RETURN(m_basicFeature); + ENCODE_CHK_NULL_RETURN(m_basicFeature->m_hevcSeqParams); + if (m_basicFeature->m_hevcSeqParams->RateControlMethod == RATECONTROL_CBR) + { + auto brcFeature = dynamic_cast(m_featureManager->GetFeature(HevcFeatureIDs::hevcBrcFeature)); + ENCODE_CHK_NULL_RETURN(brcFeature); + + auto vdenc2ndLevelBatchBuffer = brcFeature->GetVdenc2ndLevelBatchBuffer(m_pipeline->m_currRecycledBufIdx); + ENCODE_CHK_NULL_RETURN(vdenc2ndLevelBatchBuffer); + + MOS_LOCK_PARAMS lockFlags; + MOS_ZeroMemory(&lockFlags, sizeof(MOS_LOCK_PARAMS)); + lockFlags.ReadOnly = 1; + uint32_t *data = (uint32_t *)m_osInterface->pfnLockResource(m_osInterface, &(vdenc2ndLevelBatchBuffer->OsResource), &lockFlags); + ENCODE_CHK_NULL_RETURN(data); + + uint32_t value = *(data + MINFRAMESIZE_OFFSET_RSVD); + params.minframesize = (uint16_t)value; + params.minframesizeunits = (uint8_t)(value >> 30); + + m_osInterface->pfnUnlockResource(m_osInterface, &(vdenc2ndLevelBatchBuffer->OsResource)); + } + + return MOS_STATUS_SUCCESS; +} + +} // namespace encode diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_rsvd.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_rsvd.h new file mode 100644 index 0000000000..b89a9c59a3 --- /dev/null +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/encode_hevc_vdenc_packet_rsvd.h @@ -0,0 +1,125 @@ +/* +* 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_rsvd.h +//! \brief Defines the interface to adapt to HEVC VDENC pipeline +//! + +#ifndef __CODECHAL_HEVC_VDENC_PACKET_RSVD_H__ +#define __CODECHAL_HEVC_VDENC_PACKET_RSVD_H__ + +#include "encode_hevc_vdenc_packet.h" + +namespace encode +{ +#define MINFRAMESIZE_OFFSET_RSVD 0x3D + +struct PAKOBJOutput +{ + uint32_t DW0; + uint32_t DW1; +}; + +struct OutputInfoLCU +{ + PAKOBJOutput DW[5]; +}; + +struct OutputCuInfo +{ + PAKOBJOutput DW[8]; +}; + +struct InputCuInfo +{ + uint32_t DW0; + uint32_t DW1; + uint32_t DW2; + uint32_t DW3; + uint32_t DW4; + uint32_t DW5; + uint32_t DW6; + uint32_t DW7; +}; + +struct InputLcuInfo +{ + uint32_t DW0; + uint32_t DW1; + uint32_t DW2; + uint32_t DW3; + uint32_t DW4; + uint32_t DW5; + uint32_t DW6; + uint32_t DW7; +}; + +class HevcVdencPktRsvd : public HevcVdencPkt +{ +public: + HevcVdencPktRsvd(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterface *hwInterface) : + HevcVdencPkt(pipeline, task, hwInterface) {} + virtual ~HevcVdencPktRsvd() {} + + MOS_STATUS AllocateResources() override; + + MOS_STATUS Conversion(); //OutputInfo conversion to InputInfo + + MOS_STATUS Prepare() override; + MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override; + + MOS_STATUS PatchPictureLevelCommands(const uint8_t &packetPhase, MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS PatchSliceLevelCommands(MOS_COMMAND_BUFFER &cmdBuffer, uint8_t packetPhase) override; + MOS_STATUS AddPicStateWithNoTile(MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS SendHwSliceEncodeCommand(const PCODEC_ENCODER_SLCDATA slcData, const uint32_t currSlcIdx, MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer) override; + MOS_STATUS AddHcpPipeModeSelect(MOS_COMMAND_BUFFER &cmdBuffer) override; + + virtual std::string GetPacketName() override + { + return "STANDALONE_PAK_PASS" + std::to_string((uint32_t)m_pipeline->GetCurrentPass()); + } + + MHW_SETPAR_DECL_HDR(HCP_PIPE_MODE_SELECT); + + MHW_SETPAR_DECL_HDR(HCP_SLICE_STATE); + + MHW_SETPAR_DECL_HDR(HCP_IND_OBJ_BASE_ADDR_STATE); + + MHW_SETPAR_DECL_HDR(HCP_PIC_STATE); + +protected: + PMOS_RESOURCE m_res422MbCodeBuffer = nullptr; //!< Pointer to MOS_RESOURCE of MbCode buffer + uint32_t m_422mvOffset = 0; //!< MV data offset, in 64 byte + uint32_t m_422mbCodeSize = 0; //!< MB code buffer size + uint32_t m_422maxNumLCUs = 0; //!< MB code buffer size + +#if USE_CODECHAL_DEBUG_TOOL + bool m_bDumpConvertedBuf = false; //!< refine later + bool m_bLoadFromFile = false; //!< refine later +#endif + +MEDIA_CLASS_DEFINE_END(encode__HevcVdencPktRsvd) +}; + +} // namespace encode +#endif diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/media_srcs.cmake b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/media_srcs.cmake index 53fd36de92..d15b0a6cab 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/media_srcs.cmake +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/packet/media_srcs.cmake @@ -28,6 +28,7 @@ set(TMP_SOURCES_ ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_tile_replay_packet.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_huc_la_init_packet.cpp ${CMAKE_CURRENT_LIST_DIR}/encode_huc_la_update_packet.cpp + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_packet_rsvd.cpp ) set(TMP_HEADERS_ @@ -39,6 +40,8 @@ set(TMP_HEADERS_ ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_tile_replay_packet.h ${CMAKE_CURRENT_LIST_DIR}/encode_huc_la_init_packet.h ${CMAKE_CURRENT_LIST_DIR}/encode_huc_la_update_packet.h + ${CMAKE_CURRENT_LIST_DIR}/encode_hevc_vdenc_packet_rsvd.h + ) endif() diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_pipeline.h b/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_pipeline.h index f92e0f7e2f..db92ff3da8 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_pipeline.h +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_pipeline.h @@ -60,9 +60,7 @@ class HevcPipeline : public EncodePipeline HucBrcTileRowUpdate, HucLaInit, HucLaUpdate, -#ifdef _ENCODE_RESERVED hevcVdencPacketRsvd, -#endif }; protected: diff --git a/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline.cpp b/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline.cpp index f11d9934b5..8fac51cbd5 100644 --- a/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline.cpp +++ b/media_softlet/agnostic/common/codec/hal/enc/hevc/pipeline/encode_hevc_vdenc_pipeline.cpp @@ -142,7 +142,6 @@ MOS_STATUS HevcVdencPipeline::ActivateVdencVideoPackets() // Last element in m_activePacketList must be immediately submitted m_activePacketList.back().immediateSubmit = true; -#ifdef _ENCODE_RESERVED auto basicFeature = dynamic_cast(m_featureManager->GetFeature(FeatureIDs::basicFeature)); ENCODE_CHK_NULL_RETURN(basicFeature); if (basicFeature->m_rsvdState && basicFeature->m_rsvdState->GetFeatureRsvdFlag()) @@ -150,7 +149,6 @@ MOS_STATUS HevcVdencPipeline::ActivateVdencVideoPackets() m_activePacketList.front().frameTrackingRequested = false; ENCODE_CHK_STATUS_RETURN(ActivatePacket(hevcVdencPacketRsvd, true, 0, 0)); } -#endif return MOS_STATUS_SUCCESS; }