• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_FIFO_REFERENCES_MANAGER_H264_H
25 #define D3D12_VIDEO_ENCODE_FIFO_REFERENCES_MANAGER_H264_H
26 
27 #include "d3d12_video_types.h"
28 #include "d3d12_video_encoder_references_manager.h"
29 #include "d3d12_video_dpb_storage_manager.h"
30 
31 class d3d12_video_encoder_references_manager_h264 : public d3d12_video_encoder_references_manager_interface
32 {
33  public:
34    void                                      end_frame();
35    void                                      begin_frame(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA curFrameData, bool bUsedAsReference);
36    D3D12_VIDEO_ENCODER_RECONSTRUCTED_PICTURE get_current_frame_recon_pic_output_allocation();
37    void get_current_frame_picture_control_data(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA &codecAllocation);
38    bool is_current_frame_used_as_reference();
39    D3D12_VIDEO_ENCODE_REFERENCE_FRAMES get_current_reference_frames();
40 
41    d3d12_video_encoder_references_manager_h264(bool                                       gopHasInterCodedFrames,
42                                                d3d12_video_dpb_storage_manager_interface &rDpbStorageManager,
43                                                uint32_t                                   MaxDPBCapacity);
44 
~d3d12_video_encoder_references_manager_h264()45    ~d3d12_video_encoder_references_manager_h264()
46    { }
47 
48  private:
49    // Class helpers
50    void prepare_current_frame_recon_pic_allocation();
51    void reset_gop_tracking_and_dpb();
52    void update_fifo_dpb_push_front_cur_recon_pic();
53    void print_dpb();
54    void print_l0_l1_lists();
55 
56    // Class members
57 
58    uint32_t m_MaxDPBCapacity      = 0;
59 
60    struct current_frame_references_data
61    {
62       std::vector<D3D12_VIDEO_ENCODER_REFERENCE_PICTURE_DESCRIPTOR_H264> pReferenceFramesReconPictureDescriptors;
63       D3D12_VIDEO_ENCODER_RECONSTRUCTED_PICTURE                          ReconstructedPicTexture;
64    };
65 
66    d3d12_video_dpb_storage_manager_interface &m_rDPBStorageManager;
67 
68    current_frame_references_data m_CurrentFrameReferencesData;
69 
70    bool m_gopHasInterFrames = false;
71 
72    bool m_isCurrentFrameUsedAsReference = false;
73    D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264 m_curFrameState = {};
74 };
75 
76 #endif
77