FFmpeg
vaapi_encode_h265.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include <string.h>
20 
21 #include <va/va.h>
22 #include <va/va_enc_hevc.h>
23 
24 #include "libavutil/avassert.h"
25 #include "libavutil/common.h"
26 #include "libavutil/pixdesc.h"
27 #include "libavutil/opt.h"
29 
30 #include "avcodec.h"
31 #include "cbs.h"
32 #include "cbs_h265.h"
33 #include "h265_profile_level.h"
34 #include "hevc.h"
35 #include "hevc_sei.h"
36 #include "internal.h"
37 #include "put_bits.h"
38 #include "vaapi_encode.h"
39 
40 enum {
43 };
44 
45 typedef struct VAAPIEncodeH265Picture {
47 
48  int64_t last_idr_frame;
49 
52  int pic_type;
54 
55 typedef struct VAAPIEncodeH265Context {
57 
58  // User options.
59  int qp;
60  int aud;
61  int profile;
62  int tier;
63  int level;
64  int sei;
65 
66  // Derived settings.
70 
71  // Writer structures.
78 
81 
87 
88 
90  char *data, size_t *data_len,
92 {
93  VAAPIEncodeH265Context *priv = avctx->priv_data;
94  int err;
95 
96  err = ff_cbs_write_fragment_data(priv->cbc, au);
97  if (err < 0) {
98  av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
99  return err;
100  }
101 
102  if (*data_len < 8 * au->data_size - au->data_bit_padding) {
103  av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
104  "%zu < %zu.\n", *data_len,
105  8 * au->data_size - au->data_bit_padding);
106  return AVERROR(ENOSPC);
107  }
108 
109  memcpy(data, au->data, au->data_size);
110  *data_len = 8 * au->data_size - au->data_bit_padding;
111 
112  return 0;
113 }
114 
117  void *nal_unit)
118 {
119  H265RawNALUnitHeader *header = nal_unit;
120  int err;
121 
122  err = ff_cbs_insert_unit_content(au, -1,
123  header->nal_unit_type, nal_unit, NULL);
124  if (err < 0) {
125  av_log(avctx, AV_LOG_ERROR, "Failed to add NAL unit: "
126  "type = %d.\n", header->nal_unit_type);
127  return err;
128  }
129 
130  return 0;
131 }
132 
134  char *data, size_t *data_len)
135 {
136  VAAPIEncodeH265Context *priv = avctx->priv_data;
138  int err;
139 
140  if (priv->aud_needed) {
141  err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_aud);
142  if (err < 0)
143  goto fail;
144  priv->aud_needed = 0;
145  }
146 
147  err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_vps);
148  if (err < 0)
149  goto fail;
150 
151  err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_sps);
152  if (err < 0)
153  goto fail;
154 
155  err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_pps);
156  if (err < 0)
157  goto fail;
158 
159  err = vaapi_encode_h265_write_access_unit(avctx, data, data_len, au);
160 fail:
162  return err;
163 }
164 
166  VAAPIEncodePicture *pic,
167  VAAPIEncodeSlice *slice,
168  char *data, size_t *data_len)
169 {
170  VAAPIEncodeH265Context *priv = avctx->priv_data;
172  int err;
173 
174  if (priv->aud_needed) {
175  err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_aud);
176  if (err < 0)
177  goto fail;
178  priv->aud_needed = 0;
179  }
180 
181  err = vaapi_encode_h265_add_nal(avctx, au, &priv->raw_slice);
182  if (err < 0)
183  goto fail;
184 
185  err = vaapi_encode_h265_write_access_unit(avctx, data, data_len, au);
186 fail:
188  return err;
189 }
190 
192  VAAPIEncodePicture *pic,
193  int index, int *type,
194  char *data, size_t *data_len)
195 {
196  VAAPIEncodeH265Context *priv = avctx->priv_data;
198  int err, i;
199 
200  if (priv->sei_needed) {
201  H265RawSEI *sei = &priv->raw_sei;
202 
203  if (priv->aud_needed) {
204  err = vaapi_encode_h265_add_nal(avctx, au, &priv->aud);
205  if (err < 0)
206  goto fail;
207  priv->aud_needed = 0;
208  }
209 
210  *sei = (H265RawSEI) {
211  .nal_unit_header = {
213  .nuh_layer_id = 0,
214  .nuh_temporal_id_plus1 = 1,
215  },
216  };
217 
218  i = 0;
219 
220  if (priv->sei_needed & SEI_MASTERING_DISPLAY) {
223  ++i;
224  }
225 
226  if (priv->sei_needed & SEI_CONTENT_LIGHT_LEVEL) {
229  ++i;
230  }
231 
232  sei->payload_count = i;
233  av_assert0(sei->payload_count > 0);
234 
235  err = vaapi_encode_h265_add_nal(avctx, au, sei);
236  if (err < 0)
237  goto fail;
238  priv->sei_needed = 0;
239 
240  err = vaapi_encode_h265_write_access_unit(avctx, data, data_len, au);
241  if (err < 0)
242  goto fail;
243 
245 
246  *type = VAEncPackedHeaderRawData;
247  return 0;
248  } else {
249  return AVERROR_EOF;
250  }
251 
252 fail:
254  return err;
255 }
256 
258 {
259  VAAPIEncodeContext *ctx = avctx->priv_data;
260  VAAPIEncodeH265Context *priv = avctx->priv_data;
261  H265RawVPS *vps = &priv->raw_vps;
262  H265RawSPS *sps = &priv->raw_sps;
263  H265RawPPS *pps = &priv->raw_pps;
265  H265RawVUI *vui = &sps->vui;
266  VAEncSequenceParameterBufferHEVC *vseq = ctx->codec_sequence_params;
267  VAEncPictureParameterBufferHEVC *vpic = ctx->codec_picture_params;
268  const AVPixFmtDescriptor *desc;
269  int chroma_format, bit_depth;
270  int i;
271 
272  memset(vps, 0, sizeof(*vps));
273  memset(sps, 0, sizeof(*sps));
274  memset(pps, 0, sizeof(*pps));
275 
276 
278  av_assert0(desc);
279  if (desc->nb_components == 1) {
280  chroma_format = 0;
281  } else {
282  if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 1) {
283  chroma_format = 1;
284  } else if (desc->log2_chroma_w == 1 && desc->log2_chroma_h == 0) {
285  chroma_format = 2;
286  } else if (desc->log2_chroma_w == 0 && desc->log2_chroma_h == 0) {
287  chroma_format = 3;
288  } else {
289  av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
290  "%s is not supported.\n", desc->name);
291  return AVERROR(EINVAL);
292  }
293  }
294  bit_depth = desc->comp[0].depth;
295 
296 
297  // VPS
298 
301  .nuh_layer_id = 0,
302  .nuh_temporal_id_plus1 = 1,
303  };
304 
306 
309  vps->vps_max_layers_minus1 = 0;
310  vps->vps_max_sub_layers_minus1 = 0;
312 
313  ptl->general_profile_space = 0;
314  ptl->general_profile_idc = avctx->profile;
315  ptl->general_tier_flag = priv->tier;
316 
317  if (chroma_format == 1) {
318  ptl->general_profile_compatibility_flag[1] = bit_depth == 8;
319  ptl->general_profile_compatibility_flag[2] = bit_depth <= 10;
320  }
322 
327 
328  ptl->general_max_12bit_constraint_flag = bit_depth <= 12;
329  ptl->general_max_10bit_constraint_flag = bit_depth <= 10;
330  ptl->general_max_8bit_constraint_flag = bit_depth == 8;
331 
332  ptl->general_max_422chroma_constraint_flag = chroma_format <= 2;
333  ptl->general_max_420chroma_constraint_flag = chroma_format <= 1;
334  ptl->general_max_monochrome_constraint_flag = chroma_format == 0;
335 
336  ptl->general_intra_constraint_flag = ctx->gop_size == 1;
337 
339 
340  if (avctx->level != FF_LEVEL_UNKNOWN) {
341  ptl->general_level_idc = avctx->level;
342  } else {
343  const H265LevelDescriptor *level;
344 
345  level = ff_h265_guess_level(ptl, avctx->bit_rate,
346  ctx->surface_width, ctx->surface_height,
347  ctx->nb_slices, ctx->tile_rows, ctx->tile_cols,
348  (ctx->b_per_p > 0) + 1);
349  if (level) {
350  av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
351  ptl->general_level_idc = level->level_idc;
352  } else {
353  av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
354  "any normal level; using level 8.5.\n");
355  ptl->general_level_idc = 255;
356  // The tier flag must be set in level 8.5.
357  ptl->general_tier_flag = 1;
358  }
359  }
360 
363  vps->vps_max_num_reorder_pics[0] = ctx->max_b_depth;
364  vps->vps_max_latency_increase_plus1[0] = 0;
365 
366  vps->vps_max_layer_id = 0;
367  vps->vps_num_layer_sets_minus1 = 0;
368  vps->layer_id_included_flag[0][0] = 1;
369 
371  if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
372  vps->vps_num_units_in_tick = avctx->framerate.den;
373  vps->vps_time_scale = avctx->framerate.num;
376  } else {
377  vps->vps_num_units_in_tick = avctx->time_base.num;
378  vps->vps_time_scale = avctx->time_base.den;
380  }
381  vps->vps_num_hrd_parameters = 0;
382 
383 
384  // SPS
385 
388  .nuh_layer_id = 0,
389  .nuh_temporal_id_plus1 = 1,
390  };
391 
393 
396 
398 
399  sps->sps_seq_parameter_set_id = 0;
400 
401  sps->chroma_format_idc = chroma_format;
403 
406 
407  if (avctx->width != ctx->surface_width ||
408  avctx->height != ctx->surface_height) {
409  sps->conformance_window_flag = 1;
410  sps->conf_win_left_offset = 0;
411  sps->conf_win_right_offset =
412  (ctx->surface_width - avctx->width) >> desc->log2_chroma_w;
413  sps->conf_win_top_offset = 0;
415  (ctx->surface_height - avctx->height) >> desc->log2_chroma_h;
416  } else {
417  sps->conformance_window_flag = 0;
418  }
419 
420  sps->bit_depth_luma_minus8 = bit_depth - 8;
421  sps->bit_depth_chroma_minus8 = bit_depth - 8;
422 
424 
427  for (i = 0; i <= sps->sps_max_sub_layers_minus1; i++) {
434  }
435 
436  // These have to come from the capabilities of the encoder. We have no
437  // way to query them, so just hardcode parameters which work on the Intel
438  // driver.
439  // CTB size from 8x8 to 32x32.
442  // Transform size from 4x4 to 32x32.
445  // Full transform hierarchy allowed (2-5).
448  // AMP works.
449  sps->amp_enabled_flag = 1;
450  // SAO and temporal MVP do not work.
453 
454  sps->pcm_enabled_flag = 0;
455 
456  // STRPSs should ideally be here rather than defined individually in
457  // each slice, but the structure isn't completely fixed so for now
458  // don't bother.
461 
463 
464  if (avctx->sample_aspect_ratio.num != 0 &&
465  avctx->sample_aspect_ratio.den != 0) {
466  static const AVRational sar_idc[] = {
467  { 0, 0 },
468  { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
469  { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
470  { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
471  { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
472  };
473  int num, den, i;
474  av_reduce(&num, &den, avctx->sample_aspect_ratio.num,
475  avctx->sample_aspect_ratio.den, 65535);
476  for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
477  if (num == sar_idc[i].num &&
478  den == sar_idc[i].den) {
479  vui->aspect_ratio_idc = i;
480  break;
481  }
482  }
483  if (i >= FF_ARRAY_ELEMS(sar_idc)) {
484  vui->aspect_ratio_idc = 255;
485  vui->sar_width = num;
486  vui->sar_height = den;
487  }
489  }
490 
491  if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED ||
493  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
494  avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
496  vui->video_format = 5; // Unspecified.
497  vui->video_full_range_flag =
498  avctx->color_range == AVCOL_RANGE_JPEG;
499 
500  if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
501  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
502  avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
504  vui->colour_primaries = avctx->color_primaries;
505  vui->transfer_characteristics = avctx->color_trc;
506  vui->matrix_coefficients = avctx->colorspace;
507  }
508  } else {
509  vui->video_format = 5;
510  vui->video_full_range_flag = 0;
511  vui->colour_primaries = avctx->color_primaries;
512  vui->transfer_characteristics = avctx->color_trc;
513  vui->matrix_coefficients = avctx->colorspace;
514  }
515 
520  avctx->chroma_sample_location - 1;
521  }
522 
525  vui->vui_time_scale = vps->vps_time_scale;
529 
533  vui->max_bytes_per_pic_denom = 0;
534  vui->max_bits_per_min_cu_denom = 0;
536  vui->log2_max_mv_length_vertical = 15;
537 
538 
539  // PPS
540 
543  .nuh_layer_id = 0,
544  .nuh_temporal_id_plus1 = 1,
545  };
546 
547  pps->pps_pic_parameter_set_id = 0;
549 
552 
553  pps->init_qp_minus26 = priv->fixed_qp_idr - 26;
554 
555  pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP);
556  pps->diff_cu_qp_delta_depth = 0;
557 
558  if (ctx->tile_rows && ctx->tile_cols) {
559  int uniform_spacing;
560 
561  pps->tiles_enabled_flag = 1;
562  pps->num_tile_columns_minus1 = ctx->tile_cols - 1;
563  pps->num_tile_rows_minus1 = ctx->tile_rows - 1;
564 
565  // Test whether the spacing provided matches the H.265 uniform
566  // spacing, and set the flag if it does.
567  uniform_spacing = 1;
568  for (i = 0; i <= pps->num_tile_columns_minus1 &&
569  uniform_spacing; i++) {
570  if (ctx->col_width[i] !=
571  (i + 1) * ctx->slice_block_cols / ctx->tile_cols -
572  i * ctx->slice_block_cols / ctx->tile_cols)
573  uniform_spacing = 0;
574  }
575  for (i = 0; i <= pps->num_tile_rows_minus1 &&
576  uniform_spacing; i++) {
577  if (ctx->row_height[i] !=
578  (i + 1) * ctx->slice_block_rows / ctx->tile_rows -
579  i * ctx->slice_block_rows / ctx->tile_rows)
580  uniform_spacing = 0;
581  }
582  pps->uniform_spacing_flag = uniform_spacing;
583 
584  for (i = 0; i <= pps->num_tile_columns_minus1; i++)
585  pps->column_width_minus1[i] = ctx->col_width[i] - 1;
586  for (i = 0; i <= pps->num_tile_rows_minus1; i++)
587  pps->row_height_minus1[i] = ctx->row_height[i] - 1;
588 
590  }
591 
593 
594  // Fill VAAPI parameter buffers.
595 
596  *vseq = (VAEncSequenceParameterBufferHEVC) {
597  .general_profile_idc = vps->profile_tier_level.general_profile_idc,
598  .general_level_idc = vps->profile_tier_level.general_level_idc,
599  .general_tier_flag = vps->profile_tier_level.general_tier_flag,
600 
601  .intra_period = ctx->gop_size,
602  .intra_idr_period = ctx->gop_size,
603  .ip_period = ctx->b_per_p + 1,
604  .bits_per_second = ctx->va_bit_rate,
605 
606  .pic_width_in_luma_samples = sps->pic_width_in_luma_samples,
607  .pic_height_in_luma_samples = sps->pic_height_in_luma_samples,
608 
609  .seq_fields.bits = {
610  .chroma_format_idc = sps->chroma_format_idc,
611  .separate_colour_plane_flag = sps->separate_colour_plane_flag,
612  .bit_depth_luma_minus8 = sps->bit_depth_luma_minus8,
613  .bit_depth_chroma_minus8 = sps->bit_depth_chroma_minus8,
614  .scaling_list_enabled_flag = sps->scaling_list_enabled_flag,
615  .strong_intra_smoothing_enabled_flag =
617  .amp_enabled_flag = sps->amp_enabled_flag,
618  .sample_adaptive_offset_enabled_flag =
620  .pcm_enabled_flag = sps->pcm_enabled_flag,
621  .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled_flag,
622  .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag,
623  },
624 
625  .log2_min_luma_coding_block_size_minus3 =
627  .log2_diff_max_min_luma_coding_block_size =
629  .log2_min_transform_block_size_minus2 =
631  .log2_diff_max_min_transform_block_size =
633  .max_transform_hierarchy_depth_inter =
635  .max_transform_hierarchy_depth_intra =
637 
638  .pcm_sample_bit_depth_luma_minus1 =
640  .pcm_sample_bit_depth_chroma_minus1 =
642  .log2_min_pcm_luma_coding_block_size_minus3 =
644  .log2_max_pcm_luma_coding_block_size_minus3 =
647 
648  .vui_parameters_present_flag = 0,
649  };
650 
651  *vpic = (VAEncPictureParameterBufferHEVC) {
652  .decoded_curr_pic = {
653  .picture_id = VA_INVALID_ID,
654  .flags = VA_PICTURE_HEVC_INVALID,
655  },
656 
657  .coded_buf = VA_INVALID_ID,
658 
659  .collocated_ref_pic_index = 0xff,
660 
661  .last_picture = 0,
662 
663  .pic_init_qp = pps->init_qp_minus26 + 26,
664  .diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth,
665  .pps_cb_qp_offset = pps->pps_cb_qp_offset,
666  .pps_cr_qp_offset = pps->pps_cr_qp_offset,
667 
668  .num_tile_columns_minus1 = pps->num_tile_columns_minus1,
669  .num_tile_rows_minus1 = pps->num_tile_rows_minus1,
670 
671  .log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level_minus2,
672  .ctu_max_bitsize_allowed = 0,
673 
674  .num_ref_idx_l0_default_active_minus1 =
676  .num_ref_idx_l1_default_active_minus1 =
678 
679  .slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id,
680 
681  .pic_fields.bits = {
682  .sign_data_hiding_enabled_flag = pps->sign_data_hiding_enabled_flag,
683  .constrained_intra_pred_flag = pps->constrained_intra_pred_flag,
684  .transform_skip_enabled_flag = pps->transform_skip_enabled_flag,
685  .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag,
686  .weighted_pred_flag = pps->weighted_pred_flag,
687  .weighted_bipred_flag = pps->weighted_bipred_flag,
688  .transquant_bypass_enabled_flag = pps->transquant_bypass_enabled_flag,
689  .tiles_enabled_flag = pps->tiles_enabled_flag,
690  .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag,
691  .loop_filter_across_tiles_enabled_flag =
693  .scaling_list_data_present_flag = (sps->sps_scaling_list_data_present_flag |
695  .screen_content_flag = 0,
696  .enable_gpu_weighted_prediction = 0,
697  .no_output_of_prior_pics_flag = 0,
698  },
699  };
700 
701  if (pps->tiles_enabled_flag) {
702  for (i = 0; i <= vpic->num_tile_rows_minus1; i++)
703  vpic->row_height_minus1[i] = pps->row_height_minus1[i];
704  for (i = 0; i <= vpic->num_tile_columns_minus1; i++)
705  vpic->column_width_minus1[i] = pps->column_width_minus1[i];
706  }
707 
708  return 0;
709 }
710 
712  VAAPIEncodePicture *pic)
713 {
714  VAAPIEncodeContext *ctx = avctx->priv_data;
715  VAAPIEncodeH265Context *priv = avctx->priv_data;
716  VAAPIEncodeH265Picture *hpic = pic->priv_data;
717  VAAPIEncodePicture *prev = pic->prev;
718  VAAPIEncodeH265Picture *hprev = prev ? prev->priv_data : NULL;
719  VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params;
720  int i;
721 
722  if (pic->type == PICTURE_TYPE_IDR) {
723  av_assert0(pic->display_order == pic->encode_order);
724 
725  hpic->last_idr_frame = pic->display_order;
726 
728  hpic->slice_type = HEVC_SLICE_I;
729  hpic->pic_type = 0;
730  } else {
731  av_assert0(prev);
732  hpic->last_idr_frame = hprev->last_idr_frame;
733 
734  if (pic->type == PICTURE_TYPE_I) {
736  hpic->slice_type = HEVC_SLICE_I;
737  hpic->pic_type = 0;
738  } else if (pic->type == PICTURE_TYPE_P) {
739  av_assert0(pic->refs[0]);
741  hpic->slice_type = HEVC_SLICE_P;
742  hpic->pic_type = 1;
743  } else {
744  VAAPIEncodePicture *irap_ref;
745  av_assert0(pic->refs[0] && pic->refs[1]);
746  for (irap_ref = pic; irap_ref; irap_ref = irap_ref->refs[1]) {
747  if (irap_ref->type == PICTURE_TYPE_I)
748  break;
749  }
750  if (pic->b_depth == ctx->max_b_depth) {
751  hpic->slice_nal_unit = irap_ref ? HEVC_NAL_RASL_N
753  } else {
754  hpic->slice_nal_unit = irap_ref ? HEVC_NAL_RASL_R
756  }
757  hpic->slice_type = HEVC_SLICE_B;
758  hpic->pic_type = 2;
759  }
760  }
761  hpic->pic_order_cnt = pic->display_order - hpic->last_idr_frame;
762 
763  if (priv->aud) {
764  priv->aud_needed = 1;
765  priv->raw_aud = (H265RawAUD) {
766  .nal_unit_header = {
768  .nuh_layer_id = 0,
769  .nuh_temporal_id_plus1 = 1,
770  },
771  .pic_type = hpic->pic_type,
772  };
773  } else {
774  priv->aud_needed = 0;
775  }
776 
777  priv->sei_needed = 0;
778 
779  // Only look for the metadata on I/IDR frame on the output. We
780  // may force an IDR frame on the output where the medadata gets
781  // changed on the input frame.
782  if ((priv->sei & SEI_MASTERING_DISPLAY) &&
783  (pic->type == PICTURE_TYPE_I || pic->type == PICTURE_TYPE_IDR)) {
784  AVFrameSideData *sd =
787 
788  if (sd) {
791 
792  // SEI is needed when both the primaries and luminance are set
793  if (mdm->has_primaries && mdm->has_luminance) {
795  &priv->sei_mastering_display;
796  const int mapping[3] = {1, 2, 0};
797  const int chroma_den = 50000;
798  const int luma_den = 10000;
799 
800  for (i = 0; i < 3; i++) {
801  const int j = mapping[i];
802  mdcv->display_primaries_x[i] =
803  FFMIN(lrint(chroma_den *
804  av_q2d(mdm->display_primaries[j][0])),
805  chroma_den);
806  mdcv->display_primaries_y[i] =
807  FFMIN(lrint(chroma_den *
808  av_q2d(mdm->display_primaries[j][1])),
809  chroma_den);
810  }
811 
812  mdcv->white_point_x =
813  FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[0])),
814  chroma_den);
815  mdcv->white_point_y =
816  FFMIN(lrint(chroma_den * av_q2d(mdm->white_point[1])),
817  chroma_den);
818 
820  lrint(luma_den * av_q2d(mdm->max_luminance));
822  FFMIN(lrint(luma_den * av_q2d(mdm->min_luminance)),
824 
826  }
827  }
828  }
829 
830  if ((priv->sei & SEI_CONTENT_LIGHT_LEVEL) &&
831  (pic->type == PICTURE_TYPE_I || pic->type == PICTURE_TYPE_IDR)) {
832  AVFrameSideData *sd =
835 
836  if (sd) {
841 
842  clli->max_content_light_level = FFMIN(clm->MaxCLL, 65535);
843  clli->max_pic_average_light_level = FFMIN(clm->MaxFALL, 65535);
844 
846  }
847  }
848 
849  vpic->decoded_curr_pic = (VAPictureHEVC) {
850  .picture_id = pic->recon_surface,
851  .pic_order_cnt = hpic->pic_order_cnt,
852  .flags = 0,
853  };
854 
855  for (i = 0; i < pic->nb_refs; i++) {
856  VAAPIEncodePicture *ref = pic->refs[i];
858 
859  av_assert0(ref && ref->encode_order < pic->encode_order);
860  href = ref->priv_data;
861 
862  vpic->reference_frames[i] = (VAPictureHEVC) {
863  .picture_id = ref->recon_surface,
864  .pic_order_cnt = href->pic_order_cnt,
865  .flags = (ref->display_order < pic->display_order ?
866  VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE : 0) |
867  (ref->display_order > pic->display_order ?
868  VA_PICTURE_HEVC_RPS_ST_CURR_AFTER : 0),
869  };
870  }
871  for (; i < FF_ARRAY_ELEMS(vpic->reference_frames); i++) {
872  vpic->reference_frames[i] = (VAPictureHEVC) {
873  .picture_id = VA_INVALID_ID,
874  .flags = VA_PICTURE_HEVC_INVALID,
875  };
876  }
877 
878  vpic->coded_buf = pic->output_buffer;
879 
880  vpic->nal_unit_type = hpic->slice_nal_unit;
881 
882  switch (pic->type) {
883  case PICTURE_TYPE_IDR:
884  vpic->pic_fields.bits.idr_pic_flag = 1;
885  vpic->pic_fields.bits.coding_type = 1;
886  vpic->pic_fields.bits.reference_pic_flag = 1;
887  break;
888  case PICTURE_TYPE_I:
889  vpic->pic_fields.bits.idr_pic_flag = 0;
890  vpic->pic_fields.bits.coding_type = 1;
891  vpic->pic_fields.bits.reference_pic_flag = 1;
892  break;
893  case PICTURE_TYPE_P:
894  vpic->pic_fields.bits.idr_pic_flag = 0;
895  vpic->pic_fields.bits.coding_type = 2;
896  vpic->pic_fields.bits.reference_pic_flag = 1;
897  break;
898  case PICTURE_TYPE_B:
899  vpic->pic_fields.bits.idr_pic_flag = 0;
900  vpic->pic_fields.bits.coding_type = 3;
901  vpic->pic_fields.bits.reference_pic_flag = 0;
902  break;
903  default:
904  av_assert0(0 && "invalid picture type");
905  }
906 
907  return 0;
908 }
909 
911  VAAPIEncodePicture *pic,
912  VAAPIEncodeSlice *slice)
913 {
914  VAAPIEncodeH265Context *priv = avctx->priv_data;
915  VAAPIEncodeH265Picture *hpic = pic->priv_data;
916  const H265RawSPS *sps = &priv->raw_sps;
917  const H265RawPPS *pps = &priv->raw_pps;
918  H265RawSliceHeader *sh = &priv->raw_slice.header;
919  VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params;
920  VAEncSliceParameterBufferHEVC *vslice = slice->codec_slice_params;
921  int i;
922 
924  .nal_unit_type = hpic->slice_nal_unit,
925  .nuh_layer_id = 0,
926  .nuh_temporal_id_plus1 = 1,
927  };
928 
930 
931  sh->first_slice_segment_in_pic_flag = slice->index == 0;
932  sh->slice_segment_address = slice->block_start;
933 
934  sh->slice_type = hpic->slice_type;
935 
937  (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1;
938 
939  if (pic->type != PICTURE_TYPE_IDR) {
940  H265RawSTRefPicSet *rps;
941  const VAAPIEncodeH265Picture *strp;
942  int rps_poc[MAX_DPB_SIZE];
943  int rps_used[MAX_DPB_SIZE];
944  int i, j, poc, rps_pics;
945 
947 
948  rps = &sh->short_term_ref_pic_set;
949  memset(rps, 0, sizeof(*rps));
950 
951  rps_pics = 0;
952  for (i = 0; i < pic->nb_refs; i++) {
953  strp = pic->refs[i]->priv_data;
954  rps_poc[rps_pics] = strp->pic_order_cnt;
955  rps_used[rps_pics] = 1;
956  ++rps_pics;
957  }
958  for (i = 0; i < pic->nb_dpb_pics; i++) {
959  if (pic->dpb[i] == pic)
960  continue;
961  for (j = 0; j < pic->nb_refs; j++) {
962  if (pic->dpb[i] == pic->refs[j])
963  break;
964  }
965  if (j < pic->nb_refs)
966  continue;
967  strp = pic->dpb[i]->priv_data;
968  rps_poc[rps_pics] = strp->pic_order_cnt;
969  rps_used[rps_pics] = 0;
970  ++rps_pics;
971  }
972 
973  for (i = 1; i < rps_pics; i++) {
974  for (j = i; j > 0; j--) {
975  if (rps_poc[j] > rps_poc[j - 1])
976  break;
977  av_assert0(rps_poc[j] != rps_poc[j - 1]);
978  FFSWAP(int, rps_poc[j], rps_poc[j - 1]);
979  FFSWAP(int, rps_used[j], rps_used[j - 1]);
980  }
981  }
982 
983  av_log(avctx, AV_LOG_DEBUG, "RPS for POC %d:",
984  hpic->pic_order_cnt);
985  for (i = 0; i < rps_pics; i++) {
986  av_log(avctx, AV_LOG_DEBUG, " (%d,%d)",
987  rps_poc[i], rps_used[i]);
988  }
989  av_log(avctx, AV_LOG_DEBUG, "\n");
990 
991  for (i = 0; i < rps_pics; i++) {
992  av_assert0(rps_poc[i] != hpic->pic_order_cnt);
993  if (rps_poc[i] > hpic->pic_order_cnt)
994  break;
995  }
996 
997  rps->num_negative_pics = i;
998  poc = hpic->pic_order_cnt;
999  for (j = i - 1; j >= 0; j--) {
1000  rps->delta_poc_s0_minus1[i - 1 - j] = poc - rps_poc[j] - 1;
1001  rps->used_by_curr_pic_s0_flag[i - 1 - j] = rps_used[j];
1002  poc = rps_poc[j];
1003  }
1004 
1005  rps->num_positive_pics = rps_pics - i;
1006  poc = hpic->pic_order_cnt;
1007  for (j = i; j < rps_pics; j++) {
1008  rps->delta_poc_s1_minus1[j - i] = rps_poc[j] - poc - 1;
1009  rps->used_by_curr_pic_s1_flag[j - i] = rps_used[j];
1010  poc = rps_poc[j];
1011  }
1012 
1013  sh->num_long_term_sps = 0;
1014  sh->num_long_term_pics = 0;
1015 
1020  sh->collocated_ref_idx = 0;
1021  }
1022 
1026  }
1027 
1030 
1031  if (pic->type == PICTURE_TYPE_B)
1032  sh->slice_qp_delta = priv->fixed_qp_b - (pps->init_qp_minus26 + 26);
1033  else if (pic->type == PICTURE_TYPE_P)
1034  sh->slice_qp_delta = priv->fixed_qp_p - (pps->init_qp_minus26 + 26);
1035  else
1036  sh->slice_qp_delta = priv->fixed_qp_idr - (pps->init_qp_minus26 + 26);
1037 
1038 
1039  *vslice = (VAEncSliceParameterBufferHEVC) {
1040  .slice_segment_address = sh->slice_segment_address,
1041  .num_ctu_in_slice = slice->block_size,
1042 
1043  .slice_type = sh->slice_type,
1044  .slice_pic_parameter_set_id = sh->slice_pic_parameter_set_id,
1045 
1046  .num_ref_idx_l0_active_minus1 = sh->num_ref_idx_l0_active_minus1,
1047  .num_ref_idx_l1_active_minus1 = sh->num_ref_idx_l1_active_minus1,
1048 
1049  .luma_log2_weight_denom = sh->luma_log2_weight_denom,
1050  .delta_chroma_log2_weight_denom = sh->delta_chroma_log2_weight_denom,
1051 
1052  .max_num_merge_cand = 5 - sh->five_minus_max_num_merge_cand,
1053 
1054  .slice_qp_delta = sh->slice_qp_delta,
1055  .slice_cb_qp_offset = sh->slice_cb_qp_offset,
1056  .slice_cr_qp_offset = sh->slice_cr_qp_offset,
1057 
1058  .slice_beta_offset_div2 = sh->slice_beta_offset_div2,
1059  .slice_tc_offset_div2 = sh->slice_tc_offset_div2,
1060 
1061  .slice_fields.bits = {
1062  .last_slice_of_pic_flag = slice->index == pic->nb_slices - 1,
1063  .dependent_slice_segment_flag = sh->dependent_slice_segment_flag,
1064  .colour_plane_id = sh->colour_plane_id,
1065  .slice_temporal_mvp_enabled_flag =
1067  .slice_sao_luma_flag = sh->slice_sao_luma_flag,
1068  .slice_sao_chroma_flag = sh->slice_sao_chroma_flag,
1069  .num_ref_idx_active_override_flag =
1071  .mvd_l1_zero_flag = sh->mvd_l1_zero_flag,
1072  .cabac_init_flag = sh->cabac_init_flag,
1073  .slice_deblocking_filter_disabled_flag =
1075  .slice_loop_filter_across_slices_enabled_flag =
1077  .collocated_from_l0_flag = sh->collocated_from_l0_flag,
1078  },
1079  };
1080 
1081  for (i = 0; i < FF_ARRAY_ELEMS(vslice->ref_pic_list0); i++) {
1082  vslice->ref_pic_list0[i].picture_id = VA_INVALID_ID;
1083  vslice->ref_pic_list0[i].flags = VA_PICTURE_HEVC_INVALID;
1084  vslice->ref_pic_list1[i].picture_id = VA_INVALID_ID;
1085  vslice->ref_pic_list1[i].flags = VA_PICTURE_HEVC_INVALID;
1086  }
1087 
1088  av_assert0(pic->nb_refs <= 2);
1089  if (pic->nb_refs >= 1) {
1090  // Backward reference for P- or B-frame.
1091  av_assert0(pic->type == PICTURE_TYPE_P ||
1092  pic->type == PICTURE_TYPE_B);
1093  vslice->ref_pic_list0[0] = vpic->reference_frames[0];
1094  }
1095  if (pic->nb_refs >= 2) {
1096  // Forward reference for B-frame.
1097  av_assert0(pic->type == PICTURE_TYPE_B);
1098  vslice->ref_pic_list1[0] = vpic->reference_frames[1];
1099  }
1100 
1101  return 0;
1102 }
1103 
1105 {
1106  VAAPIEncodeContext *ctx = avctx->priv_data;
1107  VAAPIEncodeH265Context *priv = avctx->priv_data;
1108  int err;
1109 
1110  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_HEVC, avctx);
1111  if (err < 0)
1112  return err;
1113 
1114  if (ctx->va_rc_mode == VA_RC_CQP) {
1115  // Note that VAAPI only supports positive QP values - the range is
1116  // therefore always bounded below by 1, even in 10-bit mode where
1117  // it should go down to -12.
1118 
1119  priv->fixed_qp_p = av_clip(ctx->rc_quality, 1, 51);
1120  if (avctx->i_quant_factor > 0.0)
1121  priv->fixed_qp_idr =
1122  av_clip((avctx->i_quant_factor * priv->fixed_qp_p +
1123  avctx->i_quant_offset) + 0.5, 1, 51);
1124  else
1125  priv->fixed_qp_idr = priv->fixed_qp_p;
1126  if (avctx->b_quant_factor > 0.0)
1127  priv->fixed_qp_b =
1128  av_clip((avctx->b_quant_factor * priv->fixed_qp_p +
1129  avctx->b_quant_offset) + 0.5, 1, 51);
1130  else
1131  priv->fixed_qp_b = priv->fixed_qp_p;
1132 
1133  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
1134  "%d / %d / %d for IDR- / P- / B-frames.\n",
1135  priv->fixed_qp_idr, priv->fixed_qp_p, priv->fixed_qp_b);
1136 
1137  } else {
1138  // These still need to be set for init_qp/slice_qp_delta.
1139  priv->fixed_qp_idr = 30;
1140  priv->fixed_qp_p = 30;
1141  priv->fixed_qp_b = 30;
1142  }
1143 
1144  ctx->roi_quant_range = 51 + 6 * (ctx->profile->depth - 8);
1145 
1146  return 0;
1147 }
1148 
1150  { FF_PROFILE_HEVC_MAIN, 8, 3, 1, 1, VAProfileHEVCMain },
1151  { FF_PROFILE_HEVC_REXT, 8, 3, 1, 1, VAProfileHEVCMain },
1152 #if VA_CHECK_VERSION(0, 37, 0)
1153  { FF_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10 },
1154  { FF_PROFILE_HEVC_REXT, 10, 3, 1, 1, VAProfileHEVCMain10 },
1155 #endif
1156 #if VA_CHECK_VERSION(1, 2, 0)
1157  { FF_PROFILE_HEVC_REXT, 8, 3, 1, 0, VAProfileHEVCMain422_10 },
1158  { FF_PROFILE_HEVC_REXT, 10, 3, 1, 0, VAProfileHEVCMain422_10 },
1159 #endif
1160  { FF_PROFILE_UNKNOWN }
1161 };
1162 
1165 
1166  .flags = FLAG_SLICE_CONTROL |
1167  FLAG_B_PICTURES |
1170 
1171  .default_quality = 25,
1172 
1173  .configure = &vaapi_encode_h265_configure,
1174 
1175  .picture_priv_data_size = sizeof(VAAPIEncodeH265Picture),
1176 
1177  .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC),
1178  .init_sequence_params = &vaapi_encode_h265_init_sequence_params,
1179 
1180  .picture_params_size = sizeof(VAEncPictureParameterBufferHEVC),
1181  .init_picture_params = &vaapi_encode_h265_init_picture_params,
1182 
1183  .slice_params_size = sizeof(VAEncSliceParameterBufferHEVC),
1184  .init_slice_params = &vaapi_encode_h265_init_slice_params,
1185 
1186  .sequence_header_type = VAEncPackedHeaderSequence,
1187  .write_sequence_header = &vaapi_encode_h265_write_sequence_header,
1188 
1189  .slice_header_type = VAEncPackedHeaderHEVC_Slice,
1190  .write_slice_header = &vaapi_encode_h265_write_slice_header,
1191 
1192  .write_extra_header = &vaapi_encode_h265_write_extra_header,
1193 };
1194 
1196 {
1197  VAAPIEncodeContext *ctx = avctx->priv_data;
1198  VAAPIEncodeH265Context *priv = avctx->priv_data;
1199 
1200  ctx->codec = &vaapi_encode_type_h265;
1201 
1202  if (avctx->profile == FF_PROFILE_UNKNOWN)
1203  avctx->profile = priv->profile;
1204  if (avctx->level == FF_LEVEL_UNKNOWN)
1205  avctx->level = priv->level;
1206 
1207  if (avctx->level != FF_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1208  av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1209  "in 8-bit unsigned integer.\n", avctx->level);
1210  return AVERROR(EINVAL);
1211  }
1212 
1213  ctx->desired_packed_headers =
1214  VA_ENC_PACKED_HEADER_SEQUENCE | // VPS, SPS and PPS.
1215  VA_ENC_PACKED_HEADER_SLICE | // Slice headers.
1216  VA_ENC_PACKED_HEADER_MISC; // SEI
1217 
1218  ctx->surface_width = FFALIGN(avctx->width, 16);
1219  ctx->surface_height = FFALIGN(avctx->height, 16);
1220 
1221  // CTU size is currently hard-coded to 32.
1222  ctx->slice_block_width = ctx->slice_block_height = 32;
1223 
1224  if (priv->qp > 0)
1225  ctx->explicit_qp = priv->qp;
1226 
1227  return ff_vaapi_encode_init(avctx);
1228 }
1229 
1231 {
1232  VAAPIEncodeH265Context *priv = avctx->priv_data;
1233 
1235  ff_cbs_close(&priv->cbc);
1236 
1237  return ff_vaapi_encode_close(avctx);
1238 }
1239 
1240 #define OFFSET(x) offsetof(VAAPIEncodeH265Context, x)
1241 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1245 
1246  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
1247  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
1248 
1249  { "aud", "Include AUD",
1250  OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
1251 
1252  { "profile", "Set profile (general_profile_idc)",
1254  { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, 0xff, FLAGS, "profile" },
1255 
1256 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1257  { .i64 = value }, 0, 0, FLAGS, "profile"
1258  { PROFILE("main", FF_PROFILE_HEVC_MAIN) },
1259  { PROFILE("main10", FF_PROFILE_HEVC_MAIN_10) },
1260  { PROFILE("rext", FF_PROFILE_HEVC_REXT) },
1261 #undef PROFILE
1262 
1263  { "tier", "Set tier (general_tier_flag)",
1264  OFFSET(tier), AV_OPT_TYPE_INT,
1265  { .i64 = 0 }, 0, 1, FLAGS, "tier" },
1266  { "main", NULL, 0, AV_OPT_TYPE_CONST,
1267  { .i64 = 0 }, 0, 0, FLAGS, "tier" },
1268  { "high", NULL, 0, AV_OPT_TYPE_CONST,
1269  { .i64 = 1 }, 0, 0, FLAGS, "tier" },
1270 
1271  { "level", "Set level (general_level_idc)",
1273  { .i64 = FF_LEVEL_UNKNOWN }, FF_LEVEL_UNKNOWN, 0xff, FLAGS, "level" },
1274 
1275 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1276  { .i64 = value }, 0, 0, FLAGS, "level"
1277  { LEVEL("1", 30) },
1278  { LEVEL("2", 60) },
1279  { LEVEL("2.1", 63) },
1280  { LEVEL("3", 90) },
1281  { LEVEL("3.1", 93) },
1282  { LEVEL("4", 120) },
1283  { LEVEL("4.1", 123) },
1284  { LEVEL("5", 150) },
1285  { LEVEL("5.1", 153) },
1286  { LEVEL("5.2", 156) },
1287  { LEVEL("6", 180) },
1288  { LEVEL("6.1", 183) },
1289  { LEVEL("6.2", 186) },
1290 #undef LEVEL
1291 
1292  { "sei", "Set SEI to include",
1295  0, INT_MAX, FLAGS, "sei" },
1296  { "hdr",
1297  "Include HDR metadata for mastering display colour volume "
1298  "and content light level information",
1299  0, AV_OPT_TYPE_CONST,
1301  INT_MIN, INT_MAX, FLAGS, "sei" },
1302 
1303  { "tiles", "Tile columns x rows",
1304  OFFSET(common.tile_cols), AV_OPT_TYPE_IMAGE_SIZE,
1305  { .str = NULL }, 0, 0, FLAGS },
1306 
1307  { NULL },
1308 };
1309 
1311  { "b", "0" },
1312  { "bf", "2" },
1313  { "g", "120" },
1314  { "i_qfactor", "1" },
1315  { "i_qoffset", "0" },
1316  { "b_qfactor", "6/5" },
1317  { "b_qoffset", "0" },
1318  { "qmin", "-1" },
1319  { "qmax", "-1" },
1320  { NULL },
1321 };
1322 
1324  .class_name = "h265_vaapi",
1325  .item_name = av_default_item_name,
1326  .option = vaapi_encode_h265_options,
1327  .version = LIBAVUTIL_VERSION_INT,
1328 };
1329 
1331  .name = "hevc_vaapi",
1332  .long_name = NULL_IF_CONFIG_SMALL("H.265/HEVC (VAAPI)"),
1333  .type = AVMEDIA_TYPE_VIDEO,
1334  .id = AV_CODEC_ID_HEVC,
1335  .priv_data_size = sizeof(VAAPIEncodeH265Context),
1337  .receive_packet = &ff_vaapi_encode_receive_packet,
1338  .close = &vaapi_encode_h265_close,
1339  .priv_class = &vaapi_encode_h265_class,
1340  .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
1341  .caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
1342  .defaults = vaapi_encode_h265_defaults,
1343  .pix_fmts = (const enum AVPixelFormat[]) {
1346  },
1347  .hw_configs = ff_vaapi_encode_hw_configs,
1348  .wrapper_name = "vaapi",
1349 };
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
Definition: internal.h:48
uint8_t sps_video_parameter_set_id
Definition: cbs_h265.h:255
uint8_t loop_filter_across_tiles_enabled_flag
Definition: cbs_h265.h:392
#define NULL
Definition: coverity.c:32
AVRational framerate
Definition: avcodec.h:2069
uint8_t transfer_characteristics
Definition: cbs_h265.h:149
uint8_t pps_pic_parameter_set_id
Definition: cbs_h265.h:357
uint8_t vps_poc_proportional_to_timing_flag
Definition: cbs_h265.h:216
uint8_t num_long_term_pics
Definition: cbs_h265.h:474
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
unsigned MaxCLL
Max content light level (cd/m^2).
uint8_t num_ref_idx_l0_default_active_minus1
Definition: cbs_h265.h:366
uint8_t log2_max_mv_length_horizontal
Definition: cbs_h265.h:181
AVOption.
Definition: opt.h:248
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:100
uint8_t motion_vectors_over_pic_boundaries_flag
Definition: cbs_h265.h:176
uint8_t sps_sub_layer_ordering_info_present_flag
Definition: cbs_h265.h:281
uint8_t slice_temporal_mvp_enabled_flag
Definition: cbs_h265.h:481
const char * desc
Definition: libsvtav1.c:79
uint8_t general_max_8bit_constraint_flag
Definition: cbs_h265.h:57
static int vaapi_encode_h265_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
int64_t bit_rate
the average bitrate
Definition: avcodec.h:576
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
uint8_t bitstream_restriction_flag
Definition: cbs_h265.h:174
uint8_t bit_depth_luma_minus8
Definition: cbs_h265.h:276
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: codec.h:150
H265RawSEIContentLightLevelInfo content_light_level
Definition: cbs_h265.h:708
uint8_t vui_timing_info_present_flag
Definition: cbs_h265.h:166
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:74
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:1161
AVRational white_point[2]
CIE 1931 xy chromaticity coords of white point.
Content light level (based on CTA-861.3).
Definition: frame.h:136
uint8_t sps_max_sub_layers_minus1
Definition: cbs_h265.h:257
uint16_t slice_pic_order_cnt_lsb
Definition: cbs_h265.h:467
int num
Numerator.
Definition: rational.h:59
uint8_t sps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:283
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
static const AVClass vaapi_encode_h265_class
uint8_t tiles_enabled_flag
Definition: cbs_h265.h:384
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
Definition: avcodec.h:905
int8_t slice_qp_delta
Definition: cbs_h265.h:518
uint8_t restricted_ref_pic_lists_flag
Definition: cbs_h265.h:177
GLint GLenum type
Definition: opengl_enc.c:104
Mastering display metadata associated with a video frame.
Definition: frame.h:119
H265RawProfileTierLevel profile_tier_level
Definition: cbs_h265.h:260
int8_t slice_beta_offset_div2
Definition: cbs_h265.h:528
int has_primaries
Flag indicating whether the display primaries (and white point) are set.
static av_cold int vaapi_encode_h265_close(AVCodecContext *avctx)
uint8_t collocated_from_l0_flag
Definition: cbs_h265.h:497
CodedBitstreamContext * cbc
void * codec_sequence_params
Definition: vaapi_encode.h:274
uint8_t sample_adaptive_offset_enabled_flag
Definition: cbs_h265.h:298
uint8_t vui_parameters_present_flag
Definition: cbs_h265.h:318
uint8_t pcm_sample_bit_depth_luma_minus1
Definition: cbs_h265.h:301
static const AVCodecDefault vaapi_encode_h265_defaults[]
uint8_t bit_depth_chroma_minus8
Definition: cbs_h265.h:277
int profile
profile
Definition: avcodec.h:1859
AVCodec.
Definition: codec.h:190
int8_t delta_chroma_log2_weight_denom
Definition: cbs_h265.h:501
float i_quant_offset
qscale offset between P and I-frames
Definition: avcodec.h:838
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
uint8_t general_profile_idc
Definition: cbs_h265.h:46
uint8_t used_by_curr_pic_s0_flag[HEVC_MAX_REFS]
Definition: cbs_h265.h:240
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:649
uint16_t slice_segment_address
Definition: cbs_h265.h:459
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:751
uint32_t vps_num_units_in_tick
Definition: cbs_h265.h:214
uint8_t sign_data_hiding_enabled_flag
Definition: cbs_h265.h:363
#define FF_LEVEL_UNKNOWN
Definition: avcodec.h:1983
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:72
uint16_t conf_win_right_offset
Definition: cbs_h265.h:272
#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:75
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
H265RawSEIContentLightLevelInfo sei_content_light_level
uint8_t slice_deblocking_filter_disabled_flag
Definition: cbs_h265.h:527
uint16_t pic_height_in_luma_samples
Definition: cbs_h265.h:268
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
#define av_cold
Definition: attributes.h:88
int8_t slice_tc_offset_div2
Definition: cbs_h265.h:529
AVOptions.
int8_t slice_cb_qp_offset
Definition: cbs_h265.h:519
uint8_t colour_primaries
Definition: cbs_h265.h:148
uint8_t vps_sub_layer_ordering_info_present_flag
Definition: cbs_h265.h:204
uint8_t general_max_12bit_constraint_flag
Definition: cbs_h265.h:55
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:795
uint8_t five_minus_max_num_merge_cand
Definition: cbs_h265.h:515
#define FF_PROFILE_HEVC_MAIN
Definition: avcodec.h:1947
uint8_t video_format
Definition: cbs_h265.h:145
H265RawSTRefPicSet short_term_ref_pic_set
Definition: cbs_h265.h:470
uint8_t vps_timing_info_present_flag
Definition: cbs_h265.h:213
uint8_t log2_max_pic_order_cnt_lsb_minus4
Definition: cbs_h265.h:279
uint8_t constrained_intra_pred_flag
Definition: cbs_h265.h:371
uint32_t sps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:284
Structure to hold side data for an AVFrame.
Definition: frame.h:214
const H265RawProfileTierLevel * ptl
Definition: h265_levels.c:170
uint8_t matrix_coefficients
Definition: cbs_h265.h:150
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
uint8_t aspect_ratio_info_present_flag
Definition: cbs_h265.h:136
uint8_t vps_max_sub_layers_minus1
Definition: cbs_h265.h:199
struct VAAPIEncodePicture * prev
Definition: vaapi_encode.h:119
#define AVERROR_EOF
End of file.
Definition: error.h:55
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:210
H265RawSEIPayload payload[H265_MAX_SEI_PAYLOADS]
Definition: cbs_h265.h:724
uint8_t general_max_monochrome_constraint_flag
Definition: cbs_h265.h:60
VASurfaceID recon_surface
Definition: vaapi_encode.h:94
uint8_t log2_min_luma_transform_block_size_minus2
Definition: cbs_h265.h:288
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
Definition: rational.c:35
static const uint8_t header[24]
Definition: sdr2.c:67
uint8_t sps_scaling_list_data_present_flag
Definition: cbs_h265.h:294
uint8_t log2_min_pcm_luma_coding_block_size_minus3
Definition: cbs_h265.h:303
static int vaapi_encode_h265_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au)
#define FF_PROFILE_HEVC_MAIN_10
Definition: avcodec.h:1948
uint8_t video_full_range_flag
Definition: cbs_h265.h:146
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:1168
#define FFALIGN(x, a)
Definition: macros.h:48
#define av_log(a,...)
void ff_cbs_fragment_reset(CodedBitstreamFragment *frag)
Free the units contained in a fragment as well as the fragment&#39;s own data buffer, but not the units a...
Definition: cbs.c:147
uint8_t chroma_sample_loc_type_bottom_field
Definition: cbs_h265.h:154
union H265RawSEIPayload::@34 payload
uint16_t vps_num_layer_sets_minus1
Definition: cbs_h265.h:210
uint8_t video_signal_type_present_flag
Definition: cbs_h265.h:144
const char * name
Definition: pixdesc.h:82
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:131
H265RawVUI vui
Definition: cbs_h265.h:319
uint8_t uniform_spacing_flag
Definition: cbs_h265.h:389
unsigned int va_rc_mode
Definition: vaapi_encode.h:230
uint32_t vui_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:170
uint8_t vps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:205
uint8_t log2_max_mv_length_vertical
Definition: cbs_h265.h:182
AVHWFramesContext * input_frames
Definition: vaapi_encode.h:249
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
uint8_t vps_video_parameter_set_id
Definition: cbs_h265.h:194
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
int row_height[MAX_TILE_ROWS]
Definition: vaapi_encode.h:314
uint8_t conformance_window_flag
Definition: cbs_h265.h:270
uint8_t max_bits_per_min_cu_denom
Definition: cbs_h265.h:180
static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
uint8_t dependent_slice_segment_flag
Definition: cbs_h265.h:458
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
uint8_t chroma_loc_info_present_flag
Definition: cbs_h265.h:152
#define PROFILE(name, value)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:215
static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
uint8_t num_negative_pics
Definition: cbs_h265.h:237
const AVCodecHWConfigInternal * ff_vaapi_encode_hw_configs[]
Definition: vaapi_encode.c:31
simple assert() macros that are a bit more flexible than ISO C assert().
const char * name
Name of the codec implementation.
Definition: codec.h:197
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:831
static const AVOption vaapi_encode_h265_options[]
uint8_t general_interlaced_source_flag
Definition: cbs_h265.h:51
static const AVCodecDefault defaults[]
Definition: amfenc_h264.c:361
unsigned int va_bit_rate
Definition: vaapi_encode.h:232
uint8_t general_tier_flag
Definition: cbs_h265.h:45
uint8_t transform_skip_enabled_flag
Definition: cbs_h265.h:372
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:192
uint8_t pcm_sample_bit_depth_chroma_minus1
Definition: cbs_h265.h:302
uint16_t sar_height
Definition: cbs_h265.h:139
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
void * codec_picture_params
Definition: vaapi_encode.h:103
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
Definition: cbs.h:135
#define fail()
Definition: checkasm.h:123
uint8_t chroma_sample_loc_type_top_field
Definition: cbs_h265.h:153
uint8_t vps_max_layers_minus1
Definition: cbs_h265.h:198
uint32_t vui_time_scale
Definition: cbs_h265.h:168
static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice)
uint16_t conf_win_bottom_offset
Definition: cbs_h265.h:274
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:446
static const VAAPIEncodeType vaapi_encode_type_h265
uint8_t slice_type
Definition: cbs_h265.h:462
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
uint8_t scaling_list_enabled_flag
Definition: cbs_h265.h:293
uint32_t payload_type
Definition: cbs_h265.h:694
H265RawProfileTierLevel profile_tier_level
Definition: cbs_h265.h:202
#define FFMIN(a, b)
Definition: common.h:96
uint8_t general_max_422chroma_constraint_flag
Definition: cbs_h265.h:58
uint16_t sar_width
Definition: cbs_h265.h:138
AVRational min_luminance
Min luminance of mastering display (cd/m^2).
uint8_t transquant_bypass_enabled_flag
Definition: cbs_h265.h:383
int width
picture width / height.
Definition: avcodec.h:699
uint8_t general_intra_constraint_flag
Definition: cbs_h265.h:61
uint32_t vps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:207
uint8_t vui_hrd_parameters_present_flag
Definition: cbs_h265.h:171
#define FLAGS
uint16_t delta_poc_s1_minus1[HEVC_MAX_REFS]
Definition: cbs_h265.h:241
const VAAPIEncodeProfile * profile
Definition: vaapi_encode.h:217
uint8_t diff_cu_qp_delta_depth
Definition: cbs_h265.h:374
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:1860
const VAAPIEncodeProfile * profiles
Definition: vaapi_encode.h:369
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
AVCodec ff_hevc_vaapi_encoder
static void bit_depth(AudioStatsContext *s, uint64_t mask, uint64_t imask, AVRational *depth)
Definition: af_astats.c:254
uint8_t general_non_packed_constraint_flag
Definition: cbs_h265.h:52
AVFormatContext * ctx
Definition: movenc.c:48
uint8_t colour_plane_id
Definition: cbs_h265.h:465
uint8_t sps_seq_parameter_set_id
Definition: cbs_h265.h:262
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:1140
int level
level
Definition: avcodec.h:1982
AVFrame * input_image
Definition: vaapi_encode.h:90
uint16_t pic_width_in_luma_samples
Definition: cbs_h265.h:267
void * codec_picture_params
Definition: vaapi_encode.h:278
static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic)
uint8_t vps_base_layer_available_flag
Definition: cbs_h265.h:197
int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
uint8_t log2_min_luma_coding_block_size_minus3
Definition: cbs_h265.h:286
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:124
uint8_t pps_seq_parameter_set_id
Definition: cbs_h265.h:358
#define FF_ARRAY_ELEMS(a)
Full range content.
Definition: pixfmt.h:586
int ff_cbs_write_fragment_data(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Write the content of the fragment to its own internal buffer.
Definition: cbs.c:342
if(ret)
uint16_t vps_num_hrd_parameters
Definition: cbs_h265.h:218
uint8_t num_ref_idx_l1_active_minus1
Definition: cbs_h265.h:488
uint8_t general_max_420chroma_constraint_flag
Definition: cbs_h265.h:59
struct VAAPIEncodePicture * refs[MAX_PICTURE_REFERENCES]
Definition: vaapi_encode.h:116
uint8_t used_by_curr_pic_s1_flag[HEVC_MAX_REFS]
Definition: cbs_h265.h:242
#define OFFSET(x)
const H265LevelDescriptor * ff_h265_guess_level(const H265RawProfileTierLevel *ptl, int64_t bitrate, int width, int height, int slice_segments, int tile_rows, int tile_cols, int max_dec_pic_buffering)
Guess the level of a stream from some parameters.
int col_width[MAX_TILE_COLS]
Definition: vaapi_encode.h:312
uint8_t max_bytes_per_pic_denom
Definition: cbs_h265.h:179
uint8_t num_ref_idx_l0_active_minus1
Definition: cbs_h265.h:487
uint8_t payload_count
Definition: cbs_h265.h:725
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:253
static int vaapi_encode_h265_write_slice_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
const struct VAAPIEncodeType * codec
Definition: vaapi_encode.h:179
uint8_t log2_diff_max_min_pcm_luma_coding_block_size
Definition: cbs_h265.h:304
Libavcodec external API header.
#define VAAPI_ENCODE_RC_OPTIONS
Definition: vaapi_encode.h:463
uint8_t entropy_coding_sync_enabled_flag
Definition: cbs_h265.h:385
uint16_t row_height_minus1[HEVC_MAX_TILE_ROWS]
Definition: cbs_h265.h:391
uint8_t weighted_bipred_flag
Definition: cbs_h265.h:381
uint16_t conf_win_top_offset
Definition: cbs_h265.h:273
uint8_t sps_temporal_mvp_enabled_flag
Definition: cbs_h265.h:315
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:118
uint8_t general_level_idc
Definition: cbs_h265.h:68
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
main external API structure.
Definition: avcodec.h:526
int8_t slice_cr_qp_offset
Definition: cbs_h265.h:520
uint32_t vui_num_units_in_tick
Definition: cbs_h265.h:167
uint8_t short_term_ref_pic_set_sps_flag
Definition: cbs_h265.h:469
uint8_t slice_loop_filter_across_slices_enabled_flag
Definition: cbs_h265.h:530
uint8_t luma_log2_weight_denom
Definition: cbs_h265.h:500
uint8_t max_transform_hierarchy_depth_intra
Definition: cbs_h265.h:291
uint8_t mvd_l1_zero_flag
Definition: cbs_h265.h:495
uint8_t * data
Definition: frame.h:216
uint8_t pps_loop_filter_across_slices_enabled_flag
Definition: cbs_h265.h:394
uint8_t weighted_pred_flag
Definition: cbs_h265.h:380
uint8_t sps_temporal_id_nesting_flag
Definition: cbs_h265.h:258
int8_t pps_cb_qp_offset
Definition: cbs_h265.h:376
H265RawSEIMasteringDisplayColourVolume mastering_display
Definition: cbs_h265.h:707
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
uint8_t vps_max_layer_id
Definition: cbs_h265.h:209
uint16_t conf_win_left_offset
Definition: cbs_h265.h:271
Describe the class of an AVClass context structure.
Definition: log.h:67
uint8_t collocated_ref_idx
Definition: cbs_h265.h:498
uint8_t amp_enabled_flag
Definition: cbs_h265.h:297
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Context structure for coded bitstream operations.
Definition: cbs.h:170
int index
Definition: gxfenc.c:89
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:1154
Rational number (pair of numerator and denominator).
Definition: rational.h:58
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:1147
Mastering display metadata capable of representing the color volume of the display used to master the...
uint8_t general_max_10bit_constraint_flag
Definition: cbs_h265.h:56
static int vaapi_encode_h265_write_extra_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
int ff_cbs_insert_unit_content(CodedBitstreamFragment *frag, int position, CodedBitstreamUnitType type, void *content, AVBufferRef *content_buf)
Insert a new unit into a fragment with the given content.
Definition: cbs.c:721
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
uint8_t chroma_format_idc
Definition: cbs_h265.h:264
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:121
float b_quant_offset
qscale offset between IP and B-frames
Definition: avcodec.h:808
uint8_t general_lower_bit_rate_constraint_flag
Definition: cbs_h265.h:63
offset must point to two consecutive integers
Definition: opt.h:235
uint8_t general_profile_compatibility_flag[32]
Definition: cbs_h265.h:48
uint8_t vps_base_layer_internal_flag
Definition: cbs_h265.h:196
AVRational display_primaries[3][2]
CIE 1931 xy chromaticity coords of color primaries (r, g, b order).
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:300
mfxU16 profile
Definition: qsvenc.c:45
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
uint8_t pcm_loop_filter_disabled_flag
Definition: cbs_h265.h:305
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:355
#define VAAPI_ENCODE_COMMON_OPTIONS
Definition: vaapi_encode.h:445
static int vaapi_encode_h265_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
uint8_t num_positive_pics
Definition: cbs_h265.h:238
uint8_t general_frame_only_constraint_flag
Definition: cbs_h265.h:53
uint8_t level
Definition: svq3.c:205
int8_t pps_cr_qp_offset
Definition: cbs_h265.h:377
static const VAAPIEncodeProfile vaapi_encode_h265_profiles[]
uint8_t slice_pic_parameter_set_id
Definition: cbs_h265.h:456
uint8_t vui_poc_proportional_to_timing_flag
Definition: cbs_h265.h:169
uint8_t general_progressive_source_flag
Definition: cbs_h265.h:50
uint8_t max_transform_hierarchy_depth_inter
Definition: cbs_h265.h:290
static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
VAAPIEncodeContext common
common internal api header.
common internal and external API header
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
uint8_t pps_scaling_list_data_present_flag
Definition: cbs_h265.h:401
uint8_t cabac_init_flag
Definition: cbs_h265.h:496
uint8_t num_tile_rows_minus1
Definition: cbs_h265.h:388
uint8_t pcm_enabled_flag
Definition: cbs_h265.h:300
uint8_t slice_sao_luma_flag
Definition: cbs_h265.h:483
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
uint8_t num_tile_columns_minus1
Definition: cbs_h265.h:387
int den
Denominator.
Definition: rational.h:60
uint16_t delta_poc_s0_minus1[HEVC_MAX_REFS]
Definition: cbs_h265.h:239
uint8_t log2_diff_max_min_luma_coding_block_size
Definition: cbs_h265.h:287
CodedBitstreamFragment current_access_unit
uint8_t slice_sao_chroma_flag
Definition: cbs_h265.h:484
#define FF_PROFILE_HEVC_REXT
Definition: avcodec.h:1950
void * priv_data
Definition: avcodec.h:553
uint8_t vps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:206
H265RawSliceHeader header
Definition: cbs_h265.h:542
H265RawSEIMasteringDisplayColourVolume sei_mastering_display
uint32_t vps_time_scale
Definition: cbs_h265.h:215
uint8_t num_short_term_ref_pic_sets
Definition: cbs_h265.h:307
void * codec_slice_params
Definition: vaapi_encode.h:67
uint16_t column_width_minus1[HEVC_MAX_TILE_COLUMNS]
Definition: cbs_h265.h:390
uint8_t log2_parallel_merge_level_minus2
Definition: cbs_h265.h:405
uint8_t vps_temporal_id_nesting_flag
Definition: cbs_h265.h:200
#define lrint
Definition: tablegen.h:53
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:161
uint8_t aspect_ratio_idc
Definition: cbs_h265.h:137
unsigned int desired_packed_headers
Definition: vaapi_encode.h:201
#define LEVEL(name, value)
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:452
uint8_t num_long_term_sps
Definition: cbs_h265.h:473
uint8_t general_profile_space
Definition: cbs_h265.h:44
uint8_t sps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:282
#define FFSWAP(type, a, b)
Definition: common.h:99
int8_t init_qp_minus26
Definition: cbs_h265.h:369
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
uint32_t vps_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:217
int depth
Number of bits in the component.
Definition: pixdesc.h:58
uint8_t separate_colour_plane_flag
Definition: cbs_h265.h:265
VABufferID output_buffer
Definition: vaapi_encode.h:100
uint8_t strong_intra_smoothing_enabled_flag
Definition: cbs_h265.h:316
uint8_t colour_description_present_flag
Definition: cbs_h265.h:147
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:222
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
unsigned MaxFALL
Max average light level per frame (cd/m^2).
struct VAAPIEncodePicture * dpb[MAX_DPB_SIZE]
Definition: vaapi_encode.h:112
uint8_t log2_diff_max_min_luma_transform_block_size
Definition: cbs_h265.h:289
uint8_t long_term_ref_pics_present_flag
Definition: cbs_h265.h:310
uint8_t num_ref_idx_active_override_flag
Definition: cbs_h265.h:486
uint8_t layer_id_included_flag[HEVC_MAX_LAYER_SETS][HEVC_MAX_LAYERS]
Definition: cbs_h265.h:211
for(j=16;j >0;--j)
av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
int i
Definition: input.c:407
uint8_t nal_unit_type
Definition: cbs_h265.h:38
uint8_t num_ref_idx_l1_default_active_minus1
Definition: cbs_h265.h:367
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:722
uint8_t first_slice_segment_in_pic_flag
Definition: cbs_h265.h:454
uint8_t cu_qp_delta_enabled_flag
Definition: cbs_h265.h:373
bitstream writer API