2 * DXVA2 AV1 HW acceleration.
4 * copyright (c) 2020 Hendrik Leppkes
6 * This file is part of FFmpeg.
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.
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.
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
23 #include "libavutil/avassert.h"
24 #include "libavutil/pixdesc.h"
26 #include "dxva2_internal.h"
31 struct AV1DXVAContext {
32 FFDXVASharedContext shared;
34 unsigned int bitstream_allocated;
35 uint8_t *bitstream_cache;
38 struct av1_dxva2_picture_context {
39 DXVA_PicParams_AV1 pp;
41 DXVA_Tile_AV1 tiles[MAX_TILES];
43 unsigned bitstream_size;
46 static int get_bit_depth_from_seq(const AV1RawSequenceHeader *seq)
48 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
49 return seq->color_config.twelve_bit ? 12 : 10;
50 else if (seq->seq_profile <= 2 && seq->color_config.high_bitdepth)
56 static int fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, const AV1DecContext *h,
57 DXVA_PicParams_AV1 *pp)
60 const AV1RawSequenceHeader *seq = h->raw_seq;
61 const AV1RawFrameHeader *frame_header = h->raw_frame_header;
63 unsigned char remap_lr_type[4] = { AV1_RESTORE_NONE, AV1_RESTORE_SWITCHABLE, AV1_RESTORE_WIENER, AV1_RESTORE_SGRPROJ };
65 memset(pp, 0, sizeof(*pp));
67 pp->width = avctx->width;
68 pp->height = avctx->height;
70 pp->max_width = seq->max_frame_width_minus_1 + 1;
71 pp->max_height = seq->max_frame_height_minus_1 + 1;
73 pp->CurrPicTextureIndex = ff_dxva2_get_surface_index(avctx, ctx, h->cur_frame.tf.f);
74 pp->superres_denom = frame_header->use_superres ? frame_header->coded_denom : AV1_SUPERRES_NUM;
75 pp->bitdepth = get_bit_depth_from_seq(seq);
76 pp->seq_profile = seq->seq_profile;
79 pp->tiles.cols = frame_header->tile_cols;
80 pp->tiles.rows = frame_header->tile_rows;
81 pp->tiles.context_update_id = frame_header->context_update_tile_id;
83 for (i = 0; i < pp->tiles.cols; i++)
84 pp->tiles.widths[i] = frame_header->width_in_sbs_minus_1[i] + 1;
86 for (i = 0; i < pp->tiles.rows; i++)
87 pp->tiles.heights[i] = frame_header->height_in_sbs_minus_1[i] + 1;
90 pp->coding.use_128x128_superblock = seq->use_128x128_superblock;
91 pp->coding.intra_edge_filter = seq->enable_intra_edge_filter;
92 pp->coding.interintra_compound = seq->enable_interintra_compound;
93 pp->coding.masked_compound = seq->enable_masked_compound;
94 pp->coding.warped_motion = frame_header->allow_warped_motion;
95 pp->coding.dual_filter = seq->enable_dual_filter;
96 pp->coding.jnt_comp = seq->enable_jnt_comp;
97 pp->coding.screen_content_tools = frame_header->allow_screen_content_tools;
98 pp->coding.integer_mv = frame_header->force_integer_mv || !(frame_header->frame_type & 1);
99 pp->coding.cdef = seq->enable_cdef;
100 pp->coding.restoration = seq->enable_restoration;
101 pp->coding.film_grain = seq->film_grain_params_present;
102 pp->coding.intrabc = frame_header->allow_intrabc;
103 pp->coding.high_precision_mv = frame_header->allow_high_precision_mv;
104 pp->coding.switchable_motion_mode = frame_header->is_motion_mode_switchable;
105 pp->coding.filter_intra = seq->enable_filter_intra;
106 pp->coding.disable_frame_end_update_cdf = frame_header->disable_frame_end_update_cdf;
107 pp->coding.disable_cdf_update = frame_header->disable_cdf_update;
108 pp->coding.reference_mode = frame_header->reference_select;
109 pp->coding.skip_mode = frame_header->skip_mode_present;
110 pp->coding.reduced_tx_set = frame_header->reduced_tx_set;
111 pp->coding.superres = frame_header->use_superres;
112 pp->coding.tx_mode = frame_header->tx_mode;
113 pp->coding.use_ref_frame_mvs = frame_header->use_ref_frame_mvs;
114 pp->coding.enable_ref_frame_mvs = seq->enable_ref_frame_mvs;
115 pp->coding.reference_frame_update = 1; // 0 for show_existing_frame with key frames, but those are not passed to the hwaccel
117 /* Format & Picture Info flags */
118 pp->format.frame_type = frame_header->frame_type;
119 pp->format.show_frame = frame_header->show_frame;
120 pp->format.showable_frame = frame_header->showable_frame;
121 pp->format.subsampling_x = seq->color_config.subsampling_x;
122 pp->format.subsampling_y = seq->color_config.subsampling_y;
123 pp->format.mono_chrome = seq->color_config.mono_chrome;
126 pp->primary_ref_frame = frame_header->primary_ref_frame;
127 pp->order_hint = frame_header->order_hint;
128 pp->order_hint_bits = seq->enable_order_hint ? seq->order_hint_bits_minus_1 + 1 : 0;
130 memset(pp->RefFrameMapTextureIndex, 0xFF, sizeof(pp->RefFrameMapTextureIndex));
131 for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
132 int8_t ref_idx = frame_header->ref_frame_idx[i];
133 AVFrame *ref_frame = h->ref[ref_idx].tf.f;
135 pp->frame_refs[i].width = ref_frame->width;
136 pp->frame_refs[i].height = ref_frame->height;
137 pp->frame_refs[i].Index = ref_frame->buf[0] ? ref_idx : 0xFF;
140 pp->frame_refs[i].wminvalid = (h->cur_frame.gm_type[AV1_REF_FRAME_LAST + i] == AV1_WARP_MODEL_IDENTITY);
141 pp->frame_refs[i].wmtype = h->cur_frame.gm_type[AV1_REF_FRAME_LAST + i];
142 for (j = 0; j < 6; ++j) {
143 pp->frame_refs[i].wmmat[j] = h->cur_frame.gm_params[AV1_REF_FRAME_LAST + i][j];
146 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
147 AVFrame *ref_frame = h->ref[i].tf.f;
148 if (ref_frame->buf[0])
149 pp->RefFrameMapTextureIndex[i] = ff_dxva2_get_surface_index(avctx, ctx, ref_frame);
152 /* Loop filter parameters */
153 pp->loop_filter.filter_level[0] = frame_header->loop_filter_level[0];
154 pp->loop_filter.filter_level[1] = frame_header->loop_filter_level[1];
155 pp->loop_filter.filter_level_u = frame_header->loop_filter_level[2];
156 pp->loop_filter.filter_level_v = frame_header->loop_filter_level[3];
157 pp->loop_filter.sharpness_level = frame_header->loop_filter_sharpness;
158 pp->loop_filter.mode_ref_delta_enabled = frame_header->loop_filter_delta_enabled;
159 pp->loop_filter.mode_ref_delta_update = frame_header->loop_filter_delta_update;
160 pp->loop_filter.delta_lf_multi = frame_header->delta_lf_multi;
161 pp->loop_filter.delta_lf_present = frame_header->delta_lf_present;
162 pp->loop_filter.delta_lf_res = frame_header->delta_lf_res;
164 for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) {
165 pp->loop_filter.ref_deltas[i] = frame_header->loop_filter_ref_deltas[i];
168 pp->loop_filter.mode_deltas[0] = frame_header->loop_filter_mode_deltas[0];
169 pp->loop_filter.mode_deltas[1] = frame_header->loop_filter_mode_deltas[1];
170 pp->loop_filter.frame_restoration_type[0] = remap_lr_type[frame_header->lr_type[0]];
171 pp->loop_filter.frame_restoration_type[1] = remap_lr_type[frame_header->lr_type[1]];
172 pp->loop_filter.frame_restoration_type[2] = remap_lr_type[frame_header->lr_type[2]];
173 uses_lr = frame_header->lr_type[0] || frame_header->lr_type[1] || frame_header->lr_type[2];
174 pp->loop_filter.log2_restoration_unit_size[0] = uses_lr ? (6 + frame_header->lr_unit_shift) : 8;
175 pp->loop_filter.log2_restoration_unit_size[1] = uses_lr ? (6 + frame_header->lr_unit_shift - frame_header->lr_uv_shift) : 8;
176 pp->loop_filter.log2_restoration_unit_size[2] = uses_lr ? (6 + frame_header->lr_unit_shift - frame_header->lr_uv_shift) : 8;
179 pp->quantization.delta_q_present = frame_header->delta_q_present;
180 pp->quantization.delta_q_res = frame_header->delta_q_res;
181 pp->quantization.base_qindex = frame_header->base_q_idx;
182 pp->quantization.y_dc_delta_q = frame_header->delta_q_y_dc;
183 pp->quantization.u_dc_delta_q = frame_header->delta_q_u_dc;
184 pp->quantization.v_dc_delta_q = frame_header->delta_q_v_dc;
185 pp->quantization.u_ac_delta_q = frame_header->delta_q_u_ac;
186 pp->quantization.v_ac_delta_q = frame_header->delta_q_v_ac;
187 pp->quantization.qm_y = frame_header->using_qmatrix ? frame_header->qm_y : 0xFF;
188 pp->quantization.qm_u = frame_header->using_qmatrix ? frame_header->qm_u : 0xFF;
189 pp->quantization.qm_v = frame_header->using_qmatrix ? frame_header->qm_v : 0xFF;
191 /* Cdef parameters */
192 pp->cdef.damping = frame_header->cdef_damping_minus_3;
193 pp->cdef.bits = frame_header->cdef_bits;
194 for (i = 0; i < 8; i++) {
195 pp->cdef.y_strengths[i].primary = frame_header->cdef_y_pri_strength[i];
196 pp->cdef.y_strengths[i].secondary = frame_header->cdef_y_sec_strength[i];
197 pp->cdef.uv_strengths[i].primary = frame_header->cdef_uv_pri_strength[i];
198 pp->cdef.uv_strengths[i].secondary = frame_header->cdef_uv_sec_strength[i];
202 pp->interp_filter = frame_header->interpolation_filter;
205 pp->segmentation.enabled = frame_header->segmentation_enabled;
206 pp->segmentation.update_map = frame_header->segmentation_update_map;
207 pp->segmentation.update_data = frame_header->segmentation_update_data;
208 pp->segmentation.temporal_update = frame_header->segmentation_temporal_update;
209 for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
210 for (j = 0; j < AV1_SEG_LVL_MAX; j++) {
211 pp->segmentation.feature_mask[i].mask |= frame_header->feature_enabled[i][j] << j;
212 pp->segmentation.feature_data[i][j] = frame_header->feature_value[i][j];
217 if (frame_header->apply_grain) {
218 pp->film_grain.apply_grain = 1;
219 pp->film_grain.scaling_shift_minus8 = frame_header->grain_scaling_minus_8;
220 pp->film_grain.chroma_scaling_from_luma = frame_header->chroma_scaling_from_luma;
221 pp->film_grain.ar_coeff_lag = frame_header->ar_coeff_lag;
222 pp->film_grain.ar_coeff_shift_minus6 = frame_header->ar_coeff_shift_minus_6;
223 pp->film_grain.grain_scale_shift = frame_header->grain_scale_shift;
224 pp->film_grain.overlap_flag = frame_header->overlap_flag;
225 pp->film_grain.clip_to_restricted_range = frame_header->clip_to_restricted_range;
226 pp->film_grain.matrix_coeff_is_identity = (seq->color_config.matrix_coefficients == AVCOL_SPC_RGB);
228 pp->film_grain.grain_seed = frame_header->grain_seed;
229 pp->film_grain.num_y_points = frame_header->num_y_points;
230 for (i = 0; i < frame_header->num_y_points; i++) {
231 pp->film_grain.scaling_points_y[i][0] = frame_header->point_y_value[i];
232 pp->film_grain.scaling_points_y[i][1] = frame_header->point_y_scaling[i];
234 pp->film_grain.num_cb_points = frame_header->num_cb_points;
235 for (i = 0; i < frame_header->num_cb_points; i++) {
236 pp->film_grain.scaling_points_cb[i][0] = frame_header->point_cb_value[i];
237 pp->film_grain.scaling_points_cb[i][1] = frame_header->point_cb_scaling[i];
239 pp->film_grain.num_cr_points = frame_header->num_cr_points;
240 for (i = 0; i < frame_header->num_cr_points; i++) {
241 pp->film_grain.scaling_points_cr[i][0] = frame_header->point_cr_value[i];
242 pp->film_grain.scaling_points_cr[i][1] = frame_header->point_cr_scaling[i];
244 for (i = 0; i < 24; i++) {
245 pp->film_grain.ar_coeffs_y[i] = frame_header->ar_coeffs_y_plus_128[i];
247 for (i = 0; i < 25; i++) {
248 pp->film_grain.ar_coeffs_cb[i] = frame_header->ar_coeffs_cb_plus_128[i];
249 pp->film_grain.ar_coeffs_cr[i] = frame_header->ar_coeffs_cr_plus_128[i];
251 pp->film_grain.cb_mult = frame_header->cb_mult;
252 pp->film_grain.cb_luma_mult = frame_header->cb_luma_mult;
253 pp->film_grain.cr_mult = frame_header->cr_mult;
254 pp->film_grain.cr_luma_mult = frame_header->cr_luma_mult;
255 pp->film_grain.cb_offset = frame_header->cb_offset;
256 pp->film_grain.cr_offset = frame_header->cr_offset;
257 pp->film_grain.cr_offset = frame_header->cr_offset;
260 // XXX: Setting the StatusReportFeedbackNumber breaks decoding on some drivers (tested on NVIDIA 457.09)
261 // Status Reporting is not used by FFmpeg, hence not providing a number does not cause any issues
262 //pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;
266 static int dxva2_av1_start_frame(AVCodecContext *avctx,
267 av_unused const uint8_t *buffer,
268 av_unused uint32_t size)
270 const AV1DecContext *h = avctx->priv_data;
271 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
272 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
274 if (!DXVA_CONTEXT_VALID(avctx, ctx))
278 /* Fill up DXVA_PicParams_AV1 */
279 if (fill_picture_parameters(avctx, ctx, h, &ctx_pic->pp) < 0)
282 ctx_pic->bitstream_size = 0;
283 ctx_pic->bitstream = NULL;
287 static int dxva2_av1_decode_slice(AVCodecContext *avctx,
288 const uint8_t *buffer,
291 const AV1DecContext *h = avctx->priv_data;
292 const AV1RawFrameHeader *frame_header = h->raw_frame_header;
293 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
294 struct AV1DXVAContext *ctx = avctx->internal->hwaccel_priv_data;
297 ctx_pic->tile_count = frame_header->tile_cols * frame_header->tile_rows;
299 /* too many tiles, exceeding all defined levels in the AV1 spec */
300 if (ctx_pic->tile_count > MAX_TILES)
301 return AVERROR(ENOSYS);
303 /* Shortcut if all tiles are in the same buffer */
304 if (ctx_pic->tile_count == h->tg_end - h->tg_start + 1) {
305 ctx_pic->bitstream = (uint8_t *)buffer;
306 ctx_pic->bitstream_size = size;
308 for (uint32_t tile_num = 0; tile_num < ctx_pic->tile_count; tile_num++) {
309 ctx_pic->tiles[tile_num].DataOffset = h->tile_group_info[tile_num].tile_offset;
310 ctx_pic->tiles[tile_num].DataSize = h->tile_group_info[tile_num].tile_size;
311 ctx_pic->tiles[tile_num].row = h->tile_group_info[tile_num].tile_row;
312 ctx_pic->tiles[tile_num].column = h->tile_group_info[tile_num].tile_column;
313 ctx_pic->tiles[tile_num].anchor_frame = 0xFF;
319 /* allocate an internal buffer */
320 tmp = av_fast_realloc(ctx->bitstream_cache, &ctx->bitstream_allocated,
321 ctx_pic->bitstream_size + size);
323 return AVERROR(ENOMEM);
325 ctx_pic->bitstream = ctx->bitstream_cache = tmp;
327 memcpy(ctx_pic->bitstream + ctx_pic->bitstream_size, buffer, size);
329 for (uint32_t tile_num = h->tg_start; tile_num <= h->tg_end; tile_num++) {
330 ctx_pic->tiles[tile_num].DataOffset = ctx_pic->bitstream_size + h->tile_group_info[tile_num].tile_offset;
331 ctx_pic->tiles[tile_num].DataSize = h->tile_group_info[tile_num].tile_size;
332 ctx_pic->tiles[tile_num].row = h->tile_group_info[tile_num].tile_row;
333 ctx_pic->tiles[tile_num].column = h->tile_group_info[tile_num].tile_column;
334 ctx_pic->tiles[tile_num].anchor_frame = 0xFF;
337 ctx_pic->bitstream_size += size;
342 static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx,
343 DECODER_BUFFER_DESC *bs,
344 DECODER_BUFFER_DESC *sc)
346 const AV1DecContext *h = avctx->priv_data;
347 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
348 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
356 if (ff_dxva2_is_d3d11(avctx)) {
357 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
358 if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
359 D3D11VA_CONTEXT(ctx)->decoder,
361 &dxva_size, &dxva_data_ptr)))
366 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
367 type = DXVA2_BitStreamDateBufferType;
368 if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
370 &dxva_data_ptr, &dxva_size)))
375 dxva_data = dxva_data_ptr;
377 if (ctx_pic->bitstream_size > dxva_size) {
378 av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer");
382 memcpy(dxva_data, ctx_pic->bitstream, ctx_pic->bitstream_size);
384 padding = FFMIN(128 - ((ctx_pic->bitstream_size) & 127), dxva_size - ctx_pic->bitstream_size);
386 memset(dxva_data + ctx_pic->bitstream_size, 0, padding);
387 ctx_pic->bitstream_size += padding;
391 if (ff_dxva2_is_d3d11(avctx))
392 if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type)))
396 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
397 if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type)))
402 if (ff_dxva2_is_d3d11(avctx)) {
403 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
404 memset(dsc11, 0, sizeof(*dsc11));
405 dsc11->BufferType = type;
406 dsc11->DataSize = ctx_pic->bitstream_size;
407 dsc11->NumMBsInBuffer = 0;
409 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
413 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
414 DXVA2_DecodeBufferDesc *dsc2 = bs;
415 memset(dsc2, 0, sizeof(*dsc2));
416 dsc2->CompressedBufferType = type;
417 dsc2->DataSize = ctx_pic->bitstream_size;
418 dsc2->NumMBsInBuffer = 0;
420 type = DXVA2_SliceControlBufferType;
424 return ff_dxva2_commit_buffer(avctx, ctx, sc, type,
425 ctx_pic->tiles, sizeof(*ctx_pic->tiles) * ctx_pic->tile_count, 0);
428 static int dxva2_av1_end_frame(AVCodecContext *avctx)
430 const AV1DecContext *h = avctx->priv_data;
431 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
434 if (ctx_pic->bitstream_size <= 0)
437 ret = ff_dxva2_common_end_frame(avctx, h->cur_frame.tf.f,
438 &ctx_pic->pp, sizeof(ctx_pic->pp),
440 commit_bitstream_and_slice_buffer);
445 static int dxva2_av1_uninit(AVCodecContext *avctx)
447 struct AV1DXVAContext *ctx = avctx->internal->hwaccel_priv_data;
449 av_freep(&ctx->bitstream_cache);
450 ctx->bitstream_allocated = 0;
452 return ff_dxva2_decode_uninit(avctx);
455 #if CONFIG_AV1_DXVA2_HWACCEL
456 const AVHWAccel ff_av1_dxva2_hwaccel = {
458 .type = AVMEDIA_TYPE_VIDEO,
459 .id = AV_CODEC_ID_AV1,
460 .pix_fmt = AV_PIX_FMT_DXVA2_VLD,
461 .init = ff_dxva2_decode_init,
462 .uninit = dxva2_av1_uninit,
463 .start_frame = dxva2_av1_start_frame,
464 .decode_slice = dxva2_av1_decode_slice,
465 .end_frame = dxva2_av1_end_frame,
466 .frame_params = ff_dxva2_common_frame_params,
467 .frame_priv_data_size = sizeof(struct av1_dxva2_picture_context),
468 .priv_data_size = sizeof(struct AV1DXVAContext),
472 #if CONFIG_AV1_D3D11VA_HWACCEL
473 const AVHWAccel ff_av1_d3d11va_hwaccel = {
474 .name = "av1_d3d11va",
475 .type = AVMEDIA_TYPE_VIDEO,
476 .id = AV_CODEC_ID_AV1,
477 .pix_fmt = AV_PIX_FMT_D3D11VA_VLD,
478 .init = ff_dxva2_decode_init,
479 .uninit = dxva2_av1_uninit,
480 .start_frame = dxva2_av1_start_frame,
481 .decode_slice = dxva2_av1_decode_slice,
482 .end_frame = dxva2_av1_end_frame,
483 .frame_params = ff_dxva2_common_frame_params,
484 .frame_priv_data_size = sizeof(struct av1_dxva2_picture_context),
485 .priv_data_size = sizeof(struct AV1DXVAContext),
489 #if CONFIG_AV1_D3D11VA2_HWACCEL
490 const AVHWAccel ff_av1_d3d11va2_hwaccel = {
491 .name = "av1_d3d11va2",
492 .type = AVMEDIA_TYPE_VIDEO,
493 .id = AV_CODEC_ID_AV1,
494 .pix_fmt = AV_PIX_FMT_D3D11,
495 .init = ff_dxva2_decode_init,
496 .uninit = dxva2_av1_uninit,
497 .start_frame = dxva2_av1_start_frame,
498 .decode_slice = dxva2_av1_decode_slice,
499 .end_frame = dxva2_av1_end_frame,
500 .frame_params = ff_dxva2_common_frame_params,
501 .frame_priv_data_size = sizeof(struct av1_dxva2_picture_context),
502 .priv_data_size = sizeof(struct AV1DXVAContext),