FFmpeg
vaapi_encode_av1.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 Intel Corporation
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <va/va.h>
22 #include <va/va_enc_av1.h>
23 
24 #include "libavutil/pixdesc.h"
25 #include "libavutil/opt.h"
27 
28 #include "cbs_av1.h"
29 #include "put_bits.h"
30 #include "codec_internal.h"
31 #include "av1_levels.h"
32 #include "vaapi_encode.h"
33 
34 #define AV1_MAX_QUANT 255
35 
36 typedef struct VAAPIEncodeAV1Picture {
38  int slot;
40 
41 typedef struct VAAPIEncodeAV1Context {
43  AV1RawOBU sh; /**< sequence header.*/
44  AV1RawOBU fh; /**< frame header.*/
45  AV1RawOBU mh[4]; /**< metadata header.*/
46  int nb_mh;
49  VAConfigAttribValEncAV1 attr;
50  VAConfigAttribValEncAV1Ext1 attr_ext1;
51  VAConfigAttribValEncAV1Ext2 attr_ext2;
52 
53  char sh_data[MAX_PARAM_BUFFER_SIZE]; /**< coded sequence header data. */
54  size_t sh_data_len; /**< bit length of sh_data. */
55  char fh_data[MAX_PARAM_BUFFER_SIZE]; /**< coded frame header data. */
56  size_t fh_data_len; /**< bit length of fh_data. */
57 
58  uint8_t uniform_tile;
60  int sb_cols;
61  int sb_rows;
68 
73 
74  int q_idx_idr;
75  int q_idx_p;
76  int q_idx_b;
77 
78  /** bit positions in current frame header */
83 
84  /** user options */
85  int profile;
86  int level;
87  int tier;
91 
93  PutBitContext *pbc, int length,
94  const char *str, const int *subscripts,
95  int64_t value)
96 {
97  VAAPIEncodeAV1Context *priv = ctx;
98  int position;
99 
100  position = put_bits_count(pbc);
101  av_assert0(position >= length);
102 
103  if (!strcmp(str, "base_q_idx"))
104  priv->qindex_offset = position - length;
105  else if (!strcmp(str, "loop_filter_level[0]"))
106  priv->loopfilter_offset = position - length;
107  else if (!strcmp(str, "cdef_damping_minus_3"))
108  priv->cdef_start_offset = position - length;
109  else if (!strcmp(str, "cdef_uv_sec_strength[i]"))
110  priv->cdef_param_size = position - priv->cdef_start_offset;
111 }
112 
114 {
115  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
116  VAAPIEncodeAV1Context *priv = avctx->priv_data;
117 
118  // Surfaces must be aligned to superblock boundaries.
119  base_ctx->surface_width = FFALIGN(avctx->width, priv->use_128x128_superblock ? 128 : 64);
120  base_ctx->surface_height = FFALIGN(avctx->height, priv->use_128x128_superblock ? 128 : 64);
121 
122  return 0;
123 }
124 
126 {
127  VAAPIEncodeContext *ctx = avctx->priv_data;
128  VAAPIEncodeAV1Context *priv = avctx->priv_data;
129  int ret;
130 
131  ret = ff_cbs_init(&priv->cbc, AV_CODEC_ID_AV1, avctx);
132  if (ret < 0)
133  return ret;
134  priv->cbc->trace_enable = 1;
135  priv->cbc->trace_level = AV_LOG_DEBUG;
136  priv->cbc->trace_context = ctx;
138 
139  if (ctx->rc_mode->quality) {
140  priv->q_idx_p = av_clip(ctx->rc_quality, 0, AV1_MAX_QUANT);
141  if (fabs(avctx->i_quant_factor) > 0.0)
142  priv->q_idx_idr =
143  av_clip((fabs(avctx->i_quant_factor) * priv->q_idx_p +
144  avctx->i_quant_offset) + 0.5,
145  0, AV1_MAX_QUANT);
146  else
147  priv->q_idx_idr = priv->q_idx_p;
148 
149  if (fabs(avctx->b_quant_factor) > 0.0)
150  priv->q_idx_b =
151  av_clip((fabs(avctx->b_quant_factor) * priv->q_idx_p +
152  avctx->b_quant_offset) + 0.5,
153  0, AV1_MAX_QUANT);
154  else
155  priv->q_idx_b = priv->q_idx_p;
156  } else {
157  /** Arbitrary value */
158  priv->q_idx_idr = priv->q_idx_p = priv->q_idx_b = 128;
159  }
160 
161  ctx->roi_quant_range = AV1_MAX_QUANT;
162 
163  return 0;
164 }
165 
168  uint8_t type,
169  void *obu_unit)
170 {
171  int ret;
172 
174  type, obu_unit, NULL);
175  if (ret < 0) {
176  av_log(avctx, AV_LOG_ERROR, "Failed to add OBU unit: "
177  "type = %d.\n", type);
178  return ret;
179  }
180 
181  return 0;
182 }
183 
185  char *data, size_t *data_len,
187 {
188  VAAPIEncodeAV1Context *priv = avctx->priv_data;
189  int ret;
190 
191  ret = ff_cbs_write_fragment_data(priv->cbc, bs);
192  if (ret < 0) {
193  av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
194  return ret;
195  }
196 
197  if ((size_t)8 * MAX_PARAM_BUFFER_SIZE < 8 * bs->data_size - bs->data_bit_padding) {
198  av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
199  "%zu < %zu.\n", (size_t)8 * MAX_PARAM_BUFFER_SIZE,
200  8 * bs->data_size - bs->data_bit_padding);
201  return AVERROR(ENOSPC);
202  }
203 
204  memcpy(data, bs->data, bs->data_size);
205  *data_len = 8 * bs->data_size - bs->data_bit_padding;
206 
207  return 0;
208 }
209 
210 static int tile_log2(int blkSize, int target) {
211  int k;
212  for (k = 0; (blkSize << k) < target; k++);
213  return k;
214 }
215 
217 {
218  VAAPIEncodeAV1Context *priv = avctx->priv_data;
219  int mi_cols, mi_rows, sb_shift, sb_size;
220  int max_tile_area_sb, max_tile_area_sb_varied;
221  int tile_width_sb, tile_height_sb, widest_tile_sb;
222  int tile_cols, tile_rows;
223  int min_log2_tiles;
224  int i;
225 
226  if (priv->tile_cols > AV1_MAX_TILE_COLS ||
227  priv->tile_rows > AV1_MAX_TILE_ROWS) {
228  av_log(avctx, AV_LOG_ERROR, "Invalid tile number %dx%d, should less than %dx%d.\n",
230  return AVERROR(EINVAL);
231  }
232 
233  mi_cols = 2 * ((avctx->width + 7) >> 3);
234  mi_rows = 2 * ((avctx->height + 7) >> 3);
235  priv->sb_cols = priv->use_128x128_superblock ?
236  ((mi_cols + 31) >> 5) : ((mi_cols + 15) >> 4);
237  priv->sb_rows = priv->use_128x128_superblock ?
238  ((mi_rows + 31) >> 5) : ((mi_rows + 15) >> 4);
239  sb_shift = priv->use_128x128_superblock ? 5 : 4;
240  sb_size = sb_shift + 2;
241  priv->max_tile_width_sb = AV1_MAX_TILE_WIDTH >> sb_size;
242  max_tile_area_sb = AV1_MAX_TILE_AREA >> (2 * sb_size);
243 
247  min_log2_tiles = FFMAX(priv->min_log2_tile_cols,
248  tile_log2(max_tile_area_sb, priv->sb_rows * priv->sb_cols));
249 
250  tile_cols = av_clip(priv->tile_cols, (priv->sb_cols + priv->max_tile_width_sb - 1) / priv->max_tile_width_sb, priv->sb_cols);
251 
252  if (!priv->tile_cols)
253  priv->tile_cols = tile_cols;
254  else if (priv->tile_cols != tile_cols){
255  av_log(avctx, AV_LOG_ERROR, "Invalid tile cols %d, should be in range of %d~%d\n",
256  priv->tile_cols,
257  (priv->sb_cols + priv->max_tile_width_sb - 1) / priv->max_tile_width_sb,
258  priv->sb_cols);
259  return AVERROR(EINVAL);
260  }
261 
262  priv->tile_cols_log2 = tile_log2(1, priv->tile_cols);
263  tile_width_sb = (priv->sb_cols + (1 << priv->tile_cols_log2) - 1) >>
264  priv->tile_cols_log2;
265 
266  if (priv->tile_rows > priv->sb_rows) {
267  av_log(avctx, AV_LOG_ERROR, "Invalid tile rows %d, should be less than %d.\n",
268  priv->tile_rows, priv->sb_rows);
269  return AVERROR(EINVAL);
270  }
271 
272  /** Try user setting tile rows number first. */
273  tile_rows = priv->tile_rows ? priv->tile_rows : 1;
274  for (; tile_rows <= priv->sb_rows && tile_rows <= AV1_MAX_TILE_ROWS; tile_rows++) {
275  /** try uniformed tile. */
276  priv->tile_rows_log2 = tile_log2(1, tile_rows);
277  if ((priv->sb_cols + tile_width_sb - 1) / tile_width_sb == priv->tile_cols) {
278  for (i = 0; i < priv->tile_cols - 1; i++)
279  priv->width_in_sbs_minus_1[i] = tile_width_sb - 1;
280  priv->width_in_sbs_minus_1[i] = priv->sb_cols - (priv->tile_cols - 1) * tile_width_sb - 1;
281 
282  tile_height_sb = (priv->sb_rows + (1 << priv->tile_rows_log2) - 1) >>
283  priv->tile_rows_log2;
284 
285  if ((priv->sb_rows + tile_height_sb - 1) / tile_height_sb == tile_rows &&
286  tile_height_sb <= max_tile_area_sb / tile_width_sb) {
287  for (i = 0; i < tile_rows - 1; i++)
288  priv->height_in_sbs_minus_1[i] = tile_height_sb - 1;
289  priv->height_in_sbs_minus_1[i] = priv->sb_rows - (tile_rows - 1) * tile_height_sb - 1;
290 
291  priv->uniform_tile = 1;
292  priv->min_log2_tile_rows = FFMAX(min_log2_tiles - priv->tile_cols_log2, 0);
293 
294  break;
295  }
296  }
297 
298  /** try non-uniformed tile. */
299  widest_tile_sb = 0;
300  for (i = 0; i < priv->tile_cols; i++) {
301  priv->width_in_sbs_minus_1[i] = (i + 1) * priv->sb_cols / priv->tile_cols - i * priv->sb_cols / priv->tile_cols - 1;
302  widest_tile_sb = FFMAX(widest_tile_sb, priv->width_in_sbs_minus_1[i] + 1);
303  }
304 
305  if (min_log2_tiles)
306  max_tile_area_sb_varied = (priv->sb_rows * priv->sb_cols) >> (min_log2_tiles + 1);
307  else
308  max_tile_area_sb_varied = priv->sb_rows * priv->sb_cols;
309  priv->max_tile_height_sb = FFMAX(1, max_tile_area_sb_varied / widest_tile_sb);
310 
311  if (tile_rows == av_clip(tile_rows, (priv->sb_rows + priv->max_tile_height_sb - 1) / priv->max_tile_height_sb, priv->sb_rows)) {
312  for (i = 0; i < tile_rows; i++)
313  priv->height_in_sbs_minus_1[i] = (i + 1) * priv->sb_rows / tile_rows - i * priv->sb_rows / tile_rows - 1;
314 
315  break;
316  }
317 
318  /** Return invalid parameter if explicit tile rows is set. */
319  if (priv->tile_rows) {
320  av_log(avctx, AV_LOG_ERROR, "Invalid tile rows %d.\n", priv->tile_rows);
321  return AVERROR(EINVAL);
322  }
323  }
324 
325  priv->tile_rows = tile_rows;
326  av_log(avctx, AV_LOG_DEBUG, "Setting tile cols/rows to %d/%d.\n",
327  priv->tile_cols, priv->tile_rows);
328 
329  /** check if tile cols/rows is supported by driver. */
330  if (priv->attr_ext2.bits.max_tile_num_minus1) {
331  if ((priv->tile_cols * priv->tile_rows - 1) > priv->attr_ext2.bits.max_tile_num_minus1) {
332  av_log(avctx, AV_LOG_ERROR, "Unsupported tile num %d * %d = %d by driver, "
333  "should be at most %d.\n", priv->tile_cols, priv->tile_rows,
334  priv->tile_cols * priv->tile_rows,
335  priv->attr_ext2.bits.max_tile_num_minus1 + 1);
336  return AVERROR(EINVAL);
337  }
338  }
339 
340  /** check if tile group numbers is valid. */
341  if (priv->tile_groups > priv->tile_cols * priv->tile_rows) {
342  av_log(avctx, AV_LOG_WARNING, "Invalid tile groups number %d, "
343  "correct to %d.\n", priv->tile_groups, priv->tile_cols * priv->tile_rows);
344  priv->tile_groups = priv->tile_cols * priv->tile_rows;
345  }
346 
347  return 0;
348 }
349 
351  char *data, size_t *data_len)
352 {
353  VAAPIEncodeAV1Context *priv = avctx->priv_data;
354 
355  memcpy(data, &priv->sh_data, MAX_PARAM_BUFFER_SIZE * sizeof(char));
356  *data_len = priv->sh_data_len;
357 
358  return 0;
359 }
360 
362 {
363  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
364  VAAPIEncodeContext *ctx = avctx->priv_data;
365  VAAPIEncodeAV1Context *priv = avctx->priv_data;
366  AV1RawOBU *sh_obu = &priv->sh;
368  VAEncSequenceParameterBufferAV1 *vseq = ctx->codec_sequence_params;
369  CodedBitstreamFragment *obu = &priv->current_obu;
370  const AVPixFmtDescriptor *desc;
371  int ret;
372 
373  memset(sh_obu, 0, sizeof(*sh_obu));
375 
377  av_assert0(desc);
378 
379  sh->seq_profile = avctx->profile;
382  sh->frame_width_bits_minus_1 = av_log2(avctx->width);
384  sh->max_frame_width_minus_1 = avctx->width - 1;
385  sh->max_frame_height_minus_1 = avctx->height - 1;
386  sh->seq_tier[0] = priv->tier;
387  /** enable order hint and reserve maximum 8 bits for it by default. */
388  sh->enable_order_hint = 1;
389  sh->order_hint_bits_minus_1 = 7;
390 
392  .high_bitdepth = desc->comp[0].depth == 8 ? 0 : 1,
393  .color_primaries = avctx->color_primaries,
394  .transfer_characteristics = avctx->color_trc,
395  .matrix_coefficients = avctx->colorspace,
396  .color_description_present_flag = (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
397  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
400  .subsampling_x = desc->log2_chroma_w,
401  .subsampling_y = desc->log2_chroma_h,
402  };
403 
404  switch (avctx->chroma_sample_location) {
405  case AVCHROMA_LOC_LEFT:
407  break;
410  break;
411  default:
413  break;
414  }
415 
416  if (avctx->level != AV_LEVEL_UNKNOWN) {
417  sh->seq_level_idx[0] = avctx->level;
418  } else {
419  const AV1LevelDescriptor *level;
420  float framerate;
421 
422  if (avctx->framerate.num > 0 && avctx->framerate.den > 0)
423  framerate = avctx->framerate.num / avctx->framerate.den;
424  else
425  framerate = 0;
426 
427  level = ff_av1_guess_level(avctx->bit_rate, priv->tier,
428  base_ctx->surface_width, base_ctx->surface_height,
429  priv->tile_rows * priv->tile_cols,
430  priv->tile_cols, framerate);
431  if (level) {
432  av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
433  sh->seq_level_idx[0] = level->level_idx;
434  } else {
435  av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
436  "any normal level, using maximum parameters level by default.\n");
437  sh->seq_level_idx[0] = 31;
438  sh->seq_tier[0] = 1;
439  }
440  }
441  vseq->seq_profile = sh->seq_profile;
442  vseq->seq_level_idx = sh->seq_level_idx[0];
443  vseq->seq_tier = sh->seq_tier[0];
444  vseq->order_hint_bits_minus_1 = sh->order_hint_bits_minus_1;
445  vseq->intra_period = base_ctx->gop_size;
446  vseq->ip_period = base_ctx->b_per_p + 1;
447 
448  vseq->seq_fields.bits.enable_order_hint = sh->enable_order_hint;
449 
450  if (!(ctx->va_rc_mode & VA_RC_CQP)) {
451  vseq->bits_per_second = ctx->va_bit_rate;
452  vseq->seq_fields.bits.enable_cdef = sh->enable_cdef = 1;
453  }
454 
456  if (ret < 0)
457  goto end;
458 
459  ret = vaapi_encode_av1_write_obu(avctx, priv->sh_data, &priv->sh_data_len, obu);
460  if (ret < 0)
461  goto end;
462 
463 end:
465  return ret;
466 }
467 
470 {
471  VAAPIEncodeContext *ctx = avctx->priv_data;
472  VAAPIEncodeAV1Context *priv = avctx->priv_data;
473  VAAPIEncodePicture *vaapi_pic = pic->priv;
474  VAAPIEncodeAV1Picture *hpic = pic->codec_priv;
475  AV1RawOBU *fh_obu = &priv->fh;
476  AV1RawFrameHeader *fh = &fh_obu->obu.frame.header;
477  VAEncPictureParameterBufferAV1 *vpic = vaapi_pic->codec_picture_params;
478  CodedBitstreamFragment *obu = &priv->current_obu;
480  VAAPIEncodeAV1Picture *href;
481  int slot, i;
482  int ret;
483  static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] =
484  { 1, 0, 0, 0, -1, 0, -1, -1 };
485 
486  memset(fh_obu, 0, sizeof(*fh_obu));
487  vaapi_pic->nb_slices = priv->tile_groups;
488  vaapi_pic->non_independent_frame = pic->encode_order < pic->display_order;
490  fh_obu->header.obu_has_size_field = 1;
491 
492  switch (pic->type) {
494  av_assert0(pic->nb_refs[0] == 0 || pic->nb_refs[1]);
496  fh->refresh_frame_flags = 0xFF;
497  fh->base_q_idx = priv->q_idx_idr;
498  hpic->slot = 0;
499  hpic->last_idr_frame = pic->display_order;
500  break;
502  av_assert0(pic->nb_refs[0]);
504  fh->base_q_idx = priv->q_idx_p;
505  ref = pic->refs[0][pic->nb_refs[0] - 1];
506  href = ref->codec_priv;
507  hpic->slot = !href->slot;
508  hpic->last_idr_frame = href->last_idr_frame;
509  fh->refresh_frame_flags = 1 << hpic->slot;
510 
511  /** set the nearest frame in L0 as all reference frame. */
512  for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
513  fh->ref_frame_idx[i] = href->slot;
514  }
515  fh->primary_ref_frame = href->slot;
516  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
517  vpic->ref_frame_ctrl_l0.fields.search_idx0 = AV1_REF_FRAME_LAST;
518 
519  /** set the 2nd nearest frame in L0 as Golden frame. */
520  if (pic->nb_refs[0] > 1) {
521  ref = pic->refs[0][pic->nb_refs[0] - 2];
522  href = ref->codec_priv;
523  fh->ref_frame_idx[3] = href->slot;
524  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
525  vpic->ref_frame_ctrl_l0.fields.search_idx1 = AV1_REF_FRAME_GOLDEN;
526  }
527  break;
529  av_assert0(pic->nb_refs[0] && pic->nb_refs[1]);
531  fh->base_q_idx = priv->q_idx_b;
532  fh->refresh_frame_flags = 0x0;
533  fh->reference_select = 1;
534 
535  /** B frame will not be referenced, disable its recon frame. */
536  vpic->picture_flags.bits.disable_frame_recon = 1;
537 
538  /** Use LAST_FRAME and BWDREF_FRAME for reference. */
539  vpic->ref_frame_ctrl_l0.fields.search_idx0 = AV1_REF_FRAME_LAST;
540  vpic->ref_frame_ctrl_l1.fields.search_idx0 = AV1_REF_FRAME_BWDREF;
541 
542  ref = pic->refs[0][pic->nb_refs[0] - 1];
543  href = ref->codec_priv;
544  hpic->last_idr_frame = href->last_idr_frame;
545  fh->primary_ref_frame = href->slot;
546  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
547  for (i = 0; i < AV1_REF_FRAME_GOLDEN; i++) {
548  fh->ref_frame_idx[i] = href->slot;
549  }
550 
551  ref = pic->refs[1][pic->nb_refs[1] - 1];
552  href = ref->codec_priv;
553  fh->ref_order_hint[href->slot] = ref->display_order - href->last_idr_frame;
555  fh->ref_frame_idx[i] = href->slot;
556  }
557  break;
558  default:
559  av_assert0(0 && "invalid picture type");
560  }
561 
562  fh->show_frame = pic->display_order <= pic->encode_order;
564  fh->frame_width_minus_1 = avctx->width - 1;
565  fh->frame_height_minus_1 = avctx->height - 1;
568  fh->order_hint = pic->display_order - hpic->last_idr_frame;
569  fh->tile_cols = priv->tile_cols;
570  fh->tile_rows = priv->tile_rows;
571  fh->tile_cols_log2 = priv->tile_cols_log2;
572  fh->tile_rows_log2 = priv->tile_rows_log2;
574  fh->tile_size_bytes_minus1 = priv->attr_ext2.bits.tile_size_bytes_minus1;
575 
576  /** ignore ONLY_4x4 mode for codedlossless is not fully implemented. */
577  if (priv->attr_ext2.bits.tx_mode_support & 0x04)
579  else if (priv->attr_ext2.bits.tx_mode_support & 0x02)
581  else {
582  av_log(avctx, AV_LOG_ERROR, "No available tx mode found.\n");
583  return AVERROR(EINVAL);
584  }
585 
586  for (i = 0; i < fh->tile_cols; i++)
587  fh->width_in_sbs_minus_1[i] = vpic->width_in_sbs_minus_1[i] = priv->width_in_sbs_minus_1[i];
588 
589  for (i = 0; i < fh->tile_rows; i++)
590  fh->height_in_sbs_minus_1[i] = vpic->height_in_sbs_minus_1[i] = priv->height_in_sbs_minus_1[i];
591 
592  memcpy(fh->loop_filter_ref_deltas, default_loop_filter_ref_deltas,
593  AV1_TOTAL_REFS_PER_FRAME * sizeof(int8_t));
594 
595  if (fh->frame_type == AV1_FRAME_KEY && fh->show_frame) {
596  fh->error_resilient_mode = 1;
597  }
598 
601 
602  vpic->base_qindex = fh->base_q_idx;
603  vpic->frame_width_minus_1 = fh->frame_width_minus_1;
604  vpic->frame_height_minus_1 = fh->frame_height_minus_1;
605  vpic->primary_ref_frame = fh->primary_ref_frame;
606  vpic->reconstructed_frame = vaapi_pic->recon_surface;
607  vpic->coded_buf = vaapi_pic->output_buffer;
608  vpic->tile_cols = fh->tile_cols;
609  vpic->tile_rows = fh->tile_rows;
610  vpic->order_hint = fh->order_hint;
611 #if VA_CHECK_VERSION(1, 15, 0)
612  vpic->refresh_frame_flags = fh->refresh_frame_flags;
613 #endif
614 
615  vpic->picture_flags.bits.enable_frame_obu = 0;
616  vpic->picture_flags.bits.frame_type = fh->frame_type;
617  vpic->picture_flags.bits.reduced_tx_set = fh->reduced_tx_set;
618  vpic->picture_flags.bits.error_resilient_mode = fh->error_resilient_mode;
619 
620  /** let driver decide to use single or compound reference prediction mode. */
621  vpic->mode_control_flags.bits.reference_mode = fh->reference_select ? 2 : 0;
622  vpic->mode_control_flags.bits.tx_mode = fh->tx_mode;
623 
624  vpic->tile_group_obu_hdr_info.bits.obu_has_size_field = 1;
625 
626  /** set reference. */
627  for (i = 0; i < AV1_REFS_PER_FRAME; i++)
628  vpic->ref_frame_idx[i] = fh->ref_frame_idx[i];
629 
630  for (i = 0; i < FF_ARRAY_ELEMS(vpic->reference_frames); i++)
631  vpic->reference_frames[i] = VA_INVALID_SURFACE;
632 
633  for (i = 0; i < MAX_REFERENCE_LIST_NUM; i++) {
634  for (int j = 0; j < pic->nb_refs[i]; j++) {
635  FFHWBaseEncodePicture *ref_pic = pic->refs[i][j];
636 
637  slot = ((VAAPIEncodeAV1Picture*)ref_pic->codec_priv)->slot;
638  av_assert0(vpic->reference_frames[slot] == VA_INVALID_SURFACE);
639 
640  vpic->reference_frames[slot] = ((VAAPIEncodePicture *)ref_pic->priv)->recon_surface;
641  }
642  }
643 
644  ret = vaapi_encode_av1_add_obu(avctx, obu, AV1_OBU_FRAME_HEADER, &priv->fh);
645  if (ret < 0)
646  goto end;
647 
648  ret = vaapi_encode_av1_write_obu(avctx, priv->fh_data, &priv->fh_data_len, obu);
649  if (ret < 0)
650  goto end;
651 
652  if (!(ctx->va_rc_mode & VA_RC_CQP)) {
653  vpic->min_base_qindex = av_clip(avctx->qmin, 1, AV1_MAX_QUANT);
654  vpic->max_base_qindex = av_clip(avctx->qmax, 1, AV1_MAX_QUANT);
655 
656  vpic->bit_offset_qindex = priv->qindex_offset;
657  vpic->bit_offset_loopfilter_params = priv->loopfilter_offset;
658  vpic->bit_offset_cdef_params = priv->cdef_start_offset;
659  vpic->size_in_bits_cdef_params = priv->cdef_param_size;
660  vpic->size_in_bits_frame_hdr_obu = priv->fh_data_len;
661  vpic->byte_offset_frame_hdr_obu_size = (((pic->type == FF_HW_PICTURE_TYPE_IDR) ?
662  priv->sh_data_len / 8 : 0) +
663  (fh_obu->header.obu_extension_flag ?
664  2 : 1));
665  }
666 
667  priv->nb_mh = 0;
668 
669  if (pic->type == FF_HW_PICTURE_TYPE_IDR) {
670  AVFrameSideData *sd =
673  if (sd) {
676  if (mdm->has_primaries && mdm->has_luminance) {
677  AV1RawOBU *obu = &priv->mh[priv->nb_mh++];
678  AV1RawMetadata *md = &obu->obu.metadata;
679  AV1RawMetadataHDRMDCV *mdcv = &md->metadata.hdr_mdcv;
680  const int chroma_den = 1 << 16;
681  const int max_luma_den = 1 << 8;
682  const int min_luma_den = 1 << 14;
683 
684  memset(obu, 0, sizeof(*obu));
686  md->metadata_type = AV1_METADATA_TYPE_HDR_MDCV;
687 
688  for (i = 0; i < 3; i++) {
689  mdcv->primary_chromaticity_x[i] =
690  av_rescale(mdm->display_primaries[i][0].num, chroma_den,
691  mdm->display_primaries[i][0].den);
692  mdcv->primary_chromaticity_y[i] =
693  av_rescale(mdm->display_primaries[i][1].num, chroma_den,
694  mdm->display_primaries[i][1].den);
695  }
696 
698  av_rescale(mdm->white_point[0].num, chroma_den,
699  mdm->white_point[0].den);
701  av_rescale(mdm->white_point[1].num, chroma_den,
702  mdm->white_point[1].den);
703 
704  mdcv->luminance_max =
705  av_rescale(mdm->max_luminance.num, max_luma_den,
706  mdm->max_luminance.den);
707  mdcv->luminance_min =
708  av_rescale(mdm->min_luminance.num, min_luma_den,
709  mdm->min_luminance.den);
710  }
711  }
712 
715  if (sd) {
717  AV1RawOBU *obu = &priv->mh[priv->nb_mh++];
718  AV1RawMetadata *md = &obu->obu.metadata;
719  AV1RawMetadataHDRCLL *cll = &md->metadata.hdr_cll;
720 
721  memset(obu, 0, sizeof(*obu));
722  obu->header.obu_type = AV1_OBU_METADATA;
723  md->metadata_type = AV1_METADATA_TYPE_HDR_CLL;
724  cll->max_cll = cllm->MaxCLL;
725  cll->max_fall = cllm->MaxFALL;
726  }
727  }
728 
729 end:
731  return ret;
732 }
733 
736  VAAPIEncodeSlice *slice)
737 {
738  VAAPIEncodeAV1Context *priv = avctx->priv_data;
739  VAEncTileGroupBufferAV1 *vslice = slice->codec_slice_params;
740  CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data;
741  int div;
742 
743  /** Set tile group info. */
744  div = priv->tile_cols * priv->tile_rows / priv->tile_groups;
745  vslice->tg_start = slice->index * div;
746  if (slice->index == (priv->tile_groups - 1)) {
747  vslice->tg_end = priv->tile_cols * priv->tile_rows - 1;
748  cbctx->seen_frame_header = 0;
749  } else {
750  vslice->tg_end = (slice->index + 1) * div - 1;
751  }
752 
753  return 0;
754 }
755 
758  char *data, size_t *data_len)
759 {
760  VAAPIEncodeAV1Context *priv = avctx->priv_data;
761  CodedBitstreamFragment *obu = &priv->current_obu;
762  CodedBitstreamAV1Context *cbctx = priv->cbc->priv_data;
763  AV1RawOBU *fh_obu = &priv->fh;
764  AV1RawFrameHeader *rep_fh = &fh_obu->obu.frame_header;
765  VAAPIEncodePicture *vaapi_pic = pic->priv;
766  VAAPIEncodeAV1Picture *href;
767  int ret = 0;
768 
769  vaapi_pic->tail_size = 0;
770  /** Pack repeat frame header. */
771  if (pic->display_order > pic->encode_order) {
772  memset(fh_obu, 0, sizeof(*fh_obu));
773  href = pic->refs[0][pic->nb_refs[0] - 1]->codec_priv;
775  fh_obu->header.obu_has_size_field = 1;
776 
777  rep_fh->show_existing_frame = 1;
778  rep_fh->frame_to_show_map_idx = href->slot == 0;
779  rep_fh->frame_type = AV1_FRAME_INTER;
780  rep_fh->frame_width_minus_1 = avctx->width - 1;
781  rep_fh->frame_height_minus_1 = avctx->height - 1;
782  rep_fh->render_width_minus_1 = rep_fh->frame_width_minus_1;
784 
785  cbctx->seen_frame_header = 0;
786 
787  ret = vaapi_encode_av1_add_obu(avctx, obu, AV1_OBU_FRAME_HEADER, &priv->fh);
788  if (ret < 0)
789  goto end;
790 
791  ret = vaapi_encode_av1_write_obu(avctx, vaapi_pic->tail_data, &vaapi_pic->tail_size, obu);
792  if (ret < 0)
793  goto end;
794 
795  vaapi_pic->tail_size /= 8;
796  }
797 
798  memcpy(data, &priv->fh_data, MAX_PARAM_BUFFER_SIZE * sizeof(char));
799  *data_len = priv->fh_data_len;
800 
801 end:
803  return ret;
804 }
805 
807  FFHWBaseEncodePicture *base_pic,
808  int index, int *type,
809  char *data, size_t *data_len)
810 {
811  VAAPIEncodeAV1Context *priv = avctx->priv_data;
812  CodedBitstreamFragment *obu = &priv->current_obu;
813  AV1RawOBU *mh_obu;
814  char mh_data[MAX_PARAM_BUFFER_SIZE];
815  size_t mh_data_len;
816  int ret = 0;
817 
818  if (index >= priv->nb_mh)
819  return AVERROR_EOF;
820 
821  mh_obu = &priv->mh[index];
822  ret = vaapi_encode_av1_add_obu(avctx, obu, AV1_OBU_METADATA, mh_obu);
823  if (ret < 0)
824  goto end;
825 
826  ret = vaapi_encode_av1_write_obu(avctx, mh_data, &mh_data_len, obu);
827  if (ret < 0)
828  goto end;
829 
830  memcpy(data, mh_data, MAX_PARAM_BUFFER_SIZE * sizeof(char));
831  *data_len = mh_data_len;
832  *type = VAEncPackedHeaderRawData;
833 
834 end:
836  return ret;
837 }
838 
840  { AV_PROFILE_AV1_MAIN, 8, 3, 1, 1, VAProfileAV1Profile0 },
841  { AV_PROFILE_AV1_MAIN, 10, 3, 1, 1, VAProfileAV1Profile0 },
843 };
844 
848  .default_quality = 25,
849 
850  .get_encoder_caps = &vaapi_encode_av1_get_encoder_caps,
851  .configure = &vaapi_encode_av1_configure,
852 
853  .sequence_header_type = VAEncPackedHeaderSequence,
854  .sequence_params_size = sizeof(VAEncSequenceParameterBufferAV1),
855  .init_sequence_params = &vaapi_encode_av1_init_sequence_params,
856  .write_sequence_header = &vaapi_encode_av1_write_sequence_header,
857 
858  .picture_priv_data_size = sizeof(VAAPIEncodeAV1Picture),
859  .picture_header_type = VAEncPackedHeaderPicture,
860  .picture_params_size = sizeof(VAEncPictureParameterBufferAV1),
861  .init_picture_params = &vaapi_encode_av1_init_picture_params,
862  .write_picture_header = &vaapi_encode_av1_write_picture_header,
863 
864  .slice_params_size = sizeof(VAEncTileGroupBufferAV1),
865  .init_slice_params = &vaapi_encode_av1_init_slice_params,
866 
867  .write_extra_header = &vaapi_encode_av1_write_extra_header,
868 };
869 
871 {
872  VAAPIEncodeContext *ctx = avctx->priv_data;
873  VAAPIEncodeAV1Context *priv = avctx->priv_data;
874  VAConfigAttrib attr;
875  VAStatus vas;
876  int ret;
877 
878  ctx->codec = &vaapi_encode_type_av1;
879 
880  ctx->desired_packed_headers =
881  VA_ENC_PACKED_HEADER_SEQUENCE |
882  VA_ENC_PACKED_HEADER_PICTURE |
883  VA_ENC_PACKED_HEADER_MISC; // Metadata
884 
885  if (avctx->profile == AV_PROFILE_UNKNOWN)
886  avctx->profile = priv->profile;
887  if (avctx->level == AV_LEVEL_UNKNOWN)
888  avctx->level = priv->level;
889 
890  if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0x1f) {
891  av_log(avctx, AV_LOG_ERROR, "Invalid level %d\n", avctx->level);
892  return AVERROR(EINVAL);
893  }
894 
895  ret = ff_vaapi_encode_init(avctx);
896  if (ret < 0)
897  return ret;
898 
899  attr.type = VAConfigAttribEncAV1;
900  vas = vaGetConfigAttributes(ctx->hwctx->display,
901  ctx->va_profile,
902  ctx->va_entrypoint,
903  &attr, 1);
904  if (vas != VA_STATUS_SUCCESS) {
905  av_log(avctx, AV_LOG_ERROR, "Failed to query "
906  "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
907  return AVERROR_EXTERNAL;
908  } else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
909  priv->attr.value = 0;
910  av_log(avctx, AV_LOG_WARNING, "Attribute type:%d is not "
911  "supported.\n", attr.type);
912  } else {
913  priv->attr.value = attr.value;
914  }
915 
916  attr.type = VAConfigAttribEncAV1Ext1;
917  vas = vaGetConfigAttributes(ctx->hwctx->display,
918  ctx->va_profile,
919  ctx->va_entrypoint,
920  &attr, 1);
921  if (vas != VA_STATUS_SUCCESS) {
922  av_log(avctx, AV_LOG_ERROR, "Failed to query "
923  "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
924  return AVERROR_EXTERNAL;
925  } else if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
926  priv->attr_ext1.value = 0;
927  av_log(avctx, AV_LOG_WARNING, "Attribute type:%d is not "
928  "supported.\n", attr.type);
929  } else {
930  priv->attr_ext1.value = attr.value;
931  }
932 
933  /** This attr provides essential indicators, return error if not support. */
934  attr.type = VAConfigAttribEncAV1Ext2;
935  vas = vaGetConfigAttributes(ctx->hwctx->display,
936  ctx->va_profile,
937  ctx->va_entrypoint,
938  &attr, 1);
939  if (vas != VA_STATUS_SUCCESS || attr.value == VA_ATTRIB_NOT_SUPPORTED) {
940  av_log(avctx, AV_LOG_ERROR, "Failed to query "
941  "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
942  return AVERROR_EXTERNAL;
943  } else {
944  priv->attr_ext2.value = attr.value;
945  }
946 
947  av_opt_set_int(priv->cbc->priv_data, "fixed_obu_size_length",
948  priv->attr_ext2.bits.obu_size_bytes_minus1 + 1, 0);
949 
951  if (ret < 0)
952  return ret;
953 
954  return 0;
955 }
956 
958 {
959  VAAPIEncodeAV1Context *priv = avctx->priv_data;
960 
962  ff_cbs_close(&priv->cbc);
963 
964  return ff_vaapi_encode_close(avctx);
965 }
966 
967 #define OFFSET(x) offsetof(VAAPIEncodeAV1Context, x)
968 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
969 
974  { "profile", "Set profile (seq_profile)",
976  { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xff, FLAGS, .unit = "profile" },
977 
978 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
979  { .i64 = value }, 0, 0, FLAGS, .unit = "profile"
980  { PROFILE("main", AV_PROFILE_AV1_MAIN) },
981  { PROFILE("high", AV_PROFILE_AV1_HIGH) },
982  { PROFILE("professional", AV_PROFILE_AV1_PROFESSIONAL) },
983 #undef PROFILE
984 
985  { "tier", "Set tier (seq_tier)",
986  OFFSET(tier), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS, .unit = "tier" },
987  { "main", NULL, 0, AV_OPT_TYPE_CONST,
988  { .i64 = 0 }, 0, 0, FLAGS, .unit = "tier" },
989  { "high", NULL, 0, AV_OPT_TYPE_CONST,
990  { .i64 = 1 }, 0, 0, FLAGS, .unit = "tier" },
991  { "level", "Set level (seq_level_idx)",
993  { .i64 = AV_LEVEL_UNKNOWN }, AV_LEVEL_UNKNOWN, 0x1f, FLAGS, .unit = "level" },
994 
995 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
996  { .i64 = value }, 0, 0, FLAGS, .unit = "level"
997  { LEVEL("2.0", 0) },
998  { LEVEL("2.1", 1) },
999  { LEVEL("3.0", 4) },
1000  { LEVEL("3.1", 5) },
1001  { LEVEL("4.0", 8) },
1002  { LEVEL("4.1", 9) },
1003  { LEVEL("5.0", 12) },
1004  { LEVEL("5.1", 13) },
1005  { LEVEL("5.2", 14) },
1006  { LEVEL("5.3", 15) },
1007  { LEVEL("6.0", 16) },
1008  { LEVEL("6.1", 17) },
1009  { LEVEL("6.2", 18) },
1010  { LEVEL("6.3", 19) },
1011 #undef LEVEL
1012 
1013  { "tiles", "Tile columns x rows (Use minimal tile column/row number automatically by default)",
1014  OFFSET(tile_cols), AV_OPT_TYPE_IMAGE_SIZE, { .str = NULL }, 0, 0, FLAGS },
1015  { "tile_groups", "Number of tile groups for encoding",
1016  OFFSET(tile_groups), AV_OPT_TYPE_INT, { .i64 = 1 }, 1, AV1_MAX_TILE_ROWS * AV1_MAX_TILE_COLS, FLAGS },
1017 
1018  { NULL },
1019 };
1020 
1022  { "b", "0" },
1023  { "bf", "2" },
1024  { "g", "120" },
1025  { "qmin", "1" },
1026  { "qmax", "255" },
1027  { NULL },
1028 };
1029 
1031  .class_name = "av1_vaapi",
1032  .item_name = av_default_item_name,
1033  .option = vaapi_encode_av1_options,
1034  .version = LIBAVUTIL_VERSION_INT,
1035 };
1036 
1038  .p.name = "av1_vaapi",
1039  CODEC_LONG_NAME("AV1 (VAAPI)"),
1040  .p.type = AVMEDIA_TYPE_VIDEO,
1041  .p.id = AV_CODEC_ID_AV1,
1042  .priv_data_size = sizeof(VAAPIEncodeAV1Context),
1045  .close = &vaapi_encode_av1_close,
1046  .p.priv_class = &vaapi_encode_av1_class,
1047  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE |
1049  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1051  .defaults = vaapi_encode_av1_defaults,
1052  .p.pix_fmts = (const enum AVPixelFormat[]) {
1055  },
1056  .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
1057  .hw_configs = ff_vaapi_encode_hw_configs,
1058  .p.wrapper_name = "vaapi",
1059 };
AVMasteringDisplayMetadata::has_primaries
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
Definition: mastering_display_metadata.h:62
AV1RawSequenceHeader::seq_force_integer_mv
uint8_t seq_force_integer_mv
Definition: cbs_av1.h:120
vaapi_encode_av1_init
static av_cold int vaapi_encode_av1_init(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:870
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
VAAPIEncodeSlice::codec_slice_params
void * codec_slice_params
Definition: vaapi_encode.h:62
AVMasteringDisplayMetadata::max_luminance
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:57
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
AV1RawFrameHeader::primary_ref_frame
uint8_t primary_ref_frame
Definition: cbs_av1.h:187
av_clip
#define av_clip
Definition: common.h:100
FF_HW_PICTURE_TYPE_IDR
@ FF_HW_PICTURE_TYPE_IDR
Definition: hw_base_encode.h:39
FLAGS
#define FLAGS
Definition: vaapi_encode_av1.c:968
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:43
AV1RawSequenceHeader::seq_level_idx
uint8_t seq_level_idx[AV1_MAX_OPERATING_POINTS]
Definition: cbs_av1.h:87
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
CodedBitstreamAV1Context::seen_frame_header
int seen_frame_header
Definition: cbs_av1.h:445
CodedBitstreamContext::priv_data
void * priv_data
Internal codec-specific data.
Definition: cbs.h:240
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:691
ff_av1_vaapi_encoder
const FFCodec ff_av1_vaapi_encoder
Definition: vaapi_encode_av1.c:1037
VAAPIEncodeAV1Context::max_log2_tile_rows
int max_log2_tile_rows
Definition: vaapi_encode_av1.c:72
AV1RawSequenceHeader
Definition: cbs_av1.h:73
AV1RawFrameHeader::show_frame
uint8_t show_frame
Definition: cbs_av1.h:172
tile_log2
static int tile_log2(int blkSize, int target)
Definition: vaapi_encode_av1.c:210
AV1_REF_FRAME_LAST
@ AV1_REF_FRAME_LAST
Definition: av1.h:63
av_frame_get_side_data
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:951
FFHWBaseEncodePicture::priv
void * priv
Definition: hw_base_encode.h:63
FFHWBaseEncodePicture::codec_priv
void * codec_priv
Definition: hw_base_encode.h:65
AV1RawMetadataHDRMDCV::primary_chromaticity_x
uint16_t primary_chromaticity_x[3]
Definition: cbs_av1.h:324
ff_cbs_fragment_free
av_cold void ff_cbs_fragment_free(CodedBitstreamFragment *frag)
Free the units array of a fragment in addition to what ff_cbs_fragment_reset does.
Definition: cbs.c:186
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:3170
AVERROR_EOF
#define AVERROR_EOF
End of file.
Definition: error.h:57
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:145
AV1_MAX_TILE_AREA
@ AV1_MAX_TILE_AREA
Definition: av1.h:80
VAAPIEncodePicture::tail_size
size_t tail_size
Byte length of tail_data.
Definition: vaapi_encode.h:97
AVMasteringDisplayMetadata::display_primaries
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
Definition: mastering_display_metadata.h:42
AVMasteringDisplayMetadata::has_luminance
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
Definition: mastering_display_metadata.h:67
AV1_TX_MODE_SELECT
@ AV1_TX_MODE_SELECT
Definition: av1.h:183
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
ff_cbs_insert_unit_content
int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, void *content_ref)
Insert a new unit into a fragment with the given content.
Definition: cbs.c:783
int64_t
long long int64_t
Definition: coverity.c:34
AV1_REFS_PER_FRAME
@ AV1_REFS_PER_FRAME
Definition: av1.h:85
VAAPIEncodeAV1Context::cdef_param_size
int cdef_param_size
Definition: vaapi_encode_av1.c:82
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
md
#define md
Definition: vf_colormatrix.c:101
VAAPIEncodeAV1Context::height_in_sbs_minus_1
uint8_t height_in_sbs_minus_1[AV1_MAX_TILE_ROWS]
Definition: vaapi_encode_av1.c:67
AVContentLightMetadata::MaxCLL
unsigned MaxCLL
Max content light level (cd/m^2).
Definition: mastering_display_metadata.h:111
VAAPIEncodeAV1Context::nb_mh
int nb_mh
Definition: vaapi_encode_av1.c:46
VAAPIEncodeAV1Context::fh_data
char fh_data[MAX_PARAM_BUFFER_SIZE]
coded frame header data.
Definition: vaapi_encode_av1.c:55
pixdesc.h
VAAPIEncodeAV1Context::cdef_start_offset
int cdef_start_offset
Definition: vaapi_encode_av1.c:81
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:684
AVCOL_RANGE_JPEG
@ AVCOL_RANGE_JPEG
Full range content.
Definition: pixfmt.h:717
ff_cbs_fragment_reset
void ff_cbs_fragment_reset(CodedBitstreamFragment *frag)
Free the units contained in a fragment as well as the fragment's own data buffer, but not the units a...
Definition: cbs.c:172
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:219
vaapi_encode_av1_set_tile
static int vaapi_encode_av1_set_tile(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:216
VAAPIEncodeSlice
Definition: vaapi_encode.h:56
AVOption
AVOption.
Definition: opt.h:429
AVCOL_TRC_UNSPECIFIED
@ AVCOL_TRC_UNSPECIFIED
Definition: pixfmt.h:614
AV1RawFrameHeader::uniform_tile_spacing_flag
uint8_t uniform_tile_spacing_flag
Definition: cbs_av1.h:215
data
const char data[16]
Definition: mxf.c:149
VAAPIEncodeAV1Context::current_obu
CodedBitstreamFragment current_obu
Definition: vaapi_encode_av1.c:48
AVCodecContext::b_quant_offset
float b_quant_offset
qscale offset between IP and B-frames
Definition: avcodec.h:817
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:35
FFCodec
Definition: codec_internal.h:127
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
base
uint8_t base
Definition: vp3data.h:128
VAAPIEncodeAV1Context::fh
AV1RawOBU fh
frame header.
Definition: vaapi_encode_av1.c:44
ff_vaapi_encode_close
av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
Definition: vaapi_encode.c:2275
VAAPIEncodeSlice::index
int index
Definition: vaapi_encode.h:57
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AV_PROFILE_AV1_PROFESSIONAL
#define AV_PROFILE_AV1_PROFESSIONAL
Definition: defs.h:171
AVCodecContext::qmax
int qmax
maximum quantizer
Definition: avcodec.h:1273
VAAPIEncodeAV1Context::common
VAAPIEncodeContext common
Definition: vaapi_encode_av1.c:42
AV1RawOBU::header
AV1RawOBUHeader header
Definition: cbs_av1.h:401
VAAPIEncodeAV1Context::q_idx_b
int q_idx_b
Definition: vaapi_encode_av1.c:76
VAAPIEncodeAV1Context::min_log2_tile_cols
int min_log2_tile_cols
Definition: vaapi_encode_av1.c:69
VAAPIEncodeAV1Context::qindex_offset
int qindex_offset
bit positions in current frame header
Definition: vaapi_encode_av1.c:79
AV1RawSequenceHeader::seq_profile
uint8_t seq_profile
Definition: cbs_av1.h:74
ff_cbs_close
av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:142
AV1RawFrame::header
AV1RawFrameHeader header
Definition: cbs_av1.h:306
AVContentLightMetadata
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
Definition: mastering_display_metadata.h:107
FFHWBaseEncodeContext
Definition: hw_base_encode.h:122
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:566
AV1RawColorConfig
Definition: cbs_av1.h:41
AV1_CSP_COLOCATED
@ AV1_CSP_COLOCATED
Definition: av1.h:135
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:826
AV1RawFrameHeader::loop_filter_ref_deltas
int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME]
Definition: cbs_av1.h:260
FFCodecDefault
Definition: codec_internal.h:97
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
AV1_CSP_VERTICAL
@ AV1_CSP_VERTICAL
Definition: av1.h:134
FFHWBaseEncodePicture::type
int type
Definition: hw_base_encode.h:78
vaapi_encode.h
AV1_OBU_FRAME_HEADER
@ AV1_OBU_FRAME_HEADER
Definition: av1.h:32
VAAPIEncodePicture
Definition: vaapi_encode.h:65
vaapi_encode_av1_profiles
static const VAAPIEncodeProfile vaapi_encode_av1_profiles[]
Definition: vaapi_encode_av1.c:839
VAAPIEncodePicture::non_independent_frame
int non_independent_frame
indicate if current frame is an independent frame that the coded data can be pushed to downstream dir...
Definition: vaapi_encode.h:93
FFHWBaseEncodePicture::input_image
AVFrame * input_image
Definition: hw_base_encode.h:83
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV1RawMetadataHDRMDCV
Definition: cbs_av1.h:323
AVRational::num
int num
Numerator.
Definition: rational.h:59
CodedBitstreamContext::trace_level
int trace_level
Log level to use for default trace output.
Definition: cbs.h:263
AV1RawFrameHeader::tx_mode
uint8_t tx_mode
Definition: cbs_av1.h:275
AV1RawFrameHeader::base_q_idx
uint8_t base_q_idx
Definition: cbs_av1.h:230
cbs_av1.h
AV1RawOBUHeader::obu_extension_flag
uint8_t obu_extension_flag
Definition: cbs_av1.h:32
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:677
VAAPIEncodeAV1Picture::last_idr_frame
int64_t last_idr_frame
Definition: vaapi_encode_av1.c:37
VAAPIEncodeAV1Picture::slot
int slot
Definition: vaapi_encode_av1.c:38
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:209
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
av_cold
#define av_cold
Definition: attributes.h:90
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
AV1_MAX_QUANT
#define AV1_MAX_QUANT
Definition: vaapi_encode_av1.c:34
vaapi_encode_av1_init_sequence_params
static int vaapi_encode_av1_init_sequence_params(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:361
VAAPIEncodePicture::codec_picture_params
void * codec_picture_params
Definition: vaapi_encode.h:83
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:122
FLAG_TIMESTAMP_NO_DELAY
#define FLAG_TIMESTAMP_NO_DELAY
Definition: vaapi_encode.h:42
VAAPIEncodeAV1Context::width_in_sbs_minus_1
uint8_t width_in_sbs_minus_1[AV1_MAX_TILE_COLS]
Definition: vaapi_encode_av1.c:66
AVMasteringDisplayMetadata::white_point
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
Definition: mastering_display_metadata.h:47
AV1RawFrameHeader::render_width_minus_1
uint16_t render_width_minus_1
Definition: cbs_av1.h:193
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:135
vaapi_encode_av1_write_sequence_header
static int vaapi_encode_av1_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: vaapi_encode_av1.c:350
AV1_MAX_TILE_COLS
@ AV1_MAX_TILE_COLS
Definition: av1.h:82
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition: codec.h:159
tile_rows
int tile_rows
Definition: h265_levels.c:217
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
AV1_METADATA_TYPE_HDR_CLL
@ AV1_METADATA_TYPE_HDR_CLL
Definition: av1.h:44
tile_cols
int tile_cols
Definition: av1_levels.c:73
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
AV1RawFrameHeader::frame_width_minus_1
uint16_t frame_width_minus_1
Definition: cbs_av1.h:188
FF_HW_PICTURE_TYPE_B
@ FF_HW_PICTURE_TYPE_B
Definition: hw_base_encode.h:42
ctx
AVFormatContext * ctx
Definition: movenc.c:49
vaapi_encode_av1_init_picture_params
static int vaapi_encode_av1_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: vaapi_encode_av1.c:468
ff_vaapi_encode_receive_packet
int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: vaapi_encode.c:2086
tier
int tier
Definition: av1_levels.c:48
AV1RawSequenceHeader::seq_tier
uint8_t seq_tier[AV1_MAX_OPERATING_POINTS]
Definition: cbs_av1.h:88
CodedBitstreamFragment::data_bit_padding
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
Definition: cbs.h:139
color_range
color_range
Definition: vf_selectivecolor.c:43
VAAPIEncodeAV1Context::tile_groups
int tile_groups
Definition: vaapi_encode_av1.c:89
AV1RawMetadataHDRCLL
Definition: cbs_av1.h:318
AVCOL_PRI_UNSPECIFIED
@ AVCOL_PRI_UNSPECIFIED
Definition: pixfmt.h:589
VAAPIEncodeType
Definition: vaapi_encode.h:265
vaapi_encode_av1_init_slice_params
static int vaapi_encode_av1_init_slice_params(AVCodecContext *avctx, FFHWBaseEncodePicture *base, VAAPIEncodeSlice *slice)
Definition: vaapi_encode_av1.c:734
PutBitContext
Definition: put_bits.h:50
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
FFHWBaseEncodeContext::b_per_p
int b_per_p
Definition: hw_base_encode.h:189
VAAPIEncodeContext
Definition: vaapi_encode.h:145
if
if(ret)
Definition: filter_design.txt:179
vaapi_encode_av1_trace_write_log
static void vaapi_encode_av1_trace_write_log(void *ctx, PutBitContext *pbc, int length, const char *str, const int *subscripts, int64_t value)
Definition: vaapi_encode_av1.c:92
framerate
float framerate
Definition: av1_levels.c:29
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AV1RawMetadata
Definition: cbs_av1.h:381
AV1RawOBU
Definition: cbs_av1.h:400
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
fabs
static __device__ float fabs(float a)
Definition: cuda_runtime.h:182
AV1RawFrameHeader::tile_size_bytes_minus1
uint8_t tile_size_bytes_minus1
Definition: cbs_av1.h:223
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:210
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:701
VAAPIEncodeAV1Context
Definition: vaapi_encode_av1.c:41
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:284
CodedBitstreamContext::trace_context
void * trace_context
User context pointer to pass to trace callbacks.
Definition: cbs.h:267
AV1RawFrameHeader
Definition: cbs_av1.h:165
AV1_TX_MODE_LARGEST
@ AV1_TX_MODE_LARGEST
Definition: av1.h:182
AVCHROMA_LOC_LEFT
@ AVCHROMA_LOC_LEFT
MPEG-2/4 4:2:0, H.264 default for 4:2:0.
Definition: pixfmt.h:738
AV_LEVEL_UNKNOWN
#define AV_LEVEL_UNKNOWN
Definition: defs.h:198
VAAPIEncodeType::profiles
const VAAPIEncodeProfile * profiles
Definition: vaapi_encode.h:268
AV1RawFrameHeader::width_in_sbs_minus_1
uint8_t width_in_sbs_minus_1[AV1_MAX_TILE_COLS]
Definition: cbs_av1.h:220
AVCHROMA_LOC_TOPLEFT
@ AVCHROMA_LOC_TOPLEFT
ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2.
Definition: pixfmt.h:740
vaapi_encode_av1_add_obu
static int vaapi_encode_av1_add_obu(AVCodecContext *avctx, CodedBitstreamFragment *au, uint8_t type, void *obu_unit)
Definition: vaapi_encode_av1.c:166
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:501
AV_OPT_TYPE_IMAGE_SIZE
@ AV_OPT_TYPE_IMAGE_SIZE
Underlying C type is two consecutive integers.
Definition: opt.h:303
MAX_PARAM_BUFFER_SIZE
@ MAX_PARAM_BUFFER_SIZE
Definition: vaapi_encode.h:47
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
AV1RawColorConfig::chroma_sample_position
uint8_t chroma_sample_position
Definition: cbs_av1.h:54
VAAPIEncodeAV1Context::attr_ext2
VAConfigAttribValEncAV1Ext2 attr_ext2
Definition: vaapi_encode_av1.c:51
AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
@ AV_FRAME_DATA_MASTERING_DISPLAY_METADATA
Mastering display metadata associated with a video frame.
Definition: frame.h:120
VAAPIEncodeAV1Context::cbc
CodedBitstreamContext * cbc
Definition: vaapi_encode_av1.c:47
AVCodecContext::level
int level
Encoding level descriptor.
Definition: avcodec.h:1794
AV1RawSequenceHeader::seq_force_screen_content_tools
uint8_t seq_force_screen_content_tools
Definition: cbs_av1.h:118
index
int index
Definition: gxfenc.c:90
av_opt_set_int
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
Definition: opt.c:872
AV1RawSequenceHeader::max_frame_height_minus_1
uint16_t max_frame_height_minus_1
Definition: cbs_av1.h:99
vaapi_encode_av1_close
static av_cold int vaapi_encode_av1_close(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:957
VAAPIEncodeAV1Context::sh
AV1RawOBU sh
sequence header.
Definition: vaapi_encode_av1.c:43
AV1_REF_FRAME_BWDREF
@ AV1_REF_FRAME_BWDREF
Definition: av1.h:67
AV1_CSP_UNKNOWN
@ AV1_CSP_UNKNOWN
Definition: av1.h:133
AV1RawFrameHeader::ref_frame_idx
int8_t ref_frame_idx[AV1_REFS_PER_FRAME]
Definition: cbs_av1.h:204
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
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
AV1RawOBU::obu
union AV1RawOBU::@67 obu
AV1RawMetadataHDRMDCV::luminance_max
uint32_t luminance_max
Definition: cbs_av1.h:328
VAAPIEncodeAV1Context::attr_ext1
VAConfigAttribValEncAV1Ext1 attr_ext1
Definition: vaapi_encode_av1.c:50
AV1RawFrameHeader::refresh_frame_flags
uint8_t refresh_frame_flags
Definition: cbs_av1.h:198
codec_internal.h
VAAPI_ENCODE_RC_OPTIONS
#define VAAPI_ENCODE_RC_OPTIONS
Definition: vaapi_encode.h:364
AV1RawFrameHeader::reduced_tx_set
uint8_t reduced_tx_set
Definition: cbs_av1.h:280
FFHWBaseEncodePicture::nb_refs
int nb_refs[MAX_REFERENCE_LIST_NUM]
Definition: hw_base_encode.h:97
AV1RawMetadataHDRMDCV::white_point_chromaticity_x
uint16_t white_point_chromaticity_x
Definition: cbs_av1.h:326
AV1RawFrameHeader::tile_cols_log2
uint8_t tile_cols_log2
Definition: cbs_av1.h:216
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
VAAPIEncodeAV1Context::sb_rows
int sb_rows
Definition: vaapi_encode_av1.c:61
AV1RawOBU::sequence_header
AV1RawSequenceHeader sequence_header
Definition: cbs_av1.h:406
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:128
AV1_MAX_TILE_ROWS
@ AV1_MAX_TILE_ROWS
Definition: av1.h:81
AV1RawSequenceHeader::frame_height_bits_minus_1
uint8_t frame_height_bits_minus_1
Definition: cbs_av1.h:97
CodedBitstreamContext::trace_write_callback
CBSTraceWriteCallback trace_write_callback
Callback for write tracing.
Definition: cbs.h:281
AVFrameSideData::data
uint8_t * data
Definition: frame.h:267
AV1_OBU_SEQUENCE_HEADER
@ AV1_OBU_SEQUENCE_HEADER
Definition: av1.h:30
vaapi_encode_av1_options
static const AVOption vaapi_encode_av1_options[]
Definition: vaapi_encode_av1.c:970
AV1_METADATA_TYPE_HDR_MDCV
@ AV1_METADATA_TYPE_HDR_MDCV
Definition: av1.h:45
AV1LevelDescriptor
Definition: av1_levels.h:26
FFHWBaseEncodePicture::encode_order
int64_t encode_order
Definition: hw_base_encode.h:70
VAAPIEncodeAV1Context::min_log2_tile_rows
int min_log2_tile_rows
Definition: vaapi_encode_av1.c:71
VAAPI_ENCODE_COMMON_OPTIONS
#define VAAPI_ENCODE_COMMON_OPTIONS
Definition: vaapi_encode.h:350
VAAPIEncodePicture::recon_surface
VASurfaceID recon_surface
Definition: vaapi_encode.h:74
VAAPIEncodeAV1Context::tile_cols
int tile_cols
Definition: vaapi_encode_av1.c:88
VAAPIEncodeAV1Context::use_128x128_superblock
uint8_t use_128x128_superblock
Definition: vaapi_encode_av1.c:59
AVERROR_EXTERNAL
#define AVERROR_EXTERNAL
Generic error in an external library.
Definition: error.h:59
VAAPIEncodePicture::output_buffer
VABufferID output_buffer
Definition: vaapi_encode.h:81
AV_PROFILE_AV1_HIGH
#define AV_PROFILE_AV1_HIGH
Definition: defs.h:170
VAAPIEncodeAV1Context::loopfilter_offset
int loopfilter_offset
Definition: vaapi_encode_av1.c:80
AV1RawFrameHeader::order_hint
uint8_t order_hint
Definition: cbs_av1.h:182
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:126
AV1RawOBU::frame_header
AV1RawFrameHeader frame_header
Definition: cbs_av1.h:407
AV1_PRIMARY_REF_NONE
@ AV1_PRIMARY_REF_NONE
Definition: av1.h:87
vaapi_encode_av1_class
static const AVClass vaapi_encode_av1_class
Definition: vaapi_encode_av1.c:1030
AVCodecContext::b_quant_factor
float b_quant_factor
qscale factor between IP and B-frames If > 0 then the last P-frame quantizer will be used (q= lastp_q...
Definition: avcodec.h:810
AV1RawMetadataHDRMDCV::luminance_min
uint32_t luminance_min
Definition: cbs_av1.h:329
AV1RawOBU::metadata
AV1RawMetadata metadata
Definition: cbs_av1.h:411
VAAPIEncodeAV1Context::mh
AV1RawOBU mh[4]
metadata header.
Definition: vaapi_encode_av1.c:45
VAAPIEncodeAV1Picture
Definition: vaapi_encode_av1.c:36
AV1RawFrameHeader::frame_to_show_map_idx
uint8_t frame_to_show_map_idx
Definition: cbs_av1.h:167
AV1_SELECT_INTEGER_MV
@ AV1_SELECT_INTEGER_MV
Definition: av1.h:99
AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
@ AV_FRAME_DATA_CONTENT_LIGHT_LEVEL
Content light level (based on CTA-861.3).
Definition: frame.h:137
VAAPIEncodeAV1Context::sh_data
char sh_data[MAX_PARAM_BUFFER_SIZE]
coded sequence header data.
Definition: vaapi_encode_av1.c:53
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
put_bits_count
static int put_bits_count(PutBitContext *s)
Definition: put_bits.h:80
FF_HW_PICTURE_TYPE_P
@ FF_HW_PICTURE_TYPE_P
Definition: hw_base_encode.h:41
VAAPIEncodeAV1Context::sb_cols
int sb_cols
Definition: vaapi_encode_av1.c:60
VAAPIEncodeAV1Context::sh_data_len
size_t sh_data_len
bit length of sh_data.
Definition: vaapi_encode_av1.c:54
MAX_REFERENCE_LIST_NUM
#define MAX_REFERENCE_LIST_NUM
Definition: hw_base_encode.h:30
vaapi_encode_type_av1
static const VAAPIEncodeType vaapi_encode_type_av1
Definition: vaapi_encode_av1.c:845
AV1RawFrameHeader::tile_rows
uint16_t tile_rows
Definition: cbs_av1.h:228
value
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
Definition: writing_filters.txt:86
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV1RawSequenceHeader::max_frame_width_minus_1
uint16_t max_frame_width_minus_1
Definition: cbs_av1.h:98
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:128
vaapi_encode_av1_write_extra_header
static int vaapi_encode_av1_write_extra_header(AVCodecContext *avctx, FFHWBaseEncodePicture *base_pic, int index, int *type, char *data, size_t *data_len)
Definition: vaapi_encode_av1.c:806
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:708
VAAPIEncodeAV1Context::level
int level
Definition: vaapi_encode_av1.c:86
AVMasteringDisplayMetadata
Mastering display metadata capable of representing the color volume of the display used to master the...
Definition: mastering_display_metadata.h:38
profile
int profile
Definition: mxfenc.c:2228
AVCOL_SPC_UNSPECIFIED
@ AVCOL_SPC_UNSPECIFIED
Definition: pixfmt.h:643
AV1RawSequenceHeader::enable_order_hint
uint8_t enable_order_hint
Definition: cbs_av1.h:113
av_rescale
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Definition: mathematics.c:129
AVCodecContext::height
int height
Definition: avcodec.h:624
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
ff_cbs_write_fragment_data
int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Write the content of the fragment to its own internal buffer.
Definition: cbs.c:409
VAAPIEncodeAV1Context::profile
int profile
user options
Definition: vaapi_encode_av1.c:85
AV1RawFrameHeader::ref_order_hint
uint8_t ref_order_hint[AV1_NUM_REF_FRAMES]
Definition: cbs_av1.h:200
AV1RawFrameHeader::height_in_sbs_minus_1
uint8_t height_in_sbs_minus_1[AV1_MAX_TILE_ROWS]
Definition: cbs_av1.h:221
AV1_MAX_TILE_WIDTH
@ AV1_MAX_TILE_WIDTH
Definition: av1.h:79
VAAPIEncodePicture::tail_data
char tail_data[MAX_PARAM_BUFFER_SIZE]
Tail data of current pic, used only for repeat header of AV1.
Definition: vaapi_encode.h:95
ff_vaapi_encode_hw_configs
const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]
Definition: vaapi_encode.c:36
ff_vaapi_encode_init
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
Definition: vaapi_encode.c:2091
ret
ret
Definition: filter_design.txt:187
FFHWBaseEncodeContext::gop_size
int gop_size
Definition: hw_base_encode.h:184
FFHWBaseEncodePicture
Definition: hw_base_encode.h:61
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:80
VAAPIEncodeAV1Context::max_tile_width_sb
int max_tile_width_sb
Definition: vaapi_encode_av1.c:64
AV1_TOTAL_REFS_PER_FRAME
@ AV1_TOTAL_REFS_PER_FRAME
Definition: av1.h:86
VAAPIEncodeAV1Context::tier
int tier
Definition: vaapi_encode_av1.c:87
AV1RawColorConfig::high_bitdepth
uint8_t high_bitdepth
Definition: cbs_av1.h:42
vaapi_encode_av1_write_obu
static int vaapi_encode_av1_write_obu(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *bs)
Definition: vaapi_encode_av1.c:184
VAAPIEncodeAV1Context::tile_rows_log2
int tile_rows_log2
Definition: vaapi_encode_av1.c:63
AV1RawFrameHeader::reference_select
uint8_t reference_select
Definition: cbs_av1.h:276
vaapi_encode_av1_get_encoder_caps
static av_cold int vaapi_encode_av1_get_encoder_caps(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:113
VAAPIEncodeAV1Context::fh_data_len
size_t fh_data_len
bit length of fh_data.
Definition: vaapi_encode_av1.c:56
AV1RawSequenceHeader::frame_width_bits_minus_1
uint8_t frame_width_bits_minus_1
Definition: cbs_av1.h:96
vaapi_encode_av1_defaults
static const FFCodecDefault vaapi_encode_av1_defaults[]
Definition: vaapi_encode_av1.c:1021
FFHWBaseEncodeContext::surface_height
int surface_height
Definition: hw_base_encode.h:141
AVCodecContext
main external API structure.
Definition: avcodec.h:451
AVCodecContext::qmin
int qmin
minimum quantizer
Definition: avcodec.h:1266
AVRational::den
int den
Denominator.
Definition: rational.h:60
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
VAAPIEncodeAV1Context::tile_cols_log2
int tile_cols_log2
Definition: vaapi_encode_av1.c:62
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:1650
VAAPIEncodeAV1Context::uniform_tile
uint8_t uniform_tile
Definition: vaapi_encode_av1.c:58
av1_levels.h
AV1RawFrameHeader::frame_height_minus_1
uint16_t frame_height_minus_1
Definition: cbs_av1.h:189
AVCodecContext::i_quant_offset
float i_quant_offset
qscale offset between P and I-frames
Definition: avcodec.h:833
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:112
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
AVMasteringDisplayMetadata::min_luminance
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
Definition: mastering_display_metadata.h:52
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:122
VAAPIEncodeAV1Context::max_tile_height_sb
int max_tile_height_sb
Definition: vaapi_encode_av1.c:65
AV1RawMetadataHDRMDCV::white_point_chromaticity_y
uint16_t white_point_chromaticity_y
Definition: cbs_av1.h:327
CodedBitstreamContext::trace_enable
int trace_enable
Enable trace output during read/write operations.
Definition: cbs.h:257
AV1RawFrameHeader::show_existing_frame
uint8_t show_existing_frame
Definition: cbs_av1.h:166
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV1RawOBU::frame
AV1RawFrame frame
Definition: cbs_av1.h:408
VAAPIEncodeAV1Context::q_idx_idr
int q_idx_idr
Definition: vaapi_encode_av1.c:74
mastering_display_metadata.h
AVFrameSideData
Structure to hold side data for an AVFrame.
Definition: frame.h:265
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
AV1RawMetadataHDRMDCV::primary_chromaticity_y
uint16_t primary_chromaticity_y[3]
Definition: cbs_av1.h:325
ff_cbs_init
av_cold int ff_cbs_init(CodedBitstreamContext **ctx_ptr, enum AVCodecID codec_id, void *log_ctx)
Create and initialise a new context for the given codec.
Definition: cbs.c:90
AV1RawFrameHeader::error_resilient_mode
uint8_t error_resilient_mode
Definition: cbs_av1.h:175
AV1_REF_FRAME_GOLDEN
@ AV1_REF_FRAME_GOLDEN
Definition: av1.h:66
AV1RawFrameHeader::tile_rows_log2
uint8_t tile_rows_log2
Definition: cbs_av1.h:217
AV1_FRAME_INTER
@ AV1_FRAME_INTER
Definition: av1.h:54
VAAPIEncodeAV1Context::attr
VAConfigAttribValEncAV1 attr
Definition: vaapi_encode_av1.c:49
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AV1_FRAME_KEY
@ AV1_FRAME_KEY
Definition: av1.h:53
AVContentLightMetadata::MaxFALL
unsigned MaxFALL
Max average light level per frame (cd/m^2).
Definition: mastering_display_metadata.h:116
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
vaapi_encode_av1_write_picture_header
static int vaapi_encode_av1_write_picture_header(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, char *data, size_t *data_len)
Definition: vaapi_encode_av1.c:756
OFFSET
#define OFFSET(x)
Definition: vaapi_encode_av1.c:967
AV1RawSequenceHeader::enable_cdef
uint8_t enable_cdef
Definition: cbs_av1.h:125
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:624
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
VAAPIEncodeAV1Context::tile_rows
int tile_rows
Definition: vaapi_encode_av1.c:88
HW_BASE_ENCODE_COMMON_OPTIONS
#define HW_BASE_ENCODE_COMMON_OPTIONS
Definition: hw_base_encode.h:239
FFHWBaseEncodePicture::display_order
int64_t display_order
Definition: hw_base_encode.h:69
AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_MAIN
Definition: defs.h:169
VAAPIEncodeAV1Context::q_idx_p
int q_idx_p
Definition: vaapi_encode_av1.c:75
AV1RawFrameHeader::showable_frame
uint8_t showable_frame
Definition: cbs_av1.h:173
put_bits.h
AV1RawOBUHeader::obu_has_size_field
uint8_t obu_has_size_field
Definition: cbs_av1.h:33
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
vaapi_encode_av1_configure
static av_cold int vaapi_encode_av1_configure(AVCodecContext *avctx)
Definition: vaapi_encode_av1.c:125
AV1_OBU_METADATA
@ AV1_OBU_METADATA
Definition: av1.h:34
LEVEL
#define LEVEL(name, value)
AV1RawFrameHeader::tile_cols
uint16_t tile_cols
Definition: cbs_av1.h:227
VAAPIEncodeProfile
Definition: vaapi_encode.h:100
PROFILE
#define PROFILE(name, value)
VAAPIEncodeAV1Context::max_log2_tile_cols
int max_log2_tile_cols
Definition: vaapi_encode_av1.c:70
AV1RawFrameHeader::render_height_minus_1
uint16_t render_height_minus_1
Definition: cbs_av1.h:194
VAAPIEncodePicture::nb_slices
int nb_slices
Definition: vaapi_encode.h:85
AV1RawFrameHeader::frame_type
uint8_t frame_type
Definition: cbs_av1.h:171
CodedBitstreamAV1Context
Definition: cbs_av1.h:438
AV1RawOBUHeader::obu_type
uint8_t obu_type
Definition: cbs_av1.h:31