FFmpeg
vaapi_hevc.c
Go to the documentation of this file.
1 /*
2  * HEVC HW decode acceleration through VA API
3  *
4  * Copyright (C) 2015 Timo Rothenpieler <timo@rothenpieler.org>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include <va/va.h>
24 #include <va/va_dec_hevc.h>
25 
26 #include "avcodec.h"
27 #include "hwaccel_internal.h"
28 #include "vaapi_decode.h"
29 #include "vaapi_hevc.h"
30 #include "h265_profile_level.h"
31 
32 #include "hevc/hevcdec.h"
33 
34 typedef struct VAAPIDecodePictureHEVC {
35 #if VA_CHECK_VERSION(1, 2, 0)
36  VAPictureParameterBufferHEVCExtension pic_param;
37  VASliceParameterBufferHEVCExtension last_slice_param;
38 #else
39  VAPictureParameterBufferHEVC pic_param;
40  VASliceParameterBufferHEVC last_slice_param;
41 #endif
42  const uint8_t *last_buffer;
43  size_t last_size;
44 
47 
48 static void init_vaapi_pic(VAPictureHEVC *va_pic)
49 {
50  va_pic->picture_id = VA_INVALID_ID;
51  va_pic->flags = VA_PICTURE_HEVC_INVALID;
52  va_pic->pic_order_cnt = 0;
53 }
54 
55 static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_type)
56 {
57  va_pic->picture_id = ff_vaapi_get_surface_id(pic->f);
58  va_pic->pic_order_cnt = pic->poc;
59  va_pic->flags = rps_type;
60 
62  va_pic->flags |= VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
63 
64  if (pic->f->flags & AV_FRAME_FLAG_INTERLACED) {
65  va_pic->flags |= VA_PICTURE_HEVC_FIELD_PIC;
66 
67  if (!(pic->f->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST))
68  va_pic->flags |= VA_PICTURE_HEVC_BOTTOM_FIELD;
69  }
70 }
71 
72 static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
73 {
74  VASurfaceID pic_surf = ff_vaapi_get_surface_id(pic->f);
75  const HEVCFrame *current_picture = h->cur_frame;
76  int i;
77 
78  for (i = 0; i < h->rps[ST_CURR_BEF].nb_refs; i++) {
79  if (pic_surf == ff_vaapi_get_surface_id(h->rps[ST_CURR_BEF].ref[i]->f))
80  return VA_PICTURE_HEVC_RPS_ST_CURR_BEFORE;
81  }
82 
83  for (i = 0; i < h->rps[ST_CURR_AFT].nb_refs; i++) {
84  if (pic_surf == ff_vaapi_get_surface_id(h->rps[ST_CURR_AFT].ref[i]->f))
85  return VA_PICTURE_HEVC_RPS_ST_CURR_AFTER;
86  }
87 
88  for (i = 0; i < h->rps[LT_CURR].nb_refs; i++) {
89  if (pic_surf == ff_vaapi_get_surface_id(h->rps[LT_CURR].ref[i]->f))
90  return VA_PICTURE_HEVC_RPS_LT_CURR;
91  }
92 
93  if (h->pps->pps_curr_pic_ref_enabled_flag && current_picture->poc == pic->poc)
94  return VA_PICTURE_HEVC_LONG_TERM_REFERENCE;
95 
96  return 0;
97 }
98 
100  VAPictureParameterBufferHEVC *pp)
101 {
102  const HEVCFrame *current_picture = h->cur_frame;
103  int i, j, rps_type;
104 
105  for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->ReferenceFrames); i++) {
106  const HEVCFrame *frame = NULL;
107 
108  while (!frame && j < FF_ARRAY_ELEMS(l->DPB)) {
109  if ((&l->DPB[j] != current_picture || h->pps->pps_curr_pic_ref_enabled_flag) &&
111  frame = &l->DPB[j];
112  j++;
113  }
114 
115  init_vaapi_pic(&pp->ReferenceFrames[i]);
116 
117  if (frame) {
118  rps_type = find_frame_rps_type(h, frame);
119  fill_vaapi_pic(&pp->ReferenceFrames[i], frame, rps_type);
120  }
121  }
122 }
123 
125  av_unused const uint8_t *buffer,
126  av_unused uint32_t size)
127 {
128  const HEVCContext *h = avctx->priv_data;
129  const HEVCLayerContext *l = &h->layers[h->cur_layer];
130  VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
131  const HEVCPPS *pps = h->pps;
132  const HEVCSPS *sps = pps->sps;
133 
134  const ScalingList *scaling_list = NULL;
135  int pic_param_size, err, i;
136 
137 #if VA_CHECK_VERSION(1, 2, 0)
138  int num_comps, pre_palette_size;
139 #endif
140 
141  VAPictureParameterBufferHEVC *pic_param = (VAPictureParameterBufferHEVC *)&pic->pic_param;
142 
143  pic->pic.output_surface = ff_vaapi_get_surface_id(h->cur_frame->f);
144 
145  *pic_param = (VAPictureParameterBufferHEVC) {
146  .pic_width_in_luma_samples = sps->width,
147  .pic_height_in_luma_samples = sps->height,
148  .log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3,
149  .sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1,
150  .log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size,
151  .log2_min_transform_block_size_minus2 = sps->log2_min_tb_size - 2,
152  .log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size,
153  .max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter,
154  .max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra,
155  .num_short_term_ref_pic_sets = sps->nb_st_rps,
156  .num_long_term_ref_pic_sps = sps->num_long_term_ref_pics_sps,
157  .num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1,
158  .num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1,
159  .init_qp_minus26 = pps->pic_init_qp_minus26,
160  .pps_cb_qp_offset = pps->cb_qp_offset,
161  .pps_cr_qp_offset = pps->cr_qp_offset,
162  .pcm_sample_bit_depth_luma_minus1 = sps->pcm.bit_depth - 1,
163  .pcm_sample_bit_depth_chroma_minus1 = sps->pcm.bit_depth_chroma - 1,
164  .log2_min_pcm_luma_coding_block_size_minus3 = sps->pcm.log2_min_pcm_cb_size - 3,
165  .log2_diff_max_min_pcm_luma_coding_block_size = sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size,
166  .diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth,
167  .pps_beta_offset_div2 = pps->beta_offset / 2,
168  .pps_tc_offset_div2 = pps->tc_offset / 2,
169  .log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2,
170  .bit_depth_luma_minus8 = sps->bit_depth - 8,
171  .bit_depth_chroma_minus8 = sps->bit_depth - 8,
172  .log2_max_pic_order_cnt_lsb_minus4 = sps->log2_max_poc_lsb - 4,
173  .num_extra_slice_header_bits = pps->num_extra_slice_header_bits,
174  .pic_fields.bits = {
175  .chroma_format_idc = sps->chroma_format_idc,
176  .tiles_enabled_flag = pps->tiles_enabled_flag,
177  .separate_colour_plane_flag = sps->separate_colour_plane,
178  .pcm_enabled_flag = sps->pcm_enabled,
179  .scaling_list_enabled_flag = sps->scaling_list_enabled,
180  .transform_skip_enabled_flag = pps->transform_skip_enabled_flag,
181  .amp_enabled_flag = sps->amp_enabled,
182  .strong_intra_smoothing_enabled_flag = sps->strong_intra_smoothing_enabled,
183  .sign_data_hiding_enabled_flag = pps->sign_data_hiding_flag,
184  .constrained_intra_pred_flag = pps->constrained_intra_pred_flag,
185  .cu_qp_delta_enabled_flag = pps->cu_qp_delta_enabled_flag,
186  .weighted_pred_flag = pps->weighted_pred_flag,
187  .weighted_bipred_flag = pps->weighted_bipred_flag,
188  .transquant_bypass_enabled_flag = pps->transquant_bypass_enable_flag,
189  .entropy_coding_sync_enabled_flag = pps->entropy_coding_sync_enabled_flag,
190  .pps_loop_filter_across_slices_enabled_flag = pps->seq_loop_filter_across_slices_enabled_flag,
191  .loop_filter_across_tiles_enabled_flag = pps->loop_filter_across_tiles_enabled_flag,
192  .pcm_loop_filter_disabled_flag = sps->pcm_loop_filter_disabled,
193  },
194  .slice_parsing_fields.bits = {
195  .lists_modification_present_flag = pps->lists_modification_present_flag,
196  .long_term_ref_pics_present_flag = sps->long_term_ref_pics_present,
197  .sps_temporal_mvp_enabled_flag = sps->temporal_mvp_enabled,
198  .cabac_init_present_flag = pps->cabac_init_present_flag,
199  .output_flag_present_flag = pps->output_flag_present_flag,
200  .dependent_slice_segments_enabled_flag = pps->dependent_slice_segments_enabled_flag,
201  .pps_slice_chroma_qp_offsets_present_flag = pps->pic_slice_level_chroma_qp_offsets_present_flag,
202  .sample_adaptive_offset_enabled_flag = sps->sao_enabled,
203  .deblocking_filter_override_enabled_flag = pps->deblocking_filter_override_enabled_flag,
204  .pps_disable_deblocking_filter_flag = pps->disable_dbf,
205  .slice_segment_header_extension_present_flag = pps->slice_header_extension_present_flag,
206  .RapPicFlag = IS_IRAP(h),
207  .IdrPicFlag = IS_IDR(h),
208  .IntraPicFlag = IS_IRAP(h),
209  },
210  };
211 
212  fill_vaapi_pic(&pic_param->CurrPic, h->cur_frame, 0);
213  fill_vaapi_reference_frames(h, l, pic_param);
214 
215  if (pps->tiles_enabled_flag) {
216  pic_param->num_tile_columns_minus1 = pps->num_tile_columns - 1;
217  pic_param->num_tile_rows_minus1 = pps->num_tile_rows - 1;
218 
219  for (i = 0; i < pps->num_tile_columns; i++)
220  pic_param->column_width_minus1[i] = pps->column_width[i] - 1;
221 
222  for (i = 0; i < pps->num_tile_rows; i++)
223  pic_param->row_height_minus1[i] = pps->row_height[i] - 1;
224  }
225 
226  if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) {
227  pic_param->st_rps_bits = h->sh.short_term_ref_pic_set_size;
228  } else {
229  pic_param->st_rps_bits = 0;
230  }
231 
232 #if VA_CHECK_VERSION(1, 2, 0)
233  if (avctx->profile == AV_PROFILE_HEVC_REXT ||
234  avctx->profile == AV_PROFILE_HEVC_SCC) {
235  pic->pic_param.rext = (VAPictureParameterBufferHEVCRext) {
236  .range_extension_pic_fields.bits = {
237  .transform_skip_rotation_enabled_flag = sps->transform_skip_rotation_enabled,
238  .transform_skip_context_enabled_flag = sps->transform_skip_context_enabled,
239  .implicit_rdpcm_enabled_flag = sps->implicit_rdpcm_enabled,
240  .explicit_rdpcm_enabled_flag = sps->explicit_rdpcm_enabled,
241  .extended_precision_processing_flag = sps->extended_precision_processing,
242  .intra_smoothing_disabled_flag = sps->intra_smoothing_disabled,
243  .high_precision_offsets_enabled_flag = sps->high_precision_offsets_enabled,
244  .persistent_rice_adaptation_enabled_flag = sps->persistent_rice_adaptation_enabled,
245  .cabac_bypass_alignment_enabled_flag = sps->cabac_bypass_alignment_enabled,
246  .cross_component_prediction_enabled_flag = pps->cross_component_prediction_enabled_flag,
247  .chroma_qp_offset_list_enabled_flag = pps->chroma_qp_offset_list_enabled_flag,
248  },
249  .diff_cu_chroma_qp_offset_depth = pps->diff_cu_chroma_qp_offset_depth,
250  .chroma_qp_offset_list_len_minus1 = pps->chroma_qp_offset_list_len_minus1,
251  .log2_sao_offset_scale_luma = pps->log2_sao_offset_scale_luma,
252  .log2_sao_offset_scale_chroma = pps->log2_sao_offset_scale_chroma,
253  .log2_max_transform_skip_block_size_minus2 = pps->log2_max_transform_skip_block_size - 2,
254  };
255 
256  for (i = 0; i < 6; i++)
257  pic->pic_param.rext.cb_qp_offset_list[i] = pps->cb_qp_offset_list[i];
258  for (i = 0; i < 6; i++)
259  pic->pic_param.rext.cr_qp_offset_list[i] = pps->cr_qp_offset_list[i];
260  }
261 
262  pre_palette_size = pps->pps_palette_predictor_initializers_present_flag ?
263  pps->pps_num_palette_predictor_initializers :
264  (sps->palette_predictor_initializers_present ?
265  sps->sps_num_palette_predictor_initializers :
266  0);
267 
268  if (avctx->profile == AV_PROFILE_HEVC_SCC) {
269  pic->pic_param.scc = (VAPictureParameterBufferHEVCScc) {
270  .screen_content_pic_fields.bits = {
271  .pps_curr_pic_ref_enabled_flag = pps->pps_curr_pic_ref_enabled_flag,
272  .palette_mode_enabled_flag = sps->palette_mode_enabled,
273  .motion_vector_resolution_control_idc = sps->motion_vector_resolution_control_idc,
274  .intra_boundary_filtering_disabled_flag = sps->intra_boundary_filtering_disabled,
275  .residual_adaptive_colour_transform_enabled_flag
276  = pps->residual_adaptive_colour_transform_enabled_flag,
277  .pps_slice_act_qp_offsets_present_flag = pps->pps_slice_act_qp_offsets_present_flag,
278  },
279  .palette_max_size = sps->palette_max_size,
280  .delta_palette_max_predictor_size = sps->delta_palette_max_predictor_size,
281  .predictor_palette_size = pre_palette_size,
282  .pps_act_y_qp_offset_plus5 = pps->residual_adaptive_colour_transform_enabled_flag ?
283  pps->pps_act_y_qp_offset + 5 : 0,
284  .pps_act_cb_qp_offset_plus5 = pps->residual_adaptive_colour_transform_enabled_flag ?
285  pps->pps_act_cb_qp_offset + 5 : 0,
286  .pps_act_cr_qp_offset_plus3 = pps->residual_adaptive_colour_transform_enabled_flag ?
287  pps->pps_act_cr_qp_offset + 3 : 0,
288  };
289 
290  num_comps = pps->monochrome_palette_flag ? 1 : 3;
291  for (int comp = 0; comp < num_comps; comp++)
292  for (int j = 0; j < pre_palette_size; j++)
293  pic->pic_param.scc.predictor_palette_entries[comp][j] =
294  pps->pps_palette_predictor_initializers_present_flag ?
295  pps->pps_palette_predictor_initializer[comp][j]:
296  sps->sps_palette_predictor_initializer[comp][j];
297  }
298 
299 #endif
300  pic_param_size = avctx->profile >= AV_PROFILE_HEVC_REXT ?
301  sizeof(pic->pic_param) : sizeof(VAPictureParameterBufferHEVC);
302 
303  err = ff_vaapi_decode_make_param_buffer(avctx, &pic->pic,
304  VAPictureParameterBufferType,
305  &pic->pic_param, pic_param_size);
306  if (err < 0)
307  goto fail;
308 
309  if (pps->scaling_list_data_present_flag)
310  scaling_list = &pps->scaling_list;
311  else if (sps->scaling_list_enabled)
312  scaling_list = &sps->scaling_list;
313 
314  if (scaling_list) {
315  VAIQMatrixBufferHEVC iq_matrix;
316  int j;
317 
318  for (i = 0; i < 6; i++) {
319  for (j = 0; j < 16; j++)
320  iq_matrix.ScalingList4x4[i][j] = scaling_list->sl[0][i][j];
321  for (j = 0; j < 64; j++) {
322  iq_matrix.ScalingList8x8[i][j] = scaling_list->sl[1][i][j];
323  iq_matrix.ScalingList16x16[i][j] = scaling_list->sl[2][i][j];
324  if (i < 2)
325  iq_matrix.ScalingList32x32[i][j] = scaling_list->sl[3][i * 3][j];
326  }
327  iq_matrix.ScalingListDC16x16[i] = scaling_list->sl_dc[0][i];
328  if (i < 2)
329  iq_matrix.ScalingListDC32x32[i] = scaling_list->sl_dc[1][i * 3];
330  }
331 
332  err = ff_vaapi_decode_make_param_buffer(avctx, &pic->pic,
333  VAIQMatrixBufferType,
334  &iq_matrix, sizeof(iq_matrix));
335  if (err < 0)
336  goto fail;
337  }
338 
339  return 0;
340 
341 fail:
342  ff_vaapi_decode_cancel(avctx, &pic->pic);
343  return err;
344 }
345 
347 {
348  const HEVCContext *h = avctx->priv_data;
349  VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
350  VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param;
351  int ret;
352 
353  int slice_param_size = avctx->profile >= AV_PROFILE_HEVC_REXT ?
354  sizeof(pic->last_slice_param) : sizeof(VASliceParameterBufferHEVC);
355 
356  if (pic->last_size) {
357  last_slice_param->LongSliceFlags.fields.LastSliceOfPic = 1;
359  &pic->last_slice_param, 1, slice_param_size,
360  pic->last_buffer, pic->last_size);
361  if (ret < 0)
362  goto fail;
363  }
364 
365 
366  ret = ff_vaapi_decode_issue(avctx, &pic->pic);
367  if (ret < 0)
368  goto fail;
369 
370  return 0;
371 fail:
372  ff_vaapi_decode_cancel(avctx, &pic->pic);
373  return ret;
374 }
375 
377  const HEVCContext *h,
378  const SliceHeader *sh,
379  VASliceParameterBufferHEVC *slice_param)
380 {
381  int i;
382 #if VA_CHECK_VERSION(1, 2, 0)
383  int is_rext = avctx->profile >= AV_PROFILE_HEVC_REXT;
384 #else
385  int is_rext = 0;
386  if (avctx->profile >= AV_PROFILE_HEVC_REXT)
387  av_log(avctx, AV_LOG_WARNING, "Please consider to update to VAAPI 1.2.0 "
388  "or above, which can support REXT related setting correctly.\n");
389 #endif
390 
391  memset(slice_param->delta_luma_weight_l0, 0, sizeof(slice_param->delta_luma_weight_l0));
392  memset(slice_param->delta_luma_weight_l1, 0, sizeof(slice_param->delta_luma_weight_l1));
393  memset(slice_param->luma_offset_l0, 0, sizeof(slice_param->luma_offset_l0));
394  memset(slice_param->luma_offset_l1, 0, sizeof(slice_param->luma_offset_l1));
395  memset(slice_param->delta_chroma_weight_l0, 0, sizeof(slice_param->delta_chroma_weight_l0));
396  memset(slice_param->delta_chroma_weight_l1, 0, sizeof(slice_param->delta_chroma_weight_l1));
397  memset(slice_param->ChromaOffsetL0, 0, sizeof(slice_param->ChromaOffsetL0));
398  memset(slice_param->ChromaOffsetL1, 0, sizeof(slice_param->ChromaOffsetL1));
399 
400  slice_param->delta_chroma_log2_weight_denom = 0;
401  slice_param->luma_log2_weight_denom = 0;
402 
403  if (sh->slice_type == HEVC_SLICE_I ||
404  (sh->slice_type == HEVC_SLICE_P && !h->pps->weighted_pred_flag) ||
405  (sh->slice_type == HEVC_SLICE_B && !h->pps->weighted_bipred_flag))
406  return;
407 
408  slice_param->luma_log2_weight_denom = sh->luma_log2_weight_denom;
409 
410  if (h->pps->sps->chroma_format_idc) {
411  slice_param->delta_chroma_log2_weight_denom = sh->chroma_log2_weight_denom - sh->luma_log2_weight_denom;
412  }
413 
414  for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
415  slice_param->delta_luma_weight_l0[i] = sh->luma_weight_l0[i] - (1 << sh->luma_log2_weight_denom);
416  slice_param->delta_chroma_weight_l0[i][0] = sh->chroma_weight_l0[i][0] - (1 << sh->chroma_log2_weight_denom);
417  slice_param->delta_chroma_weight_l0[i][1] = sh->chroma_weight_l0[i][1] - (1 << sh->chroma_log2_weight_denom);
418  if (!is_rext) {
419  slice_param->luma_offset_l0[i] = sh->luma_offset_l0[i];
420  slice_param->ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
421  slice_param->ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
422  }
423  }
424 
425  if (sh->slice_type == HEVC_SLICE_B) {
426  for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
427  slice_param->delta_luma_weight_l1[i] = sh->luma_weight_l1[i] - (1 << sh->luma_log2_weight_denom);
428  slice_param->delta_chroma_weight_l1[i][0] = sh->chroma_weight_l1[i][0] - (1 << sh->chroma_log2_weight_denom);
429  slice_param->delta_chroma_weight_l1[i][1] = sh->chroma_weight_l1[i][1] - (1 << sh->chroma_log2_weight_denom);
430  if (!is_rext) {
431  slice_param->luma_offset_l1[i] = sh->luma_offset_l1[i];
432  slice_param->ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
433  slice_param->ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
434  }
435  }
436  }
437 }
438 
439 static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame)
440 {
441  VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
442  VAPictureParameterBufferHEVC *pp = (VAPictureParameterBufferHEVC *)&pic->pic_param;
443  uint8_t i;
444 
445  if (!frame)
446  return 0xff;
447 
448  for (i = 0; i < FF_ARRAY_ELEMS(pp->ReferenceFrames); i++) {
449  VASurfaceID pid = pp->ReferenceFrames[i].picture_id;
450  int poc = pp->ReferenceFrames[i].pic_order_cnt;
451  if (pid != VA_INVALID_ID && pid == ff_vaapi_get_surface_id(frame->f) && poc == frame->poc)
452  return i;
453  }
454 
455  return 0xff;
456 }
457 
459  const uint8_t *buffer,
460  uint32_t size)
461 {
462  const HEVCContext *h = avctx->priv_data;
463  const SliceHeader *sh = &h->sh;
464  VAAPIDecodePictureHEVC *pic = h->cur_frame->hwaccel_picture_private;
465  VASliceParameterBufferHEVC *last_slice_param = (VASliceParameterBufferHEVC *)&pic->last_slice_param;
466 
467  int slice_param_size = avctx->profile >= AV_PROFILE_HEVC_REXT ?
468  sizeof(pic->last_slice_param) : sizeof(VASliceParameterBufferHEVC);
469 
470  int nb_list = (sh->slice_type == HEVC_SLICE_B) ?
471  2 : (sh->slice_type == HEVC_SLICE_I ? 0 : 1);
472 
473  int err, i, list_idx;
474 
475  if (!sh->first_slice_in_pic_flag) {
476  err = ff_vaapi_decode_make_slice_buffer(avctx, &pic->pic,
477  &pic->last_slice_param, 1, slice_param_size,
478  pic->last_buffer, pic->last_size);
479  pic->last_buffer = NULL;
480  pic->last_size = 0;
481  if (err) {
482  ff_vaapi_decode_cancel(avctx, &pic->pic);
483  return err;
484  }
485  }
486 
487  *last_slice_param = (VASliceParameterBufferHEVC) {
488  .slice_data_size = size,
489  .slice_data_offset = 0,
490  .slice_data_flag = VA_SLICE_DATA_FLAG_ALL,
491  .slice_data_byte_offset = sh->data_offset,
492  .slice_segment_address = sh->slice_segment_addr,
493  .slice_qp_delta = sh->slice_qp_delta,
494  .slice_cb_qp_offset = sh->slice_cb_qp_offset,
495  .slice_cr_qp_offset = sh->slice_cr_qp_offset,
496  .slice_beta_offset_div2 = sh->beta_offset / 2,
497  .slice_tc_offset_div2 = sh->tc_offset / 2,
498  .collocated_ref_idx = sh->slice_temporal_mvp_enabled_flag ? sh->collocated_ref_idx : 0xFF,
499  .five_minus_max_num_merge_cand = sh->slice_type == HEVC_SLICE_I ? 0 : 5 - sh->max_num_merge_cand,
500  .num_ref_idx_l0_active_minus1 = sh->nb_refs[L0] ? sh->nb_refs[L0] - 1 : 0,
501  .num_ref_idx_l1_active_minus1 = sh->nb_refs[L1] ? sh->nb_refs[L1] - 1 : 0,
502 
503  .LongSliceFlags.fields = {
504  .dependent_slice_segment_flag = sh->dependent_slice_segment_flag,
505  .slice_type = sh->slice_type,
506  .color_plane_id = sh->colour_plane_id,
507  .mvd_l1_zero_flag = sh->mvd_l1_zero_flag,
508  .cabac_init_flag = sh->cabac_init_flag,
509  .slice_temporal_mvp_enabled_flag = sh->slice_temporal_mvp_enabled_flag,
510  .slice_deblocking_filter_disabled_flag = sh->disable_deblocking_filter_flag,
511  .collocated_from_l0_flag = sh->collocated_list == L0 ? 1 : 0,
512  .slice_loop_filter_across_slices_enabled_flag = sh->slice_loop_filter_across_slices_enabled_flag,
513  .slice_sao_luma_flag = sh->slice_sample_adaptive_offset_flag[0],
514  .slice_sao_chroma_flag = sh->slice_sample_adaptive_offset_flag[1],
515  },
516  };
517 
518  memset(last_slice_param->RefPicList, 0xFF, sizeof(last_slice_param->RefPicList));
519 
520  for (list_idx = 0; list_idx < nb_list; list_idx++) {
521  RefPicList *rpl = &h->cur_frame->refPicList[list_idx];
522 
523  for (i = 0; i < rpl->nb_refs; i++)
524  last_slice_param->RefPicList[list_idx][i] = get_ref_pic_index(h, rpl->ref[i]);
525  }
526 
527  fill_pred_weight_table(avctx, h, sh, last_slice_param);
528 
529 #if VA_CHECK_VERSION(1, 2, 0)
530  if (avctx->profile >= AV_PROFILE_HEVC_REXT) {
531  pic->last_slice_param.rext = (VASliceParameterBufferHEVCRext) {
532  .slice_ext_flags.bits = {
533  .cu_chroma_qp_offset_enabled_flag = sh->cu_chroma_qp_offset_enabled_flag,
534  .use_integer_mv_flag = sh->use_integer_mv_flag,
535  },
536  .slice_act_y_qp_offset = sh->slice_act_y_qp_offset,
537  .slice_act_cb_qp_offset = sh->slice_act_cb_qp_offset,
538  .slice_act_cr_qp_offset = sh->slice_act_cr_qp_offset,
539  };
540  for (i = 0; i < 15 && i < sh->nb_refs[L0]; i++) {
541  pic->last_slice_param.rext.luma_offset_l0[i] = sh->luma_offset_l0[i];
542  pic->last_slice_param.rext.ChromaOffsetL0[i][0] = sh->chroma_offset_l0[i][0];
543  pic->last_slice_param.rext.ChromaOffsetL0[i][1] = sh->chroma_offset_l0[i][1];
544  }
545 
546  if (sh->slice_type == HEVC_SLICE_B) {
547  for (i = 0; i < 15 && i < sh->nb_refs[L1]; i++) {
548  pic->last_slice_param.rext.luma_offset_l1[i] = sh->luma_offset_l1[i];
549  pic->last_slice_param.rext.ChromaOffsetL1[i][0] = sh->chroma_offset_l1[i][0];
550  pic->last_slice_param.rext.ChromaOffsetL1[i][1] = sh->chroma_offset_l1[i][1];
551  }
552  }
553  }
554 #endif
555 
556  pic->last_buffer = buffer;
557  pic->last_size = size;
558 
559  return 0;
560 }
561 
562 static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel *h265_raw_ptl)
563 {
564  h265_raw_ptl->general_profile_space = general_ptl->profile_space;
565  h265_raw_ptl->general_tier_flag = general_ptl->tier_flag;
566  h265_raw_ptl->general_profile_idc = general_ptl->profile_idc;
567 
568  memcpy(h265_raw_ptl->general_profile_compatibility_flag,
569  general_ptl->profile_compatibility_flag, 32 * sizeof(uint8_t));
570 
571 #define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name
572  copy_field(progressive_source_flag);
573  copy_field(interlaced_source_flag);
574  copy_field(non_packed_constraint_flag);
575  copy_field(frame_only_constraint_flag);
576  copy_field(max_12bit_constraint_flag);
577  copy_field(max_10bit_constraint_flag);
578  copy_field(max_8bit_constraint_flag);
579  copy_field(max_422chroma_constraint_flag);
580  copy_field(max_420chroma_constraint_flag);
581  copy_field(max_monochrome_constraint_flag);
582  copy_field(intra_constraint_flag);
583  copy_field(one_picture_only_constraint_flag);
584  copy_field(lower_bit_rate_constraint_flag);
585  copy_field(max_14bit_constraint_flag);
586  copy_field(inbld_flag);
588 #undef copy_field
589 
590  return 0;
591 }
592 
593 /*
594  * Find exact va_profile for HEVC Range Extension and Screen Content Coding Extension
595  */
597 {
598  const HEVCContext *h = avctx->priv_data;
599  const HEVCSPS *sps = h->pps->sps;
600  const PTL *ptl = &sps->ptl;
601  const PTLCommon *general_ptl = &ptl->general_ptl;
603  H265RawProfileTierLevel h265_raw_ptl = {0};
604 
605  /* convert PTLCommon to H265RawProfileTierLevel */
606  ptl_convert(general_ptl, &h265_raw_ptl);
607 
608  profile = ff_h265_get_profile(&h265_raw_ptl);
609  if (!profile) {
610  av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
611  goto end;
612  } else {
613  av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n", profile->name);
614  }
615 
616 #if VA_CHECK_VERSION(1, 2, 0)
617  if (!strcmp(profile->name, "Main 12") ||
618  !strcmp(profile->name, "Main 12 Intra"))
619  return VAProfileHEVCMain12;
620  else if (!strcmp(profile->name, "Main 4:2:2 10") ||
621  !strcmp(profile->name, "Main 4:2:2 10 Intra"))
622  return VAProfileHEVCMain422_10;
623  else if (!strcmp(profile->name, "Main 4:2:2 12") ||
624  !strcmp(profile->name, "Main 4:2:2 12 Intra"))
625  return VAProfileHEVCMain422_12;
626  else if (!strcmp(profile->name, "Main 4:4:4") ||
627  !strcmp(profile->name, "Main 4:4:4 Intra"))
628  return VAProfileHEVCMain444;
629  else if (!strcmp(profile->name, "Main 4:4:4 10") ||
630  !strcmp(profile->name, "Main 4:4:4 10 Intra"))
631  return VAProfileHEVCMain444_10;
632  else if (!strcmp(profile->name, "Main 4:4:4 12") ||
633  !strcmp(profile->name, "Main 4:4:4 12 Intra"))
634  return VAProfileHEVCMain444_12;
635  else if (!strcmp(profile->name, "Screen-Extended Main"))
636  return VAProfileHEVCSccMain;
637  else if (!strcmp(profile->name, "Screen-Extended Main 10"))
638  return VAProfileHEVCSccMain10;
639  else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4"))
640  return VAProfileHEVCSccMain444;
641 #if VA_CHECK_VERSION(1, 8, 0)
642  else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4 10"))
643  return VAProfileHEVCSccMain444_10;
644 #endif
645 #else
646  av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is "
647  "not supported with this VA version.\n", profile->name);
648 #endif
649 
650 end:
652  // Default to selecting Main profile if profile mismatch is allowed
653  return VAProfileHEVCMain;
654  } else
655  return VAProfileNone;
656 }
657 
659  .p.name = "hevc_vaapi",
660  .p.type = AVMEDIA_TYPE_VIDEO,
661  .p.id = AV_CODEC_ID_HEVC,
662  .p.pix_fmt = AV_PIX_FMT_VAAPI,
663  .start_frame = vaapi_hevc_start_frame,
664  .end_frame = vaapi_hevc_end_frame,
665  .decode_slice = vaapi_hevc_decode_slice,
666  .frame_priv_data_size = sizeof(VAAPIDecodePictureHEVC),
669  .frame_params = ff_vaapi_common_frame_params,
670  .priv_data_size = sizeof(VAAPIDecodeContext),
671  .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
672 };
SliceHeader::beta_offset
int beta_offset
beta_offset_div2 * 2
Definition: hevcdec.h:257
L1
F H1 F F H1 F F F F H1<-F-------F-------F v v v H2 H3 H2 ^ ^ ^ F-------F-------F-> H1<-F-------F-------F|||||||||F H1 F|||||||||F H1 Funavailable fullpel samples(outside the picture for example) shall be equalto the closest available fullpel sampleSmaller pel interpolation:--------------------------if diag_mc is set then points which lie on a line between 2 vertically, horizontally or diagonally adjacent halfpel points shall be interpolatedlinearly with rounding to nearest and halfway values rounded up.points which lie on 2 diagonals at the same time should only use the onediagonal not containing the fullpel point F--> O q O<--h1-> O q O<--F v \/v \/v O O O O O O O|/|\|q q q q q|/|\|O O O O O O O ^/\ ^/\ ^ h2--> O q O<--h3-> O q O<--h2 v \/v \/v O O O O O O O|\|/|q q q q q|\|/|O O O O O O O ^/\ ^/\ ^ F--> O q O<--h1-> O q O<--Fthe remaining points shall be bilinearly interpolated from theup to 4 surrounding halfpel and fullpel points, again rounding should be tonearest and halfway values rounded upcompliant Snow decoders MUST support 1-1/8 pel luma and 1/2-1/16 pel chromainterpolation at leastOverlapped block motion compensation:-------------------------------------FIXMELL band prediction:===================Each sample in the LL0 subband is predicted by the median of the left, top andleft+top-topleft samples, samples outside the subband shall be considered tobe 0. To reverse this prediction in the decoder apply the following.for(y=0;y< height;y++){ for(x=0;x< width;x++){ sample[y][x]+=median(sample[y-1][x], sample[y][x-1], sample[y-1][x]+sample[y][x-1]-sample[y-1][x-1]);}}sample[-1][ *]=sample[ *][-1]=0;width, height here are the width and height of the LL0 subband not of the finalvideoDequantization:===============FIXMEWavelet Transform:==================Snow supports 2 wavelet transforms, the symmetric biorthogonal 5/3 integertransform and an integer approximation of the symmetric biorthogonal 9/7daubechies wavelet.2D IDWT(inverse discrete wavelet transform) --------------------------------------------The 2D IDWT applies a 2D filter recursively, each time combining the4 lowest frequency subbands into a single subband until only 1 subbandremains.The 2D filter is done by first applying a 1D filter in the vertical directionand then applying it in the horizontal one. --------------- --------------- --------------- ---------------|LL0|HL0|||||||||||||---+---|HL1||L0|H0|HL1||LL1|HL1|||||LH0|HH0|||||||||||||-------+-------|-> L1 H1 LH1 HH1 LH1 HH1 LH1 HH1 L1
Definition: snow.txt:554
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:215
HEVCFrame::flags
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
Definition: hevcdec.h:385
SliceHeader::slice_act_cr_qp_offset
int slice_act_cr_qp_offset
Definition: hevcdec.h:253
SliceHeader::chroma_offset_l1
int16_t chroma_offset_l1[16][2]
Definition: hevcdec.h:282
ff_vaapi_get_surface_id
static VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
Definition: vaapi_decode.h:30
vaapi_hevc_end_frame
static int vaapi_hevc_end_frame(AVCodecContext *avctx)
Definition: vaapi_hevc.c:346
SliceHeader::slice_act_y_qp_offset
int slice_act_y_qp_offset
Definition: hevcdec.h:251
comp
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition: eamad.c:81
VAAPIDecodeContext
Definition: vaapi_decode.h:47
vaapi_decode.h
ff_h265_get_profile
const H265ProfileDescriptor * ff_h265_get_profile(const H265RawProfileTierLevel *ptl)
Definition: h265_profile_level.c:123
av_unused
#define av_unused
Definition: attributes.h:131
FFHWAccel::p
AVHWAccel p
The public AVHWAccel.
Definition: hwaccel_internal.h:38
VAAPIDecodePicture
Definition: vaapi_decode.h:35
level_idc
int level_idc
Definition: h264_levels.c:29
SliceHeader::slice_temporal_mvp_enabled_flag
uint8_t slice_temporal_mvp_enabled_flag
Definition: hevcdec.h:233
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:225
PTLCommon::profile_space
uint8_t profile_space
Definition: ps.h:128
SliceHeader::slice_loop_filter_across_slices_enabled_flag
uint8_t slice_loop_filter_across_slices_enabled_flag
Definition: hevcdec.h:242
AVFrame::flags
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:661
RefPicList
Definition: hevcdec.h:192
H265ProfileDescriptor
Definition: h265_profile_level.h:47
PTLCommon::profile_compatibility_flag
uint8_t profile_compatibility_flag[32]
Definition: ps.h:131
AV_FRAME_FLAG_TOP_FIELD_FIRST
#define AV_FRAME_FLAG_TOP_FIELD_FIRST
A flag to mark frames where the top field is displayed first if the content is interlaced.
Definition: frame.h:653
ptl_convert
static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel *h265_raw_ptl)
Definition: vaapi_hevc.c:562
ff_vaapi_decode_make_param_buffer
int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, int type, const void *data, size_t size)
Definition: vaapi_decode.c:34
HEVC_FRAME_FLAG_LONG_REF
#define HEVC_FRAME_FLAG_LONG_REF
Definition: hevcdec.h:354
FFHWAccel
Definition: hwaccel_internal.h:34
fail
#define fail()
Definition: checkasm.h:189
SliceHeader::luma_log2_weight_denom
uint8_t luma_log2_weight_denom
Definition: hevcdec.h:270
fill_vaapi_pic
static void fill_vaapi_pic(VAPictureHEVC *va_pic, const HEVCFrame *pic, int rps_type)
Definition: vaapi_hevc.c:55
RefPicList::nb_refs
int nb_refs
Definition: hevcdec.h:196
SliceHeader::slice_segment_addr
unsigned int slice_segment_addr
address (in raster order) of the first block in the current slice
Definition: hevcdec.h:207
VAAPIDecodePicture::output_surface
VASurfaceID output_surface
Definition: vaapi_decode.h:36
HEVC_SLICE_B
@ HEVC_SLICE_B
Definition: hevc.h:96
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
ptl
const H265RawProfileTierLevel * ptl
Definition: h265_levels.c:170
SliceHeader::cabac_init_flag
uint8_t cabac_init_flag
Definition: hevcdec.h:240
PTLCommon
Definition: ps.h:127
ff_vaapi_decode_init
int ff_vaapi_decode_init(AVCodecContext *avctx)
Definition: vaapi_decode.c:692
AV_PROFILE_HEVC_SCC
#define AV_PROFILE_HEVC_SCC
Definition: defs.h:164
SliceHeader::luma_offset_l1
int16_t luma_offset_l1[16]
Definition: hevcdec.h:281
H265RawProfileTierLevel::general_profile_idc
uint8_t general_profile_idc
Definition: cbs_h265.h:39
ff_vaapi_common_frame_params
int ff_vaapi_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition: vaapi_decode.c:668
vaapi_hevc_decode_slice
static int vaapi_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition: vaapi_hevc.c:458
find_frame_rps_type
static int find_frame_rps_type(const HEVCContext *h, const HEVCFrame *pic)
Definition: vaapi_hevc.c:72
IS_IDR
#define IS_IDR(s)
Definition: hevcdec.h:76
HEVC_FRAME_FLAG_SHORT_REF
#define HEVC_FRAME_FLAG_SHORT_REF
Definition: hevcdec.h:353
RefPicList::ref
struct HEVCFrame * ref[HEVC_MAX_REFS]
Definition: hevcdec.h:193
vaapi_hevc_start_frame
static int vaapi_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: vaapi_hevc.c:124
ff_vaapi_decode_uninit
int ff_vaapi_decode_uninit(AVCodecContext *avctx)
Definition: vaapi_decode.c:738
PTLCommon::profile_idc
uint8_t profile_idc
Definition: ps.h:130
ScalingList
Definition: ps.h:245
SliceHeader::collocated_list
uint8_t collocated_list
Definition: hevcdec.h:243
SliceHeader::luma_offset_l0
int16_t luma_offset_l0[16]
Definition: hevcdec.h:278
SliceHeader::chroma_weight_l1
int16_t chroma_weight_l1[16][2]
Definition: hevcdec.h:275
PTLCommon::tier_flag
uint8_t tier_flag
Definition: ps.h:129
ff_vaapi_decode_issue
int ff_vaapi_decode_issue(AVCodecContext *avctx, VAAPIDecodePicture *pic)
Definition: vaapi_decode.c:166
if
if(ret)
Definition: filter_design.txt:179
HWACCEL_CAP_ASYNC_SAFE
#define HWACCEL_CAP_ASYNC_SAFE
Header providing the internals of AVHWAccel.
Definition: hwaccel_internal.h:31
NULL
#define NULL
Definition: coverity.c:32
get_ref_pic_index
static uint8_t get_ref_pic_index(const HEVCContext *h, const HEVCFrame *frame)
Definition: vaapi_hevc.c:439
hwaccel_internal.h
HEVC_SLICE_I
@ HEVC_SLICE_I
Definition: hevc.h:98
AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH
Hardware acceleration should still be attempted for decoding when the codec profile does not match th...
Definition: avcodec.h:2169
L0
#define L0
Definition: hevcdec.h:58
VAAPIDecodePictureHEVC
Definition: vaapi_hevc.c:34
PTL
Definition: ps.h:150
init_vaapi_pic
static void init_vaapi_pic(VAPictureHEVC *va_pic)
Definition: vaapi_hevc.c:48
VAAPIDecodePictureHEVC::last_size
size_t last_size
Definition: vaapi_hevc.c:43
SliceHeader::nb_refs
unsigned int nb_refs[2]
Definition: hevcdec.h:235
H265RawProfileTierLevel::general_tier_flag
uint8_t general_tier_flag
Definition: cbs_h265.h:38
AV_PROFILE_HEVC_REXT
#define AV_PROFILE_HEVC_REXT
Definition: defs.h:162
IS_IRAP
#define IS_IRAP(s)
Definition: hevcdec.h:79
SliceHeader::colour_plane_id
uint8_t colour_plane_id
Definition: hevcdec.h:219
ff_vaapi_parse_hevc_rext_scc_profile
VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
Definition: vaapi_hevc.c:596
SliceHeader::dependent_slice_segment_flag
uint8_t dependent_slice_segment_flag
Definition: hevcdec.h:217
SliceHeader::slice_act_cb_qp_offset
int slice_act_cb_qp_offset
Definition: hevcdec.h:252
SliceHeader::first_slice_in_pic_flag
uint8_t first_slice_in_pic_flag
Definition: hevcdec.h:216
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
hevcdec.h
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
size
int size
Definition: twinvq_data.h:10344
SliceHeader::collocated_ref_idx
unsigned int collocated_ref_idx
Definition: hevcdec.h:245
h265_profile_level.h
vaapi_hevc.h
ff_vaapi_decode_cancel
int ff_vaapi_decode_cancel(AVCodecContext *avctx, VAAPIDecodePicture *pic)
Definition: vaapi_decode.c:247
SliceHeader::chroma_weight_l0
int16_t chroma_weight_l0[16][2]
Definition: hevcdec.h:274
VAAPIDecodePictureHEVC::last_slice_param
VASliceParameterBufferHEVC last_slice_param
Definition: vaapi_hevc.c:40
SliceHeader::chroma_log2_weight_denom
int16_t chroma_log2_weight_denom
Definition: hevcdec.h:271
AV_PIX_FMT_VAAPI
@ AV_PIX_FMT_VAAPI
Hardware acceleration through VA-API, data[3] contains a VASurfaceID.
Definition: pixfmt.h:126
ff_hevc_vaapi_hwaccel
const FFHWAccel ff_hevc_vaapi_hwaccel
Definition: vaapi_hevc.c:658
AVHWAccel::name
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:2105
SliceHeader::slice_cb_qp_offset
int slice_cb_qp_offset
Definition: hevcdec.h:248
SliceHeader
Definition: hevcdec.h:203
uninit
static void uninit(AVBSFContext *ctx)
Definition: pcm_rechunk.c:68
SliceHeader::slice_sample_adaptive_offset_flag
uint8_t slice_sample_adaptive_offset_flag[3]
Definition: hevcdec.h:237
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
HEVCFrame
Definition: hevcdec.h:357
HEVCLayerContext
Definition: hevcdec.h:449
VAAPIDecodePictureHEVC::last_buffer
const uint8_t * last_buffer
Definition: vaapi_hevc.c:42
AVCodecContext::hwaccel_flags
int hwaccel_flags
Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated decoding (if active).
Definition: avcodec.h:1516
SliceHeader::mvd_l1_zero_flag
uint8_t mvd_l1_zero_flag
Definition: hevcdec.h:238
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:228
VAAPIDecodePictureHEVC::pic_param
VAPictureParameterBufferHEVC pic_param
Definition: vaapi_hevc.c:39
SliceHeader::data_offset
unsigned data_offset
Definition: hevcdec.h:285
copy_field
#define copy_field(name)
SliceHeader::chroma_offset_l0
int16_t chroma_offset_l0[16][2]
Definition: hevcdec.h:279
profile
int profile
Definition: mxfenc.c:2233
fill_vaapi_reference_frames
static void fill_vaapi_reference_frames(const HEVCContext *h, const HEVCLayerContext *l, VAPictureParameterBufferHEVC *pp)
Definition: vaapi_hevc.c:99
H265RawProfileTierLevel
Definition: cbs_h265.h:36
HEVCFrame::poc
int poc
Definition: hevcdec.h:370
AV_FRAME_FLAG_INTERLACED
#define AV_FRAME_FLAG_INTERLACED
A flag to mark frames whose content is interlaced.
Definition: frame.h:648
HEVCFrame::f
AVFrame * f
Definition: hevcdec.h:360
H265RawProfileTierLevel::general_profile_space
uint8_t general_profile_space
Definition: cbs_h265.h:37
avcodec.h
SliceHeader::cu_chroma_qp_offset_enabled_flag
uint8_t cu_chroma_qp_offset_enabled_flag
Definition: hevcdec.h:255
H265RawProfileTierLevel::general_profile_compatibility_flag
uint8_t general_profile_compatibility_flag[32]
Definition: cbs_h265.h:41
ret
ret
Definition: filter_design.txt:187
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
ST_CURR_BEF
@ ST_CURR_BEF
Definition: hevcdec.h:82
SliceHeader::disable_deblocking_filter_flag
uint8_t disable_deblocking_filter_flag
slice_header_disable_deblocking_filter_flag
Definition: hevcdec.h:241
sps
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
Definition: cbs_h264_syntax_template.c:260
SliceHeader::max_num_merge_cand
uint8_t max_num_merge_cand
5 - 5_minus_max_num_merge_cand
Definition: hevcdec.h:260
SliceHeader::luma_weight_l0
int16_t luma_weight_l0[16]
Definition: hevcdec.h:273
SliceHeader::slice_type
enum HEVCSliceType slice_type
Definition: hevcdec.h:211
LT_CURR
@ LT_CURR
Definition: hevcdec.h:85
AVCodecContext
main external API structure.
Definition: avcodec.h:451
buffer
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
Definition: filter_design.txt:49
fill_pred_weight_table
static void fill_pred_weight_table(AVCodecContext *avctx, const HEVCContext *h, const SliceHeader *sh, VASliceParameterBufferHEVC *slice_param)
Definition: vaapi_hevc.c:376
SliceHeader::slice_cr_qp_offset
int slice_cr_qp_offset
Definition: hevcdec.h:249
ff_vaapi_decode_make_slice_buffer
int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, VAAPIDecodePicture *pic, const void *params_data, int nb_params, size_t params_size, const void *slice_data, size_t slice_size)
Definition: vaapi_decode.c:75
HEVCContext
Definition: hevcdec.h:487
AVCodecContext::profile
int profile
profile
Definition: avcodec.h:1650
HEVCLayerContext::DPB
HEVCFrame DPB[32]
Definition: hevcdec.h:450
pps
uint64_t pps
Definition: dovi_rpuenc.c:35
scaling_list
static int FUNC() scaling_list(CodedBitstreamContext *ctx, RWContext *rw, H264RawScalingList *current, int size_of_scaling_list)
Definition: cbs_h264_syntax_template.c:71
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
HEVCSPS
Definition: ps.h:252
HEVCPPS
Definition: ps.h:371
ST_CURR_AFT
@ ST_CURR_AFT
Definition: hevcdec.h:83
SliceHeader::tc_offset
int tc_offset
tc_offset_div2 * 2
Definition: hevcdec.h:258
AVCodecContext::priv_data
void * priv_data
Definition: avcodec.h:478
VAAPIDecodePictureHEVC::pic
VAAPIDecodePicture pic
Definition: vaapi_hevc.c:45
SliceHeader::luma_weight_l1
int16_t luma_weight_l1[16]
Definition: hevcdec.h:276
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
h
h
Definition: vp9dsp_template.c:2070
SliceHeader::slice_qp_delta
int slice_qp_delta
Definition: hevcdec.h:247
SliceHeader::use_integer_mv_flag
uint8_t use_integer_mv_flag
Definition: hevcdec.h:261
HEVC_SLICE_P
@ HEVC_SLICE_P
Definition: hevc.h:97