1 /* 2 * Copyright (c) 2018, 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 encode_recycle_res_queue.h 24 //! \brief Defines the interface for recycle resources queue 25 //! 26 27 #ifndef __ENCODE_RECYCLE_RES_QUEUE_H__ 28 #define __ENCODE_RECYCLE_RES_QUEUE_H__ 29 30 #include "media_class_trace.h" 31 #include "mos_defs.h" 32 #include "mos_os.h" 33 #include <stdint.h> 34 #include <vector> 35 36 namespace encode 37 { 38 class EncodeAllocator; 39 40 class RecycleQueue 41 { 42 public: 43 enum ResourceType 44 { 45 INVALID, 46 BUFFER, 47 SURFACE 48 }; 49 50 //! 51 //! \brief Constructor 52 //! \param [in] param 53 //! reference of MOS_ALLOC_GFXRES_PARAMS 54 //! \param [in] maxLimit 55 //! The max limitation 56 //! 57 RecycleQueue(const MOS_ALLOC_GFXRES_PARAMS ¶m, EncodeAllocator *allocator, uint32_t maxLimit); 58 59 //! 60 //! \brief Destructor 61 //! 62 virtual ~RecycleQueue(); 63 64 //! 65 //! \brief Get resource from the free queue 66 //! \return void * 67 //! void * if success, else nullptr 68 //! 69 void *GetResource(uint32_t frameInde, ResourceType type); 70 71 //! 72 //! \brief destroy all resources in the resources queue 73 //! \param [in] allocator 74 //! Pointer to EncodeAllocator 75 //! \return MOS_STATUS 76 //! MOS_STATUS_SUCCESS if success, else fail reason 77 //! 78 MOS_STATUS DestroyAllResources(EncodeAllocator *allocator); 79 80 //! 81 //! \brief Whether the m_type match with the given type 82 //! \return bool 83 //! true if matched, else false 84 //! IsTypeMatched(ResourceType type)85 bool IsTypeMatched(ResourceType type) const 86 { 87 // Still didn't set the type, return true here, will be set later 88 if (m_type == INVALID) 89 { 90 return true; 91 } 92 93 return m_type == type; 94 } 95 private: 96 uint32_t m_maxLimit = 0; 97 ResourceType m_type = INVALID; 98 MOS_ALLOC_GFXRES_PARAMS m_param = {}; 99 EncodeAllocator *m_allocator = nullptr; //!< encoder allocator 100 std::vector<void *> m_resources; //<! All resources 101 102 MEDIA_CLASS_DEFINE_END(encode__RecycleQueue) 103 }; 104 } // namespace encode 105 #endif // !__ENCODE_RECYCLE_RES_QUEUE_H__ 106