1 /* 2 * Copyright (c) 2019, 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 encode_vp9_tile.h 24 //! \brief Defines the common interface for vp9 tile 25 //! 26 #ifndef __ENCODE_VP9_TILE_H__ 27 #define __ENCODE_VP9_TILE_H__ 28 29 #include "media_cmd_packet.h" 30 #include "encode_tile.h" 31 #include "mhw_vdbox_hcp_itf.h" 32 33 #include "encode_huc.h" 34 #include "media_pipeline.h" 35 #include "encode_utils.h" 36 #include "encode_vp9_pipeline.h" 37 #include "encode_vp9_vdenc_pipeline.h" 38 #include "encode_vp9_basic_feature.h" 39 40 namespace encode 41 { 42 // Integrated stats information 43 struct Vp9TileStatusInfo 44 { 45 uint32_t tileSizeRecord = 0; 46 uint32_t vdencStats = 0; 47 uint32_t pakStats = 0; 48 uint32_t counterBuffer = 0; 49 }; 50 51 class Vp9EncodeTile : public EncodeTile, public mhw::vdbox::huc::Itf::ParSetting, public mhw::vdbox::hcp::Itf::ParSetting, public mhw::vdbox::vdenc::Itf::ParSetting 52 { 53 public: 54 //! 55 //! \brief Vp9EncodeTile feature constructor 56 //! \param [in] featureManager 57 //! Pointer to MediaFeatureManager 58 //! \param [in] allocator 59 //! Pointer to EncodeAllocator 60 //! \param [in] hwInterface 61 //! Pointer to CodechalHwInterface 62 //! \param [in] constSettings 63 //! Pointer to const settings 64 //! 65 Vp9EncodeTile( 66 MediaFeatureManager *featureManager, 67 EncodeAllocator * allocator, 68 CodechalHwInterfaceNext *hwInterface, 69 void * constSettings); 70 71 //! 72 //! \brief Vp9EncodeTile feature destructor 73 //! ~Vp9EncodeTile()74 virtual ~Vp9EncodeTile() {} 75 76 //! 77 //! \brief Init encode tile feature's parameters setting 78 //! \param [in] setting 79 //! Pointer to CodechalSetting 80 //! \return MOS_STATUS 81 //! MOS_STATUS_SUCCESS if success, else fail reason 82 //! 83 virtual MOS_STATUS Init(void *settings) override; 84 85 //! 86 //! \brief Update encode tile feature parameters 87 //! \param [in] params 88 //! Pointer to EncoderParams 89 //! \return MOS_STATUS 90 //! MOS_STATUS_SUCCESS if success, else fail reason 91 //! 92 virtual MOS_STATUS Update(void *params) override; 93 94 //! 95 //! \brief Set current tile data Encode Tile feature refers to 96 //! \param [in] tileRow 97 //! Tile row idx to set 98 //! \param [in] tileCol 99 //! Tile column idx to set 100 //! \param [in] pipeline 101 //! Pipeline used 102 //! \return MOS_STATUS 103 //! MOS_STATUS_SUCCESS if success, else fail reason 104 //! 105 virtual MOS_STATUS SetCurrentTile( 106 uint32_t tileRow, 107 uint32_t tileCol, 108 EncodePipeline *pipeline) override; 109 110 //! 111 //! \brief Set regions for brc update 112 //! \param [in] params 113 //! Pointer to parameters 114 //! \return MOS_STATUS 115 //! MOS_STATUS_SUCCESS if success, else fail reason 116 //! 117 MOS_STATUS SetRegionsForBrcUpdate( 118 mhw::vdbox::huc::HUC_VIRTUAL_ADDR_STATE_PAR ¶ms) const; 119 120 //! 121 //! \brief Set regions for pak integrate 122 //! \param [in] params 123 //! Pointer to parameters 124 //! \return MOS_STATUS 125 //! MOS_STATUS_SUCCESS if success, else fail reason 126 //! 127 MOS_STATUS SetRegionsForPakInt( 128 mhw::vdbox::huc::HUC_VIRTUAL_ADDR_STATE_PAR ¶ms) const; 129 130 //! 131 //! \brief Set encode tile features setting to tile coding parameters 132 //! \param [in] activePipes 133 //! Active pipe number 134 //! \param [in, out] params 135 //! Pointer to tile coding parameters 136 //! \return MOS_STATUS 137 //! MOS_STATUS_SUCCESS if success, else fail reason 138 //! 139 MOS_STATUS SetHcpTileCodingParams( 140 uint32_t activePipes); 141 142 //! 143 //! \brief Set vdenc pipeline buffer address parameters 144 //! \param [out] pipeBufAddrParams 145 //! Reference to Pipe Buffer Address parameters 146 //! \return MOS_STATUS 147 //! MOS_STATUS_SUCCESS if success, else fail reason 148 //! 149 MOS_STATUS SetVdencPipeBufAddrParams( 150 MHW_VDBOX_PIPE_BUF_ADDR_PARAMS &pipeBufAddrParams); 151 152 //! 153 //! \brief Get tile level batch buffer from encode tile features 154 //! \param [out] vp9TileStatsOffset 155 //! Tile Stats offset 156 //! \param [out] vp9FrameStatsOffset 157 //! Frame Stats offset 158 //! \param [out] vp9StatsSize 159 //! Stats size. 160 //! \return MOS_STATUS 161 //! MOS_STATUS_SUCCESS if success, else fail reason 162 //! 163 MOS_STATUS GetTileStatusInfo( 164 Vp9TileStatusInfo &vp9TileStatsOffset, 165 Vp9TileStatusInfo &vp9FrameStatsOffset, 166 Vp9TileStatusInfo &vp9StatsSize); 167 168 //! 169 //! \brief MHW parameters declaration 170 //! 171 MHW_SETPAR_DECL_HDR(HCP_TILE_CODING); 172 MHW_SETPAR_DECL_HDR(HCP_IND_OBJ_BASE_ADDR_STATE); 173 MHW_SETPAR_DECL_HDR(HCP_PIPE_BUF_ADDR_STATE); 174 MHW_SETPAR_DECL_HDR(VDENC_PIPE_BUF_ADDR_STATE); 175 176 MHW_SETPAR_DECL_HDR(VDENC_WEIGHTSOFFSETS_STATE); 177 MHW_SETPAR_DECL_HDR(VDENC_HEVC_VP9_TILE_SLICE_STATE); 178 MHW_SETPAR_DECL_HDR(VDENC_WALKER_STATE); 179 180 protected: 181 //! 182 //! \brief Allocate feature related resources 183 //! \return MOS_STATUS 184 //! MOS_STATUS_SUCCESS if success, else fail reason 185 //! 186 virtual MOS_STATUS AllocateResources() override; 187 188 //! 189 //! \brief Setup Codechal Tile data for each tile 190 //! \param [in] params 191 //! Pointer to parameters 192 //! \return MOS_STATUS 193 //! MOS_STATUS_SUCCESS if success, else fail reason 194 //! 195 MOS_STATUS SetTileData(void *params) override; 196 197 //! 198 //! \brief Allocate Tile Statistics 199 //! \param [in] params 200 //! Pointer to parameters 201 //! \return MOS_STATUS 202 //! MOS_STATUS_SUCCESS if success, else fail reason 203 //! 204 MOS_STATUS AllocateTileStatistics(void *params) override; 205 206 static constexpr uint32_t m_probabilityCounterBufferSize = 193 * CODECHAL_CACHELINE_SIZE; 207 208 std::shared_ptr<mhw::vdbox::hcp::Itf> m_hcpInterfaceNew = nullptr; 209 210 Vp9TileStatusInfo m_tileStatsOffset = {}; // Page aligned offsets for HuC PAK Integration kernel input 211 Vp9TileStatusInfo m_frameStatsOffset = {}; // Page aligned offsets for HuC PAK Integration kernel output 212 Vp9TileStatusInfo m_statsSize = {}; // Sizes for the stats for HuC PAK Integration kernel input 213 214 MOS_RESOURCE m_resTileRecordStrmOutBuffer = {0}; //!< Tile record stream out buffer 215 MOS_RESOURCE m_resCuStatsStrmOutBuffer = {0}; //!< CU statistics stream out buffer 216 217 MEDIA_CLASS_DEFINE_END(encode__Vp9EncodeTile) 218 }; 219 220 } // namespace encode 221 222 #endif // !__ENCODE_VP9_TILE_H__ 223