FFmpeg  4.4.9
dxva2_hevc.c
Go to the documentation of this file.
1 /*
2  * DXVA2 HEVC HW acceleration.
3  *
4  * copyright (c) 2014 - 2015 Hendrik Leppkes
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 "libavutil/avassert.h"
24 
25 #include "dxva2_internal.h"
26 #include "hevc_data.h"
27 #include "hevcdec.h"
28 
29 #define MAX_SLICES 256
30 
32  DXVA_PicParams_HEVC pp;
33  DXVA_Qmatrix_HEVC qm;
34  unsigned slice_count;
35  DXVA_Slice_HEVC_Short slice_short[MAX_SLICES];
37  unsigned bitstream_size;
38 };
39 
40 static void fill_picture_entry(DXVA_PicEntry_HEVC *pic,
41  unsigned index, unsigned flag)
42 {
43  av_assert0((index & 0x7f) == index && (flag & 0x01) == flag);
44  pic->bPicEntry = index | (flag << 7);
45 }
46 
47 static int get_refpic_index(const DXVA_PicParams_HEVC *pp, int surface_index)
48 {
49  int i;
50  for (i = 0; i < FF_ARRAY_ELEMS(pp->RefPicList); i++) {
51  if ((pp->RefPicList[i].bPicEntry & 0x7f) == surface_index)
52  return i;
53  }
54  return 0xff;
55 }
56 
58  DXVA_PicParams_HEVC *pp)
59 {
60  const HEVCFrame *current_picture = h->ref;
61  const HEVCSPS *sps = h->ps.sps;
62  const HEVCPPS *pps = h->ps.pps;
63  int i, j;
64 
65  memset(pp, 0, sizeof(*pp));
66 
67  pp->PicWidthInMinCbsY = sps->min_cb_width;
68  pp->PicHeightInMinCbsY = sps->min_cb_height;
69 
70  pp->wFormatAndSequenceInfoFlags = (sps->chroma_format_idc << 0) |
71  (sps->separate_colour_plane_flag << 2) |
72  ((sps->bit_depth - 8) << 3) |
73  ((sps->bit_depth - 8) << 6) |
74  ((sps->log2_max_poc_lsb - 4) << 9) |
75  (0 << 13) |
76  (0 << 14) |
77  (0 << 15);
78 
79  fill_picture_entry(&pp->CurrPic, ff_dxva2_get_surface_index(avctx, ctx, current_picture->frame), 0);
80 
81  pp->sps_max_dec_pic_buffering_minus1 = sps->temporal_layer[sps->max_sub_layers - 1].max_dec_pic_buffering - 1;
82  pp->log2_min_luma_coding_block_size_minus3 = sps->log2_min_cb_size - 3;
83  pp->log2_diff_max_min_luma_coding_block_size = sps->log2_diff_max_min_coding_block_size;
84  pp->log2_min_transform_block_size_minus2 = sps->log2_min_tb_size - 2;
85  pp->log2_diff_max_min_transform_block_size = sps->log2_max_trafo_size - sps->log2_min_tb_size;
86  pp->max_transform_hierarchy_depth_inter = sps->max_transform_hierarchy_depth_inter;
87  pp->max_transform_hierarchy_depth_intra = sps->max_transform_hierarchy_depth_intra;
88  pp->num_short_term_ref_pic_sets = sps->nb_st_rps;
89  pp->num_long_term_ref_pics_sps = sps->num_long_term_ref_pics_sps;
90 
91  pp->num_ref_idx_l0_default_active_minus1 = pps->num_ref_idx_l0_default_active - 1;
92  pp->num_ref_idx_l1_default_active_minus1 = pps->num_ref_idx_l1_default_active - 1;
93  pp->init_qp_minus26 = pps->pic_init_qp_minus26;
94 
95  if (h->sh.short_term_ref_pic_set_sps_flag == 0 && h->sh.short_term_rps) {
96  pp->ucNumDeltaPocsOfRefRpsIdx = h->sh.short_term_rps->rps_idx_num_delta_pocs;
97  pp->wNumBitsForShortTermRPSInSlice = h->sh.short_term_ref_pic_set_size;
98  }
99 
100  pp->dwCodingParamToolFlags = (sps->scaling_list_enable_flag << 0) |
101  (sps->amp_enabled_flag << 1) |
102  (sps->sao_enabled << 2) |
103  (sps->pcm_enabled_flag << 3) |
104  ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth - 1) : 0) << 4) |
105  ((sps->pcm_enabled_flag ? (sps->pcm.bit_depth_chroma - 1) : 0) << 8) |
106  ((sps->pcm_enabled_flag ? (sps->pcm.log2_min_pcm_cb_size - 3) : 0) << 12) |
107  ((sps->pcm_enabled_flag ? (sps->pcm.log2_max_pcm_cb_size - sps->pcm.log2_min_pcm_cb_size) : 0) << 14) |
108  (sps->pcm.loop_filter_disable_flag << 16) |
109  (sps->long_term_ref_pics_present_flag << 17) |
110  (sps->sps_temporal_mvp_enabled_flag << 18) |
111  (sps->sps_strong_intra_smoothing_enable_flag << 19) |
112  (pps->dependent_slice_segments_enabled_flag << 20) |
113  (pps->output_flag_present_flag << 21) |
114  (pps->num_extra_slice_header_bits << 22) |
115  (pps->sign_data_hiding_flag << 25) |
116  (pps->cabac_init_present_flag << 26) |
117  (0 << 27);
118 
119  pp->dwCodingSettingPicturePropertyFlags = (pps->constrained_intra_pred_flag << 0) |
120  (pps->transform_skip_enabled_flag << 1) |
121  (pps->cu_qp_delta_enabled_flag << 2) |
122  (pps->pic_slice_level_chroma_qp_offsets_present_flag << 3) |
123  (pps->weighted_pred_flag << 4) |
124  (pps->weighted_bipred_flag << 5) |
125  (pps->transquant_bypass_enable_flag << 6) |
126  (pps->tiles_enabled_flag << 7) |
127  (pps->entropy_coding_sync_enabled_flag << 8) |
128  (pps->uniform_spacing_flag << 9) |
129  ((pps->tiles_enabled_flag ? pps->loop_filter_across_tiles_enabled_flag : 0) << 10) |
130  (pps->seq_loop_filter_across_slices_enabled_flag << 11) |
131  (pps->deblocking_filter_override_enabled_flag << 12) |
132  (pps->disable_dbf << 13) |
133  (pps->lists_modification_present_flag << 14) |
134  (pps->slice_header_extension_present_flag << 15) |
135  (IS_IRAP(h) << 16) |
136  (IS_IDR(h) << 17) |
137  /* IntraPicFlag */
138  (IS_IRAP(h) << 18) |
139  (0 << 19);
140  pp->pps_cb_qp_offset = pps->cb_qp_offset;
141  pp->pps_cr_qp_offset = pps->cr_qp_offset;
142  if (pps->tiles_enabled_flag) {
143  if (pps->num_tile_columns > FF_ARRAY_ELEMS(pp->column_width_minus1) + 1 ||
144  pps->num_tile_rows > FF_ARRAY_ELEMS(pp->row_height_minus1) + 1) {
145  av_log((void *)avctx, AV_LOG_ERROR, "Too many tiles\n");
146  return AVERROR(ENOSYS);
147  }
148  pp->num_tile_columns_minus1 = pps->num_tile_columns - 1;
149  pp->num_tile_rows_minus1 = pps->num_tile_rows - 1;
150 
151  if (!pps->uniform_spacing_flag) {
152  for (i = 0; i < FFMIN(pps->num_tile_columns, FF_ARRAY_ELEMS(pp->column_width_minus1)); i++)
153  pp->column_width_minus1[i] = pps->column_width[i] - 1;
154 
155  for (i = 0; i < FFMIN(pps->num_tile_rows, FF_ARRAY_ELEMS(pp->row_height_minus1)); i++)
156  pp->row_height_minus1[i] = pps->row_height[i] - 1;
157  }
158  }
159 
160  pp->diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth;
161  pp->pps_beta_offset_div2 = pps->beta_offset / 2;
162  pp->pps_tc_offset_div2 = pps->tc_offset / 2;
163  pp->log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2;
164  pp->CurrPicOrderCntVal = h->poc;
165 
166  // fill RefPicList from the DPB
167  for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->RefPicList); i++) {
168  const HEVCFrame *frame = NULL;
169  while (!frame && j < FF_ARRAY_ELEMS(h->DPB)) {
170  if (&h->DPB[j] != current_picture && (h->DPB[j].flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF)))
171  frame = &h->DPB[j];
172  j++;
173  }
174 
175  if (frame) {
176  fill_picture_entry(&pp->RefPicList[i], ff_dxva2_get_surface_index(avctx, ctx, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));
177  pp->PicOrderCntValList[i] = frame->poc;
178  } else {
179  pp->RefPicList[i].bPicEntry = 0xff;
180  pp->PicOrderCntValList[i] = 0;
181  }
182  }
183 
184  #define DO_REF_LIST(ref_idx, ref_list) { \
185  const RefPicList *rpl = &h->rps[ref_idx]; \
186  for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->ref_list); i++) { \
187  const HEVCFrame *frame = NULL; \
188  while (!frame && j < rpl->nb_refs) \
189  frame = rpl->ref[j++]; \
190  if (frame) \
191  pp->ref_list[i] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, frame->frame)); \
192  else \
193  pp->ref_list[i] = 0xff; \
194  } \
195  }
196 
197  // Fill short term and long term lists
198  DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore);
199  DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter);
200  DO_REF_LIST(LT_CURR, RefPicSetLtCurr);
201 
202  pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;
203 
204  return 0;
205 }
206 
207 static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm)
208 {
209  unsigned i, j, pos;
210  const ScalingList *sl = h->ps.pps->scaling_list_data_present_flag ?
211  &h->ps.pps->scaling_list : &h->ps.sps->scaling_list;
212 
213  memset(qm, 0, sizeof(*qm));
214  for (i = 0; i < 6; i++) {
215  for (j = 0; j < 16; j++) {
217  qm->ucScalingLists0[i][j] = sl->sl[0][i][pos];
218  }
219 
220  for (j = 0; j < 64; j++) {
222  qm->ucScalingLists1[i][j] = sl->sl[1][i][pos];
223  qm->ucScalingLists2[i][j] = sl->sl[2][i][pos];
224 
225  if (i < 2)
226  qm->ucScalingLists3[i][j] = sl->sl[3][i * 3][pos];
227  }
228 
229  qm->ucScalingListDCCoefSizeID2[i] = sl->sl_dc[0][i];
230  if (i < 2)
231  qm->ucScalingListDCCoefSizeID3[i] = sl->sl_dc[1][i * 3];
232  }
233 }
234 
235 static void fill_slice_short(DXVA_Slice_HEVC_Short *slice,
236  unsigned position, unsigned size)
237 {
238  memset(slice, 0, sizeof(*slice));
239  slice->BSNALunitDataLocation = position;
240  slice->SliceBytesInBuffer = size;
241  slice->wBadSliceChopping = 0;
242 }
243 
247 {
248  const HEVCContext *h = avctx->priv_data;
249  AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
250  const HEVCFrame *current_picture = h->ref;
251  struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
252  DXVA_Slice_HEVC_Short *slice = NULL;
253  void *dxva_data_ptr = NULL;
254  uint8_t *dxva_data, *current, *end;
255  unsigned dxva_size;
256  void *slice_data;
257  unsigned slice_size;
258  unsigned padding;
259  unsigned i;
260  unsigned type;
261 
262  /* Create an annex B bitstream buffer with only slice NAL and finalize slice */
263 #if CONFIG_D3D11VA
264  if (ff_dxva2_is_d3d11(avctx)) {
265  type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
266  if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
268  type,
269  &dxva_size, &dxva_data_ptr)))
270  return -1;
271  }
272 #endif
273 #if CONFIG_DXVA2
274  if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
275  type = DXVA2_BitStreamDateBufferType;
276  if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
277  type,
278  &dxva_data_ptr, &dxva_size)))
279  return -1;
280  }
281 #endif
282 
283  if (!dxva_data_ptr)
284  return -1;
285 
286  dxva_data = dxva_data_ptr;
287  current = dxva_data;
288  end = dxva_data + dxva_size;
289 
290  for (i = 0; i < ctx_pic->slice_count; i++) {
291  static const uint8_t start_code[] = { 0, 0, 1 };
292  static const unsigned start_code_size = sizeof(start_code);
293  unsigned position, size;
294 
295  slice = &ctx_pic->slice_short[i];
296 
297  position = slice->BSNALunitDataLocation;
298  size = slice->SliceBytesInBuffer;
299  if (start_code_size + size > end - current) {
300  av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
301  break;
302  }
303 
304  slice->BSNALunitDataLocation = current - dxva_data;
305  slice->SliceBytesInBuffer = start_code_size + size;
306 
307  memcpy(current, start_code, start_code_size);
308  current += start_code_size;
309 
310  memcpy(current, &ctx_pic->bitstream[position], size);
311  current += size;
312  }
313  padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
314  if (slice && padding > 0) {
315  memset(current, 0, padding);
316  current += padding;
317 
318  slice->SliceBytesInBuffer += padding;
319  }
320 #if CONFIG_D3D11VA
321  if (ff_dxva2_is_d3d11(avctx))
322  if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type)))
323  return -1;
324 #endif
325 #if CONFIG_DXVA2
326  if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
327  if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type)))
328  return -1;
329 #endif
330  if (i < ctx_pic->slice_count)
331  return -1;
332 
333 #if CONFIG_D3D11VA
334  if (ff_dxva2_is_d3d11(avctx)) {
335  D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
336  memset(dsc11, 0, sizeof(*dsc11));
337  dsc11->BufferType = type;
338  dsc11->DataSize = current - dxva_data;
339  dsc11->NumMBsInBuffer = 0;
340 
341  type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
342  }
343 #endif
344 #if CONFIG_DXVA2
345  if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
346  DXVA2_DecodeBufferDesc *dsc2 = bs;
347  memset(dsc2, 0, sizeof(*dsc2));
348  dsc2->CompressedBufferType = type;
349  dsc2->DataSize = current - dxva_data;
350  dsc2->NumMBsInBuffer = 0;
351 
352  type = DXVA2_SliceControlBufferType;
353  }
354 #endif
355 
356  slice_data = ctx_pic->slice_short;
357  slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_short);
358 
359  av_assert0(((current - dxva_data) & 127) == 0);
360  return ff_dxva2_commit_buffer(avctx, ctx, sc,
361  type,
362  slice_data, slice_size, 0);
363 }
364 
365 
367  av_unused const uint8_t *buffer,
368  av_unused uint32_t size)
369 {
370  const HEVCContext *h = avctx->priv_data;
371  AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
372  struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
373 
374  if (!DXVA_CONTEXT_VALID(avctx, ctx))
375  return -1;
376  av_assert0(ctx_pic);
377 
378  /* Fill up DXVA_PicParams_HEVC */
379  if (fill_picture_parameters(avctx, ctx, h, &ctx_pic->pp) < 0)
380  return -1;
381 
382  /* Fill up DXVA_Qmatrix_HEVC */
383  fill_scaling_lists(ctx, h, &ctx_pic->qm);
384 
385  ctx_pic->slice_count = 0;
386  ctx_pic->bitstream_size = 0;
387  ctx_pic->bitstream = NULL;
388  return 0;
389 }
390 
392  const uint8_t *buffer,
393  uint32_t size)
394 {
395  const HEVCContext *h = avctx->priv_data;
396  const HEVCFrame *current_picture = h->ref;
397  struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
398  unsigned position;
399 
400  if (ctx_pic->slice_count >= MAX_SLICES)
401  return -1;
402 
403  if (!ctx_pic->bitstream)
404  ctx_pic->bitstream = buffer;
405  ctx_pic->bitstream_size += size;
406 
407  position = buffer - ctx_pic->bitstream;
408  fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count], position, size);
409  ctx_pic->slice_count++;
410 
411  return 0;
412 }
413 
415 {
416  HEVCContext *h = avctx->priv_data;
417  struct hevc_dxva2_picture_context *ctx_pic = h->ref->hwaccel_picture_private;
418  int scale = ctx_pic->pp.dwCodingParamToolFlags & 1;
419  int ret;
420 
421  if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
422  return -1;
423 
424  ret = ff_dxva2_common_end_frame(avctx, h->ref->frame,
425  &ctx_pic->pp, sizeof(ctx_pic->pp),
426  scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0,
428  return ret;
429 }
430 
431 #if CONFIG_HEVC_DXVA2_HWACCEL
433  .name = "hevc_dxva2",
434  .type = AVMEDIA_TYPE_VIDEO,
435  .id = AV_CODEC_ID_HEVC,
436  .pix_fmt = AV_PIX_FMT_DXVA2_VLD,
437  .init = ff_dxva2_decode_init,
438  .uninit = ff_dxva2_decode_uninit,
439  .start_frame = dxva2_hevc_start_frame,
440  .decode_slice = dxva2_hevc_decode_slice,
441  .end_frame = dxva2_hevc_end_frame,
442  .frame_params = ff_dxva2_common_frame_params,
443  .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
444  .priv_data_size = sizeof(FFDXVASharedContext),
445 };
446 #endif
447 
448 #if CONFIG_HEVC_D3D11VA_HWACCEL
450  .name = "hevc_d3d11va",
451  .type = AVMEDIA_TYPE_VIDEO,
452  .id = AV_CODEC_ID_HEVC,
453  .pix_fmt = AV_PIX_FMT_D3D11VA_VLD,
454  .init = ff_dxva2_decode_init,
455  .uninit = ff_dxva2_decode_uninit,
456  .start_frame = dxva2_hevc_start_frame,
457  .decode_slice = dxva2_hevc_decode_slice,
458  .end_frame = dxva2_hevc_end_frame,
459  .frame_params = ff_dxva2_common_frame_params,
460  .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
461  .priv_data_size = sizeof(FFDXVASharedContext),
462 };
463 #endif
464 
465 #if CONFIG_HEVC_D3D11VA2_HWACCEL
467  .name = "hevc_d3d11va2",
468  .type = AVMEDIA_TYPE_VIDEO,
469  .id = AV_CODEC_ID_HEVC,
470  .pix_fmt = AV_PIX_FMT_D3D11,
471  .init = ff_dxva2_decode_init,
472  .uninit = ff_dxva2_decode_uninit,
473  .start_frame = dxva2_hevc_start_frame,
474  .decode_slice = dxva2_hevc_decode_slice,
475  .end_frame = dxva2_hevc_end_frame,
476  .frame_params = ff_dxva2_common_frame_params,
477  .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
478  .priv_data_size = sizeof(FFDXVASharedContext),
479 };
480 #endif
#define av_unused
Definition: attributes.h:131
uint8_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
#define flag(name)
Definition: cbs_av1.c:564
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
#define FFMIN(a, b)
Definition: common.h:105
#define NULL
Definition: coverity.c:32
static AVFrame * frame
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
Definition: dxva2.c:1063
int ff_dxva2_decode_init(AVCodecContext *avctx)
Definition: dxva2.c:660
int ff_dxva2_commit_buffer(AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
Definition: dxva2.c:809
int ff_dxva2_decode_uninit(AVCodecContext *avctx)
Definition: dxva2.c:742
int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*commit_bs_si)(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice))
Definition: dxva2.c:898
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition: dxva2.c:592
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame)
Definition: dxva2.c:782
static int dxva2_hevc_end_frame(AVCodecContext *avctx)
Definition: dxva2_hevc.c:414
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
Definition: dxva2_hevc.c:244
static int get_refpic_index(const DXVA_PicParams_HEVC *pp, int surface_index)
Definition: dxva2_hevc.c:47
static void fill_picture_entry(DXVA_PicEntry_HEVC *pic, unsigned index, unsigned flag)
Definition: dxva2_hevc.c:40
static int fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const HEVCContext *h, DXVA_PicParams_HEVC *pp)
Definition: dxva2_hevc.c:57
#define DO_REF_LIST(ref_idx, ref_list)
static int dxva2_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition: dxva2_hevc.c:391
static int dxva2_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: dxva2_hevc.c:366
static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, unsigned size)
Definition: dxva2_hevc.c:235
static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm)
Definition: dxva2_hevc.c:207
#define MAX_SLICES
Definition: dxva2_hevc.c:29
#define DXVA_CONTEXT(avctx)
#define DXVA2_CONTEXT(ctx)
#define D3D11VA_CONTEXT(ctx)
void DECODER_BUFFER_DESC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:223
#define AVERROR(e)
Definition: error.h:43
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:194
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
int index
Definition: gxfenc.c:89
for(j=16;j >0;--j)
const uint8_t ff_hevc_diag_scan8x8_x[64]
Definition: hevc_data.c:39
const uint8_t ff_hevc_diag_scan4x4_x[16]
Definition: hevc_data.c:25
const uint8_t ff_hevc_diag_scan8x8_y[64]
Definition: hevc_data.c:58
const uint8_t ff_hevc_diag_scan4x4_y[16]
Definition: hevc_data.c:32
#define HEVC_FRAME_FLAG_SHORT_REF
Definition: hevcdec.h:392
#define IS_IDR(s)
Definition: hevcdec.h:78
#define HEVC_FRAME_FLAG_LONG_REF
Definition: hevcdec.h:393
#define IS_IRAP(s)
Definition: hevcdec.h:81
@ ST_CURR_AFT
Definition: hevcdec.h:85
@ ST_CURR_BEF
Definition: hevcdec.h:84
@ LT_CURR
Definition: hevcdec.h:87
const AVHWAccel ff_hevc_d3d11va2_hwaccel
const AVHWAccel ff_hevc_d3d11va_hwaccel
const AVHWAccel ff_hevc_dxva2_hwaccel
cl_device_type type
int i
Definition: input.c:407
static const chunk_decoder decoder[8]
Definition: dfa.c:330
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
Definition: pixfmt.h:137
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
Definition: pixfmt.h:313
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
Definition: pixfmt.h:229
static char buffer[20]
Definition: seek.c:32
#define FF_ARRAY_ELEMS(a)
unsigned int pos
Definition: spdifenc.c:412
main external API structure.
Definition: avcodec.h:536
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:746
void * priv_data
Definition: avcodec.h:563
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
Definition: frame.h:555
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:2448
void * hwaccel_picture_private
Definition: hevcdec.h:411
AVFrame * frame
Definition: hevcdec.h:397
uint8_t sl_dc[2][6]
Definition: hevc_ps.h:150
uint8_t sl[4][6][64]
Definition: hevc_ps.h:149
DXVA_Qmatrix_HEVC qm
Definition: dxva2_hevc.c:33
DXVA_PicParams_HEVC pp
Definition: dxva2_hevc.c:32
const uint8_t * bitstream
Definition: dxva2_hevc.c:36
DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]
Definition: dxva2_hevc.c:35
#define av_log(a,...)
AVFormatContext * ctx
Definition: movenc.c:48
int size
static const uint8_t start_code[]