FFmpeg: libavcodec/vaapi_encode_h265.c Source File

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/opt.h"
27 
28 #include "avcodec.h"
29 #include "cbs.h"
30 #include "cbs_h265.h"
31 #include "hevc.h"
32 #include "internal.h"
33 #include "put_bits.h"
34 #include "vaapi_encode.h"
35 
36 
37  typedef struct VAAPIEncodeH265Context {
38   unsigned int ctu_width;
39   unsigned int ctu_height;
40 
41   int fixed_qp_idr;
42   int fixed_qp_p;
43   int fixed_qp_b;
44 
45   H265RawAUD aud;
46   H265RawVPS vps;
47   H265RawSPS sps;
48   H265RawPPS pps;
49   H265RawSlice slice;
50 
51   int64_t last_idr_frame;
52   int pic_order_cnt;
53 
54   int slice_nal_unit;
55   int slice_type;
56   int pic_type;
57 
58   CodedBitstreamContext *cbc;
59   CodedBitstreamFragment current_access_unit;
60   int aud_needed;
61 } VAAPIEncodeH265Context;
62 
63  typedef struct VAAPIEncodeH265Options {
64   int qp;
65   int aud;
66   int profile;
67   int level;
68 } VAAPIEncodeH265Options;
69 
70 
71  static int vaapi_encode_h265_write_access_unit(AVCodecContext *avctx,
72  char *data, size_t *data_len,
73  CodedBitstreamFragment *au)
74 {
75  VAAPIEncodeContext *ctx = avctx->priv_data;
76  VAAPIEncodeH265Context *priv = ctx->priv_data;
77  int err;
78 
79  err = ff_cbs_write_fragment_data(priv->cbc, au);
80  if (err < 0) {
81  av_log(avctx, AV_LOG_ERROR, "Failed to write packed header.\n");
82  return err;
83  }
84 
85  if (*data_len < 8 * au->data_size - au->data_bit_padding) {
86  av_log(avctx, AV_LOG_ERROR, "Access unit too large: "
87  "%zu < %zu.\n", *data_len,
88  8 * au->data_size - au->data_bit_padding);
89  return AVERROR(ENOSPC);
90  }
91 
92  memcpy(data, au->data, au->data_size);
93  *data_len = 8 * au->data_size - au->data_bit_padding;
94 
95  return 0;
96 }
97 
98  static int vaapi_encode_h265_add_nal(AVCodecContext *avctx,
99  CodedBitstreamFragment *au,
100  void *nal_unit)
101 {
102  VAAPIEncodeContext *ctx = avctx->priv_data;
103  VAAPIEncodeH265Context *priv = ctx->priv_data;
104  H265RawNALUnitHeader *header = nal_unit;
105  int err;
106 
107  err = ff_cbs_insert_unit_content(priv->cbc, au, -1,
108  header->nal_unit_type, nal_unit, NULL);
109  if (err < 0) {
110  av_log(avctx, AV_LOG_ERROR, "Failed to add NAL unit: "
111  "type = %d.\n", header->nal_unit_type);
112  return err;
113  }
114 
115  return 0;
116 }
117 
118  static int vaapi_encode_h265_write_sequence_header(AVCodecContext *avctx,
119  char *data, size_t *data_len)
120 {
121  VAAPIEncodeContext *ctx = avctx->priv_data;
122  VAAPIEncodeH265Context *priv = ctx->priv_data;
123  CodedBitstreamFragment *au = &priv->current_access_unit;
124  int err;
125 
126  if (priv->aud_needed) {
127  err = vaapi_encode_h265_add_nal(avctx, au, &priv->aud);
128  if (err < 0)
129  goto fail;
130  priv->aud_needed = 0;
131  }
132 
133  err = vaapi_encode_h265_add_nal(avctx, au, &priv->vps);
134  if (err < 0)
135  goto fail;
136 
137  err = vaapi_encode_h265_add_nal(avctx, au, &priv->sps);
138  if (err < 0)
139  goto fail;
140 
141  err = vaapi_encode_h265_add_nal(avctx, au, &priv->pps);
142  if (err < 0)
143  goto fail;
144 
145  err = vaapi_encode_h265_write_access_unit(avctx, data, data_len, au);
146 fail:
147  ff_cbs_fragment_uninit(priv->cbc, au);
148  return err;
149 }
150 
151  static int vaapi_encode_h265_write_slice_header(AVCodecContext *avctx,
152  VAAPIEncodePicture *pic,
153  VAAPIEncodeSlice *slice,
154  char *data, size_t *data_len)
155 {
156  VAAPIEncodeContext *ctx = avctx->priv_data;
157  VAAPIEncodeH265Context *priv = ctx->priv_data;
158  CodedBitstreamFragment *au = &priv->current_access_unit;
159  int err;
160 
161  if (priv->aud_needed) {
162  err = vaapi_encode_h265_add_nal(avctx, au, &priv->aud);
163  if (err < 0)
164  goto fail;
165  priv->aud_needed = 0;
166  }
167 
168  err = vaapi_encode_h265_add_nal(avctx, au, &priv->slice);
169  if (err < 0)
170  goto fail;
171 
172  err = vaapi_encode_h265_write_access_unit(avctx, data, data_len, au);
173 fail:
174  ff_cbs_fragment_uninit(priv->cbc, au);
175  return err;
176 }
177 
178  static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
179 {
180  VAAPIEncodeContext *ctx = avctx->priv_data;
181  VAAPIEncodeH265Context *priv = ctx->priv_data;
182  H265RawVPS *vps = &priv->vps;
183  H265RawSPS *sps = &priv->sps;
184  H265RawPPS *pps = &priv->pps;
185  H265RawVUI *vui = &sps->vui;
186  VAEncSequenceParameterBufferHEVC *vseq = ctx->codec_sequence_params;
187  VAEncPictureParameterBufferHEVC *vpic = ctx->codec_picture_params;
188  int i;
189 
190  memset(&priv->current_access_unit, 0,
191  sizeof(priv->current_access_unit));
192 
193  memset(vps, 0, sizeof(*vps));
194  memset(sps, 0, sizeof(*sps));
195  memset(pps, 0, sizeof(*pps));
196 
197 
198  // VPS
199 
200  vps->nal_unit_header = (H265RawNALUnitHeader) {
201  .nal_unit_type = HEVC_NAL_VPS,
202  .nuh_layer_id = 0,
203  .nuh_temporal_id_plus1 = 1,
204  };
205 
206  vps->vps_video_parameter_set_id = 0;
207 
208  vps->vps_base_layer_internal_flag = 1;
209  vps->vps_base_layer_available_flag = 1;
210  vps->vps_max_layers_minus1 = 0;
211  vps->vps_max_sub_layers_minus1 = 0;
212  vps->vps_temporal_id_nesting_flag = 1;
213 
214  vps->profile_tier_level = (H265RawProfileTierLevel) {
215  .general_profile_space = 0,
216  .general_profile_idc = avctx->profile,
217  .general_tier_flag = 0,
218 
219  .general_progressive_source_flag = 1,
220  .general_interlaced_source_flag = 0,
221  .general_non_packed_constraint_flag = 1,
222  .general_frame_only_constraint_flag = 1,
223 
224  .general_level_idc = avctx->level,
225  };
226  vps->profile_tier_level.general_profile_compatibility_flag[avctx->profile & 31] = 1;
227 
228  vps->vps_sub_layer_ordering_info_present_flag = 0;
229  vps->vps_max_dec_pic_buffering_minus1[0] = (ctx->b_per_p > 0) + 1;
230  vps->vps_max_num_reorder_pics[0] = (ctx->b_per_p > 0);
231  vps->vps_max_latency_increase_plus1[0] = 0;
232 
233  vps->vps_max_layer_id = 0;
234  vps->vps_num_layer_sets_minus1 = 0;
235  vps->layer_id_included_flag[0][0] = 1;
236 
237  vps->vps_timing_info_present_flag = 1;
238  if (avctx->framerate.num > 0 && avctx->framerate.den > 0) {
239  vps->vps_num_units_in_tick = avctx->framerate.den;
240  vps->vps_time_scale = avctx->framerate.num;
241  vps->vps_poc_proportional_to_timing_flag = 1;
242  vps->vps_num_ticks_poc_diff_one_minus1 = 0;
243  } else {
244  vps->vps_num_units_in_tick = avctx->time_base.num;
245  vps->vps_time_scale = avctx->time_base.den;
246  vps->vps_poc_proportional_to_timing_flag = 0;
247  }
248  vps->vps_num_hrd_parameters = 0;
249 
250 
251  // SPS
252 
253  sps->nal_unit_header = (H265RawNALUnitHeader) {
254  .nal_unit_type = HEVC_NAL_SPS,
255  .nuh_layer_id = 0,
256  .nuh_temporal_id_plus1 = 1,
257  };
258 
259  sps->sps_video_parameter_set_id = vps->vps_video_parameter_set_id;
260 
261  sps->sps_max_sub_layers_minus1 = vps->vps_max_sub_layers_minus1;
262  sps->sps_temporal_id_nesting_flag = vps->vps_temporal_id_nesting_flag;
263 
264  sps->profile_tier_level = vps->profile_tier_level;
265 
266  sps->sps_seq_parameter_set_id = 0;
267 
268  sps->chroma_format_idc = 1; // YUV 4:2:0.
269  sps->separate_colour_plane_flag = 0;
270 
271  sps->pic_width_in_luma_samples = ctx->surface_width;
272  sps->pic_height_in_luma_samples = ctx->surface_height;
273 
274  if (avctx->width != ctx->surface_width ||
275  avctx->height != ctx->surface_height) {
276  sps->conformance_window_flag = 1;
277  sps->conf_win_left_offset = 0;
278  sps->conf_win_right_offset =
279  (ctx->surface_width - avctx->width) / 2;
280  sps->conf_win_top_offset = 0;
281  sps->conf_win_bottom_offset =
282  (ctx->surface_height - avctx->height) / 2;
283  } else {
284  sps->conformance_window_flag = 0;
285  }
286 
287  sps->bit_depth_luma_minus8 =
288  avctx->profile == FF_PROFILE_HEVC_MAIN_10 ? 2 : 0;
289  sps->bit_depth_chroma_minus8 = sps->bit_depth_luma_minus8;
290 
291  sps->log2_max_pic_order_cnt_lsb_minus4 = 8;
292 
293  sps->sps_sub_layer_ordering_info_present_flag =
294  vps->vps_sub_layer_ordering_info_present_flag;
295  for (i = 0; i <= sps->sps_max_sub_layers_minus1; i++) {
296  sps->sps_max_dec_pic_buffering_minus1[i] =
297  vps->vps_max_dec_pic_buffering_minus1[i];
298  sps->sps_max_num_reorder_pics[i] =
299  vps->vps_max_num_reorder_pics[i];
300  sps->sps_max_latency_increase_plus1[i] =
301  vps->vps_max_latency_increase_plus1[i];
302  }
303 
304  // These have to come from the capabilities of the encoder. We have no
305  // way to query them, so just hardcode parameters which work on the Intel
306  // driver.
307  // CTB size from 8x8 to 32x32.
308  sps->log2_min_luma_coding_block_size_minus3 = 0;
309  sps->log2_diff_max_min_luma_coding_block_size = 2;
310  // Transform size from 4x4 to 32x32.
311  sps->log2_min_luma_transform_block_size_minus2 = 0;
312  sps->log2_diff_max_min_luma_transform_block_size = 3;
313  // Full transform hierarchy allowed (2-5).
314  sps->max_transform_hierarchy_depth_inter = 3;
315  sps->max_transform_hierarchy_depth_intra = 3;
316  // AMP works.
317  sps->amp_enabled_flag = 1;
318  // SAO and temporal MVP do not work.
319  sps->sample_adaptive_offset_enabled_flag = 0;
320  sps->sps_temporal_mvp_enabled_flag = 0;
321 
322  sps->pcm_enabled_flag = 0;
323 
324  // STRPSs should ideally be here rather than defined individually in
325  // each slice, but the structure isn't completely fixed so for now
326  // don't bother.
327  sps->num_short_term_ref_pic_sets = 0;
328  sps->long_term_ref_pics_present_flag = 0;
329 
330  sps->vui_parameters_present_flag = 1;
331 
332  if (avctx->sample_aspect_ratio.num != 0 &&
333  avctx->sample_aspect_ratio.den != 0) {
334  static const AVRational sar_idc[] = {
335  { 0, 0 },
336  { 1, 1 }, { 12, 11 }, { 10, 11 }, { 16, 11 },
337  { 40, 33 }, { 24, 11 }, { 20, 11 }, { 32, 11 },
338  { 80, 33 }, { 18, 11 }, { 15, 11 }, { 64, 33 },
339  { 160, 99 }, { 4, 3 }, { 3, 2 }, { 2, 1 },
340  };
341  int i;
342  for (i = 0; i < FF_ARRAY_ELEMS(sar_idc); i++) {
343  if (avctx->sample_aspect_ratio.num == sar_idc[i].num &&
344  avctx->sample_aspect_ratio.den == sar_idc[i].den) {
345  vui->aspect_ratio_idc = i;
346  break;
347  }
348  }
349  if (i >= FF_ARRAY_ELEMS(sar_idc)) {
350  vui->aspect_ratio_idc = 255;
351  vui->sar_width = avctx->sample_aspect_ratio.num;
352  vui->sar_height = avctx->sample_aspect_ratio.den;
353  }
354  vui->aspect_ratio_info_present_flag = 1;
355  }
356 
357  if (avctx->color_range != AVCOL_RANGE_UNSPECIFIED ||
358  avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
359  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
360  avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
361  vui->video_signal_type_present_flag = 1;
362  vui->video_format = 5; // Unspecified.
363  vui->video_full_range_flag =
364  avctx->color_range == AVCOL_RANGE_JPEG;
365 
366  if (avctx->color_primaries != AVCOL_PRI_UNSPECIFIED ||
367  avctx->color_trc != AVCOL_TRC_UNSPECIFIED ||
368  avctx->colorspace != AVCOL_SPC_UNSPECIFIED) {
369  vui->colour_description_present_flag = 1;
370  vui->colour_primaries = avctx->color_primaries;
371  vui->transfer_characteristics = avctx->color_trc;
372  vui->matrix_coefficients = avctx->colorspace;
373  }
374  } else {
375  vui->video_format = 5;
376  vui->video_full_range_flag = 0;
377  vui->colour_primaries = avctx->color_primaries;
378  vui->transfer_characteristics = avctx->color_trc;
379  vui->matrix_coefficients = avctx->colorspace;
380  }
381 
382  if (avctx->chroma_sample_location != AVCHROMA_LOC_UNSPECIFIED) {
383  vui->chroma_loc_info_present_flag = 1;
384  vui->chroma_sample_loc_type_top_field =
385  vui->chroma_sample_loc_type_bottom_field =
386  avctx->chroma_sample_location - 1;
387  }
388 
389  vui->vui_timing_info_present_flag = 1;
390  vui->vui_num_units_in_tick = vps->vps_num_units_in_tick;
391  vui->vui_time_scale = vps->vps_time_scale;
392  vui->vui_poc_proportional_to_timing_flag = vps->vps_poc_proportional_to_timing_flag;
393  vui->vui_num_ticks_poc_diff_one_minus1 = vps->vps_num_ticks_poc_diff_one_minus1;
394  vui->vui_hrd_parameters_present_flag = 0;
395 
396  vui->bitstream_restriction_flag = 1;
397  vui->motion_vectors_over_pic_boundaries_flag = 1;
398  vui->restricted_ref_pic_lists_flag = 1;
399  vui->max_bytes_per_pic_denom = 0;
400  vui->max_bits_per_min_cu_denom = 0;
401  vui->log2_max_mv_length_horizontal = 15;
402  vui->log2_max_mv_length_vertical = 15;
403 
404 
405  // PPS
406 
407  pps->nal_unit_header = (H265RawNALUnitHeader) {
408  .nal_unit_type = HEVC_NAL_PPS,
409  .nuh_layer_id = 0,
410  .nuh_temporal_id_plus1 = 1,
411  };
412 
413  pps->pps_pic_parameter_set_id = 0;
414  pps->pps_seq_parameter_set_id = sps->sps_seq_parameter_set_id;
415 
416  pps->num_ref_idx_l0_default_active_minus1 = 0;
417  pps->num_ref_idx_l1_default_active_minus1 = 0;
418 
419  pps->init_qp_minus26 = priv->fixed_qp_idr - 26;
420 
421  pps->cu_qp_delta_enabled_flag = (ctx->va_rc_mode != VA_RC_CQP);
422  pps->diff_cu_qp_delta_depth = 0;
423 
424  pps->pps_loop_filter_across_slices_enabled_flag = 1;
425 
426 
427  // Fill VAAPI parameter buffers.
428 
429  *vseq = (VAEncSequenceParameterBufferHEVC) {
430  .general_profile_idc = vps->profile_tier_level.general_profile_idc,
431  .general_level_idc = vps->profile_tier_level.general_level_idc,
432  .general_tier_flag = vps->profile_tier_level.general_tier_flag,
433 
434  .intra_period = avctx->gop_size,
435  .intra_idr_period = avctx->gop_size,
436  .ip_period = ctx->b_per_p + 1,
437  .bits_per_second = avctx->bit_rate,
438 
439  .pic_width_in_luma_samples = sps->pic_width_in_luma_samples,
440  .pic_height_in_luma_samples = sps->pic_height_in_luma_samples,
441 
442  .seq_fields.bits = {
443  .chroma_format_idc = sps->chroma_format_idc,
444  .separate_colour_plane_flag = sps->separate_colour_plane_flag,
445  .bit_depth_luma_minus8 = sps->bit_depth_luma_minus8,
446  .bit_depth_chroma_minus8 = sps->bit_depth_chroma_minus8,
447  .scaling_list_enabled_flag = sps->scaling_list_enabled_flag,
448  .strong_intra_smoothing_enabled_flag =
449  sps->strong_intra_smoothing_enabled_flag,
450  .amp_enabled_flag = sps->amp_enabled_flag,
451  .sample_adaptive_offset_enabled_flag =
452  sps->sample_adaptive_offset_enabled_flag,
453  .pcm_enabled_flag = sps->pcm_enabled_flag,
454  .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled_flag,
455  .sps_temporal_mvp_enabled_flag = sps->sps_temporal_mvp_enabled_flag,
456  },
457 
458  .log2_min_luma_coding_block_size_minus3 =
459  sps->log2_min_luma_coding_block_size_minus3,
460  .log2_diff_max_min_luma_coding_block_size =
461  sps->log2_diff_max_min_luma_coding_block_size,
462  .log2_min_transform_block_size_minus2 =
463  sps->log2_min_luma_transform_block_size_minus2,
464  .log2_diff_max_min_transform_block_size =
465  sps->log2_diff_max_min_luma_transform_block_size,
466  .max_transform_hierarchy_depth_inter =
467  sps->max_transform_hierarchy_depth_inter,
468  .max_transform_hierarchy_depth_intra =
469  sps->max_transform_hierarchy_depth_intra,
470 
471  .pcm_sample_bit_depth_luma_minus1 =
472  sps->pcm_sample_bit_depth_luma_minus1,
473  .pcm_sample_bit_depth_chroma_minus1 =
474  sps->pcm_sample_bit_depth_chroma_minus1,
475  .log2_min_pcm_luma_coding_block_size_minus3 =
476  sps->log2_min_pcm_luma_coding_block_size_minus3,
477  .log2_max_pcm_luma_coding_block_size_minus3 =
478  sps->log2_min_pcm_luma_coding_block_size_minus3 +
479  sps->log2_diff_max_min_pcm_luma_coding_block_size,
480 
481  .vui_parameters_present_flag = 0,
482  };
483 
484  *vpic = (VAEncPictureParameterBufferHEVC) {
485  .decoded_curr_pic = {
486  .picture_id = VA_INVALID_ID,
487  .flags = VA_PICTURE_HEVC_INVALID,
488  },
489 
490  .coded_buf = VA_INVALID_ID,
491 
492  .collocated_ref_pic_index = 0xff,
493 
494  .last_picture = 0,
495 
496  .pic_init_qp = pps->init_qp_minus26 + 26,
497  .diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth,
498  .pps_cb_qp_offset = pps->pps_cb_qp_offset,
499  .pps_cr_qp_offset = pps->pps_cr_qp_offset,
500 
501  .num_tile_columns_minus1 = pps->num_tile_columns_minus1,
502  .num_tile_rows_minus1 = pps->num_tile_rows_minus1,
503 
504  .log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level_minus2,
505  .ctu_max_bitsize_allowed = 0,
506 
507  .num_ref_idx_l0_default_active_minus1 =
508  pps->num_ref_idx_l0_default_active_minus1,
509  .num_ref_idx_l1_default_active_minus1 =
510  pps->num_ref_idx_l1_default_active_minus1,
511 
512  .slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id,
513 
514  .pic_fields.bits = {
515  .sign_data_hiding_enabled_flag = pps->sign_data_hiding_enabled_flag,
516  .constrained_intra_pred_flag = pps->constrained_intra_pred_flag,
517  .transform_skip_enabled_flag = pps->transform_skip_enabled_flag,
518  .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag,
519  .weighted_pred_flag = pps->weighted_pred_flag,
520  .weighted_bipred_flag = pps->weighted_bipred_flag,
521  .transquant_bypass_enabled_flag = pps->transquant_bypass_enabled_flag,
522  .tiles_enabled_flag = pps->tiles_enabled_flag,
523  .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag,
524  .loop_filter_across_tiles_enabled_flag =
525  pps->loop_filter_across_tiles_enabled_flag,
526  .scaling_list_data_present_flag = (sps->sps_scaling_list_data_present_flag |
527  pps->pps_scaling_list_data_present_flag),
528  .screen_content_flag = 0,
529  .enable_gpu_weighted_prediction = 0,
530  .no_output_of_prior_pics_flag = 0,
531  },
532  };
533 
534  return 0;
535 }
536 
537  static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx,
538  VAAPIEncodePicture *pic)
539 {
540  VAAPIEncodeContext *ctx = avctx->priv_data;
541  VAAPIEncodeH265Context *priv = ctx->priv_data;
542  VAAPIEncodeH265Options *opt = ctx->codec_options;
543  VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params;
544  int i;
545 
546  if (pic->type == PICTURE_TYPE_IDR) {
547  av_assert0(pic->display_order == pic->encode_order);
548 
549  priv->last_idr_frame = pic->display_order;
550 
551  priv->slice_nal_unit = HEVC_NAL_IDR_W_RADL;
552  priv->slice_type = HEVC_SLICE_I;
553  priv->pic_type = 0;
554  } else {
555  av_assert0(pic->encode_order > priv->last_idr_frame);
556 
557  if (pic->type == PICTURE_TYPE_I) {
558  priv->slice_nal_unit = HEVC_NAL_CRA_NUT;
559  priv->slice_type = HEVC_SLICE_I;
560  priv->pic_type = 0;
561  } else if (pic->type == PICTURE_TYPE_P) {
562  av_assert0(pic->refs[0]);
563  priv->slice_nal_unit = HEVC_NAL_TRAIL_R;
564  priv->slice_type = HEVC_SLICE_P;
565  priv->pic_type = 1;
566  } else {
567  av_assert0(pic->refs[0] && pic->refs[1]);
568  if (pic->refs[1]->type == PICTURE_TYPE_I)
569  priv->slice_nal_unit = HEVC_NAL_RASL_N;
570  else
571  priv->slice_nal_unit = HEVC_NAL_TRAIL_N;
572  priv->slice_type = HEVC_SLICE_B;
573  priv->pic_type = 2;
574  }
575  }
576  priv->pic_order_cnt = pic->display_order - priv->last_idr_frame;
577 
578  if (opt->aud) {
579  priv->aud_needed = 1;
580  priv->aud.nal_unit_header = (H265RawNALUnitHeader) {
581  .nal_unit_type = HEVC_NAL_AUD,
582  .nuh_layer_id = 0,
583  .nuh_temporal_id_plus1 = 1,
584  };
585  priv->aud.pic_type = priv->pic_type;
586  } else {
587  priv->aud_needed = 0;
588  }
589 
590  vpic->decoded_curr_pic = (VAPictureHEVC) {
591  .picture_id = pic->recon_surface,
592  .pic_order_cnt = priv->pic_order_cnt,
593  .flags = 0,
594  };
595 
596  for (i = 0; i < pic->nb_refs; i++) {
597  VAAPIEncodePicture *ref = pic->refs[i];
598  av_assert0(ref && ref->encode_order < pic->encode_order);
599 
600  vpic->reference_frames[i] = (VAPictureHEVC) {
601  .picture_id = ref->recon_surface,
602  .pic_order_cnt = ref->display_order - priv->last_idr_frame,
603  .flags = (ref->display_order < pic->display_order ?
604  VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE : 0) |
605  (ref->display_order > pic->display_order ?
606  VA_PICTURE_HEVC_RPS_ST_CURR_AFTER : 0),
607  };
608  }
609  for (; i < FF_ARRAY_ELEMS(vpic->reference_frames); i++) {
610  vpic->reference_frames[i] = (VAPictureHEVC) {
611  .picture_id = VA_INVALID_ID,
612  .flags = VA_PICTURE_HEVC_INVALID,
613  };
614  }
615 
616  vpic->coded_buf = pic->output_buffer;
617 
618  vpic->nal_unit_type = priv->slice_nal_unit;
619 
620  switch (pic->type) {
621  case PICTURE_TYPE_IDR:
622  vpic->pic_fields.bits.idr_pic_flag = 1;
623  vpic->pic_fields.bits.coding_type = 1;
624  vpic->pic_fields.bits.reference_pic_flag = 1;
625  break;
626  case PICTURE_TYPE_I:
627  vpic->pic_fields.bits.idr_pic_flag = 0;
628  vpic->pic_fields.bits.coding_type = 1;
629  vpic->pic_fields.bits.reference_pic_flag = 1;
630  break;
631  case PICTURE_TYPE_P:
632  vpic->pic_fields.bits.idr_pic_flag = 0;
633  vpic->pic_fields.bits.coding_type = 2;
634  vpic->pic_fields.bits.reference_pic_flag = 1;
635  break;
636  case PICTURE_TYPE_B:
637  vpic->pic_fields.bits.idr_pic_flag = 0;
638  vpic->pic_fields.bits.coding_type = 3;
639  vpic->pic_fields.bits.reference_pic_flag = 0;
640  break;
641  default:
642  av_assert0(0 && "invalid picture type");
643  }
644 
645  pic->nb_slices = 1;
646 
647  return 0;
648 }
649 
650  static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx,
651  VAAPIEncodePicture *pic,
652  VAAPIEncodeSlice *slice)
653 {
654  VAAPIEncodeContext *ctx = avctx->priv_data;
655  VAAPIEncodeH265Context *priv = ctx->priv_data;
656  const H265RawSPS *sps = &priv->sps;
657  const H265RawPPS *pps = &priv->pps;
658  H265RawSliceHeader *sh = &priv->slice.header;
659  VAEncPictureParameterBufferHEVC *vpic = pic->codec_picture_params;
660  VAEncSliceParameterBufferHEVC *vslice = slice->codec_slice_params;
661  int i;
662 
663  sh->nal_unit_header = (H265RawNALUnitHeader) {
664  .nal_unit_type = priv->slice_nal_unit,
665  .nuh_layer_id = 0,
666  .nuh_temporal_id_plus1 = 1,
667  };
668 
669  sh->slice_pic_parameter_set_id = pps->pps_pic_parameter_set_id;
670 
671  // Currently we only support one slice per frame.
672  sh->first_slice_segment_in_pic_flag = 1;
673  sh->slice_segment_address = 0;
674 
675  sh->slice_type = priv->slice_type;
676 
677  sh->slice_pic_order_cnt_lsb = priv->pic_order_cnt &
678  (1 << (sps->log2_max_pic_order_cnt_lsb_minus4 + 4)) - 1;
679 
680  if (pic->type != PICTURE_TYPE_IDR) {
681  H265RawSTRefPicSet *rps;
682  VAAPIEncodePicture *st;
683  int used;
684 
685  sh->short_term_ref_pic_set_sps_flag = 0;
686 
687  rps = &sh->short_term_ref_pic_set;
688  memset(rps, 0, sizeof(*rps));
689 
690  for (st = ctx->pic_start; st; st = st->next) {
691  if (st->encode_order >= pic->encode_order) {
692  // Not yet in DPB.
693  continue;
694  }
695  used = 0;
696  for (i = 0; i < pic->nb_refs; i++) {
697  if (pic->refs[i] == st)
698  used = 1;
699  }
700  if (!used) {
701  // Usually each picture always uses all of the others in the
702  // DPB as references. The one case we have to treat here is
703  // a non-IDR IRAP picture, which may need to hold unused
704  // references across itself to be used for the decoding of
705  // following RASL pictures. This looks for such an RASL
706  // picture, and keeps the reference if there is one.
707  VAAPIEncodePicture *rp;
708  for (rp = ctx->pic_start; rp; rp = rp->next) {
709  if (rp->encode_order < pic->encode_order)
710  continue;
711  if (rp->type != PICTURE_TYPE_B)
712  continue;
713  if (rp->refs[0] == st && rp->refs[1] == pic)
714  break;
715  }
716  if (!rp)
717  continue;
718  }
719  // This only works for one instance of each (delta_poc_sN_minus1
720  // is relative to the previous frame in the list, not relative to
721  // the current frame directly).
722  if (st->display_order < pic->display_order) {
723  rps->delta_poc_s0_minus1[rps->num_negative_pics] =
724  pic->display_order - st->display_order - 1;
725  rps->used_by_curr_pic_s0_flag[rps->num_negative_pics] = used;
726  ++rps->num_negative_pics;
727  } else {
728  rps->delta_poc_s1_minus1[rps->num_positive_pics] =
729  st->display_order - pic->display_order - 1;
730  rps->used_by_curr_pic_s1_flag[rps->num_positive_pics] = used;
731  ++rps->num_positive_pics;
732  }
733  }
734 
735  sh->num_long_term_sps = 0;
736  sh->num_long_term_pics = 0;
737 
738  sh->slice_temporal_mvp_enabled_flag =
739  sps->sps_temporal_mvp_enabled_flag;
740  if (sh->slice_temporal_mvp_enabled_flag) {
741  sh->collocated_from_l0_flag = sh->slice_type == HEVC_SLICE_B;
742  sh->collocated_ref_idx = 0;
743  }
744 
745  sh->num_ref_idx_active_override_flag = 0;
746  sh->num_ref_idx_l0_active_minus1 = pps->num_ref_idx_l0_default_active_minus1;
747  sh->num_ref_idx_l1_active_minus1 = pps->num_ref_idx_l1_default_active_minus1;
748  }
749 
750  sh->slice_sao_luma_flag = sh->slice_sao_chroma_flag =
751  sps->sample_adaptive_offset_enabled_flag;
752 
753  if (pic->type == PICTURE_TYPE_B)
754  sh->slice_qp_delta = priv->fixed_qp_b - (pps->init_qp_minus26 + 26);
755  else if (pic->type == PICTURE_TYPE_P)
756  sh->slice_qp_delta = priv->fixed_qp_p - (pps->init_qp_minus26 + 26);
757  else
758  sh->slice_qp_delta = priv->fixed_qp_idr - (pps->init_qp_minus26 + 26);
759 
760 
761  *vslice = (VAEncSliceParameterBufferHEVC) {
762  .slice_segment_address = sh->slice_segment_address,
763  .num_ctu_in_slice = priv->ctu_width * priv->ctu_height,
764 
765  .slice_type = sh->slice_type,
766  .slice_pic_parameter_set_id = sh->slice_pic_parameter_set_id,
767 
768  .num_ref_idx_l0_active_minus1 = sh->num_ref_idx_l0_active_minus1,
769  .num_ref_idx_l1_active_minus1 = sh->num_ref_idx_l1_active_minus1,
770 
771  .luma_log2_weight_denom = sh->luma_log2_weight_denom,
772  .delta_chroma_log2_weight_denom = sh->delta_chroma_log2_weight_denom,
773 
774  .max_num_merge_cand = 5 - sh->five_minus_max_num_merge_cand,
775 
776  .slice_qp_delta = sh->slice_qp_delta,
777  .slice_cb_qp_offset = sh->slice_cb_qp_offset,
778  .slice_cr_qp_offset = sh->slice_cr_qp_offset,
779 
780  .slice_beta_offset_div2 = sh->slice_beta_offset_div2,
781  .slice_tc_offset_div2 = sh->slice_tc_offset_div2,
782 
783  .slice_fields.bits = {
784  .last_slice_of_pic_flag = 1,
785  .dependent_slice_segment_flag = sh->dependent_slice_segment_flag,
786  .colour_plane_id = sh->colour_plane_id,
787  .slice_temporal_mvp_enabled_flag =
788  sh->slice_temporal_mvp_enabled_flag,
789  .slice_sao_luma_flag = sh->slice_sao_luma_flag,
790  .slice_sao_chroma_flag = sh->slice_sao_chroma_flag,
791  .num_ref_idx_active_override_flag =
792  sh->num_ref_idx_active_override_flag,
793  .mvd_l1_zero_flag = sh->mvd_l1_zero_flag,
794  .cabac_init_flag = sh->cabac_init_flag,
795  .slice_deblocking_filter_disabled_flag =
796  sh->slice_deblocking_filter_disabled_flag,
797  .slice_loop_filter_across_slices_enabled_flag =
798  sh->slice_loop_filter_across_slices_enabled_flag,
799  .collocated_from_l0_flag = sh->collocated_from_l0_flag,
800  },
801  };
802 
803  for (i = 0; i < FF_ARRAY_ELEMS(vslice->ref_pic_list0); i++) {
804  vslice->ref_pic_list0[i].picture_id = VA_INVALID_ID;
805  vslice->ref_pic_list0[i].flags = VA_PICTURE_HEVC_INVALID;
806  vslice->ref_pic_list1[i].picture_id = VA_INVALID_ID;
807  vslice->ref_pic_list1[i].flags = VA_PICTURE_HEVC_INVALID;
808  }
809 
810  av_assert0(pic->nb_refs <= 2);
811  if (pic->nb_refs >= 1) {
812  // Backward reference for P- or B-frame.
813  av_assert0(pic->type == PICTURE_TYPE_P ||
814  pic->type == PICTURE_TYPE_B);
815  vslice->ref_pic_list0[0] = vpic->reference_frames[0];
816  }
817  if (pic->nb_refs >= 2) {
818  // Forward reference for B-frame.
819  av_assert0(pic->type == PICTURE_TYPE_B);
820  vslice->ref_pic_list1[0] = vpic->reference_frames[1];
821  }
822 
823  return 0;
824 }
825 
826  static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
827 {
828  VAAPIEncodeContext *ctx = avctx->priv_data;
829  VAAPIEncodeH265Context *priv = ctx->priv_data;
830  VAAPIEncodeH265Options *opt = ctx->codec_options;
831  int err;
832 
833  err = ff_cbs_init(&priv->cbc, AV_CODEC_ID_HEVC, avctx);
834  if (err < 0)
835  return err;
836 
837  priv->ctu_width = FFALIGN(ctx->surface_width, 32) / 32;
838  priv->ctu_height = FFALIGN(ctx->surface_height, 32) / 32;
839 
840  av_log(avctx, AV_LOG_VERBOSE, "Input %ux%u -> Surface %ux%u -> CTU %ux%u.\n",
841  avctx->width, avctx->height, ctx->surface_width,
842  ctx->surface_height, priv->ctu_width, priv->ctu_height);
843 
844  if (ctx->va_rc_mode == VA_RC_CQP) {
845  priv->fixed_qp_p = opt->qp;
846  if (avctx->i_quant_factor > 0.0)
847  priv->fixed_qp_idr = (int)((priv->fixed_qp_p * avctx->i_quant_factor +
848  avctx->i_quant_offset) + 0.5);
849  else
850  priv->fixed_qp_idr = priv->fixed_qp_p;
851  if (avctx->b_quant_factor > 0.0)
852  priv->fixed_qp_b = (int)((priv->fixed_qp_p * avctx->b_quant_factor +
853  avctx->b_quant_offset) + 0.5);
854  else
855  priv->fixed_qp_b = priv->fixed_qp_p;
856 
857  av_log(avctx, AV_LOG_DEBUG, "Using fixed QP = "
858  "%d / %d / %d for IDR- / P- / B-frames.\n",
859  priv->fixed_qp_idr, priv->fixed_qp_p, priv->fixed_qp_b);
860 
861  } else if (ctx->va_rc_mode == VA_RC_CBR ||
862  ctx->va_rc_mode == VA_RC_VBR) {
863  // These still need to be set for pic_init_qp/slice_qp_delta.
864  priv->fixed_qp_idr = 30;
865  priv->fixed_qp_p = 30;
866  priv->fixed_qp_b = 30;
867 
868  av_log(avctx, AV_LOG_DEBUG, "Using %s-bitrate = %"PRId64" bps.\n",
869  ctx->va_rc_mode == VA_RC_CBR ? "constant" : "variable",
870  avctx->bit_rate);
871 
872  } else {
873  av_assert0(0 && "Invalid RC mode.");
874  }
875 
876  return 0;
877 }
878 
879  static const VAAPIEncodeType vaapi_encode_type_h265 = {
880  .priv_data_size = sizeof(VAAPIEncodeH265Context),
881 
882  .configure = &vaapi_encode_h265_configure,
883 
884  .sequence_params_size = sizeof(VAEncSequenceParameterBufferHEVC),
885  .init_sequence_params = &vaapi_encode_h265_init_sequence_params,
886 
887  .picture_params_size = sizeof(VAEncPictureParameterBufferHEVC),
888  .init_picture_params = &vaapi_encode_h265_init_picture_params,
889 
890  .slice_params_size = sizeof(VAEncSliceParameterBufferHEVC),
891  .init_slice_params = &vaapi_encode_h265_init_slice_params,
892 
893  .sequence_header_type = VAEncPackedHeaderSequence,
894  .write_sequence_header = &vaapi_encode_h265_write_sequence_header,
895 
896  .slice_header_type = VAEncPackedHeaderHEVC_Slice,
897  .write_slice_header = &vaapi_encode_h265_write_slice_header,
898 };
899 
900  static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
901 {
902  VAAPIEncodeContext *ctx = avctx->priv_data;
903  VAAPIEncodeH265Options *opt =
904  (VAAPIEncodeH265Options*)ctx->codec_options_data;
905 
906  ctx->codec = &vaapi_encode_type_h265;
907 
908  if (avctx->profile == FF_PROFILE_UNKNOWN)
909  avctx->profile = opt->profile;
910  if (avctx->level == FF_LEVEL_UNKNOWN)
911  avctx->level = opt->level;
912 
913  switch (avctx->profile) {
914  case FF_PROFILE_HEVC_MAIN:
915  case FF_PROFILE_UNKNOWN:
916  ctx->va_profile = VAProfileHEVCMain;
917  ctx->va_rt_format = VA_RT_FORMAT_YUV420;
918  break;
919  case FF_PROFILE_HEVC_MAIN_10:
920 #ifdef VA_RT_FORMAT_YUV420_10BPP
921  ctx->va_profile = VAProfileHEVCMain10;
922  ctx->va_rt_format = VA_RT_FORMAT_YUV420_10BPP;
923  break;
924 #else
925  av_log(avctx, AV_LOG_ERROR, "10-bit encoding is not "
926  "supported with this VAAPI version.\n");
927  return AVERROR(ENOSYS);
928 #endif
929  default:
930  av_log(avctx, AV_LOG_ERROR, "Unknown H.265 profile %d.\n",
931  avctx->profile);
932  return AVERROR(EINVAL);
933  }
934  ctx->va_entrypoint = VAEntrypointEncSlice;
935 
936  if (avctx->bit_rate > 0) {
937  if (avctx->rc_max_rate == avctx->bit_rate)
938  ctx->va_rc_mode = VA_RC_CBR;
939  else
940  ctx->va_rc_mode = VA_RC_VBR;
941  } else
942  ctx->va_rc_mode = VA_RC_CQP;
943 
944  ctx->va_packed_headers =
945  VA_ENC_PACKED_HEADER_SEQUENCE | // VPS, SPS and PPS.
946  VA_ENC_PACKED_HEADER_SLICE; // Slice headers.
947 
948  ctx->surface_width = FFALIGN(avctx->width, 16);
949  ctx->surface_height = FFALIGN(avctx->height, 16);
950 
951  return ff_vaapi_encode_init(avctx);
952 }
953 
954  static av_cold int vaapi_encode_h265_close(AVCodecContext *avctx)
955 {
956  VAAPIEncodeContext *ctx = avctx->priv_data;
957  VAAPIEncodeH265Context *priv = ctx->priv_data;
958 
959  if (priv)
960  ff_cbs_close(&priv->cbc);
961 
962  return ff_vaapi_encode_close(avctx);
963 }
964 
965  #define OFFSET(x) (offsetof(VAAPIEncodeContext, codec_options_data) + \
966  offsetof(VAAPIEncodeH265Options, x))
967  #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
968  static const AVOption vaapi_encode_h265_options[] = {
969  { "qp", "Constant QP (for P-frames; scaled by qfactor/qoffset for I/B)",
970  OFFSET(qp), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, 52, FLAGS },
971 
972  { "aud", "Include AUD",
973  OFFSET(aud), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, FLAGS },
974 
975  { "profile", "Set profile (general_profile_idc)",
976  OFFSET(profile), AV_OPT_TYPE_INT,
977  { .i64 = FF_PROFILE_HEVC_MAIN }, 0x00, 0xff, FLAGS, "profile" },
978 
979 #define PROFILE(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
980  { .i64 = value }, 0, 0, FLAGS, "profile"
981  { PROFILE("main", FF_PROFILE_HEVC_MAIN) },
982  { PROFILE("main10", FF_PROFILE_HEVC_MAIN_10) },
983 #undef PROFILE
984 
985  { "level", "Set level (general_level_idc)",
986  OFFSET(level), AV_OPT_TYPE_INT,
987  { .i64 = 153 }, 0x00, 0xff, FLAGS, "level" },
988 
989 #define LEVEL(name, value) name, NULL, 0, AV_OPT_TYPE_CONST, \
990  { .i64 = value }, 0, 0, FLAGS, "level"
991  { LEVEL("1", 30) },
992  { LEVEL("2", 60) },
993  { LEVEL("2.1", 63) },
994  { LEVEL("3", 90) },
995  { LEVEL("3.1", 93) },
996  { LEVEL("4", 120) },
997  { LEVEL("4.1", 123) },
998  { LEVEL("5", 150) },
999  { LEVEL("5.1", 153) },
1000  { LEVEL("5.2", 156) },
1001  { LEVEL("6", 180) },
1002  { LEVEL("6.1", 183) },
1003  { LEVEL("6.2", 186) },
1004 #undef LEVEL
1005 
1006  { NULL },
1007 };
1008 
1009  static const AVCodecDefault vaapi_encode_h265_defaults[] = {
1010  { "b", "0" },
1011  { "bf", "2" },
1012  { "g", "120" },
1013  { "i_qfactor", "1" },
1014  { "i_qoffset", "0" },
1015  { "b_qfactor", "6/5" },
1016  { "b_qoffset", "0" },
1017  { NULL },
1018 };
1019 
1020  static const AVClass vaapi_encode_h265_class = {
1021  .class_name = "h265_vaapi",
1022  .item_name = av_default_item_name,
1023  .option = vaapi_encode_h265_options,
1024  .version = LIBAVUTIL_VERSION_INT,
1025 };
1026 
1027  AVCodec ff_hevc_vaapi_encoder = {
1028  .name = "hevc_vaapi",
1029  .long_name = NULL_IF_CONFIG_SMALL("H.265/HEVC (VAAPI)"),
1030  .type = AVMEDIA_TYPE_VIDEO,
1031  .id = AV_CODEC_ID_HEVC,
1032  .priv_data_size = (sizeof(VAAPIEncodeContext) +
1033  sizeof(VAAPIEncodeH265Options)),
1034  .init = &vaapi_encode_h265_init,
1035  .encode2 = &ff_vaapi_encode2,
1036  .close = &vaapi_encode_h265_close,
1037  .priv_class = &vaapi_encode_h265_class,
1038  .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE,
1039  .defaults = vaapi_encode_h265_defaults,
1040  .pix_fmts = (const enum AVPixelFormat[]) {
1041  AV_PIX_FMT_VAAPI,
1042  AV_PIX_FMT_NONE,
1043  },
1044  .wrapper_name = "vaapi",
1045 };
H265RawSPS::sps_video_parameter_set_id
uint8_t sps_video_parameter_set_id
Definition: cbs_h265.h:224
H265RawPPS::loop_filter_across_tiles_enabled_flag
uint8_t loop_filter_across_tiles_enabled_flag
Definition: cbs_h265.h:361
NULL
#define NULL
Definition: coverity.c:32
AVCodecContext::framerate
AVRational framerate
Definition: avcodec.h:3040
H265RawVUI::transfer_characteristics
uint8_t transfer_characteristics
Definition: cbs_h265.h:118
H265RawPPS::pps_pic_parameter_set_id
uint8_t pps_pic_parameter_set_id
Definition: cbs_h265.h:326
VAAPIEncodeContext::va_profile
VAProfile va_profile
Definition: vaapi_encode.h:96
H265RawVPS::vps_poc_proportional_to_timing_flag
uint8_t vps_poc_proportional_to_timing_flag
Definition: cbs_h265.h:185
H265RawSliceHeader::num_long_term_pics
uint8_t num_long_term_pics
Definition: cbs_h265.h:443
H265RawPPS::num_ref_idx_l0_default_active_minus1
uint8_t num_ref_idx_l0_default_active_minus1
Definition: cbs_h265.h:335
VAAPIEncodeContext::va_entrypoint
VAEntrypoint va_entrypoint
Definition: vaapi_encode.h:98
H265RawVUI::log2_max_mv_length_horizontal
uint8_t log2_max_mv_length_horizontal
Definition: cbs_h265.h:150
AVOption
AVOption.
Definition: opt.h:246
data
ptrdiff_t const GLvoid * data
Definition: opengl_enc.c:101
H265RawVUI::motion_vectors_over_pic_boundaries_flag
uint8_t motion_vectors_over_pic_boundaries_flag
Definition: cbs_h265.h:145
H265RawSPS::sps_sub_layer_ordering_info_present_flag
uint8_t sps_sub_layer_ordering_info_present_flag
Definition: cbs_h265.h:250
H265RawSliceHeader::slice_temporal_mvp_enabled_flag
uint8_t slice_temporal_mvp_enabled_flag
Definition: cbs_h265.h:450
VAAPIEncodeContext::codec_options_data
char codec_options_data[0]
Definition: vaapi_encode.h:213
vaapi_encode_h265_add_nal
static int vaapi_encode_h265_add_nal(AVCodecContext *avctx, CodedBitstreamFragment *au, void *nal_unit)
Definition: vaapi_encode_h265.c:98
AVCodecContext::bit_rate
int64_t bit_rate
the average bitrate
Definition: avcodec.h:1568
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
H265RawVUI::bitstream_restriction_flag
uint8_t bitstream_restriction_flag
Definition: cbs_h265.h:143
H265RawSPS::bit_depth_luma_minus8
uint8_t bit_depth_luma_minus8
Definition: cbs_h265.h:245
init
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
AV_CODEC_CAP_HARDWARE
#define AV_CODEC_CAP_HARDWARE
Codec is backed by a hardware implementation.
Definition: avcodec.h:1056
H265RawVUI::vui_timing_info_present_flag
uint8_t vui_timing_info_present_flag
Definition: cbs_h265.h:135
ff_cbs_init
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:56
AVCodecContext::color_range
enum AVColorRange color_range
MPEG vs JPEG YUV range.
Definition: avcodec.h:2148
H265RawSPS::sps_max_sub_layers_minus1
uint8_t sps_max_sub_layers_minus1
Definition: cbs_h265.h:226
H265RawSliceHeader::slice_pic_order_cnt_lsb
uint16_t slice_pic_order_cnt_lsb
Definition: cbs_h265.h:436
AVRational::num
int num
Numerator.
Definition: rational.h:59
H265RawSPS::sps_max_num_reorder_pics
uint8_t sps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:252
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
vaapi_encode_h265_class
static const AVClass vaapi_encode_h265_class
Definition: vaapi_encode_h265.c:1020
VAAPIEncodeType::priv_data_size
size_t priv_data_size
Definition: vaapi_encode.h:218
H265RawPPS::tiles_enabled_flag
uint8_t tiles_enabled_flag
Definition: cbs_h265.h:353
ff_cbs_insert_unit_content
int ff_cbs_insert_unit_content(CodedBitstreamContext *ctx, 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:518
AVCodecContext::sample_aspect_ratio
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:1896
H265RawSliceHeader::slice_qp_delta
int8_t slice_qp_delta
Definition: cbs_h265.h:487
H265RawVUI::restricted_ref_pic_lists_flag
uint8_t restricted_ref_pic_lists_flag
Definition: cbs_h265.h:146
H265RawSPS::profile_tier_level
H265RawProfileTierLevel profile_tier_level
Definition: cbs_h265.h:229
H265RawSliceHeader::slice_beta_offset_div2
int8_t slice_beta_offset_div2
Definition: cbs_h265.h:497
vaapi_encode_h265_close
static av_cold int vaapi_encode_h265_close(AVCodecContext *avctx)
Definition: vaapi_encode_h265.c:954
H265RawSliceHeader::collocated_from_l0_flag
uint8_t collocated_from_l0_flag
Definition: cbs_h265.h:466
VAAPIEncodeH265Context::cbc
CodedBitstreamContext * cbc
Definition: vaapi_encode_h265.c:58
VAAPIEncodeContext::codec_sequence_params
void * codec_sequence_params
Definition: vaapi_encode.h:168
H265RawSPS::sample_adaptive_offset_enabled_flag
uint8_t sample_adaptive_offset_enabled_flag
Definition: cbs_h265.h:267
H265RawSPS::vui_parameters_present_flag
uint8_t vui_parameters_present_flag
Definition: cbs_h265.h:287
H265RawSPS::pcm_sample_bit_depth_luma_minus1
uint8_t pcm_sample_bit_depth_luma_minus1
Definition: cbs_h265.h:270
vaapi_encode_h265_defaults
static const AVCodecDefault vaapi_encode_h265_defaults[]
Definition: vaapi_encode_h265.c:1009
H265RawSPS::bit_depth_chroma_minus8
uint8_t bit_depth_chroma_minus8
Definition: cbs_h265.h:246
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:2843
AVCodec
AVCodec.
Definition: avcodec.h:3408
H265RawSliceHeader::delta_chroma_log2_weight_denom
int8_t delta_chroma_log2_weight_denom
Definition: cbs_h265.h:470
AVCodecContext::i_quant_offset
float i_quant_offset
qscale offset between P and I-frames
Definition: avcodec.h:1829
H265RawProfileTierLevel::general_profile_idc
uint8_t general_profile_idc
Definition: cbs_h265.h:39
H265RawSTRefPicSet::used_by_curr_pic_s0_flag
uint8_t used_by_curr_pic_s0_flag[HEVC_MAX_REFS]
Definition: cbs_h265.h:209
AVCodecContext::time_base
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
Definition: avcodec.h:1640
H265RawSliceHeader::slice_segment_address
uint16_t slice_segment_address
Definition: cbs_h265.h:428
VAAPIEncodeContext::va_packed_headers
unsigned int va_packed_headers
Definition: vaapi_encode.h:105
H265RawVPS::vps_num_units_in_tick
uint32_t vps_num_units_in_tick
Definition: cbs_h265.h:183
H265RawPPS::sign_data_hiding_enabled_flag
uint8_t sign_data_hiding_enabled_flag
Definition: cbs_h265.h:332
FF_LEVEL_UNKNOWN
#define FF_LEVEL_UNKNOWN
Definition: avcodec.h:2954
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:72
H265RawSPS::conf_win_right_offset
uint16_t conf_win_right_offset
Definition: cbs_h265.h:241
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: avcodec.h:984
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
H265RawSliceHeader::slice_deblocking_filter_disabled_flag
uint8_t slice_deblocking_filter_disabled_flag
Definition: cbs_h265.h:496
H265RawSPS::pic_height_in_luma_samples
uint16_t pic_height_in_luma_samples
Definition: cbs_h265.h:237
HEVC_SLICE_I
Definition: hevc.h:74
av_cold
#define av_cold
Definition: attributes.h:82
HEVC_NAL_AUD
Definition: hevc.h:63
H265RawSliceHeader::slice_tc_offset_div2
int8_t slice_tc_offset_div2
Definition: cbs_h265.h:498
opt.h
AVOptions.
H265RawSliceHeader::slice_cb_qp_offset
int8_t slice_cb_qp_offset
Definition: cbs_h265.h:488
H265RawVUI::colour_primaries
uint8_t colour_primaries
Definition: cbs_h265.h:117
H265RawVPS::vps_sub_layer_ordering_info_present_flag
uint8_t vps_sub_layer_ordering_info_present_flag
Definition: cbs_h265.h:173
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:1786
H265RawSliceHeader::five_minus_max_num_merge_cand
uint8_t five_minus_max_num_merge_cand
Definition: cbs_h265.h:484
FF_PROFILE_HEVC_MAIN
#define FF_PROFILE_HEVC_MAIN
Definition: avcodec.h:2931
H265RawVUI::video_format
uint8_t video_format
Definition: cbs_h265.h:114
H265RawSliceHeader::short_term_ref_pic_set
H265RawSTRefPicSet short_term_ref_pic_set
Definition: cbs_h265.h:439
H265RawVPS::vps_timing_info_present_flag
uint8_t vps_timing_info_present_flag
Definition: cbs_h265.h:182
H265RawSPS::log2_max_pic_order_cnt_lsb_minus4
uint8_t log2_max_pic_order_cnt_lsb_minus4
Definition: cbs_h265.h:248
H265RawPPS::constrained_intra_pred_flag
uint8_t constrained_intra_pred_flag
Definition: cbs_h265.h:340
H265RawSPS::sps_max_latency_increase_plus1
uint32_t sps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:253
H265RawVUI::matrix_coefficients
uint8_t matrix_coefficients
Definition: cbs_h265.h:119
H265RawVUI::aspect_ratio_info_present_flag
uint8_t aspect_ratio_info_present_flag
Definition: cbs_h265.h:105
H265RawVPS::vps_max_sub_layers_minus1
uint8_t vps_max_sub_layers_minus1
Definition: cbs_h265.h:168
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
VAAPIEncodePicture::recon_surface
VASurfaceID recon_surface
Definition: vaapi_encode.h:71
H265RawSPS::log2_min_luma_transform_block_size_minus2
uint8_t log2_min_luma_transform_block_size_minus2
Definition: cbs_h265.h:257
header
static const uint8_t header[24]
Definition: sdr2.c:67
H265RawSPS::sps_scaling_list_data_present_flag
uint8_t sps_scaling_list_data_present_flag
Definition: cbs_h265.h:263
H265RawSPS::log2_min_pcm_luma_coding_block_size_minus3
uint8_t log2_min_pcm_luma_coding_block_size_minus3
Definition: cbs_h265.h:272
vaapi_encode_h265_write_access_unit
static int vaapi_encode_h265_write_access_unit(AVCodecContext *avctx, char *data, size_t *data_len, CodedBitstreamFragment *au)
Definition: vaapi_encode_h265.c:71
FF_PROFILE_HEVC_MAIN_10
#define FF_PROFILE_HEVC_MAIN_10
Definition: avcodec.h:2932
H265RawVUI::video_full_range_flag
uint8_t video_full_range_flag
Definition: cbs_h265.h:115
AVCodecContext::chroma_sample_location
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
Definition: avcodec.h:2155
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:48
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
H265RawVUI::chroma_sample_loc_type_bottom_field
uint8_t chroma_sample_loc_type_bottom_field
Definition: cbs_h265.h:123
H265RawVPS::vps_num_layer_sets_minus1
uint16_t vps_num_layer_sets_minus1
Definition: cbs_h265.h:179
H265RawVUI::video_signal_type_present_flag
uint8_t video_signal_type_present_flag
Definition: cbs_h265.h:113
CodedBitstreamFragment::data_size
size_t data_size
The number of bytes in the bitstream.
Definition: cbs.h:127
H265RawSPS::vui
H265RawVUI vui
Definition: cbs_h265.h:288
VAAPIEncodeContext::va_rc_mode
unsigned int va_rc_mode
Definition: vaapi_encode.h:102
H265RawVUI::vui_num_ticks_poc_diff_one_minus1
uint32_t vui_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:139
H265RawVPS::vps_max_dec_pic_buffering_minus1
uint8_t vps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:174
VAAPIEncodeContext::codec_options
void * codec_options
Definition: vaapi_encode.h:212
H265RawVUI::log2_max_mv_length_vertical
uint8_t log2_max_mv_length_vertical
Definition: cbs_h265.h:151
H265RawVPS::vps_video_parameter_set_id
uint8_t vps_video_parameter_set_id
Definition: cbs_h265.h:163
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
ff_cbs_fragment_uninit
void ff_cbs_fragment_uninit(CodedBitstreamContext *ctx, CodedBitstreamFragment *frag)
Free all allocated memory in a fragment.
Definition: cbs.c:121
H265RawSPS::conformance_window_flag
uint8_t conformance_window_flag
Definition: cbs_h265.h:239
H265RawVUI::max_bits_per_min_cu_denom
uint8_t max_bits_per_min_cu_denom
Definition: cbs_h265.h:149
AVERROR
#define AVERROR(e)
Definition: error.h:43
vaapi_encode_h265_init
static av_cold int vaapi_encode_h265_init(AVCodecContext *avctx)
Definition: vaapi_encode_h265.c:900
H265RawSliceHeader::dependent_slice_segment_flag
uint8_t dependent_slice_segment_flag
Definition: cbs_h265.h:427
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
H265RawVUI::chroma_loc_info_present_flag
uint8_t chroma_loc_info_present_flag
Definition: cbs_h265.h:121
PROFILE
#define PROFILE(name, value)
AV_LOG_DEBUG
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
vaapi_encode_h265_init_sequence_params
static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
Definition: vaapi_encode_h265.c:178
H265RawSTRefPicSet::num_negative_pics
uint8_t num_negative_pics
Definition: cbs_h265.h:206
avassert.h
simple assert() macros that are a bit more flexible than ISO C assert().
AVCodec::name
const char * name
Name of the codec implementation.
Definition: avcodec.h:3415
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:1822
vaapi_encode_h265_options
static const AVOption vaapi_encode_h265_options[]
Definition: vaapi_encode_h265.c:968
defaults
static const AVCodecDefault defaults[]
Definition: amfenc_h264.c:361
H265RawProfileTierLevel::general_tier_flag
uint8_t general_tier_flag
Definition: cbs_h265.h:38
H265RawPPS::transform_skip_enabled_flag
uint8_t transform_skip_enabled_flag
Definition: cbs_h265.h:341
H265RawVPS::nal_unit_header
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:161
H265RawSPS::pcm_sample_bit_depth_chroma_minus1
uint8_t pcm_sample_bit_depth_chroma_minus1
Definition: cbs_h265.h:271
H265RawVUI::sar_height
uint16_t sar_height
Definition: cbs_h265.h:108
VAAPIEncodePicture::codec_picture_params
void * codec_picture_params
Definition: vaapi_encode.h:80
CodedBitstreamFragment::data_bit_padding
size_t data_bit_padding
The number of bits which should be ignored in the final byte.
Definition: cbs.h:131
fail
#define fail()
Definition: checkasm.h:116
H265RawVUI::chroma_sample_loc_type_top_field
uint8_t chroma_sample_loc_type_top_field
Definition: cbs_h265.h:122
H265RawVPS::vps_max_layers_minus1
uint8_t vps_max_layers_minus1
Definition: cbs_h265.h:167
H265RawVUI::vui_time_scale
uint32_t vui_time_scale
Definition: cbs_h265.h:137
vaapi_encode_h265_init_slice_params
static int vaapi_encode_h265_init_slice_params(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice)
Definition: vaapi_encode_h265.c:650
H265RawSPS::conf_win_bottom_offset
uint16_t conf_win_bottom_offset
Definition: cbs_h265.h:243
H265RawAUD::nal_unit_header
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:415
vaapi_encode_type_h265
static const VAAPIEncodeType vaapi_encode_type_h265
Definition: vaapi_encode_h265.c:879
H265RawSliceHeader::slice_type
uint8_t slice_type
Definition: cbs_h265.h:431
H265RawSPS::scaling_list_enabled_flag
uint8_t scaling_list_enabled_flag
Definition: cbs_h265.h:262
H265RawVPS::profile_tier_level
H265RawProfileTierLevel profile_tier_level
Definition: cbs_h265.h:171
H265RawAUD::pic_type
uint8_t pic_type
Definition: cbs_h265.h:417
H265RawVUI::sar_width
uint16_t sar_width
Definition: cbs_h265.h:107
H265RawPPS::transquant_bypass_enabled_flag
uint8_t transquant_bypass_enabled_flag
Definition: cbs_h265.h:352
AVCodecContext::width
int width
picture width / height.
Definition: avcodec.h:1690
H265RawVPS::vps_max_latency_increase_plus1
uint32_t vps_max_latency_increase_plus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:176
H265RawVUI::vui_hrd_parameters_present_flag
uint8_t vui_hrd_parameters_present_flag
Definition: cbs_h265.h:140
FLAGS
#define FLAGS
Definition: vaapi_encode_h265.c:967
H265RawSTRefPicSet::delta_poc_s1_minus1
uint16_t delta_poc_s1_minus1[HEVC_MAX_REFS]
Definition: cbs_h265.h:210
H265RawPPS::diff_cu_qp_delta_depth
uint8_t diff_cu_qp_delta_depth
Definition: cbs_h265.h:343
FF_PROFILE_UNKNOWN
#define FF_PROFILE_UNKNOWN
Definition: avcodec.h:2844
ff_vaapi_encode_init
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
Definition: vaapi_encode.c:1362
ff_hevc_vaapi_encoder
AVCodec ff_hevc_vaapi_encoder
Definition: vaapi_encode_h265.c:1027
ctx
AVFormatContext * ctx
Definition: movenc.c:48
H265RawSliceHeader::colour_plane_id
uint8_t colour_plane_id
Definition: cbs_h265.h:434
H265RawSPS::sps_seq_parameter_set_id
uint8_t sps_seq_parameter_set_id
Definition: cbs_h265.h:231
AVCodecContext::color_primaries
enum AVColorPrimaries color_primaries
Chromaticity coordinates of the source primaries.
Definition: avcodec.h:2127
HEVC_NAL_SPS
Definition: hevc.h:61
VAAPIEncodeContext::va_rt_format
unsigned int va_rt_format
Definition: vaapi_encode.h:100
VAAPIEncodePicture::next
struct VAAPIEncodePicture * next
Definition: vaapi_encode.h:56
AVCodecContext::level
int level
level
Definition: avcodec.h:2953
H265RawSPS::pic_width_in_luma_samples
uint16_t pic_width_in_luma_samples
Definition: cbs_h265.h:236
VAAPIEncodeContext::codec_picture_params
void * codec_picture_params
Definition: vaapi_encode.h:172
vaapi_encode_h265_init_picture_params
static int vaapi_encode_h265_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic)
Definition: vaapi_encode_h265.c:537
VAAPIEncodePicture::encode_order
int64_t encode_order
Definition: vaapi_encode.h:59
H265RawVPS::vps_base_layer_available_flag
uint8_t vps_base_layer_available_flag
Definition: cbs_h265.h:166
H265RawSPS::log2_min_luma_coding_block_size_minus3
uint8_t log2_min_luma_coding_block_size_minus3
Definition: cbs_h265.h:255
AVCodecContext::height
int height
Definition: avcodec.h:1690
CodedBitstreamFragment::data
uint8_t * data
Pointer to the bitstream form of this fragment.
Definition: cbs.h:120
H265RawPPS::pps_seq_parameter_set_id
uint8_t pps_seq_parameter_set_id
Definition: cbs_h265.h:327
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen_template.c:36
AVCOL_RANGE_JPEG
the normal 2^n-1 "JPEG" YUV ranges
Definition: pixfmt.h:499
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:261
H265RawVPS::vps_num_hrd_parameters
uint16_t vps_num_hrd_parameters
Definition: cbs_h265.h:187
H265RawSliceHeader::num_ref_idx_l1_active_minus1
uint8_t num_ref_idx_l1_active_minus1
Definition: cbs_h265.h:457
VAAPIEncodePicture::refs
struct VAAPIEncodePicture * refs[MAX_PICTURE_REFERENCES]
Definition: vaapi_encode.h:83
H265RawSTRefPicSet::used_by_curr_pic_s1_flag
uint8_t used_by_curr_pic_s1_flag[HEVC_MAX_REFS]
Definition: cbs_h265.h:211
OFFSET
#define OFFSET(x)
Definition: vaapi_encode_h265.c:965
H265RawVUI::max_bytes_per_pic_denom
uint8_t max_bytes_per_pic_denom
Definition: cbs_h265.h:148
H265RawSliceHeader::num_ref_idx_l0_active_minus1
uint8_t num_ref_idx_l0_active_minus1
Definition: cbs_h265.h:456
H265RawSPS::nal_unit_header
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:222
vaapi_encode_h265_write_slice_header
static int vaapi_encode_h265_write_slice_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)
Definition: vaapi_encode_h265.c:151
VAAPIEncodeContext::codec
const struct VAAPIEncodeType * codec
Definition: vaapi_encode.h:93
H265RawSPS::log2_diff_max_min_pcm_luma_coding_block_size
uint8_t log2_diff_max_min_pcm_luma_coding_block_size
Definition: cbs_h265.h:273
avcodec.h
Libavcodec external API header.
H265RawPPS::entropy_coding_sync_enabled_flag
uint8_t entropy_coding_sync_enabled_flag
Definition: cbs_h265.h:354
H265RawPPS::weighted_bipred_flag
uint8_t weighted_bipred_flag
Definition: cbs_h265.h:350
H265RawSPS::conf_win_top_offset
uint16_t conf_win_top_offset
Definition: cbs_h265.h:242
H265RawSPS::sps_temporal_mvp_enabled_flag
uint8_t sps_temporal_mvp_enabled_flag
Definition: cbs_h265.h:284
HEVC_SLICE_P
Definition: hevc.h:73
VAAPIEncodeContext::pic_start
VAAPIEncodePicture * pic_start
Definition: vaapi_encode.h:175
CodedBitstreamFragment
Coded bitstream fragment structure, combining one or more units.
Definition: cbs.h:114
H265RawProfileTierLevel::general_level_idc
uint8_t general_level_idc
Definition: cbs_h265.h:61
HEVC_NAL_VPS
Definition: hevc.h:60
AVCodecContext
main external API structure.
Definition: avcodec.h:1518
H265RawSliceHeader::slice_cr_qp_offset
int8_t slice_cr_qp_offset
Definition: cbs_h265.h:489
H265RawVUI::vui_num_units_in_tick
uint32_t vui_num_units_in_tick
Definition: cbs_h265.h:136
H265RawSliceHeader::short_term_ref_pic_set_sps_flag
uint8_t short_term_ref_pic_set_sps_flag
Definition: cbs_h265.h:438
H265RawSliceHeader::slice_loop_filter_across_slices_enabled_flag
uint8_t slice_loop_filter_across_slices_enabled_flag
Definition: cbs_h265.h:499
H265RawSliceHeader::luma_log2_weight_denom
uint8_t luma_log2_weight_denom
Definition: cbs_h265.h:469
H265RawSPS::max_transform_hierarchy_depth_intra
uint8_t max_transform_hierarchy_depth_intra
Definition: cbs_h265.h:260
H265RawSliceHeader::mvd_l1_zero_flag
uint8_t mvd_l1_zero_flag
Definition: cbs_h265.h:464
H265RawPPS::pps_loop_filter_across_slices_enabled_flag
uint8_t pps_loop_filter_across_slices_enabled_flag
Definition: cbs_h265.h:363
H265RawPPS::weighted_pred_flag
uint8_t weighted_pred_flag
Definition: cbs_h265.h:349
H265RawSPS::sps_temporal_id_nesting_flag
uint8_t sps_temporal_id_nesting_flag
Definition: cbs_h265.h:227
H265RawPPS::pps_cb_qp_offset
int8_t pps_cb_qp_offset
Definition: cbs_h265.h:345
aud
static int FUNC() aud(CodedBitstreamContext *ctx, RWContext *rw, H264RawAUD *current)
Definition: cbs_h264_syntax_template.c:878
H265RawVPS::vps_max_layer_id
uint8_t vps_max_layer_id
Definition: cbs_h265.h:178
H265RawSPS::conf_win_left_offset
uint16_t conf_win_left_offset
Definition: cbs_h265.h:240
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
H265RawSliceHeader::collocated_ref_idx
uint8_t collocated_ref_idx
Definition: cbs_h265.h:467
H265RawSPS::amp_enabled_flag
uint8_t amp_enabled_flag
Definition: cbs_h265.h:266
pps
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
Definition: cbs_h264_syntax_template.c:356
CodedBitstreamContext
Context structure for coded bitstream operations.
Definition: cbs.h:156
AVCodecContext::colorspace
enum AVColorSpace colorspace
YUV colorspace type.
Definition: avcodec.h:2141
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVCodecContext::color_trc
enum AVColorTransferCharacteristic color_trc
Color Transfer Characteristic.
Definition: avcodec.h:2134
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:214
H265RawSPS::chroma_format_idc
uint8_t chroma_format_idc
Definition: cbs_h265.h:233
ff_cbs_close
void ff_cbs_close(CodedBitstreamContext **ctx_ptr)
Close a context and free all internal state.
Definition: cbs.c:95
AVCodecContext::b_quant_offset
float b_quant_offset
qscale offset between IP and B-frames
Definition: avcodec.h:1799
H265RawProfileTierLevel::general_profile_compatibility_flag
uint8_t general_profile_compatibility_flag[32]
Definition: cbs_h265.h:41
H265RawVPS::vps_base_layer_internal_flag
uint8_t vps_base_layer_internal_flag
Definition: cbs_h265.h:165
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
profile
mfxU16 profile
Definition: qsvenc.c:44
vps
static int FUNC() vps(CodedBitstreamContext *ctx, RWContext *rw, H265RawVPS *current)
Definition: cbs_h265_syntax_template.c:364
H265RawSPS::pcm_loop_filter_disabled_flag
uint8_t pcm_loop_filter_disabled_flag
Definition: cbs_h265.h:274
H265RawPPS::nal_unit_header
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:324
vaapi_encode_h265_write_sequence_header
static int vaapi_encode_h265_write_sequence_header(AVCodecContext *avctx, char *data, size_t *data_len)
Definition: vaapi_encode_h265.c:118
H265RawSTRefPicSet::num_positive_pics
uint8_t num_positive_pics
Definition: cbs_h265.h:207
level
uint8_t level
Definition: svq3.c:207
H265RawPPS::pps_cr_qp_offset
int8_t pps_cr_qp_offset
Definition: cbs_h265.h:346
AVCodecContext::gop_size
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
Definition: avcodec.h:1712
H265RawSliceHeader::slice_pic_parameter_set_id
uint8_t slice_pic_parameter_set_id
Definition: cbs_h265.h:425
H265RawVUI::vui_poc_proportional_to_timing_flag
uint8_t vui_poc_proportional_to_timing_flag
Definition: cbs_h265.h:138
int
int
Definition: ffmpeg_filter.c:190
H265RawSPS::max_transform_hierarchy_depth_inter
uint8_t max_transform_hierarchy_depth_inter
Definition: cbs_h265.h:259
vaapi_encode_h265_configure
static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
Definition: vaapi_encode_h265.c:826
internal.h
common internal api header.
common.h
common internal and external API header
if
if(ret< 0)
Definition: vf_mcdeint.c:279
ref
static int ref[MAX_W *MAX_W]
Definition: jpeg2000dwt.c:107
H265RawPPS::pps_scaling_list_data_present_flag
uint8_t pps_scaling_list_data_present_flag
Definition: cbs_h265.h:370
H265RawSliceHeader::cabac_init_flag
uint8_t cabac_init_flag
Definition: cbs_h265.h:465
H265RawPPS::num_tile_rows_minus1
uint8_t num_tile_rows_minus1
Definition: cbs_h265.h:357
H265RawSPS::pcm_enabled_flag
uint8_t pcm_enabled_flag
Definition: cbs_h265.h:269
H265RawSliceHeader::slice_sao_luma_flag
uint8_t slice_sao_luma_flag
Definition: cbs_h265.h:452
ff_vaapi_encode2
int ff_vaapi_encode2(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *input_image, int *got_packet)
Definition: vaapi_encode.c:853
H265RawPPS::num_tile_columns_minus1
uint8_t num_tile_columns_minus1
Definition: cbs_h265.h:356
AVRational::den
int den
Denominator.
Definition: rational.h:60
H265RawSTRefPicSet::delta_poc_s0_minus1
uint16_t delta_poc_s0_minus1[HEVC_MAX_REFS]
Definition: cbs_h265.h:208
H265RawSPS::log2_diff_max_min_luma_coding_block_size
uint8_t log2_diff_max_min_luma_coding_block_size
Definition: cbs_h265.h:256
VAAPIEncodeH265Context::current_access_unit
CodedBitstreamFragment current_access_unit
Definition: vaapi_encode_h265.c:59
H265RawSliceHeader::slice_sao_chroma_flag
uint8_t slice_sao_chroma_flag
Definition: cbs_h265.h:453
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:1545
H265RawVPS::vps_max_num_reorder_pics
uint8_t vps_max_num_reorder_pics[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:175
H265RawSlice::header
H265RawSliceHeader header
Definition: cbs_h265.h:511
H265RawVPS::vps_time_scale
uint32_t vps_time_scale
Definition: cbs_h265.h:184
H265RawSPS::num_short_term_ref_pic_sets
uint8_t num_short_term_ref_pic_sets
Definition: cbs_h265.h:276
VAAPIEncodeSlice::codec_slice_params
void * codec_slice_params
Definition: vaapi_encode.h:52
H265RawPPS::log2_parallel_merge_level_minus2
uint8_t log2_parallel_merge_level_minus2
Definition: cbs_h265.h:374
HEVC_NAL_PPS
Definition: hevc.h:62
H265RawVPS::vps_temporal_id_nesting_flag
uint8_t vps_temporal_id_nesting_flag
Definition: cbs_h265.h:169
H265RawVUI::aspect_ratio_idc
uint8_t aspect_ratio_idc
Definition: cbs_h265.h:106
LEVEL
#define LEVEL(name, value)
H265RawSliceHeader::nal_unit_header
H265RawNALUnitHeader nal_unit_header
Definition: cbs_h265.h:421
H265RawSliceHeader::num_long_term_sps
uint8_t num_long_term_sps
Definition: cbs_h265.h:442
H265RawProfileTierLevel::general_profile_space
uint8_t general_profile_space
Definition: cbs_h265.h:37
H265RawSPS::sps_max_dec_pic_buffering_minus1
uint8_t sps_max_dec_pic_buffering_minus1[HEVC_MAX_SUB_LAYERS]
Definition: cbs_h265.h:251
HEVC_SLICE_B
Definition: hevc.h:72
H265RawPPS::init_qp_minus26
int8_t init_qp_minus26
Definition: cbs_h265.h:338
H265RawVPS::vps_num_ticks_poc_diff_one_minus1
uint32_t vps_num_ticks_poc_diff_one_minus1
Definition: cbs_h265.h:186
H265RawSPS::separate_colour_plane_flag
uint8_t separate_colour_plane_flag
Definition: cbs_h265.h:234
VAAPIEncodePicture::output_buffer
VABufferID output_buffer
Definition: vaapi_encode.h:77
H265RawSPS::strong_intra_smoothing_enabled_flag
uint8_t strong_intra_smoothing_enabled_flag
Definition: cbs_h265.h:285
H265RawVUI::colour_description_present_flag
uint8_t colour_description_present_flag
Definition: cbs_h265.h:116
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
H265RawSPS::log2_diff_max_min_luma_transform_block_size
uint8_t log2_diff_max_min_luma_transform_block_size
Definition: cbs_h265.h:258
H265RawSPS::long_term_ref_pics_present_flag
uint8_t long_term_ref_pics_present_flag
Definition: cbs_h265.h:279
VAAPIEncodePicture::display_order
int64_t display_order
Definition: vaapi_encode.h:58
H265RawSliceHeader::num_ref_idx_active_override_flag
uint8_t num_ref_idx_active_override_flag
Definition: cbs_h265.h:455
H265RawVPS::layer_id_included_flag
uint8_t layer_id_included_flag[HEVC_MAX_LAYER_SETS][HEVC_MAX_LAYERS]
Definition: cbs_h265.h:180
ff_vaapi_encode_close
av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
Definition: vaapi_encode.c:1557
H265RawNALUnitHeader::nal_unit_type
uint8_t nal_unit_type
Definition: cbs_h265.h:31
AVCodecContext::rc_max_rate
int64_t rc_max_rate
maximum bitrate
Definition: avcodec.h:2391
H265RawPPS::num_ref_idx_l1_default_active_minus1
uint8_t num_ref_idx_l1_default_active_minus1
Definition: cbs_h265.h:336
H265RawSliceHeader::first_slice_segment_in_pic_flag
uint8_t first_slice_segment_in_pic_flag
Definition: cbs_h265.h:423
H265RawPPS::cu_qp_delta_enabled_flag
uint8_t cu_qp_delta_enabled_flag
Definition: cbs_h265.h:342
put_bits.h
bitstream writer API

Generated on Sun May 13 2018 02:03:56 for FFmpeg by   doxygen 1.8.6

AltStyle によって変換されたページ (->オリジナル) /