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 "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 
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) |
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) |
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) |
128  (pps->uniform_spacing_flag << 9) |
132  (pps->disable_dbf << 13) |
133  (pps->lists_modification_present_flag << 14) |
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  pp->num_tile_columns_minus1 = pps->num_tile_columns - 1;
144  pp->num_tile_rows_minus1 = pps->num_tile_rows - 1;
145 
146  if (!pps->uniform_spacing_flag) {
147  for (i = 0; i < pps->num_tile_columns; i++)
148  pp->column_width_minus1[i] = pps->column_width[i] - 1;
149 
150  for (i = 0; i < pps->num_tile_rows; i++)
151  pp->row_height_minus1[i] = pps->row_height[i] - 1;
152  }
153  }
154 
155  pp->diff_cu_qp_delta_depth = pps->diff_cu_qp_delta_depth;
156  pp->pps_beta_offset_div2 = pps->beta_offset / 2;
157  pp->pps_tc_offset_div2 = pps->tc_offset / 2;
158  pp->log2_parallel_merge_level_minus2 = pps->log2_parallel_merge_level - 2;
159  pp->CurrPicOrderCntVal = h->poc;
160 
161  // fill RefPicList from the DPB
162  for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->RefPicList); i++) {
163  const HEVCFrame *frame = NULL;
164  while (!frame && j < FF_ARRAY_ELEMS(h->DPB)) {
165  if (&h->DPB[j] != current_picture && (h->DPB[j].flags & (HEVC_FRAME_FLAG_LONG_REF | HEVC_FRAME_FLAG_SHORT_REF)))
166  frame = &h->DPB[j];
167  j++;
168  }
169 
170  if (frame) {
171  fill_picture_entry(&pp->RefPicList[i], ff_dxva2_get_surface_index(avctx, ctx, frame->frame), !!(frame->flags & HEVC_FRAME_FLAG_LONG_REF));
172  pp->PicOrderCntValList[i] = frame->poc;
173  } else {
174  pp->RefPicList[i].bPicEntry = 0xff;
175  pp->PicOrderCntValList[i] = 0;
176  }
177  }
178 
179  #define DO_REF_LIST(ref_idx, ref_list) { \
180  const RefPicList *rpl = &h->rps[ref_idx]; \
181  for (i = 0, j = 0; i < FF_ARRAY_ELEMS(pp->ref_list); i++) { \
182  const HEVCFrame *frame = NULL; \
183  while (!frame && j < rpl->nb_refs) \
184  frame = rpl->ref[j++]; \
185  if (frame) \
186  pp->ref_list[i] = get_refpic_index(pp, ff_dxva2_get_surface_index(avctx, ctx, frame->frame)); \
187  else \
188  pp->ref_list[i] = 0xff; \
189  } \
190  }
191 
192  // Fill short term and long term lists
193  DO_REF_LIST(ST_CURR_BEF, RefPicSetStCurrBefore);
194  DO_REF_LIST(ST_CURR_AFT, RefPicSetStCurrAfter);
195  DO_REF_LIST(LT_CURR, RefPicSetLtCurr);
196 
197  pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;
198 }
199 
200 static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm)
201 {
202  unsigned i, j, pos;
204  &h->ps.pps->scaling_list : &h->ps.sps->scaling_list;
205 
206  memset(qm, 0, sizeof(*qm));
207  for (i = 0; i < 6; i++) {
208  for (j = 0; j < 16; j++) {
210  qm->ucScalingLists0[i][j] = sl->sl[0][i][pos];
211  }
212 
213  for (j = 0; j < 64; j++) {
215  qm->ucScalingLists1[i][j] = sl->sl[1][i][pos];
216  qm->ucScalingLists2[i][j] = sl->sl[2][i][pos];
217 
218  if (i < 2)
219  qm->ucScalingLists3[i][j] = sl->sl[3][i * 3][pos];
220  }
221 
222  qm->ucScalingListDCCoefSizeID2[i] = sl->sl_dc[0][i];
223  if (i < 2)
224  qm->ucScalingListDCCoefSizeID3[i] = sl->sl_dc[1][i * 3];
225  }
226 }
227 
228 static void fill_slice_short(DXVA_Slice_HEVC_Short *slice,
229  unsigned position, unsigned size)
230 {
231  memset(slice, 0, sizeof(*slice));
232  slice->BSNALunitDataLocation = position;
233  slice->SliceBytesInBuffer = size;
234  slice->wBadSliceChopping = 0;
235 }
236 
240 {
241  const HEVCContext *h = avctx->priv_data;
242  AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
243  const HEVCFrame *current_picture = h->ref;
244  struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
245  DXVA_Slice_HEVC_Short *slice = NULL;
246  void *dxva_data_ptr;
247  uint8_t *dxva_data, *current, *end;
248  unsigned dxva_size;
249  void *slice_data;
250  unsigned slice_size;
251  unsigned padding;
252  unsigned i;
253  unsigned type;
254 
255  /* Create an annex B bitstream buffer with only slice NAL and finalize slice */
256 #if CONFIG_D3D11VA
257  if (ff_dxva2_is_d3d11(avctx)) {
258  type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
259  if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
260  D3D11VA_CONTEXT(ctx)->decoder,
261  type,
262  &dxva_size, &dxva_data_ptr)))
263  return -1;
264  }
265 #endif
266 #if CONFIG_DXVA2
267  if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
268  type = DXVA2_BitStreamDateBufferType;
269  if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
270  type,
271  &dxva_data_ptr, &dxva_size)))
272  return -1;
273  }
274 #endif
275 
276  dxva_data = dxva_data_ptr;
277  current = dxva_data;
278  end = dxva_data + dxva_size;
279 
280  for (i = 0; i < ctx_pic->slice_count; i++) {
281  static const uint8_t start_code[] = { 0, 0, 1 };
282  static const unsigned start_code_size = sizeof(start_code);
283  unsigned position, size;
284 
285  slice = &ctx_pic->slice_short[i];
286 
287  position = slice->BSNALunitDataLocation;
288  size = slice->SliceBytesInBuffer;
289  if (start_code_size + size > end - current) {
290  av_log(avctx, AV_LOG_ERROR, "Failed to build bitstream");
291  break;
292  }
293 
294  slice->BSNALunitDataLocation = current - dxva_data;
295  slice->SliceBytesInBuffer = start_code_size + size;
296 
297  memcpy(current, start_code, start_code_size);
298  current += start_code_size;
299 
300  memcpy(current, &ctx_pic->bitstream[position], size);
301  current += size;
302  }
303  padding = FFMIN(128 - ((current - dxva_data) & 127), end - current);
304  if (slice && padding > 0) {
305  memset(current, 0, padding);
306  current += padding;
307 
308  slice->SliceBytesInBuffer += padding;
309  }
310 #if CONFIG_D3D11VA
311  if (ff_dxva2_is_d3d11(avctx))
312  if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type)))
313  return -1;
314 #endif
315 #if CONFIG_DXVA2
316  if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
317  if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type)))
318  return -1;
319 #endif
320  if (i < ctx_pic->slice_count)
321  return -1;
322 
323 #if CONFIG_D3D11VA
324  if (ff_dxva2_is_d3d11(avctx)) {
325  D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
326  memset(dsc11, 0, sizeof(*dsc11));
327  dsc11->BufferType = type;
328  dsc11->DataSize = current - dxva_data;
329  dsc11->NumMBsInBuffer = 0;
330 
331  type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
332  }
333 #endif
334 #if CONFIG_DXVA2
335  if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
336  DXVA2_DecodeBufferDesc *dsc2 = bs;
337  memset(dsc2, 0, sizeof(*dsc2));
338  dsc2->CompressedBufferType = type;
339  dsc2->DataSize = current - dxva_data;
340  dsc2->NumMBsInBuffer = 0;
341 
342  type = DXVA2_SliceControlBufferType;
343  }
344 #endif
345 
346  slice_data = ctx_pic->slice_short;
347  slice_size = ctx_pic->slice_count * sizeof(*ctx_pic->slice_short);
348 
349  av_assert0(((current - dxva_data) & 127) == 0);
350  return ff_dxva2_commit_buffer(avctx, ctx, sc,
351  type,
352  slice_data, slice_size, 0);
353 }
354 
355 
357  av_unused const uint8_t *buffer,
358  av_unused uint32_t size)
359 {
360  const HEVCContext *h = avctx->priv_data;
361  AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
363 
364  if (!DXVA_CONTEXT_VALID(avctx, ctx))
365  return -1;
366  av_assert0(ctx_pic);
367 
368  /* Fill up DXVA_PicParams_HEVC */
369  fill_picture_parameters(avctx, ctx, h, &ctx_pic->pp);
370 
371  /* Fill up DXVA_Qmatrix_HEVC */
372  fill_scaling_lists(ctx, h, &ctx_pic->qm);
373 
374  ctx_pic->slice_count = 0;
375  ctx_pic->bitstream_size = 0;
376  ctx_pic->bitstream = NULL;
377  return 0;
378 }
379 
381  const uint8_t *buffer,
382  uint32_t size)
383 {
384  const HEVCContext *h = avctx->priv_data;
385  const HEVCFrame *current_picture = h->ref;
386  struct hevc_dxva2_picture_context *ctx_pic = current_picture->hwaccel_picture_private;
387  unsigned position;
388 
389  if (ctx_pic->slice_count >= MAX_SLICES)
390  return -1;
391 
392  if (!ctx_pic->bitstream)
393  ctx_pic->bitstream = buffer;
394  ctx_pic->bitstream_size += size;
395 
396  position = buffer - ctx_pic->bitstream;
397  fill_slice_short(&ctx_pic->slice_short[ctx_pic->slice_count], position, size);
398  ctx_pic->slice_count++;
399 
400  return 0;
401 }
402 
404 {
405  HEVCContext *h = avctx->priv_data;
407  int scale = ctx_pic->pp.dwCodingParamToolFlags & 1;
408  int ret;
409 
410  if (ctx_pic->slice_count <= 0 || ctx_pic->bitstream_size <= 0)
411  return -1;
412 
413  ret = ff_dxva2_common_end_frame(avctx, h->ref->frame,
414  &ctx_pic->pp, sizeof(ctx_pic->pp),
415  scale ? &ctx_pic->qm : NULL, scale ? sizeof(ctx_pic->qm) : 0,
417  return ret;
418 }
419 
420 #if CONFIG_HEVC_DXVA2_HWACCEL
422  .name = "hevc_dxva2",
423  .type = AVMEDIA_TYPE_VIDEO,
424  .id = AV_CODEC_ID_HEVC,
425  .pix_fmt = AV_PIX_FMT_DXVA2_VLD,
426  .init = ff_dxva2_decode_init,
427  .uninit = ff_dxva2_decode_uninit,
428  .start_frame = dxva2_hevc_start_frame,
429  .decode_slice = dxva2_hevc_decode_slice,
430  .end_frame = dxva2_hevc_end_frame,
431  .frame_params = ff_dxva2_common_frame_params,
432  .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
433  .priv_data_size = sizeof(FFDXVASharedContext),
434 };
435 #endif
436 
437 #if CONFIG_HEVC_D3D11VA_HWACCEL
439  .name = "hevc_d3d11va",
440  .type = AVMEDIA_TYPE_VIDEO,
441  .id = AV_CODEC_ID_HEVC,
442  .pix_fmt = AV_PIX_FMT_D3D11VA_VLD,
443  .init = ff_dxva2_decode_init,
444  .uninit = ff_dxva2_decode_uninit,
445  .start_frame = dxva2_hevc_start_frame,
446  .decode_slice = dxva2_hevc_decode_slice,
447  .end_frame = dxva2_hevc_end_frame,
448  .frame_params = ff_dxva2_common_frame_params,
449  .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
450  .priv_data_size = sizeof(FFDXVASharedContext),
451 };
452 #endif
453 
454 #if CONFIG_HEVC_D3D11VA2_HWACCEL
456  .name = "hevc_d3d11va2",
457  .type = AVMEDIA_TYPE_VIDEO,
458  .id = AV_CODEC_ID_HEVC,
459  .pix_fmt = AV_PIX_FMT_D3D11,
460  .init = ff_dxva2_decode_init,
461  .uninit = ff_dxva2_decode_uninit,
462  .start_frame = dxva2_hevc_start_frame,
463  .decode_slice = dxva2_hevc_decode_slice,
464  .end_frame = dxva2_hevc_end_frame,
465  .frame_params = ff_dxva2_common_frame_params,
466  .frame_priv_data_size = sizeof(struct hevc_dxva2_picture_context),
467  .priv_data_size = sizeof(FFDXVASharedContext),
468 };
469 #endif
const HEVCPPS * pps
Definition: hevc_ps.h:407
AVFrame * frame
Definition: hevcdec.h:312
#define NULL
Definition: coverity.c:32
unsigned int log2_min_cb_size
Definition: hevc_ps.h:277
int short_term_ref_pic_set_sps_flag
Definition: hevc_ps.h:66
HEVCFrame * ref
Definition: hevcdec.h:423
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
Definition: dxva2_hevc.c:237
int max_dec_pic_buffering
Definition: hevc_ps.h:244
const uint8_t * bitstream
Definition: dxva2_hevc.c:36
unsigned int * row_height
RowHeight.
Definition: hevc_ps.h:383
void * hwaccel_picture_private
Definition: hevcdec.h:326
int pic_init_qp_minus26
Definition: hevc_ps.h:330
uint8_t weighted_bipred_flag
Definition: hevc_ps.h:342
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition: avcodec.h:1778
GLint GLenum type
Definition: opengl_enc.c:104
uint8_t seq_loop_filter_across_slices_enabled_flag
Definition: hevc_ps.h:355
uint8_t cabac_init_present_flag
Definition: hevc_ps.h:326
static void fill_slice_short(DXVA_Slice_HEVC_Short *slice, unsigned position, unsigned size)
Definition: dxva2_hevc.c:228
HEVCParamSets ps
Definition: hevcdec.h:408
int min_cb_height
Definition: hevc_ps.h:305
int num_ref_idx_l0_default_active
num_ref_idx_l0_default_active_minus1 + 1
Definition: hevc_ps.h:328
#define D3D11VA_CONTEXT(ctx)
uint8_t entropy_coding_sync_enabled_flag
Definition: hevc_ps.h:348
int log2_parallel_merge_level
log2_parallel_merge_level_minus2 + 2
Definition: hevc_ps.h:367
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
static int get_refpic_index(const DXVA_PicParams_HEVC *pp, int surface_index)
Definition: dxva2_hevc.c:47
int chroma_format_idc
Definition: hevc_ps.h:227
uint8_t disable_dbf
Definition: hevc_ps.h:359
unsigned int log2_max_trafo_size
Definition: hevc_ps.h:280
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition: dxva2.c:586
int ff_dxva2_decode_uninit(AVCodecContext *avctx)
Definition: dxva2.c:724
DXVA_Qmatrix_HEVC qm
Definition: dxva2_hevc.c:33
uint8_t
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
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:880
const uint8_t ff_hevc_diag_scan8x8_x[64]
Definition: hevc_data.c:39
int num_ref_idx_l1_default_active
num_ref_idx_l1_default_active_minus1 + 1
Definition: hevc_ps.h:329
unsigned int log2_min_pcm_cb_size
Definition: hevc_ps.h:270
int min_cb_width
Definition: hevc_ps.h:304
DXVA_Slice_HEVC_Short slice_short[MAX_SLICES]
Definition: dxva2_hevc.c:35
uint8_t scaling_list_data_present_flag
Definition: hevc_ps.h:363
uint8_t loop_filter_disable_flag
Definition: hevc_ps.h:272
ptrdiff_t size
Definition: opengl_enc.c:100
uint8_t transquant_bypass_enable_flag
Definition: hevc_ps.h:344
#define av_log(a,...)
int bit_depth_chroma
Definition: hevc_ps.h:235
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
unsigned int log2_max_poc_lsb
Definition: hevc_ps.h:239
#define HEVC_FRAME_FLAG_LONG_REF
Definition: hevcdec.h:308
uint8_t amp_enabled_flag
Definition: hevc_ps.h:259
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
Definition: dxva2.c:1045
#define DXVA2_CONTEXT(ctx)
struct HEVCSPS::@94 temporal_layer[HEVC_MAX_SUB_LAYERS]
simple assert() macros that are a bit more flexible than ISO C assert().
const ShortTermRPS * short_term_rps
Definition: hevc_ps.h:69
#define IS_IDR(s)
Definition: hevcdec.h:77
#define MAX_SLICES
Definition: dxva2_hevc.c:29
#define HEVC_FRAME_FLAG_SHORT_REF
Definition: hevcdec.h:307
static void fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const HEVCContext *h, DXVA_PicParams_HEVC *pp)
Definition: dxva2_hevc.c:57
uint8_t tiles_enabled_flag
Definition: hevc_ps.h:347
const HEVCSPS * sps
Definition: hevc_ps.h:406
uint8_t lists_modification_present_flag
Definition: hevc_ps.h:366
#define IS_IRAP(s)
Definition: hevcdec.h:80
const char * name
Name of the hardware accelerated codec.
Definition: avcodec.h:3666
int max_transform_hierarchy_depth_inter
Definition: hevc_ps.h:284
#define FFMIN(a, b)
Definition: common.h:96
static const chunk_decoder decoder[8]
Definition: dfa.c:330
AVFormatContext * ctx
Definition: movenc.c:48
uint8_t cu_qp_delta_enabled_flag
Definition: hevc_ps.h:335
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
int ff_dxva2_decode_init(AVCodecContext *avctx)
Definition: dxva2.c:649
static void fill_scaling_lists(AVDXVAContext *ctx, const HEVCContext *h, DXVA_Qmatrix_HEVC *qm)
Definition: dxva2_hevc.c:200
uint8_t sl_dc[2][6]
Definition: hevc_ps.h:222
uint8_t sign_data_hiding_flag
Definition: hevc_ps.h:324
uint8_t output_flag_present_flag
Definition: hevc_ps.h:343
const uint8_t ff_hevc_diag_scan4x4_y[16]
Definition: hevc_data.c:32
const AVHWAccel ff_hevc_dxva2_hwaccel
#define FF_ARRAY_ELEMS(a)
uint8_t constrained_intra_pred_flag
Definition: hevc_ps.h:332
uint8_t sl[4][6][64]
Definition: hevc_ps.h:221
uint8_t pic_slice_level_chroma_qp_offsets_present_flag
Definition: hevc_ps.h:340
HEVCFrame DPB[32]
Definition: hevcdec.h:424
uint8_t transform_skip_enabled_flag
Definition: hevc_ps.h:333
uint16_t num_tile_columns
num_tile_columns_minus1 + 1
Definition: hevc_ps.h:350
int short_term_ref_pic_set_size
Definition: hevc_ps.h:67
uint8_t uniform_spacing_flag
Definition: hevc_ps.h:352
int max_sub_layers
Definition: hevc_ps.h:242
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, const AVDXVAContext *ctx, const AVFrame *frame)
Definition: dxva2.c:764
ScalingList scaling_list
Definition: hevc_ps.h:364
main external API structure.
Definition: avcodec.h:1568
uint8_t sao_enabled
Definition: hevc_ps.h:260
int num_extra_slice_header_bits
Definition: hevc_ps.h:368
static void fill_picture_entry(DXVA_PicEntry_HEVC *pic, unsigned index, unsigned flag)
Definition: dxva2_hevc.c:40
uint8_t loop_filter_across_tiles_enabled_flag
Definition: hevc_ps.h:353
uint8_t num_long_term_ref_pics_sps
Definition: hevc_ps.h:265
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:791
const AVHWAccel ff_hevc_d3d11va2_hwaccel
uint8_t sps_temporal_mvp_enabled_flag
Definition: hevc_ps.h:274
unsigned int nb_st_rps
Definition: hevc_ps.h:256
static int FUNC() pps(CodedBitstreamContext *ctx, RWContext *rw, H264RawPPS *current)
int index
Definition: gxfenc.c:89
int poc
Definition: hevcdec.h:318
unsigned int log2_min_tb_size
Definition: hevc_ps.h:279
static int FUNC() sps(CodedBitstreamContext *ctx, RWContext *rw, H264RawSPS *current)
void DECODER_BUFFER_DESC
uint8_t scaling_list_enable_flag
Definition: hevc_ps.h:253
int tc_offset
tc_offset_div2 * 2
Definition: hevc_ps.h:361
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer. ...
Definition: pixfmt.h:137
uint8_t flags
A combination of HEVC_FRAME_FLAG_*.
Definition: hevcdec.h:337
int cr_qp_offset
Definition: hevc_ps.h:339
ScalingList scaling_list
Definition: hevc_ps.h:254
unsigned int log2_diff_max_min_coding_block_size
Definition: hevc_ps.h:278
#define FAILED(hr)
Definition: windows2linux.h:48
unsigned int log2_max_pcm_cb_size
Definition: hevc_ps.h:271
Hardware surfaces for Direct3D11.
Definition: pixfmt.h:313
const uint8_t ff_hevc_diag_scan4x4_x[16]
Definition: hevc_data.c:25
int max_transform_hierarchy_depth_intra
Definition: hevc_ps.h:285
#define DO_REF_LIST(ref_idx, ref_list)
uint8_t weighted_pred_flag
Definition: hevc_ps.h:341
#define flag(name)
Definition: cbs_av1.c:553
uint16_t num_tile_rows
num_tile_rows_minus1 + 1
Definition: hevc_ps.h:351
unsigned int * column_width
ColumnWidth.
Definition: hevc_ps.h:382
static int dxva2_hevc_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition: dxva2_hevc.c:380
uint8_t slice_header_extension_present_flag
Definition: hevc_ps.h:369
const uint8_t ff_hevc_diag_scan8x8_y[64]
Definition: hevc_data.c:58
void * priv_data
Definition: avcodec.h:1595
uint8_t sps_strong_intra_smoothing_enable_flag
Definition: hevc_ps.h:275
int rps_idx_num_delta_pocs
Definition: hevc_ps.h:37
#define DXVA_CONTEXT(avctx)
uint8_t long_term_ref_pics_present_flag
Definition: hevc_ps.h:262
int diff_cu_qp_delta_depth
Definition: hevc_ps.h:336
struct HEVCSPS::@95 pcm
static const uint8_t start_code[]
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
Definition: pixfmt.h:229
const AVHWAccel ff_hevc_d3d11va_hwaccel
static int dxva2_hevc_end_frame(AVCodecContext *avctx)
Definition: dxva2_hevc.c:403
int cb_qp_offset
Definition: hevc_ps.h:338
uint8_t deblocking_filter_override_enabled_flag
Definition: hevc_ps.h:358
int bit_depth
Definition: hevc_ps.h:234
int beta_offset
beta_offset_div2 * 2
Definition: hevc_ps.h:360
DXVA_PicParams_HEVC pp
Definition: dxva2_hevc.c:32
SliceHeader sh
Definition: hevcdec.h:418
int pcm_enabled_flag
Definition: hevc_ps.h:240
static int dxva2_hevc_start_frame(AVCodecContext *avctx, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition: dxva2_hevc.c:356
for(j=16;j >0;--j)
uint8_t separate_colour_plane_flag
Definition: hevc_ps.h:228
GLuint buffer
Definition: opengl_enc.c:101
#define av_unused
Definition: attributes.h:125
uint8_t dependent_slice_segments_enabled_flag
Definition: hevc_ps.h:346