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_jpeg_packet.h 24 //! \brief Defines the interface for jpeg decode packet. 25 //! 26 27 #ifndef __DECODE_JPEG_PACKET_H__ 28 #define __DECODE_JPEG_PACKET_H__ 29 30 #include "media_cmd_packet.h" 31 #include "codec_hw_next.h" 32 #include "decode_vdbox_mfx_common.h" 33 #include "decode_jpeg_basic_feature.h" 34 #include "decode_jpeg_pipeline.h" 35 #include "decode_utils.h" 36 #include "decode_jpeg_picture_packet.h" 37 38 namespace decode { 39 40 class JpegDecodePkt : public CmdPacket, public MediaStatusReportObserver 41 { 42 public: JpegDecodePkt(MediaPipeline * pipeline,MediaTask * task,CodechalHwInterfaceNext * hwInterface)43 JpegDecodePkt(MediaPipeline *pipeline, MediaTask *task, CodechalHwInterfaceNext *hwInterface) 44 : CmdPacket(task) 45 { 46 if (pipeline != nullptr) 47 { 48 m_statusReport = pipeline->GetStatusReportInstance(); 49 m_featureManager = pipeline->GetFeatureManager(); 50 m_jpegPipeline = dynamic_cast<JpegPipeline*>(pipeline); 51 } 52 if (hwInterface != nullptr) 53 { 54 m_hwInterface = hwInterface; 55 m_miItf = std::static_pointer_cast<mhw::mi::Itf>(hwInterface->GetMiInterfaceNext()); 56 m_osInterface = hwInterface->GetOsInterface(); 57 } 58 } ~JpegDecodePkt()59 virtual ~JpegDecodePkt(){}; 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 Destroy the media packet and release the resources 77 //! \return MOS_STATUS 78 //! MOS_STATUS_SUCCESS if success, else fail reason 79 //! 80 virtual MOS_STATUS Destroy() override; 81 82 //! 83 //! \brief One frame is completed 84 //! \param [in] mfxStatus 85 //! pointer to status buffer which for mfx 86 //! \param [in] rcsStatus 87 //! pointer to status buffer which for RCS 88 //! \param [in, out] statusReport 89 //! pointer of DecoderStatusReport 90 //! \return MOS_STATUS 91 //! MOS_STATUS_SUCCESS if success, else fail reason 92 //! 93 virtual MOS_STATUS Completed(void *mfxStatus, void *rcsStatus, void *statusReport) override; 94 95 //! 96 //! \brief Calculate Command Size 97 //! 98 //! \param [in, out] commandBufferSize 99 //! requested size 100 //! \param [in, out] requestedPatchListSize 101 //! requested size 102 //! \return MOS_STATUS 103 //! status 104 //! 105 MOS_STATUS CalculateCommandSize(uint32_t &commandBufferSize, uint32_t &requestedPatchListSize) override; 106 107 //! 108 //! \brief Get Packet Name 109 //! \return std::string 110 //! GetPacketName()111 virtual std::string GetPacketName() override 112 { 113 return "JPEG_DECODE"; 114 } 115 116 protected: 117 //! 118 //! \brief Calculate Command Buffer Size 119 //! 120 //! \return uint32_t 121 //! Command buffer size calculated 122 //! 123 virtual uint32_t CalculateCommandBufferSize(); 124 125 //! 126 //! \brief Calculate Patch List Size 127 //! 128 //! \return uint32_t 129 //! Patchlist size calculated 130 //! 131 virtual uint32_t CalculatePatchListSize(); 132 133 void SetPerfTag(CODECHAL_MODE mode, uint16_t picCodingType); 134 135 bool IsPrologRequired(); 136 137 MOS_STATUS SendPrologWithFrameTracking(MOS_COMMAND_BUFFER &cmdBuffer, bool frameTrackingRequested); 138 139 MOS_STATUS MiFlush(MOS_COMMAND_BUFFER & cmdBuffer); 140 141 MOS_STATUS AddForceWakeup(MOS_COMMAND_BUFFER &cmdBuffer); 142 143 MOS_STATUS ReadMfxStatus(MediaStatusReport* statusReport, MOS_COMMAND_BUFFER& cmdBuffer); 144 145 virtual MOS_STATUS StartStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override; 146 virtual MOS_STATUS EndStatusReport(uint32_t srType, MOS_COMMAND_BUFFER* cmdBuffer) override; 147 148 MediaFeatureManager *m_featureManager = nullptr; 149 JpegPipeline *m_jpegPipeline = nullptr; 150 DecodeAllocator *m_allocator = nullptr; 151 JpegBasicFeature *m_jpegBasicFeature = nullptr; 152 CodechalHwInterfaceNext *m_hwInterface = nullptr; 153 DecodeMemComp *m_mmcState = nullptr; 154 155 JpegDecodePicPkt *m_picturePkt = nullptr; 156 157 // Parameters passed from application 158 const CodecDecodeJpegPicParams *m_jpegPicParams = nullptr; //!< Pointer to picture parameter 159 160 161 uint32_t m_pictureStatesSize = 0; 162 uint32_t m_picturePatchListSize = 0; 163 164 MEDIA_CLASS_DEFINE_END(decode__JpegDecodePkt) 165 }; 166 167 } 168 #endif // !__DECODE_JPEG_PACKET_H__ 169