FFmpeg
d3d12va_encode_av1.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 
23 #include "libavutil/opt.h"
24 #include "libavutil/common.h"
25 #include "libavutil/mem.h"
26 #include "libavutil/pixdesc.h"
28 
29 #include "config_components.h"
30 #include "avcodec.h"
31 #include "cbs.h"
32 #include "cbs_av1.h"
33 #include "av1_levels.h"
34 #include "codec_internal.h"
35 #include "d3d12va_encode.h"
36 #include "encode.h"
37 #include "hw_base_encode.h"
38 
39 #include <d3d12.h>
40 #include <d3d12video.h>
41 
42 #ifndef D3D12_VIDEO_ENCODER_AV1_INVALID_DPB_RESOURCE_INDEX
43 #define D3D12_VIDEO_ENCODER_AV1_INVALID_DPB_RESOURCE_INDEX ( 0xff )
44 #endif
45 
46 typedef struct D3D12VAHWBaseEncodeAV1 {
51 
53  int tier; // 0: Main tier, 1: High tier
54  int level; // AV1 level (2.0-7.3 map to 0-23)
55 
56  int enable_cdef; // Constrained Directional Enhancement Filter
57  int enable_restoration; // loop restoration
58  int enable_superres; // super-resolution
60 
63 
69 
73 
77 
78 typedef struct D3D12VAEncodeAV1Picture {
79  uint8_t temporal_id;
80  uint8_t spatial_id;
81  uint8_t show_frame;
82  uint8_t frame_type;
83  uint16_t last_idr_frame;
84  uint8_t slot;
86 
87 typedef struct D3D12VAEncodeAV1Context {
89  // User options.
90  int qp;
91  int profile;
92  int level;
93  int tier;
94 
95  uint8_t q_idx_idr;
96  uint8_t q_idx_p;
97 
98  // Writer structures.
101 
104  D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAGS post_encode_values_flag;
107 
108 typedef struct D3D12VAEncodeAV1Level {
109  uint8_t level;
110  D3D12_VIDEO_ENCODER_AV1_LEVELS d3d12_level;
112 
113 
115  { 0, D3D12_VIDEO_ENCODER_AV1_LEVELS_2_0 },
116  { 1, D3D12_VIDEO_ENCODER_AV1_LEVELS_2_1 },
117  { 2, D3D12_VIDEO_ENCODER_AV1_LEVELS_2_2 },
118  { 3, D3D12_VIDEO_ENCODER_AV1_LEVELS_2_3 },
119  { 4, D3D12_VIDEO_ENCODER_AV1_LEVELS_3_0 },
120  { 5, D3D12_VIDEO_ENCODER_AV1_LEVELS_3_1 },
121  { 6, D3D12_VIDEO_ENCODER_AV1_LEVELS_3_2 },
122  { 7, D3D12_VIDEO_ENCODER_AV1_LEVELS_3_3 },
123  { 8, D3D12_VIDEO_ENCODER_AV1_LEVELS_4_0 },
124  { 9, D3D12_VIDEO_ENCODER_AV1_LEVELS_4_1 },
125  { 10, D3D12_VIDEO_ENCODER_AV1_LEVELS_4_2 },
126  { 11, D3D12_VIDEO_ENCODER_AV1_LEVELS_4_3 },
127  { 12, D3D12_VIDEO_ENCODER_AV1_LEVELS_5_0 },
128  { 13, D3D12_VIDEO_ENCODER_AV1_LEVELS_5_1 },
129  { 14, D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2 },
130  { 15, D3D12_VIDEO_ENCODER_AV1_LEVELS_5_3 },
131  { 16, D3D12_VIDEO_ENCODER_AV1_LEVELS_6_0 },
132  { 17, D3D12_VIDEO_ENCODER_AV1_LEVELS_6_1 },
133  { 18, D3D12_VIDEO_ENCODER_AV1_LEVELS_6_2 },
134  { 19, D3D12_VIDEO_ENCODER_AV1_LEVELS_6_3 },
135  { 20, D3D12_VIDEO_ENCODER_AV1_LEVELS_7_0 },
136  { 21, D3D12_VIDEO_ENCODER_AV1_LEVELS_7_1 },
137  { 22, D3D12_VIDEO_ENCODER_AV1_LEVELS_7_2 },
138  { 23, D3D12_VIDEO_ENCODER_AV1_LEVELS_7_3 },
139 };
140 
141 static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_main = D3D12_VIDEO_ENCODER_AV1_PROFILE_MAIN;
142 static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_high = D3D12_VIDEO_ENCODER_AV1_PROFILE_HIGH;
143 static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_professional = D3D12_VIDEO_ENCODER_AV1_PROFILE_PROFESSIONAL;
144 
145 #define D3D_PROFILE_DESC(name) \
146  { sizeof(D3D12_VIDEO_ENCODER_AV1_PROFILE), { .pAV1Profile = (D3D12_VIDEO_ENCODER_AV1_PROFILE *)&profile_ ## name } }
148  { AV_PROFILE_AV1_MAIN, 8, 3, 1, 1, D3D_PROFILE_DESC(main) },
149  { AV_PROFILE_AV1_MAIN, 10, 3, 1, 1, D3D_PROFILE_DESC(main) },
150  { AV_PROFILE_AV1_HIGH, 10, 3, 1, 1, D3D_PROFILE_DESC(high) },
151  { AV_PROFILE_AV1_PROFESSIONAL, 8, 3, 1, 1, D3D_PROFILE_DESC(professional) },
152  { AV_PROFILE_AV1_PROFESSIONAL, 10, 3, 1, 1, D3D_PROFILE_DESC(professional) },
153  { AV_PROFILE_AV1_PROFESSIONAL, 12, 3, 1, 1, D3D_PROFILE_DESC(professional) },
154  { AV_PROFILE_UNKNOWN },
155 };
156 
158  char *data, size_t *data_len,
160 {
161  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
162  int err = 0;
163 
164  err = ff_cbs_write_fragment_data(priv->cbc, obu);
165  if (err < 0) {
166  av_log(avctx, AV_LOG_ERROR, "Failed to write packed OBU data.\n");
167  return err;
168  }
169 
170  memcpy(data, obu->data, obu->data_size);
171  *data_len = (8 * obu->data_size) - obu->data_bit_padding;
172 
173  return 0;
174 }
175 
178  CodedBitstreamUnitType obu_type,
179  void* obu_unit)
180 {
181  int err = 0;
182 
183  err = ff_cbs_insert_unit_content(au, -1, obu_type, obu_unit, NULL);
184  if (err < 0) {
185  av_log(avctx, AV_LOG_ERROR, "Failed to add OBU unit: "
186  "type = %d.\n", obu_type);
187  return err;
188  }
189  return 0;
190 }
191 
193  char *data, size_t *data_len)
194 {
195  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
196  CodedBitstreamFragment *obu = &priv->current_obu;
197  int err = 0;
198 
201  if (err < 0)
202  goto fail;
203 
204  err = d3d12va_encode_av1_write_obu(avctx, data, data_len, obu);
205 
206 fail:
207  ff_cbs_fragment_reset(obu);
208  return err;
209 }
210 
213  AV1RawOBU *frameheader_obu)
214 {
215  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
216  AV1RawFrameHeader *fh = &frameheader_obu->obu.frame_header;
217  uint8_t *data = NULL;
218  HRESULT hr = S_OK;
219  int err = 0;
220  D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES *post_encode_values = NULL;
221 
222  // Update the frame header according to the picture post_encode_values
223  hr = ID3D12Resource_Map(pic->resolved_metadata, 0, NULL, (void **)&data);
224  if (FAILED(hr)) {
225  err = AVERROR_UNKNOWN;
226  return err;
227  }
228  post_encode_values = (D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES*) (data +
229  sizeof(D3D12_VIDEO_ENCODER_OUTPUT_METADATA) +
230  sizeof(D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA) +
231  sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES));
232 
233  if (priv->post_encode_values_flag & D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAG_QUANTIZATION) {
234  fh->base_q_idx = post_encode_values->Quantization.BaseQIndex;
235  fh->delta_q_y_dc = post_encode_values->Quantization.YDCDeltaQ;
236  fh->delta_q_u_dc = post_encode_values->Quantization.UDCDeltaQ;
237  fh->delta_q_u_ac = post_encode_values->Quantization.UACDeltaQ;
238  fh->delta_q_v_dc = post_encode_values->Quantization.VDCDeltaQ;
239  fh->delta_q_v_ac = post_encode_values->Quantization.VACDeltaQ;
240  fh->using_qmatrix = post_encode_values->Quantization.UsingQMatrix;
241  fh->qm_y = post_encode_values->Quantization.QMY;
242  fh->qm_u = post_encode_values->Quantization.QMU;
243  fh->qm_v = post_encode_values->Quantization.QMV;
244  }
245 
246  if (priv->post_encode_values_flag & D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAG_LOOP_FILTER) {
247  fh->loop_filter_level[0] = post_encode_values->LoopFilter.LoopFilterLevel[0];
248  fh->loop_filter_level[1] = post_encode_values->LoopFilter.LoopFilterLevel[1];
249  fh->loop_filter_level[2] = post_encode_values->LoopFilter.LoopFilterLevelU;
250  fh->loop_filter_level[3] = post_encode_values->LoopFilter.LoopFilterLevelV;
251  fh->loop_filter_sharpness = post_encode_values->LoopFilter.LoopFilterSharpnessLevel;
252  fh->loop_filter_delta_enabled = post_encode_values->LoopFilter.LoopFilterDeltaEnabled;
253  if (fh->loop_filter_delta_enabled) {
254  for (int i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) {
255  fh->loop_filter_ref_deltas[i] = post_encode_values->LoopFilter.RefDeltas[i];
256  fh->update_ref_delta[i] = post_encode_values->LoopFilter.RefDeltas[i];
257  }
258  for (int i = 0; i < 2; i++) {
259  fh->loop_filter_mode_deltas[i] = post_encode_values->LoopFilter.ModeDeltas[i];
260  fh->update_mode_delta[i] = post_encode_values->LoopFilter.ModeDeltas[i];
261  }
262  }
263  }
264  if (priv->post_encode_values_flag & D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAG_CDEF_DATA) {
265  fh->cdef_damping_minus_3 = post_encode_values->CDEF.CdefDampingMinus3;
266  fh->cdef_bits = post_encode_values->CDEF.CdefBits;
267  for (int i = 0; i < 8; i++) {
268  fh->cdef_y_pri_strength[i] = post_encode_values->CDEF.CdefYPriStrength[i];
269  fh->cdef_y_sec_strength[i] = post_encode_values->CDEF.CdefYSecStrength[i];
270  fh->cdef_uv_pri_strength[i] = post_encode_values->CDEF.CdefUVPriStrength[i];
271  fh->cdef_uv_sec_strength[i] = post_encode_values->CDEF.CdefUVSecStrength[i];
272  }
273  }
274  if (priv->post_encode_values_flag & D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAG_QUANTIZATION_DELTA) {
275  fh->delta_q_present = post_encode_values->QuantizationDelta.DeltaQPresent;
276  fh->delta_q_res = post_encode_values->QuantizationDelta.DeltaQRes;
277  }
278 
279  if (priv->post_encode_values_flag & D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAG_REFERENCE_INDICES) {
280  for (int i = 0; i < AV1_REFS_PER_FRAME; i++) {
281  fh->ref_frame_idx[i] = post_encode_values->ReferenceIndices[i];
282  }
283  }
284 
285  ID3D12Resource_Unmap(pic->resolved_metadata, 0, NULL);
286  return 0;
287 }
288 
291  char *data, size_t *data_len)
292 {
293  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
294  CodedBitstreamFragment *obu = &priv->current_obu;
295  AV1RawOBU *frameheader_obu = av_mallocz(sizeof(AV1RawOBU));
296  int err = 0;
297 
298  av_fifo_read(priv->picture_header_list, frameheader_obu, 1);
299  err = d3d12va_encode_av1_update_current_frame_picture_header(avctx, pic,frameheader_obu);
300  if (err < 0) {
301  av_log(avctx, AV_LOG_ERROR, "Failed to update current frame picture header: %d.\n", err);
302  return err;
303  }
304 
305  // Add the frame header OBU
306  frameheader_obu->header.obu_has_size_field = 1;
307 
308  err = d3d12va_encode_av1_add_obu(avctx, obu, AV1_OBU_FRAME_HEADER, frameheader_obu);
309  if (err < 0)
310  goto fail;
311  err = d3d12va_encode_av1_write_obu(avctx, data, data_len, obu);
312 
313 fail:
314  ff_cbs_fragment_reset(obu);
315  av_freep(&frameheader_obu);
316  return err;
317 }
318 
320  uint8_t* tile_group,
321  uint32_t tile_group_size,
322  char *data, size_t *data_len)
323 {
324  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
325  CodedBitstreamFragment *obu = &priv->current_obu;
327  AV1RawTileGroup *tg = &tile_group_obu->obu.tile_group;
328  int err = 0;
329 
330  tg->tile_data.data = tile_group;
331  tg->tile_data.data_ref = NULL;
332  tg->tile_data.data_size = tile_group_size;
333  tile_group_obu->header.obu_has_size_field = 1;
334  tile_group_obu->header.obu_type = AV1_OBU_TILE_GROUP;
335 
337  if (err < 0)
338  goto fail;
339  err = d3d12va_encode_av1_write_obu(avctx, data, data_len, obu);
340 
341 fail:
342  ff_cbs_fragment_reset(obu);
343  return err;
344 }
345 
347  D3D12VAEncodePicture *pic, size_t *size)
348 {
350  D3D12_VIDEO_ENCODER_OUTPUT_METADATA *meta = NULL;
351  D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA *subregion_meta = NULL;
352  uint8_t *data = NULL;
353  HRESULT hr = S_OK;
354  int err = 0;
355 
356  hr = ID3D12Resource_Map(pic->resolved_metadata, 0, NULL, (void **)&data);
357  if (FAILED(hr)) {
358  err = AVERROR_UNKNOWN;
359  return err;
360  }
361 
362  subregion_meta = (D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA*)(data + sizeof(D3D12_VIDEO_ENCODER_OUTPUT_METADATA));
363  if (subregion_meta->bSize == 0) {
364  av_log(avctx, AV_LOG_ERROR, "No subregion metadata found\n");
365  err = AVERROR(EINVAL);
366  return err;
367  }
368  *size = subregion_meta->bSize;
369 
370  ID3D12Resource_Unmap(pic->resolved_metadata, 0, NULL);
371 
372  return 0;
373 }
374 
377 {
378  int err = 0;
379  uint8_t *ptr = NULL;
380  uint8_t *mapped_data = NULL;
381  size_t total_size = 0;
382  HRESULT hr = S_OK;
383  size_t av1_pic_hd_size = 0;
384  int tile_group_extra_size = 0;
385  size_t bit_len = 0;
387 
388  char pic_hd_data[MAX_PARAM_BUFFER_SIZE] = { 0 };
389 
390  err = d3d12va_encode_av1_get_buffer_size(avctx, pic, &total_size);
391  if (err < 0)
392  goto end;
393 
394  // Update the picture header and calculate the picture header size
395  memset(pic_hd_data, 0, sizeof(pic_hd_data));
396  err = d3d12va_encode_av1_write_picture_header(avctx, pic, pic_hd_data, &av1_pic_hd_size);
397  if (err < 0) {
398  av_log(avctx, AV_LOG_ERROR, "Failed to write picture header: %d.\n", err);
399  return err;
400  }
401  av1_pic_hd_size /= 8;
402  av_log(avctx, AV_LOG_DEBUG, "AV1 picture header size: %zu bytes.\n", av1_pic_hd_size);
403 
404 
405  tile_group_extra_size = (av_log2(total_size) + 7) / 7 + 1; // 1 byte for obu header, rest for tile group LEB128 size
406  av_log(avctx, AV_LOG_DEBUG, "Tile group extra size: %d bytes.\n", tile_group_extra_size);
407 
408  total_size += (pic->header_size + tile_group_extra_size + av1_pic_hd_size);
409  av_log(avctx, AV_LOG_DEBUG, "Output buffer size %"SIZE_SPECIFIER"\n", total_size);
410 
411  hr = ID3D12Resource_Map(pic->output_buffer, 0, NULL, (void **)&mapped_data);
412  if (FAILED(hr)) {
413  err = AVERROR_UNKNOWN;
414  goto end;
415  }
416 
417  err = ff_get_encode_buffer(avctx, pkt, total_size, 0);
418  if (err < 0)
419  goto end;
420  ptr = pkt->data;
421 
422  memcpy(ptr, mapped_data, pic->header_size);
423 
424  ptr += pic->header_size;
425  mapped_data += pic->aligned_header_size;
426  total_size -= pic->header_size;
427 
428  memcpy(ptr, pic_hd_data, av1_pic_hd_size);
429  ptr += av1_pic_hd_size;
430  total_size -= av1_pic_hd_size;
431  av_log(avctx, AV_LOG_DEBUG, "AV1 total_size after write picture header: %d.\n", total_size);
432 
433  total_size -= tile_group_extra_size;
434  err = d3d12va_encode_av1_write_tile_group(avctx, mapped_data, total_size, ptr, &bit_len);
435  if (err < 0) {
436  av_log(avctx, AV_LOG_ERROR, "Failed to write tile group: %d.\n", err);
437  goto end;
438  }
439  assert((total_size + tile_group_extra_size) * 8 == bit_len);
440 
441  ID3D12Resource_Unmap(pic->output_buffer, 0, NULL);
442 
443 end:
445  pic->output_buffer = NULL;
446  return err;
447 }
448 
450  AVCodecContext *avctx,
451  D3D12VAHWBaseEncodeAV1 *common,
453 {
454  AV1RawOBU *seqheader_obu = &common->raw_sequence_header;
455  AV1RawSequenceHeader *seq = &seqheader_obu->obu.sequence_header;
456  const AVPixFmtDescriptor *desc;
457 
458  seq->seq_profile = avctx->profile;
461  seq->seq_tier[0] = opts->tier;
462 
465  .high_bitdepth = desc->comp[0].depth == 8 ? 0 : 1,
466  .color_primaries = avctx->color_primaries,
467  .transfer_characteristics = avctx->color_trc,
468  .matrix_coefficients = avctx->colorspace,
469  .color_description_present_flag = (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
470  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
473  .subsampling_x = desc->log2_chroma_w,
474  .subsampling_y = desc->log2_chroma_h,
475  };
476 
477  switch (avctx->chroma_sample_location) {
478  case AVCHROMA_LOC_LEFT:
480  break;
483  break;
484  default:
486  break;
487  }
488 
489  if (avctx->level != AV_LEVEL_UNKNOWN) {
490  seq->seq_level_idx[0] = avctx->level;
491  }
492  else {
493  const AV1LevelDescriptor *level;
494  float framerate;
495 
496  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
497  framerate = avctx->framerate.num / avctx->framerate.den;
498  else
499  framerate = 0;
500 
501  //currently only supporting 1 tile
502  level = ff_av1_guess_level(avctx->bit_rate, opts->tier,
503  base_ctx->surface_width, base_ctx->surface_height,
504  /*priv->tile_rows*/1 * 1/*priv->tile_cols*/,
505  /*priv->tile_cols*/1, framerate);
506  if (level) {
507  av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
508  seq->seq_level_idx[0] = level->level_idx;
509  }
510  else {
511  av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
512  "any normal level, using maximum parameters level by default.\n");
513  seq->seq_level_idx[0] = 31;
514  seq->seq_tier[0] = 1;
515  }
516  }
517 
518  // Still picture mode
519  seq->still_picture = (base_ctx->gop_size == 1);
521 
522  // Feature flags
523  seq->enable_filter_intra = opts->enable_filter_intra;
524  seq->enable_intra_edge_filter = opts->enable_intra_edge_filter;
525  seq->enable_interintra_compound = opts->enable_interintra_compound;
526  seq->enable_masked_compound = opts->enable_masked_compound;
527  seq->enable_warped_motion = opts->enable_warped_motion;
528  seq->enable_dual_filter = opts->enable_dual_filter;
529  seq->enable_order_hint = !seq->still_picture;
530  if (seq->enable_order_hint) {
531  seq->order_hint_bits_minus_1 = 7;
532  }
533  seq->enable_jnt_comp = opts->enable_jnt_comp && seq->enable_order_hint;
534  seq->enable_ref_frame_mvs = opts->enable_ref_frame_mvs && seq->enable_order_hint;
535  seq->enable_superres = opts->enable_superres;
536  seq->enable_cdef = opts->enable_cdef;
537  seq->enable_restoration = opts->enable_restoration;
538 
539  return 0;
540 
541 }
542 
544 {
545  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
547  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
548  AVD3D12VAFramesContext *hwctx = base_ctx->input_frames->hwctx;
549  AV1RawOBU *seqheader_obu = &priv->units.raw_sequence_header;
551 
552  D3D12_VIDEO_ENCODER_AV1_PROFILE profile = D3D12_VIDEO_ENCODER_AV1_PROFILE_MAIN;
553  D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS level = { 0 };
554  HRESULT hr;
555  int err;
556 
557  D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT1 support = {
558  .NodeIndex = 0,
559  .Codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
560  .InputFormat = hwctx->format,
561  .RateControl = ctx->rc,
562  .IntraRefresh = D3D12_VIDEO_ENCODER_INTRA_REFRESH_MODE_NONE,
563  .SubregionFrameEncoding = D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME,
564  .ResolutionsListCount = 1,
565  .pResolutionList = &ctx->resolution,
566  .CodecGopSequence = ctx->gop,
567  .MaxReferenceFramesInDPB = AV1_NUM_REF_FRAMES,
568  .CodecConfiguration = ctx->codec_conf,
569  .SuggestedProfile.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PROFILE),
570  .SuggestedProfile.pAV1Profile = &profile,
571  .SuggestedLevel.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS),
572  .SuggestedLevel.pAV1LevelSetting = &level,
573  .pResolutionDependentSupport = &ctx->res_limits,
574  .SubregionFrameEncodingData.pTilesPartition_AV1 = ctx->subregions_layout.pTilesPartition_AV1,
575  };
576 
577  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_SUPPORT1,
578  &support, sizeof(support));
579 
580  if (FAILED(hr)) {
581  av_log(avctx, AV_LOG_ERROR, "Failed to check encoder support(%lx).\n", (long)hr);
582  return AVERROR(EINVAL);
583  }
584 
585  if (!(support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_GENERAL_SUPPORT_OK)) {
586  av_log(avctx, AV_LOG_ERROR, "Driver does not support some request D3D12VA AV1 features. %#x\n",
587  support.ValidationFlags);
588  return AVERROR(EINVAL);
589  }
590 
591  if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RECONSTRUCTED_FRAMES_REQUIRE_TEXTURE_ARRAYS) {
592  ctx->is_texture_array = 1;
593  av_log(avctx, AV_LOG_DEBUG, "D3D12 video encode on this device uses texture array mode.\n");
594  }
595 
596  memset(seqheader_obu, 0, sizeof(*seqheader_obu));
597  seq->seq_profile = profile;
598  seq->seq_level_idx[0] = level.Level;
599  seq->seq_tier[0] = level.Tier;
600 
601  seq->max_frame_width_minus_1 = ctx->resolution.Width - 1;
602  seq->max_frame_height_minus_1 = ctx->resolution.Height - 1;
603  seq->frame_width_bits_minus_1 = av_log2(ctx->resolution.Width);
604  seq->frame_height_bits_minus_1 = av_log2(ctx->resolution.Height);
605 
606  seqheader_obu->header.obu_type = AV1_OBU_SEQUENCE_HEADER;
607 
608  err = d3d12va_hw_base_encode_init_params_av1(base_ctx, avctx,
609  &priv->units, &priv->unit_opts);
610  if (err < 0)
611  return err;
612 
613  if (avctx->level == AV_LEVEL_UNKNOWN)
614  avctx->level = level.Level;
615 
616  return 0;
617 }
618 
620 {
621  HRESULT hr = S_OK;
622  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
624  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
625 
626  D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION *config;
627  D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT av1_caps;
628 
629  D3D12_FEATURE_DATA_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT codec_caps = {
630  .NodeIndex = 0,
631  .Codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
632  .Profile = ctx->profile->d3d12_profile,
633  .CodecSupportLimits.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT),
634  };
635 
636  codec_caps.CodecSupportLimits.pAV1Support = &av1_caps;
637 
638  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT,
639  &codec_caps, sizeof(codec_caps));
640  if (!(SUCCEEDED(hr) && codec_caps.IsSupported))
641  return AVERROR(EINVAL);
642 
643  ctx->codec_conf.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION);
644  ctx->codec_conf.pAV1Config = av_mallocz(ctx->codec_conf.DataSize);
645  if (!ctx->codec_conf.pAV1Config)
646  return AVERROR(ENOMEM);
647 
648  priv->post_encode_values_flag = av1_caps.PostEncodeValuesFlags;
649  config = ctx->codec_conf.pAV1Config;
650 
651  config->FeatureFlags = D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_NONE;
652  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK) {
653  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK;
655  }
656 
657  base_ctx->surface_width = FFALIGN(avctx->width, priv->unit_opts.enable_128x128_superblock ? 128 : 64);
658  base_ctx->surface_height = FFALIGN(avctx->height, priv->unit_opts.enable_128x128_superblock ? 128 : 64);
659 
660  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_RESTORATION_FILTER) {
661  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_RESTORATION_FILTER;
662  priv->unit_opts.enable_loop_filter = 1;
663  }
664 
665  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_PALETTE_ENCODING) {
666  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_PALETTE_ENCODING;
667  priv->unit_opts.enable_palette = 1;
668  }
669 
670  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTRA_BLOCK_COPY) {
671  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTRA_BLOCK_COPY;
673  }
674 
675  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_FILTER_DELTAS) {
676  // Loop filter deltas
677  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_FILTER_DELTAS;
679  }
680 
681  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_CDEF_FILTERING) {
682  // CDEF (Constrained Directional Enhancement Filter)
683  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_CDEF_FILTERING;
684  priv->unit_opts.enable_cdef = 1;
685  }
686 
687  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_DUAL_FILTER) {
688  // Dual filter
689  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_DUAL_FILTER;
690  priv->unit_opts.enable_dual_filter = 1;
691  }
692 
693  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_JNT_COMP) {
694  // Joint compound prediction
695  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_JNT_COMP;
696  priv->unit_opts.enable_jnt_comp = 1;
697  }
698 
699  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_FRAME_REFERENCE_MOTION_VECTORS) {
700  // Frame reference motion vectors
701  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_FRAME_REFERENCE_MOTION_VECTORS;
703  }
704 
705  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_SUPER_RESOLUTION) {
706  // Super-resolution
707  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_SUPER_RESOLUTION;
708  priv->unit_opts.enable_superres = 1;
709  }
710 
711  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_WARPED_MOTION) {
712  // Warped motion
713  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_WARPED_MOTION;
715  }
716 
717  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTERINTRA_COMPOUND) {
718  // Inter-intra compound prediction
719  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTERINTRA_COMPOUND;
721  }
722 
723  return 0;
724 }
725 
727 {
728  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
730  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
731  int err = 0;
732  int fixed_qp_key, fixed_qp_inter;
733 
734  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_AV1, avctx);
735  if (err < 0)
736  return err;
737 
738  if (ctx->rc.Mode == D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CQP) {
739  D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP *cqp_ctl;
740  fixed_qp_inter = av_clip_uintp2(ctx->rc_quality, 8);
741 
742  if (avctx->i_quant_factor > 0.0)
743  fixed_qp_key = av_clip_uintp2((avctx->i_quant_factor * fixed_qp_inter +
744  avctx->i_quant_offset) + 0.5, 8);
745  else
746  fixed_qp_key = fixed_qp_inter;
747 
748  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
749  "%d / %d for Key / Inter frames.\n",
750  fixed_qp_key, fixed_qp_inter);
751 
752  ctx->rc.ConfigParams.DataSize = sizeof(D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP);
753  cqp_ctl = av_mallocz(ctx->rc.ConfigParams.DataSize);
754  if (!cqp_ctl)
755  return AVERROR(ENOMEM);
756 
757  cqp_ctl->ConstantQP_FullIntracodedFrame = fixed_qp_key;
758  cqp_ctl->ConstantQP_InterPredictedFrame_PrevRefOnly = fixed_qp_inter;
759  cqp_ctl->ConstantQP_InterPredictedFrame_BiDirectionalRef = fixed_qp_inter;
760 
761  ctx->rc.ConfigParams.pConfiguration_CQP = cqp_ctl;
762 
763  priv->q_idx_idr = fixed_qp_key;
764  priv->q_idx_p = fixed_qp_inter;
765 
766  }
767 
768  // GOP configuration for AV1
769  ctx->gop.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_SEQUENCE_STRUCTURE);
770  ctx->gop.pAV1SequenceStructure = av_mallocz(ctx->gop.DataSize);
771  if (!ctx->gop.pAV1SequenceStructure)
772  return AVERROR(ENOMEM);
773 
774  ctx->gop.pAV1SequenceStructure->IntraDistance = base_ctx->gop_size;
775  ctx->gop.pAV1SequenceStructure->InterFramePeriod = base_ctx->b_per_p + 1;
776 
777  return 0;
778 }
779 
781 {
783  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
784  int i = 0;
785 
786  ctx->level.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS);
787  ctx->level.pAV1LevelSetting = av_mallocz(ctx->level.DataSize);
788  if (!ctx->level.pAV1LevelSetting)
789  return AVERROR(ENOMEM);
790 
791  if (avctx->level != AV_LEVEL_UNKNOWN) {
792  for (i = 0; i < FF_ARRAY_ELEMS(av1_levels); i++) {
793  if (avctx->level == av1_levels[i].level) {
794  ctx->level.pAV1LevelSetting->Level = av1_levels[i].d3d12_level;
795  break;
796  }
797  }
798 
799  if (i == FF_ARRAY_ELEMS(av1_levels) ) {
800  av_log(avctx, AV_LOG_ERROR, "Invalid AV1 level %d.\n", avctx->level);
801  return AVERROR(EINVAL);
802  }
803  } else {
804  ctx->level.pAV1LevelSetting->Level = D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2;
805  avctx->level = D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2;
806  av_log(avctx, AV_LOG_DEBUG, "Using default AV1 level 5.2\n");
807  }
808 
809  if (priv->tier == 1 || avctx->bit_rate > 30000000) {
810  ctx->level.pAV1LevelSetting->Tier = D3D12_VIDEO_ENCODER_AV1_TIER_HIGH;
811  av_log(avctx, AV_LOG_DEBUG, "Using AV1 High tier\n");
812  } else {
813  ctx->level.pAV1LevelSetting->Tier = D3D12_VIDEO_ENCODER_AV1_TIER_MAIN;
814  av_log(avctx, AV_LOG_DEBUG, "Using AV1 Main tier\n");
815  }
816 
817  if (priv->tier >= 0) {
818  ctx->level.pAV1LevelSetting->Tier = priv->tier == 0 ?
819  D3D12_VIDEO_ENCODER_AV1_TIER_MAIN :
820  D3D12_VIDEO_ENCODER_AV1_TIER_HIGH;
821  }
822 
823  av_log(avctx, AV_LOG_DEBUG, "AV1 level set to %d, tier: %s\n",
824  ctx->level.pAV1LevelSetting->Level,
825  ctx->level.pAV1LevelSetting->Tier == D3D12_VIDEO_ENCODER_AV1_TIER_MAIN ? "Main" : "High");
826 
827  return 0;
828 }
829 
831 {
833 
834  ctx->subregions_layout.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES);
835  D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES *tiles_layout = av_mallocz(ctx->subregions_layout.DataSize);
836  ctx->subregions_layout.pTilesPartition_AV1 = tiles_layout;
837 
838  // Currently only support 1 tile
839  tiles_layout->RowCount = 1;
840  tiles_layout->ColCount = 1;
841 
842  return 0;
843 }
844 
846 {
847  if (!pic->pic_ctl.pAV1PicData)
848  return;
849 
850  av_freep(&pic->pic_ctl.pAV1PicData);
851 }
852 
855 {
856  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
857  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
859  D3D12VAEncodePicture *d3d12va_pic = pic->priv;
860  D3D12VAEncodeAV1Picture *hpic = pic->codec_priv;
861  CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data;
862  AV1RawOBU *frameheader_obu = &priv->units.raw_frame_header;
863  AV1RawFrameHeader *fh = &frameheader_obu->obu.frame_header;
864 
867  int i;
868 
869  static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] =
870  { 1, 0, 0, 0, -1, 0, -1, -1 };
871 
872  memset(frameheader_obu, 0, sizeof(*frameheader_obu));
873 
874  frameheader_obu->header.obu_type = AV1_OBU_FRAME_HEADER;
875 
876  d3d12va_pic->pic_ctl.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_CODEC_DATA);
877  d3d12va_pic->pic_ctl.pAV1PicData = av_mallocz(d3d12va_pic->pic_ctl.DataSize);
878  if (!d3d12va_pic->pic_ctl.pAV1PicData)
879  return AVERROR(ENOMEM);
880 
881  // Initialize frame type and reference frame management
882  switch(pic->type) {
885  fh->refresh_frame_flags = 0xFF;
886  fh->base_q_idx = priv->q_idx_idr;
887  hpic->slot = 0;
888  hpic->last_idr_frame = pic->display_order;
890  break;
891 
894  fh->base_q_idx = priv->q_idx_p;
896 
897  ref = pic->refs[0][pic->nb_refs[0] - 1];
898  href = ref->codec_priv;
899 
900  /**
901  * The encoder uses a simple alternating reference frame strategy:
902  * - For P-frames, it uses the last reconstructed frame as a reference.
903  * - To simplify the reference model of the encoder, the encoder alternates between
904  * two reference frame slots (typically slot 0 and slot 1) for storing reconstructed
905  * images and providing prediction references for the next frame.
906  */
907  if (base_ctx->ref_l0 > 1) {
908  hpic->slot = !href->slot;
909  } else {
910  hpic->slot = 0;
911  }
912  hpic->last_idr_frame = href->last_idr_frame;
913  fh->refresh_frame_flags = 1 << hpic->slot;
914 
915  // Set the nearest frame in L0 as all reference frame.
916  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
917  fh->ref_frame_idx[i] = href->slot;
918 
919  fh->primary_ref_frame = href->slot;
920  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
921 
922  // Set the 2nd nearest frame in L0 as Golden frame.
923  if (pic->nb_refs[0] > 1) {
924  ref = pic->refs[0][pic->nb_refs[0] - 2];
925  href = ref->codec_priv;
926  // Reference frame index 3 is the GOLDEN_FRAME
927  fh->ref_frame_idx[3] = href->slot;
928  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
929  } else if (base_ctx->ref_l0 == 1) {
930  fh->ref_order_hint[!href->slot] = cbctx->ref[!href->slot].order_hint;
931  }
932  break;
933 
935  av_log(avctx, AV_LOG_ERROR, "D3D12 AV1 video encode on this device requires B-frame support, "
936  "but it's not implemented.\n");
937  return AVERROR_PATCHWELCOME;
938  default:
939  av_log(avctx, AV_LOG_ERROR, "Unsupported picture type %d.\n", pic->type);
940  }
941 
942 
943  cbctx->seen_frame_header = 0;
944 
945  fh->show_frame = pic->display_order <= pic->encode_order;
947  fh->order_hint = pic->display_order - hpic->last_idr_frame;
948  fh->frame_width_minus_1 = ctx->resolution.Width - 1;
949  fh->frame_height_minus_1 = ctx->resolution.Height - 1;
952  fh->is_filter_switchable = 1;
955  fh->width_in_sbs_minus_1[0] = (ctx->resolution.Width + 63 >> 6) -1; // 64x64 superblock size
956  fh->height_in_sbs_minus_1[0] = (ctx->resolution.Height + 63 >> 6) -1; // 64x64 superblock size
957 
958  memcpy(fh->loop_filter_ref_deltas, default_loop_filter_ref_deltas,
959  AV1_TOTAL_REFS_PER_FRAME * sizeof(int8_t));
960 
961  if (fh->frame_type == AV1_FRAME_KEY && fh->show_frame)
962  fh->error_resilient_mode = 1;
963 
966 
967  d3d12va_pic->pic_ctl.pAV1PicData->FrameType = fh->frame_type;
968  d3d12va_pic->pic_ctl.pAV1PicData->TxMode = fh->tx_mode;
969  d3d12va_pic->pic_ctl.pAV1PicData->RefreshFrameFlags = fh->refresh_frame_flags;
970  d3d12va_pic->pic_ctl.pAV1PicData->TemporalLayerIndexPlus1 = hpic->temporal_id + 1;
971  d3d12va_pic->pic_ctl.pAV1PicData->SpatialLayerIndexPlus1 = hpic->spatial_id + 1;
972  d3d12va_pic->pic_ctl.pAV1PicData->PictureIndex = pic->display_order;
973  d3d12va_pic->pic_ctl.pAV1PicData->InterpolationFilter = D3D12_VIDEO_ENCODER_AV1_INTERPOLATION_FILTERS_SWITCHABLE;
974  d3d12va_pic->pic_ctl.pAV1PicData->PrimaryRefFrame = fh->primary_ref_frame;
975  if (fh->error_resilient_mode)
976  d3d12va_pic->pic_ctl.pAV1PicData->Flags |= D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_FLAG_ENABLE_ERROR_RESILIENT_MODE;
977 
978  if (pic->type == FF_HW_PICTURE_TYPE_IDR)
979  {
980  for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
981  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceFramesReconPictureDescriptors[i].ReconstructedPictureResourceIndex =
983  }
984  } else if (pic->type == FF_HW_PICTURE_TYPE_P) {
985  for (i = 0; i < pic->nb_refs[0]; i++) {
986  FFHWBaseEncodePicture *ref_pic = pic->refs[0][i];
987  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceFramesReconPictureDescriptors[i].ReconstructedPictureResourceIndex =
988  ((D3D12VAEncodeAV1Picture*)ref_pic->codec_priv)->slot;
989  }
990  }
991  // Set reference frame management
992  memset(d3d12va_pic->pic_ctl.pAV1PicData->ReferenceIndices, 0, sizeof(UINT) * AV1_REFS_PER_FRAME);
993  if (pic->type == FF_HW_PICTURE_TYPE_P) {
994  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
995  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceIndices[i] = fh->ref_frame_idx[i];
996  }
997 
999 
1000  return 0;
1001 }
1002 
1003 
1006 
1007  .d3d12_codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
1008 
1009  .flags = FF_HW_FLAG_B_PICTURES |
1012 
1013  .default_quality = 25,
1014 
1015  .get_encoder_caps = &d3d12va_encode_av1_get_encoder_caps,
1016 
1017  .configure = &d3d12va_encode_av1_configure,
1018 
1019  .set_level = &d3d12va_encode_av1_set_level,
1020 
1021  .set_tile = &d3d12va_encode_av1_set_tile,
1022 
1023  .picture_priv_data_size = sizeof(D3D12VAEncodeAV1Picture),
1024 
1025  .init_sequence_params = &d3d12va_encode_av1_init_sequence_params,
1026 
1027  .init_picture_params = &d3d12va_encode_av1_init_picture_params,
1028 
1029  .free_picture_params = &d3d12va_encode_av1_free_picture_params,
1030 
1032 
1033 #ifdef CONFIG_AV1_D3D12VA_ENCODER
1034  .get_coded_data = &d3d12va_encode_av1_get_coded_data,
1035 #endif
1036 };
1037 
1039 {
1041  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
1042 
1043  ctx->codec = &d3d12va_encode_type_av1;
1044 
1045  if (avctx->profile == AV_PROFILE_UNKNOWN)
1046  avctx->profile = priv->profile;
1047  if (avctx->level == AV_LEVEL_UNKNOWN)
1048  avctx->level = priv->level;
1049 
1050  if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1051  av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1052  "in 8-bit unsigned integer.\n", avctx->level);
1053  return AVERROR(EINVAL);
1054  }
1055 
1056  if (priv->qp > 0)
1057  ctx->explicit_qp = priv->qp;
1058 
1060 
1061  return ff_d3d12va_encode_init(avctx);
1062 }
1063 
1065 {
1066  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
1067 
1068  ff_cbs_fragment_free(&priv->current_obu);
1069  ff_cbs_close(&priv->cbc);
1070 
1071  av_freep(&priv->common.codec_conf.pAV1Config);
1072  av_freep(&priv->common.gop.pAV1SequenceStructure);
1073  av_freep(&priv->common.level.pAV1LevelSetting);
1074  av_freep(&priv->common.subregions_layout.pTilesPartition_AV1);
1075 
1077 
1078  return ff_d3d12va_encode_close(avctx);
1079 }
1080 
1081 #define OFFSET(x) offsetof(D3D12VAEncodeAV1Context, x)
1082 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1086 
1087  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
1088  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
1089 
1090  { "profile", "Set profile (general_profile_idc)",
1092  { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xff, FLAGS, "profile" },
1093 
1094 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1095  { .i64 = value }, 0, 0, FLAGS, "profile"
1096  { PROFILE("main", AV_PROFILE_AV1_MAIN) },
1097  { PROFILE("high", AV_PROFILE_AV1_HIGH) },
1098  { PROFILE("professional", AV_PROFILE_AV1_PROFESSIONAL) },
1099 #undef PROFILE
1100 
1101  { "tier", "Set tier (general_tier_flag)",
1102  OFFSET(unit_opts.tier), AV_OPT_TYPE_INT,
1103  { .i64 = 0 }, 0, 1, FLAGS, "tier" },
1104  { "main", NULL, 0, AV_OPT_TYPE_CONST,
1105  { .i64 = 0 }, 0, 0, FLAGS, "tier" },
1106  { "high", NULL, 0, AV_OPT_TYPE_CONST,
1107  { .i64 = 1 }, 0, 0, FLAGS, "tier" },
1108 
1109  { "level", "Set level (general_level_idc)",
1111  { .i64 = AV_LEVEL_UNKNOWN }, AV_LEVEL_UNKNOWN, 0xff, FLAGS, "level" },
1112 
1113 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1114  { .i64 = value }, 0, 0, FLAGS, "level"
1115  { LEVEL("2.0", 0) },
1116  { LEVEL("2.1", 1) },
1117  { LEVEL("2.2", 2) },
1118  { LEVEL("2.3", 3) },
1119  { LEVEL("3.0", 4) },
1120  { LEVEL("3.1", 5) },
1121  { LEVEL("3.2", 6) },
1122  { LEVEL("3.3", 7) },
1123  { LEVEL("4.0", 8) },
1124  { LEVEL("4.1", 9) },
1125  { LEVEL("4.2", 10) },
1126  { LEVEL("4.3", 11) },
1127  { LEVEL("5.0", 12) },
1128  { LEVEL("5.1", 13) },
1129  { LEVEL("5.2", 14) },
1130  { LEVEL("5.3", 15) },
1131  { LEVEL("6.0", 16) },
1132  { LEVEL("6.1", 17) },
1133  { LEVEL("6.2", 18) },
1134  { LEVEL("6.3", 19) },
1135  { LEVEL("7.0", 20) },
1136  { LEVEL("7.1", 21) },
1137  { LEVEL("7.2", 22) },
1138  { LEVEL("7.3", 23) },
1139 #undef LEVEL
1140  { NULL },
1141 };
1142 
1144  { "b", "0" },
1145  { "bf", "0" },
1146  { "g", "120" },
1147  { "i_qfactor", "1" },
1148  { "i_qoffset", "0" },
1149  { "b_qfactor", "1" },
1150  { "b_qoffset", "0" },
1151  { "qmin", "-1" },
1152  { "qmax", "-1" },
1153  { "refs", "0" },
1154  { NULL },
1155 };
1156 
1158  .class_name = "av1_d3d12va",
1159  .item_name = av_default_item_name,
1160  .option = d3d12va_encode_av1_options,
1161  .version = LIBAVUTIL_VERSION_INT,
1162 };
1163 
1165  .p.name = "av1_d3d12va",
1166  CODEC_LONG_NAME("D3D12VA av1 encoder"),
1167  .p.type = AVMEDIA_TYPE_VIDEO,
1168  .p.id = AV_CODEC_ID_AV1,
1169  .priv_data_size = sizeof(D3D12VAEncodeAV1Context),
1172  .close = &d3d12va_encode_av1_close,
1173  .p.priv_class = &d3d12va_encode_av1_class,
1174  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE |
1176  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1178  .defaults = d3d12va_encode_av1_defaults,
1180  .hw_configs = ff_d3d12va_encode_hw_configs,
1181  .p.wrapper_name = "d3d12va",
1182 };
D3D12VAHWBaseEncodeAV1Opts::enable_masked_compound
int enable_masked_compound
Definition: d3d12va_encode_av1.c:67
D3D12VAHWBaseEncodeAV1Opts::enable_intra_block_copy
int enable_intra_block_copy
Definition: d3d12va_encode_av1.c:75
cbs.h
d3d12va_encode_av1_profiles
static const D3D12VAEncodeProfile d3d12va_encode_av1_profiles[]
Definition: d3d12va_encode_av1.c:147
CODEC_PIXFMTS
#define CODEC_PIXFMTS(...)
Definition: codec_internal.h:392
AV1RawSequenceHeader::seq_force_integer_mv
uint8_t seq_force_integer_mv
Definition: cbs_av1.h:129
profile_high
static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_high
Definition: d3d12va_encode_av1.c:142
profile_professional
static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_professional
Definition: d3d12va_encode_av1.c:143
level
uint8_t level
Definition: svq3.c:208
AV1RawFrameHeader::primary_ref_frame
uint8_t primary_ref_frame
Definition: cbs_av1.h:196
d3d12va_hw_base_encode_init_params_av1
static int d3d12va_hw_base_encode_init_params_av1(FFHWBaseEncodeContext *base_ctx, AVCodecContext *avctx, D3D12VAHWBaseEncodeAV1 *common, D3D12VAHWBaseEncodeAV1Opts *opts)
Definition: d3d12va_encode_av1.c:449
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
AV1RawSequenceHeader::seq_level_idx
uint8_t seq_level_idx[AV1_MAX_OPERATING_POINTS]
Definition: cbs_av1.h:96
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
D3D12VAHWBaseEncodeAV1::raw_frame_header
AV1RawOBU raw_frame_header
Definition: d3d12va_encode_av1.c:48
D3D12VAEncodeAV1Picture::last_idr_frame
uint16_t last_idr_frame
Definition: d3d12va_encode_av1.c:83
CodedBitstreamAV1Context::seen_frame_header
int seen_frame_header
Definition: cbs_av1.h:464
CodedBitstreamContext::priv_data
void * priv_data
Internal codec-specific data.
Definition: cbs.h:247
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:659
profile_main
static const D3D12_VIDEO_ENCODER_AV1_PROFILE profile_main
Definition: d3d12va_encode_av1.c:141
AV1RawSequenceHeader
Definition: cbs_av1.h:82
AV1RawFrameHeader::show_frame
uint8_t show_frame
Definition: cbs_av1.h:181
D3D12VAEncodeAV1Picture::slot
uint8_t slot
Definition: d3d12va_encode_av1.c:84
AV1_PRIMARY_REF_NONE
@ AV1_PRIMARY_REF_NONE
Definition: av1.h:87
FFHWBaseEncodePicture::priv
void * priv
Definition: hw_base_encode.h:63
FFHWBaseEncodePicture::codec_priv
void * codec_priv
Definition: hw_base_encode.h:65
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3456
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:130
av_clip_uintp2
#define av_clip_uintp2
Definition: common.h:124
FF_HW_PICTURE_TYPE_P
@ FF_HW_PICTURE_TYPE_P
Definition: hw_base_encode.h:41
AV1RawFrameHeader::cdef_uv_pri_strength
uint8_t cdef_uv_pri_strength[8]
Definition: cbs_av1.h:277
ff_av1_guess_level
const AV1LevelDescriptor * ff_av1_guess_level(int64_t bitrate, int tier, int width, int height, int tiles, int tile_cols, float fps)
Guess the level of a stream from some parameters.
Definition: av1_levels.c:48
D3D12VAEncodeAV1Context::level
int level
Definition: d3d12va_encode_av1.c:92
pixdesc.h
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:652
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:777
AV1_TX_MODE_SELECT
@ AV1_TX_MODE_SELECT
Definition: av1.h:183
AVPacket::data
uint8_t * data
Definition: packet.h:588
AV1_INTERPOLATION_FILTER_SWITCHABLE
@ AV1_INTERPOLATION_FILTER_SWITCHABLE
Definition: av1.h:104
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:226
AVOption
AVOption.
Definition: opt.h:429
encode.h
d3d12va_encode.h
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:669
AV1RawFrameHeader::uniform_tile_spacing_flag
uint8_t uniform_tile_spacing_flag
Definition: cbs_av1.h:224
data
const char data[16]
Definition: mxf.c:149
high
int high
Definition: dovi_rpuenc.c:39
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:127
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
d3d12va_encode_av1_defaults
static const FFCodecDefault d3d12va_encode_av1_defaults[]
Definition: d3d12va_encode_av1.c:1143
d3d12va_encode_av1_update_current_frame_picture_header
static int d3d12va_encode_av1_update_current_frame_picture_header(AVCodecContext *avctx, D3D12VAEncodePicture *pic, AV1RawOBU *frameheader_obu)
Definition: d3d12va_encode_av1.c:211
AV_PROFILE_AV1_PROFESSIONAL
#define AV_PROFILE_AV1_PROFESSIONAL
Definition: defs.h:171
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
AV1RawTileData::data
uint8_t * data
Definition: cbs_av1.h:301
AV1RawOBU::header
AV1RawOBUHeader header
Definition: cbs_av1.h:414
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
AV1RawOBU::obu
union AV1RawOBU::@77 obu
tf_sess_config.config
config
Definition: tf_sess_config.py:33
AV1RawFrameHeader::loop_filter_level
uint8_t loop_filter_level[4]
Definition: cbs_av1.h:264
AV1ReferenceFrameState::order_hint
int order_hint
Definition: cbs_av1.h:447
AV1RawFrameHeader::cdef_y_sec_strength
uint8_t cdef_y_sec_strength[8]
Definition: cbs_av1.h:276
AV1RawSequenceHeader::seq_profile
uint8_t seq_profile
Definition: cbs_av1.h:83
AV1RawFrameHeader::cdef_damping_minus_3
uint8_t cdef_damping_minus_3
Definition: cbs_av1.h:273
AV1_CSP_COLOCATED
@ AV1_CSP_COLOCATED
Definition: av1.h:135
D3D12VAEncodeAV1Picture::temporal_id
uint8_t temporal_id
Definition: d3d12va_encode_av1.c:79
OFFSET
#define OFFSET(x)
Definition: d3d12va_encode_av1.c:1081
D3D12VAEncodePicture::resolved_metadata
ID3D12Resource * resolved_metadata
Definition: d3d12va_encode.h:53
D3D12VAHWBaseEncodeAV1Opts::enable_loop_filter
int enable_loop_filter
Definition: d3d12va_encode_av1.c:70
FFHWBaseEncodeContext
Definition: hw_base_encode.h:122
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:551
AV1RawColorConfig
Definition: cbs_av1.h:50
FF_HW_PICTURE_TYPE_B
@ FF_HW_PICTURE_TYPE_B
Definition: hw_base_encode.h:42
ff_d3d12va_encode_hw_configs
const AVCodecHWConfigInternal *const ff_d3d12va_encode_hw_configs[]
Definition: d3d12va_encode.c:37
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:794
AV1RawFrameHeader::loop_filter_ref_deltas
int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME]
Definition: cbs_av1.h:269
D3D12VAEncodePicture::output_buffer_ref
AVBufferRef * output_buffer_ref
Definition: d3d12va_encode.h:49
FFCodecDefault
Definition: codec_internal.h:96
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
D3D12VAHWBaseEncodeAV1Opts::enable_superres
int enable_superres
Definition: d3d12va_encode_av1.c:58
AV1RawFrameHeader::delta_q_u_dc
int8_t delta_q_u_dc
Definition: cbs_av1.h:242
D3D12VAEncodeContext::subregions_layout
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA subregions_layout
Definition: d3d12va_encode.h:268
FFHWBaseEncodePicture::type
int type
Definition: hw_base_encode.h:78
AV1RawSequenceHeader::enable_ref_frame_mvs
uint8_t enable_ref_frame_mvs
Definition: cbs_av1.h:124
fail
#define fail()
Definition: checkasm.h:208
AV1_OBU_FRAME_HEADER
@ AV1_OBU_FRAME_HEADER
Definition: av1.h:32
D3D12VAEncodeAV1Context
Definition: d3d12va_encode_av1.c:87
D3D12VAEncodeAV1Context::tier
int tier
Definition: d3d12va_encode_av1.c:93
av_fifo_write
int av_fifo_write(AVFifo *f, const void *buf, size_t nb_elems)
Write data into a FIFO.
Definition: fifo.c:188
AV1RawSequenceHeader::enable_filter_intra
uint8_t enable_filter_intra
Definition: cbs_av1.h:115
D3D12VAEncodePicture::output_buffer
ID3D12Resource * output_buffer
Definition: d3d12va_encode.h:50
CodedBitstreamAV1Context::ref
AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES]
Definition: cbs_av1.h:491
D3D12VA_ENCODE_RC_OPTIONS
#define D3D12VA_ENCODE_RC_OPTIONS
Definition: d3d12va_encode.h:359
D3D12VAHWBaseEncodeAV1Opts::enable_dual_filter
int enable_dual_filter
Definition: d3d12va_encode_av1.c:72
AVRational::num
int num
Numerator.
Definition: rational.h:59
D3D12VAEncodeAV1Context::common
D3D12VAEncodeContext common
Definition: d3d12va_encode_av1.c:88
AV1RawFrameHeader::tx_mode
uint8_t tx_mode
Definition: cbs_av1.h:284
d3d12va_encode_av1_init_sequence_params
static int d3d12va_encode_av1_init_sequence_params(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:543
AV1RawFrameHeader::base_q_idx
uint8_t base_q_idx
Definition: cbs_av1.h:239
cbs_av1.h
D3D12VAEncodeAV1Context::q_idx_idr
uint8_t q_idx_idr
Definition: d3d12va_encode_av1.c:95
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:645
pkt
AVPacket * pkt
Definition: movenc.c:60
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
AV1RawSequenceHeader::enable_masked_compound
uint8_t enable_masked_compound
Definition: cbs_av1.h:118
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
main
int main
Definition: dovi_rpuenc.c:38
FFHWBaseEncodeContext::ref_l0
int ref_l0
Definition: hw_base_encode.h:197
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
av_fifo_read
int av_fifo_read(AVFifo *f, void *buf, size_t nb_elems)
Read data from a FIFO.
Definition: fifo.c:240
AV1RawFrameHeader::cdef_uv_sec_strength
uint8_t cdef_uv_sec_strength[8]
Definition: cbs_av1.h:278
d3d12va_encode_av1_get_buffer_size
static int d3d12va_encode_av1_get_buffer_size(AVCodecContext *avctx, D3D12VAEncodePicture *pic, size_t *size)
Definition: d3d12va_encode_av1.c:346
AV1RawFrameHeader::qm_y
uint8_t qm_y
Definition: cbs_av1.h:247
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:129
D3D12VAHWBaseEncodeAV1Opts::enable_cdef
int enable_cdef
Definition: d3d12va_encode_av1.c:56
AV1RawFrameHeader::render_width_minus_1
uint16_t render_width_minus_1
Definition: cbs_av1.h:202
AV1RawFrameHeader::update_mode_delta
uint8_t update_mode_delta[2]
Definition: cbs_av1.h:270
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:142
D3D12VAEncodePicture::header_size
int header_size
Definition: d3d12va_encode.h:43
FLAGS
#define FLAGS
Definition: d3d12va_encode_av1.c:1082
d3d12va_encode_av1_options
static const AVOption d3d12va_encode_av1_options[]
Definition: d3d12va_encode_av1.c:1083
D3D12VAEncodeAV1Level
Definition: d3d12va_encode_av1.c:108
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:144
d3d12va_encode_av1_class
static const AVClass d3d12va_encode_av1_class
Definition: d3d12va_encode_av1.c:1157
D3D12VAHWBaseEncodeAV1Opts::enable_interintra_compound
int enable_interintra_compound
Definition: d3d12va_encode_av1.c:66
AV1_TOTAL_REFS_PER_FRAME
@ AV1_TOTAL_REFS_PER_FRAME
Definition: av1.h:86
d3d12va_encode_av1_configure
static int d3d12va_encode_av1_configure(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:726
CodedBitstreamUnitType
uint32_t CodedBitstreamUnitType
The codec-specific type of a bitstream unit.
Definition: cbs.h:54
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:231
AV1RawFrameHeader::frame_width_minus_1
uint16_t frame_width_minus_1
Definition: cbs_av1.h:197
ctx
AVFormatContext * ctx
Definition: movenc.c:49
hw_base_encode.h
D3D12VAEncodePicture::pic_ctl
D3D12_VIDEO_ENCODER_PICTURE_CONTROL_CODEC_DATA pic_ctl
Definition: d3d12va_encode.h:57
AV1RawSequenceHeader::seq_tier
uint8_t seq_tier[AV1_MAX_OPERATING_POINTS]
Definition: cbs_av1.h:97
CodedBitstreamFragment::data_bit_padding
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
Definition: cbs.h:146
AV1RawFrameHeader::loop_filter_mode_deltas
int8_t loop_filter_mode_deltas[2]
Definition: cbs_av1.h:271
color_range
color_range
Definition: vf_selectivecolor.c:43
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:639
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:332
FFHWBaseEncodeContext::b_per_p
int b_per_p
Definition: hw_base_encode.h:189
if
if(ret)
Definition: filter_design.txt:179
AV1_FRAME_INTER
@ AV1_FRAME_INTER
Definition: av1.h:54
D3D12VAHWBaseEncodeAV1Opts
Definition: d3d12va_encode_av1.c:52
D3D12VAHWBaseEncodeAV1
Definition: d3d12va_encode_av1.c:46
opts
AVDictionary * opts
Definition: movenc.c:51
framerate
float framerate
Definition: av1_levels.c:29
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AV1RawOBU
Definition: cbs_av1.h:413
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
AV1RawFrameHeader::qm_v
uint8_t qm_v
Definition: cbs_av1.h:249
AV1RawFrameHeader::is_filter_switchable
uint8_t is_filter_switchable
Definition: cbs_av1.h:217
D3D12VAEncodeAV1Context::qp
int qp
Definition: d3d12va_encode_av1.c:90
NULL
#define NULL
Definition: coverity.c:32
D3D12VAHWBaseEncodeAV1Opts::enable_jnt_comp
int enable_jnt_comp
Definition: d3d12va_encode_av1.c:61
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
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:669
av_buffer_unref
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition: buffer.c:139
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:284
AV1RawFrameHeader
Definition: cbs_av1.h:174
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:798
AV_LEVEL_UNKNOWN
#define AV_LEVEL_UNKNOWN
Definition: defs.h:209
AV1RawFrameHeader::width_in_sbs_minus_1
uint8_t width_in_sbs_minus_1[AV1_MAX_TILE_COLS]
Definition: cbs_av1.h:229
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:800
d3d12va_encode_av1_free_picture_params
static void d3d12va_encode_av1_free_picture_params(D3D12VAEncodePicture *pic)
Definition: d3d12va_encode_av1.c:845
AV1_SELECT_INTEGER_MV
@ AV1_SELECT_INTEGER_MV
Definition: av1.h:99
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:367
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:481
D3D12VAHWBaseEncodeAV1::raw_tile_group
AV1RawOBU raw_tile_group
Definition: d3d12va_encode_av1.c:49
d3d12va_encode_av1_write_tile_group
static int d3d12va_encode_av1_write_tile_group(AVCodecContext *avctx, uint8_t *tile_group, uint32_t tile_group_size, char *data, size_t *data_len)
Definition: d3d12va_encode_av1.c:319
AV1RawTileData::data_size
size_t data_size
Definition: cbs_av1.h:303
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
AV1RawColorConfig::chroma_sample_position
uint8_t chroma_sample_position
Definition: cbs_av1.h:63
AV1_CSP_VERTICAL
@ AV1_CSP_VERTICAL
Definition: av1.h:134
AV1_OBU_TILE_GROUP
@ AV1_OBU_TILE_GROUP
Definition: av1.h:33
AV1RawSequenceHeader::enable_jnt_comp
uint8_t enable_jnt_comp
Definition: cbs_av1.h:123
AVD3D12VAFramesContext
This struct is allocated as AVHWFramesContext.hwctx.
Definition: hwcontext_d3d12va.h:172
AV_PIX_FMT_D3D12
@ AV_PIX_FMT_D3D12
Hardware surfaces for Direct3D 12.
Definition: pixfmt.h:440
D3D12VAEncodeAV1Picture::show_frame
uint8_t show_frame
Definition: d3d12va_encode_av1.c:81
D3D12VAEncodeAV1Context::profile
int profile
Definition: d3d12va_encode_av1.c:91
AVCodecContext::level
int level
Encoding level descriptor.
Definition: avcodec.h:1628
AV1RawSequenceHeader::seq_force_screen_content_tools
uint8_t seq_force_screen_content_tools
Definition: cbs_av1.h:127
d3d12va_encode_av1_set_level
static int d3d12va_encode_av1_set_level(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:780
D3D12VAEncodeAV1Context::unit_opts
D3D12VAHWBaseEncodeAV1Opts unit_opts
Definition: d3d12va_encode_av1.c:100
AV1RawFrameHeader::delta_q_res
uint8_t delta_q_res
Definition: cbs_av1.h:259
D3D12VAEncodeAV1Context::units
D3D12VAHWBaseEncodeAV1 units
Definition: d3d12va_encode_av1.c:99
AV1RawSequenceHeader::max_frame_height_minus_1
uint16_t max_frame_height_minus_1
Definition: cbs_av1.h:108
D3D12VAHWBaseEncodeAV1Opts::enable_ref_frame_mvs
int enable_ref_frame_mvs
Definition: d3d12va_encode_av1.c:59
AV1RawFrameHeader::interpolation_filter
uint8_t interpolation_filter
Definition: cbs_av1.h:218
D3D12VAHWBaseEncodeAV1Opts::tier
int tier
Definition: d3d12va_encode_av1.c:53
D3D12VAEncodeContext::codec_conf
D3D12_VIDEO_ENCODER_CODEC_CONFIGURATION codec_conf
Definition: d3d12va_encode.h:260
AV1RawFrameHeader::ref_frame_idx
int8_t ref_frame_idx[AV1_REFS_PER_FRAME]
Definition: cbs_av1.h:213
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:550
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
AVFifo
Definition: fifo.c:35
d3d12va_encode_av1_init_picture_params
static int d3d12va_encode_av1_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: d3d12va_encode_av1.c:853
AV1RawFrameHeader::refresh_frame_flags
uint8_t refresh_frame_flags
Definition: cbs_av1.h:207
AV1RawFrameHeader::cdef_bits
uint8_t cdef_bits
Definition: cbs_av1.h:274
D3D12VAEncodeAV1Level::level
uint8_t level
Definition: d3d12va_encode_av1.c:109
codec_internal.h
D3D_PROFILE_DESC
#define D3D_PROFILE_DESC(name)
Definition: d3d12va_encode_av1.c:145
ff_d3d12va_encode_init
int ff_d3d12va_encode_init(AVCodecContext *avctx)
Definition: d3d12va_encode.c:1499
FFHWBaseEncodePicture::nb_refs
int nb_refs[MAX_REFERENCE_LIST_NUM]
Definition: hw_base_encode.h:97
D3D12VAEncodeProfile
Definition: d3d12va_encode.h:62
size
int size
Definition: twinvq_data.h:10344
AV1RawOBU::sequence_header
AV1RawSequenceHeader sequence_header
Definition: cbs_av1.h:419
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:135
AV1RawSequenceHeader::frame_height_bits_minus_1
uint8_t frame_height_bits_minus_1
Definition: cbs_av1.h:106
LEVEL
#define LEVEL(name, value)
d3d12va_encode_av1_write_picture_header
static int d3d12va_encode_av1_write_picture_header(AVCodecContext *avctx, D3D12VAEncodePicture *pic, char *data, size_t *data_len)
Definition: d3d12va_encode_av1.c:289
AV1_OBU_SEQUENCE_HEADER
@ AV1_OBU_SEQUENCE_HEADER
Definition: av1.h:30
AV1LevelDescriptor
Definition: av1_levels.h:26
FFHWBaseEncodePicture::encode_order
int64_t encode_order
Definition: hw_base_encode.h:70
AV1RawSequenceHeader::still_picture
uint8_t still_picture
Definition: cbs_av1.h:84
AV1_TX_MODE_LARGEST
@ AV1_TX_MODE_LARGEST
Definition: av1.h:182
D3D12VAHWBaseEncodeAV1Opts::enable_intra_edge_filter
int enable_intra_edge_filter
Definition: d3d12va_encode_av1.c:65
AV_PROFILE_AV1_HIGH
#define AV_PROFILE_AV1_HIGH
Definition: defs.h:170
AV1RawSequenceHeader::enable_interintra_compound
uint8_t enable_interintra_compound
Definition: cbs_av1.h:117
AV1RawFrameHeader::order_hint
uint8_t order_hint
Definition: cbs_av1.h:191
d3d12va_encode_av1_write_obu
static int d3d12va_encode_av1_write_obu(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *obu)
Definition: d3d12va_encode_av1.c:157
AV1RawOBU::frame_header
AV1RawFrameHeader frame_header
Definition: cbs_av1.h:420
D3D12VAEncodePicture
Definition: d3d12va_encode.h:42
AV1RawFrameHeader::delta_q_v_dc
int8_t delta_q_v_dc
Definition: cbs_av1.h:244
D3D12VAHWBaseEncodeAV1Opts::enable_warped_motion
int enable_warped_motion
Definition: d3d12va_encode_av1.c:64
D3D12VAEncodeContext::level
D3D12_VIDEO_ENCODER_LEVEL_SETTING level
Definition: d3d12va_encode.h:266
d3d12va_encode_av1_write_sequence_header
static int d3d12va_encode_av1_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: d3d12va_encode_av1.c:192
D3D12VAHWBaseEncodeAV1::raw_sequence_header
AV1RawOBU raw_sequence_header
Definition: d3d12va_encode_av1.c:47
D3D12VAEncodeAV1Level::d3d12_level
D3D12_VIDEO_ENCODER_AV1_LEVELS d3d12_level
Definition: d3d12va_encode_av1.c:110
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
AV1RawSequenceHeader::enable_dual_filter
uint8_t enable_dual_filter
Definition: cbs_av1.h:120
AV1RawSequenceHeader::enable_superres
uint8_t enable_superres
Definition: cbs_av1.h:133
MAX_PARAM_BUFFER_SIZE
@ MAX_PARAM_BUFFER_SIZE
Definition: vaapi_encode.h:47
common.h
d3d12va_encode_type_av1
static const D3D12VAEncodeType d3d12va_encode_type_av1
Definition: d3d12va_encode_av1.c:1004
AV1RawSequenceHeader::enable_intra_edge_filter
uint8_t enable_intra_edge_filter
Definition: cbs_av1.h:116
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
D3D12_VIDEO_ENCODER_AV1_INVALID_DPB_RESOURCE_INDEX
#define D3D12_VIDEO_ENCODER_AV1_INVALID_DPB_RESOURCE_INDEX
Definition: d3d12va_encode_av1.c:43
AV1RawSequenceHeader::max_frame_width_minus_1
uint16_t max_frame_width_minus_1
Definition: cbs_av1.h:107
FFHWBaseEncodePicture::refs
struct FFHWBaseEncodePicture * refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES]
Definition: hw_base_encode.h:98
AV1RawSequenceHeader::color_config
AV1RawColorConfig color_config
Definition: cbs_av1.h:137
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:179
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:676
profile
int profile
Definition: mxfenc.c:2297
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:703
D3D12VAHWBaseEncodeAV1Opts::enable_filter_intra
int enable_filter_intra
Definition: d3d12va_encode_av1.c:68
AV1RawSequenceHeader::enable_order_hint
uint8_t enable_order_hint
Definition: cbs_av1.h:122
AV1RawFrameHeader::loop_filter_delta_enabled
uint8_t loop_filter_delta_enabled
Definition: cbs_av1.h:266
AVCodecContext::height
int height
Definition: avcodec.h:592
av1_levels
static const D3D12VAEncodeAV1Level av1_levels[]
Definition: d3d12va_encode_av1.c:114
avcodec.h
d3d12va_encode_av1_close
static int d3d12va_encode_av1_close(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:1064
AV1RawTileGroup::tile_data
AV1RawTileData tile_data
Definition: cbs_av1.h:315
AVD3D12VAFramesContext::format
DXGI_FORMAT format
DXGI_FORMAT format.
Definition: hwcontext_d3d12va.h:177
AV1RawFrameHeader::ref_order_hint
uint8_t ref_order_hint[AV1_NUM_REF_FRAMES]
Definition: cbs_av1.h:209
AV1RawFrameHeader::height_in_sbs_minus_1
uint8_t height_in_sbs_minus_1[AV1_MAX_TILE_ROWS]
Definition: cbs_av1.h:230
tile_group_obu
static int FUNC() tile_group_obu(CodedBitstreamContext *ctx, RWContext *rw, AV1RawTileGroup *current)
Definition: cbs_av1_syntax_template.c:1819
ret
ret
Definition: filter_design.txt:187
FFHWBaseEncodeContext::gop_size
int gop_size
Definition: hw_base_encode.h:184
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:81
AVHWFramesContext::hwctx
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
Definition: hwcontext.h:153
D3D12VAEncodeContext
Definition: d3d12va_encode.h:146
AV1RawColorConfig::high_bitdepth
uint8_t high_bitdepth
Definition: cbs_av1.h:51
av_fifo_alloc2
AVFifo * av_fifo_alloc2(size_t nb_elems, size_t elem_size, unsigned int flags)
Allocate and initialize an AVFifo with a given element size.
Definition: fifo.c:47
AV1RawFrameHeader::update_ref_delta
uint8_t update_ref_delta[AV1_TOTAL_REFS_PER_FRAME]
Definition: cbs_av1.h:268
SIZE_SPECIFIER
#define SIZE_SPECIFIER
Definition: internal.h:119
AV1RawFrameHeader::using_qmatrix
uint8_t using_qmatrix
Definition: cbs_av1.h:246
AV1RawSequenceHeader::frame_width_bits_minus_1
uint8_t frame_width_bits_minus_1
Definition: cbs_av1.h:105
AV1RawSequenceHeader::enable_warped_motion
uint8_t enable_warped_motion
Definition: cbs_av1.h:119
FFHWBaseEncodeContext::surface_height
int surface_height
Definition: hw_base_encode.h:141
D3D12VAEncodeAV1Picture::spatial_id
uint8_t spatial_id
Definition: d3d12va_encode_av1.c:80
AVCodecContext
main external API structure.
Definition: avcodec.h:431
write_sequence_header
static int write_sequence_header(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, uint8_t *data, size_t *data_len)
Definition: vulkan_encode_av1.c:1095
ff_get_encode_buffer
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
Definition: encode.c:105
d3d12va_encode_av1_set_tile
static int d3d12va_encode_av1_set_tile(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:830
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1618
D3D12VAHWBaseEncodeAV1Opts::enable_restoration
int enable_restoration
Definition: d3d12va_encode_av1.c:57
av1_levels.h
ff_av1_d3d12va_encoder
const FFCodec ff_av1_d3d12va_encoder
Definition: d3d12va_encode_av1.c:1164
AV1_FRAME_KEY
@ AV1_FRAME_KEY
Definition: av1.h:53
AV1RawFrameHeader::frame_height_minus_1
uint16_t frame_height_minus_1
Definition: cbs_av1.h:198
AVCodecContext::i_quant_offset
float i_quant_offset
qscale offset between P and I-frames
Definition: avcodec.h:801
D3D12VAEncodePicture::aligned_header_size
int aligned_header_size
Definition: d3d12va_encode.h:44
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
D3D12VAHWBaseEncodeAV1Opts::level
int level
Definition: d3d12va_encode_av1.c:54
FFHWBaseEncodeContext::input_frames
AVHWFramesContext * input_frames
Definition: hw_base_encode.h:153
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
D3D12VAEncodeAV1Picture
Definition: d3d12va_encode_av1.c:78
D3D12VAHWBaseEncodeAV1Opts::enable_palette
int enable_palette
Definition: d3d12va_encode_av1.c:74
AV1_NUM_REF_FRAMES
@ AV1_NUM_REF_FRAMES
Definition: av1.h:84
FFHWBaseEncodeContext::surface_width
int surface_width
Definition: hw_base_encode.h:140
AV1RawSequenceHeader::order_hint_bits_minus_1
uint8_t order_hint_bits_minus_1
Definition: cbs_av1.h:131
AV1RawTileGroup
Definition: cbs_av1.h:306
AV1RawFrameHeader::loop_filter_sharpness
uint8_t loop_filter_sharpness
Definition: cbs_av1.h:265
AV1_CSP_UNKNOWN
@ AV1_CSP_UNKNOWN
Definition: av1.h:133
D3D12VAEncodeContext::gop
D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE gop
Definition: d3d12va_encode.h:264
FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
Definition: hw_base_encode.h:58
AV1RawFrameHeader::delta_q_v_ac
int8_t delta_q_v_ac
Definition: cbs_av1.h:245
desc
const char * desc
Definition: libsvtav1.c:78
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FF_HW_PICTURE_TYPE_IDR
@ FF_HW_PICTURE_TYPE_IDR
Definition: hw_base_encode.h:39
D3D12VAHWBaseEncodeAV1Opts::enable_128x128_superblock
int enable_128x128_superblock
Definition: d3d12va_encode_av1.c:62
mem.h
D3D12VAHWBaseEncodeAV1Opts::enable_loop_filter_delta
int enable_loop_filter_delta
Definition: d3d12va_encode_av1.c:71
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AV1RawSequenceHeader::enable_restoration
uint8_t enable_restoration
Definition: cbs_av1.h:135
ff_d3d12va_encode_close
int ff_d3d12va_encode_close(AVCodecContext *avctx)
Definition: d3d12va_encode.c:1634
AV1RawFrameHeader::error_resilient_mode
uint8_t error_resilient_mode
Definition: cbs_av1.h:184
AV1RawFrameHeader::delta_q_u_ac
int8_t delta_q_u_ac
Definition: cbs_av1.h:243
d3d12va_encode_av1_init
static int d3d12va_encode_av1_init(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:1038
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:1494
AVPacket
This structure stores compressed data.
Definition: packet.h:565
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:458
d3d12va_encode_av1_add_obu
static int d3d12va_encode_av1_add_obu(AVCodecContext *avctx, CodedBitstreamFragment *au, CodedBitstreamUnitType obu_type, void *obu_unit)
Definition: d3d12va_encode_av1.c:176
AV1RawTileData::data_ref
AVBufferRef * data_ref
Definition: cbs_av1.h:302
D3D12VAEncodeAV1Context::current_obu
CodedBitstreamFragment current_obu
Definition: d3d12va_encode_av1.c:103
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
AV1RawFrameHeader::delta_q_present
uint8_t delta_q_present
Definition: cbs_av1.h:258
D3D12VAEncodeAV1Context::post_encode_values_flag
D3D12_VIDEO_ENCODER_AV1_POST_ENCODE_VALUES_FLAGS post_encode_values_flag
Definition: d3d12va_encode_av1.c:104
AV1RawSequenceHeader::enable_cdef
uint8_t enable_cdef
Definition: cbs_av1.h:134
d3d12va_encode_av1_get_coded_data
static int d3d12va_encode_av1_get_coded_data(AVCodecContext *avctx, D3D12VAEncodePicture *pic, AVPacket *pkt)
Definition: d3d12va_encode_av1.c:375
AV1RawSequenceHeader::reduced_still_picture_header
uint8_t reduced_still_picture_header
Definition: cbs_av1.h:85
D3D12VAEncodeType::profiles
const D3D12VAEncodeProfile * profiles
List of supported profiles.
Definition: d3d12va_encode.h:275
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:592
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
av_fifo_freep2
void av_fifo_freep2(AVFifo **f)
Free an AVFifo and reset pointer to NULL.
Definition: fifo.c:286
HW_BASE_ENCODE_COMMON_OPTIONS
#define HW_BASE_ENCODE_COMMON_OPTIONS
Definition: hw_base_encode.h:243
D3D12VAEncodeType
Definition: d3d12va_encode.h:271
D3D12VAEncodeAV1Context::q_idx_p
uint8_t q_idx_p
Definition: d3d12va_encode_av1.c:96
D3D12VAEncodeAV1Picture::frame_type
uint8_t frame_type
Definition: d3d12va_encode_av1.c:82
AV1RawFrameHeader::qm_u
uint8_t qm_u
Definition: cbs_av1.h:248
hwcontext_d3d12va_internal.h
FFHWBaseEncodePicture::display_order
int64_t display_order
Definition: hw_base_encode.h:69
AV1RawFrameHeader::cdef_y_pri_strength
uint8_t cdef_y_pri_strength[8]
Definition: cbs_av1.h:275
AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_MAIN
Definition: defs.h:169
AV1RawFrameHeader::delta_q_y_dc
int8_t delta_q_y_dc
Definition: cbs_av1.h:240
AV1RawFrameHeader::showable_frame
uint8_t showable_frame
Definition: cbs_av1.h:182
AV1RawOBUHeader::obu_has_size_field
uint8_t obu_has_size_field
Definition: cbs_av1.h:42
d3d12va_encode_av1_get_encoder_caps
static int d3d12va_encode_av1_get_encoder_caps(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:619
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
AV1_REFS_PER_FRAME
@ AV1_REFS_PER_FRAME
Definition: av1.h:85
av_log2
int av_log2(unsigned v)
Definition: intmath.c:26
AV_FIFO_FLAG_AUTO_GROW
#define AV_FIFO_FLAG_AUTO_GROW
Automatically resize the FIFO on writes, so that the data fits.
Definition: fifo.h:63
PROFILE
#define PROFILE(name, value)
AV1RawFrameHeader::render_height_minus_1
uint16_t render_height_minus_1
Definition: cbs_av1.h:203
D3D12VAEncodeAV1Context::cbc
CodedBitstreamContext * cbc
Definition: d3d12va_encode_av1.c:102
AV1RawFrameHeader::frame_type
uint8_t frame_type
Definition: cbs_av1.h:180
CodedBitstreamAV1Context
Definition: cbs_av1.h:457
D3D12VAEncodeAV1Context::picture_header_list
AVFifo * picture_header_list
Definition: d3d12va_encode_av1.c:105
AV1RawOBUHeader::obu_type
uint8_t obu_type
Definition: cbs_av1.h:40