67 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_NONE,
68 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8,
69 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_32x32,
70 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4,
71 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32,
76 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_NONE,
77 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8,
78 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_32x32,
79 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4,
80 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32,
85 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_NONE,
86 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8,
87 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_32x32,
88 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4,
89 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32,
94 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_NONE,
95 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8,
96 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_64x64,
97 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4,
98 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32,
103 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_NONE,
104 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8,
105 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_64x64,
106 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4,
107 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32,
114 { 30, D3D12_VIDEO_ENCODER_LEVELS_HEVC_1 },
115 { 60, D3D12_VIDEO_ENCODER_LEVELS_HEVC_2 },
116 { 63, D3D12_VIDEO_ENCODER_LEVELS_HEVC_21 },
117 { 90, D3D12_VIDEO_ENCODER_LEVELS_HEVC_3 },
118 { 93, D3D12_VIDEO_ENCODER_LEVELS_HEVC_31 },
119 { 120, D3D12_VIDEO_ENCODER_LEVELS_HEVC_4 },
120 { 123, D3D12_VIDEO_ENCODER_LEVELS_HEVC_41 },
121 { 150, D3D12_VIDEO_ENCODER_LEVELS_HEVC_5 },
122 { 153, D3D12_VIDEO_ENCODER_LEVELS_HEVC_51 },
123 { 156, D3D12_VIDEO_ENCODER_LEVELS_HEVC_52 },
124 { 180, D3D12_VIDEO_ENCODER_LEVELS_HEVC_6 },
125 { 183, D3D12_VIDEO_ENCODER_LEVELS_HEVC_61 },
126 { 186, D3D12_VIDEO_ENCODER_LEVELS_HEVC_62 },
129static const D3D12_VIDEO_ENCODER_PROFILE_HEVC
profile_main = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN;
130static const D3D12_VIDEO_ENCODER_PROFILE_HEVC
profile_main10 = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10;
132#define D3D_PROFILE_DESC(name) \
133 { sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC), { .pHEVCProfile = (D3D12_VIDEO_ENCODER_PROFILE_HEVC *)&profile_ ## name } }
143 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_8x8:
return 8;
144 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_16x16:
return 16;
145 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_32x32:
return 32;
146 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE_64x64:
return 64;
155 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_4x4:
return 4;
156 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_8x8:
return 8;
157 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_16x16:
return 16;
158 case D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE_32x32:
return 32;
165 char *
data,
size_t *data_len,
171 err = ff_cbs_write_fragment_data(priv->
cbc, au);
179 "%zu < %zu.\n", *data_len,
197 err = ff_cbs_insert_unit_content(au, -1,
201 "type = %d.\n",
header->nal_unit_type);
209 char *
data,
size_t *data_len)
229 ff_cbs_fragment_reset(au);
242 D3D12_VIDEO_ENCODER_PROFILE_HEVC
profile = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN;
243 D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC
level = { 0 };
245 uint8_t min_cu_size, max_cu_size, min_tu_size, max_tu_size;
249 D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT support = {
251 .Codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
252 .InputFormat = hwctx->
format,
253 .RateControl =
ctx->rc,
254 .IntraRefresh =
ctx->intra_refresh.Mode,
255 .SubregionFrameEncoding = D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME,
256 .ResolutionsListCount = 1,
257 .pResolutionList = &
ctx->resolution,
258 .CodecGopSequence =
ctx->gop,
260 .CodecConfiguration =
ctx->codec_conf,
261 .SuggestedProfile.DataSize =
sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC),
262 .SuggestedProfile.pHEVCProfile = &
profile,
263 .SuggestedLevel.DataSize =
sizeof(D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC),
264 .SuggestedLevel.pHEVCLevelSetting = &
level,
265 .pResolutionDependentSupport = &
ctx->res_limits,
268 hr = ID3D12VideoDevice3_CheckFeatureSupport(
ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_SUPPORT,
269 &support,
sizeof(support));
276 if (!(support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_GENERAL_SUPPORT_OK)) {
277 av_log(avctx,
AV_LOG_ERROR,
"Driver does not support requested features. ValidationFlags: %#x\n",
278 support.ValidationFlags);
283 if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RECONSTRUCTED_FRAMES_REQUIRE_TEXTURE_ARRAYS) {
284 ctx->is_texture_array = 1;
285 av_log(avctx,
AV_LOG_DEBUG,
"D3D12 video encode on this device uses texture array mode.\n");
289 if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RATE_CONTROL_DELTA_QP_AVAILABLE) {
292 ctx->qp_map_region_size =
ctx->res_limits.QPMapRegionPixelsSize;
294 "(QP map region size: %d pixels).\n",
ctx->qp_map_region_size);
297 av_log(avctx,
AV_LOG_DEBUG,
"ROI encoding not supported by hardware for current rate control mode \n");
301 if (
ctx->me_precision != D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM) {
302 if (!(support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_MOTION_ESTIMATION_PRECISION_MODE_LIMIT_AVAILABLE)) {
304 "precision mode limits.\n");
308 "precision mode limits.\n");
330 av_assert0(
ctx->res_limits.SubregionBlockPixelsSize % min_cu_size == 0);
333 ctx->res_limits.SubregionBlockPixelsSize);
335 ctx->res_limits.SubregionBlockPixelsSize);
337 if (avctx->
width !=
sps->pic_width_in_luma_samples ||
338 avctx->
height !=
sps->pic_height_in_luma_samples) {
339 sps->conformance_window_flag = 1;
340 sps->conf_win_left_offset = 0;
341 sps->conf_win_right_offset =
342 (
sps->pic_width_in_luma_samples - avctx->
width) >>
desc->log2_chroma_w;
343 sps->conf_win_top_offset = 0;
344 sps->conf_win_bottom_offset =
345 (
sps->pic_height_in_luma_samples - avctx->
height) >>
desc->log2_chroma_h;
347 sps->conformance_window_flag = 0;
350 sps->log2_max_pic_order_cnt_lsb_minus4 =
ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4;
352 sps->log2_min_luma_coding_block_size_minus3 = (uint8_t)(
av_log2(min_cu_size) - 3);
353 sps->log2_diff_max_min_luma_coding_block_size = (uint8_t)(
av_log2(max_cu_size) -
av_log2(min_cu_size));
354 sps->log2_min_luma_transform_block_size_minus2 = (uint8_t)(
av_log2(min_tu_size) - 2);
355 sps->log2_diff_max_min_luma_transform_block_size = (uint8_t)(
av_log2(max_tu_size) -
av_log2(min_tu_size));
357 sps->max_transform_hierarchy_depth_inter =
ctx->codec_conf.pHEVCConfig->max_transform_hierarchy_depth_inter;
358 sps->max_transform_hierarchy_depth_intra =
ctx->codec_conf.pHEVCConfig->max_transform_hierarchy_depth_intra;
360 sps->amp_enabled_flag = !!(
ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
361 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_ASYMETRIC_MOTION_PARTITION);
362 sps->sample_adaptive_offset_enabled_flag = !!(
ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
363 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_SAO_FILTER);
365 pps->cabac_init_present_flag = 1;
367 pps->init_qp_minus26 = 0;
369 pps->transform_skip_enabled_flag = !!(
ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
370 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_TRANSFORM_SKIPPING);
372 pps->pps_slice_chroma_qp_offsets_present_flag = 1;
374 pps->tiles_enabled_flag = 0;
376 pps->pps_loop_filter_across_slices_enabled_flag = !(
ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
377 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_DISABLE_LOOP_FILTER_ACROSS_SLICES);
379 pps->deblocking_filter_control_present_flag = 1;
389 uint8_t min_cu_size, max_cu_size;
393 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC *config;
394 D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_caps;
396 D3D12_FEATURE_DATA_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT codec_caps = {
398 .Codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
399 .Profile =
ctx->profile->d3d12_profile,
400 .CodecSupportLimits.DataSize =
sizeof(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC),
405 codec_caps.CodecSupportLimits.pHEVCSupport = &hevc_caps;
406 hr = ID3D12VideoDevice3_CheckFeatureSupport(
ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT,
407 &codec_caps,
sizeof(codec_caps));
408 if (SUCCEEDED(hr) && codec_caps.IsSupported)
417 ctx->codec_conf.DataSize =
sizeof(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC);
419 if (!
ctx->codec_conf.pHEVCConfig)
422 config =
ctx->codec_conf.pHEVCConfig;
424 config->ConfigurationFlags = D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_NONE;
425 config->MinLumaCodingUnitSize = hevc_caps.MinLumaCodingUnitSize;
426 config->MaxLumaCodingUnitSize = hevc_caps.MaxLumaCodingUnitSize;
427 config->MinLumaTransformUnitSize = hevc_caps.MinLumaTransformUnitSize;
428 config->MaxLumaTransformUnitSize = hevc_caps.MaxLumaTransformUnitSize;
429 config->max_transform_hierarchy_depth_inter = hevc_caps.max_transform_hierarchy_depth_inter;
430 config->max_transform_hierarchy_depth_intra = hevc_caps.max_transform_hierarchy_depth_intra;
432 if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_ASYMETRIC_MOTION_PARTITION_SUPPORT ||
433 hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_ASYMETRIC_MOTION_PARTITION_REQUIRED)
434 config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_ASYMETRIC_MOTION_PARTITION;
436 if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_SAO_FILTER_SUPPORT)
437 config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_SAO_FILTER;
439 if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_DISABLING_LOOP_FILTER_ACROSS_SLICES_SUPPORT)
440 config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_DISABLE_LOOP_FILTER_ACROSS_SLICES;
442 if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_SUPPORT)
443 config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_TRANSFORM_SKIPPING;
447 if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_CONSTRAINED_INTRAPREDICTION_SUPPORT) {
448 config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_CONSTRAINED_INTRAPREDICTION;
450 av_log(avctx,
AV_LOG_WARNING,
"Constrained intra prediction is not supported by the driver, disabling.\n");
455 if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_P_FRAMES_IMPLEMENTED_AS_LOW_DELAY_B_FRAMES)
456 ctx->bi_not_empty = 1;
463 "min CB size %dx%d.\n", max_cu_size, max_cu_size,
464 min_cu_size, min_cu_size);
477 int fixed_qp_idr, fixed_qp_p, fixed_qp_b;
485 if (
ctx->rc.Mode == D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CQP) {
486 D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP *cqp_ctl;
492 fixed_qp_idr = fixed_qp_p;
497 fixed_qp_b = fixed_qp_p;
500 "%d / %d / %d for IDR- / P- / B-frames.\n",
501 fixed_qp_idr, fixed_qp_p, fixed_qp_b);
503 ctx->rc.ConfigParams.DataSize =
sizeof(D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP);
508 cqp_ctl->ConstantQP_FullIntracodedFrame = fixed_qp_idr;
509 cqp_ctl->ConstantQP_InterPredictedFrame_PrevRefOnly = fixed_qp_p;
510 cqp_ctl->ConstantQP_InterPredictedFrame_BiDirectionalRef = fixed_qp_b;
512 ctx->rc.ConfigParams.pConfiguration_CQP = cqp_ctl;
516 ctx->gop.DataSize =
sizeof(D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE_HEVC);
518 if (!
ctx->gop.pHEVCGroupOfPictures)
521 ctx->gop.pHEVCGroupOfPictures->GOPLength = base_ctx->
gop_size;
522 ctx->gop.pHEVCGroupOfPictures->PPicturePeriod = base_ctx->
b_per_p + 1;
525 ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4 =
528 ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4 =
540 ctx->level.DataSize =
sizeof(D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC);
542 if (!
ctx->level.pHEVCLevelSetting)
558 D3D12_VIDEO_ENCODER_TIER_HEVC_MAIN :
559 D3D12_VIDEO_ENCODER_TIER_HEVC_HIGH;
566 if (!pic->
pic_ctl.pHEVCPicData)
571 av_freep(&pic->
pic_ctl.pHEVCPicData->pReferenceFramesReconPictureDescriptors);
583 D3D12_VIDEO_ENCODER_REFERENCE_PICTURE_DESCRIPTOR_HEVC *pd =
NULL;
584 UINT *ref_list0 =
NULL, *ref_list1 =
NULL;
587 pic->
pic_ctl.DataSize =
sizeof(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC);
589 if (!pic->
pic_ctl.pHEVCPicData)
601 switch(base_pic->
type) {
603 pic->
pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_IDR_FRAME;
606 pic->
pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_I_FRAME;
609 pic->
pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_P_FRAME;
612 pic->
pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_B_FRAME;
618 pic->
pic_ctl.pHEVCPicData->slice_pic_parameter_set_id = 0;
630 pic->
pic_ctl.pHEVCPicData->List0ReferenceFramesCount = base_pic->
nb_refs[0];
636 href =
ref->codec_priv;
639 pd[idx].ReconstructedPictureResourceIndex = idx;
640 pd[idx].IsRefUsedByCurrentPic = TRUE;
651 pic->
pic_ctl.pHEVCPicData->List1ReferenceFramesCount = base_pic->
nb_refs[1];
657 href =
ref->codec_priv;
660 pd[idx].ReconstructedPictureResourceIndex = idx;
661 pd[idx].IsRefUsedByCurrentPic = TRUE;
667 pic->
pic_ctl.pHEVCPicData->pList0ReferenceFrames = ref_list0;
668 pic->
pic_ctl.pHEVCPicData->pList1ReferenceFrames = ref_list1;
669 pic->
pic_ctl.pHEVCPicData->ReferenceFramesReconPictureDescriptorsCount = idx;
670 pic->
pic_ctl.pHEVCPicData->pReferenceFramesReconPictureDescriptors = pd;
675 pic->
pic_ctl.pHEVCPicData->pRateControlQPMap = (INT8 *)pic->
qp_map;
684 .d3d12_codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
690 .default_quality = 25,
723 "in 8-bit unsigned integer.\n", avctx->
level);
728 ctx->explicit_qp = priv->
qp;
738 ff_cbs_close(&priv->
cbc);
747#define OFFSET(x) offsetof(D3D12VAEncodeHEVCContext, x)
748#define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
754 {
"qp",
"Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
757 {
"profile",
"Set profile (general_profile_idc)",
761#define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
762 { .i64 = value }, 0, 0, FLAGS, "profile"
767 {
"tier",
"Set tier (general_tier_flag)",
769 { .i64 = 0 }, 0, 1,
FLAGS,
"tier" },
771 { .i64 = 0 }, 0, 0,
FLAGS,
"tier" },
773 { .i64 = 1 }, 0, 0,
FLAGS,
"tier" },
775 {
"level",
"Set level (general_level_idc)",
779#define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
780 { .i64 = value }, 0, 0, FLAGS, "level"
783 {
LEVEL(
"2.1", 63) },
785 {
LEVEL(
"3.1", 93) },
787 {
LEVEL(
"4.1", 123) },
789 {
LEVEL(
"5.1", 153) },
790 {
LEVEL(
"5.2", 156) },
792 {
LEVEL(
"6.1", 183) },
793 {
LEVEL(
"6.2", 186) },
796 {
"constrained_intra_pred",
"Constrained intra prediction (constrained_intra_pred_flag)",
806 {
"i_qfactor",
"1" },
807 {
"i_qoffset",
"0" },
808 {
"b_qfactor",
"1" },
809 {
"b_qoffset",
"0" },
817 .class_name =
"hevc_d3d12va",
824 .p.name =
"hevc_d3d12va",
840 .p.wrapper_name =
"d3d12va",
const FFCodec ff_hevc_d3d12va_encoder
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
static int FUNC sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define CODEC_PIXFMTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_RECEIVE_PACKET_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
common internal and external API header
int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
void ff_d3d12va_encode_check_encoder_feature_flags(void *log_ctx, D3D12_VIDEO_ENCODER_VALIDATION_FLAGS flags)
const AVCodecHWConfigInternal *const ff_d3d12va_encode_hw_configs[]
int ff_d3d12va_encode_init(AVCodecContext *avctx)
int ff_d3d12va_encode_close(AVCodecContext *avctx)
#define D3D12VA_ENCODE_RC_OPTIONS
#define D3D12VA_ENCODE_COMMON_OPTIONS
static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_main
static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main10
#define D3D_PROFILE_DESC(name)
static const D3D12VAEncodeProfile d3d12va_encode_hevc_profiles[]
static int d3d12va_encode_hevc_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au)
static int d3d12va_encode_hevc_init(AVCodecContext *avctx)
static const FFCodecDefault d3d12va_encode_hevc_defaults[]
static uint8_t d3d12va_encode_hevc_map_tusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE tusize)
static int d3d12va_encode_hevc_close(AVCodecContext *avctx)
static int d3d12va_encode_hevc_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
static void d3d12va_encode_hevc_free_picture_params(D3D12VAEncodePicture *pic)
static int d3d12va_encode_hevc_configure(AVCodecContext *avctx)
static int d3d12va_encode_hevc_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
static int d3d12va_encode_hevc_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic)
#define LEVEL(name, value)
static int d3d12va_encode_hevc_init_sequence_params(AVCodecContext *avctx)
static const D3D12VAEncodeHEVCLevel hevc_levels[]
static int d3d12va_encode_hevc_set_level(AVCodecContext *avctx)
static const D3D12VAEncodeType d3d12va_encode_type_hevc
static const AVClass d3d12va_encode_hevc_class
#define PROFILE(name, value)
static const AVOption d3d12va_encode_hevc_options[]
static int d3d12va_encode_hevc_get_encoder_caps(AVCodecContext *avctx)
static uint8_t d3d12va_encode_hevc_map_cusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE cusize)
static const D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_config_support_sets[]
#define AV_PROFILE_UNKNOWN
#define AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN_10
int(* init)(AVBSFContext *ctx)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
#define LIBAVUTIL_VERSION_INT
#define MAX_PICTURE_REFERENCES
#define HW_BASE_ENCODE_COMMON_OPTIONS
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
int ff_hw_base_encode_init_params_h265(FFHWBaseEncodeContext *base_ctx, AVCodecContext *avctx, FFHWBaseEncodeH265 *common, FFHWBaseEncodeH265Opts *opts)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
static const uint8_t header[24]
#define FF_ARRAY_ELEMS(a)
Describe the class of an AVClass context structure.
main external API structure.
int width
picture width / height.
float b_quant_offset
qscale offset between IP and B-frames
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
int level
Encoding level descriptor.
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
float i_quant_offset
qscale offset between P and I-frames
This struct is allocated as AVHWFramesContext.hwctx.
DXGI_FORMAT format
DXGI_FORMAT format.
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Context structure for coded bitstream operations.
Coded bitstream fragment structure, combining one or more units.
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
size_t data_size
The number of bytes in the bitstream.
uint8_t * data
Pointer to the bitstream form of this fragment.
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION codec_conf
D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE gop
D3D12_VIDEO_ENCODER_LEVEL_SETTING level
CodedBitstreamFragment current_access_unit
CodedBitstreamContext * cbc
D3D12VAEncodeContext common
int constrained_intra_pred
FFHWBaseEncodeH265Opts unit_opts
D3D12_VIDEO_ENCODER_LEVELS_HEVC d3d12_level
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA pic_ctl
AVHWFramesContext * input_frames
int cu_qp_delta_enabled_flag
struct FFHWBaseEncodePicture * prev
int nb_refs[MAX_REFERENCE_LIST_NUM]
struct FFHWBaseEncodePicture * refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES]
uint8_t general_level_idc
uint8_t general_tier_flag
H265RawProfileTierLevel profile_tier_level
static int ref[MAX_W *MAX_W]
static AVFormatContext * ctx
static int write_sequence_header(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)