1 /*
2 * AV1 HW decode acceleration through VDPAU
3 *
4 * Copyright (c) 2022 Manoj Gupta Bonda
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 Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <vdpau/vdpau.h>
31
33 {
37 return 10;
38 } else {
39 return 8;
40 }
41 }
42
45 {
50
53
55
56
57 VdpPictureInfoAV1 *
info = &pic_ctx->
info.av1;
59 if (!pixdesc) {
61 }
62
65
66
68
69 /* Sequence Header */
88
89 /* Frame Header */
103 info->disable_frame_end_update_cdf =
frame_header->disable_frame_end_update_cdf;
107 info->coded_lossless =
s->cur_frame.coded_lossless;
114
115 /* Tiling Info */
119
120 /* CDEF */
123
124 /* SkipModeFrames */
126 s->cur_frame.skip_mode_frame_idx[0] : 0;
128 s->cur_frame.skip_mode_frame_idx[1] : 0;
129
130 /* QP Information */
140
141 /* Segmentation */
145 info->segmentation_temporal_update =
frame_header->segmentation_temporal_update;
146
147 /* Loopfilter */
155 info->loop_filter_mode_deltas[0] =
frame_header->loop_filter_mode_deltas[0];
156 info->loop_filter_mode_deltas[1] =
frame_header->loop_filter_mode_deltas[1];
160
161 /* Restoration */
168
169 /* Reference Frames */
170 info->temporal_layer_id =
s->cur_frame.temporal_id;
171 info->spatial_layer_id =
s->cur_frame.spatial_id;
172
173 /* Film Grain Params */
192
193 /* Tiling Info */
196 }
199 }
200
201 /* CDEF */
205 }
206
207
208 /* Segmentation */
210 info->segmentation_feature_mask[
i] = 0;
214 }
215 }
216
218 /* Loopfilter */
220
221 /* Reference Frames */
223 }
224
226 info->primary_ref_frame = -1;
227 } else {
229 info->primary_ref_frame =
info->ref_frame_map[pri_ref_idx];
230 }
231
233 /* Ref Frame List */
236
237 info->ref_frame[
i].index =
info->ref_frame_map[ref_idx];
240
241 /* Global Motion */
244 for (j = 0; j < 6; ++j) {
246 }
247 }
248
249 /* Film Grain Params */
251 for (
i = 0;
i < 14; ++
i) {
254 }
255 for (
i = 0;
i < 10; ++
i) {
260 }
261 for (
i = 0;
i < 24; ++
i) {
263 }
264 for (
i = 0;
i < 25; ++
i) {
267 }
268 }
269
270
272
273 }
274
277 {
281 VdpPictureInfoAV1 *
info = &pic_ctx->
info.av1;
283 int nb_slices;
285 int bitstream_len = 0;
286
288 /* Shortcut if all tiles are in the same buffer*/
289 if (nb_slices ==
s->tg_end -
s->tg_start + 1) {
290 for (
int i = 0;
i < nb_slices; ++
i) {
291 info->tile_info[
i*2 ] =
s->tile_group_info[
i].tile_offset;
292 info->tile_info[
i*2 + 1] =
info->tile_info[
i*2] +
s->tile_group_info[
i].tile_size;
293 }
297 }
298
299 return 0;
300 }
301
303 bitstream_len += buffers->bitstream_bytes;
304 buffers++;
305 }
306
307 for (uint32_t tile_num =
s->tg_start; tile_num <= s->tg_end; ++tile_num) {
308 info->tile_info[tile_num*2 ] = bitstream_len +
s->tile_group_info[tile_num].tile_offset;
309 info->tile_info[tile_num*2 + 1] =
info->tile_info[tile_num*2] +
s->tile_group_info[tile_num].tile_size;
310 }
311
315 }
316
317 return 0;
318 }
319
321 {
324
326
330
331 return 0;
332 }
333
335 {
338
341 profile = VDP_DECODER_PROFILE_AV1_MAIN;
342 break;
344 profile = VDP_DECODER_PROFILE_AV1_HIGH;
345 break;
347 profile = VDP_DECODER_PROFILE_AV1_PROFESSIONAL;
348 break;
349 default:
351 }
352
354 }
355
357 .
p.
name =
"av1_vdpau",
370 };