Go to the documentation of this file.
23 #ifndef AVCODEC_D3D12VA_ENCODE_H
24 #define AVCODEC_D3D12VA_ENCODE_H
39 #define MAX_PARAM_BUFFER_SIZE 4096
40 #define D3D12VA_VIDEO_ENC_ASYNC_DEPTH 8
57 D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA
pic_ctl;
251 D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS
req;
253 D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOLUTION_SUPPORT_LIMITS
res_limits;
262 D3D12_VIDEO_ENCODER_RATE_CONTROL
rc;
264 D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE
gop;
266 D3D12_VIDEO_ENCODER_LEVEL_SETTING
level;
347 char *
data,
size_t *data_len);
361 #define D3D12VA_ENCODE_INTRA_REFRESH_MODE(name, mode, desc) \
362 { #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_ ## mode }, \
363 0, 0, FLAGS, .unit = "intra_refresh_mode" }
365 #define D3D12VA_ENCODE_COMMON_OPTIONS \
366 { "max_frame_size", \
367 "Maximum frame size (in bytes)",\
368 OFFSET(common.max_frame_size), AV_OPT_TYPE_INT, \
369 { .i64 = 0 }, 0, INT_MAX / 8, FLAGS }, \
370 { "intra_refresh_mode", \
371 "Set intra refresh mode", \
372 OFFSET(common.intra_refresh.Mode), AV_OPT_TYPE_INT, \
373 { .i64 = D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE }, \
374 D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE, \
375 D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_ROW_BASED, FLAGS, .unit = "intra_refresh_mode" }, \
376 D3D12VA_ENCODE_INTRA_REFRESH_MODE(none, NONE, "Disable intra refresh"), \
377 D3D12VA_ENCODE_INTRA_REFRESH_MODE(row_based, ROW_BASED, "Row-based intra refresh"), \
378 { "intra_refresh_duration", \
379 "Number of frames over which to spread intra refresh (0 = GOP size)", \
380 OFFSET(common.intra_refresh.IntraRefreshDuration), AV_OPT_TYPE_INT, \
381 { .i64 = 0 }, 0, INT_MAX, FLAGS }
383 #define D3D12VA_ENCODE_RC_MODE(name, desc) \
384 { #name, desc, 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_ ## name }, \
385 0, 0, FLAGS, .unit = "rc_mode" }
386 #define D3D12VA_ENCODE_RC_OPTIONS \
388 "Set rate control mode", \
389 OFFSET(common.explicit_rc_mode), AV_OPT_TYPE_INT, \
390 { .i64 = RC_MODE_AUTO }, RC_MODE_AUTO, RC_MODE_MAX, FLAGS, .unit = "rc_mode" }, \
391 { "auto", "Choose mode automatically based on other parameters", \
392 0, AV_OPT_TYPE_CONST, { .i64 = RC_MODE_AUTO }, 0, 0, FLAGS, .unit = "rc_mode" }, \
393 D3D12VA_ENCODE_RC_MODE(CQP, "Constant-quality"), \
394 D3D12VA_ENCODE_RC_MODE(CBR, "Constant-bitrate"), \
395 D3D12VA_ENCODE_RC_MODE(VBR, "Variable-bitrate"), \
396 D3D12VA_ENCODE_RC_MODE(QVBR, "Quality-defined variable-bitrate")
int mode
Mode from above enum (RC_MODE_*).
int(* init_sequence_params)(AVCodecContext *avctx)
Fill the corresponding parameters.
D3D12_VIDEO_ENCODER_PROFILE_DESC d3d12_profile
D3D12 profile value.
D3D12_VIDEO_ENCODER_CODEC d3d12_codec
D3D12 codec name.
int(* init_picture_params)(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
ID3D12VideoEncoderHeap * encoder_heap
D3D12 video encoder heap.
AVD3D12VAFrame * input_surface
D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOURCE_REQUIREMENTS req
D3D12_FEATURE structures.
int plane_count
The number of planes in the input DXGI FORMAT.
int explicit_rc_mode
Explicitly set RC mode (otherwise attempt to pick from available modes).
D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE d3d12_mode
D3D12 mode value.
AVBufferRef * encoder_ref
D3D12 video encoder.
int maxrate
Supports maxrate distinct from bitrate.
ID3D12VideoEncoder * encoder
int(* configure)(AVCodecContext *avctx)
Perform any extra codec-specific configuration.
AVD3D12VASyncContext sync_ctx
The sync context used to sync command queue.
D3D12_VIDEO_ENCODER_PICTURE_RESOLUTION_DESC resolution
D3D12_VIDEO_ENCODER structures.
int quality
Uses quality value.
ID3D12Resource * resolved_metadata
AVBufferRef * output_buffer_ref
int rc_quality
RC quality level - meaning depends on codec and RC mode.
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA subregions_layout
ID3D12Resource * output_buffer
AVD3D12VADeviceContext * hwctx
AVD3D12VAFrame * recon_surface
int ff_d3d12va_encode_close(AVCodecContext *avctx)
int bi_not_empty
The bi_not_empty feature.
int default_quality
Default quality for this codec - used as quantiser or RC quality factor depending on RC mode.
int bitrate
Uses bitrate parameters.
void(* free_picture_params)(D3D12VAEncodePicture *pic)
int log2_chroma_w
Chroma subsampling in width dimension.
int ff_d3d12va_encode_init(AVCodecContext *avctx)
size_t picture_priv_data_size
The size of any private data structure associated with each picture (can be zero if not required).
int nb_components
Number of components.
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA pic_ctl
This struct is used to sync d3d12 execution.
ID3D12Device3 * device3
ID3D12Device3 interface.
FFHWBaseEncodeContext base
const D3D12VAEncodeProfile * profile
Chosen encoding profile details.
UINT intra_refresh_frame_index
Current frame index within intra refresh cycle.
int max_frame_size
Max frame size.
int flags
Codec feature flags.
D3D12_VIDEO_ENCODER_RATE_CONTROL rc
AVFifo * allocator_queue
A cached queue for reusing the D3D12 command allocators.
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION codec_conf
D3D12_FEATURE_DATA_VIDEO_ENCODER_RESOLUTION_SUPPORT_LIMITS res_limits
int is_texture_array
Flag indicates if the HW is texture array mode.
const struct D3D12VAEncodeType * codec
Codec-specific hooks.
int(* set_tile)(AVCodecContext *avctx)
Set codec-specific tile setting.
int(* get_coded_data)(AVCodecContext *avctx, D3D12VAEncodePicture *pic, AVPacket *pkt)
Fill the coded data into AVPacket.
const AVCodecHWConfigInternal *const ff_d3d12va_encode_hw_configs[]
D3D12VA frame descriptor for pool allocation.
ID3D12Resource * encoded_metadata
D3D12_VIDEO_ENCODER_LEVEL_SETTING level
int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
This struct is allocated as AVHWDeviceContext.hwctx.
int log2_chroma_h
Chroma subsampling in height dimension.
int hrd
Supports HRD/VBV parameters.
int(* write_sequence_header)(AVCodecContext *avctx, char *data, size_t *data_len)
Write the packed header data to the provided buffer.
int av_profile
lavc profile value (AV_PROFILE_*).
ID3D12VideoEncodeCommandList2 * command_list
D3D12 video encode command list.
int(* get_encoder_caps)(AVCodecContext *avctx)
Query codec configuration and determine encode parameters like block sizes for surface alignment and ...
ID3D12CommandQueue * command_queue
D3D12 command queue.
int(* set_level)(AVCodecContext *avctx)
Set codec-specific level setting.
D3D12_VIDEO_ENCODER_INTRA_REFRESH intra_refresh
Intra refresh configuration.
main external API structure.
ID3D12VideoDevice3 * video_device3
ID3D12VideoDevice3 interface.
AVBufferPool * output_buffer_pool
Pool of (reusable) bitstream output buffers.
int depth
Supported bit depth.
D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE gop
A reference to a data buffer.
This structure stores compressed data.
const D3D12VAEncodeProfile * profiles
List of supported profiles.
int explicit_qp
Explicitly-set QP, for use with the "qp" options.