FFmpeg
Loading...
Searching...
No Matches
dxva2_av1.c
Go to the documentation of this file.
1/*
2 * DXVA2 AV1 HW acceleration.
3 *
4 * copyright (c) 2020 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#include "libavutil/mem.h"
27#include "libavutil/pixdesc.h"
28
29#include "dxva2_internal.h"
30#include "av1dec.h"
31#include "hwaccel_internal.h"
32
33#define MAX_TILES 256
34
41
43 DXVA_PicParams_AV1 pp;
44 unsigned tile_count;
45 DXVA_Tile_AV1 tiles[MAX_TILES];
46 uint8_t *bitstream;
48};
49
51{
52 if (seq->seq_profile == 2 && seq->color_config.high_bitdepth)
53 return seq->color_config.twelve_bit ? 12 : 10;
54 else if (seq->seq_profile <= 2 && seq->color_config.high_bitdepth)
55 return 10;
56 else
57 return 8;
58}
59
61 DXVA_PicParams_AV1 *pp)
62{
63 int i,j, uses_lr;
64 const AV1DecContext *h = avctx->priv_data;
65 const AV1RawSequenceHeader *seq = h->raw_seq;
66 const AV1RawFrameHeader *frame_header = h->raw_frame_header;
67 const AV1RawFilmGrainParams *film_grain = &h->cur_frame.film_grain;
68
70 int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) && film_grain->apply_grain;
71
72 memset(pp, 0, sizeof(*pp));
73
74 pp->width = avctx->width;
75 pp->height = avctx->height;
76
77 pp->max_width = seq->max_frame_width_minus_1 + 1;
78 pp->max_height = seq->max_frame_height_minus_1 + 1;
79
80 pp->superres_denom = frame_header->use_superres ? frame_header->coded_denom + AV1_SUPERRES_DENOM_MIN : AV1_SUPERRES_NUM;
81 pp->bitdepth = get_bit_depth_from_seq(seq);
82 pp->seq_profile = seq->seq_profile;
83
84 /* Tiling info */
85 pp->tiles.cols = frame_header->tile_cols;
86 pp->tiles.rows = frame_header->tile_rows;
87 pp->tiles.context_update_id = frame_header->context_update_tile_id;
88
89 for (i = 0; i < pp->tiles.cols; i++)
90 pp->tiles.widths[i] = frame_header->width_in_sbs_minus_1[i] + 1;
91
92 for (i = 0; i < pp->tiles.rows; i++)
93 pp->tiles.heights[i] = frame_header->height_in_sbs_minus_1[i] + 1;
94
95 /* Coding tools */
96 pp->coding.use_128x128_superblock = seq->use_128x128_superblock;
97 pp->coding.intra_edge_filter = seq->enable_intra_edge_filter;
98 pp->coding.interintra_compound = seq->enable_interintra_compound;
99 pp->coding.masked_compound = seq->enable_masked_compound;
100 pp->coding.warped_motion = frame_header->allow_warped_motion;
101 pp->coding.dual_filter = seq->enable_dual_filter;
102 pp->coding.jnt_comp = seq->enable_jnt_comp;
103 pp->coding.screen_content_tools = frame_header->allow_screen_content_tools;
104 pp->coding.integer_mv = h->cur_frame.force_integer_mv;
105 pp->coding.cdef = seq->enable_cdef;
106 pp->coding.restoration = seq->enable_restoration;
107 pp->coding.film_grain = seq->film_grain_params_present && !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
108 pp->coding.intrabc = frame_header->allow_intrabc;
109 pp->coding.high_precision_mv = frame_header->allow_high_precision_mv;
110 pp->coding.switchable_motion_mode = frame_header->is_motion_mode_switchable;
111 pp->coding.filter_intra = seq->enable_filter_intra;
112 pp->coding.disable_frame_end_update_cdf = frame_header->disable_frame_end_update_cdf;
113 pp->coding.disable_cdf_update = frame_header->disable_cdf_update;
114 pp->coding.reference_mode = frame_header->reference_select;
115 pp->coding.skip_mode = frame_header->skip_mode_present;
116 pp->coding.reduced_tx_set = frame_header->reduced_tx_set;
117 pp->coding.superres = frame_header->use_superres;
118 pp->coding.tx_mode = frame_header->tx_mode;
119 pp->coding.use_ref_frame_mvs = frame_header->use_ref_frame_mvs;
120 pp->coding.enable_ref_frame_mvs = seq->enable_ref_frame_mvs;
121 pp->coding.reference_frame_update = 1; // 0 for show_existing_frame with key frames, but those are not passed to the hwaccel
122
123 /* Format & Picture Info flags */
124 pp->format.frame_type = frame_header->frame_type;
125 pp->format.show_frame = frame_header->show_frame;
126 pp->format.showable_frame = frame_header->showable_frame;
127 pp->format.subsampling_x = seq->color_config.subsampling_x;
128 pp->format.subsampling_y = seq->color_config.subsampling_y;
129 pp->format.mono_chrome = seq->color_config.mono_chrome;
130
131 /* References */
132 pp->primary_ref_frame = frame_header->primary_ref_frame;
133 pp->order_hint = frame_header->order_hint;
134 pp->order_hint_bits = seq->enable_order_hint ? seq->order_hint_bits_minus_1 + 1 : 0;
135
136 memset(pp->RefFrameMapTextureIndex, 0xFF, sizeof(pp->RefFrameMapTextureIndex));
137 for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
138 int8_t ref_idx = frame_header->ref_frame_idx[i];
139 AVFrame *ref_frame = h->ref[ref_idx].f;
140
141 pp->frame_refs[i].width = ref_frame ? ref_frame->width : 0;
142 pp->frame_refs[i].height = ref_frame ? ref_frame->height : 0;
143 pp->frame_refs[i].Index = ref_frame ? ref_idx : 0xFF;
144
145 /* Global Motion */
146 pp->frame_refs[i].wminvalid = h->cur_frame.gm_invalid[AV1_REF_FRAME_LAST + i];
147 pp->frame_refs[i].wmtype = h->cur_frame.gm_type[AV1_REF_FRAME_LAST + i];
148 for (j = 0; j < 6; ++j) {
149 pp->frame_refs[i].wmmat[j] = h->cur_frame.gm_params[AV1_REF_FRAME_LAST + i][j];
150 }
151 }
152 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
153 AVFrame *ref_frame = h->ref[i].f;
154 if (ref_frame)
155 pp->RefFrameMapTextureIndex[i] = ff_dxva2_get_surface_index(avctx, ctx, ref_frame, 0);
156 }
157
158 pp->CurrPicTextureIndex = ff_dxva2_get_surface_index(avctx, ctx, h->cur_frame.f, 1);
159
160 /* Loop filter parameters */
161 pp->loop_filter.filter_level[0] = frame_header->loop_filter_level[0];
162 pp->loop_filter.filter_level[1] = frame_header->loop_filter_level[1];
163 pp->loop_filter.filter_level_u = frame_header->loop_filter_level[2];
164 pp->loop_filter.filter_level_v = frame_header->loop_filter_level[3];
165 pp->loop_filter.sharpness_level = frame_header->loop_filter_sharpness;
166 pp->loop_filter.mode_ref_delta_enabled = frame_header->loop_filter_delta_enabled;
167 pp->loop_filter.mode_ref_delta_update = frame_header->loop_filter_delta_update;
168 pp->loop_filter.delta_lf_multi = frame_header->delta_lf_multi;
169 pp->loop_filter.delta_lf_present = frame_header->delta_lf_present;
170 pp->loop_filter.delta_lf_res = frame_header->delta_lf_res;
171
172 for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) {
173 pp->loop_filter.ref_deltas[i] = frame_header->loop_filter_ref_deltas[i];
174 }
175
176 pp->loop_filter.mode_deltas[0] = frame_header->loop_filter_mode_deltas[0];
177 pp->loop_filter.mode_deltas[1] = frame_header->loop_filter_mode_deltas[1];
178 pp->loop_filter.frame_restoration_type[0] = remap_lr_type[frame_header->lr_type[0]];
179 pp->loop_filter.frame_restoration_type[1] = remap_lr_type[frame_header->lr_type[1]];
180 pp->loop_filter.frame_restoration_type[2] = remap_lr_type[frame_header->lr_type[2]];
181 uses_lr = frame_header->lr_type[0] || frame_header->lr_type[1] || frame_header->lr_type[2];
182 pp->loop_filter.log2_restoration_unit_size[0] = uses_lr ? (6 + frame_header->lr_unit_shift) : 8;
183 pp->loop_filter.log2_restoration_unit_size[1] = uses_lr ? (6 + frame_header->lr_unit_shift - frame_header->lr_uv_shift) : 8;
184 pp->loop_filter.log2_restoration_unit_size[2] = uses_lr ? (6 + frame_header->lr_unit_shift - frame_header->lr_uv_shift) : 8;
185
186 /* Quantization */
187 pp->quantization.delta_q_present = frame_header->delta_q_present;
188 pp->quantization.delta_q_res = frame_header->delta_q_res;
189 pp->quantization.base_qindex = frame_header->base_q_idx;
190 pp->quantization.y_dc_delta_q = frame_header->delta_q_y_dc;
191 pp->quantization.u_dc_delta_q = frame_header->delta_q_u_dc;
192 pp->quantization.v_dc_delta_q = frame_header->delta_q_v_dc;
193 pp->quantization.u_ac_delta_q = frame_header->delta_q_u_ac;
194 pp->quantization.v_ac_delta_q = frame_header->delta_q_v_ac;
195 pp->quantization.qm_y = frame_header->using_qmatrix ? frame_header->qm_y : 0xFF;
196 pp->quantization.qm_u = frame_header->using_qmatrix ? frame_header->qm_u : 0xFF;
197 pp->quantization.qm_v = frame_header->using_qmatrix ? frame_header->qm_v : 0xFF;
198
199 /* Cdef parameters */
200 pp->cdef.damping = frame_header->cdef_damping_minus_3;
201 pp->cdef.bits = frame_header->cdef_bits;
202 for (i = 0; i < 8; i++) {
203 pp->cdef.y_strengths[i].primary = frame_header->cdef_y_pri_strength[i];
204 pp->cdef.y_strengths[i].secondary = frame_header->cdef_y_sec_strength[i];
205 pp->cdef.uv_strengths[i].primary = frame_header->cdef_uv_pri_strength[i];
206 pp->cdef.uv_strengths[i].secondary = frame_header->cdef_uv_sec_strength[i];
207 }
208
209 /* Misc flags */
210 pp->interp_filter = frame_header->interpolation_filter;
211
212 /* Segmentation */
213 pp->segmentation.enabled = frame_header->segmentation_enabled;
214 pp->segmentation.update_map = frame_header->segmentation_update_map;
215 pp->segmentation.update_data = frame_header->segmentation_update_data;
216 pp->segmentation.temporal_update = frame_header->segmentation_temporal_update;
217 for (i = 0; i < AV1_MAX_SEGMENTS; i++) {
218 for (j = 0; j < AV1_SEG_LVL_MAX; j++) {
219 pp->segmentation.feature_mask[i].mask |= frame_header->feature_enabled[i][j] << j;
220 pp->segmentation.feature_data[i][j] = frame_header->feature_value[i][j];
221 }
222 }
223
224 /* Film grain */
225 if (apply_grain) {
226 pp->film_grain.apply_grain = 1;
227 pp->film_grain.scaling_shift_minus8 = film_grain->grain_scaling_minus_8;
228 pp->film_grain.chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma;
229 pp->film_grain.ar_coeff_lag = film_grain->ar_coeff_lag;
230 pp->film_grain.ar_coeff_shift_minus6 = film_grain->ar_coeff_shift_minus_6;
231 pp->film_grain.grain_scale_shift = film_grain->grain_scale_shift;
232 pp->film_grain.overlap_flag = film_grain->overlap_flag;
233 pp->film_grain.clip_to_restricted_range = film_grain->clip_to_restricted_range;
234 pp->film_grain.matrix_coeff_is_identity = (seq->color_config.matrix_coefficients == AVCOL_SPC_RGB);
235
236 pp->film_grain.grain_seed = film_grain->grain_seed;
237 pp->film_grain.num_y_points = film_grain->num_y_points;
238 for (i = 0; i < film_grain->num_y_points; i++) {
239 pp->film_grain.scaling_points_y[i][0] = film_grain->point_y_value[i];
240 pp->film_grain.scaling_points_y[i][1] = film_grain->point_y_scaling[i];
241 }
242 pp->film_grain.num_cb_points = film_grain->num_cb_points;
243 for (i = 0; i < film_grain->num_cb_points; i++) {
244 pp->film_grain.scaling_points_cb[i][0] = film_grain->point_cb_value[i];
245 pp->film_grain.scaling_points_cb[i][1] = film_grain->point_cb_scaling[i];
246 }
247 pp->film_grain.num_cr_points = film_grain->num_cr_points;
248 for (i = 0; i < film_grain->num_cr_points; i++) {
249 pp->film_grain.scaling_points_cr[i][0] = film_grain->point_cr_value[i];
250 pp->film_grain.scaling_points_cr[i][1] = film_grain->point_cr_scaling[i];
251 }
252 for (i = 0; i < 24; i++) {
253 pp->film_grain.ar_coeffs_y[i] = film_grain->ar_coeffs_y_plus_128[i];
254 }
255 for (i = 0; i < 25; i++) {
256 pp->film_grain.ar_coeffs_cb[i] = film_grain->ar_coeffs_cb_plus_128[i];
257 pp->film_grain.ar_coeffs_cr[i] = film_grain->ar_coeffs_cr_plus_128[i];
258 }
259 pp->film_grain.cb_mult = film_grain->cb_mult;
260 pp->film_grain.cb_luma_mult = film_grain->cb_luma_mult;
261 pp->film_grain.cr_mult = film_grain->cr_mult;
262 pp->film_grain.cr_luma_mult = film_grain->cr_luma_mult;
263 pp->film_grain.cb_offset = film_grain->cb_offset;
264 pp->film_grain.cr_offset = film_grain->cr_offset;
265 pp->film_grain.cr_offset = film_grain->cr_offset;
266 }
267
268 // XXX: Setting the StatusReportFeedbackNumber breaks decoding on some drivers (tested on NVIDIA 457.09)
269 // Status Reporting is not used by FFmpeg, hence not providing a number does not cause any issues
270 //pp->StatusReportFeedbackNumber = 1 + DXVA_CONTEXT_REPORT_ID(avctx, ctx)++;
271 return 0;
272}
273
275 av_unused const AVBufferRef *buffer_ref,
276 av_unused const uint8_t *buffer,
277 av_unused uint32_t size)
278{
279 const AV1DecContext *h = avctx->priv_data;
281 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
282
283 if (!DXVA_CONTEXT_VALID(avctx, ctx))
284 return -1;
285 av_assert0(ctx_pic);
286
287 /* Fill up DXVA_PicParams_AV1 */
288 if (ff_dxva2_av1_fill_picture_parameters(avctx, ctx, &ctx_pic->pp) < 0)
289 return -1;
290
291 ctx_pic->bitstream_size = 0;
292 ctx_pic->bitstream = NULL;
293 return 0;
294}
295
297 const uint8_t *buffer,
298 uint32_t size)
299{
300 const AV1DecContext *h = avctx->priv_data;
301 const AV1RawFrameHeader *frame_header = h->raw_frame_header;
302 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
304 void *tmp;
305
306 ctx_pic->tile_count = frame_header->tile_cols * frame_header->tile_rows;
307
308 /* too many tiles, exceeding all defined levels in the AV1 spec */
309 if (ctx_pic->tile_count > MAX_TILES)
310 return AVERROR(ENOSYS);
311
312 /* Shortcut if all tiles are in the same buffer */
313 if (ctx_pic->tile_count == h->tg_end - h->tg_start + 1) {
314 ctx_pic->bitstream = (uint8_t *)buffer;
315 ctx_pic->bitstream_size = size;
316
317 for (uint32_t tile_num = 0; tile_num < ctx_pic->tile_count; tile_num++) {
318 ctx_pic->tiles[tile_num].DataOffset = h->tile_group_info[tile_num].tile_offset;
319 ctx_pic->tiles[tile_num].DataSize = h->tile_group_info[tile_num].tile_size;
320 ctx_pic->tiles[tile_num].row = h->tile_group_info[tile_num].tile_row;
321 ctx_pic->tiles[tile_num].column = h->tile_group_info[tile_num].tile_column;
322 ctx_pic->tiles[tile_num].anchor_frame = 0xFF;
323 }
324
325 return 0;
326 }
327
328 /* allocate an internal buffer */
329 tmp = av_fast_realloc(ctx->bitstream_cache, &ctx->bitstream_allocated,
330 ctx_pic->bitstream_size + size);
331 if (!tmp) {
332 return AVERROR(ENOMEM);
333 }
334 ctx_pic->bitstream = ctx->bitstream_cache = tmp;
335
336 memcpy(ctx_pic->bitstream + ctx_pic->bitstream_size, buffer, size);
337
338 for (uint32_t tile_num = h->tg_start; tile_num <= h->tg_end; tile_num++) {
339 ctx_pic->tiles[tile_num].DataOffset = ctx_pic->bitstream_size + h->tile_group_info[tile_num].tile_offset;
340 ctx_pic->tiles[tile_num].DataSize = h->tile_group_info[tile_num].tile_size;
341 ctx_pic->tiles[tile_num].row = h->tile_group_info[tile_num].tile_row;
342 ctx_pic->tiles[tile_num].column = h->tile_group_info[tile_num].tile_column;
343 ctx_pic->tiles[tile_num].anchor_frame = 0xFF;
344 }
345
346 ctx_pic->bitstream_size += size;
347
348 return 0;
349}
350
354{
355 const AV1DecContext *h = avctx->priv_data;
357 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
358 void *dxva_data_ptr = NULL;
359 uint8_t *dxva_data;
360 unsigned dxva_size;
361 unsigned padding;
362 unsigned type;
363
364#if CONFIG_D3D11VA
365 if (ff_dxva2_is_d3d11(avctx)) {
366 type = D3D11_VIDEO_DECODER_BUFFER_BITSTREAM;
367 if (FAILED(ID3D11VideoContext_GetDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context,
369 type,
370 &dxva_size, &dxva_data_ptr)))
371 return -1;
372 }
373#endif
374#if CONFIG_DXVA2
375 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
376 type = DXVA2_BitStreamDateBufferType;
377 if (FAILED(IDirectXVideoDecoder_GetBuffer(DXVA2_CONTEXT(ctx)->decoder,
378 type,
379 &dxva_data_ptr, &dxva_size)))
380 return -1;
381 }
382#endif
383
384 dxva_data = dxva_data_ptr;
385
386 if (!dxva_data || ctx_pic->bitstream_size > dxva_size) {
387 av_log(avctx, AV_LOG_ERROR, "Bitstream size exceeds hardware buffer");
388 return -1;
389 }
390
391 memcpy(dxva_data, ctx_pic->bitstream, ctx_pic->bitstream_size);
392
393 padding = FFMIN(128 - ((ctx_pic->bitstream_size) & 127), dxva_size - ctx_pic->bitstream_size);
394 if (padding > 0) {
395 memset(dxva_data + ctx_pic->bitstream_size, 0, padding);
396 ctx_pic->bitstream_size += padding;
397 }
398
399#if CONFIG_D3D11VA
400 if (ff_dxva2_is_d3d11(avctx))
401 if (FAILED(ID3D11VideoContext_ReleaseDecoderBuffer(D3D11VA_CONTEXT(ctx)->video_context, D3D11VA_CONTEXT(ctx)->decoder, type)))
402 return -1;
403#endif
404#if CONFIG_DXVA2
405 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
406 if (FAILED(IDirectXVideoDecoder_ReleaseBuffer(DXVA2_CONTEXT(ctx)->decoder, type)))
407 return -1;
408#endif
409
410#if CONFIG_D3D11VA
411 if (ff_dxva2_is_d3d11(avctx)) {
412 D3D11_VIDEO_DECODER_BUFFER_DESC *dsc11 = bs;
413 memset(dsc11, 0, sizeof(*dsc11));
414 dsc11->BufferType = type;
415 dsc11->DataSize = ctx_pic->bitstream_size;
416 dsc11->NumMBsInBuffer = 0;
417
418 type = D3D11_VIDEO_DECODER_BUFFER_SLICE_CONTROL;
419 }
420#endif
421#if CONFIG_DXVA2
422 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
423 DXVA2_DecodeBufferDesc *dsc2 = bs;
424 memset(dsc2, 0, sizeof(*dsc2));
425 dsc2->CompressedBufferType = type;
426 dsc2->DataSize = ctx_pic->bitstream_size;
427 dsc2->NumMBsInBuffer = 0;
428
429 type = DXVA2_SliceControlBufferType;
430 }
431#endif
432
433 return ff_dxva2_commit_buffer(avctx, ctx, sc, type,
434 ctx_pic->tiles, sizeof(*ctx_pic->tiles) * ctx_pic->tile_count, 0);
435}
436
438{
439 const AV1DecContext *h = avctx->priv_data;
440 struct av1_dxva2_picture_context *ctx_pic = h->cur_frame.hwaccel_picture_private;
441 int ret;
442
443 if (ctx_pic->bitstream_size <= 0)
444 return -1;
445
446 ret = ff_dxva2_common_end_frame(avctx, h->cur_frame.f,
447 &ctx_pic->pp, sizeof(ctx_pic->pp),
448 NULL, 0,
450
451 return ret;
452}
453
455{
457
458 av_freep(&ctx->bitstream_cache);
459 ctx->bitstream_allocated = 0;
460
461 return ff_dxva2_decode_uninit(avctx);
462}
463
464#if CONFIG_AV1_DXVA2_HWACCEL
466 .p.name = "av1_dxva2",
467 .p.type = AVMEDIA_TYPE_VIDEO,
468 .p.id = AV_CODEC_ID_AV1,
469 .p.pix_fmt = AV_PIX_FMT_DXVA2_VLD,
470 .init = ff_dxva2_decode_init,
471 .uninit = dxva2_av1_uninit,
472 .start_frame = dxva2_av1_start_frame,
473 .decode_slice = dxva2_av1_decode_slice,
474 .end_frame = dxva2_av1_end_frame,
475 .frame_params = ff_dxva2_common_frame_params,
476 .frame_priv_data_size = sizeof(struct av1_dxva2_picture_context),
477 .priv_data_size = sizeof(struct AV1DXVAContext),
478};
479#endif
480
481#if CONFIG_AV1_D3D11VA_HWACCEL
483 .p.name = "av1_d3d11va",
484 .p.type = AVMEDIA_TYPE_VIDEO,
485 .p.id = AV_CODEC_ID_AV1,
486 .p.pix_fmt = AV_PIX_FMT_D3D11VA_VLD,
487 .init = ff_dxva2_decode_init,
488 .uninit = dxva2_av1_uninit,
489 .start_frame = dxva2_av1_start_frame,
490 .decode_slice = dxva2_av1_decode_slice,
491 .end_frame = dxva2_av1_end_frame,
492 .frame_params = ff_dxva2_common_frame_params,
493 .frame_priv_data_size = sizeof(struct av1_dxva2_picture_context),
494 .priv_data_size = sizeof(struct AV1DXVAContext),
495};
496#endif
497
498#if CONFIG_AV1_D3D11VA2_HWACCEL
500 .p.name = "av1_d3d11va2",
501 .p.type = AVMEDIA_TYPE_VIDEO,
502 .p.id = AV_CODEC_ID_AV1,
503 .p.pix_fmt = AV_PIX_FMT_D3D11,
504 .init = ff_dxva2_decode_init,
505 .uninit = dxva2_av1_uninit,
506 .start_frame = dxva2_av1_start_frame,
507 .decode_slice = dxva2_av1_decode_slice,
508 .end_frame = dxva2_av1_end_frame,
509 .frame_params = ff_dxva2_common_frame_params,
510 .frame_priv_data_size = sizeof(struct av1_dxva2_picture_context),
511 .priv_data_size = sizeof(struct AV1DXVAContext),
512};
513#endif
static AVFormatContext * ctx
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:42
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define NULL
Definition coverity.c:32
#define MAX_TILES
Definition d3d12va_av1.c:31
int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
Definition dxva2.c:1068
unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx, AVDXVAContext *ctx, const AVFrame *frame, int curr)
Definition dxva2.c:783
int ff_dxva2_decode_init(AVCodecContext *avctx)
Definition dxva2.c:668
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:814
int ff_dxva2_decode_uninit(AVCodecContext *avctx)
Definition dxva2.c:743
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:903
int ff_dxva2_common_frame_params(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
Definition dxva2.c:602
int ff_dxva2_av1_fill_picture_parameters(const AVCodecContext *avctx, AVDXVAContext *ctx, DXVA_PicParams_AV1 *pp)
Definition dxva2_av1.c:60
static av_cold int dxva2_av1_uninit(AVCodecContext *avctx)
Definition dxva2_av1.c:454
static int commit_bitstream_and_slice_buffer(AVCodecContext *avctx, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *sc)
Definition dxva2_av1.c:351
static int dxva2_av1_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size)
Definition dxva2_av1.c:296
static int dxva2_av1_end_frame(AVCodecContext *avctx)
Definition dxva2_av1.c:437
#define MAX_TILES
Definition dxva2_av1.c:33
static int dxva2_av1_start_frame(AVCodecContext *avctx, av_unused const AVBufferRef *buffer_ref, av_unused const uint8_t *buffer, av_unused uint32_t size)
Definition dxva2_av1.c:274
static int get_bit_depth_from_seq(const AV1RawSequenceHeader *seq)
Definition dxva2_av1.c:50
#define DXVA_CONTEXT(avctx)
#define DXVA2_CONTEXT(ctx)
#define D3D11VA_CONTEXT(ctx)
#define DXVA_CONTEXT_VALID(avctx, ctx)
void DECODER_BUFFER_DESC
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN
Decoding only.
Definition avcodec.h:404
@ AV_CODEC_ID_AV1
Definition codec_id.h:275
#define AVERROR(e)
Definition error.h:45
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
Definition mem.c:495
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
const struct FFHWAccel ff_av1_d3d11va2_hwaccel
const struct FFHWAccel ff_av1_dxva2_hwaccel
const struct FFHWAccel ff_av1_d3d11va_hwaccel
cl_device_type type
@ AV1_REF_FRAME_LAST
Definition av1.h:63
@ AV1_RESTORE_WIENER
Definition av1.h:174
@ AV1_RESTORE_SWITCHABLE
Definition av1.h:176
@ AV1_RESTORE_NONE
Definition av1.h:173
@ AV1_RESTORE_SGRPROJ
Definition av1.h:175
@ AV1_SUPERRES_DENOM_MIN
Definition av1.h:102
@ AV1_SEG_LVL_MAX
Definition av1.h:90
@ AV1_SUPERRES_NUM
Definition av1.h:101
@ AV1_NUM_REF_FRAMES
Definition av1.h:84
@ AV1_MAX_SEGMENTS
Definition av1.h:89
@ AV1_REFS_PER_FRAME
Definition av1.h:85
@ AV1_TOTAL_REFS_PER_FRAME
Definition av1.h:86
static const chunk_decoder decoder[8]
Definition dfa.c:331
#define av_unused
Definition attributes.h:164
#define av_cold
Definition attributes.h:117
#define FFMIN(a, b)
Definition macros.h:49
Memory handling functions.
@ AV_PIX_FMT_DXVA2_VLD
HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer.
Definition pixfmt.h:134
@ AV_PIX_FMT_D3D11
Hardware surfaces for Direct3D11.
Definition pixfmt.h:336
@ AV_PIX_FMT_D3D11VA_VLD
HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView p...
Definition pixfmt.h:254
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Definition pixfmt.h:707
unsigned int bitstream_allocated
Definition dxva2_av1.c:38
FFDXVASharedContext shared
Definition dxva2_av1.c:36
uint8_t * bitstream_cache
Definition dxva2_av1.c:39
uint8_t twelve_bit
Definition cbs_av1.h:52
uint8_t matrix_coefficients
Definition cbs_av1.h:58
uint8_t subsampling_x
Definition cbs_av1.h:61
uint8_t high_bitdepth
Definition cbs_av1.h:51
uint8_t mono_chrome
Definition cbs_av1.h:53
uint8_t subsampling_y
Definition cbs_av1.h:62
uint8_t ar_coeffs_y_plus_128[24]
Definition cbs_av1.h:159
uint8_t ar_coeff_shift_minus_6
Definition cbs_av1.h:162
uint8_t point_y_value[14]
Definition cbs_av1.h:148
uint8_t grain_scale_shift
Definition cbs_av1.h:163
uint8_t point_cb_scaling[10]
Definition cbs_av1.h:153
uint8_t point_cr_scaling[10]
Definition cbs_av1.h:156
uint8_t ar_coeffs_cr_plus_128[25]
Definition cbs_av1.h:161
uint8_t clip_to_restricted_range
Definition cbs_av1.h:171
uint8_t point_cr_value[10]
Definition cbs_av1.h:155
uint8_t point_cb_value[10]
Definition cbs_av1.h:152
uint8_t chroma_scaling_from_luma
Definition cbs_av1.h:150
uint8_t grain_scaling_minus_8
Definition cbs_av1.h:157
uint8_t point_y_scaling[14]
Definition cbs_av1.h:149
uint8_t ar_coeffs_cb_plus_128[25]
Definition cbs_av1.h:160
uint8_t use_128x128_superblock
Definition cbs_av1.h:114
uint8_t enable_ref_frame_mvs
Definition cbs_av1.h:124
uint8_t enable_dual_filter
Definition cbs_av1.h:120
uint8_t enable_restoration
Definition cbs_av1.h:135
uint8_t enable_intra_edge_filter
Definition cbs_av1.h:116
uint16_t max_frame_height_minus_1
Definition cbs_av1.h:108
uint8_t enable_filter_intra
Definition cbs_av1.h:115
uint8_t seq_profile
Definition cbs_av1.h:83
uint8_t film_grain_params_present
Definition cbs_av1.h:139
uint8_t enable_jnt_comp
Definition cbs_av1.h:123
uint8_t enable_interintra_compound
Definition cbs_av1.h:117
AV1RawColorConfig color_config
Definition cbs_av1.h:137
uint8_t enable_masked_compound
Definition cbs_av1.h:118
uint8_t order_hint_bits_minus_1
Definition cbs_av1.h:131
uint16_t max_frame_width_minus_1
Definition cbs_av1.h:107
uint8_t enable_order_hint
Definition cbs_av1.h:122
A reference to a data buffer.
Definition buffer.h:82
main external API structure.
Definition avcodec.h:443
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
Definition avcodec.h:643
int width
picture width / height.
Definition avcodec.h:604
int export_side_data
Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of metadata exported in frame,...
Definition avcodec.h:1779
struct AVCodecInternal * internal
Private context used for internal data.
Definition avcodec.h:478
void * priv_data
Definition avcodec.h:470
void * hwaccel_priv_data
hwaccel-specific private data
Definition internal.h:130
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
DXVA_Tile_AV1 tiles[MAX_TILES]
Definition dxva2_av1.c:45
DXVA_PicParams_AV1 pp
Definition dxva2_av1.c:43
#define av_freep(p)
#define av_log(a,...)
static uint8_t tmp[40]
Definition aes_ctr.c:52
static char buffer[20]
Definition seek.c:32
int size
static int ref_frame(VVCFrame *dst, const VVCFrame *src)
Definition dec.c:616