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