1 /* 2 * Copyright (c) 2019-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_av1_packet_g12_base.h 24 //! \brief Defines the implementation of gen12 base av1 decode packet 25 //! 26 27 #ifndef __DECODE_AV1_PACKET_G12_BASE_H__ 28 #define __DECODE_AV1_PACKET_G12_BASE_H__ 29 30 #include "media_cmd_packet.h" 31 #include "decode_av1_pipeline_g12_base.h" 32 #include "decode_utils.h" 33 #include "decode_av1_basic_feature_g12.h" 34 #include "decode_status_report.h" 35 #include "decode_av1_picture_packet_g12_base.h" 36 #include "decode_av1_tile_packet_g12_base.h" 37 38 namespace decode 39 { 40 41 class Av1DecodePkt_G12_Base : public CmdPacket, public MediaStatusReportObserver 42 { 43 public: Av1DecodePkt_G12_Base(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterface * hwInterface)44 Av1DecodePkt_G12_Base(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterface *hwInterface) 45 : CmdPacket(task) 46 { 47 if (pipeline != nullptr) 48 { 49 m_statusReport = pipeline->GetStatusReportInstance(); 50 m_featureManager = pipeline->GetFeatureManager(); 51 m_av1Pipeline = dynamic_cast<Av1PipelineG12_Base*>(pipeline); 52 } 53 if (hwInterface != nullptr) 54 { 55 m_hwInterface = hwInterface; 56 m_miInterface = hwInterface->GetMiInterface(); 57 m_osInterface = hwInterface->GetOsInterface(); 58 m_vdencInterface = hwInterface->GetVdencInterface(); 59 } 60 } ~Av1DecodePkt_G12_Base()61 virtual ~Av1DecodePkt_G12_Base(){}; 62 63 //! 64 //! \brief Initialize the media packet, allocate required resources 65 //! \return MOS_STATUS 66 //! MOS_STATUS_SUCCESS if success, else fail reason 67 //! 68 virtual MOS_STATUS Init() override; 69 70 //! 71 //! \brief Prepare interal parameters, should be invoked for each frame 72 //! \return MOS_STATUS 73 //! MOS_STATUS_SUCCESS if success, else fail reason 74 //! 75 virtual MOS_STATUS Prepare() override; 76 77 //! 78 //! \brief Destroy the media packet and release the resources 79 //! \return MOS_STATUS 80 //! MOS_STATUS_SUCCESS if success, else fail reason 81 //! 82 virtual MOS_STATUS Destroy() override; 83 84 //! 85 //! \brief One frame is completed 86 //! \param [in] mfxStatus 87 //! pointer to status buffer which for mfx 88 //! \param [in] rcsStatus 89 //! pointer to status buffer which for RCS 90 //! \param [in, out] statusReport 91 //! pointer of DecoderStatusReport 92 //! \return MOS_STATUS 93 //! MOS_STATUS_SUCCESS if success, else fail reason 94 //! 95 virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override; 96 97 //! 98 //! \brief Calculate Command Size 99 //! 100 //! \param [in, out] commandBufferSize 101 //! requested size 102 //! \param [in, out] requestedPatchListSize 103 //! requested size 104 //! \return MOS_STATUS 105 //! status 106 //! 107 MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override; 108 109 //! 110 //! \brief Get Packet Name 111 //! \return std::string 112 //! GetPacketName()113 virtual std::string GetPacketName() override 114 { 115 return "AV1_DECODE"; 116 } 117 GetSecondLvlBB()118 PMHW_BATCH_BUFFER GetSecondLvlBB() { return m_batchBuf; }; 119 120 protected: 121 //! 122 //! \brief Calculate Command Buffer Size 123 //! 124 //! \return uint32_t 125 //! Command buffer size calculated 126 //! 127 virtual uint32_t CalculateCommandBufferSize(); 128 129 //! 130 //! \brief Calculate Patch List Size 131 //! 132 //! \return uint32_t 133 //! Patchlist size calculated 134 //! 135 virtual uint32_t CalculatePatchListSize(); 136 137 void SetPerfTag(CODECHAL_MODE mode, uint16_t picCodingType); 138 139 bool IsPrologRequired(); 140 141 MOS_STATUS SendPrologWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested); 142 143 MOS_STATUS VdPipelineFlush(MOS_COMMAND_BUFFER & cmdBuffer); 144 145 MOS_STATUS MiFlush(MOS_COMMAND_BUFFER & cmdBuffer); 146 147 MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer); 148 149 virtual MOS_STATUS ReadAvpStatus(MediaStatusReport* statusReport, MOS_COMMAND_BUFFER& cmdBuffer); 150 151 virtual MOS_STATUS StartStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override; 152 virtual MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override; 153 MOS_STATUS InitPicLevelCmdBuffer(MHW_BATCH_BUFFER &batchBuffer, uint8_t *batchBufBase); 154 155 MediaFeatureManager *m_featureManager = nullptr; 156 Av1PipelineG12_Base *m_av1Pipeline = nullptr; 157 DecodeAllocator *m_allocator = nullptr; 158 PMOS_INTERFACE m_osInterface = nullptr; 159 Av1BasicFeatureG12 *m_av1BasicFeature = nullptr; 160 MhwVdboxVdencInterface *m_vdencInterface = nullptr; 161 CodechalHwInterface *m_hwInterface = nullptr; 162 DecodeMemComp *m_mmcState = nullptr; 163 164 Av1DecodePicPkt_G12_Base *m_picturePkt = nullptr; 165 Av1DecodeTilePkt_G12_Base *m_tilePkt = nullptr; 166 bool m_isLastTileInPartialFrm = false; 167 bool m_isFirstTileInPartialFrm = false; 168 169 // Parameters passed from application 170 const CodecAv1PicParams *m_av1PicParams = nullptr; //!< Pointer to picture parameter 171 172 uint32_t m_pictureStatesSize = 0; 173 uint32_t m_picturePatchListSize = 0; 174 uint32_t m_tileStatesSize = 0; 175 uint32_t m_tilePatchListSize = 0; 176 177 BatchBufferArray *m_secondLevelBBArray = nullptr; //!< Point to second level batch buffer 178 MOS_COMMAND_BUFFER m_picCmdBuffer; 179 PMHW_BATCH_BUFFER m_batchBuf = nullptr; 180 }; 181 182 } // namespace decode 183 #endif // !__DECODE_AV1_PACKET_G12_BASE_H__ 184 185