FFmpeg
d3d12va_encode_hevc.c
Go to the documentation of this file.
1 /*
2  * Direct3D 12 HW acceleration video encoder
3  *
4  * Copyright (c) 2024 Intel Corporation
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #include "libavutil/opt.h"
23 #include "libavutil/common.h"
24 #include "libavutil/mem.h"
25 #include "libavutil/pixdesc.h"
27 
28 #include "avcodec.h"
29 #include "cbs.h"
30 #include "cbs_h265.h"
31 #include "h2645data.h"
32 #include "h265_profile_level.h"
33 #include "codec_internal.h"
34 #include "d3d12va_encode.h"
35 
36 typedef struct D3D12VAEncodeHEVCPicture {
38  int64_t last_idr_frame;
40 
41 typedef struct D3D12VAEncodeHEVCContext {
43 
44  // User options.
45  int qp;
46  int profile;
47  int tier;
48  int level;
49 
50  // Writer structures.
54 
58 
59 typedef struct D3D12VAEncodeHEVCLevel {
60  int level;
61  D3D12_VIDEO_ENCODER_LEVELS_HEVC d3d12_level;
63 
64 static const D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_config_support_sets[] =
65 {
66  {
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,
72  3,
73  3,
74  },
75  {
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,
81  0,
82  0,
83  },
84  {
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,
90  2,
91  2,
92  },
93  {
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,
99  2,
100  2,
101  },
102  {
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,
108  4,
109  4,
110  },
111 };
112 
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 },
127 };
128 
129 static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN;
130 static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main10 = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN10;
131 
132 #define D3D_PROFILE_DESC(name) \
133  { sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC), { .pHEVCProfile = (D3D12_VIDEO_ENCODER_PROFILE_HEVC *)&profile_ ## name } }
135  { AV_PROFILE_HEVC_MAIN, 8, 3, 1, 1, D3D_PROFILE_DESC(main) },
136  { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, D3D_PROFILE_DESC(main10) },
137  { AV_PROFILE_UNKNOWN },
138 };
139 
140 static uint8_t d3d12va_encode_hevc_map_cusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE cusize)
141 {
142  switch (cusize) {
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;
147  default: av_assert0(0);
148  }
149  return 0;
150 }
151 
152 static uint8_t d3d12va_encode_hevc_map_tusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE tusize)
153 {
154  switch (tusize) {
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;
159  default: av_assert0(0);
160  }
161  return 0;
162 }
163 
165  char *data, size_t *data_len,
167 {
168  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
169  int err;
170 
171  err = ff_cbs_write_fragment_data(priv->cbc, au);
172  if (err < 0) {
173  av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
174  return err;
175  }
176 
177  if (*data_len < 8 * au->data_size - au->data_bit_padding) {
178  av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
179  "%zu < %zu.\n", *data_len,
180  8 * au->data_size - au->data_bit_padding);
181  return AVERROR(ENOSPC);
182  }
183 
184  memcpy(data, au->data, au->data_size);
185  *data_len = 8 * au->data_size - au->data_bit_padding;
186 
187  return 0;
188 }
189 
192  void *nal_unit)
193 {
194  H265RawNALUnitHeader *header = nal_unit;
195  int err;
196 
197  err = ff_cbs_insert_unit_content(au, -1,
198  header->nal_unit_type, nal_unit, NULL);
199  if (err < 0) {
200  av_log(avctx, AV_LOG_ERROR, "Failed to add NAL unit: "
201  "type = %d.\n", header->nal_unit_type);
202  return err;
203  }
204 
205  return 0;
206 }
207 
209  char *data, size_t *data_len)
210 {
211  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
213  int err;
214 
215  err = d3d12va_encode_hevc_add_nal(avctx, au, &priv->raw_vps);
216  if (err < 0)
217  goto fail;
218 
219  err = d3d12va_encode_hevc_add_nal(avctx, au, &priv->raw_sps);
220  if (err < 0)
221  goto fail;
222 
223  err = d3d12va_encode_hevc_add_nal(avctx, au, &priv->raw_pps);
224  if (err < 0)
225  goto fail;
226 
227  err = d3d12va_encode_hevc_write_access_unit(avctx, data, data_len, au);
228 fail:
230  return err;
231 
232 }
233 
235 {
236  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
238  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
239  AVD3D12VAFramesContext *hwctx = base_ctx->input_frames->hwctx;
240  H265RawVPS *vps = &priv->raw_vps;
241  H265RawSPS *sps = &priv->raw_sps;
242  H265RawPPS *pps = &priv->raw_pps;
243  H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
244  H265RawVUI *vui = &sps->vui;
245  D3D12_VIDEO_ENCODER_PROFILE_HEVC profile = D3D12_VIDEO_ENCODER_PROFILE_HEVC_MAIN;
246  D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC level = { 0 };
247  const AVPixFmtDescriptor *desc;
248  uint8_t min_cu_size, max_cu_size, min_tu_size, max_tu_size;
249  int chroma_format, bit_depth;
250  HRESULT hr;
251  int i;
252 
253  D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT support = {
254  .NodeIndex = 0,
255  .Codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
256  .InputFormat = hwctx->format,
257  .RateControl = ctx->rc,
258  .IntraRefresh = D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE,
259  .SubregionFrameEncoding = D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME,
260  .ResolutionsListCount = 1,
261  .pResolutionList = &ctx->resolution,
262  .CodecGopSequence = ctx->gop,
263  .MaxReferenceFramesInDPB = MAX_DPB_SIZE - 1,
264  .CodecConfiguration = ctx->codec_conf,
265  .SuggestedProfile.DataSize = sizeof(D3D12_VIDEO_ENCODER_PROFILE_HEVC),
266  .SuggestedProfile.pHEVCProfile = &profile,
267  .SuggestedLevel.DataSize = sizeof(D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC),
268  .SuggestedLevel.pHEVCLevelSetting = &level,
269  .pResolutionDependentSupport = &ctx->res_limits,
270  };
271 
272  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_SUPPORT,
273  &support, sizeof(support));
274 
275  if (FAILED(hr)) {
276  av_log(avctx, AV_LOG_ERROR, "Failed to check encoder support(%lx).\n", (long)hr);
277  return AVERROR(EINVAL);
278  }
279 
280  if (!(support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_GENERAL_SUPPORT_OK)) {
281  av_log(avctx, AV_LOG_ERROR, "Driver does not support some request features. %#x\n",
282  support.ValidationFlags);
283  return AVERROR(EINVAL);
284  }
285 
286  if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RECONSTRUCTED_FRAMES_REQUIRE_TEXTURE_ARRAYS) {
287  av_log(avctx, AV_LOG_ERROR, "D3D12 video encode on this device requires texture array support, "
288  "but it's not implemented.\n");
289  return AVERROR_PATCHWELCOME;
290  }
291 
292  memset(vps, 0, sizeof(*vps));
293  memset(sps, 0, sizeof(*sps));
294  memset(pps, 0, sizeof(*pps));
295 
297  av_assert0(desc);
298  if (desc->nb_components == 1) {
299  chroma_format = 0;
300  } else {
301  if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1) {
302  chroma_format = 1;
303  } else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0) {
304  chroma_format = 2;
305  } else if (desc->log2_chroma_w == 0 && desc->log2_chroma_h == 0) {
306  chroma_format = 3;
307  } else {
308  av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
309  "%s is not supported.\n", desc->name);
310  return AVERROR(EINVAL);
311  }
312  }
313  bit_depth = desc->comp[0].depth;
314 
315  min_cu_size = d3d12va_encode_hevc_map_cusize(ctx->codec_conf.pHEVCConfig->MinLumaCodingUnitSize);
316  max_cu_size = d3d12va_encode_hevc_map_cusize(ctx->codec_conf.pHEVCConfig->MaxLumaCodingUnitSize);
317  min_tu_size = d3d12va_encode_hevc_map_tusize(ctx->codec_conf.pHEVCConfig->MinLumaTransformUnitSize);
318  max_tu_size = d3d12va_encode_hevc_map_tusize(ctx->codec_conf.pHEVCConfig->MaxLumaTransformUnitSize);
319 
320  // VPS
321 
322  vps->nal_unit_header = (H265RawNALUnitHeader) {
323  .nal_unit_type = HEVC_NAL_VPS,
324  .nuh_layer_id = 0,
325  .nuh_temporal_id_plus1 = 1,
326  };
327 
328  vps->vps_video_parameter_set_id = 0;
329 
330  vps->vps_base_layer_internal_flag = 1;
331  vps->vps_base_layer_available_flag = 1;
332  vps->vps_max_layers_minus1 = 0;
333  vps->vps_max_sub_layers_minus1 = 0;
334  vps->vps_temporal_id_nesting_flag = 1;
335 
337  ptl->general_profile_idc = avctx->profile;
338  ptl->general_tier_flag = priv->tier;
339 
341 
346 
351 
352  ptl->general_max_422chroma_constraint_flag = chroma_format <= 2;
353  ptl->general_max_420chroma_constraint_flag = chroma_format <= 1;
354  ptl->general_max_monochrome_constraint_flag = chroma_format == 0;
355 
356  ptl->general_intra_constraint_flag = base_ctx->gop_size == 1;
358 
360 
361  if (avctx->level != FF_LEVEL_UNKNOWN) {
362  ptl->general_level_idc = avctx->level;
363  } else {
364  const H265LevelDescriptor *level;
365 
367  base_ctx->surface_width, base_ctx->surface_height,
368  1, 1, 1, (base_ctx->b_per_p > 0) + 1);
369  if (level) {
370  av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
371  ptl->general_level_idc = level->level_idc;
372  } else {
373  av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
374  "any normal level; using level 8.5.\n");
375  ptl->general_level_idc = 255;
376  // The tier flag must be set in level 8.5.
377  ptl->general_tier_flag = 1;
378  }
379  avctx->level = ptl->general_level_idc;
380  }
381 
382  vps->vps_sub_layer_ordering_info_present_flag = 0;
383  vps->vps_max_dec_pic_buffering_minus1[0] = base_ctx->max_b_depth + 1;
384  vps->vps_max_num_reorder_pics[0] = base_ctx->max_b_depth;
385  vps->vps_max_latency_increase_plus1[0] = 0;
386 
387  vps->vps_max_layer_id = 0;
388  vps->vps_num_layer_sets_minus1 = 0;
389  vps->layer_id_included_flag[0][0] = 1;
390 
391  vps->vps_timing_info_present_flag = 1;
392  if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
393  vps->vps_num_units_in_tick = avctx->framerate.den;
394  vps->vps_time_scale = avctx->framerate.num;
395  vps->vps_poc_proportional_to_timing_flag = 1;
396  vps->vps_num_ticks_poc_diff_one_minus1 = 0;
397  } else {
398  vps->vps_num_units_in_tick = avctx->time_base.num;
399  vps->vps_time_scale = avctx->time_base.den;
400  vps->vps_poc_proportional_to_timing_flag = 0;
401  }
402  vps->vps_num_hrd_parameters = 0;
403 
404  // SPS
405 
406  sps->nal_unit_header = (H265RawNALUnitHeader) {
407  .nal_unit_type = HEVC_NAL_SPS,
408  .nuh_layer_id = 0,
409  .nuh_temporal_id_plus1 = 1,
410  };
411 
412  sps->sps_video_parameter_set_id = vps->vps_video_parameter_set_id;
413 
414  sps->sps_max_sub_layers_minus1 = vps->vps_max_sub_layers_minus1;
415  sps->sps_temporal_id_nesting_flag = vps->vps_temporal_id_nesting_flag;
416 
417  sps->profile_tier_level = vps->profile_tier_level;
418 
419  sps->sps_seq_parameter_set_id = 0;
420 
421  sps->chroma_format_idc = chroma_format;
422  sps->separate_colour_plane_flag = 0;
423 
424  av_assert0(ctx->res_limits.SubregionBlockPixelsSize % min_cu_size == 0);
425 
426  sps->pic_width_in_luma_samples = FFALIGN(base_ctx->surface_width,
427  ctx->res_limits.SubregionBlockPixelsSize);
428  sps->pic_height_in_luma_samples = FFALIGN(base_ctx->surface_height,
429  ctx->res_limits.SubregionBlockPixelsSize);
430 
431  if (avctx->width != sps->pic_width_in_luma_samples ||
432  avctx->height != sps->pic_height_in_luma_samples) {
433  sps->conformance_window_flag = 1;
434  sps->conf_win_left_offset = 0;
435  sps->conf_win_right_offset =
436  (sps->pic_width_in_luma_samples - avctx->width) >> desc->log2_chroma_w;
437  sps->conf_win_top_offset = 0;
438  sps->conf_win_bottom_offset =
439  (sps->pic_height_in_luma_samples - avctx->height) >> desc->log2_chroma_h;
440  } else {
441  sps->conformance_window_flag = 0;
442  }
443 
444  sps->bit_depth_luma_minus8 = bit_depth - 8;
445  sps->bit_depth_chroma_minus8 = bit_depth - 8;
446 
447  sps->log2_max_pic_order_cnt_lsb_minus4 = ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4;
448 
449  sps->sps_sub_layer_ordering_info_present_flag =
450  vps->vps_sub_layer_ordering_info_present_flag;
451  for (i = 0; i <= sps->sps_max_sub_layers_minus1; i++) {
452  sps->sps_max_dec_pic_buffering_minus1[i] =
453  vps->vps_max_dec_pic_buffering_minus1[i];
454  sps->sps_max_num_reorder_pics[i] =
455  vps->vps_max_num_reorder_pics[i];
456  sps->sps_max_latency_increase_plus1[i] =
457  vps->vps_max_latency_increase_plus1[i];
458  }
459 
460  sps->log2_min_luma_coding_block_size_minus3 = (uint8_t)(av_log2(min_cu_size) - 3);
461  sps->log2_diff_max_min_luma_coding_block_size = (uint8_t)(av_log2(max_cu_size) - av_log2(min_cu_size));
462  sps->log2_min_luma_transform_block_size_minus2 = (uint8_t)(av_log2(min_tu_size) - 2);
463  sps->log2_diff_max_min_luma_transform_block_size = (uint8_t)(av_log2(max_tu_size) - av_log2(min_tu_size));
464 
465  sps->max_transform_hierarchy_depth_inter = ctx->codec_conf.pHEVCConfig->max_transform_hierarchy_depth_inter;
466  sps->max_transform_hierarchy_depth_intra = ctx->codec_conf.pHEVCConfig->max_transform_hierarchy_depth_intra;
467 
468  sps->amp_enabled_flag = !!(ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
469  D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_ASYMETRIC_MOTION_PARTITION);
470  sps->sample_adaptive_offset_enabled_flag = !!(ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
471  D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_SAO_FILTER);
472  sps->sps_temporal_mvp_enabled_flag = 0;
473  sps->pcm_enabled_flag = 0;
474 
475  sps->vui_parameters_present_flag = 1;
476 
477  if (avctx->sample_aspect_ratio.num != 0 &&
478  avctx->sample_aspect_ratio.den != 0) {
479  int num, den, i;
480  av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
481  avctx->sample_aspect_ratio.den, 65535);
482  for (i = 0; i < FF_ARRAY_ELEMS(ff_h2645_pixel_aspect); i++) {
483  if (num == ff_h2645_pixel_aspect[i].num &&
484  den == ff_h2645_pixel_aspect[i].den) {
485  vui->aspect_ratio_idc = i;
486  break;
487  }
488  }
490  vui->aspect_ratio_idc = 255;
491  vui->sar_width = num;
492  vui->sar_height = den;
493  }
495  }
496 
497  // Unspecified video format, from table E-2.
498  vui->video_format = 5;
499  vui->video_full_range_flag =
500  avctx->color_range == AVCOL_RANGE_JPEG;
501  vui->colour_primaries = avctx->color_primaries;
502  vui->transfer_characteristics = avctx->color_trc;
503  vui->matrix_coefficients = avctx->colorspace;
504  if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
505  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
508  if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED ||
511 
516  avctx->chroma_sample_location - 1;
517  }
518 
520  vui->vui_num_units_in_tick = vps->vps_num_units_in_tick;
521  vui->vui_time_scale = vps->vps_time_scale;
522  vui->vui_poc_proportional_to_timing_flag = vps->vps_poc_proportional_to_timing_flag;
523  vui->vui_num_ticks_poc_diff_one_minus1 = vps->vps_num_ticks_poc_diff_one_minus1;
525 
529  vui->max_bytes_per_pic_denom = 0;
530  vui->max_bits_per_min_cu_denom = 0;
532  vui->log2_max_mv_length_vertical = 15;
533 
534  // PPS
535 
536  pps->nal_unit_header = (H265RawNALUnitHeader) {
537  .nal_unit_type = HEVC_NAL_PPS,
538  .nuh_layer_id = 0,
539  .nuh_temporal_id_plus1 = 1,
540  };
541 
542  pps->pps_pic_parameter_set_id = 0;
543  pps->pps_seq_parameter_set_id = sps->sps_seq_parameter_set_id;
544 
545  pps->cabac_init_present_flag = 1;
546 
547  pps->num_ref_idx_l0_default_active_minus1 = 0;
548  pps->num_ref_idx_l1_default_active_minus1 = 0;
549 
550  pps->init_qp_minus26 = 0;
551 
552  pps->transform_skip_enabled_flag = !!(ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
553  D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_TRANSFORM_SKIPPING);
554 
555  // cu_qp_delta always required to be 1 in https://github.com/microsoft/DirectX-Specs/blob/master/d3d/D3D12VideoEncoding.md
556  pps->cu_qp_delta_enabled_flag = 1;
557 
558  pps->diff_cu_qp_delta_depth = 0;
559 
560  pps->pps_slice_chroma_qp_offsets_present_flag = 1;
561 
562  pps->tiles_enabled_flag = 0; // no tiling in D3D12
563 
564  pps->pps_loop_filter_across_slices_enabled_flag = !(ctx->codec_conf.pHEVCConfig->ConfigurationFlags &
565  D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_DISABLE_LOOP_FILTER_ACROSS_SLICES);
566  pps->deblocking_filter_control_present_flag = 1;
567 
568  return 0;
569 }
570 
572 {
573  int i;
574  HRESULT hr;
575  uint8_t min_cu_size, max_cu_size;
576  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
578  D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC *config;
579  D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_caps;
580 
581  D3D12_FEATURE_DATA_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT codec_caps = {
582  .NodeIndex = 0,
583  .Codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
584  .Profile = ctx->profile->d3d12_profile,
585  .CodecSupportLimits.DataSize = sizeof(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC),
586  };
587 
588  for (i = 0; i < FF_ARRAY_ELEMS(hevc_config_support_sets); i++) {
589  hevc_caps = hevc_config_support_sets[i];
590  codec_caps.CodecSupportLimits.pHEVCSupport = &hevc_caps;
591  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT,
592  &codec_caps, sizeof(codec_caps));
593  if (SUCCEEDED(hr) && codec_caps.IsSupported)
594  break;
595  }
596 
598  av_log(avctx, AV_LOG_ERROR, "Unsupported codec configuration\n");
599  return AVERROR(EINVAL);
600  }
601 
602  ctx->codec_conf.DataSize = sizeof(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC);
603  ctx->codec_conf.pHEVCConfig = av_mallocz(ctx->codec_conf.DataSize);
604  if (!ctx->codec_conf.pHEVCConfig)
605  return AVERROR(ENOMEM);
606 
607  config = ctx->codec_conf.pHEVCConfig;
608 
609  config->ConfigurationFlags = D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_NONE;
610  config->MinLumaCodingUnitSize = hevc_caps.MinLumaCodingUnitSize;
611  config->MaxLumaCodingUnitSize = hevc_caps.MaxLumaCodingUnitSize;
612  config->MinLumaTransformUnitSize = hevc_caps.MinLumaTransformUnitSize;
613  config->MaxLumaTransformUnitSize = hevc_caps.MaxLumaTransformUnitSize;
614  config->max_transform_hierarchy_depth_inter = hevc_caps.max_transform_hierarchy_depth_inter;
615  config->max_transform_hierarchy_depth_intra = hevc_caps.max_transform_hierarchy_depth_intra;
616 
617  if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_ASYMETRIC_MOTION_PARTITION_SUPPORT ||
618  hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_ASYMETRIC_MOTION_PARTITION_REQUIRED)
619  config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_USE_ASYMETRIC_MOTION_PARTITION;
620 
621  if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_SAO_FILTER_SUPPORT)
622  config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_SAO_FILTER;
623 
624  if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_DISABLING_LOOP_FILTER_ACROSS_SLICES_SUPPORT)
625  config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_DISABLE_LOOP_FILTER_ACROSS_SLICES;
626 
627  if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_TRANSFORM_SKIP_SUPPORT)
628  config->ConfigurationFlags |= D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_FLAG_ENABLE_TRANSFORM_SKIPPING;
629 
630  if (hevc_caps.SupportFlags & D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC_FLAG_P_FRAMES_IMPLEMENTED_AS_LOW_DELAY_B_FRAMES)
631  ctx->bi_not_empty = 1;
632 
633  // block sizes
634  min_cu_size = d3d12va_encode_hevc_map_cusize(hevc_caps.MinLumaCodingUnitSize);
635  max_cu_size = d3d12va_encode_hevc_map_cusize(hevc_caps.MaxLumaCodingUnitSize);
636 
637  av_log(avctx, AV_LOG_VERBOSE, "Using CTU size %dx%d, "
638  "min CB size %dx%d.\n", max_cu_size, max_cu_size,
639  min_cu_size, min_cu_size);
640 
641  base_ctx->surface_width = FFALIGN(avctx->width, min_cu_size);
642  base_ctx->surface_height = FFALIGN(avctx->height, min_cu_size);
643 
644  return 0;
645 }
646 
648 {
649  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
651  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
652  int fixed_qp_idr, fixed_qp_p, fixed_qp_b;
653  int err;
654 
655  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_HEVC, avctx);
656  if (err < 0)
657  return err;
658 
659  // Rate control
660  if (ctx->rc.Mode == D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CQP) {
661  D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP *cqp_ctl;
662  fixed_qp_p = av_clip(ctx->rc_quality, 1, 51);
663  if (avctx->i_quant_factor > 0.0)
664  fixed_qp_idr = av_clip((avctx->i_quant_factor * fixed_qp_p +
665  avctx->i_quant_offset) + 0.5, 1, 51);
666  else
667  fixed_qp_idr = fixed_qp_p;
668  if (avctx->b_quant_factor > 0.0)
669  fixed_qp_b = av_clip((avctx->b_quant_factor * fixed_qp_p +
670  avctx->b_quant_offset) + 0.5, 1, 51);
671  else
672  fixed_qp_b = fixed_qp_p;
673 
674  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
675  "%d / %d / %d for IDR- / P- / B-frames.\n",
676  fixed_qp_idr, fixed_qp_p, fixed_qp_b);
677 
678  ctx->rc.ConfigParams.DataSize = sizeof(D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP);
679  cqp_ctl = av_mallocz(ctx->rc.ConfigParams.DataSize);
680  if (!cqp_ctl)
681  return AVERROR(ENOMEM);
682 
683  cqp_ctl->ConstantQP_FullIntracodedFrame = fixed_qp_idr;
684  cqp_ctl->ConstantQP_InterPredictedFrame_PrevRefOnly = fixed_qp_p;
685  cqp_ctl->ConstantQP_InterPredictedFrame_BiDirectionalRef = fixed_qp_b;
686 
687  ctx->rc.ConfigParams.pConfiguration_CQP = cqp_ctl;
688  }
689 
690  // GOP
691  ctx->gop.DataSize = sizeof(D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE_HEVC);
692  ctx->gop.pHEVCGroupOfPictures = av_mallocz(ctx->gop.DataSize);
693  if (!ctx->gop.pHEVCGroupOfPictures)
694  return AVERROR(ENOMEM);
695 
696  ctx->gop.pHEVCGroupOfPictures->GOPLength = base_ctx->gop_size;
697  ctx->gop.pHEVCGroupOfPictures->PPicturePeriod = base_ctx->b_per_p + 1;
698  // Power of 2
699  if (base_ctx->gop_size & base_ctx->gop_size - 1 == 0)
700  ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4 =
701  FFMAX(av_log2(base_ctx->gop_size) - 4, 0);
702  else
703  ctx->gop.pHEVCGroupOfPictures->log2_max_pic_order_cnt_lsb_minus4 =
704  FFMAX(av_log2(base_ctx->gop_size) - 3, 0);
705 
706  return 0;
707 }
708 
710 {
712  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
713  int i;
714 
715  ctx->level.DataSize = sizeof(D3D12_VIDEO_ENCODER_LEVEL_TIER_CONSTRAINTS_HEVC);
716  ctx->level.pHEVCLevelSetting = av_mallocz(ctx->level.DataSize);
717  if (!ctx->level.pHEVCLevelSetting)
718  return AVERROR(ENOMEM);
719 
720  for (i = 0; i < FF_ARRAY_ELEMS(hevc_levels); i++) {
721  if (avctx->level == hevc_levels[i].level) {
722  ctx->level.pHEVCLevelSetting->Level = hevc_levels[i].d3d12_level;
723  break;
724  }
725  }
726 
727  if (i == FF_ARRAY_ELEMS(hevc_levels)) {
728  av_log(avctx, AV_LOG_ERROR, "Invalid level %d.\n", avctx->level);
729  return AVERROR(EINVAL);
730  }
731 
732  ctx->level.pHEVCLevelSetting->Tier = priv->raw_vps.profile_tier_level.general_tier_flag == 0 ?
733  D3D12_VIDEO_ENCODER_TIER_HEVC_MAIN :
734  D3D12_VIDEO_ENCODER_TIER_HEVC_HIGH;
735 
736  return 0;
737 }
738 
740 {
741  if (!pic->pic_ctl.pHEVCPicData)
742  return;
743 
744  av_freep(&pic->pic_ctl.pHEVCPicData->pList0ReferenceFrames);
745  av_freep(&pic->pic_ctl.pHEVCPicData->pList1ReferenceFrames);
746  av_freep(&pic->pic_ctl.pHEVCPicData->pReferenceFramesReconPictureDescriptors);
747  av_freep(&pic->pic_ctl.pHEVCPicData);
748 }
749 
752 {
753  FFHWBaseEncodePicture *base_pic = &pic->base;
754  D3D12VAEncodeHEVCPicture *hpic = base_pic->priv_data;
755  FFHWBaseEncodePicture *prev = base_pic->prev;
756  D3D12VAEncodeHEVCPicture *hprev = prev ? prev->priv_data : NULL;
757  D3D12_VIDEO_ENCODER_REFERENCE_PICTURE_DESCRIPTOR_HEVC *pd = NULL;
758  UINT *ref_list0 = NULL, *ref_list1 = NULL;
759  int i, idx = 0;
760 
761  pic->pic_ctl.DataSize = sizeof(D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA_HEVC);
762  pic->pic_ctl.pHEVCPicData = av_mallocz(pic->pic_ctl.DataSize);
763  if (!pic->pic_ctl.pHEVCPicData)
764  return AVERROR(ENOMEM);
765 
766  if (base_pic->type == FF_HW_PICTURE_TYPE_IDR) {
767  av_assert0(base_pic->display_order == base_pic->encode_order);
768  hpic->last_idr_frame = base_pic->display_order;
769  } else {
770  av_assert0(prev);
771  hpic->last_idr_frame = hprev->last_idr_frame;
772  }
773  hpic->pic_order_cnt = base_pic->display_order - hpic->last_idr_frame;
774 
775  switch(base_pic->type) {
777  pic->pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_IDR_FRAME;
778  break;
780  pic->pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_I_FRAME;
781  break;
783  pic->pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_P_FRAME;
784  break;
786  pic->pic_ctl.pHEVCPicData->FrameType = D3D12_VIDEO_ENCODER_FRAME_TYPE_HEVC_B_FRAME;
787  break;
788  default:
789  av_assert0(0 && "invalid picture type");
790  }
791 
792  pic->pic_ctl.pHEVCPicData->slice_pic_parameter_set_id = 0;
793  pic->pic_ctl.pHEVCPicData->PictureOrderCountNumber = hpic->pic_order_cnt;
794 
795  if (base_pic->type == FF_HW_PICTURE_TYPE_P || base_pic->type == FF_HW_PICTURE_TYPE_B) {
796  pd = av_calloc(MAX_PICTURE_REFERENCES, sizeof(*pd));
797  if (!pd)
798  return AVERROR(ENOMEM);
799 
800  ref_list0 = av_calloc(MAX_PICTURE_REFERENCES, sizeof(*ref_list0));
801  if (!ref_list0)
802  return AVERROR(ENOMEM);
803 
804  pic->pic_ctl.pHEVCPicData->List0ReferenceFramesCount = base_pic->nb_refs[0];
805  for (i = 0; i < base_pic->nb_refs[0]; i++) {
806  FFHWBaseEncodePicture *ref = base_pic->refs[0][i];
808 
809  av_assert0(ref && ref->encode_order < base_pic->encode_order);
810  href = ref->priv_data;
811 
812  ref_list0[i] = idx;
813  pd[idx].ReconstructedPictureResourceIndex = idx;
814  pd[idx].IsRefUsedByCurrentPic = TRUE;
815  pd[idx].PictureOrderCountNumber = href->pic_order_cnt;
816  idx++;
817  }
818  }
819 
820  if (base_pic->type == FF_HW_PICTURE_TYPE_B) {
821  ref_list1 = av_calloc(MAX_PICTURE_REFERENCES, sizeof(*ref_list1));
822  if (!ref_list1)
823  return AVERROR(ENOMEM);
824 
825  pic->pic_ctl.pHEVCPicData->List1ReferenceFramesCount = base_pic->nb_refs[1];
826  for (i = 0; i < base_pic->nb_refs[1]; i++) {
827  FFHWBaseEncodePicture *ref = base_pic->refs[1][i];
829 
830  av_assert0(ref && ref->encode_order < base_pic->encode_order);
831  href = ref->priv_data;
832 
833  ref_list1[i] = idx;
834  pd[idx].ReconstructedPictureResourceIndex = idx;
835  pd[idx].IsRefUsedByCurrentPic = TRUE;
836  pd[idx].PictureOrderCountNumber = href->pic_order_cnt;
837  idx++;
838  }
839  }
840 
841  pic->pic_ctl.pHEVCPicData->pList0ReferenceFrames = ref_list0;
842  pic->pic_ctl.pHEVCPicData->pList1ReferenceFrames = ref_list1;
843  pic->pic_ctl.pHEVCPicData->ReferenceFramesReconPictureDescriptorsCount = idx;
844  pic->pic_ctl.pHEVCPicData->pReferenceFramesReconPictureDescriptors = pd;
845 
846  return 0;
847 }
848 
851 
852  .d3d12_codec = D3D12_VIDEO_ENCODER_CODEC_HEVC,
853 
854  .flags = FF_HW_FLAG_B_PICTURES |
857 
858  .default_quality = 25,
859 
860  .get_encoder_caps = &d3d12va_encode_hevc_get_encoder_caps,
861 
862  .configure = &d3d12va_encode_hevc_configure,
863 
864  .set_level = &d3d12va_encode_hevc_set_level,
865 
866  .picture_priv_data_size = sizeof(D3D12VAEncodeHEVCPicture),
867 
868  .init_sequence_params = &d3d12va_encode_hevc_init_sequence_params,
869 
870  .init_picture_params = &d3d12va_encode_hevc_init_picture_params,
871 
872  .free_picture_params = &d3d12va_encode_hevc_free_picture_params,
873 
874  .write_sequence_header = &d3d12va_encode_hevc_write_sequence_header,
875 };
876 
878 {
880  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
881 
882  ctx->codec = &d3d12va_encode_type_hevc;
883 
884  if (avctx->profile == AV_PROFILE_UNKNOWN)
885  avctx->profile = priv->profile;
886  if (avctx->level == FF_LEVEL_UNKNOWN)
887  avctx->level = priv->level;
888 
889  if (avctx->level != FF_LEVEL_UNKNOWN && avctx->level & ~0xff) {
890  av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
891  "in 8-bit unsigned integer.\n", avctx->level);
892  return AVERROR(EINVAL);
893  }
894 
895  if (priv->qp > 0)
896  ctx->explicit_qp = priv->qp;
897 
898  return ff_d3d12va_encode_init(avctx);
899 }
900 
902 {
903  D3D12VAEncodeHEVCContext *priv = avctx->priv_data;
904 
906  ff_cbs_close(&priv->cbc);
907 
908  av_freep(&priv->common.codec_conf.pHEVCConfig);
909  av_freep(&priv->common.gop.pHEVCGroupOfPictures);
910  av_freep(&priv->common.level.pHEVCLevelSetting);
911 
912  return ff_d3d12va_encode_close(avctx);
913 }
914 
915 #define OFFSET(x) offsetof(D3D12VAEncodeHEVCContext, x)
916 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
920 
921  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
922  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
923 
924  { "profile", "Set profile (general_profile_idc)",
926  { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xff, FLAGS, "profile" },
927 
928 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
929  { .i64 = value }, 0, 0, FLAGS, "profile"
930  { PROFILE("main", AV_PROFILE_HEVC_MAIN) },
931  { PROFILE("main10", AV_PROFILE_HEVC_MAIN_10) },
932 #undef PROFILE
933 
934  { "tier", "Set tier (general_tier_flag)",
936  { .i64 = 0 }, 0, 1, FLAGS, "tier" },
937  { "main", NULL, 0, AV_OPT_TYPE_CONST,
938  { .i64 = 0 }, 0, 0, FLAGS, "tier" },
939  { "high", NULL, 0, AV_OPT_TYPE_CONST,
940  { .i64 = 1 }, 0, 0, FLAGS, "tier" },
941 
942  { "level", "Set level (general_level_idc)",
944  { .i64 = FF_LEVEL_UNKNOWN }, FF_LEVEL_UNKNOWN, 0xff, FLAGS, "level" },
945 
946 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
947  { .i64 = value }, 0, 0, FLAGS, "level"
948  { LEVEL("1", 30) },
949  { LEVEL("2", 60) },
950  { LEVEL("2.1", 63) },
951  { LEVEL("3", 90) },
952  { LEVEL("3.1", 93) },
953  { LEVEL("4", 120) },
954  { LEVEL("4.1", 123) },
955  { LEVEL("5", 150) },
956  { LEVEL("5.1", 153) },
957  { LEVEL("5.2", 156) },
958  { LEVEL("6", 180) },
959  { LEVEL("6.1", 183) },
960  { LEVEL("6.2", 186) },
961 #undef LEVEL
962 
963  { NULL },
964 };
965 
967  { "b", "0" },
968  { "bf", "2" },
969  { "g", "120" },
970  { "i_qfactor", "1" },
971  { "i_qoffset", "0" },
972  { "b_qfactor", "1" },
973  { "b_qoffset", "0" },
974  { "qmin", "-1" },
975  { "qmax", "-1" },
976  { NULL },
977 };
978 
980  .class_name = "hevc_d3d12va",
981  .item_name = av_default_item_name,
982  .option = d3d12va_encode_hevc_options,
983  .version = LIBAVUTIL_VERSION_INT,
984 };
985 
987  .p.name = "hevc_d3d12va",
988  CODEC_LONG_NAME("D3D12VA hevc encoder"),
989  .p.type = AVMEDIA_TYPE_VIDEO,
990  .p.id = AV_CODEC_ID_HEVC,
991  .priv_data_size = sizeof(D3D12VAEncodeHEVCContext),
994  .close = &d3d12va_encode_hevc_close,
995  .p.priv_class = &d3d12va_encode_hevc_class,
996  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE |
998  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1000  .defaults = d3d12va_encode_hevc_defaults,
1001  .p.pix_fmts = (const enum AVPixelFormat[]) {
1004  },
1005  .hw_configs = ff_d3d12va_encode_hw_configs,
1006  .p.wrapper_name = "d3d12va",
1007 };
H265RawVUI::log2_max_mv_length_horizontal
uint8_t log2_max_mv_length_horizontal
Definition: cbs_h265.h:174
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
av_clip
#define av_clip
Definition: common.h:100
H265RawVUI::bitstream_restriction_flag
uint8_t bitstream_restriction_flag
Definition: cbs_h265.h:167
FF_CODEC_CAP_INIT_CLEANUP
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: codec_internal.h:42
FF_HW_PICTURE_TYPE_I
@ FF_HW_PICTURE_TYPE_I
Definition: hw_base_encode.h:40
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
d3d12va_encode_hevc_write_sequence_header
static int d3d12va_encode_hevc_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: d3d12va_encode_hevc.c:208
H265RawProfileTierLevel::general_interlaced_source_flag
uint8_t general_interlaced_source_flag
Definition: cbs_h265.h:44
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:685
H265RawProfileTierLevel::general_level_idc
uint8_t general_level_idc
Definition: cbs_h265.h:61
d3d12va_encode_hevc_init_sequence_params
static int d3d12va_encode_hevc_init_sequence_params(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:234
ff_cbs_fragment_free
av_cold void ff_cbs_fragment_free(CodedBitstreamFragment *frag)
Free the units array of a fragment in addition to what ff_cbs_fragment_reset does.
Definition: cbs.c:186
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2965
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
H265RawVUI::colour_primaries
uint8_t colour_primaries
Definition: cbs_h265.h:141
ff_cbs_insert_unit_content
int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, void *content_ref)
Insert a new unit into a fragment with the given content.
Definition: cbs.c:783
D3D12VAEncodeHEVCLevel::d3d12_level
D3D12_VIDEO_ENCODER_LEVELS_HEVC d3d12_level
Definition: d3d12va_encode_hevc.c:61
AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN
Definition: defs.h:159
H265RawVUI
Definition: cbs_h265.h:128
pixdesc.h
D3D12VAEncodeHEVCContext::tier
int tier
Definition: d3d12va_encode_hevc.c:47
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:678
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:686
ff_cbs_fragment_reset
void ff_cbs_fragment_reset(CodedBitstreamFragment *frag)
Free the units contained in a fragment as well as the fragment's own data buffer, but not the units a...
Definition: cbs.c:172
d3d12va_encode_hevc_class
static const AVClass d3d12va_encode_hevc_class
Definition: d3d12va_encode_hevc.c:979
H265RawProfileTierLevel::general_max_8bit_constraint_flag
uint8_t general_max_8bit_constraint_flag
Definition: cbs_h265.h:50
H265RawVUI::aspect_ratio_info_present_flag
uint8_t aspect_ratio_info_present_flag
Definition: cbs_h265.h:129
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:219
AVOption
AVOption.
Definition: opt.h:357
D3D12VAEncodeHEVCPicture::last_idr_frame
int64_t last_idr_frame
Definition: d3d12va_encode_hevc.c:38
d3d12va_encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:583
data
const char data[16]
Definition: mxf.c:148
d3d12va_encode_hevc_add_nal
static int d3d12va_encode_hevc_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
Definition: d3d12va_encode_hevc.c:190
d3d12va_encode_hevc_map_cusize
static uint8_t d3d12va_encode_hevc_map_cusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_CUSIZE cusize)
Definition: d3d12va_encode_hevc.c:140
AVCodecContext::b_quant_offset
float b_quant_offset
qscale offset between IP and B-frames
Definition: avcodec.h:811
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:34
FFCodec
Definition: codec_internal.h:126
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
d3d12va_encode_hevc_write_access_unit
static int d3d12va_encode_hevc_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au)
Definition: d3d12va_encode_hevc.c:164
H265RawVUI::vui_timing_info_present_flag
uint8_t vui_timing_info_present_flag
Definition: cbs_h265.h:159
cbs.h
cbs_h265.h
FF_LEVEL_UNKNOWN
#define FF_LEVEL_UNKNOWN
Definition: avcodec.h:1788
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
H265RawProfileTierLevel::general_frame_only_constraint_flag
uint8_t general_frame_only_constraint_flag
Definition: cbs_h265.h:46
bit_depth
static void bit_depth(AudioStatsContext *s, const uint64_t *const mask, uint8_t *depth)
Definition: af_astats.c:246
D3D12VAEncodeHEVCContext
Definition: d3d12va_encode_hevc.c:41
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
H265RawVUI::log2_max_mv_length_vertical
uint8_t log2_max_mv_length_vertical
Definition: cbs_h265.h:175
tf_sess_config.config
config
Definition: tf_sess_config.py:33
ff_cbs_close
av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:142
H265LevelDescriptor
Definition: h265_profile_level.h:27
H265RawProfileTierLevel::general_max_422chroma_constraint_flag
uint8_t general_max_422chroma_constraint_flag
Definition: cbs_h265.h:51
H265RawSPS
Definition: cbs_h265.h:245
H265RawVPS
Definition: cbs_h265.h:184
H265RawPPS
Definition: cbs_h265.h:347
FFHWBaseEncodeContext
Definition: hw_base_encode.h:118
d3d12va_encode_hevc_map_tusize
static uint8_t d3d12va_encode_hevc_map_tusize(D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_HEVC_TUSIZE tusize)
Definition: d3d12va_encode_hevc.c:152
D3D12VAEncodeHEVCContext::current_access_unit
CodedBitstreamFragment current_access_unit
Definition: d3d12va_encode_hevc.c:56
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:560
ff_d3d12va_encode_hw_configs
const AVCodecHWConfigInternal *const ff_d3d12va_encode_hw_configs[]
Definition: d3d12va_encode.c:36
H265RawVUI::video_format
uint8_t video_format
Definition: cbs_h265.h:138
H265RawVUI::max_bits_per_min_cu_denom
uint8_t max_bits_per_min_cu_denom
Definition: cbs_h265.h:173
AVCodecContext::i_quant_factor
float i_quant_factor
qscale factor between P- and I-frames If > 0 then the last P-frame quantizer will be used (q = lastp_...
Definition: avcodec.h:820
H265RawProfileTierLevel::general_progressive_source_flag
uint8_t general_progressive_source_flag
Definition: cbs_h265.h:43
FFCodecDefault
Definition: codec_internal.h:96
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:130
FFHWBaseEncodePicture::type
int type
Definition: hw_base_encode.h:73
fail
#define fail()
Definition: checkasm.h:186
FF_HW_PICTURE_TYPE_B
@ FF_HW_PICTURE_TYPE_B
Definition: hw_base_encode.h:42
profile_main10
static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main10
Definition: d3d12va_encode_hevc.c:130
H265RawProfileTierLevel::general_max_12bit_constraint_flag
uint8_t general_max_12bit_constraint_flag
Definition: cbs_h265.h:48
D3D12VAEncodeHEVCContext::qp
int qp
Definition: d3d12va_encode_hevc.c:45
D3D12VA_ENCODE_RC_OPTIONS
#define D3D12VA_ENCODE_RC_OPTIONS
Definition: d3d12va_encode.h:324
D3D12VAEncodeHEVCContext::level
int level
Definition: d3d12va_encode_hevc.c:48
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
H265RawProfileTierLevel::general_intra_constraint_flag
uint8_t general_intra_constraint_flag
Definition: cbs_h265.h:54
av_reduce
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
d3d12va_encode_hevc_free_picture_params
static void d3d12va_encode_hevc_free_picture_params(D3D12VAEncodePicture *pic)
Definition: d3d12va_encode_hevc.c:739
AVRational::num
int num
Numerator.
Definition: rational.h:59
d3d12va_encode_hevc_close
static int d3d12va_encode_hevc_close(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:901
D3D12VAEncodeHEVCContext::common
D3D12VAEncodeContext common
Definition: d3d12va_encode_hevc.c:42
FFHWBaseEncodePicture::prev
struct FFHWBaseEncodePicture * prev
Definition: hw_base_encode.h:98
d3d12va_encode_hevc_get_encoder_caps
static int d3d12va_encode_hevc_get_encoder_caps(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:571
D3D12VAEncodeHEVCContext::raw_pps
H265RawPPS raw_pps
Definition: d3d12va_encode_hevc.c:53
H265RawVUI::sar_height
uint16_t sar_height
Definition: cbs_h265.h:132
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:671
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
main
int main
Definition: dovi_rpuenc.c:37
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
ptl
const H265RawProfileTierLevel * ptl
Definition: h265_levels.c:170
ff_h265_guess_level
const H265LevelDescriptor * ff_h265_guess_level(const H265RawProfileTierLevel *ptl, int64_t bitrate, int width, int height, int slice_segments, int tile_rows, int tile_cols, int max_dec_pic_buffering)
Guess the level of a stream from some parameters.
Definition: h265_profile_level.c:162
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:122
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:135
H265RawProfileTierLevel::general_profile_idc
uint8_t general_profile_idc
Definition: cbs_h265.h:39
H265RawProfileTierLevel::general_non_packed_constraint_flag
uint8_t general_non_packed_constraint_flag
Definition: cbs_h265.h:45
H265RawVPS::profile_tier_level
H265RawProfileTierLevel profile_tier_level
Definition: cbs_h265.h:195
FFHWBaseEncodeContext::max_b_depth
int max_b_depth
Definition: hw_base_encode.h:184
hevc_config_support_sets
static const D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT_HEVC hevc_config_support_sets[]
Definition: d3d12va_encode_hevc.c:64
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
D3D12VAEncodeHEVCPicture
Definition: d3d12va_encode_hevc.c:36
HEVC_NAL_VPS
@ HEVC_NAL_VPS
Definition: hevc.h:61
FLAGS
#define FLAGS
Definition: d3d12va_encode_hevc.c:916
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
FFHWBaseEncodePicture::priv_data
void * priv_data
Definition: hw_base_encode.h:81
D3D12VAEncodeHEVCContext::cbc
CodedBitstreamContext * cbc
Definition: d3d12va_encode_hevc.c:55
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:201
ctx
AVFormatContext * ctx
Definition: movenc.c:49
H265RawProfileTierLevel::general_max_14bit_constraint_flag
uint8_t general_max_14bit_constraint_flag
Definition: cbs_h265.h:57
PROFILE
#define PROFILE(name, value)
D3D12VAEncodePicture::pic_ctl
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA pic_ctl
Definition: d3d12va_encode.h:56
H265RawVUI::vui_time_scale
uint32_t vui_time_scale
Definition: cbs_h265.h:161
H265RawVUI::video_signal_type_present_flag
uint8_t video_signal_type_present_flag
Definition: cbs_h265.h:137
FF_HW_PICTURE_TYPE_IDR
@ FF_HW_PICTURE_TYPE_IDR
Definition: hw_base_encode.h:39
tier
int tier
Definition: av1_levels.c:48
CodedBitstreamFragment::data_bit_padding
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
Definition: cbs.h:139
h2645data.h
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:558
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:271
FFHWBaseEncodeContext::b_per_p
int b_per_p
Definition: hw_base_encode.h:185
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
H265RawVUI::matrix_coefficients
uint8_t matrix_coefficients
Definition: cbs_h265.h:143
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:210
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:695
d3d12va_encode_hevc_set_level
static int d3d12va_encode_hevc_set_level(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:709
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:301
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:495
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
H265RawVUI::chroma_sample_loc_type_bottom_field
uint8_t chroma_sample_loc_type_bottom_field
Definition: cbs_h265.h:147
AVD3D12VAFramesContext
This struct is allocated as AVHWFramesContext.hwctx.
Definition: hwcontext_d3d12va.h:126
AV_PIX_FMT_D3D12
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
Definition: pixfmt.h:440
vps
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
Definition: cbs_h265_syntax_template.c:423
H265RawProfileTierLevel::general_max_10bit_constraint_flag
uint8_t general_max_10bit_constraint_flag
Definition: cbs_h265.h:49
H265RawVUI::vui_num_ticks_poc_diff_one_minus1
uint32_t vui_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:163
H265RawVUI::video_full_range_flag
uint8_t video_full_range_flag
Definition: cbs_h265.h:139
H265RawProfileTierLevel::general_tier_flag
uint8_t general_tier_flag
Definition: cbs_h265.h:38
AVCodecContext::level
int level
Encoding level descriptor.
Definition: avcodec.h:1784
AV_PROFILE_HEVC_MAIN_10
#define AV_PROFILE_HEVC_MAIN_10
Definition: defs.h:160
AVCOL_RANGE_UNSPECIFIED
@ AVCOL_RANGE_UNSPECIFIED
Definition: pixfmt.h:652
H265RawNALUnitHeader
Definition: cbs_h265.h:30
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Definition: avcodec.h:544
D3D12VAEncodeContext::codec_conf
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION codec_conf
Definition: d3d12va_encode.h:244
D3D12VAEncodeHEVCLevel
Definition: d3d12va_encode_hevc.c:59
H265RawVUI::chroma_loc_info_present_flag
uint8_t chroma_loc_info_present_flag
Definition: cbs_h265.h:145
H265RawVUI::sar_width
uint16_t sar_width
Definition: cbs_h265.h:131
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:366
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
codec_internal.h
ff_d3d12va_encode_init
int ff_d3d12va_encode_init(AVCodecContext *avctx)
Definition: d3d12va_encode.c:1400
FFHWBaseEncodePicture::nb_refs
int nb_refs[MAX_REFERENCE_LIST_NUM]
Definition: hw_base_encode.h:94
MAX_DPB_SIZE
#define MAX_DPB_SIZE
Definition: hw_base_encode.h:26
D3D12VAEncodeProfile
Definition: d3d12va_encode.h:61
H265RawProfileTierLevel::general_lower_bit_rate_constraint_flag
uint8_t general_lower_bit_rate_constraint_flag
Definition: cbs_h265.h:56
HEVC_NAL_SPS
@ HEVC_NAL_SPS
Definition: hevc.h:62
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:128
H265RawProfileTierLevel::general_max_monochrome_constraint_flag
uint8_t general_max_monochrome_constraint_flag
Definition: cbs_h265.h:53
D3D12VAEncodeHEVCContext::profile
int profile
Definition: d3d12va_encode_hevc.c:46
D3D12VAEncodePicture::base
FFHWBaseEncodePicture base
Definition: d3d12va_encode.h:43
d3d12va_encode_hevc_init
static int d3d12va_encode_hevc_init(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:877
h265_profile_level.h
AVCHROMA_LOC_UNSPECIFIED
@ AVCHROMA_LOC_UNSPECIFIED
Definition: pixfmt.h:706
d3d12va_encode_hevc_options
static const AVOption d3d12va_encode_hevc_options[]
Definition: d3d12va_encode_hevc.c:917
HEVC_NAL_PPS
@ HEVC_NAL_PPS
Definition: hevc.h:63
header
static const uint8_t header[24]
Definition: sdr2.c:68
H265RawProfileTierLevel::general_one_picture_only_constraint_flag
uint8_t general_one_picture_only_constraint_flag
Definition: cbs_h265.h:55
FFHWBaseEncodePicture::encode_order
int64_t encode_order
Definition: hw_base_encode.h:65
ff_hevc_d3d12va_encoder
const FFCodec ff_hevc_d3d12va_encoder
Definition: d3d12va_encode_hevc.c:986
H265RawVUI::chroma_sample_loc_type_top_field
uint8_t chroma_sample_loc_type_top_field
Definition: cbs_h265.h:146
d3d12va_encode_hevc_defaults
static const FFCodecDefault d3d12va_encode_hevc_defaults[]
Definition: d3d12va_encode_hevc.c:966
d3d12va_encode_hevc_init_picture_params
static int d3d12va_encode_hevc_init_picture_params(AVCodecContext *avctx, D3D12VAEncodePicture *pic)
Definition: d3d12va_encode_hevc.c:750
D3D12VAEncodePicture
Definition: d3d12va_encode.h:42
AVCodecContext::b_quant_factor
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...
Definition: avcodec.h:804
H265RawVUI::max_bytes_per_pic_denom
uint8_t max_bytes_per_pic_denom
Definition: cbs_h265.h:172
D3D12VAEncodeContext::level
D3D12_VIDEO_ENCODER_LEVEL_SETTING level
Definition: d3d12va_encode.h:250
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
H265RawVUI::vui_hrd_parameters_present_flag
uint8_t vui_hrd_parameters_present_flag
Definition: cbs_h265.h:164
common.h
H265RawVUI::vui_num_units_in_tick
uint32_t vui_num_units_in_tick
Definition: cbs_h265.h:160
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:226
D3D12VAEncodeHEVCContext::raw_vps
H265RawVPS raw_vps
Definition: d3d12va_encode_hevc.c:51
FFHWBaseEncodePicture::refs
struct FFHWBaseEncodePicture * refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES]
Definition: hw_base_encode.h:95
av_mallocz
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
Definition: mem.c:256
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
ff_h2645_pixel_aspect
const AVRational ff_h2645_pixel_aspect[]
Definition: h2645data.c:21
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:702
profile
int profile
Definition: mxfenc.c:2228
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:612
AVCodecContext::height
int height
Definition: avcodec.h:618
H265RawProfileTierLevel
Definition: cbs_h265.h:36
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Definition: mem.c:264
H265RawProfileTierLevel::general_max_420chroma_constraint_flag
uint8_t general_max_420chroma_constraint_flag
Definition: cbs_h265.h:52
ff_cbs_write_fragment_data
int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Write the content of the fragment to its own internal buffer.
Definition: cbs.c:409
H265RawProfileTierLevel::general_profile_space
uint8_t general_profile_space
Definition: cbs_h265.h:37
avcodec.h
AVD3D12VAFramesContext::format
DXGI_FORMAT format
DXGI_FORMAT format.
Definition: hwcontext_d3d12va.h:131
H265RawProfileTierLevel::general_profile_compatibility_flag
uint8_t general_profile_compatibility_flag[32]
Definition: cbs_h265.h:41
FFHWBaseEncodeContext::gop_size
int gop_size
Definition: hw_base_encode.h:180
FFHWBaseEncodePicture
Definition: hw_base_encode.h:61
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:71
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:150
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
D3D12VAEncodeContext
Definition: d3d12va_encode.h:145
d3d12va_encode_type_hevc
static const D3D12VAEncodeType d3d12va_encode_type_hevc
Definition: d3d12va_encode_hevc.c:849
FF_HW_PICTURE_TYPE_P
@ FF_HW_PICTURE_TYPE_P
Definition: hw_base_encode.h:41
profile_main
static const D3D12_VIDEO_ENCODER_PROFILE_HEVC profile_main
Definition: d3d12va_encode_hevc.c:129
D3D12VAEncodeHEVCLevel::level
int level
Definition: d3d12va_encode_hevc.c:60
OFFSET
#define OFFSET(x)
Definition: d3d12va_encode_hevc.c:915
FFHWBaseEncodeContext::surface_height
int surface_height
Definition: hw_base_encode.h:137
AVCodecContext
main external API structure.
Definition: avcodec.h:445
D3D12VAEncodeHEVCContext::raw_sps
H265RawSPS raw_sps
Definition: d3d12va_encode_hevc.c:52
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
H265RawVUI::colour_description_present_flag
uint8_t colour_description_present_flag
Definition: cbs_h265.h:140
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:245
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1640
AVCodecContext::i_quant_offset
float i_quant_offset
qscale offset between P and I-frames
Definition: avcodec.h:827
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
D3D_PROFILE_DESC
#define D3D_PROFILE_DESC(name)
Definition: d3d12va_encode_hevc.c:132
pps
uint64_t pps
Definition: dovi_rpuenc.c:35
FFHWBaseEncodeContext::input_frames
AVHWFramesContext * input_frames
Definition: hw_base_encode.h:149
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
Definition: hw_base_encode.h:58
FFHWBaseEncodeContext::surface_width
int surface_width
Definition: hw_base_encode.h:136
D3D12VAEncodeContext::gop
D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE gop
Definition: d3d12va_encode.h:248
H265RawVUI::transfer_characteristics
uint8_t transfer_characteristics
Definition: cbs_h265.h:142
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
mem.h
D3D12VAEncodeHEVCPicture::pic_order_cnt
int pic_order_cnt
Definition: d3d12va_encode_hevc.c:37
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
ff_cbs_init
av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx)
Create and initialise a new context for the given codec.
Definition: cbs.c:90
LEVEL
#define LEVEL(name, value)
ff_d3d12va_encode_close
int ff_d3d12va_encode_close(AVCodecContext *avctx)
Definition: d3d12va_encode.c:1519
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
ff_d3d12va_encode_receive_packet
int ff_d3d12va_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: d3d12va_encode.c:1395
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:472
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
D3D12VAEncodeType::profiles
const D3D12VAEncodeProfile * profiles
List of supported profiles.
Definition: d3d12va_encode.h:257
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:618
d3d12va_encode_hevc_configure
static int d3d12va_encode_hevc_configure(AVCodecContext *avctx)
Definition: d3d12va_encode_hevc.c:647
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
H265RawVUI::vui_poc_proportional_to_timing_flag
uint8_t vui_poc_proportional_to_timing_flag
Definition: cbs_h265.h:162
HW_BASE_ENCODE_COMMON_OPTIONS
#define HW_BASE_ENCODE_COMMON_OPTIONS
Definition: hw_base_encode.h:237
D3D12VAEncodeType
Definition: d3d12va_encode.h:253
d3d12va_encode_hevc_profiles
static const D3D12VAEncodeProfile d3d12va_encode_hevc_profiles[]
Definition: d3d12va_encode_hevc.c:134
hwcontext_d3d12va_internal.h
FFHWBaseEncodePicture::display_order
int64_t display_order
Definition: hw_base_encode.h:64
H265RawVUI::aspect_ratio_idc
uint8_t aspect_ratio_idc
Definition: cbs_h265.h:130
H265RawVUI::restricted_ref_pic_lists_flag
uint8_t restricted_ref_pic_lists_flag
Definition: cbs_h265.h:170
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:254
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
hevc_levels
static const D3D12VAEncodeHEVCLevel hevc_levels[]
Definition: d3d12va_encode_hevc.c:113
AVCodecContext::sample_aspect_ratio
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel.
Definition: avcodec.h:642
H265RawVUI::motion_vectors_over_pic_boundaries_flag
uint8_t motion_vectors_over_pic_boundaries_flag
Definition: cbs_h265.h:169
MAX_PICTURE_REFERENCES
#define MAX_PICTURE_REFERENCES
Definition: hw_base_encode.h:27