1 /* 2 * Copyright (c) 2021, 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_huc_prob_update_packet.h 24 //! \brief Defines the implementation of huc prob update packet for VP9 decode 25 //! 26 27 #ifndef __DECODE_HUC_PROB_UPDATE_PACKET_H__ 28 #define __DECODE_HUC_PROB_UPDATE_PACKET_H__ 29 30 #include "media_cmd_packet.h" 31 #include "decode_huc.h" 32 #include "media_pipeline.h" 33 #include "codec_hw_next.h" 34 #include "decode_utils.h" 35 #include "decode_vp9_pipeline.h" 36 #include "decode_vp9_basic_feature.h" 37 #include "decode_huc_packet_creator.h" 38 #include "mhw_vdbox_huc_cmdpar.h" 39 #include "mhw_vdbox_huc_itf.h" 40 #include "mhw_cmdpar.h" 41 42 namespace decode 43 { 44 struct HucVp9ProbBss 45 { 46 int32_t bSegProbCopy; //!< seg tree and pred prob update with values from App. 47 int32_t bProbSave; //!< Save prob buffer 48 int32_t bProbRestore; //!< Restore prob buffer 49 int32_t bProbReset; //!< 1: reset; 0: not reset 50 int32_t bResetFull; //!< full reset or partial (section A) reset 51 int32_t bResetKeyDefault; //!< reset to key or inter default 52 uint8_t SegTreeProbs[7]; //!< Segment tree prob buffers 53 uint8_t SegPredProbs[3]; //!< Segment predict prob buffers 54 }; 55 56 class HucVp9ProbUpdatePkt : public DecodeHucBasic, public mhw::vdbox::huc::Itf::ParSetting 57 { 58 public: HucVp9ProbUpdatePkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)59 HucVp9ProbUpdatePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) 60 : DecodeHucBasic(pipeline, task, hwInterface){} 61 62 virtual ~HucVp9ProbUpdatePkt(); 63 64 //! 65 //! \brief Initialize the media packet, allocate required resources 66 //! \return MOS_STATUS 67 //! MOS_STATUS_SUCCESS if success, else fail reason 68 //! 69 virtual MOS_STATUS Init() override; 70 71 //! 72 //! \brief Prepare interal parameters, should be invoked for each frame 73 //! \return MOS_STATUS 74 //! MOS_STATUS_SUCCESS if success, else fail reason 75 //! 76 virtual MOS_STATUS Prepare() override; 77 78 MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase = otherPacket) override; 79 80 //! 81 //! \brief Calculate Command Size 82 //! 83 //! \param [in, out] commandBufferSize 84 //! requested size 85 //! \param [in, out] requestedPatchListSize 86 //! requested size 87 //! \return MOS_STATUS 88 //! status 89 //! 90 virtual MOS_STATUS CalculateCommandSize( 91 uint32_t &commandBufferSize, 92 uint32_t &requestedPatchListSize) override; 93 94 //! 95 //! \brief Get Packet Name 96 //! \return std::string 97 //! GetPacketName()98 virtual std::string GetPacketName() override 99 { 100 return "VP9_PROB_UPDATE"; 101 } 102 103 MOS_STATUS VdPipelineFlush(MOS_COMMAND_BUFFER &cmdBuffer); 104 105 protected: 106 //! 107 //! \brief Calculate Command Buffer Size 108 //! 109 //! \return uint32_t 110 //! Command buffer size calculated 111 //! 112 virtual uint32_t CalculateCommandBufferSize(); 113 114 //! 115 //! \brief Calculate Patch List Size 116 //! 117 //! \return uint32_t 118 //! Patchlist size calculated 119 //! 120 virtual uint32_t CalculatePatchListSize(); 121 122 virtual MOS_STATUS AllocateResources() override; 123 124 virtual MOS_STATUS Execute(MOS_COMMAND_BUFFER &cmdBuffer, bool prologNeeded) override; 125 126 virtual MOS_STATUS PackPictureLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer); 127 MOS_STATUS PackSliceLevelCmds(MOS_COMMAND_BUFFER &cmdBuffer); 128 MOS_STATUS SetDmemBuffer(); 129 virtual MOS_STATUS AddCmd_HUC_IMEM_STATE(MOS_COMMAND_BUFFER &cmdBuffer); 130 MOS_STATUS AddCmd_HUC_PIPE_MODE_SELECT(MOS_COMMAND_BUFFER &cmdBuffer); 131 132 virtual MHW_SETPAR_DECL_HDR(HUC_DMEM_STATE); 133 virtual MHW_SETPAR_DECL_HDR(HUC_VIRTUAL_ADDR_STATE); 134 virtual MHW_SETPAR_DECL_HDR(HUC_START); 135 136 static constexpr uint32_t m_vdboxHucVp9ProbUpdateKernelDescriptor = 6; //!< Huc Vp9 prob update kernel descriptor 137 static constexpr uint32_t m_numVp9ProbUpdateDmem = 8; //!< Huc Vp9 prob update Dmem number 138 static constexpr uint32_t m_mediaResetCounter = 2400; //!< Media reset counter for Huc Vp9 prob update 139 140 Vp9BasicFeature *m_vp9BasicFeature = nullptr; //!< Pointer to vp9 basic feature 141 142 BufferArray *m_probUpdateDmemBufferArray = nullptr; //!< Vp9 prob update DMEM buffer array 143 MOS_BUFFER * m_probUpdateDmemBuffer = nullptr; //!< Resource of current DMEM buffer 144 uint32_t m_dmemBufferSize = 0; //!< Size of DMEM buffer 145 146 MOS_BUFFER *m_interProbSaveBuffer = nullptr; //!< Vp9 inter prob save buffer 147 148 uint32_t m_pictureStatesSize = 0; 149 uint32_t m_picturePatchListSize = 0; 150 uint32_t m_sliceStatesSize = 0; 151 uint32_t m_slicePatchListSize = 0; 152 153 MEDIA_CLASS_DEFINE_END(decode__HucVp9ProbUpdatePkt) 154 }; 155 156 } // namespace decode 157 #endif 158