1 /* 2 * Copyright (c) 2019-2024, 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_status_report.h 24 //! \brief Defines the class for decode status report 25 //! \details 26 //! 27 #ifndef __DECODE_STATUS_REPORT_H__ 28 #define __DECODE_STATUS_REPORT_H__ 29 30 #include "media_status_report.h" 31 #include "decode_status_report_defs.h" 32 #include "codec_def_common.h" 33 #include "media_class_trace.h" 34 #include "mos_defs.h" 35 #include "mos_os_specific.h" 36 #include "decode_utils.h" 37 #include <stdint.h> 38 39 #define CODECHAL_DECODE_STATUS_NUM 512 40 41 namespace decode { 42 class DecodeAllocator; 43 44 //! 45 //! \struct DecodeStatusReportData 46 //! \brief Decode status report structure 47 //! 48 struct DecodeStatusReportData 49 { 50 //! \brief Status for the picture associated with this status report 51 CODECHAL_STATUS codecStatus = CODECHAL_STATUS_SUCCESSFUL; 52 //! \brief Status report number associated with the picture in this status report provided in Execute() 53 uint32_t statusReportNumber = 0; 54 //! \brief Uncompressed frame information for the picture associated with this status report 55 CODEC_PICTURE currDecodedPic = { 0 }; 56 //! \brief Applies for VC1 and MPEG2 only, uncompressed frame information for the out of loop deblock destination 57 CODEC_PICTURE currDeblockedPic = { 0 }; 58 //! \brief Pointer to the resource for the decode render target for the picture associated with this status report 59 MOS_RESOURCE currDecodedPicRes = { 0 }; 60 //! \brief Applies when debug dumps are enabled for VC1 only, resource of deblocked picture 61 MOS_RESOURCE deblockedPicResOlp = { 0 }; 62 //! \brief number of MBs decoded or if unused set to 0xFFFF 63 uint16_t numMbsAffected = 0; 64 //! \brief Crc of frame from MMIO 65 uint32_t frameCrc = 0; 66 67 #if (_DEBUG || _RELEASE_INTERNAL) 68 //! \brief Applies when debug dumps are enabled, pointer to SFC output resource for the picture associated with this status report 69 PMOS_SURFACE currSfcOutputSurface = nullptr; 70 //! \brief Applies when debug dumps are enabled, pointer to histogram output resource for the picture associated with this status report 71 PMOS_RESOURCE currHistogramOutBuf = nullptr; 72 //! \brief Applies when debug dumps are enabled, pointer to AV1 film grain output resource for the picture associated with this status report 73 PMOS_RESOURCE currFgOutputPicRes = nullptr; 74 //! \brief Applies when debug dumps are enabled, stream out buffer (legacy) 75 PMOS_RESOURCE streamOutBuf = nullptr; 76 //! \brief Applies when debug dumps are enabled, index of the streamout buffer (legacy) 77 uint32_t streamoutIdx = 0; 78 //! \brief Applies when debug dumps are enabled, stream in buffer 79 MOS_RESOURCE streamInBufRes = { 0 }; 80 //! \brief Applies when debug dumps are enabled, stream out buffer 81 MOS_RESOURCE streamOutBufRes = { 0 }; 82 //! \brief Applies when debug dumps are enabled, stream size 83 uint32_t streamSize = 0; 84 //! \brief Applies when debug dumps are enabled, indicates whether or not this is the final field in the frame. 85 bool secondField = false; 86 //! \brief Applies to VC1 only, indicates whether or not the frame required OLP. 87 bool olpNeeded = false; 88 //! \brief Applies when debug dumps are enabled, frame type (I/P/B) 89 uint16_t frameType = 0; 90 #endif // (_DEBUG || _RELEASE_INTERNAL) 91 }; 92 93 class DecodeStatusReport : public MediaStatusReport 94 { 95 public: 96 DecodeStatusReport(DecodeAllocator *alloc, bool enableRcs, PMOS_INTERFACE osInterface = nullptr); 97 virtual ~DecodeStatusReport(); 98 99 //! 100 //! \brief Create resources for status report and do initialization 101 //! \return MOS_STATUS 102 //! MOS_STATUS_SUCCESS if success, else fail reason 103 //! 104 virtual MOS_STATUS Create() override; 105 //! 106 //! \brief Destroy resources for status report 107 //! \return MOS_STATUS 108 //! MOS_STATUS_SUCCESS if success, else fail reason 109 //! 110 virtual MOS_STATUS Destroy(); 111 //! 112 //! \brief Initialize the status in report for each item 113 //! 114 //! \details Called per frame for normal usages. 115 //! It can be called per tilerow if enable tile replay mode. 116 //! 117 //! \param [in] inputPar 118 //! Pointer to parameters pass to status report. 119 //! \return MOS_STATUS 120 //! MOS_STATUS_SUCCESS if success, else fail reason 121 //! 122 virtual MOS_STATUS Init(void *inputPar) override; 123 //! 124 //! \brief Reset Status 125 //! 126 //! \details Called per frame for normal usages. 127 //! It can be called per tilerow if enable tile replay mode. 128 //! 129 //! \return MOS_STATUS 130 //! MOS_STATUS_SUCCESS if success, else fail reason 131 //! 132 virtual MOS_STATUS Reset() override; 133 134 //! 135 //! \brief Get Mfx status for frame specified by counter 136 //! \param [in] counter 137 //! The decode counter of requesting frame 138 //! \return DecodeStatusMfx 139 //! The Mfx status specified by counter 140 //! 141 const DecodeStatusMfx& GetMfxStatus(uint32_t counter); 142 143 //! 144 //! \brief Get report data for frame specified by counter 145 //! \param [in] counter 146 //! The decode counter of requesting frame 147 //! \return DecodeStatusReportData 148 //! The report data specified by counter 149 //! 150 const DecodeStatusReportData& GetReportData(uint32_t counter); 151 152 protected: 153 //! 154 //! \brief Collect the status report information into report buffer. 155 //! \param [in] report 156 //! The report buffer address provided by DDI. 157 //! \param [in] index 158 //! The index of current requesting report. 159 //! \return MOS_STATUS 160 //! MOS_STATUS_SUCCESS if success, else fail reason 161 //! 162 virtual MOS_STATUS ParseStatus(void *report, uint32_t index) override; 163 164 virtual MOS_STATUS SetStatus(void *report, uint32_t index, bool outOfRange = false) override; 165 166 //! 167 //! \brief Set size for Mfx status buffer. 168 //! \return void 169 //! 170 virtual void SetSizeForStatusBuf(); 171 172 //! 173 //! \brief Set offsets for Mfx status buffer. 174 //! \return void 175 //! 176 virtual void SetOffsetsForStatusBuf(); 177 178 //! 179 //! \brief Update the status result of current report. 180 //! \param [in] statusReportData 181 //! The pointer to DecodeStatusReportData. 182 //! \param [in] decodeStatus 183 //! The RCS status report buffer. 184 //! \param [in] completed 185 //! Whether the request frame completed. 186 //! \return MOS_STATUS 187 //! MOS_STATUS_SUCCESS if success, else fail reason 188 //! 189 virtual MOS_STATUS UpdateCodecStatus( 190 DecodeStatusReportData* statusReportData, 191 DecodeStatusMfx* decodeStatus, 192 bool completed); 193 194 protected: 195 196 bool m_enableRcs = false; 197 DecodeAllocator* m_allocator = nullptr; //!< Decode allocator 198 199 DecodeStatusReportData m_statusReportData[m_statusNum] = {}; 200 201 const uint32_t m_completedCountSize = sizeof(uint32_t) * 2; 202 uint32_t m_statusBufSizeMfx = 0; 203 uint32_t m_statusBufSizeRcs = 0; 204 205 PMOS_BUFFER m_statusBufMfx = nullptr; 206 PMOS_BUFFER m_statusBufRcs = nullptr; 207 uint8_t *m_dataStatusMfx = nullptr; 208 uint8_t *m_dataStatusRcs = nullptr; 209 PMOS_INTERFACE m_osInterface = nullptr; 210 211 MEDIA_CLASS_DEFINE_END(decode__DecodeStatusReport) 212 }; 213 } 214 215 #endif // !__DECODE_STATUS_REPORT_H__ 216