1 /* 2 * Copyright (c) 2020-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 //! 24 //! \file encode_vp9_huc_brc_init_packet.h 25 //! \brief Defines the implementation of huc init packet for VP9 26 //! 27 28 #ifndef __ENCODE_VP9_HUC_BRC_INIT_PACKET_H__ 29 #define __ENCODE_VP9_HUC_BRC_INIT_PACKET_H__ 30 31 #include "media_cmd_packet.h" 32 #include "encode_huc.h" 33 #include "media_pipeline.h" 34 #include "encode_utils.h" 35 #include "encode_vp9_basic_feature.h" 36 37 namespace encode 38 { 39 40 class Vp9HucBrcInitPkt : public EncodeHucPkt 41 { 42 public: 43 //! 44 //! \brief Vp9HucBrcInitPkt constructor 45 //! Vp9HucBrcInitPkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)46 Vp9HucBrcInitPkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) 47 : EncodeHucPkt(pipeline, task, hwInterface) {} 48 49 //! 50 //! \brief Vp9HucBrcInitPkt destructor 51 //! ~Vp9HucBrcInitPkt()52 virtual ~Vp9HucBrcInitPkt() {} 53 54 //! 55 //! \brief Initialize the media packet, allocate required resources 56 //! \return MOS_STATUS 57 //! MOS_STATUS_SUCCESS if success, else fail reason 58 //! 59 virtual MOS_STATUS Init() override; 60 61 //! 62 //! \brief Add the command sequence into the commandBuffer and 63 //! and return to the caller task 64 //! \param [in] commandBuffer 65 //! Pointer to the command buffer which is allocated by caller 66 //! \param [in] packetPhase 67 //! Indicate packet phase stage 68 //! \return MOS_STATUS 69 //! MOS_STATUS_SUCCESS if success, else fail reason 70 //! 71 MOS_STATUS Submit(MOS_COMMAND_BUFFER *commandBuffer, uint8_t packetPhase = otherPacket) override; 72 73 //! 74 //! \brief Calculate Command Size 75 //! 76 //! \param [in, out] commandBufferSize 77 //! requested size 78 //! \param [in, out] requestedPatchListSize 79 //! requested size 80 //! \return MOS_STATUS 81 //! status 82 //! 83 virtual MOS_STATUS CalculateCommandSize( 84 uint32_t &commandBufferSize, 85 uint32_t &requestedPatchListSize) override; 86 87 //! 88 //! \brief Dump output resources or infomation after submit 89 //! \return MOS_STATUS 90 //! MOS_STATUS_SUCCESS if success, else fail reason 91 //! 92 virtual MOS_STATUS DumpOutput() override; 93 94 //! 95 //! \brief Get Packet Name 96 //! \return std::string 97 //! GetPacketName()98 virtual std::string GetPacketName() override 99 { 100 return "BrcInit"; 101 } 102 103 protected: 104 //! 105 //! \brief Allocate resources 106 //! \return MOS_STATUS 107 //! MOS_STATUS_SUCCESS if success, else fail reason 108 //! 109 virtual MOS_STATUS AllocateResources() override; 110 111 //! 112 //! \brief Set huc dmem buffer 113 //! \return MOS_STATUS 114 //! MOS_STATUS_SUCCESS if success, else fail reason 115 //! 116 virtual MOS_STATUS SetDmemBuffer() const; 117 118 #if USE_CODECHAL_DEBUG_TOOL 119 //! 120 //! \brief Dump input resources or infomation after submit 121 //! \return MOS_STATUS 122 //! MOS_STATUS_SUCCESS if success, else fail reason 123 //! 124 virtual MOS_STATUS DumpInput() override; 125 #endif 126 127 MHW_SETPAR_DECL_HDR(HUC_IMEM_STATE); 128 MHW_SETPAR_DECL_HDR(HUC_DMEM_STATE); 129 MHW_SETPAR_DECL_HDR(HUC_VIRTUAL_ADDR_STATE); 130 131 MOS_RESOURCE m_resVdencBrcInitDmemBuffer = {0}; //!< VDENC BRC/Init DMEM buffer 132 Vp9BasicFeature *m_basicFeature = nullptr; //!< VP9 Basic Feature used in each frame 133 134 static constexpr uint32_t m_vdboxHucVp9VdencBrcInitKernelDescriptor = 11; //!< VDBox Huc VDEnc Brc init kernel descriptor 135 136 static const uint32_t m_brcInitDmem[48]; 137 138 MEDIA_CLASS_DEFINE_END(encode__Vp9HucBrcInitPkt) 139 }; 140 } // namespace encode 141 142 #endif 143