1 /* 2 * Copyright (c) 2021-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_avc_picture_packet.h 24 //! \brief Defines the implementation of avc decode picture packet 25 //! 26 27 #ifndef __DECODE_AVC_PICTURE_PACKET_H__ 28 #define __DECODE_AVC_PICTURE_PACKET_H__ 29 30 #include "media_cmd_packet.h" 31 #include "decode_avc_pipeline.h" 32 #include "decode_utils.h" 33 #include "decode_avc_basic_feature.h" 34 #include "decode_downsampling_packet.h" 35 #include "mhw_vdbox_mfx_itf.h" 36 37 using namespace mhw::vdbox::mfx; 38 namespace decode 39 { 40 class AvcDecodePicPkt : public DecodeSubPacket, public mhw::vdbox::mfx::Itf::ParSetting 41 { 42 public: 43 //! 44 //! \brief AvcDecodePicPkt constructor 45 //! AvcDecodePicPkt(AvcPipeline * pipeline,CodechalHwInterfaceNext * hwInterface)46 AvcDecodePicPkt(AvcPipeline *pipeline, CodechalHwInterfaceNext*hwInterface) 47 : DecodeSubPacket(pipeline, hwInterface), m_avcPipeline(pipeline) 48 { 49 if (m_hwInterface != nullptr) 50 { 51 m_mfxItf = std::static_pointer_cast<mhw::vdbox::mfx::Itf>(m_hwInterface->GetMfxInterfaceNext()); 52 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext()); 53 } 54 } 55 56 //! 57 //! \brief AvcDecodePicPkt deconstructor 58 //! 59 virtual ~AvcDecodePicPkt(); 60 61 //! 62 //! \brief Initialize the media packet, allocate required resources 63 //! \return MOS_STATUS 64 //! MOS_STATUS_SUCCESS if success, else fail reason 65 //! 66 virtual MOS_STATUS Init() override; 67 68 //! 69 //! \brief Prepare interal parameters, should be invoked for each frame 70 //! \return MOS_STATUS 71 //! MOS_STATUS_SUCCESS if success, else fail reason 72 //! 73 virtual MOS_STATUS Prepare() override; 74 75 //! 76 //! \brief Execute av1 picture packet 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! 80 virtual MOS_STATUS Execute(MOS_COMMAND_BUFFER &cmdBuffer) = 0; 81 82 //! 83 //! \brief Calculate Command Size 84 //! 85 //! \param [in, out] commandBufferSize 86 //! requested size 87 //! \param [in, out] requestedPatchListSize 88 //! requested size 89 //! \return MOS_STATUS 90 //! status 91 //! 92 MOS_STATUS CalculateCommandSize( 93 uint32_t &commandBufferSize, 94 uint32_t &requestedPatchListSize) override; 95 96 MOS_STATUS AddAllCmds_MFX_QM_STATE(PMOS_COMMAND_BUFFER cmdBuffer); 97 98 protected: 99 MHW_SETPAR_DECL_HDR(MFX_PIPE_MODE_SELECT); 100 MHW_SETPAR_DECL_HDR(MFX_SURFACE_STATE); 101 MHW_SETPAR_DECL_HDR(MFX_PIPE_BUF_ADDR_STATE); 102 MHW_SETPAR_DECL_HDR(MFX_IND_OBJ_BASE_ADDR_STATE); 103 MHW_SETPAR_DECL_HDR(MFX_BSP_BUF_BASE_ADDR_STATE); 104 MHW_SETPAR_DECL_HDR(MFX_AVC_IMG_STATE); 105 MHW_SETPAR_DECL_HDR(MFX_AVC_DIRECTMODE_STATE); 106 MHW_SETPAR_DECL_HDR(MFD_AVC_PICID_STATE); 107 MHW_SETPAR_DECL_HDR(MFD_AVC_DPB_STATE); 108 109 virtual MOS_STATUS AllocateFixedResources(); 110 virtual MOS_STATUS AllocateVariableResources(); 111 112 MOS_STATUS FixMfxPipeBufAddrParams() const; 113 114 MOS_STATUS SetResAvcDmvBuffers(); 115 //! \brief Set Rowstore Cache offset 116 //! 117 //! \return MOS_STATUS 118 //! MOS_STATUS_SUCCESS if success, else fail reason 119 //! 120 virtual MOS_STATUS SetRowstoreCachingOffsets(); 121 122 //! 123 //! \brief Free resources 124 //! \return MOS_STATUS 125 //! MOS_STATUS_SUCCESS if success, else fail reason 126 //! 127 MOS_STATUS FreeResources(); 128 129 MOS_STATUS SetSurfaceMmcState() const; 130 131 //! 132 //! \brief Dump resources 133 //! \return MOS_STATUS 134 //! MOS_STATUS_SUCCESS if success, else fail reason 135 //! 136 MOS_STATUS DumpResources(uint32_t mvBufferSize) const; 137 138 #ifdef _DECODE_PROCESSING_SUPPORTED 139 DecodeDownSamplingFeature *m_downSamplingFeature = nullptr; 140 DecodeDownSamplingPkt * m_downSamplingPkt = nullptr; 141 #endif 142 143 //Interfaces 144 AvcPipeline * m_avcPipeline = nullptr; 145 AvcBasicFeature * m_avcBasicFeature = nullptr; 146 DecodeAllocator * m_allocator = nullptr; 147 DecodeMemComp * m_mmcState = nullptr; 148 AvcReferenceFrames m_refFrames = {}; 149 std::shared_ptr<mhw::vdbox::mfx::Itf> m_mfxItf = nullptr; 150 151 CODEC_AVC_PIC_PARAMS *m_avcPicParams = nullptr; //!< Pointer to picture parameter 152 MOS_RESOURCE m_resAvcDmvBuffers[CODEC_AVC_NUM_DMV_BUFFERS]; 153 154 //non-temporal buffers 155 PMOS_BUFFER m_resMfdDeblockingFilterRowStoreScratchBuffer = nullptr; //!< Handle of MFD Deblocking Filter Row Store Scratch data surface 156 PMOS_BUFFER m_resMfdIntraRowStoreScratchBuffer = nullptr; //!< Handle of MFD Intra Row Store Scratch data surface 157 PMOS_BUFFER m_resBsdMpcRowStoreScratchBuffer = nullptr; //!< Handle of BSD/MPC Row Store Scratch data surface 158 PMOS_BUFFER m_resMprRowStoreScratchBuffer = nullptr; //!< Handle of MPR Row Store Scratch data surface 159 160 uint32_t m_pictureStatesSize = 0; //!< Picture states size 161 uint32_t m_picturePatchListSize = 0; //!< Picture patch list size 162 uint16_t m_picWidthInMbLastMaxAlloced = 0; //!< Max Picture Width in MB used for buffer allocation in past frames 163 uint16_t m_picHeightInMbLastMaxAlloced = 0; //!< Max Picture Height in MB used for buffer allocation in past frames 164 165 enum AvcDecoderFormatMode 166 { 167 shortFormatMode = 0, 168 longFormatMode = 1 169 }; 170 171 MEDIA_CLASS_DEFINE_END(decode__AvcDecodePicPkt) 172 }; 173 } // namespace decode 174 #endif 175