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 requested features. ValidationFlags: %#x\n",
584  support.ValidationFlags);
585  ff_d3d12va_encode_check_encoder_feature_flags(avctx, support.ValidationFlags);
586  return AVERROR(EINVAL);
587  }
588 
589  if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RECONSTRUCTED_FRAMES_REQUIRE_TEXTURE_ARRAYS) {
590  ctx->is_texture_array = 1;
591  av_log(avctx, AV_LOG_DEBUG, "D3D12 video encode on this device uses texture array mode.\n");
592  }
593 
594  // Check if the configuration with DELTA_QP is supported
595  if (support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_RATE_CONTROL_DELTA_QP_AVAILABLE) {
596  base_ctx->roi_allowed = 1;
597  // Store the QP map region size from resolution limits
598  ctx->qp_map_region_size = ctx->res_limits.QPMapRegionPixelsSize;
599  av_log(avctx, AV_LOG_DEBUG, "ROI encoding is supported via delta QP "
600  "(QP map region size: %d pixels).\n", ctx->qp_map_region_size);
601  } else {
602  base_ctx->roi_allowed = 0;
603  av_log(avctx, AV_LOG_DEBUG, "ROI encoding not supported by hardware for current rate control mode \n");
604  }
605 
606  // Check motion estimation precision mode support
607  if (ctx->me_precision != D3D12_VIDEO_ENCODER_MOTION_ESTIMATION_PRECISION_MODE_MAXIMUM) {
608  if (!(support.SupportFlags & D3D12_VIDEO_ENCODER_SUPPORT_FLAG_MOTION_ESTIMATION_PRECISION_MODE_LIMIT_AVAILABLE)) {
609  av_log(avctx, AV_LOG_ERROR, "Hardware does not support motion estimation "
610  "precision mode limits.\n");
611  return AVERROR(ENOTSUP);
612  }
613  av_log(avctx, AV_LOG_VERBOSE, "Hardware supports motion estimation "
614  "precision mode limits.\n");
615  }
616 
617  memset(seqheader_obu, 0, sizeof(*seqheader_obu));
618  seq->seq_profile = profile;
619  seq->seq_level_idx[0] = level.Level;
620  seq->seq_tier[0] = level.Tier;
621 
622  seq->max_frame_width_minus_1 = ctx->resolution.Width - 1;
623  seq->max_frame_height_minus_1 = ctx->resolution.Height - 1;
624  seq->frame_width_bits_minus_1 = av_log2(ctx->resolution.Width);
625  seq->frame_height_bits_minus_1 = av_log2(ctx->resolution.Height);
626 
627  seqheader_obu->header.obu_type = AV1_OBU_SEQUENCE_HEADER;
628 
629  err = d3d12va_hw_base_encode_init_params_av1(base_ctx, avctx,
630  &priv->units, &priv->unit_opts);
631  if (err < 0)
632  return err;
633 
634  if (avctx->level == AV_LEVEL_UNKNOWN)
635  avctx->level = level.Level;
636 
637  return 0;
638 }
639 
641 {
642  HRESULT hr = S_OK;
643  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
645  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
646 
647  D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION *config;
648  D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT av1_caps;
649 
650  D3D12_FEATURE_DATA_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT codec_caps = {
651  .NodeIndex = 0,
652  .Codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
653  .Profile = ctx->profile->d3d12_profile,
654  .CodecSupportLimits.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION_SUPPORT),
655  };
656 
657  codec_caps.CodecSupportLimits.pAV1Support = &av1_caps;
658 
659  hr = ID3D12VideoDevice3_CheckFeatureSupport(ctx->video_device3, D3D12_FEATURE_VIDEO_ENCODER_CODEC_CONFIGURATION_SUPPORT,
660  &codec_caps, sizeof(codec_caps));
661  if (!(SUCCEEDED(hr) && codec_caps.IsSupported))
662  return AVERROR(EINVAL);
663 
664  ctx->codec_conf.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_CODEC_CONFIGURATION);
665  ctx->codec_conf.pAV1Config = av_mallocz(ctx->codec_conf.DataSize);
666  if (!ctx->codec_conf.pAV1Config)
667  return AVERROR(ENOMEM);
668 
669  priv->post_encode_values_flag = av1_caps.PostEncodeValuesFlags;
670  config = ctx->codec_conf.pAV1Config;
671 
672  config->FeatureFlags = D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_NONE;
673  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK) {
674  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_128x128_SUPERBLOCK;
676  }
677 
678  base_ctx->surface_width = FFALIGN(avctx->width, priv->unit_opts.enable_128x128_superblock ? 128 : 64);
679  base_ctx->surface_height = FFALIGN(avctx->height, priv->unit_opts.enable_128x128_superblock ? 128 : 64);
680 
681  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_RESTORATION_FILTER) {
682  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_RESTORATION_FILTER;
683  priv->unit_opts.enable_loop_filter = 1;
684  }
685 
686  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_PALETTE_ENCODING) {
687  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_PALETTE_ENCODING;
688  priv->unit_opts.enable_palette = 1;
689  }
690 
691  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTRA_BLOCK_COPY) {
692  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTRA_BLOCK_COPY;
694  }
695 
696  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_FILTER_DELTAS) {
697  // Loop filter deltas
698  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_LOOP_FILTER_DELTAS;
700  }
701 
702  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_CDEF_FILTERING) {
703  // CDEF (Constrained Directional Enhancement Filter)
704  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_CDEF_FILTERING;
705  priv->unit_opts.enable_cdef = 1;
706  }
707 
708  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_DUAL_FILTER) {
709  // Dual filter
710  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_DUAL_FILTER;
711  priv->unit_opts.enable_dual_filter = 1;
712  }
713 
714  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_JNT_COMP) {
715  // Joint compound prediction
716  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_JNT_COMP;
717  priv->unit_opts.enable_jnt_comp = 1;
718  }
719 
720  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_FRAME_REFERENCE_MOTION_VECTORS) {
721  // Frame reference motion vectors
722  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_FRAME_REFERENCE_MOTION_VECTORS;
724  }
725 
726  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_SUPER_RESOLUTION) {
727  // Super-resolution
728  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_SUPER_RESOLUTION;
729  priv->unit_opts.enable_superres = 1;
730  }
731 
732  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_WARPED_MOTION) {
733  // Warped motion
734  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_WARPED_MOTION;
736  }
737 
738  if (av1_caps.SupportedFeatureFlags & D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTERINTRA_COMPOUND) {
739  // Inter-intra compound prediction
740  config->FeatureFlags |= D3D12_VIDEO_ENCODER_AV1_FEATURE_FLAG_INTERINTRA_COMPOUND;
742  }
743 
744  return 0;
745 }
746 
748 {
749  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
751  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
752  int err = 0;
753  int fixed_qp_key, fixed_qp_inter;
754 
755  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_AV1, avctx);
756  if (err < 0)
757  return err;
758 
759  if (ctx->rc.Mode == D3D12_VIDEO_ENCODER_RATE_CONTROL_MODE_CQP) {
760  D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP *cqp_ctl;
761  fixed_qp_inter = av_clip_uintp2(ctx->rc_quality, 8);
762 
763  if (avctx->i_quant_factor > 0.0)
764  fixed_qp_key = av_clip_uintp2((avctx->i_quant_factor * fixed_qp_inter +
765  avctx->i_quant_offset) + 0.5, 8);
766  else
767  fixed_qp_key = fixed_qp_inter;
768 
769  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
770  "%d / %d for Key / Inter frames.\n",
771  fixed_qp_key, fixed_qp_inter);
772 
773  ctx->rc.ConfigParams.DataSize = sizeof(D3D12_VIDEO_ENCODER_RATE_CONTROL_CQP);
774  cqp_ctl = av_mallocz(ctx->rc.ConfigParams.DataSize);
775  if (!cqp_ctl)
776  return AVERROR(ENOMEM);
777 
778  cqp_ctl->ConstantQP_FullIntracodedFrame = fixed_qp_key;
779  cqp_ctl->ConstantQP_InterPredictedFrame_PrevRefOnly = fixed_qp_inter;
780  cqp_ctl->ConstantQP_InterPredictedFrame_BiDirectionalRef = fixed_qp_inter;
781 
782  ctx->rc.ConfigParams.pConfiguration_CQP = cqp_ctl;
783 
784  priv->q_idx_idr = fixed_qp_key;
785  priv->q_idx_p = fixed_qp_inter;
786 
787  }
788 
789  // GOP configuration for AV1
790  ctx->gop.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_SEQUENCE_STRUCTURE);
791  ctx->gop.pAV1SequenceStructure = av_mallocz(ctx->gop.DataSize);
792  if (!ctx->gop.pAV1SequenceStructure)
793  return AVERROR(ENOMEM);
794 
795  ctx->gop.pAV1SequenceStructure->IntraDistance = base_ctx->gop_size;
796  ctx->gop.pAV1SequenceStructure->InterFramePeriod = base_ctx->b_per_p + 1;
797 
798  return 0;
799 }
800 
802 {
804  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
805  int i = 0;
806 
807  ctx->level.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_LEVEL_TIER_CONSTRAINTS);
808  ctx->level.pAV1LevelSetting = av_mallocz(ctx->level.DataSize);
809  if (!ctx->level.pAV1LevelSetting)
810  return AVERROR(ENOMEM);
811 
812  if (avctx->level != AV_LEVEL_UNKNOWN) {
813  for (i = 0; i < FF_ARRAY_ELEMS(av1_levels); i++) {
814  if (avctx->level == av1_levels[i].level) {
815  ctx->level.pAV1LevelSetting->Level = av1_levels[i].d3d12_level;
816  break;
817  }
818  }
819 
820  if (i == FF_ARRAY_ELEMS(av1_levels) ) {
821  av_log(avctx, AV_LOG_ERROR, "Invalid AV1 level %d.\n", avctx->level);
822  return AVERROR(EINVAL);
823  }
824  } else {
825  ctx->level.pAV1LevelSetting->Level = D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2;
826  avctx->level = D3D12_VIDEO_ENCODER_AV1_LEVELS_5_2;
827  av_log(avctx, AV_LOG_DEBUG, "Using default AV1 level 5.2\n");
828  }
829 
830  if (priv->tier == 1 || avctx->bit_rate > 30000000) {
831  ctx->level.pAV1LevelSetting->Tier = D3D12_VIDEO_ENCODER_AV1_TIER_HIGH;
832  av_log(avctx, AV_LOG_DEBUG, "Using AV1 High tier\n");
833  } else {
834  ctx->level.pAV1LevelSetting->Tier = D3D12_VIDEO_ENCODER_AV1_TIER_MAIN;
835  av_log(avctx, AV_LOG_DEBUG, "Using AV1 Main tier\n");
836  }
837 
838  if (priv->tier >= 0) {
839  ctx->level.pAV1LevelSetting->Tier = priv->tier == 0 ?
840  D3D12_VIDEO_ENCODER_AV1_TIER_MAIN :
841  D3D12_VIDEO_ENCODER_AV1_TIER_HIGH;
842  }
843 
844  av_log(avctx, AV_LOG_DEBUG, "AV1 level set to %d, tier: %s\n",
845  ctx->level.pAV1LevelSetting->Level,
846  ctx->level.pAV1LevelSetting->Tier == D3D12_VIDEO_ENCODER_AV1_TIER_MAIN ? "Main" : "High");
847 
848  return 0;
849 }
850 
852 {
854 
855  ctx->subregions_layout.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES);
856  D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_SUBREGIONS_LAYOUT_DATA_TILES *tiles_layout = av_mallocz(ctx->subregions_layout.DataSize);
857  ctx->subregions_layout.pTilesPartition_AV1 = tiles_layout;
858 
859  // Currently only support 1 tile
860  tiles_layout->RowCount = 1;
861  tiles_layout->ColCount = 1;
862 
863  return 0;
864 }
865 
867 {
868  if (!pic->pic_ctl.pAV1PicData)
869  return;
870 
871  av_freep(&pic->pic_ctl.pAV1PicData);
872 }
873 
876 {
877  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
878  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
880  D3D12VAEncodePicture *d3d12va_pic = pic->priv;
881  D3D12VAEncodeAV1Picture *hpic = pic->codec_priv;
882  CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data;
883  AV1RawOBU *frameheader_obu = &priv->units.raw_frame_header;
884  AV1RawFrameHeader *fh = &frameheader_obu->obu.frame_header;
885 
888  int i;
889 
890  static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] =
891  { 1, 0, 0, 0, -1, 0, -1, -1 };
892 
893  memset(frameheader_obu, 0, sizeof(*frameheader_obu));
894 
895  frameheader_obu->header.obu_type = AV1_OBU_FRAME_HEADER;
896 
897  d3d12va_pic->pic_ctl.DataSize = sizeof(D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_CODEC_DATA);
898  d3d12va_pic->pic_ctl.pAV1PicData = av_mallocz(d3d12va_pic->pic_ctl.DataSize);
899  if (!d3d12va_pic->pic_ctl.pAV1PicData)
900  return AVERROR(ENOMEM);
901 
902  // Initialize frame type and reference frame management
903  switch(pic->type) {
906  fh->refresh_frame_flags = 0xFF;
907  fh->base_q_idx = priv->q_idx_idr;
908  hpic->slot = 0;
909  hpic->last_idr_frame = pic->display_order;
911  break;
912 
915  fh->base_q_idx = priv->q_idx_p;
917 
918  ref = pic->refs[0][pic->nb_refs[0] - 1];
919  href = ref->codec_priv;
920 
921  /**
922  * The encoder uses a simple alternating reference frame strategy:
923  * - For P-frames, it uses the last reconstructed frame as a reference.
924  * - To simplify the reference model of the encoder, the encoder alternates between
925  * two reference frame slots (typically slot 0 and slot 1) for storing reconstructed
926  * images and providing prediction references for the next frame.
927  */
928  if (base_ctx->ref_l0 > 1) {
929  hpic->slot = !href->slot;
930  } else {
931  hpic->slot = 0;
932  }
933  hpic->last_idr_frame = href->last_idr_frame;
934  fh->refresh_frame_flags = 1 << hpic->slot;
935 
936  // Set the nearest frame in L0 as all reference frame.
937  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
938  fh->ref_frame_idx[i] = href->slot;
939 
940  fh->primary_ref_frame = href->slot;
941  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
942 
943  // Set the 2nd nearest frame in L0 as Golden frame.
944  if (pic->nb_refs[0] > 1) {
945  ref = pic->refs[0][pic->nb_refs[0] - 2];
946  href = ref->codec_priv;
947  // Reference frame index 3 is the GOLDEN_FRAME
948  fh->ref_frame_idx[3] = href->slot;
949  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
950  } else if (base_ctx->ref_l0 == 1) {
951  fh->ref_order_hint[!href->slot] = cbctx->ref[!href->slot].order_hint;
952  }
953  break;
954 
956  av_log(avctx, AV_LOG_ERROR, "D3D12 AV1 video encode on this device requires B-frame support, "
957  "but it's not implemented.\n");
958  return AVERROR_PATCHWELCOME;
959  default:
960  av_log(avctx, AV_LOG_ERROR, "Unsupported picture type %d.\n", pic->type);
961  }
962 
963 
964  cbctx->seen_frame_header = 0;
965 
966  fh->show_frame = pic->display_order <= pic->encode_order;
968  fh->order_hint = pic->display_order - hpic->last_idr_frame;
969  fh->frame_width_minus_1 = ctx->resolution.Width - 1;
970  fh->frame_height_minus_1 = ctx->resolution.Height - 1;
973  fh->is_filter_switchable = 1;
976  fh->width_in_sbs_minus_1[0] = (ctx->resolution.Width + 63 >> 6) -1; // 64x64 superblock size
977  fh->height_in_sbs_minus_1[0] = (ctx->resolution.Height + 63 >> 6) -1; // 64x64 superblock size
978 
979  memcpy(fh->loop_filter_ref_deltas, default_loop_filter_ref_deltas,
980  AV1_TOTAL_REFS_PER_FRAME * sizeof(int8_t));
981 
982  if (fh->frame_type == AV1_FRAME_KEY && fh->show_frame)
983  fh->error_resilient_mode = 1;
984 
987 
988  d3d12va_pic->pic_ctl.pAV1PicData->FrameType = fh->frame_type;
989  d3d12va_pic->pic_ctl.pAV1PicData->TxMode = fh->tx_mode;
990  d3d12va_pic->pic_ctl.pAV1PicData->RefreshFrameFlags = fh->refresh_frame_flags;
991  d3d12va_pic->pic_ctl.pAV1PicData->TemporalLayerIndexPlus1 = hpic->temporal_id + 1;
992  d3d12va_pic->pic_ctl.pAV1PicData->SpatialLayerIndexPlus1 = hpic->spatial_id + 1;
993  d3d12va_pic->pic_ctl.pAV1PicData->PictureIndex = pic->display_order;
994  d3d12va_pic->pic_ctl.pAV1PicData->InterpolationFilter = D3D12_VIDEO_ENCODER_AV1_INTERPOLATION_FILTERS_SWITCHABLE;
995  d3d12va_pic->pic_ctl.pAV1PicData->PrimaryRefFrame = fh->primary_ref_frame;
996  if (fh->error_resilient_mode)
997  d3d12va_pic->pic_ctl.pAV1PicData->Flags |= D3D12_VIDEO_ENCODER_AV1_PICTURE_CONTROL_FLAG_ENABLE_ERROR_RESILIENT_MODE;
998 
999  if (pic->type == FF_HW_PICTURE_TYPE_IDR)
1000  {
1001  for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
1002  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceFramesReconPictureDescriptors[i].ReconstructedPictureResourceIndex =
1004  }
1005  } else if (pic->type == FF_HW_PICTURE_TYPE_P) {
1006  for (i = 0; i < pic->nb_refs[0]; i++) {
1007  FFHWBaseEncodePicture *ref_pic = pic->refs[0][i];
1008  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceFramesReconPictureDescriptors[i].ReconstructedPictureResourceIndex =
1009  ((D3D12VAEncodeAV1Picture*)ref_pic->codec_priv)->slot;
1010  }
1011  }
1012  // Set reference frame management
1013  memset(d3d12va_pic->pic_ctl.pAV1PicData->ReferenceIndices, 0, sizeof(UINT) * AV1_REFS_PER_FRAME);
1014  if (pic->type == FF_HW_PICTURE_TYPE_P) {
1015  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
1016  d3d12va_pic->pic_ctl.pAV1PicData->ReferenceIndices[i] = fh->ref_frame_idx[i];
1017  }
1018 
1019  // Process ROI side data if present and supported
1020  if (base_ctx->roi_allowed && d3d12va_pic->qp_map && d3d12va_pic->qp_map_size > 0) {
1021  d3d12va_pic->pic_ctl.pAV1PicData->QPMapValuesCount = d3d12va_pic->qp_map_size;
1022  d3d12va_pic->pic_ctl.pAV1PicData->pRateControlQPMap = (INT16 *)d3d12va_pic->qp_map;
1023  }
1024 
1025  return av_fifo_write(priv->picture_header_list, &priv->units.raw_frame_header, 1);
1026 }
1027 
1028 
1031 
1032  .d3d12_codec = D3D12_VIDEO_ENCODER_CODEC_AV1,
1033 
1034  .flags = FF_HW_FLAG_B_PICTURES |
1037 
1038  .default_quality = 25,
1039 
1040  .get_encoder_caps = &d3d12va_encode_av1_get_encoder_caps,
1041 
1042  .configure = &d3d12va_encode_av1_configure,
1043 
1044  .set_level = &d3d12va_encode_av1_set_level,
1045 
1046  .set_tile = &d3d12va_encode_av1_set_tile,
1047 
1048  .picture_priv_data_size = sizeof(D3D12VAEncodeAV1Picture),
1049 
1050  .init_sequence_params = &d3d12va_encode_av1_init_sequence_params,
1051 
1052  .init_picture_params = &d3d12va_encode_av1_init_picture_params,
1053 
1054  .free_picture_params = &d3d12va_encode_av1_free_picture_params,
1055 
1057 
1058 #ifdef CONFIG_AV1_D3D12VA_ENCODER
1059  .get_coded_data = &d3d12va_encode_av1_get_coded_data,
1060 #endif
1061 };
1062 
1064 {
1066  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
1067 
1068  ctx->codec = &d3d12va_encode_type_av1;
1069 
1070  if (avctx->profile == AV_PROFILE_UNKNOWN)
1071  avctx->profile = priv->profile;
1072  if (avctx->level == AV_LEVEL_UNKNOWN)
1073  avctx->level = priv->level;
1074 
1075  if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1076  av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1077  "in 8-bit unsigned integer.\n", avctx->level);
1078  return AVERROR(EINVAL);
1079  }
1080 
1081  if (priv->qp > 0)
1082  ctx->explicit_qp = priv->qp;
1083 
1085 
1086  return ff_d3d12va_encode_init(avctx);
1087 }
1088 
1090 {
1091  D3D12VAEncodeAV1Context *priv = avctx->priv_data;
1092 
1093  ff_cbs_fragment_free(&priv->current_obu);
1094  ff_cbs_close(&priv->cbc);
1095 
1096  av_freep(&priv->common.codec_conf.pAV1Config);
1097  av_freep(&priv->common.gop.pAV1SequenceStructure);
1098  av_freep(&priv->common.level.pAV1LevelSetting);
1099  av_freep(&priv->common.subregions_layout.pTilesPartition_AV1);
1100 
1102 
1103  return ff_d3d12va_encode_close(avctx);
1104 }
1105 
1106 #define OFFSET(x) offsetof(D3D12VAEncodeAV1Context, x)
1107 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1112 
1113  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
1114  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
1115 
1116  { "profile", "Set profile (general_profile_idc)",
1118  { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xff, FLAGS, "profile" },
1119 
1120 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1121  { .i64 = value }, 0, 0, FLAGS, "profile"
1122  { PROFILE("main", AV_PROFILE_AV1_MAIN) },
1123  { PROFILE("high", AV_PROFILE_AV1_HIGH) },
1124  { PROFILE("professional", AV_PROFILE_AV1_PROFESSIONAL) },
1125 #undef PROFILE
1126 
1127  { "tier", "Set tier (general_tier_flag)",
1128  OFFSET(unit_opts.tier), AV_OPT_TYPE_INT,
1129  { .i64 = 0 }, 0, 1, FLAGS, "tier" },
1130  { "main", NULL, 0, AV_OPT_TYPE_CONST,
1131  { .i64 = 0 }, 0, 0, FLAGS, "tier" },
1132  { "high", NULL, 0, AV_OPT_TYPE_CONST,
1133  { .i64 = 1 }, 0, 0, FLAGS, "tier" },
1134 
1135  { "level", "Set level (general_level_idc)",
1137  { .i64 = AV_LEVEL_UNKNOWN }, AV_LEVEL_UNKNOWN, 0xff, FLAGS, "level" },
1138 
1139 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1140  { .i64 = value }, 0, 0, FLAGS, "level"
1141  { LEVEL("2.0", 0) },
1142  { LEVEL("2.1", 1) },
1143  { LEVEL("2.2", 2) },
1144  { LEVEL("2.3", 3) },
1145  { LEVEL("3.0", 4) },
1146  { LEVEL("3.1", 5) },
1147  { LEVEL("3.2", 6) },
1148  { LEVEL("3.3", 7) },
1149  { LEVEL("4.0", 8) },
1150  { LEVEL("4.1", 9) },
1151  { LEVEL("4.2", 10) },
1152  { LEVEL("4.3", 11) },
1153  { LEVEL("5.0", 12) },
1154  { LEVEL("5.1", 13) },
1155  { LEVEL("5.2", 14) },
1156  { LEVEL("5.3", 15) },
1157  { LEVEL("6.0", 16) },
1158  { LEVEL("6.1", 17) },
1159  { LEVEL("6.2", 18) },
1160  { LEVEL("6.3", 19) },
1161  { LEVEL("7.0", 20) },
1162  { LEVEL("7.1", 21) },
1163  { LEVEL("7.2", 22) },
1164  { LEVEL("7.3", 23) },
1165 #undef LEVEL
1166  { NULL },
1167 };
1168 
1170  { "b", "0" },
1171  { "bf", "0" },
1172  { "g", "120" },
1173  { "i_qfactor", "1" },
1174  { "i_qoffset", "0" },
1175  { "b_qfactor", "1" },
1176  { "b_qoffset", "0" },
1177  { "qmin", "-1" },
1178  { "qmax", "-1" },
1179  { "refs", "0" },
1180  { NULL },
1181 };
1182 
1184  .class_name = "av1_d3d12va",
1185  .item_name = av_default_item_name,
1186  .option = d3d12va_encode_av1_options,
1187  .version = LIBAVUTIL_VERSION_INT,
1188 };
1189 
1191  .p.name = "av1_d3d12va",
1192  CODEC_LONG_NAME("D3D12VA av1 encoder"),
1193  .p.type = AVMEDIA_TYPE_VIDEO,
1194  .p.id = AV_CODEC_ID_AV1,
1195  .priv_data_size = sizeof(D3D12VAEncodeAV1Context),
1198  .close = &d3d12va_encode_av1_close,
1199  .p.priv_class = &d3d12va_encode_av1_class,
1200  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE |
1202  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1204  .defaults = d3d12va_encode_av1_defaults,
1206  .hw_configs = ff_d3d12va_encode_hw_configs,
1207  .p.wrapper_name = "d3d12va",
1208 };
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
FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
Definition: hw_base_encode.h:58
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
AV1_SELECT_INTEGER_MV
@ AV1_SELECT_INTEGER_MV
Definition: av1.h:99
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
AVPacket::data
uint8_t * data
Definition: packet.h:588
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:1169
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
AV1RawOBU::header
AV1RawOBUHeader header
Definition: cbs_av1.h:414
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_UNKNOWN
@ AV1_CSP_UNKNOWN
Definition: av1.h:133
D3D12VAEncodeAV1Picture::temporal_id
uint8_t temporal_id
Definition: d3d12va_encode_av1.c:79
OFFSET
#define OFFSET(x)
Definition: d3d12va_encode_av1.c:1106
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_check_encoder_feature_flags
void ff_d3d12va_encode_check_encoder_feature_flags(void *log_ctx, D3D12_VIDEO_ENCODER_VALIDATION_FLAGS flags)
Definition: d3d12va_encode.c: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: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
AV1_TOTAL_REFS_PER_FRAME
@ AV1_TOTAL_REFS_PER_FRAME
Definition: av1.h:86
fail
#define fail()
Definition: checkasm.h:219
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:433
D3D12VAHWBaseEncodeAV1Opts::enable_dual_filter
int enable_dual_filter
Definition: d3d12va_encode_av1.c:72
AV1_REFS_PER_FRAME
@ AV1_REFS_PER_FRAME
Definition: av1.h:85
AVRational::num
int num
Numerator.
Definition: rational.h:59
AV1_CSP_VERTICAL
@ AV1_CSP_VERTICAL
Definition: av1.h:134
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
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
AV1_PRIMARY_REF_NONE
@ AV1_PRIMARY_REF_NONE
Definition: av1.h:87
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:399
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
AV1_TX_MODE_LARGEST
@ AV1_TX_MODE_LARGEST
Definition: av1.h:182
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:1107
d3d12va_encode_av1_options
static const AVOption d3d12va_encode_av1_options[]
Definition: d3d12va_encode_av1.c:1108
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:1183
D3D12VAHWBaseEncodeAV1Opts::enable_interintra_compound
int enable_interintra_compound
Definition: d3d12va_encode_av1.c:66
d3d12va_encode_av1_configure
static int d3d12va_encode_av1_configure(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:747
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
static 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
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
D3D12VAHWBaseEncodeAV1Opts
Definition: d3d12va_encode_av1.c:52
D3D12VAHWBaseEncodeAV1
Definition: d3d12va_encode_av1.c:46
MAX_PARAM_BUFFER_SIZE
@ MAX_PARAM_BUFFER_SIZE
Definition: vaapi_encode.h:47
opts
static AVDictionary * opts
Definition: movenc.c:51
AV1_INTERPOLATION_FILTER_SWITCHABLE
@ AV1_INTERPOLATION_FILTER_SWITCHABLE
Definition: av1.h:104
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: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:866
AV1_TX_MODE_SELECT
@ AV1_TX_MODE_SELECT
Definition: av1.h:183
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_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:801
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:874
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:1726
FFHWBaseEncodePicture::nb_refs
int nb_refs[MAX_REFERENCE_LIST_NUM]
Definition: hw_base_encode.h:97
i
#define i(width, name, range_min, range_max)
Definition: cbs_h264.c:63
D3D12VAEncodeProfile
Definition: d3d12va_encode.h:66
size
int size
Definition: twinvq_data.h:10344
AV1_NUM_REF_FRAMES
@ AV1_NUM_REF_FRAMES
Definition: av1.h:84
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
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
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
AV1_CSP_COLOCATED
@ AV1_CSP_COLOCATED
Definition: av1.h:135
FF_HW_PICTURE_TYPE_B
@ FF_HW_PICTURE_TYPE_B
Definition: hw_base_encode.h:42
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
AV1RawSequenceHeader::enable_dual_filter
uint8_t enable_dual_filter
Definition: cbs_av1.h:120
AV1_FRAME_KEY
@ AV1_FRAME_KEY
Definition: av1.h:53
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:1029
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
AV1RawOBU::obu
union AV1RawOBU::@81 obu
avcodec.h
d3d12va_encode_av1_close
static int d3d12va_encode_av1_close(AVCodecContext *avctx)
Definition: d3d12va_encode_av1.c:1089
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
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:851
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:1190
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
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
D3D12VAEncodeContext::gop
D3D12_VIDEO_ENCODER_SEQUENCE_GOP_STRUCTURE gop
Definition: d3d12va_encode.h:268
AV1_FRAME_INTER
@ AV1_FRAME_INTER
Definition: av1.h:54
AV1RawFrameHeader::delta_q_v_ac
int8_t delta_q_v_ac
Definition: cbs_av1.h:245
desc
const char * desc
Definition: libsvtav1.c:82
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
D3D12VAHWBaseEncodeAV1Opts::enable_128x128_superblock
int enable_128x128_superblock
Definition: d3d12va_encode_av1.c:62
mem.h
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
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:1865
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:1063
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:1721
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
FF_HW_PICTURE_TYPE_IDR
@ FF_HW_PICTURE_TYPE_IDR
Definition: hw_base_encode.h:39
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
pkt
static AVPacket * pkt
Definition: demux_decode.c:55
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
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
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:640
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
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
FF_HW_PICTURE_TYPE_P
@ FF_HW_PICTURE_TYPE_P
Definition: hw_base_encode.h:41
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