1 /* 2 * Copyright (c) 2022, Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 */ 22 //! 23 //! \file decode_hevc_picture_packet.h 24 //! \brief Defines the implementation of hevc decode picture packet 25 //! 26 27 #ifndef __DECODE_HEVC_PICTURE_PACKET_H__ 28 #define __DECODE_HEVC_PICTURE_PACKET_H__ 29 30 #include "media_cmd_packet.h" 31 #include "decode_hevc_pipeline.h" 32 #include "decode_utils.h" 33 #include "decode_hevc_basic_feature.h" 34 #include "decode_downsampling_packet.h" 35 #include "mhw_vdbox_hcp_itf.h" 36 37 namespace decode 38 { 39 class HevcDecodePicPkt : public DecodeSubPacket, public mhw::vdbox::hcp::Itf::ParSetting 40 { 41 public: HevcDecodePicPkt(HevcPipeline * pipeline,CodechalHwInterfaceNext * hwInterface)42 HevcDecodePicPkt(HevcPipeline *pipeline, CodechalHwInterfaceNext*hwInterface) 43 : DecodeSubPacket(pipeline, hwInterface), m_hevcPipeline(pipeline) 44 { 45 if (m_hwInterface != nullptr) 46 { 47 m_hcpItf = std::static_pointer_cast<mhw::vdbox::hcp::Itf>(m_hwInterface->GetHcpInterfaceNext()); 48 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(m_hwInterface->GetMiInterfaceNext()); 49 } 50 } 51 virtual ~HevcDecodePicPkt(); 52 53 //! 54 //! \brief Initialize the media packet, allocate required resources 55 //! \return MOS_STATUS 56 //! MOS_STATUS_SUCCESS if success, else fail reason 57 //! 58 virtual MOS_STATUS Init() override; 59 60 //! 61 //! \brief Prepare interal parameters, should be invoked for each frame 62 //! \return MOS_STATUS 63 //! MOS_STATUS_SUCCESS if success, else fail reason 64 //! 65 virtual MOS_STATUS Prepare() override; 66 67 //! \brief Set current phase for packet 68 //! 69 //! \return MOS_STATUS 70 //! MOS_STATUS_SUCCESS if success, else fail reason 71 //! 72 MOS_STATUS SetPhase(DecodePhase *phase); 73 74 //! \brief Store cabac stream out size to memory 75 //! 76 //! \return MOS_STATUS 77 //! MOS_STATUS_SUCCESS if success, else fail reason 78 //! 79 MOS_STATUS ReportCabacStreamOutSize(MOS_COMMAND_BUFFER &cmdBuffer); 80 81 //! 82 //! \brief Execute hevc picture packet 83 //! \return MOS_STATUS 84 //! MOS_STATUS_SUCCESS if success, else fail reason 85 //! 86 virtual MOS_STATUS Execute(MOS_COMMAND_BUFFER& cmdBuffer) = 0; 87 88 protected: 89 virtual MOS_STATUS AllocateFixedResources(); 90 virtual MOS_STATUS AllocateVariableResources(); 91 MOS_STATUS FixHcpPipeBufAddrParams(mhw::vdbox::hcp::HCP_PIPE_BUF_ADDR_STATE_PAR &par) const; 92 MOS_STATUS AddAllCmds_HCP_SURFACE_STATE(MOS_COMMAND_BUFFER &cmdBuffer); 93 MOS_STATUS AddAllCmds_HCP_QM_STATE(MOS_COMMAND_BUFFER &cmdBuffer); 94 95 MHW_SETPAR_DECL_HDR(HCP_PIPE_MODE_SELECT); 96 MHW_SETPAR_DECL_HDR(HCP_SURFACE_STATE); 97 MHW_SETPAR_DECL_HDR(HCP_PIPE_BUF_ADDR_STATE); 98 MHW_SETPAR_DECL_HDR(HCP_IND_OBJ_BASE_ADDR_STATE); 99 MHW_SETPAR_DECL_HDR(HCP_PIC_STATE); 100 MHW_SETPAR_DECL_HDR(HCP_TILE_STATE); 101 102 //! \brief Set Rowstore Cache offset 103 //! 104 //! \return MOS_STATUS 105 //! MOS_STATUS_SUCCESS if success, else fail reason 106 //! 107 virtual MOS_STATUS SetRowstoreCachingOffsets(); 108 109 virtual bool IsRealTilePhase(); 110 virtual bool IsFrontEndPhase(); 111 virtual bool IsBackEndPhase(); 112 113 //! 114 //! \brief Free resources 115 //! \return MOS_STATUS 116 //! MOS_STATUS_SUCCESS if success, else fail reason 117 //! 118 MOS_STATUS FreeResources(); 119 120 #if USE_CODECHAL_DEBUG_TOOL 121 MOS_STATUS DumpResources( 122 mhw::vdbox::hcp::HCP_PIPE_BUF_ADDR_STATE_PAR &pipeBufAddrParams, 123 uint8_t activeRefListSize, 124 uint32_t mvBufferSize) const; 125 #endif 126 127 static constexpr uint32_t sliceStateCachelinesPerSlice = 9; 128 static const uint32_t m_rawUVPlaneAlignment = 4; 129 static const uint32_t m_reconUVPlaneAlignment = 8; 130 static const uint32_t m_uvPlaneAlignmentLegacy = 8; //! starting Gen9 the alignment is relaxed to 4x instead of 16x 131 132 enum SIZEID 133 { 134 SIZEID_4X4 = 0, //!< No additional details 135 SIZEID_8X8 = 1, //!< No additional details 136 SIZEID_16X16 = 2, //!< No additional details 137 SIZEID_32X32 = 3, //!< (Illegal Value for Colour Component Chroma Cr and Cb.) 138 }; 139 140 HevcPipeline *m_hevcPipeline = nullptr; 141 HevcBasicFeature *m_hevcBasicFeature = nullptr; 142 DecodeAllocator *m_allocator = nullptr; 143 std::shared_ptr<mhw::vdbox::hcp::Itf> m_hcpItf = nullptr; 144 145 #ifdef _MMC_SUPPORTED 146 DecodeMemComp *m_mmcState = nullptr; 147 #endif 148 149 #ifdef _DECODE_PROCESSING_SUPPORTED 150 DecodeDownSamplingFeature *m_downSamplingFeature = nullptr; 151 DecodeDownSamplingPkt *m_downSamplingPkt = nullptr; 152 #endif 153 154 DecodePhase *m_phase = nullptr; 155 156 // Parameters passed from application 157 PCODEC_HEVC_PIC_PARAMS m_hevcPicParams = nullptr; //!< Pointer to picture parameter 158 PCODECHAL_HEVC_IQ_MATRIX_PARAMS m_hevcIqMatrixParams = nullptr; //!< Pointer to IQ matrix parameter 159 PCODEC_HEVC_EXT_PIC_PARAMS m_hevcRextPicParams = nullptr; //!< Extended pic params for Rext 160 PCODEC_HEVC_SCC_PIC_PARAMS m_hevcSccPicParams = nullptr; //!< Pic params for SCC 161 162 PMOS_BUFFER m_resMfdDeblockingFilterRowStoreScratchBuffer = nullptr; //!< Handle of MFD Deblocking Filter Row Store Scratch data surface 163 PMOS_BUFFER m_resDeblockingFilterTileRowStoreScratchBuffer = nullptr; //!< Handle of Deblocking Filter Tile Row Store Scratch data surface 164 PMOS_BUFFER m_resDeblockingFilterColumnRowStoreScratchBuffer = nullptr; //!< Handle of Deblocking Filter Column Row Store Scratch data surface 165 PMOS_BUFFER m_resMetadataLineBuffer = nullptr; //!< Handle of Metadata Line data buffer 166 PMOS_BUFFER m_resMetadataTileLineBuffer = nullptr; //!< Handle of Metadata Tile Line data buffer 167 PMOS_BUFFER m_resMetadataTileColumnBuffer = nullptr; //!< Handle of Metadata Tile Column data buffer 168 PMOS_BUFFER m_resSaoLineBuffer = nullptr; //!< Handle of SAO Line data buffer 169 PMOS_BUFFER m_resSaoTileLineBuffer = nullptr; //!< Handle of SAO Tile Line data buffer 170 PMOS_BUFFER m_resSaoTileColumnBuffer = nullptr; //!< Handle of SAO Tile Column data buffer 171 172 PMOS_BUFFER m_resSliceStateStreamOutBuffer = nullptr; //!< Handle of slice state stream out buffer 173 PMOS_BUFFER m_resMvUpRightColStoreBuffer = nullptr; //!< Handle of MV up right column store buffer 174 PMOS_BUFFER m_resIntraPredUpRightColStoreBuffer = nullptr; //!< Handle of intra prediction up right column store buffer 175 PMOS_BUFFER m_resIntraPredLeftReconColStoreBuffer = nullptr; //!< Handle of intra prediction left recon column store buffer 176 PMOS_BUFFER m_resCABACSyntaxStreamOutBuffer = nullptr; //!< Handle of CABAC syntax stream out buffer 177 PMOS_BUFFER m_resCABACStreamOutSizeBuffer = nullptr; //!< Handle of CABAC stream out size buffer 178 179 mutable uint8_t m_curHcpSurfStateId = 0; 180 181 MEDIA_CLASS_DEFINE_END(decode__HevcDecodePicPkt) 182 }; // class HevcDecodePicPkt 183 184 } // namespace decode 185 #endif 186