xref: /aosp_15_r20/external/mesa3d/src/gallium/drivers/d3d12/d3d12_video_enc_av1.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 
2 /*
3  * Copyright © Microsoft Corporation
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22  * IN THE SOFTWARE.
23  */
24 
25 #ifndef D3D12_VIDEO_ENC_AV1_H
26 #define D3D12_VIDEO_ENC_AV1_H
27 #include "d3d12_video_types.h"
28 
29 const uint32_t UNUSED_VIRTUAL_DPB_SLOT_PHYSICAL_INDEX = 0xFF;   // As per D3D12 spec
30 
31 size_t
32 d3d12_video_encoder_calculate_metadata_resolved_buffer_size_av1(uint32_t maxSliceNumber);
33 
34 bool
35 d3d12_video_encoder_update_current_encoder_config_state_av1(struct d3d12_video_encoder *pD3D12Enc,
36                                                             D3D12_VIDEO_SAMPLE srcTextureDesc,
37                                                             struct pipe_picture_desc *picture);
38 
39 void
40 d3d12_video_encoder_update_current_frame_pic_params_info_av1(struct d3d12_video_encoder *pD3D12Enc,
41                                                              struct pipe_video_buffer *srcTexture,
42                                                              struct pipe_picture_desc *picture,
43                                                              D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA &picParams,
44                                                              bool &bUsedAsReference);
45 
46 unsigned
47 d3d12_video_encoder_build_post_encode_codec_bitstream_av1(struct d3d12_video_encoder *pD3D12Enc,
48                                                           uint64_t associated_fence_value,
49                                                           EncodedBitstreamResolvedMetadata &associatedMetadata);
50 
51 D3D12_VIDEO_ENCODER_AV1_RESTORATION_TILESIZE
52 d3d12_video_encoder_looprestorationsize_uint_to_d3d12_av1(uint32_t pixel_size);
53 
54 unsigned
55 d3d12_video_encoder_looprestorationsize_d3d12_to_uint_av1(D3D12_VIDEO_ENCODER_AV1_RESTORATION_TILESIZE d3d12_type);
56 
57 void
58 upload_tile_group_obu(struct d3d12_video_encoder *pD3D12Enc,
59                       size_t tile_group_obu_size,
60                       size_t decode_tile_elements_size,
61                       std::vector<uint8_t> &staging_bitstream_buffer,
62                       size_t staging_bitstream_buffer_offset,
63                       pipe_resource *src_driver_bitstream,
64                       pipe_resource *comp_bit_destination,
65                       size_t comp_bit_destination_offset,
66                       const D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA *pFrameSubregionMetadata,
67                       size_t TileSizeBytes,   // Pass already +1'd from TileSizeBytesMinus1
68                       const D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES &TilesPartition,
69                       const av1_tile_group_t &tileGroup,
70                       size_t &written_bytes_to_staging_bitstream_buffer,
71                       std::vector<uint64_t> &pWrittenCodecUnitsSizes);
72 
73 
74 void
75 d3d12_video_encoder_store_current_picture_references_av1(d3d12_video_encoder *pD3D12Enc,
76                                                          uint64_t current_metadata_slot);
77 
78 #endif
79