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 #ifndef D3D12_VIDEO_ENCODE_REFERENCES_MANAGER_H264_H 25 #define D3D12_VIDEO_ENCODE_REFERENCES_MANAGER_H264_H 26 27 #include "d3d12_video_types.h" 28 #include "d3d12_video_encoder_references_manager.h" 29 30 class d3d12_video_encoder_references_manager_h264 : public d3d12_video_encoder_references_manager_interface 31 { 32 public: 33 void begin_frame(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA curFrameData, 34 bool bUsedAsReference, 35 struct pipe_picture_desc *picture); 36 bool get_current_frame_picture_control_data(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA &codecAllocation); 37 D3D12_VIDEO_ENCODE_REFERENCE_FRAMES get_current_reference_frames(); 38 is_current_frame_used_as_reference()39 bool is_current_frame_used_as_reference() 40 { 41 return m_isCurrentFrameUsedAsReference; 42 } get_current_frame_recon_pic_output_allocation()43 D3D12_VIDEO_ENCODER_RECONSTRUCTED_PICTURE get_current_frame_recon_pic_output_allocation() 44 { 45 return m_CurrentFrameReferencesData.ReconstructedPicTexture; 46 } end_frame()47 void end_frame() 48 { } d3d12_video_encoder_references_manager_h264()49 d3d12_video_encoder_references_manager_h264() 50 { } ~d3d12_video_encoder_references_manager_h264()51 ~d3d12_video_encoder_references_manager_h264() 52 { } 53 54 private: 55 // Class helpers 56 void update_fifo_dpb_push_front_cur_recon_pic(); 57 void print_dpb(); 58 void print_l0_l1_lists(); 59 void print_mmco_lists(); 60 61 // Class members 62 struct d3d12_video_dpb 63 { 64 std::vector<ID3D12Resource *> pResources; 65 std::vector<uint32_t> pSubresources; 66 }; 67 68 struct current_frame_references_data 69 { 70 std::vector<D3D12_VIDEO_ENCODER_REFERENCE_PICTURE_DESCRIPTOR_H264> pReferenceFramesReconPictureDescriptors; 71 D3D12_VIDEO_ENCODER_RECONSTRUCTED_PICTURE ReconstructedPicTexture; 72 d3d12_video_dpb ReferenceTextures; 73 std::vector<UINT> pList0ReferenceFrames; 74 std::vector<UINT> pList1ReferenceFrames; 75 std::vector<D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264_REFERENCE_PICTURE_MARKING_OPERATION> pMemoryOps; 76 }; 77 current_frame_references_data m_CurrentFrameReferencesData; 78 79 bool m_isCurrentFrameUsedAsReference = false; 80 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264 m_curFrameState = {}; 81 }; 82 83 #endif 84