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 {
349  D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA *subregion_meta = NULL;
350  uint8_t *data = NULL;
351  HRESULT hr = S_OK;
352  int err = 0;
353 
354  hr = ID3D12Resource_Map(pic->resolved_metadata, 0, NULL, (void **)&data);
355  if (FAILED(hr)) {
356  err = AVERROR_UNKNOWN;
357  return err;
358  }
359 
360  subregion_meta = (D3D12_VIDEO_ENCODER_FRAME_SUBREGION_METADATA*)(data + sizeof(D3D12_VIDEO_ENCODER_OUTPUT_METADATA));
361  if (subregion_meta->bSize == 0) {
362  av_log(avctx, AV_LOG_ERROR, "No subregion metadata found\n");
363  err = AVERROR(EINVAL);
364  return err;
365  }
366  *size = subregion_meta->bSize;
367 
368  ID3D12Resource_Unmap(pic->resolved_metadata, 0, NULL);
369 
370  return 0;
371 }
372 
375 {
376  int err = 0;
377  uint8_t *ptr = NULL;
378  uint8_t *mapped_data = NULL;
379  size_t total_size = 0;
380  HRESULT hr = S_OK;
381  size_t av1_pic_hd_size = 0;
382  int tile_group_extra_size = 0;
383  size_t bit_len = 0;
384 
385  char pic_hd_data[MAX_PARAM_BUFFER_SIZE] = { 0 };
386 
387  err = d3d12va_encode_av1_get_buffer_size(avctx, pic, &total_size);
388  if (err < 0)
389  goto end;
390 
391  // Update the picture header and calculate the picture header size
392  memset(pic_hd_data, 0, sizeof(pic_hd_data));
393  err = d3d12va_encode_av1_write_picture_header(avctx, pic, pic_hd_data, &av1_pic_hd_size);
394  if (err < 0) {
395  av_log(avctx, AV_LOG_ERROR, "Failed to write picture header: %d.\n", err);
396  return err;
397  }
398  av1_pic_hd_size /= 8;
399  av_log(avctx, AV_LOG_DEBUG, "AV1 picture header size: %zu bytes.\n", av1_pic_hd_size);
400 
401 
402  tile_group_extra_size = (av_log2(total_size) + 7) / 7 + 1; // 1 byte for obu header, rest for tile group LEB128 size
403  av_log(avctx, AV_LOG_DEBUG, "Tile group extra size: %d bytes.\n", tile_group_extra_size);
404 
405  total_size += (pic->header_size + tile_group_extra_size + av1_pic_hd_size);
406  av_log(avctx, AV_LOG_DEBUG, "Output buffer size %zu\n", total_size);
407 
408  hr = ID3D12Resource_Map(pic->output_buffer, 0, NULL, (void **)&mapped_data);
409  if (FAILED(hr)) {
410  err = AVERROR_UNKNOWN;
411  goto end;
412  }
413 
414  err = ff_get_encode_buffer(avctx, pkt, total_size, 0);
415  if (err < 0)
416  goto end;
417  ptr = pkt->data;
418 
419  memcpy(ptr, mapped_data, pic->header_size);
420 
421  ptr += pic->header_size;
422  mapped_data += pic->aligned_header_size;
423  total_size -= pic->header_size;
424 
425  memcpy(ptr, pic_hd_data, av1_pic_hd_size);
426  ptr += av1_pic_hd_size;
427  total_size -= av1_pic_hd_size;
428  av_log(avctx, AV_LOG_DEBUG, "AV1 total_size after write picture header: %zu.\n", total_size);
429 
430  total_size -= tile_group_extra_size;
431  err = d3d12va_encode_av1_write_tile_group(avctx, mapped_data, total_size, ptr, &bit_len);
432  if (err < 0) {
433  av_log(avctx, AV_LOG_ERROR, "Failed to write tile group: %d.\n", err);
434  goto end;
435  }
436  assert((total_size + tile_group_extra_size) * 8 == bit_len);
437 
438  ID3D12Resource_Unmap(pic->output_buffer, 0, NULL);
439 
440 end:
442  pic->output_buffer = NULL;
443  return err;
444 }
445 
447  AVCodecContext *avctx,
448  D3D12VAHWBaseEncodeAV1 *common,
450 {
451  AV1RawOBU *seqheader_obu = &common->raw_sequence_header;
452  AV1RawSequenceHeader *seq = &seqheader_obu->obu.sequence_header;
453  const AVPixFmtDescriptor *desc;
454 
455  seq->seq_profile = avctx->profile;
458  seq->seq_tier[0] = opts->tier;
459 
462  .high_bitdepth = desc->comp[0].depth == 8 ? 0 : 1,
463  .color_primaries = avctx->color_primaries,
464  .transfer_characteristics = avctx->color_trc,
465  .matrix_coefficients = avctx->colorspace,
466  .color_description_present_flag = (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
467  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
470  .subsampling_x = desc->log2_chroma_w,
471  .subsampling_y = desc->log2_chroma_h,
472  };
473 
474  switch (avctx->chroma_sample_location) {
475  case AVCHROMA_LOC_LEFT:
477  break;
480  break;
481  default:
483  break;
484  }
485 
486  if (avctx->level != AV_LEVEL_UNKNOWN) {
487  seq->seq_level_idx[0] = avctx->level;
488  }
489  else {
490  const AV1LevelDescriptor *level;
491  float framerate;
492 
493  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
494  framerate = avctx->framerate.num / avctx->framerate.den;
495  else
496  framerate = 0;
497 
498  //currently only supporting 1 tile
499  level = ff_av1_guess_level(avctx->bit_rate, opts->tier,
500  base_ctx->surface_width, base_ctx->surface_height,
501  /*priv->tile_rows*/1 * 1/*priv->tile_cols*/,
502  /*priv->tile_cols*/1, framerate);
503  if (level) {
504  av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
505  seq->seq_level_idx[0] = level->level_idx;
506  }
507  else {
508  av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
509  "any normal level, using maximum parameters level by default.\n");
510  seq->seq_level_idx[0] = 31;
511  seq->seq_tier[0] = 1;
512  }
513  }
514 
515  // Still picture mode
516  seq->still_picture = (base_ctx->gop_size == 1);
518 
519  // Feature flags
520  seq->enable_filter_intra = opts->enable_filter_intra;
521  seq->enable_intra_edge_filter = opts->enable_intra_edge_filter;
522  seq->enable_interintra_compound = opts->enable_interintra_compound;
523  seq->enable_masked_compound = opts->enable_masked_compound;
524  seq->enable_warped_motion = opts->enable_warped_motion;
525  seq->enable_dual_filter = opts->enable_dual_filter;
526  seq->enable_order_hint = !seq->still_picture;
527  if (seq->enable_order_hint) {
528  seq->order_hint_bits_minus_1 = 7;
529  }
530  seq->enable_jnt_comp = opts->enable_jnt_comp && seq->enable_order_hint;
531  seq->enable_ref_frame_mvs = opts->enable_ref_frame_mvs && seq->enable_order_hint;
532  seq->enable_superres = opts->enable_superres;
533  seq->enable_cdef = opts->enable_cdef;
534  seq->enable_restoration = opts->enable_restoration;
535 
536  return 0;
537 
538 }
539 
541 {
542  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
544  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
545  AVD3D12VAFramesContext *hwctx = base_ctx->input_frames->hwctx;
546  AV1RawOBU *seqheader_obu = &priv->units.raw_sequence_header;
548 
549  D3D12_VIDEO_ENCODER_AV1_PROFILE profile = D3D12_VIDEO_ENCODER_AV1_PROFILE_MAIN;
550  D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS level = { 0 };
551  HRESULT hr;
552  int err;
553 
554  D3D12_FEATURE_DATA_VIDEO_ENCODER_SUPPORT1 support = {
555  .NodeIndex = 0,
556  .Codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
557  .InputFormat = hwctx->format,
558  .RateControl = ctx->rc,
559  .IntraRefresh = ctx->intra_refresh.Mode,
560  .SubregionFrameEncoding = D3D12_VIDEO_ENCODER_FRAME_SUBREGION_LAYOUT_MODE_FULL_FRAME,
561  .ResolutionsListCount = 1,
562  .pResolutionList = &ctx->resolution,
563  .CodecGopSequence = ctx->gop,
564  .MaxReferenceFramesInDPB = AV1_NUM_REF_FRAMES,
565  .CodecConfiguration = ctx->codec_conf,
566  .SuggestedProfile.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PROFILE),
567  .SuggestedProfile.pAV1Profile = &profile,
568  .SuggestedLevel.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS),
569  .SuggestedLevel.pAV1LevelSetting = &level,
570  .pResolutionDependentSupport = &ctx->res_limits,
571  .SubregionFrameEncodingData.pTilesPartition_AV1 = ctx->subregions_layout.pTilesPartition_AV1,
572  };
573 
574  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_SUPPORT1,
575  &support, sizeof(support));
576 
577  if (FAILED(hr)) {
578  av_log(avctx, AV_LOG_ERROR, "Failed to check encoder support(%lx).\n", (long)hr);
579  return AVERROR(EINVAL);
580  }
581 
582  if (!(support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_GENERAL_SUPPORT_OK)) {
583  av_log(avctx, AV_LOG_ERROR, "Driver does not support some request D3D12VA AV1 features. %#x\n",
584  support.ValidationFlags);
585  return AVERROR(EINVAL);
586  }
587 
588  if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RECONSTRUCTED_FRAMES_REQUIRE_TEXTURE_ARRAYS) {
589  ctx->is_texture_array = 1;
590  av_log(avctx, AV_LOG_DEBUG, "D3D12 video encode on this device uses texture array mode.\n");
591  }
592 
593  // Check if the configuration with DELTA_QP is supported
594  if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RATE_CONTROL_DELTA_QP_AVAILABLE) {
595  base_ctx->roi_allowed = 1;
596  // Store the QP map region size from resolution limits
597  ctx->qp_map_region_size = ctx->res_limits.QPMapRegionPixelsSize;
598  av_log(avctx, AV_LOG_DEBUG, "ROI encoding is supported via delta QP "
599  "(QP map region size: %d pixels).\n", ctx->qp_map_region_size);
600  } else {
601  base_ctx->roi_allowed = 0;
602  av_log(avctx, AV_LOG_DEBUG, "ROI encoding not supported by hardware for current rate control mode \n");
603  }
604 
605  memset(seqheader_obu, 0, sizeof(*seqheader_obu));
606  seq->seq_profile = profile;
607  seq->seq_level_idx[0] = level.Level;
608  seq->seq_tier[0] = level.Tier;
609 
610  seq->max_frame_width_minus_1 = ctx->resolution.Width - 1;
611  seq->max_frame_height_minus_1 = ctx->resolution.Height - 1;
612  seq->frame_width_bits_minus_1 = av_log2(ctx->resolution.Width);
613  seq->frame_height_bits_minus_1 = av_log2(ctx->resolution.Height);
614 
615  seqheader_obu->header.obu_type = AV1_OBU_SEQUENCE_HEADER;
616 
617  err = d3d12va_hw_base_encode_init_params_av1(base_ctx, avctx,
618  &priv->units, &priv->unit_opts);
619  if (err < 0)
620  return err;
621 
622  if (avctx->level == AV_LEVEL_UNKNOWN)
623  avctx->level = level.Level;
624 
625  return 0;
626 }
627 
629 {
630  HRESULT hr = S_OK;
631  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
633  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
634 
635  D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION *config;
636  D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT av1_caps;
637 
638  D3D12_FEATURE_DATA_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT codec_caps = {
639  .NodeIndex = 0,
640  .Codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
641  .Profile = ctx->profile->d3d12_profile,
642  .CodecSupportLimits.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT),
643  };
644 
645  codec_caps.CodecSupportLimits.pAV1Support = &av1_caps;
646 
647  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT,
648  &codec_caps, sizeof(codec_caps));
649  if (!(SUCCEEDED(hr) && codec_caps.IsSupported))
650  return AVERROR(EINVAL);
651 
652  ctx->codec_conf.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION);
653  ctx->codec_conf.pAV1Config = av_mallocz(ctx->codec_conf.DataSize);
654  if (!ctx->codec_conf.pAV1Config)
655  return AVERROR(ENOMEM);
656 
657  priv->post_encode_values_flag = av1_caps.PostEncodeValuesFlags;
658  config = ctx->codec_conf.pAV1Config;
659 
660  config->FeatureFlags = D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_NONE;
661  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK) {
662  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK;
664  }
665 
666  base_ctx->surface_width = FFALIGN(avctx->width, priv->unit_opts.enable_128x128_superblock ? 128 : 64);
667  base_ctx->surface_height = FFALIGN(avctx->height, priv->unit_opts.enable_128x128_superblock ? 128 : 64);
668 
669  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_RESTORATION_FILTER) {
670  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_RESTORATION_FILTER;
671  priv->unit_opts.enable_loop_filter = 1;
672  }
673 
674  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_PALETTE_ENCODING) {
675  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_PALETTE_ENCODING;
676  priv->unit_opts.enable_palette = 1;
677  }
678 
679  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTRA_BLOCK_COPY) {
680  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTRA_BLOCK_COPY;
682  }
683 
684  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_FILTER_DELTAS) {
685  // Loop filter deltas
686  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_FILTER_DELTAS;
688  }
689 
690  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_CDEF_FILTERING) {
691  // CDEF (Constrained Directional Enhancement Filter)
692  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_CDEF_FILTERING;
693  priv->unit_opts.enable_cdef = 1;
694  }
695 
696  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_DUAL_FILTER) {
697  // Dual filter
698  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_DUAL_FILTER;
699  priv->unit_opts.enable_dual_filter = 1;
700  }
701 
702  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_JNT_COMP) {
703  // Joint compound prediction
704  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_JNT_COMP;
705  priv->unit_opts.enable_jnt_comp = 1;
706  }
707 
708  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_FRAME_REFERENCE_MOTION_VECTORS) {
709  // Frame reference motion vectors
710  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_FRAME_REFERENCE_MOTION_VECTORS;
712  }
713 
714  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_SUPER_RESOLUTION) {
715  // Super-resolution
716  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_SUPER_RESOLUTION;
717  priv->unit_opts.enable_superres = 1;
718  }
719 
720  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_WARPED_MOTION) {
721  // Warped motion
722  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_WARPED_MOTION;
724  }
725 
726  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTERINTRA_COMPOUND) {
727  // Inter-intra compound prediction
728  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTERINTRA_COMPOUND;
730  }
731 
732  return 0;
733 }
734 
736 {
737  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
739  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
740  int err = 0;
741  int fixed_qp_key, fixed_qp_inter;
742 
743  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_AV1, avctx);
744  if (err < 0)
745  return err;
746 
747  if (ctx->rc.Mode == D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CQP) {
748  D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP *cqp_ctl;
749  fixed_qp_inter = av_clip_uintp2(ctx->rc_quality, 8);
750 
751  if (avctx->i_quant_factor > 0.0)
752  fixed_qp_key = av_clip_uintp2((avctx->i_quant_factor * fixed_qp_inter +
753  avctx->i_quant_offset) + 0.5, 8);
754  else
755  fixed_qp_key = fixed_qp_inter;
756 
757  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
758  "%d / %d for Key / Inter frames.\n",
759  fixed_qp_key, fixed_qp_inter);
760 
761  ctx->rc.ConfigParams.DataSize = sizeof(D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP);
762  cqp_ctl = av_mallocz(ctx->rc.ConfigParams.DataSize);
763  if (!cqp_ctl)
764  return AVERROR(ENOMEM);
765 
766  cqp_ctl->ConstantQP_FullIntracodedFrame = fixed_qp_key;
767  cqp_ctl->ConstantQP_InterPredictedFrame_PrevRefOnly = fixed_qp_inter;
768  cqp_ctl->ConstantQP_InterPredictedFrame_BiDirectionalRef = fixed_qp_inter;
769 
770  ctx->rc.ConfigParams.pConfiguration_CQP = cqp_ctl;
771 
772  priv->q_idx_idr = fixed_qp_key;
773  priv->q_idx_p = fixed_qp_inter;
774 
775  }
776 
777  // GOP configuration for AV1
778  ctx->gop.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_SEQUENCE_STRUCTURE);
779  ctx->gop.pAV1SequenceStructure = av_mallocz(ctx->gop.DataSize);
780  if (!ctx->gop.pAV1SequenceStructure)
781  return AVERROR(ENOMEM);
782 
783  ctx->gop.pAV1SequenceStructure->IntraDistance = base_ctx->gop_size;
784  ctx->gop.pAV1SequenceStructure->InterFramePeriod = base_ctx->b_per_p + 1;
785 
786  return 0;
787 }
788 
790 {
792  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
793  int i = 0;
794 
795  ctx->level.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS);
796  ctx->level.pAV1LevelSetting = av_mallocz(ctx->level.DataSize);
797  if (!ctx->level.pAV1LevelSetting)
798  return AVERROR(ENOMEM);
799 
800  if (avctx->level != AV_LEVEL_UNKNOWN) {
801  for (i = 0; i < FF_ARRAY_ELEMS(av1_levels); i++) {
802  if (avctx->level == av1_levels[i].level) {
803  ctx->level.pAV1LevelSetting->Level = av1_levels[i].d3d12_level;
804  break;
805  }
806  }
807 
808  if (i == FF_ARRAY_ELEMS(av1_levels) ) {
809  av_log(avctx, AV_LOG_ERROR, "Invalid AV1 level %d.\n", avctx->level);
810  return AVERROR(EINVAL);
811  }
812  } else {
813  ctx->level.pAV1LevelSetting->Level = D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2;
814  avctx->level = D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2;
815  av_log(avctx, AV_LOG_DEBUG, "Using default AV1 level 5.2\n");
816  }
817 
818  if (priv->tier == 1 || avctx->bit_rate > 30000000) {
819  ctx->level.pAV1LevelSetting->Tier = D3D12_VIDEO_ENCODER_AV1_TIER_HIGH;
820  av_log(avctx, AV_LOG_DEBUG, "Using AV1 High tier\n");
821  } else {
822  ctx->level.pAV1LevelSetting->Tier = D3D12_VIDEO_ENCODER_AV1_TIER_MAIN;
823  av_log(avctx, AV_LOG_DEBUG, "Using AV1 Main tier\n");
824  }
825 
826  if (priv->tier >= 0) {
827  ctx->level.pAV1LevelSetting->Tier = priv->tier == 0 ?
828  D3D12_VIDEO_ENCODER_AV1_TIER_MAIN :
829  D3D12_VIDEO_ENCODER_AV1_TIER_HIGH;
830  }
831 
832  av_log(avctx, AV_LOG_DEBUG, "AV1 level set to %d, tier: %s\n",
833  ctx->level.pAV1LevelSetting->Level,
834  ctx->level.pAV1LevelSetting->Tier == D3D12_VIDEO_ENCODER_AV1_TIER_MAIN ? "Main" : "High");
835 
836  return 0;
837 }
838 
840 {
842 
843  ctx->subregions_layout.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES);
844  D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES *tiles_layout = av_mallocz(ctx->subregions_layout.DataSize);
845  ctx->subregions_layout.pTilesPartition_AV1 = tiles_layout;
846 
847  // Currently only support 1 tile
848  tiles_layout->RowCount = 1;
849  tiles_layout->ColCount = 1;
850 
851  return 0;
852 }
853 
855 {
856  if (!pic->pic_ctl.pAV1PicData)
857  return;
858 
859  av_freep(&pic->pic_ctl.pAV1PicData);
860 }
861 
864 {
865  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
866  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
868  D3D12VAEncodePicture *d3d12va_pic = pic->priv;
869  D3D12VAEncodeAV1Picture *hpic = pic->codec_priv;
870  CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data;
871  AV1RawOBU *frameheader_obu = &priv->units.raw_frame_header;
872  AV1RawFrameHeader *fh = &frameheader_obu->obu.frame_header;
873 
876  int i;
877 
878  static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] =
879  { 1, 0, 0, 0, -1, 0, -1, -1 };
880 
881  memset(frameheader_obu, 0, sizeof(*frameheader_obu));
882 
883  frameheader_obu->header.obu_type = AV1_OBU_FRAME_HEADER;
884 
885  d3d12va_pic->pic_ctl.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_CODEC_DATA);
886  d3d12va_pic->pic_ctl.pAV1PicData = av_mallocz(d3d12va_pic->pic_ctl.DataSize);
887  if (!d3d12va_pic->pic_ctl.pAV1PicData)
888  return AVERROR(ENOMEM);
889 
890  // Initialize frame type and reference frame management
891  switch(pic->type) {
894  fh->refresh_frame_flags = 0xFF;
895  fh->base_q_idx = priv->q_idx_idr;
896  hpic->slot = 0;
897  hpic->last_idr_frame = pic->display_order;
899  break;
900 
903  fh->base_q_idx = priv->q_idx_p;
905 
906  ref = pic->refs[0][pic->nb_refs[0] - 1];
907  href = ref->codec_priv;
908 
909  /**
910  * The encoder uses a simple alternating reference frame strategy:
911  * - For P-frames, it uses the last reconstructed frame as a reference.
912  * - To simplify the reference model of the encoder, the encoder alternates between
913  * two reference frame slots (typically slot 0 and slot 1) for storing reconstructed
914  * images and providing prediction references for the next frame.
915  */
916  if (base_ctx->ref_l0 > 1) {
917  hpic->slot = !href->slot;
918  } else {
919  hpic->slot = 0;
920  }
921  hpic->last_idr_frame = href->last_idr_frame;
922  fh->refresh_frame_flags = 1 << hpic->slot;
923 
924  // Set the nearest frame in L0 as all reference frame.
925  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
926  fh->ref_frame_idx[i] = href->slot;
927 
928  fh->primary_ref_frame = href->slot;
929  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
930 
931  // Set the 2nd nearest frame in L0 as Golden frame.
932  if (pic->nb_refs[0] > 1) {
933  ref = pic->refs[0][pic->nb_refs[0] - 2];
934  href = ref->codec_priv;
935  // Reference frame index 3 is the GOLDEN_FRAME
936  fh->ref_frame_idx[3] = href->slot;
937  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
938  } else if (base_ctx->ref_l0 == 1) {
939  fh->ref_order_hint[!href->slot] = cbctx->ref[!href->slot].order_hint;
940  }
941  break;
942 
944  av_log(avctx, AV_LOG_ERROR, "D3D12 AV1 video encode on this device requires B-frame support, "
945  "but it's not implemented.\n");
946  return AVERROR_PATCHWELCOME;
947  default:
948  av_log(avctx, AV_LOG_ERROR, "Unsupported picture type %d.\n", pic->type);
949  }
950 
951 
952  cbctx->seen_frame_header = 0;
953 
954  fh->show_frame = pic->display_order <= pic->encode_order;
956  fh->order_hint = pic->display_order - hpic->last_idr_frame;
957  fh->frame_width_minus_1 = ctx->resolution.Width - 1;
958  fh->frame_height_minus_1 = ctx->resolution.Height - 1;
961  fh->is_filter_switchable = 1;
964  fh->width_in_sbs_minus_1[0] = (ctx->resolution.Width + 63 >> 6) -1; // 64x64 superblock size
965  fh->height_in_sbs_minus_1[0] = (ctx->resolution.Height + 63 >> 6) -1; // 64x64 superblock size
966 
967  memcpy(fh->loop_filter_ref_deltas, default_loop_filter_ref_deltas,
968  AV1_TOTAL_REFS_PER_FRAME * sizeof(int8_t));
969 
970  if (fh->frame_type == AV1_FRAME_KEY && fh->show_frame)
971  fh->error_resilient_mode = 1;
972 
975 
976  d3d12va_pic->pic_ctl.pAV1PicData->FrameType = fh->frame_type;
977  d3d12va_pic->pic_ctl.pAV1PicData->TxMode = fh->tx_mode;
978  d3d12va_pic->pic_ctl.pAV1PicData->RefreshFrameFlags = fh->refresh_frame_flags;
979  d3d12va_pic->pic_ctl.pAV1PicData->TemporalLayerIndexPlus1 = hpic->temporal_id + 1;
980  d3d12va_pic->pic_ctl.pAV1PicData->SpatialLayerIndexPlus1 = hpic->spatial_id + 1;
981  d3d12va_pic->pic_ctl.pAV1PicData->PictureIndex = pic->display_order;
982  d3d12va_pic->pic_ctl.pAV1PicData->InterpolationFilter = D3D12_VIDEO_ENCODER_AV1_INTERPOLATION_FILTERS_SWITCHABLE;
983  d3d12va_pic->pic_ctl.pAV1PicData->PrimaryRefFrame = fh->primary_ref_frame;
984  if (fh->error_resilient_mode)
985  d3d12va_pic->pic_ctl.pAV1PicData->Flags |= D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_FLAG_ENABLE_ERROR_RESILIENT_MODE;
986 
987  if (pic->type == FF_HW_PICTURE_TYPE_IDR)
988  {
989  for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
990  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceFramesReconPictureDescriptors[i].ReconstructedPictureResourceIndex =
992  }
993  } else if (pic->type == FF_HW_PICTURE_TYPE_P) {
994  for (i = 0; i < pic->nb_refs[0]; i++) {
995  FFHWBaseEncodePicture *ref_pic = pic->refs[0][i];
996  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceFramesReconPictureDescriptors[i].ReconstructedPictureResourceIndex =
997  ((D3D12VAEncodeAV1Picture*)ref_pic->codec_priv)->slot;
998  }
999  }
1000  // Set reference frame management
1001  memset(d3d12va_pic->pic_ctl.pAV1PicData->ReferenceIndices, 0, sizeof(UINT) * AV1_REFS_PER_FRAME);
1002  if (pic->type == FF_HW_PICTURE_TYPE_P) {
1003  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
1004  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceIndices[i] = fh->ref_frame_idx[i];
1005  }
1006 
1007  // Process ROI side data if present and supported
1008  if (base_ctx->roi_allowed && d3d12va_pic->qp_map && d3d12va_pic->qp_map_size > 0) {
1009  d3d12va_pic->pic_ctl.pAV1PicData->QPMapValuesCount = d3d12va_pic->qp_map_size;
1010  d3d12va_pic->pic_ctl.pAV1PicData->pRateControlQPMap = (INT16 *)d3d12va_pic->qp_map;
1011  }
1012 
1013  return av_fifo_write(priv->picture_header_list, &priv->units.raw_frame_header, 1);
1014 }
1015 
1016 
1019 
1020  .d3d12_codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
1021 
1022  .flags = FF_HW_FLAG_B_PICTURES |
1025 
1026  .default_quality = 25,
1027 
1028  .get_encoder_caps = &d3d12va_encode_av1_get_encoder_caps,
1029 
1030  .configure = &d3d12va_encode_av1_configure,
1031 
1032  .set_level = &d3d12va_encode_av1_set_level,
1033 
1034  .set_tile = &d3d12va_encode_av1_set_tile,
1035 
1036  .picture_priv_data_size = sizeof(D3D12VAEncodeAV1Picture),
1037 
1038  .init_sequence_params = &d3d12va_encode_av1_init_sequence_params,
1039 
1040  .init_picture_params = &d3d12va_encode_av1_init_picture_params,
1041 
1042  .free_picture_params = &d3d12va_encode_av1_free_picture_params,
1043 
1045 
1046 #ifdef CONFIG_AV1_D3D12VA_ENCODER
1047  .get_coded_data = &d3d12va_encode_av1_get_coded_data,
1048 #endif
1049 };
1050 
1052 {
1054  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
1055 
1056  ctx->codec = &d3d12va_encode_type_av1;
1057 
1058  if (avctx->profile == AV_PROFILE_UNKNOWN)
1059  avctx->profile = priv->profile;
1060  if (avctx->level == AV_LEVEL_UNKNOWN)
1061  avctx->level = priv->level;
1062 
1063  if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1064  av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1065  "in 8-bit unsigned integer.\n", avctx->level);
1066  return AVERROR(EINVAL);
1067  }
1068 
1069  if (priv->qp > 0)
1070  ctx->explicit_qp = priv->qp;
1071 
1073 
1074  return ff_d3d12va_encode_init(avctx);
1075 }
1076 
1078 {
1079  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
1080 
1081  ff_cbs_fragment_free(&priv->current_obu);
1082  ff_cbs_close(&priv->cbc);
1083 
1084  av_freep(&priv->common.codec_conf.pAV1Config);
1085  av_freep(&priv->common.gop.pAV1SequenceStructure);
1086  av_freep(&priv->common.level.pAV1LevelSetting);
1087  av_freep(&priv->common.subregions_layout.pTilesPartition_AV1);
1088 
1090 
1091  return ff_d3d12va_encode_close(avctx);
1092 }
1093 
1094 #define OFFSET(x) offsetof(D3D12VAEncodeAV1Context, x)
1095 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1100 
1101  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
1102  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
1103 
1104  { "profile", "Set profile (general_profile_idc)",
1106  { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xff, FLAGS, "profile" },
1107 
1108 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1109  { .i64 = value }, 0, 0, FLAGS, "profile"
1110  { PROFILE("main", AV_PROFILE_AV1_MAIN) },
1111  { PROFILE("high", AV_PROFILE_AV1_HIGH) },
1112  { PROFILE("professional", AV_PROFILE_AV1_PROFESSIONAL) },
1113 #undef PROFILE
1114 
1115  { "tier", "Set tier (general_tier_flag)",
1116  OFFSET(unit_opts.tier), AV_OPT_TYPE_INT,
1117  { .i64 = 0 }, 0, 1, FLAGS, "tier" },
1118  { "main", NULL, 0, AV_OPT_TYPE_CONST,
1119  { .i64 = 0 }, 0, 0, FLAGS, "tier" },
1120  { "high", NULL, 0, AV_OPT_TYPE_CONST,
1121  { .i64 = 1 }, 0, 0, FLAGS, "tier" },
1122 
1123  { "level", "Set level (general_level_idc)",
1125  { .i64 = AV_LEVEL_UNKNOWN }, AV_LEVEL_UNKNOWN, 0xff, FLAGS, "level" },
1126 
1127 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1128  { .i64 = value }, 0, 0, FLAGS, "level"
1129  { LEVEL("2.0", 0) },
1130  { LEVEL("2.1", 1) },
1131  { LEVEL("2.2", 2) },
1132  { LEVEL("2.3", 3) },
1133  { LEVEL("3.0", 4) },
1134  { LEVEL("3.1", 5) },
1135  { LEVEL("3.2", 6) },
1136  { LEVEL("3.3", 7) },
1137  { LEVEL("4.0", 8) },
1138  { LEVEL("4.1", 9) },
1139  { LEVEL("4.2", 10) },
1140  { LEVEL("4.3", 11) },
1141  { LEVEL("5.0", 12) },
1142  { LEVEL("5.1", 13) },
1143  { LEVEL("5.2", 14) },
1144  { LEVEL("5.3", 15) },
1145  { LEVEL("6.0", 16) },
1146  { LEVEL("6.1", 17) },
1147  { LEVEL("6.2", 18) },
1148  { LEVEL("6.3", 19) },
1149  { LEVEL("7.0", 20) },
1150  { LEVEL("7.1", 21) },
1151  { LEVEL("7.2", 22) },
1152  { LEVEL("7.3", 23) },
1153 #undef LEVEL
1154  { NULL },
1155 };
1156 
1158  { "b", "0" },
1159  { "bf", "0" },
1160  { "g", "120" },
1161  { "i_qfactor", "1" },
1162  { "i_qoffset", "0" },
1163  { "b_qfactor", "1" },
1164  { "b_qoffset", "0" },
1165  { "qmin", "-1" },
1166  { "qmax", "-1" },
1167  { "refs", "0" },
1168  { NULL },
1169 };
1170 
1172  .class_name = "av1_d3d12va",
1173  .item_name = av_default_item_name,
1174  .option = d3d12va_encode_av1_options,
1175  .version = LIBAVUTIL_VERSION_INT,
1176 };
1177 
1179  .p.name = "av1_d3d12va",
1180  CODEC_LONG_NAME("D3D12VA av1 encoder"),
1181  .p.type = AVMEDIA_TYPE_VIDEO,
1182  .p.id = AV_CODEC_ID_AV1,
1183  .priv_data_size = sizeof(D3D12VAEncodeAV1Context),
1186  .close = &d3d12va_encode_av1_close,
1187  .p.priv_class = &d3d12va_encode_av1_class,
1188  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE |
1190  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1192  .defaults = d3d12va_encode_av1_defaults,
1194  .hw_configs = ff_d3d12va_encode_hw_configs,
1195  .p.wrapper_name = "d3d12va",
1196 };
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:446
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:667
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
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:660
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:1157
D3D12VAEncodePicture::qp_map_size
int qp_map_size
Definition: d3d12va_encode.h:63
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
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
AV1RawOBU::header
AV1RawOBUHeader header
Definition: cbs_av1.h:414
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:1094
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:559
AV1RawColorConfig
Definition: cbs_av1.h:50
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:802
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:272
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:216
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:430
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:540
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:653
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
D3D12VA_ENCODE_COMMON_OPTIONS
#define D3D12VA_ENCODE_COMMON_OPTIONS
Definition: d3d12va_encode.h:396
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:1095
d3d12va_encode_av1_options
static const AVOption d3d12va_encode_av1_options[]
Definition: d3d12va_encode_av1.c:1096
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:1171
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:735
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
av_mallocz
#define av_mallocz(s)
Definition: tableprint_vlc.h:31
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:639
FF_HW_PICTURE_TYPE_P
@ FF_HW_PICTURE_TYPE_P
Definition: hw_base_encode.h:41
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
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
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:677
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:854
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:489
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:242
AV1RawColorConfig::chroma_sample_position
uint8_t chroma_sample_position
Definition: cbs_av1.h:63
AV1_CSP_VERTICAL
@ AV1_CSP_VERTICAL
Definition: av1.h:134
FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
Definition: hw_base_encode.h:58
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:1636
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:789
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:264
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:862
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:1788
FFHWBaseEncodePicture::nb_refs
int nb_refs[MAX_REFERENCE_LIST_NUM]
Definition: hw_base_encode.h:97
D3D12VAEncodeProfile
Definition: d3d12va_encode.h:66
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
FFHWBaseEncodeContext::roi_allowed
int roi_allowed
Definition: hw_base_encode.h:201
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
MAX_PARAM_BUFFER_SIZE
@ MAX_PARAM_BUFFER_SIZE
Definition: vaapi_encode.h:47
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:270
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
D3D12VAEncodePicture::qp_map
void * qp_map
Definition: d3d12va_encode.h:62
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
common.h
d3d12va_encode_type_av1
static const D3D12VAEncodeType d3d12va_encode_type_av1
Definition: d3d12va_encode_av1.c:1017
AV1RawSequenceHeader::enable_intra_edge_filter
uint8_t enable_intra_edge_filter
Definition: cbs_av1.h:116
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
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:684
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:600
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:1077
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
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:150
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
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
FF_HW_PICTURE_TYPE_IDR
@ FF_HW_PICTURE_TYPE_IDR
Definition: hw_base_encode.h:39
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:439
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:839
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:1626
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:1178
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:809
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:268
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
D3D12VAHWBaseEncodeAV1Opts::enable_128x128_superblock
int enable_128x128_superblock
Definition: d3d12va_encode_av1.c:62
FF_HW_PICTURE_TYPE_B
@ FF_HW_PICTURE_TYPE_B
Definition: hw_base_encode.h:42
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:1931
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:1051
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:1783
AVPacket
This structure stores compressed data.
Definition: packet.h:565
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:466
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:373
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:299
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:600
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:295
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:628
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