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_ENC_H 25 #define D3D12_VIDEO_ENC_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 #include "d3d12_video_encoder_bitstream_builder_h264.h" 31 #include "d3d12_video_encoder_bitstream_builder_hevc.h" 32 #include "d3d12_video_encoder_bitstream_builder_av1.h" 33 #include <list> 34 35 /// 36 /// Pipe video interface starts 37 /// 38 39 /** 40 * creates a video encoder 41 */ 42 struct pipe_video_codec * 43 d3d12_video_encoder_create_encoder(struct pipe_context *context, const struct pipe_video_codec *templ); 44 45 /** 46 * destroy this video encoder 47 */ 48 void 49 d3d12_video_encoder_destroy(struct pipe_video_codec *codec); 50 51 /** 52 * start encoding of a new frame 53 */ 54 void 55 d3d12_video_encoder_begin_frame(struct pipe_video_codec * codec, 56 struct pipe_video_buffer *target, 57 struct pipe_picture_desc *picture); 58 59 /** 60 * encode to a bitstream 61 */ 62 void 63 d3d12_video_encoder_encode_bitstream(struct pipe_video_codec * codec, 64 struct pipe_video_buffer *source, 65 struct pipe_resource * destination, 66 void ** feedback); 67 68 int d3d12_video_encoder_get_encode_headers(struct pipe_video_codec *codec, 69 struct pipe_picture_desc *picture, 70 void* bitstream_buf, 71 unsigned *bitstream_buf_size); 72 /** 73 * Get feedback fence. 74 * 75 * Can be used to wait on the pipe_fence_handle directly instead 76 * of waiting on the get_feedback blocking call 77 */ 78 struct pipe_fence_handle* 79 d3d12_video_encoder_get_feedback_fence(struct pipe_video_codec *codec, void *feedback); 80 81 /** 82 * get encoder feedback 83 */ 84 void 85 d3d12_video_encoder_get_feedback(struct pipe_video_codec *codec, 86 void *feedback, 87 unsigned *size, 88 struct pipe_enc_feedback_metadata* pMetadata); 89 90 /** 91 * end encoding of the current frame 92 */ 93 void 94 d3d12_video_encoder_end_frame(struct pipe_video_codec * codec, 95 struct pipe_video_buffer *target, 96 struct pipe_picture_desc *picture); 97 98 /** 99 * flush async any outstanding command buffers to the hardware 100 * and returns to the caller without waiting for completion 101 */ 102 void 103 d3d12_video_encoder_flush(struct pipe_video_codec *codec); 104 105 /** 106 * Waits until the async work from the fenceValue has been completed in the device 107 * and releases the in-flight resources 108 */ 109 void 110 d3d12_video_encoder_sync_completion(struct pipe_video_codec *codec, uint64_t fenceValueToWaitOn, uint64_t timeout_ns); 111 112 /// 113 /// Pipe video interface ends 114 /// 115 116 enum d3d12_video_encoder_config_dirty_flags 117 { 118 d3d12_video_encoder_config_dirty_flag_none = 0x0, 119 d3d12_video_encoder_config_dirty_flag_codec = 0x1, 120 d3d12_video_encoder_config_dirty_flag_profile = 0x2, 121 d3d12_video_encoder_config_dirty_flag_level = 0x4, 122 d3d12_video_encoder_config_dirty_flag_codec_config = 0x8, 123 d3d12_video_encoder_config_dirty_flag_input_format = 0x10, 124 d3d12_video_encoder_config_dirty_flag_resolution = 0x20, 125 d3d12_video_encoder_config_dirty_flag_rate_control = 0x40, 126 d3d12_video_encoder_config_dirty_flag_slices = 0x80, 127 d3d12_video_encoder_config_dirty_flag_gop = 0x100, 128 d3d12_video_encoder_config_dirty_flag_motion_precision_limit = 0x200, 129 d3d12_video_encoder_config_dirty_flag_sequence_info = 0x400, 130 d3d12_video_encoder_config_dirty_flag_intra_refresh = 0x800, 131 }; 132 DEFINE_ENUM_FLAG_OPERATORS(d3d12_video_encoder_config_dirty_flags); 133 134 /// 135 /// d3d12_video_encoder functions starts 136 /// 137 138 struct D3D12EncodeCapabilities 139 { 140 bool m_fArrayOfTexturesDpb = false; 141 142 D3D12_VIDEO_ENCODER_SUPPORT_FLAGS m_SupportFlags = {}; 143 D3D12_VIDEO_ENCODER_VALIDATION_FLAGS m_ValidationFlags = {}; 144 D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOLUTION_SUPPORT_LIMITS m_currentResolutionSupportCaps = {}; 145 union 146 { 147 D3D12_VIDEO_ENCODER_PROFILE_H264 m_H264Profile; 148 D3D12_VIDEO_ENCODER_PROFILE_HEVC m_HEVCProfile; 149 D3D12_VIDEO_ENCODER_AV1_PROFILE m_AV1Profile; 150 } m_encoderSuggestedProfileDesc = {}; 151 152 union 153 { 154 D3D12_VIDEO_ENCODER_LEVELS_H264 m_H264LevelSetting; 155 D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC m_HEVCLevelSetting; 156 D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS m_AV1LevelSetting; 157 } m_encoderLevelSuggestedDesc = {}; 158 159 struct 160 { 161 union{ 162 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_H264 m_H264CodecCaps; 163 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC m_HEVCCodecCaps; 164 D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT m_AV1CodecCaps; 165 }; 166 D3D12_VIDEO_ENCODER_AV1_FRAME_SUBREGION_LAYOUT_CONFIG_SUPPORT m_AV1TileCaps; 167 D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAGS RequiredNotRequestedFeatureFlags; 168 } m_encoderCodecSpecificConfigCaps = {}; 169 170 // The maximum number of slices that the output of the current frame to be encoded will contain 171 uint32_t m_MaxSlicesInOutput = 0; 172 173 D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS m_ResourceRequirementsCaps = {}; 174 175 }; 176 177 struct D3D12EncodeRateControlState 178 { 179 D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE m_Mode = {}; 180 D3D12_VIDEO_ENCODER_RATE_CONTROL_FLAGS m_Flags = {}; 181 uint64_t max_frame_size = 0; 182 DXGI_RATIONAL m_FrameRate = {}; 183 union 184 { 185 D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP m_Configuration_CQP; 186 D3D12_VIDEO_ENCODER_RATE_CONTROL_CBR m_Configuration_CBR; 187 D3D12_VIDEO_ENCODER_RATE_CONTROL_VBR m_Configuration_VBR; 188 D3D12_VIDEO_ENCODER_RATE_CONTROL_QVBR m_Configuration_QVBR; 189 D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP1 m_Configuration_CQP1; 190 D3D12_VIDEO_ENCODER_RATE_CONTROL_CBR1 m_Configuration_CBR1; 191 D3D12_VIDEO_ENCODER_RATE_CONTROL_VBR1 m_Configuration_VBR1; 192 D3D12_VIDEO_ENCODER_RATE_CONTROL_QVBR1 m_Configuration_QVBR1; 193 } m_Config; 194 195 // AV1 uses 16 bit integers, H26x uses 8 bit integers 196 std::vector<int8_t> m_pRateControlQPMap8Bit; 197 std::vector<int16_t> m_pRateControlQPMap16Bit; 198 }; 199 200 struct D3D12EncodeConfiguration 201 { 202 d3d12_video_encoder_config_dirty_flags m_ConfigDirtyFlags = d3d12_video_encoder_config_dirty_flag_none; 203 204 D3D12_VIDEO_ENCODER_PICTURE_RESOLUTION_DESC m_currentResolution = {}; 205 D3D12_BOX m_FrameCroppingCodecConfig = {}; 206 207 D3D12_FEATURE_DATA_FORMAT_INFO m_encodeFormatInfo = {}; 208 209 D3D12_VIDEO_ENCODER_CODEC m_encoderCodecDesc = {}; 210 211 D3D12_VIDEO_ENCODER_SEQUENCE_CONTROL_FLAGS m_seqFlags = D3D12_VIDEO_ENCODER_SEQUENCE_CONTROL_FLAG_NONE; 212 213 /// As the following D3D12 Encode types have pointers in their structures, we need to keep a deep copy of them 214 215 union 216 { 217 D3D12_VIDEO_ENCODER_PROFILE_H264 m_H264Profile; 218 D3D12_VIDEO_ENCODER_PROFILE_HEVC m_HEVCProfile; 219 D3D12_VIDEO_ENCODER_AV1_PROFILE m_AV1Profile; 220 } m_encoderProfileDesc = {}; 221 222 union 223 { 224 D3D12_VIDEO_ENCODER_LEVELS_H264 m_H264LevelSetting; 225 D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC m_HEVCLevelSetting; 226 D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS m_AV1LevelSetting; 227 } m_encoderLevelDesc = {}; 228 229 struct D3D12EncodeRateControlState m_encoderRateControlDesc = {}; 230 231 union 232 { 233 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_H264 m_H264Config; 234 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC m_HEVCConfig; 235 D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION m_AV1Config; 236 } m_encoderCodecSpecificConfigDesc = {}; 237 238 239 D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE m_encoderSliceConfigMode = {}; 240 union 241 { 242 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_SLICES m_SlicesPartition_H264; 243 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_SLICES m_SlicesPartition_HEVC; 244 struct { 245 D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES TilesPartition; 246 uint8_t TilesGroupsCount; 247 av1_tile_group_t TilesGroups[128]; 248 } m_TilesConfig_AV1; 249 } m_encoderSliceConfigDesc = {}; 250 251 union 252 { 253 D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE_H264 m_H264GroupOfPictures; 254 D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE_HEVC m_HEVCGroupOfPictures; 255 D3D12_VIDEO_ENCODER_AV1_SEQUENCE_STRUCTURE m_AV1SequenceStructure; 256 } m_encoderGOPConfigDesc = {}; 257 258 union 259 { 260 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_H264 m_H264PicData; 261 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC m_HEVCPicData; 262 D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_CODEC_DATA m_AV1PicData; 263 } m_encoderPicParamsDesc = {}; 264 265 D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE m_encoderMotionPrecisionLimit = 266 D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM; 267 268 D3D12_VIDEO_ENCODER_INTRA_REFRESH m_IntraRefresh = { D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE, 0 }; 269 uint32_t m_IntraRefreshCurrentFrameIndex = 0; 270 271 struct D3D12AV1CodecSpecificState 272 { 273 std::list<UINT/*PictureIndex*/> pendingShowableFrames; 274 } m_encoderCodecSpecificStateDescAV1; 275 276 struct pipe_h264_enc_seq_param m_encoderCodecSpecificSequenceStateDescH264; 277 struct pipe_h265_enc_seq_param m_encoderCodecSpecificSequenceStateDescH265; 278 }; 279 280 struct EncodedBitstreamResolvedMetadata 281 { 282 ComPtr<ID3D12Resource> spBuffer; 283 uint64_t bufferSize = 0; 284 285 ComPtr<ID3D12Resource> m_spMetadataOutputBuffer; 286 /* 287 * We need to store a snapshot of the encoder state 288 * below as when get_feedback processes this other 289 * async queued frames might have changed it 290 */ 291 292 /* 293 * byte size of pre encode uploaded bitstream headers 294 * We need it in metadata as will be read in get_feedback 295 * to calculate the final size while other async encode 296 * operations (with potentially different headers) are being 297 * encoded in the GPU 298 */ 299 uint64_t preEncodeGeneratedHeadersByteSize = 0; 300 uint64_t preEncodeGeneratedHeadersBytePadding = 0; 301 std::vector<uint64_t> pWrittenCodecUnitsSizes; 302 303 /* 304 * Indicates if the encoded frame needs header generation after GPU execution 305 * If false, preEncodeGeneratedHeadersByteSize indicates the size of the generated 306 * headers (if any) 307 * 308 * If true, indicates the headers must be generated at get_feedback time. 309 */ 310 bool postEncodeHeadersNeeded = false; 311 312 /* Indicates if the current metadata has been read by get_feedback */ 313 bool bRead = true; 314 315 /* associated encoded frame state snapshot*/ 316 struct D3D12EncodeCapabilities m_associatedEncodeCapabilities = {}; 317 struct D3D12EncodeConfiguration m_associatedEncodeConfig = {}; 318 319 /* 320 * Associated frame compressed bitstream buffer 321 * If needed get_feedback will have to generate 322 * headers and re-pack the compressed bitstream 323 */ 324 pipe_resource* comp_bit_destination; 325 326 /* 327 * Staging bitstream for when headers must be 328 * packed in get_feedback, it contains the encoded 329 * stream from EncodeFrame. 330 */ 331 ComPtr<ID3D12Resource> spStagingBitstream; 332 333 /* codec specific associated configuration flags */ 334 union { 335 struct { 336 bool enable_frame_obu; 337 bool obu_has_size_field; 338 bool temporal_delim_rendered; 339 } AV1HeadersInfo; 340 } m_CodecSpecificData; 341 342 /* 343 * Scratch CPU buffer memory to generate any extra headers 344 * in between the GPU spStagingBitstream contents 345 */ 346 std::vector<uint8_t> m_StagingBitstreamConstruction; 347 348 /* Stores encode result for get_feedback readback in the D3D12_VIDEO_ENC_METADATA_BUFFERS_COUNT slots */ 349 enum pipe_video_feedback_encode_result_flags encode_result = PIPE_VIDEO_FEEDBACK_METADATA_ENCODE_FLAG_OK; 350 351 /* Expected max frame, slice sizes */ 352 uint64_t expected_max_frame_size = 0; 353 uint64_t expected_max_slice_size = 0; 354 355 /* Pending fence data for this frame */ 356 struct d3d12_fence m_FenceData; 357 }; 358 359 struct d3d12_video_encoder 360 { 361 struct pipe_video_codec base = {}; 362 struct pipe_screen * m_screen = nullptr; 363 struct d3d12_screen * m_pD3D12Screen = nullptr; 364 UINT max_quality_levels = 1; 365 366 /// 367 /// D3D12 objects and context info 368 /// 369 370 const uint m_NodeMask = 0u; 371 const uint m_NodeIndex = 0u; 372 373 ComPtr<ID3D12Fence> m_spFence; 374 uint64_t m_fenceValue = 1u; 375 bool m_bPendingWorkNotFlushed = false; 376 377 ComPtr<ID3D12VideoDevice3> m_spD3D12VideoDevice; 378 ComPtr<ID3D12VideoEncoder> m_spVideoEncoder; 379 ComPtr<ID3D12VideoEncoderHeap> m_spVideoEncoderHeap; 380 ComPtr<ID3D12CommandQueue> m_spEncodeCommandQueue; 381 ComPtr<ID3D12VideoEncodeCommandList2> m_spEncodeCommandList; 382 std::vector<D3D12_RESOURCE_BARRIER> m_transitionsBeforeCloseCmdList; 383 384 std::unique_ptr<d3d12_video_encoder_references_manager_interface> m_upDPBManager; 385 std::shared_ptr<d3d12_video_dpb_storage_manager_interface> m_upDPBStorageManager; 386 std::unique_ptr<d3d12_video_bitstream_builder_interface> m_upBitstreamBuilder; 387 388 std::vector<uint8_t> m_BitstreamHeadersBuffer; 389 std::vector<uint8_t> m_StagingHeadersBuffer; 390 std::vector<EncodedBitstreamResolvedMetadata> m_spEncodedFrameMetadata; 391 392 struct D3D12EncodeCapabilities m_currentEncodeCapabilities = {}; 393 struct D3D12EncodeConfiguration m_currentEncodeConfig = {}; 394 struct D3D12EncodeConfiguration m_prevFrameEncodeConfig = {}; 395 396 struct InFlightEncodeResources 397 { 398 // In case of reconfigurations that trigger creation of new 399 // encoder or encoderheap or reference frames allocations 400 // we need to keep a reference alive to the ones that 401 // are currently in-flight 402 ComPtr<ID3D12VideoEncoder> m_spEncoder; 403 ComPtr<ID3D12VideoEncoderHeap> m_spEncoderHeap; 404 std::shared_ptr<d3d12_video_dpb_storage_manager_interface> m_References; 405 406 ComPtr<ID3D12CommandAllocator> m_spCommandAllocator; 407 408 struct d3d12_fence* m_InputSurfaceFence = NULL; 409 410 /* Stores encode result for submission error control in the D3D12_VIDEO_ENC_ASYNC_DEPTH slots */ 411 enum pipe_video_feedback_encode_result_flags encode_result = PIPE_VIDEO_FEEDBACK_METADATA_ENCODE_FLAG_OK; 412 }; 413 414 std::vector<InFlightEncodeResources> m_inflightResourcesPool; 415 }; 416 417 bool 418 d3d12_video_encoder_create_command_objects(struct d3d12_video_encoder *pD3D12Enc); 419 bool 420 d3d12_video_encoder_reconfigure_session(struct d3d12_video_encoder *pD3D12Enc, 421 struct pipe_video_buffer * srcTexture, 422 struct pipe_picture_desc * picture); 423 bool 424 d3d12_video_encoder_update_current_encoder_config_state(struct d3d12_video_encoder *pD3D12Enc, 425 D3D12_VIDEO_SAMPLE srcTextureDesc, 426 struct pipe_picture_desc * picture); 427 bool 428 d3d12_video_encoder_reconfigure_encoder_objects(struct d3d12_video_encoder *pD3D12Enc, 429 struct pipe_video_buffer * srcTexture, 430 struct pipe_picture_desc * picture); 431 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA 432 d3d12_video_encoder_get_current_picture_param_settings(struct d3d12_video_encoder *pD3D12Enc); 433 D3D12_VIDEO_ENCODER_LEVEL_SETTING 434 d3d12_video_encoder_get_current_level_desc(struct d3d12_video_encoder *pD3D12Enc); 435 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION 436 d3d12_video_encoder_get_current_codec_config_desc(struct d3d12_video_encoder *pD3D12Enc); 437 D3D12_VIDEO_ENCODER_PROFILE_DESC 438 d3d12_video_encoder_get_current_profile_desc(struct d3d12_video_encoder *pD3D12Enc); 439 D3D12_VIDEO_ENCODER_RATE_CONTROL 440 d3d12_video_encoder_get_current_rate_control_settings(struct d3d12_video_encoder *pD3D12Enc); 441 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA 442 d3d12_video_encoder_get_current_slice_param_settings(struct d3d12_video_encoder *pD3D12Enc); 443 D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE 444 d3d12_video_encoder_get_current_gop_desc(struct d3d12_video_encoder *pD3D12Enc); 445 uint32_t 446 d3d12_video_encoder_get_current_max_dpb_capacity(struct d3d12_video_encoder *pD3D12Enc); 447 void 448 d3d12_video_encoder_create_reference_picture_manager(struct d3d12_video_encoder *pD3D12Enc, struct pipe_picture_desc * picture); 449 void 450 d3d12_video_encoder_update_picparams_tracking(struct d3d12_video_encoder *pD3D12Enc, 451 struct pipe_video_buffer * srcTexture, 452 struct pipe_picture_desc * picture); 453 void 454 d3d12_video_encoder_calculate_metadata_resolved_buffer_size(enum pipe_video_format codec, uint32_t maxSliceNumber, uint64_t &bufferSize); 455 uint32_t 456 d3d12_video_encoder_calculate_max_slices_count_in_output( 457 D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE slicesMode, 458 const D3D12_VIDEO_ENCODER_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_SLICES *slicesConfig, 459 uint32_t MaxSubregionsNumberFromCaps, 460 D3D12_VIDEO_ENCODER_PICTURE_RESOLUTION_DESC sequenceTargetResolution, 461 uint32_t SubregionBlockPixelsSize); 462 bool 463 d3d12_video_encoder_prepare_output_buffers(struct d3d12_video_encoder *pD3D12Enc, 464 struct pipe_video_buffer * srcTexture, 465 struct pipe_picture_desc * picture); 466 void 467 d3d12_video_encoder_build_pre_encode_codec_headers(struct d3d12_video_encoder *pD3D12Enc, 468 bool &postEncodeHeadersNeeded, 469 uint64_t &preEncodeGeneratedHeadersByteSize, 470 std::vector<uint64_t> &pWrittenCodecUnitsSizes); 471 void 472 d3d12_video_encoder_extract_encode_metadata( 473 struct d3d12_video_encoder * pD3D12Dec, 474 ID3D12Resource * pResolvedMetadataBuffer, 475 uint64_t resourceMetadataSize, 476 D3D12_VIDEO_ENCODER_OUTPUT_METADATA & encoderMetadata, 477 std::vector<D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA> &pSubregionsMetadata); 478 479 D3D12_VIDEO_ENCODER_CODEC 480 d3d12_video_encoder_get_current_codec(struct d3d12_video_encoder *pD3D12Enc); 481 482 bool 483 d3d12_video_encoder_negotiate_requested_features_and_d3d12_driver_caps(struct d3d12_video_encoder *pD3D12Enc, 484 D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT1 &capEncoderSupportData); 485 bool 486 d3d12_video_encoder_query_d3d12_driver_caps(struct d3d12_video_encoder *pD3D12Enc, 487 D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT1 &capEncoderSupportData); 488 bool 489 d3d12_video_encoder_check_subregion_mode_support(struct d3d12_video_encoder *pD3D12Enc, 490 D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE requestedSlicesMode); 491 uint64_t 492 d3d12_video_encoder_pool_current_index(struct d3d12_video_encoder *pD3D12Enc); 493 494 unsigned 495 d3d12_video_encoder_build_post_encode_codec_bitstream(struct d3d12_video_encoder * pD3D12Enc, 496 uint64_t associated_fence_value, 497 EncodedBitstreamResolvedMetadata& associatedMetadata); 498 499 void 500 d3d12_video_encoder_store_current_picture_references(d3d12_video_encoder *pD3D12Enc, 501 uint64_t current_metadata_slot); 502 503 504 // Implementation here to prevent template linker issues 505 template<typename T> 506 void 507 d3d12_video_encoder_update_picparams_region_of_interest_qpmap(struct d3d12_video_encoder *pD3D12Enc, 508 const struct pipe_enc_roi *roi_config, 509 int32_t min_delta_qp, 510 int32_t max_delta_qp, 511 std::vector<T>& pQPMap); 512 /// 513 /// d3d12_video_encoder functions ends 514 /// 515 516 #endif 517