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_vvc_reference_frames.h 24 //! \brief Defines reference list related logic for VVC decode 25 //! 26 #ifndef __DECODE_VVC_REFERENCE_FRAMES_H__ 27 #define __DECODE_VVC_REFERENCE_FRAMES_H__ 28 29 #include "codec_def_decode_vvc.h" 30 #include "mhw_vdbox.h" 31 #include "decode_allocator.h" 32 33 namespace decode 34 { 35 class VvcBasicFeature; 36 37 class VvcReferenceFrames 38 { 39 public: 40 //! 41 //! \brief VvcReferenceFrames constructor 42 //! 43 VvcReferenceFrames(); 44 45 //! 46 //! \brief VvcReferenceFrames deconstructor 47 //! 48 ~VvcReferenceFrames(); 49 50 //! 51 //! \brief Init Vvc reference frames 52 //! \param [in] basicFeature 53 //! Pointer to Vvc basic feature 54 //! \return MOS_STATUS 55 //! MOS_STATUS_SUCCESS if success, else fail reason 56 //! 57 MOS_STATUS Init(VvcBasicFeature *basicFeature, DecodeAllocator& allocator); 58 59 //! 60 //! \brief Update reference frames for picture 61 //! \param [in] picParams 62 //! Picture parameters 63 //! \return MOS_STATUS 64 //! MOS_STATUS_SUCCESS if success, else fail reason 65 //! 66 MOS_STATUS UpdatePicture(CodecVvcPicParams & picParams); 67 68 //! 69 //! \brief Get active reference list for current frame 70 //! \param [in] picParams 71 //! Picture parameters 72 //! \return std::vector<uint8_t> & 73 //! Active reference list indices for current frame 74 //! 75 const std::vector<uint8_t> &GetActiveReferenceList(CodecVvcPicParams &picParams); 76 77 //! 78 //! \brief Get frame surface with index equals to frameIndex 79 //! \param [in] frameIndex 80 //! Frame index for reference 81 //! \return PMOS_RESOURCE 82 //! The returned frame surface coresponding to frameIndex 83 //! 84 PMOS_RESOURCE GetReferenceByFrameIndex(uint8_t frameIndex); 85 86 //! 87 //! \brief Get reference picture attributes 88 //! \param [in] frameIndex 89 //! Frame index for reference 90 //! \return PMOS_RESOURCE 91 //! Attributes for the frame of frameIndex 92 //! 93 MOS_STATUS GetRefAttrByFrameIndex(uint8_t frameIndex, VvcRefFrameAttributes* attributes); 94 95 //! 96 //! \brief Get valid reference for error concealment 97 //! \return PMOS_RESOURCE 98 //! Valid reference resource 99 //! 100 PMOS_RESOURCE GetValidReference(); 101 102 //! 103 //! \brief Get frame index of the valid reference for error concealment. 104 //! \return PMOS_RESOURCE 105 //! Valid reference resource 106 //! GetValidReferenceFrameIdx()107 uint8_t GetValidReferenceFrameIdx() { return m_validRefFrameIdx; } 108 109 //! 110 //! \brief Update the current frame entry on m_refList 111 //! \param [in] picParams 112 //! Picture parameters 113 //! \return MOS_STATUS 114 //! MOS_STATUS_SUCCESS if success, else fail reason 115 //! 116 MOS_STATUS UpdateCurFrame(const CodecVvcPicParams &picParams); 117 118 //! 119 //! \brief Update the unavailable ref frames entries on m_refList 120 //! \param [in] picParams 121 //! Picture parameters 122 //! \return MOS_STATUS 123 //! MOS_STATUS_SUCCESS if success, else fail reason 124 //! 125 MOS_STATUS UpdateUnavailableRefFrames(const CodecVvcPicParams &picParams); 126 127 //! 128 //! \brief Calculate RPR constraints active flag 129 //! \param [in] refFrameIdx 130 //! Frame index for reference 131 //! \param [in] flag 132 //! The calculation result 133 //! \return MOS_STATUS 134 //! MOS_STATUS_SUCCESS if success, else fail reason 135 //! 136 MOS_STATUS CalcRprConstraintsActiveFlag(uint8_t refFrameIdx, bool& flag); 137 138 //! 139 //! \brief Update the current resource for currnet ref list 140 //! \param [in] pCurRefList 141 //! pointer of current ref list 142 //! \return MOS_STATUS 143 //! MOS_STATUS_SUCCESS if success, else fail reason 144 //! 145 MOS_STATUS UpdateCurResource(const PCODEC_REF_LIST_VVC pCurRefList); 146 147 PCODEC_REF_LIST_VVC m_refList[CODEC_MAX_DPB_NUM_VVC]; //!< Pointer to reference list, actually the DPB 148 PCODEC_REF_LIST_VVC m_currRefList = nullptr; //!< Current frame reference list 149 uint8_t m_validRefFrameIdx = CODEC_MAX_DPB_NUM_VVC; //!< the frame index for the valid reference for error concealment 150 bool m_curIsIntra = true; //!< Indicate current picture is intra 151 152 protected: 153 VvcBasicFeature *m_basicFeature = nullptr; //!< VVC basic feature 154 DecodeAllocator *m_allocator = nullptr; //!< Decode allocator 155 std::vector<uint8_t> m_activeReferenceList; //!< Active reference list of current picture 156 157 MEDIA_CLASS_DEFINE_END(decode__VvcReferenceFrames) 158 }; 159 160 } // namespace decode 161 162 #endif // !__DECODE_VVC_REFERENCE_FRAMES_H__ 163