FFmpeg
vaapi_encode_h264.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_h264.h>
23 
24 #include "libavutil/avassert.h"
25 #include "libavutil/common.h"
26 #include "libavutil/mem.h"
27 #include "libavutil/pixdesc.h"
28 #include "libavutil/opt.h"
29 
30 #include "atsc_a53.h"
31 #include "avcodec.h"
32 #include "cbs.h"
33 #include "cbs_h264.h"
34 #include "codec_internal.h"
35 #include "h264.h"
36 #include "hw_base_encode_h264.h"
37 #include "h264_levels.h"
38 #include "h2645data.h"
39 #include "vaapi_encode.h"
40 #include "version.h"
41 
42 enum {
43  SEI_TIMING = 0x01,
46  SEI_A53_CC = 0x08,
47 };
48 
49 // Random (version 4) ISO 11578 UUID.
50 static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16] = {
51  0x59, 0x94, 0x8b, 0x28, 0x11, 0xec, 0x45, 0xaf,
52  0x96, 0x75, 0x19, 0xd4, 0x1f, 0xea, 0xa9, 0x4d,
53 };
54 
55 typedef struct VAAPIEncodeH264Picture {
56  int frame_num;
58 
60  uint16_t idr_pic_id;
61 
64 
65  int cpb_delay;
66  int dpb_delay;
68 
69 typedef struct VAAPIEncodeH264Context {
72 
73  // User options.
74  int qp;
75  int quality;
76  int coder;
77  int aud;
78  int sei;
79  int profile;
80  int level;
81 
82  // Derived settings.
83  int mb_width;
84  int mb_height;
85 
89 
90  // Writer structures.
93 
96 
103 
108 
109 
111  char *data, size_t *data_len,
113 {
114  VAAPIEncodeH264Context *priv = avctx->priv_data;
115  int err;
116 
117  err = ff_cbs_write_fragment_data(priv->cbc, au);
118  if (err < 0) {
119  av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
120  return err;
121  }
122 
123  if (*data_len < 8 * au->data_size - au->data_bit_padding) {
124  av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
125  "%zu < %zu.\n", *data_len,
126  8 * au->data_size - au->data_bit_padding);
127  return AVERROR(ENOSPC);
128  }
129 
130  memcpy(data, au->data, au->data_size);
131  *data_len = 8 * au->data_size - au->data_bit_padding;
132 
133  return 0;
134 }
135 
138  void *nal_unit)
139 {
140  H264RawNALUnitHeader *header = nal_unit;
141  int err;
142 
143  err = ff_cbs_insert_unit_content(au, -1,
144  header->nal_unit_type, nal_unit, NULL);
145  if (err < 0) {
146  av_log(avctx, AV_LOG_ERROR, "Failed to add NAL unit: "
147  "type = %d.\n", header->nal_unit_type);
148  return err;
149  }
150 
151  return 0;
152 }
153 
155  char *data, size_t *data_len)
156 {
157  VAAPIEncodeH264Context *priv = avctx->priv_data;
159  int err;
160 
161  if (priv->aud_needed) {
162  err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
163  if (err < 0)
164  goto fail;
165  priv->aud_needed = 0;
166  }
167 
168  err = vaapi_encode_h264_add_nal(avctx, au, &priv->units.raw_sps);
169  if (err < 0)
170  goto fail;
171 
172  err = vaapi_encode_h264_add_nal(avctx, au, &priv->units.raw_pps);
173  if (err < 0)
174  goto fail;
175 
176  err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
177 fail:
179  return err;
180 }
181 
183  VAAPIEncodePicture *pic,
184  VAAPIEncodeSlice *slice,
185  char *data, size_t *data_len)
186 {
187  VAAPIEncodeH264Context *priv = avctx->priv_data;
189  int err;
190 
191  if (priv->aud_needed) {
192  err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
193  if (err < 0)
194  goto fail;
195  priv->aud_needed = 0;
196  }
197 
198  err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_slice);
199  if (err < 0)
200  goto fail;
201 
202  err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
203 fail:
205  return err;
206 }
207 
210  int index, int *type,
211  char *data, size_t *data_len)
212 {
213  VAAPIEncodeH264Context *priv = avctx->priv_data;
215  int err;
216 
217  if (priv->sei_needed) {
218  if (priv->aud_needed) {
219  err = vaapi_encode_h264_add_nal(avctx, au, &priv->raw_aud);
220  if (err < 0)
221  goto fail;
222  priv->aud_needed = 0;
223  }
224 
225  if (priv->sei_needed & SEI_IDENTIFIER) {
226  err = ff_cbs_sei_add_message(priv->cbc, au, 1,
228  &priv->sei_identifier, NULL);
229  if (err < 0)
230  goto fail;
231  }
232  if (priv->sei_needed & SEI_TIMING) {
233  if (base->type == FF_HW_PICTURE_TYPE_IDR) {
234  err = ff_cbs_sei_add_message(priv->cbc, au, 1,
237  if (err < 0)
238  goto fail;
239  }
240  err = ff_cbs_sei_add_message(priv->cbc, au, 1,
242  &priv->sei_pic_timing, NULL);
243  if (err < 0)
244  goto fail;
245  }
246  if (priv->sei_needed & SEI_RECOVERY_POINT) {
247  err = ff_cbs_sei_add_message(priv->cbc, au, 1,
249  &priv->sei_recovery_point, NULL);
250  if (err < 0)
251  goto fail;
252  }
253  if (priv->sei_needed & SEI_A53_CC) {
254  err = ff_cbs_sei_add_message(priv->cbc, au, 1,
256  &priv->sei_a53cc, NULL);
257  if (err < 0)
258  goto fail;
259  }
260 
261  priv->sei_needed = 0;
262 
263  err = vaapi_encode_h264_write_access_unit(avctx, data, data_len, au);
264  if (err < 0)
265  goto fail;
266 
268 
269  *type = VAEncPackedHeaderRawData;
270  return 0;
271 
272 #if !CONFIG_VAAPI_1
273  } else if (priv->sei_cbr_workaround_needed) {
274  // Insert a zero-length header using the old SEI type. This is
275  // required to avoid triggering broken behaviour on Intel platforms
276  // in CBR mode where an invalid SEI message is generated by the
277  // driver and inserted into the stream.
278  *data_len = 0;
279  *type = VAEncPackedHeaderH264_SEI;
280  priv->sei_cbr_workaround_needed = 0;
281  return 0;
282 #endif
283 
284  } else {
285  return AVERROR_EOF;
286  }
287 
288 fail:
290  return err;
291 }
292 
294 {
295  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
296  VAAPIEncodeContext *ctx = avctx->priv_data;
297  VAAPIEncodeH264Context *priv = avctx->priv_data;
298  H264RawSPS *sps = &priv->units.raw_sps;
299  H264RawPPS *pps = &priv->units.raw_pps;
300  VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
301  VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params;
302 
303  FFHWBaseEncodeH264Opts unit_opts = {
304  .flags = (priv->sei & SEI_TIMING) ? FF_HW_H264_SEI_TIMING : 0,
305  .mb_width = priv->mb_width,
306  .mb_height = priv->mb_height,
307  .cabac = priv->coder,
308  .hrd_buffer_size = ctx->hrd_params.buffer_size,
309  .fixed_qp_idr = priv->fixed_qp_idr,
310  .initial_buffer_fullness = ctx->hrd_params.initial_buffer_fullness,
311  .bit_rate = ctx->va_bit_rate,
312  };
313 
314  int err = ff_hw_base_encode_init_params_h264(base_ctx, avctx,
315  &priv->units, &unit_opts);
316  if (err < 0)
317  return err;
318 
319  *vseq = (VAEncSequenceParameterBufferH264) {
320  .seq_parameter_set_id = sps->seq_parameter_set_id,
321  .level_idc = sps->level_idc,
322  .intra_period = base_ctx->gop_size,
323  .intra_idr_period = base_ctx->gop_size,
324  .ip_period = base_ctx->b_per_p + 1,
325 
326  .bits_per_second = ctx->va_bit_rate,
327  .max_num_ref_frames = sps->max_num_ref_frames,
328  .picture_width_in_mbs = sps->pic_width_in_mbs_minus1 + 1,
329  .picture_height_in_mbs = sps->pic_height_in_map_units_minus1 + 1,
330 
331  .seq_fields.bits = {
332  .chroma_format_idc = sps->chroma_format_idc,
333  .frame_mbs_only_flag = sps->frame_mbs_only_flag,
334  .mb_adaptive_frame_field_flag = sps->mb_adaptive_frame_field_flag,
335  .seq_scaling_matrix_present_flag = sps->seq_scaling_matrix_present_flag,
336  .direct_8x8_inference_flag = sps->direct_8x8_inference_flag,
337  .log2_max_frame_num_minus4 = sps->log2_max_frame_num_minus4,
338  .pic_order_cnt_type = sps->pic_order_cnt_type,
339  .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_pic_order_cnt_lsb_minus4,
340  .delta_pic_order_always_zero_flag = sps->delta_pic_order_always_zero_flag,
341  },
342 
343  .bit_depth_luma_minus8 = sps->bit_depth_luma_minus8,
344  .bit_depth_chroma_minus8 = sps->bit_depth_chroma_minus8,
345 
346  .frame_cropping_flag = sps->frame_cropping_flag,
347  .frame_crop_left_offset = sps->frame_crop_left_offset,
348  .frame_crop_right_offset = sps->frame_crop_right_offset,
349  .frame_crop_top_offset = sps->frame_crop_top_offset,
350  .frame_crop_bottom_offset = sps->frame_crop_bottom_offset,
351 
352  .vui_parameters_present_flag = sps->vui_parameters_present_flag,
353 
354  .vui_fields.bits = {
355  .aspect_ratio_info_present_flag = sps->vui.aspect_ratio_info_present_flag,
356  .timing_info_present_flag = sps->vui.timing_info_present_flag,
357  .bitstream_restriction_flag = sps->vui.bitstream_restriction_flag,
358  .log2_max_mv_length_horizontal = sps->vui.log2_max_mv_length_horizontal,
359  .log2_max_mv_length_vertical = sps->vui.log2_max_mv_length_vertical,
360  },
361 
362  .aspect_ratio_idc = sps->vui.aspect_ratio_idc,
363  .sar_width = sps->vui.sar_width,
364  .sar_height = sps->vui.sar_height,
365  .num_units_in_tick = sps->vui.num_units_in_tick,
366  .time_scale = sps->vui.time_scale,
367  };
368 
369  *vpic = (VAEncPictureParameterBufferH264) {
370  .CurrPic = {
371  .picture_id = VA_INVALID_ID,
372  .flags = VA_PICTURE_H264_INVALID,
373  },
374 
375  .coded_buf = VA_INVALID_ID,
376 
377  .pic_parameter_set_id = pps->pic_parameter_set_id,
378  .seq_parameter_set_id = pps->seq_parameter_set_id,
379 
380  .pic_init_qp = pps->pic_init_qp_minus26 + 26,
381  .num_ref_idx_l0_active_minus1 = pps->num_ref_idx_l0_default_active_minus1,
382  .num_ref_idx_l1_active_minus1 = pps->num_ref_idx_l1_default_active_minus1,
383 
384  .chroma_qp_index_offset = pps->chroma_qp_index_offset,
385  .second_chroma_qp_index_offset = pps->second_chroma_qp_index_offset,
386 
387  .pic_fields.bits = {
388  .entropy_coding_mode_flag = pps->entropy_coding_mode_flag,
389  .weighted_pred_flag = pps->weighted_pred_flag,
390  .weighted_bipred_idc = pps->weighted_bipred_idc,
391  .constrained_intra_pred_flag = pps->constrained_intra_pred_flag,
392  .transform_8x8_mode_flag = pps->transform_8x8_mode_flag,
393  .deblocking_filter_control_present_flag =
394  pps->deblocking_filter_control_present_flag,
395  .redundant_pic_cnt_present_flag = pps->redundant_pic_cnt_present_flag,
396  .pic_order_present_flag =
397  pps->bottom_field_pic_order_in_frame_present_flag,
398  .pic_scaling_matrix_present_flag = pps->pic_scaling_matrix_present_flag,
399  },
400  };
401 
402  return 0;
403 }
404 
407 {
408  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
409 #if !CONFIG_VAAPI_1
410  VAAPIEncodeContext *ctx = avctx->priv_data;
411 #endif
412  VAAPIEncodeH264Context *priv = avctx->priv_data;
413  VAAPIEncodePicture *vaapi_pic = pic->priv;
414  VAAPIEncodeH264Picture *hpic = pic->codec_priv;
415  FFHWBaseEncodePicture *prev = pic->prev;
416  VAAPIEncodeH264Picture *hprev = prev ? prev->codec_priv : NULL;
417  VAEncPictureParameterBufferH264 *vpic = vaapi_pic->codec_picture_params;
418  int i, j = 0;
419 
420  if (pic->type == FF_HW_PICTURE_TYPE_IDR) {
421  av_assert0(pic->display_order == pic->encode_order);
422 
423  hpic->frame_num = 0;
424  hpic->last_idr_frame = pic->display_order;
425  hpic->idr_pic_id = hprev ? hprev->idr_pic_id + 1 : 0;
426 
427  hpic->primary_pic_type = 0;
428  hpic->slice_type = 7;
429  } else {
430  av_assert0(prev);
431 
432  hpic->frame_num = hprev->frame_num + prev->is_reference;
433 
434  hpic->last_idr_frame = hprev->last_idr_frame;
435  hpic->idr_pic_id = hprev->idr_pic_id;
436 
437  if (pic->type == FF_HW_PICTURE_TYPE_I) {
438  hpic->slice_type = 7;
439  hpic->primary_pic_type = 0;
440  } else if (pic->type == FF_HW_PICTURE_TYPE_P) {
441  hpic->slice_type = 5;
442  hpic->primary_pic_type = 1;
443  } else {
444  hpic->slice_type = 6;
445  hpic->primary_pic_type = 2;
446  }
447  }
448  hpic->pic_order_cnt = pic->display_order - hpic->last_idr_frame;
449  if (priv->units.raw_sps.pic_order_cnt_type == 2) {
450  hpic->pic_order_cnt *= 2;
451  }
452 
453  hpic->dpb_delay = pic->display_order - pic->encode_order + base_ctx->max_b_depth;
454  hpic->cpb_delay = pic->encode_order - hpic->last_idr_frame;
455 
456  if (priv->aud) {
457  priv->aud_needed = 1;
458  priv->raw_aud = (H264RawAUD) {
459  .nal_unit_header = {
461  },
462  .primary_pic_type = hpic->primary_pic_type,
463  };
464  } else {
465  priv->aud_needed = 0;
466  }
467 
468  priv->sei_needed = 0;
469 
470  if (priv->sei & SEI_IDENTIFIER && pic->encode_order == 0)
471  priv->sei_needed |= SEI_IDENTIFIER;
472 #if !CONFIG_VAAPI_1
473  if (ctx->va_rc_mode == VA_RC_CBR)
474  priv->sei_cbr_workaround_needed = 1;
475 #endif
476 
477  if (priv->sei & SEI_TIMING) {
479  .cpb_removal_delay = 2 * hpic->cpb_delay,
480  .dpb_output_delay = 2 * hpic->dpb_delay,
481  };
482 
483  priv->sei_needed |= SEI_TIMING;
484  }
485 
486  if (priv->sei & SEI_RECOVERY_POINT && pic->type == FF_HW_PICTURE_TYPE_I) {
488  .recovery_frame_cnt = 0,
489  .exact_match_flag = 1,
490  .broken_link_flag = base_ctx->b_per_p > 0,
491  };
492 
494  }
495 
496  if (priv->sei & SEI_A53_CC) {
497  int err;
498  size_t sei_a53cc_len;
499  av_freep(&priv->sei_a53cc_data);
500  err = ff_alloc_a53_sei(pic->input_image, 0, &priv->sei_a53cc_data, &sei_a53cc_len);
501  if (err < 0)
502  return err;
503  if (priv->sei_a53cc_data != NULL) {
504  priv->sei_a53cc.itu_t_t35_country_code = 181;
505  priv->sei_a53cc.data = (uint8_t *)priv->sei_a53cc_data + 1;
506  priv->sei_a53cc.data_length = sei_a53cc_len - 1;
507 
508  priv->sei_needed |= SEI_A53_CC;
509  }
510  }
511 
512  vpic->CurrPic = (VAPictureH264) {
513  .picture_id = vaapi_pic->recon_surface,
514  .frame_idx = hpic->frame_num,
515  .flags = 0,
516  .TopFieldOrderCnt = hpic->pic_order_cnt,
517  .BottomFieldOrderCnt = hpic->pic_order_cnt,
518  };
519  for (int k = 0; k < MAX_REFERENCE_LIST_NUM; k++) {
520  for (i = 0; i < pic->nb_refs[k]; i++) {
521  FFHWBaseEncodePicture *ref = pic->refs[k][i];
523 
524  av_assert0(ref && ref->encode_order < pic->encode_order);
525  href = ref->codec_priv;
526 
527  vpic->ReferenceFrames[j++] = (VAPictureH264) {
528  .picture_id = ((VAAPIEncodePicture *)ref->priv)->recon_surface,
529  .frame_idx = href->frame_num,
530  .flags = VA_PICTURE_H264_SHORT_TERM_REFERENCE,
531  .TopFieldOrderCnt = href->pic_order_cnt,
532  .BottomFieldOrderCnt = href->pic_order_cnt,
533  };
534  }
535  }
536 
537  for (; j < FF_ARRAY_ELEMS(vpic->ReferenceFrames); j++) {
538  vpic->ReferenceFrames[j] = (VAPictureH264) {
539  .picture_id = VA_INVALID_ID,
540  .flags = VA_PICTURE_H264_INVALID,
541  };
542  }
543 
544  vpic->coded_buf = vaapi_pic->output_buffer;
545 
546  vpic->frame_num = hpic->frame_num;
547 
548  vpic->pic_fields.bits.idr_pic_flag = (pic->type == FF_HW_PICTURE_TYPE_IDR);
549  vpic->pic_fields.bits.reference_pic_flag = pic->is_reference;
550 
551  return 0;
552 }
553 
556  FFHWBaseEncodePicture **rpl0,
557  FFHWBaseEncodePicture **rpl1,
558  int *rpl_size)
559 {
560  FFHWBaseEncodePicture *prev;
561  VAAPIEncodeH264Picture *hp, *hn, *hc;
562  int i, j, n = 0;
563 
564  prev = pic->prev;
565  av_assert0(prev);
566  hp = pic->codec_priv;
567 
568  for (i = 0; i < pic->prev->nb_dpb_pics; i++) {
569  hn = prev->dpb[i]->codec_priv;
570  av_assert0(hn->frame_num < hp->frame_num);
571 
572  if (pic->type == FF_HW_PICTURE_TYPE_P) {
573  for (j = n; j > 0; j--) {
574  hc = rpl0[j - 1]->codec_priv;
575  av_assert0(hc->frame_num != hn->frame_num);
576  if (hc->frame_num > hn->frame_num)
577  break;
578  rpl0[j] = rpl0[j - 1];
579  }
580  rpl0[j] = prev->dpb[i];
581 
582  } else if (pic->type == FF_HW_PICTURE_TYPE_B) {
583  for (j = n; j > 0; j--) {
584  hc = rpl0[j - 1]->codec_priv;
586  if (hc->pic_order_cnt < hp->pic_order_cnt) {
587  if (hn->pic_order_cnt > hp->pic_order_cnt ||
588  hn->pic_order_cnt < hc->pic_order_cnt)
589  break;
590  } else {
591  if (hn->pic_order_cnt > hc->pic_order_cnt)
592  break;
593  }
594  rpl0[j] = rpl0[j - 1];
595  }
596  rpl0[j] = prev->dpb[i];
597 
598  for (j = n; j > 0; j--) {
599  hc = rpl1[j - 1]->codec_priv;
601  if (hc->pic_order_cnt > hp->pic_order_cnt) {
602  if (hn->pic_order_cnt < hp->pic_order_cnt ||
603  hn->pic_order_cnt > hc->pic_order_cnt)
604  break;
605  } else {
606  if (hn->pic_order_cnt < hc->pic_order_cnt)
607  break;
608  }
609  rpl1[j] = rpl1[j - 1];
610  }
611  rpl1[j] = prev->dpb[i];
612  }
613 
614  ++n;
615  }
616 
617  if (pic->type == FF_HW_PICTURE_TYPE_B) {
618  for (i = 0; i < n; i++) {
619  if (rpl0[i] != rpl1[i])
620  break;
621  }
622  if (i == n)
623  FFSWAP(FFHWBaseEncodePicture *, rpl1[0], rpl1[1]);
624  }
625 
626  if (pic->type == FF_HW_PICTURE_TYPE_P ||
627  pic->type == FF_HW_PICTURE_TYPE_B) {
628  av_log(avctx, AV_LOG_DEBUG, "Default RefPicList0 for fn=%d/poc=%d:",
629  hp->frame_num, hp->pic_order_cnt);
630  for (i = 0; i < n; i++) {
631  hn = rpl0[i]->codec_priv;
632  av_log(avctx, AV_LOG_DEBUG, " fn=%d/poc=%d",
633  hn->frame_num, hn->pic_order_cnt);
634  }
635  av_log(avctx, AV_LOG_DEBUG, "\n");
636  }
637  if (pic->type == FF_HW_PICTURE_TYPE_B) {
638  av_log(avctx, AV_LOG_DEBUG, "Default RefPicList1 for fn=%d/poc=%d:",
639  hp->frame_num, hp->pic_order_cnt);
640  for (i = 0; i < n; i++) {
641  hn = rpl1[i]->codec_priv;
642  av_log(avctx, AV_LOG_DEBUG, " fn=%d/poc=%d",
643  hn->frame_num, hn->pic_order_cnt);
644  }
645  av_log(avctx, AV_LOG_DEBUG, "\n");
646  }
647 
648  *rpl_size = n;
649 }
650 
653  VAAPIEncodeSlice *slice)
654 {
655  VAAPIEncodeH264Context *priv = avctx->priv_data;
656  VAAPIEncodePicture *vaapi_pic = pic->priv;
657  VAAPIEncodeH264Picture *hpic = pic->codec_priv;
658  FFHWBaseEncodePicture *prev = pic->prev;
659  H264RawSPS *sps = &priv->units.raw_sps;
660  H264RawPPS *pps = &priv->units.raw_pps;
661  H264RawSliceHeader *sh = &priv->raw_slice.header;
662  VAEncPictureParameterBufferH264 *vpic = vaapi_pic->codec_picture_params;
663  VAEncSliceParameterBufferH264 *vslice = slice->codec_slice_params;
664  int i, j;
665 
666  if (pic->type == FF_HW_PICTURE_TYPE_IDR) {
669  } else {
672  }
673 
674  sh->first_mb_in_slice = slice->block_start;
675  sh->slice_type = hpic->slice_type;
676 
677  sh->pic_parameter_set_id = pps->pic_parameter_set_id;
678 
679  sh->frame_num = hpic->frame_num &
680  ((1 << (4 + sps->log2_max_frame_num_minus4)) - 1);
681  sh->idr_pic_id = hpic->idr_pic_id;
682  sh->pic_order_cnt_lsb = hpic->pic_order_cnt &
683  ((1 << (4 + sps->log2_max_pic_order_cnt_lsb_minus4)) - 1);
684 
686 
687  if (pic->type == FF_HW_PICTURE_TYPE_B)
688  sh->slice_qp_delta = priv->fixed_qp_b - (pps->pic_init_qp_minus26 + 26);
689  else if (pic->type == FF_HW_PICTURE_TYPE_P)
690  sh->slice_qp_delta = priv->fixed_qp_p - (pps->pic_init_qp_minus26 + 26);
691  else
692  sh->slice_qp_delta = priv->fixed_qp_idr - (pps->pic_init_qp_minus26 + 26);
693 
694  if (pic->is_reference && pic->type != FF_HW_PICTURE_TYPE_IDR) {
695  FFHWBaseEncodePicture *discard_list[MAX_DPB_SIZE];
696  int discard = 0, keep = 0;
697 
698  // Discard everything which is in the DPB of the previous frame but
699  // not in the DPB of this one.
700  for (i = 0; i < prev->nb_dpb_pics; i++) {
701  for (j = 0; j < pic->nb_dpb_pics; j++) {
702  if (prev->dpb[i] == pic->dpb[j])
703  break;
704  }
705  if (j == pic->nb_dpb_pics) {
706  discard_list[discard] = prev->dpb[i];
707  ++discard;
708  } else {
709  ++keep;
710  }
711  }
712  av_assert0(keep <= priv->units.dpb_frames);
713 
714  if (discard == 0) {
716  } else {
718  for (i = 0; i < discard; i++) {
719  VAAPIEncodeH264Picture *old = discard_list[i]->codec_priv;
720  av_assert0(old->frame_num < hpic->frame_num);
723  hpic->frame_num - old->frame_num - 1;
724  }
726  }
727  }
728 
729  // If the intended references are not the first entries of RefPicListN
730  // by default, use ref-pic-list-modification to move them there.
731  if (pic->type == FF_HW_PICTURE_TYPE_P || pic->type == FF_HW_PICTURE_TYPE_B) {
734  int n;
735 
737  def_l0, def_l1, &n);
738 
739  if (pic->type == FF_HW_PICTURE_TYPE_P) {
740  int need_rplm = 0;
741  for (i = 0; i < pic->nb_refs[0]; i++) {
742  av_assert0(pic->refs[0][i]);
743  if (pic->refs[0][i] != (FFHWBaseEncodePicture *)def_l0[i])
744  need_rplm = 1;
745  }
746 
747  sh->ref_pic_list_modification_flag_l0 = need_rplm;
748  if (need_rplm) {
749  int pic_num = hpic->frame_num;
750  for (i = 0; i < pic->nb_refs[0]; i++) {
751  href = pic->refs[0][i]->codec_priv;
752  av_assert0(href->frame_num != pic_num);
753  if (href->frame_num < pic_num) {
756  pic_num - href->frame_num - 1;
757  } else {
760  href->frame_num - pic_num - 1;
761  }
762  pic_num = href->frame_num;
763  }
765  }
766 
767  } else {
768  int need_rplm_l0 = 0, need_rplm_l1 = 0;
769  int n0 = 0, n1 = 0;
770  for (i = 0; i < pic->nb_refs[0]; i++) {
771  av_assert0(pic->refs[0][i]);
772  href = pic->refs[0][i]->codec_priv;
773  av_assert0(href->pic_order_cnt < hpic->pic_order_cnt);
774  if (pic->refs[0][i] != (FFHWBaseEncodePicture *)def_l0[n0])
775  need_rplm_l0 = 1;
776  ++n0;
777  }
778 
779  for (i = 0; i < pic->nb_refs[1]; i++) {
780  av_assert0(pic->refs[1][i]);
781  href = pic->refs[1][i]->codec_priv;
782  av_assert0(href->pic_order_cnt > hpic->pic_order_cnt);
783  if (pic->refs[1][i] != (FFHWBaseEncodePicture *)def_l1[n1])
784  need_rplm_l1 = 1;
785  ++n1;
786  }
787 
788  sh->ref_pic_list_modification_flag_l0 = need_rplm_l0;
789  if (need_rplm_l0) {
790  int pic_num = hpic->frame_num;
791  for (i = j = 0; i < pic->nb_refs[0]; i++) {
792  href = pic->refs[0][i]->codec_priv;
793  av_assert0(href->frame_num != pic_num);
794  if (href->frame_num < pic_num) {
797  pic_num - href->frame_num - 1;
798  } else {
801  href->frame_num - pic_num - 1;
802  }
803  pic_num = href->frame_num;
804  ++j;
805  }
806  av_assert0(j == n0);
808  }
809 
810  sh->ref_pic_list_modification_flag_l1 = need_rplm_l1;
811  if (need_rplm_l1) {
812  int pic_num = hpic->frame_num;
813  for (i = j = 0; i < pic->nb_refs[1]; i++) {
814  href = pic->refs[1][i]->codec_priv;
815  av_assert0(href->frame_num != pic_num);
816  if (href->frame_num < pic_num) {
819  pic_num - href->frame_num - 1;
820  } else {
823  href->frame_num - pic_num - 1;
824  }
825  pic_num = href->frame_num;
826  ++j;
827  }
828  av_assert0(j == n1);
830  }
831  }
832  }
833 
834  vslice->macroblock_address = slice->block_start;
835  vslice->num_macroblocks = slice->block_size;
836 
837  vslice->macroblock_info = VA_INVALID_ID;
838 
839  vslice->slice_type = sh->slice_type % 5;
840  vslice->pic_parameter_set_id = sh->pic_parameter_set_id;
841  vslice->idr_pic_id = sh->idr_pic_id;
842 
843  vslice->pic_order_cnt_lsb = sh->pic_order_cnt_lsb;
844 
845  vslice->direct_spatial_mv_pred_flag = sh->direct_spatial_mv_pred_flag;
846 
847  for (i = 0; i < FF_ARRAY_ELEMS(vslice->RefPicList0); i++) {
848  vslice->RefPicList0[i].picture_id = VA_INVALID_ID;
849  vslice->RefPicList0[i].flags = VA_PICTURE_H264_INVALID;
850  vslice->RefPicList1[i].picture_id = VA_INVALID_ID;
851  vslice->RefPicList1[i].flags = VA_PICTURE_H264_INVALID;
852  }
853 
854  if (pic->nb_refs[0]) {
855  // Backward reference for P- or B-frame.
857  pic->type == FF_HW_PICTURE_TYPE_B);
858  vslice->RefPicList0[0] = vpic->ReferenceFrames[0];
859  }
860  if (pic->nb_refs[1]) {
861  // Forward reference for B-frame.
863  vslice->RefPicList1[0] = vpic->ReferenceFrames[1];
864  }
865 
866  vslice->slice_qp_delta = sh->slice_qp_delta;
867 
868  return 0;
869 }
870 
872 {
873  VAAPIEncodeContext *ctx = avctx->priv_data;
874  VAAPIEncodeH264Context *priv = avctx->priv_data;
875  int err;
876 
877  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_H264, avctx);
878  if (err < 0)
879  return err;
880 
881  priv->mb_width = FFALIGN(avctx->width, 16) / 16;
882  priv->mb_height = FFALIGN(avctx->height, 16) / 16;
883 
884  if (ctx->va_rc_mode == VA_RC_CQP) {
885  priv->fixed_qp_p = av_clip(ctx->rc_quality, 1, 51);
886  if (avctx->i_quant_factor > 0.0)
887  priv->fixed_qp_idr =
888  av_clip((avctx->i_quant_factor * priv->fixed_qp_p +
889  avctx->i_quant_offset) + 0.5, 1, 51);
890  else
891  priv->fixed_qp_idr = priv->fixed_qp_p;
892  if (avctx->b_quant_factor > 0.0)
893  priv->fixed_qp_b =
894  av_clip((avctx->b_quant_factor * priv->fixed_qp_p +
895  avctx->b_quant_offset) + 0.5, 1, 51);
896  else
897  priv->fixed_qp_b = priv->fixed_qp_p;
898 
899  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
900  "%d / %d / %d for IDR- / P- / B-frames.\n",
901  priv->fixed_qp_idr, priv->fixed_qp_p, priv->fixed_qp_b);
902 
903  } else {
904  // These still need to be set for pic_init_qp/slice_qp_delta.
905  priv->fixed_qp_idr = 26;
906  priv->fixed_qp_p = 26;
907  priv->fixed_qp_b = 26;
908  }
909 
910  if (!ctx->rc_mode->hrd) {
911  // Timing SEI requires a mode respecting HRD parameters.
912  priv->sei &= ~SEI_TIMING;
913  }
914 
915  if (priv->sei & SEI_IDENTIFIER) {
916  const char *lavc = LIBAVCODEC_IDENT;
917  const char *vaapi = VA_VERSION_S;
918  const char *driver;
919  int len;
920 
921  memcpy(priv->sei_identifier.uuid_iso_iec_11578,
923  sizeof(priv->sei_identifier.uuid_iso_iec_11578));
924 
925  driver = vaQueryVendorString(ctx->hwctx->display);
926  if (!driver)
927  driver = "unknown driver";
928 
929  len = snprintf(NULL, 0, "%s / VAAPI %s / %s", lavc, vaapi, driver);
930  if (len >= 0) {
931  priv->sei_identifier_string = av_malloc(len + 1);
932  if (!priv->sei_identifier_string)
933  return AVERROR(ENOMEM);
934 
936  "%s / VAAPI %s / %s", lavc, vaapi, driver);
937 
939  priv->sei_identifier.data_length = len + 1;
940  }
941  }
942 
943  ctx->roi_quant_range = 51 + 6 * (ctx->profile->depth - 8);
944 
945  return 0;
946 }
947 
949 #if VA_CHECK_VERSION(1, 18, 0)
950  { AV_PROFILE_H264_HIGH_10, 10, 3, 1, 1, VAProfileH264High10 },
951 #endif
952  { AV_PROFILE_H264_HIGH, 8, 3, 1, 1, VAProfileH264High },
953  { AV_PROFILE_H264_MAIN, 8, 3, 1, 1, VAProfileH264Main },
955  8, 3, 1, 1, VAProfileH264ConstrainedBaseline },
957 };
958 
961 
962  .flags = FF_HW_FLAG_SLICE_CONTROL |
966 
967  .default_quality = 20,
968 
969  .configure = &vaapi_encode_h264_configure,
970 
971  .picture_priv_data_size = sizeof(VAAPIEncodeH264Picture),
972 
973  .sequence_params_size = sizeof(VAEncSequenceParameterBufferH264),
974  .init_sequence_params = &vaapi_encode_h264_init_sequence_params,
975 
976  .picture_params_size = sizeof(VAEncPictureParameterBufferH264),
977  .init_picture_params = &vaapi_encode_h264_init_picture_params,
978 
979  .slice_params_size = sizeof(VAEncSliceParameterBufferH264),
980  .init_slice_params = &vaapi_encode_h264_init_slice_params,
981 
982  .sequence_header_type = VAEncPackedHeaderSequence,
983  .write_sequence_header = &vaapi_encode_h264_write_sequence_header,
984 
985  .slice_header_type = VAEncPackedHeaderH264_Slice,
986  .write_slice_header = &vaapi_encode_h264_write_slice_header,
987 
988  .write_extra_header = &vaapi_encode_h264_write_extra_header,
989 };
990 
992 {
993  FFHWBaseEncodeContext *base_ctx = avctx->priv_data;
994  VAAPIEncodeContext *ctx = avctx->priv_data;
995  VAAPIEncodeH264Context *priv = avctx->priv_data;
996 
997  ctx->codec = &vaapi_encode_type_h264;
998 
999  if (avctx->profile == AV_PROFILE_UNKNOWN)
1000  avctx->profile = priv->profile;
1001  if (avctx->level == AV_LEVEL_UNKNOWN)
1002  avctx->level = priv->level;
1004  avctx->compression_level = priv->quality;
1005 
1006  // Reject unsupported profiles.
1007  switch (avctx->profile) {
1009  av_log(avctx, AV_LOG_WARNING, "H.264 baseline profile is not "
1010  "supported, using constrained baseline profile instead.\n");
1012  break;
1014  av_log(avctx, AV_LOG_ERROR, "H.264 extended profile "
1015  "is not supported.\n");
1016  return AVERROR_PATCHWELCOME;
1018  av_log(avctx, AV_LOG_ERROR, "H.264 high 10 intra profile "
1019  "is not supported.\n");
1020  return AVERROR_PATCHWELCOME;
1027  av_log(avctx, AV_LOG_ERROR, "H.264 non-4:2:0 profiles "
1028  "are not supported.\n");
1029  return AVERROR_PATCHWELCOME;
1030  }
1031 
1032  if (avctx->level != AV_LEVEL_UNKNOWN && avctx->level & ~0xff) {
1033  av_log(avctx, AV_LOG_ERROR, "Invalid level %d: must fit "
1034  "in 8-bit unsigned integer.\n", avctx->level);
1035  return AVERROR(EINVAL);
1036  }
1037 
1038  ctx->desired_packed_headers =
1039  VA_ENC_PACKED_HEADER_SEQUENCE | // SPS and PPS.
1040  VA_ENC_PACKED_HEADER_SLICE | // Slice headers.
1041  VA_ENC_PACKED_HEADER_MISC; // SEI.
1042 
1043  base_ctx->surface_width = FFALIGN(avctx->width, 16);
1044  base_ctx->surface_height = FFALIGN(avctx->height, 16);
1045 
1046  base_ctx->slice_block_height = base_ctx->slice_block_width = 16;
1047 
1048  if (priv->qp > 0)
1049  ctx->explicit_qp = priv->qp;
1050 
1051  return ff_vaapi_encode_init(avctx);
1052 }
1053 
1055 {
1056  VAAPIEncodeH264Context *priv = avctx->priv_data;
1057 
1059  ff_cbs_close(&priv->cbc);
1061  av_freep(&priv->sei_a53cc_data);
1062 
1063  return ff_vaapi_encode_close(avctx);
1064 }
1065 
1066 #define OFFSET(x) offsetof(VAAPIEncodeH264Context, x)
1067 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
1072 
1073  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
1074  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 52, FLAGS },
1075  { "quality", "Set encode quality (trades off against speed, higher is faster)",
1076  OFFSET(quality), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, FLAGS },
1077  { "coder", "Entropy coder type",
1078  OFFSET(coder), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 1, FLAGS, .unit = "coder" },
1079  { "cavlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, .unit = "coder" },
1080  { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, .unit = "coder" },
1081  { "vlc", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, INT_MIN, INT_MAX, FLAGS, .unit = "coder" },
1082  { "ac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, FLAGS, .unit = "coder" },
1083 
1084  { "aud", "Include AUD",
1085  OFFSET(aud), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS },
1086 
1087  { "sei", "Set SEI to include",
1090  0, INT_MAX, FLAGS, .unit = "sei" },
1091  { "identifier", "Include encoder version identifier",
1092  0, AV_OPT_TYPE_CONST, { .i64 = SEI_IDENTIFIER },
1093  INT_MIN, INT_MAX, FLAGS, .unit = "sei" },
1094  { "timing", "Include timing parameters (buffering_period and pic_timing)",
1095  0, AV_OPT_TYPE_CONST, { .i64 = SEI_TIMING },
1096  INT_MIN, INT_MAX, FLAGS, .unit = "sei" },
1097  { "recovery_point", "Include recovery points where appropriate",
1098  0, AV_OPT_TYPE_CONST, { .i64 = SEI_RECOVERY_POINT },
1099  INT_MIN, INT_MAX, FLAGS, .unit = "sei" },
1100  { "a53_cc", "Include A/53 caption data",
1101  0, AV_OPT_TYPE_CONST, { .i64 = SEI_A53_CC },
1102  INT_MIN, INT_MAX, FLAGS, .unit = "sei" },
1103 
1104  { "profile", "Set profile (profile_idc and constraint_set*_flag)",
1106  { .i64 = AV_PROFILE_UNKNOWN }, AV_PROFILE_UNKNOWN, 0xffff, FLAGS, .unit = "profile" },
1107 
1108 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1109  { .i64 = value }, 0, 0, FLAGS, .unit = "profile"
1110  { PROFILE("constrained_baseline", AV_PROFILE_H264_CONSTRAINED_BASELINE) },
1111  { PROFILE("main", AV_PROFILE_H264_MAIN) },
1112  { PROFILE("high", AV_PROFILE_H264_HIGH) },
1113  { PROFILE("high10", AV_PROFILE_H264_HIGH_10) },
1114 #undef PROFILE
1115 
1116  { "level", "Set level (level_idc)",
1118  { .i64 = AV_LEVEL_UNKNOWN }, AV_LEVEL_UNKNOWN, 0xff, FLAGS, .unit = "level" },
1119 
1120 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
1121  { .i64 = value }, 0, 0, FLAGS, .unit = "level"
1122  { LEVEL("1", 10) },
1123  { LEVEL("1.1", 11) },
1124  { LEVEL("1.2", 12) },
1125  { LEVEL("1.3", 13) },
1126  { LEVEL("2", 20) },
1127  { LEVEL("2.1", 21) },
1128  { LEVEL("2.2", 22) },
1129  { LEVEL("3", 30) },
1130  { LEVEL("3.1", 31) },
1131  { LEVEL("3.2", 32) },
1132  { LEVEL("4", 40) },
1133  { LEVEL("4.1", 41) },
1134  { LEVEL("4.2", 42) },
1135  { LEVEL("5", 50) },
1136  { LEVEL("5.1", 51) },
1137  { LEVEL("5.2", 52) },
1138  { LEVEL("6", 60) },
1139  { LEVEL("6.1", 61) },
1140  { LEVEL("6.2", 62) },
1141 #undef LEVEL
1142 
1143  { NULL },
1144 };
1145 
1147  { "b", "0" },
1148  { "bf", "2" },
1149  { "g", "120" },
1150  { "i_qfactor", "1" },
1151  { "i_qoffset", "0" },
1152  { "b_qfactor", "6/5" },
1153  { "b_qoffset", "0" },
1154  { "qmin", "-1" },
1155  { "qmax", "-1" },
1156  { NULL },
1157 };
1158 
1160  .class_name = "h264_vaapi",
1161  .item_name = av_default_item_name,
1162  .option = vaapi_encode_h264_options,
1163  .version = LIBAVUTIL_VERSION_INT,
1164 };
1165 
1167  .p.name = "h264_vaapi",
1168  CODEC_LONG_NAME("H.264/AVC (VAAPI)"),
1169  .p.type = AVMEDIA_TYPE_VIDEO,
1170  .p.id = AV_CODEC_ID_H264,
1171  .priv_data_size = sizeof(VAAPIEncodeH264Context),
1174  .close = &vaapi_encode_h264_close,
1175  .p.priv_class = &vaapi_encode_h264_class,
1176  .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE |
1178  .caps_internal = FF_CODEC_CAP_NOT_INIT_THREADSAFE |
1180  .defaults = vaapi_encode_h264_defaults,
1181  .p.pix_fmts = (const enum AVPixelFormat[]) {
1184  },
1185  .color_ranges = AVCOL_RANGE_MPEG | AVCOL_RANGE_JPEG,
1186  .hw_configs = ff_vaapi_encode_hw_configs,
1187  .p.wrapper_name = "vaapi",
1188 };
FLAGS
#define FLAGS
Definition: vaapi_encode_h264.c:1067
VAAPIEncodeH264Context::sei_identifier_string
char * sei_identifier_string
Definition: vaapi_encode_h264.c:100
ff_alloc_a53_sei
int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len, void **data, size_t *sei_size)
Check AVFrame for A53 side data and allocate and fill SEI message with A53 info.
Definition: atsc_a53.c:26
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
OFFSET
#define OFFSET(x)
Definition: vaapi_encode_h264.c:1066
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
level
uint8_t level
Definition: svq3.c:205
AV_PROFILE_H264_HIGH_10_INTRA
#define AV_PROFILE_H264_HIGH_10_INTRA
Definition: defs.h:116
av_clip
#define av_clip
Definition: common.h:100
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
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
FFHWBaseEncodeH264Opts
Definition: hw_base_encode_h264.h:34
FF_HW_PICTURE_TYPE_P
@ FF_HW_PICTURE_TYPE_P
Definition: hw_base_encode.h:41
LIBAVCODEC_IDENT
#define LIBAVCODEC_IDENT
Definition: version.h:43
SEIRawUserDataRegistered
Definition: cbs_sei.h:33
FFHWBaseEncodePicture::priv
void * priv
Definition: hw_base_encode.h:63
VAAPIEncodeH264Picture
Definition: vaapi_encode_h264.c:55
FFHWBaseEncodePicture::codec_priv
void * codec_priv
Definition: hw_base_encode.h:65
h264_levels.h
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
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
AV_PROFILE_H264_MAIN
#define AV_PROFILE_H264_MAIN
Definition: defs.h:112
ff_cbs_sei_add_message
int ff_cbs_sei_add_message(CodedBitstreamContext *ctx, CodedBitstreamFragment *au, int prefix, uint32_t payload_type, void *payload_data, void *payload_ref)
Add an SEI message to an access unit.
Definition: cbs_sei.c:267
cbs_h264.h
FFHWBaseEncodeH264Opts::flags
int flags
Definition: hw_base_encode_h264.h:35
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
vaapi_encode_h264_sei_identifier_uuid
static const uint8_t vaapi_encode_h264_sei_identifier_uuid[16]
Definition: vaapi_encode_h264.c:50
pixdesc.h
H264_NAL_AUD
@ H264_NAL_AUD
Definition: h264.h:43
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
vaapi_encode_h264_class
static const AVClass vaapi_encode_h264_class
Definition: vaapi_encode_h264.c:1159
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:219
VAAPIEncodeSlice
Definition: vaapi_encode.h:56
VAAPIEncodeH264Context::aud
int aud
Definition: vaapi_encode_h264.c:77
AVOption
AVOption.
Definition: opt.h:429
data
const char data[16]
Definition: mxf.c:149
AVCodecContext::b_quant_offset
float b_quant_offset
qscale offset between IP and B-frames
Definition: avcodec.h:817
VAAPIEncodeSlice::block_start
int block_start
Definition: vaapi_encode.h:60
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
VAAPIEncodeH264Context::sei_a53cc
SEIRawUserDataRegistered sei_a53cc
Definition: vaapi_encode_h264.c:101
FFCodec
Definition: codec_internal.h:127
version.h
VAAPIEncodeH264Context::units
FFHWBaseEncodeH264 units
Definition: vaapi_encode_h264.c:71
base
uint8_t base
Definition: vp3data.h:128
VAAPIEncodeH264Context::sei_recovery_point
H264RawSEIRecoveryPoint sei_recovery_point
Definition: vaapi_encode_h264.c:98
ff_hw_base_encode_init_params_h264
int ff_hw_base_encode_init_params_h264(FFHWBaseEncodeContext *base_ctx, AVCodecContext *avctx, FFHWBaseEncodeH264 *common, FFHWBaseEncodeH264Opts *opts)
Definition: hw_base_encode_h264.c:26
ff_vaapi_encode_close
av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
Definition: vaapi_encode.c:2275
cbs.h
FF_HW_FLAG_B_PICTURE_REFERENCES
@ FF_HW_FLAG_B_PICTURE_REFERENCES
Definition: hw_base_encode.h:55
FFHWBaseEncodeContext::slice_block_width
int slice_block_width
Definition: hw_base_encode.h:144
VAAPIEncodeH264Context::mb_height
int mb_height
Definition: vaapi_encode_h264.c:84
FF_COMPRESSION_DEFAULT
#define FF_COMPRESSION_DEFAULT
Definition: avcodec.h:1256
FFHWBaseEncodeContext::slice_block_height
int slice_block_height
Definition: hw_base_encode.h:145
quality
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
Definition: rate_distortion.txt:12
H264RawSliceHeader::nal_unit_header
H264RawNALUnitHeader nal_unit_header
Definition: cbs_h264.h:331
ff_cbs_close
av_cold void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:142
av_malloc
#define av_malloc(s)
Definition: tableprint_vlc.h:30
H264RawSliceHeader::direct_spatial_mv_pred_flag
uint8_t direct_spatial_mv_pred_flag
Definition: cbs_h264.h:351
FFHWBaseEncodeContext
Definition: hw_base_encode.h:122
AV_PROFILE_H264_EXTENDED
#define AV_PROFILE_H264_EXTENDED
Definition: defs.h:113
H264RawSEIRecoveryPoint::recovery_frame_cnt
uint16_t recovery_frame_cnt
Definition: cbs_h264.h:269
VAAPIEncodeH264Context::level
int level
Definition: vaapi_encode_h264.c:80
H264RawSEIPicTiming
Definition: cbs_h264.h:249
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
FFCodecDefault
Definition: codec_internal.h:97
FFCodec::p
AVCodec p
The public AVCodec.
Definition: codec_internal.h:131
VAAPIEncodeH264Picture::pic_order_cnt
int pic_order_cnt
Definition: vaapi_encode_h264.c:57
FFHWBaseEncodePicture::type
int type
Definition: hw_base_encode.h:78
vaapi_encode.h
SEIRawUserDataUnregistered::data
uint8_t * data
RefStruct reference.
Definition: cbs_sei.h:42
FFHWBaseEncodePicture::is_reference
int is_reference
Definition: hw_base_encode.h:87
fail
#define fail()
Definition: checkasm.h:193
FFHWBaseEncodeH264
Definition: hw_base_encode_h264.h:25
VAAPIEncodePicture
Definition: vaapi_encode.h:65
VAAPIEncodeH264Context
Definition: vaapi_encode_h264.c:69
SEIRawUserDataUnregistered
Definition: cbs_sei.h:40
FF_HW_FLAG_SLICE_CONTROL
@ FF_HW_FLAG_SLICE_CONTROL
Definition: hw_base_encode.h:47
FF_HW_FLAG_B_PICTURES
@ FF_HW_FLAG_B_PICTURES
Definition: hw_base_encode.h:53
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
H264RawSliceHeader::pic_order_cnt_lsb
uint16_t pic_order_cnt_lsb
Definition: cbs_h264.h:346
FFHWBaseEncodePicture::prev
struct FFHWBaseEncodePicture * prev
Definition: hw_base_encode.h:101
AVFormatContext::bit_rate
int64_t bit_rate
Total stream bitrate in bit/s, 0 if not available.
Definition: avformat.h:1442
avassert.h
H264RawSliceHeader::first_mb_in_slice
uint32_t first_mb_in_slice
Definition: cbs_h264.h:333
SEIRawUserDataRegistered::itu_t_t35_country_code
uint8_t itu_t_t35_country_code
Definition: cbs_sei.h:34
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
LEVEL
#define LEVEL(name, value)
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
vaapi_encode_h264_init
static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
Definition: vaapi_encode_h264.c:991
VAAPIEncodeH264Context::fixed_qp_idr
int fixed_qp_idr
Definition: vaapi_encode_h264.c:86
H264RawSliceHeader::slice_qp_delta
int8_t slice_qp_delta
Definition: cbs_h264.h:396
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:135
VAAPIEncodeH264Context::quality
int quality
Definition: vaapi_encode_h264.c:75
SEI_IDENTIFIER
@ SEI_IDENTIFIER
Definition: vaapi_encode_h264.c:44
H264RawNALUnitHeader::nal_unit_type
uint8_t nal_unit_type
Definition: cbs_h264.h:33
AV_PROFILE_H264_HIGH_10
#define AV_PROFILE_H264_HIGH_10
Definition: defs.h:115
FFHWBaseEncodeContext::max_b_depth
int max_b_depth
Definition: hw_base_encode.h:188
H264RawSliceHeader::frame_num
uint16_t frame_num
Definition: cbs_h264.h:340
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
H264RawAUD::nal_unit_header
H264RawNALUnitHeader nal_unit_header
Definition: cbs_h264.h:219
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:40
SEIRawUserDataUnregistered::data_length
size_t data_length
Definition: cbs_sei.h:43
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:230
VAAPIEncodeH264Picture::cpb_delay
int cpb_delay
Definition: vaapi_encode_h264.c:65
ctx
AVFormatContext * ctx
Definition: movenc.c:49
SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
@ SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35
Definition: sei.h:34
FF_HW_PICTURE_TYPE_IDR
@ FF_HW_PICTURE_TYPE_IDR
Definition: hw_base_encode.h:39
vaapi_encode_h264_options
static const AVOption vaapi_encode_h264_options[]
Definition: vaapi_encode_h264.c:1068
AV_PROFILE_H264_HIGH_422_INTRA
#define AV_PROFILE_H264_HIGH_422_INTRA
Definition: defs.h:119
ff_vaapi_encode_receive_packet
int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
Definition: vaapi_encode.c:2086
VAAPIEncodeH264Context::fixed_qp_b
int fixed_qp_b
Definition: vaapi_encode_h264.c:88
VAAPIEncodeH264Context::sei_pic_timing
H264RawSEIPicTiming sei_pic_timing
Definition: vaapi_encode_h264.c:97
CodedBitstreamFragment::data_bit_padding
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
Definition: cbs.h:139
H264_NAL_SLICE
@ H264_NAL_SLICE
Definition: h264.h:35
VAAPIEncodeH264Context::coder
int coder
Definition: vaapi_encode_h264.c:76
h2645data.h
VAAPIEncodeType
Definition: vaapi_encode.h:265
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
H264RawSliceHeader::rplm_l0
struct H264RawSliceHeader::@70 rplm_l0[H264_MAX_RPLM_COUNT]
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
AV_PROFILE_H264_HIGH_422
#define AV_PROFILE_H264_HIGH_422
Definition: defs.h:118
FFHWBaseEncodeH264::raw_sps
H264RawSPS raw_sps
Definition: hw_base_encode_h264.h:26
H264RawSliceHeader::adaptive_ref_pic_marking_mode_flag
uint8_t adaptive_ref_pic_marking_mode_flag
Definition: cbs_h264.h:385
FFHWBaseEncodeContext::b_per_p
int b_per_p
Definition: hw_base_encode.h:189
VAAPIEncodeContext
Definition: vaapi_encode.h:145
H264RawSliceHeader::rplm_l1
struct H264RawSliceHeader::@70 rplm_l1[H264_MAX_RPLM_COUNT]
FFHWBaseEncodePicture::dpb
struct FFHWBaseEncodePicture * dpb[MAX_DPB_SIZE]
Definition: hw_base_encode.h:93
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:75
NULL
#define NULL
Definition: coverity.c:32
VAAPIEncodeH264Context::cbc
CodedBitstreamContext * cbc
Definition: vaapi_encode_h264.c:91
VAAPIEncodeH264Picture::dpb_delay
int dpb_delay
Definition: vaapi_encode_h264.c:66
AVERROR_PATCHWELCOME
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
Definition: error.h:64
hw_base_encode_h264.h
VAAPIEncodeH264Context::sei
int sei
Definition: vaapi_encode_h264.c:78
AV_LEVEL_UNKNOWN
#define AV_LEVEL_UNKNOWN
Definition: defs.h:198
VAAPIEncodeType::profiles
const VAAPIEncodeProfile * profiles
Definition: vaapi_encode.h:268
FF_CODEC_RECEIVE_PACKET_CB
#define FF_CODEC_RECEIVE_PACKET_CB(func)
Definition: codec_internal.h:326
H264RawNALUnitHeader
Definition: cbs_h264.h:31
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
VAAPIEncodeH264Context::raw_slice
H264RawSlice raw_slice
Definition: vaapi_encode_h264.c:95
VAAPIEncodeH264Context::fixed_qp_p
int fixed_qp_p
Definition: vaapi_encode_h264.c:87
vaapi_encode_h264_profiles
static const VAAPIEncodeProfile vaapi_encode_h264_profiles[]
Definition: vaapi_encode_h264.c:948
vaapi_encode_h264_add_nal
static int vaapi_encode_h264_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
Definition: vaapi_encode_h264.c:136
sei
static int FUNC() sei(CodedBitstreamContext *ctx, RWContext *rw, H264RawSEI *current)
Definition: cbs_h264_syntax_template.c:858
AVCodecContext::level
int level
Encoding level descriptor.
Definition: avcodec.h:1794
index
int index
Definition: gxfenc.c:90
aud
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
Definition: cbs_h264_syntax_template.c:875
vaapi_encode_h264_write_access_unit
static int vaapi_encode_h264_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au)
Definition: vaapi_encode_h264.c:110
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
H264RawSliceHeader::difference_of_pic_nums_minus1
int32_t difference_of_pic_nums_minus1
Definition: cbs_h264.h:388
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
hn
static float hn(int n, EqParameter *param, float fs)
Definition: af_superequalizer.c:91
FFHWBaseEncodeH264::sei_buffering_period
H264RawSEIBufferingPeriod sei_buffering_period
Definition: hw_base_encode_h264.h:29
codec_internal.h
H264RawNALUnitHeader::nal_ref_idc
uint8_t nal_ref_idc
Definition: cbs_h264.h:32
VAAPI_ENCODE_RC_OPTIONS
#define VAAPI_ENCODE_RC_OPTIONS
Definition: vaapi_encode.h:364
H264RawSliceHeader::slice_type
uint8_t slice_type
Definition: cbs_h264.h:334
FFHWBaseEncodePicture::nb_refs
int nb_refs[MAX_REFERENCE_LIST_NUM]
Definition: hw_base_encode.h:97
MAX_DPB_SIZE
#define MAX_DPB_SIZE
Definition: hw_base_encode.h:26
AV_PROFILE_H264_CAVLC_444
#define AV_PROFILE_H264_CAVLC_444
Definition: defs.h:124
FF_HW_FLAG_NON_IDR_KEY_PICTURES
@ FF_HW_FLAG_NON_IDR_KEY_PICTURES
Definition: hw_base_encode.h:58
SEIRawUserDataRegistered::data
uint8_t * data
RefStruct reference.
Definition: cbs_sei.h:36
vaapi_encode_h264_init_sequence_params
static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
Definition: vaapi_encode_h264.c:293
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:128
FFHWBaseEncodeH264::raw_pps
H264RawPPS raw_pps
Definition: hw_base_encode_h264.h:27
vaapi_encode_h264_write_slice_header
static int vaapi_encode_h264_write_slice_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
Definition: vaapi_encode_h264.c:182
VAAPIEncodeH264Context::mb_width
int mb_width
Definition: vaapi_encode_h264.c:83
VAAPIEncodeH264Context::common
VAAPIEncodeContext common
Definition: vaapi_encode_h264.c:70
header
static const uint8_t header[24]
Definition: sdr2.c:68
vaapi_encode_h264_write_extra_header
static int vaapi_encode_h264_write_extra_header(AVCodecContext *avctx, FFHWBaseEncodePicture *base, int index, int *type, char *data, size_t *data_len)
Definition: vaapi_encode_h264.c:208
FFHWBaseEncodePicture::encode_order
int64_t encode_order
Definition: hw_base_encode.h:70
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
VAAPIEncodePicture::output_buffer
VABufferID output_buffer
Definition: vaapi_encode.h:81
SEIRawUserDataRegistered::data_length
size_t data_length
Definition: cbs_sei.h:37
vaapi_encode_h264_init_slice_params
static int vaapi_encode_h264_init_slice_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, VAAPIEncodeSlice *slice)
Definition: vaapi_encode_h264.c:651
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:126
vaapi_encode_h264_write_sequence_header
static int vaapi_encode_h264_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: vaapi_encode_h264.c:154
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
VAAPIEncodeH264Picture::slice_type
int slice_type
Definition: vaapi_encode_h264.c:63
H264RawSliceHeader
Definition: cbs_h264.h:330
H264RawSlice::header
H264RawSliceHeader header
Definition: cbs_h264.h:409
H264RawSliceHeader::idr_pic_id
uint16_t idr_pic_id
Definition: cbs_h264.h:344
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
VAAPIEncodeH264Context::raw_aud
H264RawAUD raw_aud
Definition: vaapi_encode_h264.c:94
VAAPIEncodeH264Context::aud_needed
int aud_needed
Definition: vaapi_encode_h264.c:104
SEI_RECOVERY_POINT
@ SEI_RECOVERY_POINT
Definition: vaapi_encode_h264.c:45
common.h
VAAPIEncodeH264Context::sei_needed
int sei_needed
Definition: vaapi_encode_h264.c:105
SEI_TYPE_PIC_TIMING
@ SEI_TYPE_PIC_TIMING
Definition: sei.h:31
MAX_REFERENCE_LIST_NUM
#define MAX_REFERENCE_LIST_NUM
Definition: hw_base_encode.h:30
VAAPIEncodeH264Context::sei_a53cc_data
void * sei_a53cc_data
Definition: vaapi_encode_h264.c:102
VAAPIEncodeH264Context::sei_cbr_workaround_needed
int sei_cbr_workaround_needed
Definition: vaapi_encode_h264.c:106
vaapi_encode_h264_close
static av_cold int vaapi_encode_h264_close(AVCodecContext *avctx)
Definition: vaapi_encode_h264.c:1054
H264RawSPS::pic_order_cnt_type
uint8_t pic_order_cnt_type
Definition: cbs_h264.h:129
FFHWBaseEncodePicture::refs
struct FFHWBaseEncodePicture * refs[MAX_REFERENCE_LIST_NUM][MAX_PICTURE_REFERENCES]
Definition: hw_base_encode.h:98
AVCodec::name
const char * name
Name of the codec implementation.
Definition: codec.h:194
len
int len
Definition: vorbis_enc_data.h:426
profile
int profile
Definition: mxfenc.c:2233
vaapi_encode_h264_init_picture_params
static int vaapi_encode_h264_init_picture_params(AVCodecContext *avctx, FFHWBaseEncodePicture *pic)
Definition: vaapi_encode_h264.c:405
H264RawSliceHeader::ref_pic_list_modification_flag_l0
uint8_t ref_pic_list_modification_flag_l0
Definition: cbs_h264.h:357
H264_NAL_IDR_SLICE
@ H264_NAL_IDR_SLICE
Definition: h264.h:39
AVCodecContext::height
int height
Definition: avcodec.h:624
VAAPIEncodeH264Context::qp
int qp
Definition: vaapi_encode_h264.c:74
AVCOL_RANGE_MPEG
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
Definition: pixfmt.h:700
SEI_TIMING
@ SEI_TIMING
Definition: vaapi_encode_h264.c:43
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
VAAPIEncodeH264Picture::primary_pic_type
int primary_pic_type
Definition: vaapi_encode_h264.c:62
avcodec.h
H264RawSliceHeader::memory_management_control_operation
uint8_t memory_management_control_operation
Definition: cbs_h264.h:387
ff_vaapi_encode_hw_configs
const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]
Definition: vaapi_encode.c:36
SEI_A53_CC
@ SEI_A53_CC
Definition: vaapi_encode_h264.c:46
AV_PROFILE_H264_HIGH_444_PREDICTIVE
#define AV_PROFILE_H264_HIGH_444_PREDICTIVE
Definition: defs.h:122
ff_vaapi_encode_init
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
Definition: vaapi_encode.c:2091
FFHWBaseEncodeContext::gop_size
int gop_size
Definition: hw_base_encode.h:184
FFHWBaseEncodePicture
Definition: hw_base_encode.h:61
FFSWAP
#define FFSWAP(type, a, b)
Definition: macros.h:52
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
VAAPIEncodeH264Context::sei_identifier
SEIRawUserDataUnregistered sei_identifier
Definition: vaapi_encode_h264.c:99
VAAPIEncodeH264Picture::frame_num
int frame_num
Definition: vaapi_encode_h264.c:56
VAAPIEncodeH264Picture::idr_pic_id
uint16_t idr_pic_id
Definition: vaapi_encode_h264.c:60
atsc_a53.h
VAAPIEncodeH264Picture::last_idr_frame
int64_t last_idr_frame
Definition: vaapi_encode_h264.c:59
AV_PROFILE_H264_BASELINE
#define AV_PROFILE_H264_BASELINE
Definition: defs.h:110
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
ff_h264_vaapi_encoder
const FFCodec ff_h264_vaapi_encoder
Definition: vaapi_encode_h264.c:1166
VAAPIEncodeH264Context::current_access_unit
CodedBitstreamFragment current_access_unit
Definition: vaapi_encode_h264.c:92
FFHWBaseEncodeContext::surface_height
int surface_height
Definition: hw_base_encode.h:141
AVCodecContext
main external API structure.
Definition: avcodec.h:451
H264RawAUD
Definition: cbs_h264.h:218
AV_PROFILE_H264_HIGH
#define AV_PROFILE_H264_HIGH
Definition: defs.h:114
SEI_TYPE_BUFFERING_PERIOD
@ SEI_TYPE_BUFFERING_PERIOD
Definition: sei.h:30
SEI_TYPE_USER_DATA_UNREGISTERED
@ SEI_TYPE_USER_DATA_UNREGISTERED
Definition: sei.h:35
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
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
AVCodecContext::i_quant_offset
float i_quant_offset
qscale offset between P and I-frames
Definition: avcodec.h:833
H264RawSliceHeader::ref_pic_list_modification_flag_l1
uint8_t ref_pic_list_modification_flag_l1
Definition: cbs_h264.h:358
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:117
pps
uint64_t pps
Definition: dovi_rpuenc.c:35
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
AV_PROFILE_H264_CONSTRAINED_BASELINE
#define AV_PROFILE_H264_CONSTRAINED_BASELINE
Definition: defs.h:111
FFHWBaseEncodeContext::surface_width
int surface_width
Definition: hw_base_encode.h:140
SEI_TYPE_RECOVERY_POINT
@ SEI_TYPE_RECOVERY_POINT
Definition: sei.h:36
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PROFILE_H264_HIGH_444
#define AV_PROFILE_H264_HIGH_444
Definition: defs.h:121
H264RawSEIRecoveryPoint
Definition: cbs_h264.h:268
mem.h
AV_PROFILE_H264_HIGH_444_INTRA
#define AV_PROFILE_H264_HIGH_444_INTRA
Definition: defs.h:123
H264RawSEIPicTiming::cpb_removal_delay
uint32_t cpb_removal_delay
Definition: cbs_h264.h:250
vaapi_encode_type_h264
static const VAAPIEncodeType vaapi_encode_type_h264
Definition: vaapi_encode_h264.c:959
vaapi_encode_h264_configure
static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
Definition: vaapi_encode_h264.c:871
VAAPIEncodeSlice::block_size
int block_size
Definition: vaapi_encode.h:61
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
H264RawSliceHeader::modification_of_pic_nums_idc
uint8_t modification_of_pic_nums_idc
Definition: cbs_h264.h:360
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
FF_HW_H264_SEI_TIMING
#define FF_HW_H264_SEI_TIMING
Definition: hw_base_encode_h264.h:36
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:34
vaapi_encode_h264_defaults
static const FFCodecDefault vaapi_encode_h264_defaults[]
Definition: vaapi_encode_h264.c:1146
PROFILE
#define PROFILE(name, value)
vaapi_encode_h264_default_ref_pic_list
static void vaapi_encode_h264_default_ref_pic_list(AVCodecContext *avctx, FFHWBaseEncodePicture *pic, FFHWBaseEncodePicture **rpl0, FFHWBaseEncodePicture **rpl1, int *rpl_size)
Definition: vaapi_encode_h264.c:554
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:624
FF_HW_PICTURE_TYPE_B
@ FF_HW_PICTURE_TYPE_B
Definition: hw_base_encode.h:42
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
Definition: opt.h:255
h264.h
H264RawSliceHeader::mmco
struct H264RawSliceHeader::@71 mmco[H264_MAX_MMCO_COUNT]
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
SEIRawUserDataUnregistered::uuid_iso_iec_11578
uint8_t uuid_iso_iec_11578[16]
Definition: cbs_sei.h:41
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
VAAPIEncodeH264Context::profile
int profile
Definition: vaapi_encode_h264.c:79
FF_HW_PICTURE_TYPE_I
@ FF_HW_PICTURE_TYPE_I
Definition: hw_base_encode.h:40
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
snprintf
#define snprintf
Definition: snprintf.h:34
H264RawSliceHeader::pic_parameter_set_id
uint8_t pic_parameter_set_id
Definition: cbs_h264.h:336
VAAPIEncodeProfile
Definition: vaapi_encode.h:100
FFHWBaseEncodePicture::nb_dpb_pics
int nb_dpb_pics
Definition: hw_base_encode.h:92
H264RawSliceHeader::abs_diff_pic_num_minus1
int32_t abs_diff_pic_num_minus1
Definition: cbs_h264.h:361
AVCodecContext::compression_level
int compression_level
Definition: avcodec.h:1255
H264RawSlice
Definition: cbs_h264.h:408
H264RawSPS
Definition: cbs_h264.h:102
H264RawPPS
Definition: cbs_h264.h:171