1 /* 2 * Copyright (c) 2020-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_vp8_picture_packet.h 24 //! \brief Defines the implementation of vp8 decode picture packet 25 //! 26 27 #ifndef __DECODE_VP8_PICTURE_PACKET_H__ 28 #define __DECODE_VP8_PICTURE_PACKET_H__ 29 30 #include "media_cmd_packet.h" 31 #include "decode_vp8_pipeline.h" 32 #include "decode_utils.h" 33 #include "decode_vp8_basic_feature.h" 34 #include "mhw_vdbox_mfx_itf.h" 35 36 using namespace mhw::vdbox::mfx; 37 38 namespace decode 39 { 40 class Vp8DecodePicPkt : public DecodeSubPacket, public Itf::ParSetting 41 { 42 public: 43 //! 44 //! \brief vp8DecodePicPkt constructor 45 //! Vp8DecodePicPkt(Vp8Pipeline * pipeline,CodechalHwInterfaceNext * hwInterface)46 Vp8DecodePicPkt(Vp8Pipeline *pipeline, CodechalHwInterfaceNext *hwInterface) 47 : DecodeSubPacket(pipeline, hwInterface), m_vp8Pipeline(pipeline) 48 { 49 if (m_hwInterface != nullptr) 50 { 51 m_mfxItf = std::static_pointer_cast<Itf>(m_hwInterface->GetMfxInterfaceNext()); 52 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext()); 53 } 54 } 55 56 //! 57 //! \brief Vp8DecodePicPkt deconstructor 58 //! 59 virtual ~Vp8DecodePicPkt(); 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 vp8 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 enum CodechalDecodeRefAddrIndex 97 { 98 // VP8 reference address indexes 99 CodechalDecodeLastRef = 0, //!< last reference 100 CodechalDecodeGoldenRef = 1, //!< golden reference 101 CodechalDecodeAlternateRef = 2 //!< alternate reference 102 }; 103 104 protected: 105 virtual MOS_STATUS SetRowstoreCachingOffsets(); 106 107 virtual MOS_STATUS SetRowStoreScratchBuffer(); 108 109 virtual MOS_STATUS SetSegmentationIdStreamBuffer(); 110 111 virtual MOS_STATUS AddMiForceWakeupCmd(MOS_COMMAND_BUFFER& cmdBuffer); 112 113 MHW_SETPAR_DECL_HDR(MFX_PIPE_MODE_SELECT); 114 MHW_SETPAR_DECL_HDR(MFX_SURFACE_STATE); 115 MHW_SETPAR_DECL_HDR(MFX_PIPE_BUF_ADDR_STATE); 116 MHW_SETPAR_DECL_HDR(MFX_IND_OBJ_BASE_ADDR_STATE); 117 MHW_SETPAR_DECL_HDR(MFX_BSP_BUF_BASE_ADDR_STATE); 118 MHW_SETPAR_DECL_HDR(MFX_VP8_PIC_STATE); 119 MOS_STATUS AddAllCmds_MFX_PIPE_MODE_SELECT(MOS_COMMAND_BUFFER &cmdBuffer); 120 121 //! 122 //! \brief Free resources 123 //! \return MOS_STATUS 124 //! MOS_STATUS_SUCCESS if success, else fail reason 125 //! 126 MOS_STATUS FreeResources(); 127 128 //! 129 //! \brief Dump resources 130 //! \return MOS_STATUS 131 //! MOS_STATUS_SUCCESS if success, else fail reason 132 //! 133 MOS_STATUS DumpResources(MFX_PIPE_BUF_ADDR_STATE_PAR &pipeBufAddrParams) const; 134 135 136 uint32_t m_pictureStatesSize = 0; //!< Picture state command size 137 uint32_t m_picturePatchListSize = 0; //!< Picture patch list size 138 139 // Internally maintained 140 PMOS_BUFFER m_resBsdMpcRowStoreScratchBuffer = nullptr; //!< Graphics resource of BSD/MPC Row Store Scratch data surface 141 PMOS_BUFFER m_resMprRowStoreScratchBuffer = nullptr; //!< Graphics resource of MPR Row Store Scratch data surface 142 PMOS_BUFFER m_resSegmentationIdStreamBuffer = nullptr; //!< Graphics resource of Segmentation ID Stream data surface 143 PMOS_BUFFER m_resMfdIntraRowStoreScratchBuffer = nullptr; //!< Graphics resource of MFD Intra Row Store Scratch data surface 144 PMOS_BUFFER m_resMfdDeblockingFilterRowStoreScratchBuffer = nullptr; //!< Graphics resource of MFD Deblocking Filter Row Store Scratch data surface 145 146 // Interfaces 147 Vp8Pipeline *m_vp8Pipeline = nullptr; 148 CODEC_VP8_PIC_PARAMS *m_vp8PicParams = nullptr; //!< Pointer to picture parameter 149 Vp8BasicFeature *m_vp8BasicFeature = nullptr; 150 DecodeMemComp *m_mmcState = nullptr; 151 DecodeAllocator *m_allocator = nullptr; 152 153 std::shared_ptr<Itf> m_mfxItf = nullptr; 154 155 MEDIA_CLASS_DEFINE_END(decode__Vp8DecodePicPkt) 156 }; 157 158 } // namespace decode 159 #endif 160