1 /* 2 * Copyright © Microsoft 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 (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24 25 #ifndef D3D12_VIDEO_DPB_STORAGE_MANAGER_INTERFACE_H 26 #define D3D12_VIDEO_DPB_STORAGE_MANAGER_INTERFACE_H 27 28 #include "d3d12_video_types.h" 29 30 struct d3d12_video_reconstructed_picture 31 { 32 ID3D12Resource *pReconstructedPicture; 33 uint32_t ReconstructedPictureSubresource; 34 IUnknown * pVideoHeap; 35 }; 36 37 struct d3d12_video_reference_frames 38 { 39 uint32_t NumTexture2Ds; 40 ID3D12Resource **ppTexture2Ds; 41 uint32_t * pSubresources; 42 IUnknown ** ppHeaps; 43 }; 44 45 // Defines interface for storing and retrieving the decoded picture buffer ID3D12Resources with 46 // the reconstructed pictures 47 // Implementors of this interface can decide how to do this, let Class1 and Class2 be implementors... 48 // for example Class1 can use a texture array and Class2 or an array of textures 49 class d3d12_video_dpb_storage_manager_interface 50 { 51 // d3d12_video_dpb_storage_manager_interface 52 public: 53 // Adds a new reference frame at a given position 54 virtual void insert_reference_frame(d3d12_video_reconstructed_picture pReconPicture, uint32_t dpbPosition) = 0; 55 56 // Gets a reference frame at a given position 57 virtual d3d12_video_reconstructed_picture get_reference_frame(uint32_t dpbPosition) = 0; 58 59 // Assigns a reference frame at a given position 60 virtual void assign_reference_frame(d3d12_video_reconstructed_picture pReconPicture, uint32_t dpbPosition) = 0; 61 62 // Removes a new reference frame at a given position and returns operation success 63 // pResourceUntracked is an optional output indicating if the removed resource was being tracked by the pool 64 virtual bool remove_reference_frame(uint32_t dpbPosition, bool *pResourceUntracked) = 0; 65 66 // Returns the resource allocation for a NEW reconstructed picture 67 virtual d3d12_video_reconstructed_picture get_new_tracked_picture_allocation() = 0; 68 69 // Returns whether it found the tracked resource on this instance pool tracking and was able to free it 70 virtual bool untrack_reconstructed_picture_allocation(d3d12_video_reconstructed_picture trackedItem) = 0; 71 72 // Returns true if the trackedItem was allocated (and is being tracked) by this class 73 virtual bool is_tracked_allocation(d3d12_video_reconstructed_picture trackedItem) = 0; 74 75 // resource pool size 76 virtual uint32_t get_number_of_tracked_allocations() = 0; 77 78 // number of resources in the pool that are marked as in use 79 virtual uint32_t get_number_of_in_use_allocations() = 0; 80 81 // Returns the number of pictures currently stored in the DPB 82 virtual uint32_t get_number_of_pics_in_dpb() = 0; 83 84 // Returns all the current reference frames stored in the storage manager 85 virtual d3d12_video_reference_frames get_current_reference_frames() = 0; 86 87 // Remove all pictures from DPB 88 // returns the number of resources marked as reusable 89 virtual uint32_t clear_decode_picture_buffer() = 0; 90 ~d3d12_video_dpb_storage_manager_interface()91 virtual ~d3d12_video_dpb_storage_manager_interface() 92 { } 93 }; 94 95 #endif 96