]> git.pld-linux.org Git - packages/ffmpeg.git/blame - ffmpeg-vulkan1.3.280.patch
- added patch for vulkan sdk 1.3.280, note on ffmpeg 7
[packages/ffmpeg.git] / ffmpeg-vulkan1.3.280.patch
CommitLineData
e8591a3e
JB
1From 998aa66a10546be207d5dfc1a4a76bc2ce9ea07c Mon Sep 17 00:00:00 2001
2From: Lynne <dev@lynne.ee>
3Date: Sun, 17 Mar 2024 19:31:17 +0100
4Subject: [PATCH] av1dec: add AV1_REF_FRAME_NONE
5
6---
7 libavcodec/av1.h | 1 +
8 libavcodec/cbs_av1_syntax_template.c | 12 ++++++------
9 2 files changed, 7 insertions(+), 6 deletions(-)
10
11diff --git a/libavcodec/av1.h b/libavcodec/av1.h
12index 8704bc41c1..94e88f8484 100644
13--- a/libavcodec/av1.h
14+++ b/libavcodec/av1.h
15@@ -58,6 +58,7 @@ enum {
16
17 // Reference frames (section 6.10.24).
18 enum {
19+ AV1_REF_FRAME_NONE = -1,
20 AV1_REF_FRAME_INTRA = 0,
21 AV1_REF_FRAME_LAST = 1,
22 AV1_REF_FRAME_LAST2 = 2,
23diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
24index 2979c5d98f..3f4b13a177 100644
25--- a/libavcodec/cbs_av1_syntax_template.c
26+++ b/libavcodec/cbs_av1_syntax_template.c
27@@ -360,7 +360,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw,
28 int i, j;
29
30 for (i = 0; i < AV1_REFS_PER_FRAME; i++)
31- ref_frame_idx[i] = -1;
32+ ref_frame_idx[i] = AV1_REF_FRAME_NONE;
33 ref_frame_idx[AV1_REF_FRAME_LAST - AV1_REF_FRAME_LAST] = current->last_frame_idx;
34 ref_frame_idx[AV1_REF_FRAME_GOLDEN - AV1_REF_FRAME_LAST] = current->golden_frame_idx;
35
36@@ -378,7 +378,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw,
37 latest_order_hint = shifted_order_hints[current->last_frame_idx];
38 earliest_order_hint = shifted_order_hints[current->golden_frame_idx];
39
40- ref = -1;
41+ ref = AV1_REF_FRAME_NONE;
42 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
43 int hint = shifted_order_hints[i];
44 if (!used_frame[i] && hint >= cur_frame_hint &&
45@@ -392,7 +392,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw,
46 used_frame[ref] = 1;
47 }
48
49- ref = -1;
50+ ref = AV1_REF_FRAME_NONE;
51 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
52 int hint = shifted_order_hints[i];
53 if (!used_frame[i] && hint >= cur_frame_hint &&
54@@ -406,7 +406,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw,
55 used_frame[ref] = 1;
56 }
57
58- ref = -1;
59+ ref = AV1_REF_FRAME_NONE;
60 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
61 int hint = shifted_order_hints[i];
62 if (!used_frame[i] && hint >= cur_frame_hint &&
63@@ -423,7 +423,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw,
64 for (i = 0; i < AV1_REFS_PER_FRAME - 2; i++) {
65 int ref_frame = ref_frame_list[i];
66 if (ref_frame_idx[ref_frame - AV1_REF_FRAME_LAST] < 0 ) {
67- ref = -1;
68+ ref = AV1_REF_FRAME_NONE;
69 for (j = 0; j < AV1_NUM_REF_FRAMES; j++) {
70 int hint = shifted_order_hints[j];
71 if (!used_frame[j] && hint < cur_frame_hint &&
72@@ -439,7 +439,7 @@ static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw,
73 }
74 }
75
76- ref = -1;
77+ ref = AV1_REF_FRAME_NONE;
78 for (i = 0; i < AV1_NUM_REF_FRAMES; i++) {
79 int hint = shifted_order_hints[i];
80 if (ref < 0 || hint < earliest_order_hint) {
81--
822.25.1
83
84From cafb4c554845332eeb33284cf6498049997dc67e Mon Sep 17 00:00:00 2001
85From: Mark Thompson <sw@jkqxz.net>
86Date: Wed, 20 Mar 2024 20:35:28 +0000
87Subject: [PATCH] lavc/cbs_av1: Save more frame ordering information
88
89This is wanted by the Vulkan decoder.
90---
91 libavcodec/cbs_av1.h | 5 +++++
92 libavcodec/cbs_av1_syntax_template.c | 25 +++++++++++++++++++++----
93 2 files changed, 26 insertions(+), 4 deletions(-)
94
95diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
96index a5402f069d..a027013bc7 100644
97--- a/libavcodec/cbs_av1.h
98+++ b/libavcodec/cbs_av1.h
99@@ -427,6 +427,8 @@ typedef struct AV1ReferenceFrameState {
100 int bit_depth; // RefBitDepth
101 int order_hint; // RefOrderHint
102
103+ int saved_order_hints[AV1_TOTAL_REFS_PER_FRAME]; // SavedOrderHints[ref]
104+
105 int8_t loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME];
106 int8_t loop_filter_mode_deltas[2];
107 uint8_t feature_enabled[AV1_MAX_SEGMENTS][AV1_SEG_LVL_MAX];
108@@ -464,6 +466,9 @@ typedef struct CodedBitstreamAV1Context {
109 int tile_rows;
110 int tile_num;
111
112+ int order_hints[AV1_TOTAL_REFS_PER_FRAME]; // OrderHints
113+ int ref_frame_sign_bias[AV1_TOTAL_REFS_PER_FRAME]; // RefFrameSignBias
114+
115 AV1ReferenceFrameState ref[AV1_NUM_REF_FRAMES];
116
117 // AVOptions
118diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
119index 3be1f2d30f..2979c5d98f 100644
120--- a/libavcodec/cbs_av1_syntax_template.c
121+++ b/libavcodec/cbs_av1_syntax_template.c
122@@ -1414,6 +1414,8 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
123 priv->ref[i].valid = 0;
124 priv->ref[i].order_hint = 0;
125 }
126+ for (i = 0; i < AV1_REFS_PER_FRAME; i++)
127+ priv->order_hints[i + AV1_REF_FRAME_LAST] = 0;
128 }
129
130 flag(disable_cdf_update);
131@@ -1568,11 +1570,20 @@ static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw,
132 else
133 flag(use_ref_frame_mvs);
134
135- infer(allow_intrabc, 0);
136- }
137+ for (i = 0; i < AV1_REFS_PER_FRAME; i++) {
138+ int ref_frame = AV1_REF_FRAME_LAST + i;
139+ int hint = priv->ref[current->ref_frame_idx[i]].order_hint;
140+ priv->order_hints[ref_frame] = hint;
141+ if (!seq->enable_order_hint) {
142+ priv->ref_frame_sign_bias[ref_frame] = 0;
143+ } else {
144+ priv->ref_frame_sign_bias[ref_frame] =
145+ cbs_av1_get_relative_dist(seq, hint,
146+ current->order_hint) > 0;
147+ }
148+ }
149
150- if (!frame_is_intra) {
151- // Derive reference frame sign biases.
152+ infer(allow_intrabc, 0);
153 }
154
155 if (seq->reduced_still_picture_header || current->disable_cdf_update)
156@@ -1674,6 +1685,12 @@ update_refs:
157 .bit_depth = priv->bit_depth,
158 .order_hint = priv->order_hint,
159 };
160+
161+ for (int j = 0; j < AV1_REFS_PER_FRAME; j++) {
162+ priv->ref[i].saved_order_hints[j + AV1_REF_FRAME_LAST] =
163+ priv->order_hints[j + AV1_REF_FRAME_LAST];
164+ }
165+
166 memcpy(priv->ref[i].loop_filter_ref_deltas, current->loop_filter_ref_deltas,
167 sizeof(current->loop_filter_ref_deltas));
168 memcpy(priv->ref[i].loop_filter_mode_deltas, current->loop_filter_mode_deltas,
169--
1702.25.1
171
172From: Lynne <dev@lynne.ee>
173Date: Fri, 19 Jan 2024 00:49:02 +0000 (+1000)
174Subject: vulkan_av1: port to the new stable API
175X-Git-Tag: n7.0~143
176X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/ecdc94b97f809d5f2b88640842fd0541951ad295
177
178vulkan_av1: port to the new stable API
179
180Co-Authored-by: Dave Airlie <airlied@redhat.com>
181---
182
183--- ffmpeg-6.1.1/configure.orig 2024-04-15 21:35:22.596075876 +0200
184+++ ffmpeg-6.1.1/configure 2024-04-15 21:41:06.030881997 +0200
185@@ -7150,8 +7150,8 @@ enabled crystalhd && check_lib crystalhd
186 "in maintaining it."
187
188 if enabled vulkan; then
189- check_pkg_config_header_only vulkan "vulkan >= 1.3.255" "vulkan/vulkan.h" "defined VK_VERSION_1_3" ||
190- check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 255)"
191+ check_pkg_config_header_only vulkan "vulkan >= 1.3.277" "vulkan/vulkan.h" "defined VK_VERSION_1_3" ||
192+ check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 277)"
193 fi
194
195 if disabled vulkan; then
196--- ffmpeg-6.1.1/libavcodec/Makefile.orig 2024-04-15 21:35:22.596075876 +0200
197+++ ffmpeg-6.1.1/libavcodec/Makefile 2024-04-15 21:43:51.719984382 +0200
198@@ -1284,7 +1284,6 @@ SKIPHEADERS +
199 aacenc_quantization.h \
200 aacenc_quantization_misc.h \
201 bitstream_template.h \
202- vulkan_video_codec_av1std.h \
203 $(ARCH)/vpx_arith.h \
204
205 SKIPHEADERS-$(CONFIG_AMF) += amfenc.h
206@@ -1306,7 +1305,7 @@ SKIPHEADERS-$(CONFIG_XVMC) +
207 SKIPHEADERS-$(CONFIG_VAAPI) += vaapi_decode.h vaapi_hevc.h vaapi_encode.h
208 SKIPHEADERS-$(CONFIG_VDPAU) += vdpau.h vdpau_internal.h
209 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h
210-SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h vulkan_video_codec_av1std_decode.h
211+SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h
212 SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h
213 SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h
214
215diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c
216index 5afd5353cc..c9e398eaec 100644
217--- a/libavcodec/vulkan_av1.c
218+++ b/libavcodec/vulkan_av1.c
219@@ -36,33 +36,47 @@ const FFVulkanDecodeDescriptor ff_vk_dec_av1_desc = {
220 typedef struct AV1VulkanDecodePicture {
221 FFVulkanDecodePicture vp;
222
223- /* Workaround for a spec issue.
224- *Can be removed once no longer needed, and threading can be enabled. */
225+ /* TODO: investigate if this can be removed to make decoding completely
226+ * independent. */
227 FFVulkanDecodeContext *dec;
228
229- StdVideoAV1MESATile tiles[MAX_TILES];
230- StdVideoAV1MESATileList tile_list;
231- const uint32_t *tile_offsets;
232+ uint32_t tile_sizes[MAX_TILES];
233
234 /* Current picture */
235- VkVideoDecodeAV1DpbSlotInfoMESA vkav1_ref;
236- StdVideoAV1MESAFrameHeader av1_frame_header;
237- VkVideoDecodeAV1PictureInfoMESA av1_pic_info;
238+ StdVideoDecodeAV1ReferenceInfo std_ref;
239+ VkVideoDecodeAV1DpbSlotInfoKHR vkav1_ref;
240+ uint16_t width_in_sbs_minus1[64];
241+ uint16_t height_in_sbs_minus1[64];
242+ uint16_t mi_col_starts[64];
243+ uint16_t mi_row_starts[64];
244+ StdVideoAV1TileInfo tile_info;
245+ StdVideoAV1Quantization quantization;
246+ StdVideoAV1Segmentation segmentation;
247+ StdVideoAV1LoopFilter loop_filter;
248+ StdVideoAV1CDEF cdef;
249+ StdVideoAV1LoopRestoration loop_restoration;
250+ StdVideoAV1GlobalMotion global_motion;
251+ StdVideoAV1FilmGrain film_grain;
252+ StdVideoDecodeAV1PictureInfo std_pic_info;
253+ VkVideoDecodeAV1PictureInfoKHR av1_pic_info;
254
255 /* Picture refs */
256 const AV1Frame *ref_src [AV1_NUM_REF_FRAMES];
257- VkVideoDecodeAV1DpbSlotInfoMESA vkav1_refs[AV1_NUM_REF_FRAMES];
258+ StdVideoDecodeAV1ReferenceInfo std_refs [AV1_NUM_REF_FRAMES];
259+ VkVideoDecodeAV1DpbSlotInfoKHR vkav1_refs[AV1_NUM_REF_FRAMES];
260
261 uint8_t frame_id_set;
262 uint8_t frame_id;
263+ uint8_t ref_frame_sign_bias_mask;
264 } AV1VulkanDecodePicture;
265
266 static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src,
267 VkVideoReferenceSlotInfoKHR *ref_slot, /* Main structure */
268 VkVideoPictureResourceInfoKHR *ref, /* Goes in ^ */
269- VkVideoDecodeAV1DpbSlotInfoMESA *vkav1_ref, /* Goes in ^ */
270+ StdVideoDecodeAV1ReferenceInfo *vkav1_std_ref,
271+ VkVideoDecodeAV1DpbSlotInfoKHR *vkav1_ref, /* Goes in ^ */
272 const AV1Frame *pic, int is_current, int has_grain,
273- int dpb_slot_index)
274+ int *saved_order_hints)
275 {
276 FFVulkanDecodeContext *dec = avctx->internal->hwaccel_priv_data;
277 AV1VulkanDecodePicture *hp = pic->hwaccel_picture_private;
278@@ -73,31 +87,42 @@ static int vk_av1_fill_pict(AVCodecContext *avctx, const AV1Frame **ref_src,
279 if (err < 0)
280 return err;
281
282- *vkav1_ref = (VkVideoDecodeAV1DpbSlotInfoMESA) {
283- .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_MESA,
284- .frameIdx = hp->frame_id,
285+ *vkav1_std_ref = (StdVideoDecodeAV1ReferenceInfo) {
286+ .flags = (StdVideoDecodeAV1ReferenceInfoFlags) {
287+ .disable_frame_end_update_cdf = pic->raw_frame_header->disable_frame_end_update_cdf,
288+ .segmentation_enabled = pic->raw_frame_header->segmentation_enabled,
289+ },
290+ .frame_type = pic->raw_frame_header->frame_type,
291+ .OrderHint = pic->raw_frame_header->order_hint,
292+ .RefFrameSignBias = hp->ref_frame_sign_bias_mask,
293 };
294
295- for (unsigned i = 0; i < 7; i++) {
296- const int idx = pic->raw_frame_header->ref_frame_idx[i];
297- vkav1_ref->ref_order_hint[i] = pic->raw_frame_header->ref_order_hint[idx];
298- }
299+ if (saved_order_hints)
300+ for (int i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++)
301+ vkav1_std_ref->SavedOrderHints[i] = saved_order_hints[i];
302+
303+ *vkav1_ref = (VkVideoDecodeAV1DpbSlotInfoKHR) {
304+ .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_KHR,
305+ .pStdReferenceInfo = vkav1_std_ref,
306+ };
307
308- vkav1_ref->disable_frame_end_update_cdf = pic->raw_frame_header->disable_frame_end_update_cdf;
309+ vkav1_std_ref->flags.disable_frame_end_update_cdf = pic->raw_frame_header->disable_frame_end_update_cdf;
310+ vkav1_std_ref->flags.segmentation_enabled = pic->raw_frame_header->segmentation_enabled;
311+ vkav1_std_ref->frame_type = pic->raw_frame_header->frame_type;
312
313 *ref = (VkVideoPictureResourceInfoKHR) {
314 .sType = VK_STRUCTURE_TYPE_VIDEO_PICTURE_RESOURCE_INFO_KHR,
315 .codedOffset = (VkOffset2D){ 0, 0 },
316 .codedExtent = (VkExtent2D){ pic->f->width, pic->f->height },
317 .baseArrayLayer = ((has_grain || dec->dedicated_dpb) && dec->layered_dpb) ?
318- dpb_slot_index : 0,
319+ hp->frame_id : 0,
320 .imageViewBinding = vkpic->img_view_ref,
321 };
322
323 *ref_slot = (VkVideoReferenceSlotInfoKHR) {
324 .sType = VK_STRUCTURE_TYPE_VIDEO_REFERENCE_SLOT_INFO_KHR,
325 .pNext = vkav1_ref,
326- .slotIndex = dpb_slot_index,
327+ .slotIndex = hp->frame_id,
328 .pPictureResource = ref,
329 };
330
331@@ -115,15 +140,40 @@ static int vk_av1_create_params(AVCodecContext *avctx, AVBufferRef **buf)
332
333 const AV1RawSequenceHeader *seq = s->raw_seq;
334
335- StdVideoAV1MESASequenceHeader av1_sequence_header;
336- VkVideoDecodeAV1SessionParametersAddInfoMESA av1_params_info;
337- VkVideoDecodeAV1SessionParametersCreateInfoMESA av1_params;
338+ StdVideoAV1SequenceHeader av1_sequence_header;
339+ StdVideoAV1TimingInfo av1_timing_info;
340+ StdVideoAV1ColorConfig av1_color_config;
341+ VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params;
342 VkVideoSessionParametersCreateInfoKHR session_params_create;
343
344 int err;
345
346- av1_sequence_header = (StdVideoAV1MESASequenceHeader) {
347- .flags = (StdVideoAV1MESASequenceHeaderFlags) {
348+ av1_timing_info = (StdVideoAV1TimingInfo) {
349+ .flags = (StdVideoAV1TimingInfoFlags) {
350+ .equal_picture_interval = seq->timing_info.equal_picture_interval,
351+ },
352+ .num_units_in_display_tick = seq->timing_info.num_units_in_display_tick,
353+ .time_scale = seq->timing_info.time_scale,
354+ .num_ticks_per_picture_minus_1 = seq->timing_info.num_ticks_per_picture_minus_1,
355+ };
356+
357+ av1_color_config = (StdVideoAV1ColorConfig) {
358+ .flags = (StdVideoAV1ColorConfigFlags) {
359+ .mono_chrome = seq->color_config.mono_chrome,
360+ .color_range = seq->color_config.color_range,
361+ .separate_uv_delta_q = seq->color_config.separate_uv_delta_q,
362+ },
363+ .BitDepth = seq->color_config.twelve_bit ? 12 :
364+ seq->color_config.high_bitdepth ? 10 : 8,
365+ .subsampling_x = seq->color_config.subsampling_x,
366+ .subsampling_y = seq->color_config.subsampling_y,
367+ .color_primaries = seq->color_config.color_primaries,
368+ .transfer_characteristics = seq->color_config.transfer_characteristics,
369+ .matrix_coefficients = seq->color_config.matrix_coefficients,
370+ };
371+
372+ av1_sequence_header = (StdVideoAV1SequenceHeader) {
373+ .flags = (StdVideoAV1SequenceHeaderFlags) {
374 .still_picture = seq->still_picture,
375 .reduced_still_picture_header = seq->reduced_still_picture_header,
376 .use_128x128_superblock = seq->use_128x128_superblock,
377@@ -152,34 +202,15 @@ static int vk_av1_create_params(AVCodecContext *avctx, AVBufferRef **buf)
378 .delta_frame_id_length_minus_2 = seq->delta_frame_id_length_minus_2,
379 .additional_frame_id_length_minus_1 = seq->additional_frame_id_length_minus_1,
380 .order_hint_bits_minus_1 = seq->order_hint_bits_minus_1,
381- .timing_info = (StdVideoAV1MESATimingInfo) {
382- .flags = (StdVideoAV1MESATimingInfoFlags) {
383- .equal_picture_interval = seq->timing_info.equal_picture_interval,
384- },
385- .num_units_in_display_tick = seq->timing_info.num_units_in_display_tick,
386- .time_scale = seq->timing_info.time_scale,
387- .num_ticks_per_picture_minus_1 = seq->timing_info.num_ticks_per_picture_minus_1,
388- },
389- .color_config = (StdVideoAV1MESAColorConfig) {
390- .flags = (StdVideoAV1MESAColorConfigFlags) {
391- .mono_chrome = seq->color_config.mono_chrome,
392- .color_range = seq->color_config.color_range,
393- .separate_uv_delta_q = seq->color_config.separate_uv_delta_q,
394- },
395- .bit_depth = seq->color_config.twelve_bit ? 12 :
396- seq->color_config.high_bitdepth ? 10 : 8,
397- .subsampling_x = seq->color_config.subsampling_x,
398- .subsampling_y = seq->color_config.subsampling_y,
399- },
400+ .seq_force_integer_mv = seq->seq_force_integer_mv,
401+ .seq_force_screen_content_tools = seq->seq_force_screen_content_tools,
402+ .pTimingInfo = &av1_timing_info,
403+ .pColorConfig = &av1_color_config,
404 };
405
406- av1_params_info = (VkVideoDecodeAV1SessionParametersAddInfoMESA) {
407- .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_ADD_INFO_MESA,
408- .sequence_header = &av1_sequence_header,
409- };
410- av1_params = (VkVideoDecodeAV1SessionParametersCreateInfoMESA) {
411- .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_MESA,
412- .pParametersAddInfo = &av1_params_info,
413+ av1_params = (VkVideoDecodeAV1SessionParametersCreateInfoKHR) {
414+ .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
415+ .pStdSequenceHeader = &av1_sequence_header,
416 };
417 session_params_create = (VkVideoSessionParametersCreateInfoKHR) {
418 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
419@@ -211,8 +242,14 @@ static int vk_av1_start_frame(AVCodecContext *avctx,
420
421 const AV1RawFrameHeader *frame_header = s->raw_frame_header;
422 const AV1RawFilmGrainParams *film_grain = &s->cur_frame.film_grain;
423+ CodedBitstreamAV1Context *cbs_ctx = (CodedBitstreamAV1Context *)(s->cbc->priv_data);
424+
425 const int apply_grain = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN) &&
426 film_grain->apply_grain;
427+ StdVideoAV1FrameRestorationType remap_lr_type[4] = { STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_NONE,
428+ STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SWITCHABLE,
429+ STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_WIENER,
430+ STD_VIDEO_AV1_FRAME_RESTORATION_TYPE_SGRPROJ };
431
432 if (!dec->session_params) {
433 err = vk_av1_create_params(avctx, &dec->session_params);
434@@ -233,15 +270,31 @@ static int vk_av1_start_frame(AVCodecContext *avctx,
435 dec->frame_id_alloc_mask |= (1 << slot_idx);
436 }
437
438- /* Fill in references */
439- for (int i = 0; i < AV1_NUM_REF_FRAMES; i++) {
440- const AV1Frame *ref_frame = &s->ref[i];
441- if (s->ref[i].f->pict_type == AV_PICTURE_TYPE_NONE)
442+ ap->ref_frame_sign_bias_mask = 0x0;
443+ for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
444+ ap->ref_frame_sign_bias_mask |= cbs_ctx->ref_frame_sign_bias[i] << i;
445+
446+ for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) {
447+ const int idx = pic->raw_frame_header->ref_frame_idx[i];
448+ const AV1Frame *ref_frame = &s->ref[idx];
449+ AV1VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private;
450+ int found = 0;
451+
452+ if (ref_frame->f->pict_type == AV_PICTURE_TYPE_NONE)
453+ continue;
454+
455+ for (int j = 0; j < ref_count; j++) {
456+ if (vp->ref_slots[j].slotIndex == hp->frame_id) {
457+ found = 1;
458+ break;
459+ }
460+ }
461+ if (found)
462 continue;
463
464- err = vk_av1_fill_pict(avctx, &ap->ref_src[i], &vp->ref_slots[i],
465- &vp->refs[i], &ap->vkav1_refs[i],
466- ref_frame, 0, 0, i);
467+ err = vk_av1_fill_pict(avctx, &ap->ref_src[ref_count], &vp->ref_slots[ref_count],
468+ &vp->refs[ref_count], &ap->std_refs[ref_count], &ap->vkav1_refs[ref_count],
469+ ref_frame, 0, 0, cbs_ctx->ref[idx].saved_order_hints);
470 if (err < 0)
471 return err;
472
473@@ -249,20 +302,32 @@ static int vk_av1_start_frame(AVCodecContext *avctx,
474 }
475
476 err = vk_av1_fill_pict(avctx, NULL, &vp->ref_slot, &vp->ref,
477+ &ap->std_ref,
478 &ap->vkav1_ref,
479- pic, 1, apply_grain, 8);
480+ pic, 1, apply_grain, NULL);
481 if (err < 0)
482 return err;
483
484- ap->tile_list.nb_tiles = 0;
485- ap->tile_list.tile_list = ap->tiles;
486-
487- ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoMESA) {
488- .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_MESA,
489- .frame_header = &ap->av1_frame_header,
490- .tile_list = &ap->tile_list,
491+ ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoKHR) {
492+ .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_KHR,
493+ .pStdPictureInfo = &ap->std_pic_info,
494+ .frameHeaderOffset = 0,
495+ .tileCount = 0,
496+ .pTileOffsets = NULL,
497+ .pTileSizes = ap->tile_sizes,
498 };
499
500+ for (int i = 0; i < STD_VIDEO_AV1_REFS_PER_FRAME; i++) {
501+ const int idx = pic->raw_frame_header->ref_frame_idx[i];
502+ const AV1Frame *ref_frame = &s->ref[idx];
503+ AV1VulkanDecodePicture *hp = ref_frame->hwaccel_picture_private;
504+
505+ if (ref_frame->f->pict_type == AV_PICTURE_TYPE_NONE)
506+ ap->av1_pic_info.referenceNameSlotIndices[i] = AV1_REF_FRAME_NONE;
507+ else
508+ ap->av1_pic_info.referenceNameSlotIndices[i] = hp->frame_id;
509+ }
510+
511 vp->decode_info = (VkVideoDecodeInfoKHR) {
512 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_INFO_KHR,
513 .pNext = &ap->av1_pic_info,
514@@ -279,9 +344,87 @@ static int vk_av1_start_frame(AVCodecContext *avctx,
515 },
516 };
517
518+ ap->tile_info = (StdVideoAV1TileInfo) {
519+ .flags = (StdVideoAV1TileInfoFlags) {
520+ .uniform_tile_spacing_flag = frame_header->uniform_tile_spacing_flag,
521+ },
522+ .TileCols = frame_header->tile_cols,
523+ .TileRows = frame_header->tile_rows,
524+ .context_update_tile_id = frame_header->context_update_tile_id,
525+ .tile_size_bytes_minus_1 = frame_header->tile_size_bytes_minus1,
526+ .pWidthInSbsMinus1 = ap->width_in_sbs_minus1,
527+ .pHeightInSbsMinus1 = ap->height_in_sbs_minus1,
528+ .pMiColStarts = ap->mi_col_starts,
529+ .pMiRowStarts = ap->mi_row_starts,
530+ };
531+
532+ ap->quantization = (StdVideoAV1Quantization) {
533+ .flags.using_qmatrix = frame_header->using_qmatrix,
534+ .flags.diff_uv_delta = frame_header->diff_uv_delta,
535+ .base_q_idx = frame_header->base_q_idx,
536+ .DeltaQYDc = frame_header->delta_q_y_dc,
537+ .DeltaQUDc = frame_header->delta_q_u_dc,
538+ .DeltaQUAc = frame_header->delta_q_u_ac,
539+ .DeltaQVDc = frame_header->delta_q_v_dc,
540+ .DeltaQVAc = frame_header->delta_q_v_ac,
541+ .qm_y = frame_header->qm_y,
542+ .qm_u = frame_header->qm_u,
543+ .qm_v = frame_header->qm_v,
544+ };
545+
546+ ap->loop_filter = (StdVideoAV1LoopFilter) {
547+ .flags = (StdVideoAV1LoopFilterFlags) {
548+ .loop_filter_delta_enabled = frame_header->loop_filter_delta_enabled,
549+ .loop_filter_delta_update = frame_header->loop_filter_delta_update,
550+ },
551+ .loop_filter_sharpness = frame_header->loop_filter_sharpness,
552+ };
553+
554+ for (int i = 0; i < STD_VIDEO_AV1_MAX_LOOP_FILTER_STRENGTHS; i++)
555+ ap->loop_filter.loop_filter_level[i] = frame_header->loop_filter_level[i];
556+ for (int i = 0; i < STD_VIDEO_AV1_LOOP_FILTER_ADJUSTMENTS; i++)
557+ ap->loop_filter.loop_filter_mode_deltas[i] = frame_header->loop_filter_mode_deltas[i];
558+
559+ ap->cdef = (StdVideoAV1CDEF) {
560+ .cdef_damping_minus_3 = frame_header->cdef_damping_minus_3,
561+ .cdef_bits = frame_header->cdef_bits,
562+ };
563+
564+ ap->loop_restoration = (StdVideoAV1LoopRestoration) {
565+ .FrameRestorationType[0] = remap_lr_type[frame_header->lr_type[0]],
566+ .FrameRestorationType[1] = remap_lr_type[frame_header->lr_type[1]],
567+ .FrameRestorationType[2] = remap_lr_type[frame_header->lr_type[2]],
568+ .LoopRestorationSize[0] = 1 + frame_header->lr_unit_shift,
569+ .LoopRestorationSize[1] = 1 + frame_header->lr_unit_shift - frame_header->lr_uv_shift,
570+ .LoopRestorationSize[2] = 1 + frame_header->lr_unit_shift - frame_header->lr_uv_shift,
571+ };
572+
573+ ap->film_grain = (StdVideoAV1FilmGrain) {
574+ .flags = (StdVideoAV1FilmGrainFlags) {
575+ .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
576+ .overlap_flag = film_grain->overlap_flag,
577+ .clip_to_restricted_range = film_grain->clip_to_restricted_range,
578+ },
579+ .grain_scaling_minus_8 = film_grain->grain_scaling_minus_8,
580+ .ar_coeff_lag = film_grain->ar_coeff_lag,
581+ .ar_coeff_shift_minus_6 = film_grain->ar_coeff_shift_minus_6,
582+ .grain_scale_shift = film_grain->grain_scale_shift,
583+ .grain_seed = film_grain->grain_seed,
584+ .film_grain_params_ref_idx = film_grain->film_grain_params_ref_idx,
585+ .num_y_points = film_grain->num_y_points,
586+ .num_cb_points = film_grain->num_cb_points,
587+ .num_cr_points = film_grain->num_cr_points,
588+ .cb_mult = film_grain->cb_mult,
589+ .cb_luma_mult = film_grain->cb_luma_mult,
590+ .cb_offset = film_grain->cb_offset,
591+ .cr_mult = film_grain->cr_mult,
592+ .cr_luma_mult = film_grain->cr_luma_mult,
593+ .cr_offset = film_grain->cr_offset,
594+ };
595+
596 /* Setup frame header */
597- ap->av1_frame_header = (StdVideoAV1MESAFrameHeader) {
598- .flags = (StdVideoAV1MESAFrameHeaderFlags) {
599+ ap->std_pic_info = (StdVideoDecodeAV1PictureInfo) {
600+ .flags = (StdVideoDecodeAV1PictureInfoFlags) {
601 .error_resilient_mode = frame_header->error_resilient_mode,
602 .disable_cdf_update = frame_header->disable_cdf_update,
603 .use_superres = frame_header->use_superres,
604@@ -302,174 +445,92 @@ static int vk_av1_start_frame(AVCodecContext *avctx,
605 .reference_select = frame_header->reference_select,
606 .skip_mode_present = frame_header->skip_mode_present,
607 .delta_q_present = frame_header->delta_q_present,
608+ .delta_lf_present = frame_header->delta_lf_present,
609+ .delta_lf_multi = frame_header->delta_lf_multi,
610+ .segmentation_enabled = frame_header->segmentation_enabled,
611+ .segmentation_update_map = frame_header->segmentation_update_map,
612+ .segmentation_temporal_update = frame_header->segmentation_temporal_update,
613+ .segmentation_update_data = frame_header->segmentation_update_data,
614+ .UsesLr = frame_header->lr_type[0] || frame_header->lr_type[1] || frame_header->lr_type[2],
615+ .apply_grain = apply_grain,
616 },
617- .frame_to_show_map_idx = frame_header->frame_to_show_map_idx,
618- .frame_presentation_time = frame_header->frame_presentation_time,
619- .display_frame_id = frame_header->display_frame_id,
620 .frame_type = frame_header->frame_type,
621 .current_frame_id = frame_header->current_frame_id,
622- .order_hint = frame_header->order_hint,
623+ .OrderHint = frame_header->order_hint,
624 .primary_ref_frame = frame_header->primary_ref_frame,
625- .frame_width_minus_1 = frame_header->frame_width_minus_1,
626- .frame_height_minus_1 = frame_header->frame_height_minus_1,
627- .coded_denom = frame_header->coded_denom,
628- .render_width_minus_1 = frame_header->render_width_minus_1,
629- .render_height_minus_1 = frame_header->render_height_minus_1,
630 .refresh_frame_flags = frame_header->refresh_frame_flags,
631 .interpolation_filter = frame_header->interpolation_filter,
632- .tx_mode = frame_header->tx_mode,
633- .tiling = (StdVideoAV1MESATileInfo) {
634- .flags = (StdVideoAV1MESATileInfoFlags) {
635- .uniform_tile_spacing_flag = frame_header->uniform_tile_spacing_flag,
636- },
637- .tile_cols = frame_header->tile_cols,
638- .tile_rows = frame_header->tile_rows,
639- .context_update_tile_id = frame_header->context_update_tile_id,
640- .tile_size_bytes_minus1 = frame_header->tile_size_bytes_minus1,
641- },
642- .quantization = (StdVideoAV1MESAQuantization) {
643- .flags.using_qmatrix = frame_header->using_qmatrix,
644- .base_q_idx = frame_header->base_q_idx,
645- .delta_q_y_dc = frame_header->delta_q_y_dc,
646- .diff_uv_delta = frame_header->diff_uv_delta,
647- .delta_q_u_dc = frame_header->delta_q_u_dc,
648- .delta_q_u_ac = frame_header->delta_q_u_ac,
649- .delta_q_v_dc = frame_header->delta_q_v_dc,
650- .delta_q_v_ac = frame_header->delta_q_v_ac,
651- .qm_y = frame_header->qm_y,
652- .qm_u = frame_header->qm_u,
653- .qm_v = frame_header->qm_v,
654- },
655- .delta_q = (StdVideoAV1MESADeltaQ) {
656- .flags = (StdVideoAV1MESADeltaQFlags) {
657- .delta_lf_present = frame_header->delta_lf_present,
658- .delta_lf_multi = frame_header->delta_lf_multi,
659- },
660- .delta_q_res = frame_header->delta_q_res,
661- .delta_lf_res = frame_header->delta_lf_res,
662- },
663- .loop_filter = (StdVideoAV1MESALoopFilter) {
664- .flags = (StdVideoAV1MESALoopFilterFlags) {
665- .delta_enabled = frame_header->loop_filter_delta_enabled,
666- .delta_update = frame_header->loop_filter_delta_update,
667- },
668- .level = {
669- frame_header->loop_filter_level[0], frame_header->loop_filter_level[1],
670- frame_header->loop_filter_level[2], frame_header->loop_filter_level[3],
671- },
672- .sharpness = frame_header->loop_filter_sharpness,
673- .mode_deltas = {
674- frame_header->loop_filter_mode_deltas[0], frame_header->loop_filter_mode_deltas[1],
675- },
676- },
677- .cdef = (StdVideoAV1MESACDEF) {
678- .damping_minus_3 = frame_header->cdef_damping_minus_3,
679- .bits = frame_header->cdef_bits,
680- },
681- .lr = (StdVideoAV1MESALoopRestoration) {
682- .lr_unit_shift = frame_header->lr_unit_shift,
683- .lr_uv_shift = frame_header->lr_uv_shift,
684- .lr_type = { frame_header->lr_type[0], frame_header->lr_type[1], frame_header->lr_type[2] },
685- },
686- .segmentation = (StdVideoAV1MESASegmentation) {
687- .flags = (StdVideoAV1MESASegmentationFlags) {
688- .enabled = frame_header->segmentation_enabled,
689- .update_map = frame_header->segmentation_update_map,
690- .temporal_update = frame_header->segmentation_temporal_update,
691- .update_data = frame_header->segmentation_update_data,
692- },
693- },
694- .film_grain = (StdVideoAV1MESAFilmGrainParameters) {
695- .flags = (StdVideoAV1MESAFilmGrainFlags) {
696- .apply_grain = apply_grain,
697- .chroma_scaling_from_luma = film_grain->chroma_scaling_from_luma,
698- .overlap_flag = film_grain->overlap_flag,
699- .clip_to_restricted_range = film_grain->clip_to_restricted_range,
700- },
701- .grain_scaling_minus_8 = film_grain->grain_scaling_minus_8,
702- .ar_coeff_lag = film_grain->ar_coeff_lag,
703- .ar_coeff_shift_minus_6 = film_grain->ar_coeff_shift_minus_6,
704- .grain_scale_shift = film_grain->grain_scale_shift,
705- .grain_seed = film_grain->grain_seed,
706- .num_y_points = film_grain->num_y_points,
707- .num_cb_points = film_grain->num_cb_points,
708- .num_cr_points = film_grain->num_cr_points,
709- .cb_mult = film_grain->cb_mult,
710- .cb_luma_mult = film_grain->cb_luma_mult,
711- .cb_offset = film_grain->cb_offset,
712- .cr_mult = film_grain->cr_mult,
713- .cr_luma_mult = film_grain->cr_luma_mult,
714- .cr_offset = film_grain->cr_offset,
715- },
716+ .TxMode = frame_header->tx_mode,
717+ .delta_q_res = frame_header->delta_q_res,
718+ .delta_lf_res = frame_header->delta_lf_res,
719+ .SkipModeFrame[0] = s->cur_frame.skip_mode_frame_idx[0],
720+ .SkipModeFrame[1] = s->cur_frame.skip_mode_frame_idx[1],
721+ .coded_denom = frame_header->coded_denom,
722+ .pTileInfo = &ap->tile_info,
723+ .pQuantization = &ap->quantization,
724+ .pSegmentation = &ap->segmentation,
725+ .pLoopFilter = &ap->loop_filter,
726+ .pCDEF = &ap->cdef,
727+ .pLoopRestoration = &ap->loop_restoration,
728+ .pGlobalMotion = &ap->global_motion,
729+ .pFilmGrain = apply_grain ? &ap->film_grain : NULL,
730 };
731
732 for (int i = 0; i < 64; i++) {
733- ap->av1_frame_header.tiling.width_in_sbs_minus_1[i] = frame_header->width_in_sbs_minus_1[i];
734- ap->av1_frame_header.tiling.height_in_sbs_minus_1[i] = frame_header->height_in_sbs_minus_1[i];
735- ap->av1_frame_header.tiling.tile_start_col_sb[i] = frame_header->tile_start_col_sb[i];
736- ap->av1_frame_header.tiling.tile_start_row_sb[i] = frame_header->tile_start_row_sb[i];
737+ ap->width_in_sbs_minus1[i] = frame_header->width_in_sbs_minus_1[i];
738+ ap->height_in_sbs_minus1[i] = frame_header->height_in_sbs_minus_1[i];
739+ ap->mi_col_starts[i] = frame_header->tile_start_col_sb[i];
740+ ap->mi_row_starts[i] = frame_header->tile_start_row_sb[i];
741 }
742
743- for (int i = 0; i < 8; i++) {
744- ap->av1_frame_header.segmentation.feature_enabled_bits[i] = 0;
745- for (int j = 0; j < 8; j++) {
746- ap->av1_frame_header.segmentation.feature_enabled_bits[i] |= (frame_header->feature_enabled[i][j] << j);
747- ap->av1_frame_header.segmentation.feature_data[i][j] = frame_header->feature_value[i][j];
748+ for (int i = 0; i < STD_VIDEO_AV1_MAX_SEGMENTS; i++) {
749+ ap->segmentation.FeatureEnabled[i] = 0x0;
750+ for (int j = 0; j < STD_VIDEO_AV1_SEG_LVL_MAX; j++) {
751+ ap->segmentation.FeatureEnabled[i] |= (frame_header->feature_enabled[i][j] << j);
752+ ap->segmentation.FeatureData[i][j] = frame_header->feature_value[i][j];
753 }
754-
755- ap->av1_frame_header.loop_filter.ref_deltas[i] = frame_header->loop_filter_ref_deltas[i];
756-
757- ap->av1_frame_header.cdef.y_pri_strength[i] = frame_header->cdef_y_pri_strength[i];
758- ap->av1_frame_header.cdef.y_sec_strength[i] = frame_header->cdef_y_sec_strength[i];
759- ap->av1_frame_header.cdef.uv_pri_strength[i] = frame_header->cdef_uv_pri_strength[i];
760- ap->av1_frame_header.cdef.uv_sec_strength[i] = frame_header->cdef_uv_sec_strength[i];
761-
762- ap->av1_frame_header.ref_order_hint[i] = frame_header->ref_order_hint[i];
763- ap->av1_frame_header.global_motion[i] = (StdVideoAV1MESAGlobalMotion) {
764- .flags = (StdVideoAV1MESAGlobalMotionFlags) {
765- .gm_invalid = s->cur_frame.gm_invalid[i],
766- },
767- .gm_type = s->cur_frame.gm_type[i],
768- .gm_params = {
769- s->cur_frame.gm_params[i][0], s->cur_frame.gm_params[i][1],
770- s->cur_frame.gm_params[i][2], s->cur_frame.gm_params[i][3],
771- s->cur_frame.gm_params[i][4], s->cur_frame.gm_params[i][5],
772- },
773- };
774 }
775
776- for (int i = 0; i < 7; i++) {
777- ap->av1_frame_header.ref_frame_idx[i] = frame_header->ref_frame_idx[i];
778- ap->av1_frame_header.delta_frame_id_minus1[i] = frame_header->delta_frame_id_minus1[i];
779+ for (int i = 0; i < STD_VIDEO_AV1_TOTAL_REFS_PER_FRAME; i++)
780+ ap->loop_filter.loop_filter_ref_deltas[i] = frame_header->loop_filter_ref_deltas[i];
781+
782+ for (int i = 0; i < STD_VIDEO_AV1_MAX_CDEF_FILTER_STRENGTHS; i++) {
783+ ap->cdef.cdef_y_pri_strength[i] = frame_header->cdef_y_pri_strength[i];
784+ ap->cdef.cdef_y_sec_strength[i] = frame_header->cdef_y_sec_strength[i];
785+ ap->cdef.cdef_uv_pri_strength[i] = frame_header->cdef_uv_pri_strength[i];
786+ ap->cdef.cdef_uv_sec_strength[i] = frame_header->cdef_uv_sec_strength[i];
787 }
788
789- ap->av1_pic_info.skip_mode_frame_idx[0] = s->cur_frame.skip_mode_frame_idx[0];
790- ap->av1_pic_info.skip_mode_frame_idx[1] = s->cur_frame.skip_mode_frame_idx[1];
791+ for (int i = 0; i < STD_VIDEO_AV1_NUM_REF_FRAMES; i++) {
792+ ap->std_pic_info.OrderHints[i] = frame_header->ref_order_hint[i];
793+ ap->global_motion.GmType[i] = s->cur_frame.gm_type[i];
794+ for (int j = 0; j < STD_VIDEO_AV1_GLOBAL_MOTION_PARAMS; j++) {
795+ ap->global_motion.gm_params[i][j] = s->cur_frame.gm_params[i][j];
796+ }
797+ }
798
799 if (apply_grain) {
800- for (int i = 0; i < 14; i++) {
801- ap->av1_frame_header.film_grain.point_y_value[i] = film_grain->point_y_value[i];
802- ap->av1_frame_header.film_grain.point_y_scaling[i] = film_grain->point_y_scaling[i];
803+ for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_Y_POINTS; i++) {
804+ ap->film_grain.point_y_value[i] = film_grain->point_y_value[i];
805+ ap->film_grain.point_y_scaling[i] = film_grain->point_y_scaling[i];
806 }
807
808- for (int i = 0; i < 10; i++) {
809- ap->av1_frame_header.film_grain.point_cb_value[i] = film_grain->point_cb_value[i];
810- ap->av1_frame_header.film_grain.point_cb_scaling[i] = film_grain->point_cb_scaling[i];
811- ap->av1_frame_header.film_grain.point_cr_value[i] = film_grain->point_cr_value[i];
812- ap->av1_frame_header.film_grain.point_cr_scaling[i] = film_grain->point_cr_scaling[i];
813+ for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_CB_POINTS; i++) {
814+ ap->film_grain.point_cb_value[i] = film_grain->point_cb_value[i];
815+ ap->film_grain.point_cb_scaling[i] = film_grain->point_cb_scaling[i];
816+ ap->film_grain.point_cr_value[i] = film_grain->point_cr_value[i];
817+ ap->film_grain.point_cr_scaling[i] = film_grain->point_cr_scaling[i];
818 }
819
820- for (int i = 0; i < 24; i++) {
821- ap->av1_frame_header.film_grain.ar_coeffs_y_plus_128[i] = film_grain->ar_coeffs_y_plus_128[i];
822- ap->av1_frame_header.film_grain.ar_coeffs_cb_plus_128[i] = film_grain->ar_coeffs_cb_plus_128[i];
823- ap->av1_frame_header.film_grain.ar_coeffs_cr_plus_128[i] = film_grain->ar_coeffs_cr_plus_128[i];
824- }
825+ for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_POS_LUMA; i++)
826+ ap->film_grain.ar_coeffs_y_plus_128[i] = film_grain->ar_coeffs_y_plus_128[i];
827
828- ap->av1_frame_header.film_grain.ar_coeffs_cb_plus_128[24] = film_grain->ar_coeffs_cb_plus_128[24];
829- ap->av1_frame_header.film_grain.ar_coeffs_cr_plus_128[24] = film_grain->ar_coeffs_cr_plus_128[24];
830+ for (int i = 0; i < STD_VIDEO_AV1_MAX_NUM_POS_CHROMA; i++) {
831+ ap->film_grain.ar_coeffs_cb_plus_128[i] = film_grain->ar_coeffs_cb_plus_128[i];
832+ ap->film_grain.ar_coeffs_cr_plus_128[i] = film_grain->ar_coeffs_cr_plus_128[i];
833+ }
834 }
835
836- /* Workaround for a spec issue. */
837 ap->dec = dec;
838
839 return 0;
840@@ -484,25 +545,20 @@ static int vk_av1_decode_slice(AVCodecContext *avctx,
841 AV1VulkanDecodePicture *ap = s->cur_frame.hwaccel_picture_private;
842 FFVulkanDecodePicture *vp = &ap->vp;
843
844+ /* Too many tiles, exceeding all defined levels in the AV1 spec */
845+ if (ap->av1_pic_info.tileCount > MAX_TILES)
846+ return AVERROR(ENOSYS);
847+
848 for (int i = s->tg_start; i <= s->tg_end; i++) {
849- ap->tiles[ap->tile_list.nb_tiles] = (StdVideoAV1MESATile) {
850- .size = s->tile_group_info[i].tile_size,
851- .offset = s->tile_group_info[i].tile_offset,
852- .row = s->tile_group_info[i].tile_row,
853- .column = s->tile_group_info[i].tile_column,
854- .tg_start = s->tg_start,
855- .tg_end = s->tg_end,
856- };
857+ ap->tile_sizes[ap->av1_pic_info.tileCount] = s->tile_group_info[i].tile_size;
858
859 err = ff_vk_decode_add_slice(avctx, vp,
860 data + s->tile_group_info[i].tile_offset,
861 s->tile_group_info[i].tile_size, 0,
862- &ap->tile_list.nb_tiles,
863- &ap->tile_offsets);
864+ &ap->av1_pic_info.tileCount,
865+ &ap->av1_pic_info.pTileOffsets);
866 if (err < 0)
867 return err;
868-
869- ap->tiles[ap->tile_list.nb_tiles - 1].offset = ap->tile_offsets[ap->tile_list.nb_tiles - 1];
870 }
871
872 return 0;
873@@ -518,7 +574,7 @@ static int vk_av1_end_frame(AVCodecContext *avctx)
874 FFVulkanDecodePicture *rvp[AV1_NUM_REF_FRAMES] = { 0 };
875 AVFrame *rav[AV1_NUM_REF_FRAMES] = { 0 };
876
877- if (!ap->tile_list.nb_tiles)
878+ if (!ap->av1_pic_info.tileCount)
879 return 0;
880
881 if (!dec->session_params) {
882@@ -536,7 +592,7 @@ static int vk_av1_end_frame(AVCodecContext *avctx)
883 }
884
885 av_log(avctx, AV_LOG_VERBOSE, "Decoding frame, %"SIZE_SPECIFIER" bytes, %i tiles\n",
886- vp->slices_size, ap->tile_list.nb_tiles);
887+ vp->slices_size, ap->av1_pic_info.tileCount);
888
889 return ff_vk_decode_frame(avctx, pic->f, vp, rav, rvp);
890 }
891@@ -580,8 +636,6 @@ const FFHWAccel ff_av1_vulkan_hwaccel = {
892 * flexibility, this index cannot be present anywhere.
893 * The current implementation tracks the index for the driver and submits it
894 * as necessary information. Due to needing to modify the decoding context,
895- * which is not thread-safe, on frame free, threading is disabled.
896- * In the future, once this is fixed in the spec, the workarounds may be removed
897- * and threading enabled. */
898+ * which is not thread-safe, on frame free, threading is disabled. */
899 .caps_internal = HWACCEL_CAP_ASYNC_SAFE,
900 };
901--- ffmpeg-6.1.1/libavcodec/vulkan_decode.c.orig 2023-11-11 01:25:17.000000000 +0100
902+++ ffmpeg-6.1.1/libavcodec/vulkan_decode.c 2024-04-15 21:49:59.451325544 +0200
903@@ -50,7 +50,7 @@ static const VkVideoProfileInfoKHR *get_
904 VkStructureType profile_struct_type =
905 codec_id == AV_CODEC_ID_H264 ? VK_STRUCTURE_TYPE_VIDEO_DECODE_H264_PROFILE_INFO_KHR :
906 codec_id == AV_CODEC_ID_HEVC ? VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_PROFILE_INFO_KHR :
907- codec_id == AV_CODEC_ID_AV1 ? VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_MESA :
908+ codec_id == AV_CODEC_ID_AV1 ? VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR :
909 0;
910
911 profile_list = ff_vk_find_struct(ctx->s.hwfc->create_pnext,
912@@ -663,7 +663,7 @@ static VkResult vulkan_setup_profile(AVC
913 const struct FFVkCodecMap *vk_codec,
914 VkVideoDecodeH264CapabilitiesKHR *h264_caps,
915 VkVideoDecodeH265CapabilitiesKHR *h265_caps,
916- VkVideoDecodeAV1CapabilitiesMESA *av1_caps,
917+ VkVideoDecodeAV1CapabilitiesKHR *av1_caps,
918 VkVideoCapabilitiesKHR *caps,
919 VkVideoDecodeCapabilitiesKHR *dec_caps,
920 int cur_profile)
921@@ -674,7 +674,7 @@ static VkResult vulkan_setup_profile(AVC
922
923 VkVideoDecodeH264ProfileInfoKHR *h264_profile = &prof->h264_profile;
924 VkVideoDecodeH265ProfileInfoKHR *h265_profile = &prof->h265_profile;
925- VkVideoDecodeAV1ProfileInfoMESA *av1_profile = &prof->av1_profile;
926+ VkVideoDecodeAV1ProfileInfoKHR *av1_profile = &prof->av1_profile;
927
928 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
929 if (!desc)
930@@ -702,8 +702,9 @@ static VkResult vulkan_setup_profile(AVC
931 } else if (avctx->codec_id == AV_CODEC_ID_AV1) {
932 dec_caps->pNext = av1_caps;
933 usage->pNext = av1_profile;
934- av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_MESA;
935- av1_profile->stdProfileIdc = cur_profile;
936+ av1_profile->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_KHR;
937+ av1_profile->stdProfile = cur_profile;
938+ av1_profile->filmGrainSupport = !(avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
939 }
940
941 usage->sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_USAGE_INFO_KHR;
942@@ -758,8 +759,8 @@ static int vulkan_decode_get_profile(AVC
943 VkVideoDecodeH265CapabilitiesKHR h265_caps = {
944 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_CAPABILITIES_KHR,
945 };
946- VkVideoDecodeAV1CapabilitiesMESA av1_caps = {
947- .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_MESA,
948+ VkVideoDecodeAV1CapabilitiesKHR av1_caps = {
949+ .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_KHR,
950 };
951
952 VkPhysicalDeviceVideoFormatInfoKHR fmt_info = {
953@@ -782,7 +783,7 @@ static int vulkan_decode_get_profile(AVC
954 cur_profile = avctx->profile;
955 base_profile = avctx->codec_id == AV_CODEC_ID_H264 ? AV_PROFILE_H264_CONSTRAINED_BASELINE :
956 avctx->codec_id == AV_CODEC_ID_H265 ? AV_PROFILE_HEVC_MAIN :
957- avctx->codec_id == AV_CODEC_ID_AV1 ? STD_VIDEO_AV1_MESA_PROFILE_MAIN :
958+ avctx->codec_id == AV_CODEC_ID_AV1 ? STD_VIDEO_AV1_PROFILE_MAIN :
959 0;
960
961 ret = vulkan_setup_profile(avctx, prof, hwctx, vk, vk_codec,
962@@ -830,7 +831,7 @@ static int vulkan_decode_get_profile(AVC
963
964 max_level = avctx->codec_id == AV_CODEC_ID_H264 ? ff_vk_h264_level_to_av(h264_caps.maxLevelIdc) :
965 avctx->codec_id == AV_CODEC_ID_H265 ? ff_vk_h265_level_to_av(h265_caps.maxLevelIdc) :
966- avctx->codec_id == AV_CODEC_ID_AV1 ? av1_caps.maxLevelIdc :
967+ avctx->codec_id == AV_CODEC_ID_AV1 ? av1_caps.maxLevel :
968 0;
969
970 av_log(avctx, AV_LOG_VERBOSE, "Decoder capabilities for %s profile \"%s\":\n",
971@@ -901,17 +902,11 @@ static int vulkan_decode_get_profile(AVC
972 "VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR set "
973 "but VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR is unset!\n");
974 return AVERROR_EXTERNAL;
975- } else if (!(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR) &&
976- avctx->codec_id == AV_CODEC_ID_AV1) {
977- av_log(avctx, AV_LOG_ERROR, "Cannot initialize Vulkan decoding session, buggy driver: "
978- "codec is AV1, but VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_DISTINCT_BIT_KHR isn't set!\n");
979- return AVERROR_EXTERNAL;
980 }
981
982 /* TODO: make dedicated_dpb tunable */
983 dec->dedicated_dpb = !(dec_caps->flags & VK_VIDEO_DECODE_CAPABILITY_DPB_AND_OUTPUT_COINCIDE_BIT_KHR);
984 dec->layered_dpb = !(caps->flags & VK_VIDEO_CAPABILITY_SEPARATE_REFERENCE_IMAGES_BIT_KHR);
985- dec->external_fg = av1_caps.flags & VK_VIDEO_DECODE_AV1_CAPABILITY_EXTERNAL_FILM_GRAIN_MESA;
986
987 if (dec->dedicated_dpb) {
988 fmt_info.imageUsage = VK_IMAGE_USAGE_VIDEO_DECODE_DPB_BIT_KHR;
989@@ -1118,8 +1113,10 @@ int ff_vk_decode_init(AVCodecContext *av
990 VkVideoDecodeH265SessionParametersCreateInfoKHR h265_params = {
991 .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_H265_SESSION_PARAMETERS_CREATE_INFO_KHR,
992 };
993- VkVideoDecodeAV1SessionParametersCreateInfoMESA av1_params = {
994- .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_MESA,
995+ StdVideoAV1SequenceHeader av1_empty_seq = { 0 };
996+ VkVideoDecodeAV1SessionParametersCreateInfoKHR av1_params = {
997+ .sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_KHR,
998+ .pStdSequenceHeader = &av1_empty_seq,
999 };
1000 VkVideoSessionParametersCreateInfoKHR session_params_create = {
1001 .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
1002diff --git a/libavcodec/vulkan_decode.h b/libavcodec/vulkan_decode.h
1003index a43e328d73..7ba8b239cb 100644
1004--- a/libavcodec/vulkan_decode.h
1005+++ b/libavcodec/vulkan_decode.h
1006@@ -37,7 +37,7 @@ typedef struct FFVulkanDecodeDescriptor {
1007 typedef struct FFVulkanDecodeProfileData {
1008 VkVideoDecodeH264ProfileInfoKHR h264_profile;
1009 VkVideoDecodeH265ProfileInfoKHR h265_profile;
1010- VkVideoDecodeAV1ProfileInfoMESA av1_profile;
1011+ VkVideoDecodeAV1ProfileInfoKHR av1_profile;
1012 VkVideoDecodeUsageInfoKHR usage;
1013 VkVideoProfileInfoKHR profile;
1014 VkVideoProfileListInfoKHR profile_list;
1015--- ffmpeg-6.1.1/libavcodec/vulkan_video.h.orig 2024-04-15 21:35:22.599409192 +0200
1016+++ ffmpeg-6.1.1/libavcodec/vulkan_video.h 2024-04-15 21:50:11.117929007 +0200
1017@@ -23,8 +23,6 @@
1018 #include "vulkan.h"
1019
1020 #include <vk_video/vulkan_video_codecs_common.h>
1021-#include "vulkan_video_codec_av1std.h"
1022-#include "vulkan_video_codec_av1std_decode.h"
1023
1024 #define CODEC_VER_MAJ(ver) (ver >> 22)
1025 #define CODEC_VER_MIN(ver) ((ver >> 12) & ((1 << 10) - 1))
1026diff --git a/libavcodec/vulkan_video_codec_av1std_decode.h b/libavcodec/vulkan_video_codec_av1std_decode.h
1027deleted file mode 100644
1028index e2f37b4e6e..0000000000
1029--- a/libavcodec/vulkan_video_codec_av1std_decode.h
1030+++ /dev/null
1031@@ -1,36 +0,0 @@
1032-/* Copyright 2023 Lynne
1033- * Copyright 2023 Dave Airlie
1034- *
1035- * Licensed under the Apache License, Version 2.0 (the "License");
1036- * you may not use this file except in compliance with the License.
1037- * You may obtain a copy of the License at
1038- *
1039- * http://www.apache.org/licenses/LICENSE-2.0
1040- *
1041- * Unless required by applicable law or agreed to in writing, software
1042- * distributed under the License is distributed on an "AS IS" BASIS,
1043- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1044- * See the License for the specific language governing permissions and
1045- * limitations under the License.
1046- */
1047-
1048-#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_
1049-#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ 1
1050-
1051-/*
1052-** This header is NOT YET generated from the Khronos Vulkan XML API Registry.
1053-**
1054-*/
1055-
1056-#ifdef __cplusplus
1057-extern "C" {
1058-#endif
1059-#define vulkan_video_codec_av1std_decode 1
1060-
1061-
1062-
1063-#ifdef __cplusplus
1064-}
1065-#endif
1066-
1067-#endif
1068diff --git a/libavcodec/vulkan_video_codec_av1std.h b/libavcodec/vulkan_video_codec_av1std.h
1069deleted file mode 100644
1070index c91589eee2..0000000000
1071--- a/libavcodec/vulkan_video_codec_av1std.h
1072+++ /dev/null
1073@@ -1,403 +0,0 @@
1074-/* Copyright 2023 Lynne
1075- * Copyright 2023 Dave Airlie
1076- *
1077- * Licensed under the Apache License, Version 2.0 (the "License");
1078- * you may not use this file except in compliance with the License.
1079- * You may obtain a copy of the License at
1080- *
1081- * http://www.apache.org/licenses/LICENSE-2.0
1082- *
1083- * Unless required by applicable law or agreed to in writing, software
1084- * distributed under the License is distributed on an "AS IS" BASIS,
1085- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1086- * See the License for the specific language governing permissions and
1087- * limitations under the License.
1088- */
1089-
1090-#ifndef VULKAN_VIDEO_CODEC_AV1STD_H_
1091-#define VULKAN_VIDEO_CODEC_AV1STD_H_ 1
1092-
1093-/*
1094-** This header is NOT YET generated from the Khronos Vulkan XML API Registry.
1095-**
1096-*/
1097-
1098-#ifdef __cplusplus
1099-extern "C" {
1100-#endif
1101-#define vulkan_video_codec_av1std 1
1102-
1103-#define VK_MAKE_VIDEO_STD_VERSION(major, minor, patch) \
1104- ((((uint32_t)(major)) << 22) | (((uint32_t)(minor)) << 12) | ((uint32_t)(patch)))
1105-#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_0_1_0 VK_MAKE_VIDEO_STD_VERSION(0, 1, 0)
1106-#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_API_VERSION_0_1_0
1107-#define VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_EXTENSION_NAME "VK_STD_vulkan_video_codec_av1_decode"
1108-
1109-typedef enum StdVideoAV1MESAProfile {
1110- STD_VIDEO_AV1_MESA_PROFILE_MAIN = 0,
1111- STD_VIDEO_AV1_MESA_PROFILE_HIGH = 1,
1112- STD_VIDEO_AV1_MESA_PROFILE_PROFESSIONAL = 2,
1113-} StdVideoAV1MESAProfile;
1114-
1115-typedef enum StdVideoAV1MESALevel {
1116- STD_VIDEO_AV1_MESA_LEVEL_2_0 = 0,
1117- STD_VIDEO_AV1_MESA_LEVEL_2_1 = 1,
1118- STD_VIDEO_AV1_MESA_LEVEL_2_2 = 2,
1119- STD_VIDEO_AV1_MESA_LEVEL_2_3 = 3,
1120- STD_VIDEO_AV1_MESA_LEVEL_3_0 = 4,
1121- STD_VIDEO_AV1_MESA_LEVEL_3_1 = 5,
1122- STD_VIDEO_AV1_MESA_LEVEL_3_2 = 6,
1123- STD_VIDEO_AV1_MESA_LEVEL_3_3 = 7,
1124- STD_VIDEO_AV1_MESA_LEVEL_4_0 = 8,
1125- STD_VIDEO_AV1_MESA_LEVEL_4_1 = 9,
1126- STD_VIDEO_AV1_MESA_LEVEL_4_2 = 10,
1127- STD_VIDEO_AV1_MESA_LEVEL_4_3 = 11,
1128- STD_VIDEO_AV1_MESA_LEVEL_5_0 = 12,
1129- STD_VIDEO_AV1_MESA_LEVEL_5_1 = 13,
1130- STD_VIDEO_AV1_MESA_LEVEL_5_2 = 14,
1131- STD_VIDEO_AV1_MESA_LEVEL_5_3 = 15,
1132- STD_VIDEO_AV1_MESA_LEVEL_6_0 = 16,
1133- STD_VIDEO_AV1_MESA_LEVEL_6_1 = 17,
1134- STD_VIDEO_AV1_MESA_LEVEL_6_2 = 18,
1135- STD_VIDEO_AV1_MESA_LEVEL_6_3 = 19,
1136- STD_VIDEO_AV1_MESA_LEVEL_7_0 = 20,
1137- STD_VIDEO_AV1_MESA_LEVEL_7_1 = 21,
1138- STD_VIDEO_AV1_MESA_LEVEL_7_2 = 22,
1139- STD_VIDEO_AV1_MESA_LEVEL_7_3 = 23,
1140- STD_VIDEO_AV1_MESA_LEVEL_MAX = 31,
1141-} StdVideoAV1MESALevel;
1142-
1143-typedef struct StdVideoAV1MESAFilmGrainFlags {
1144- uint8_t apply_grain;
1145- uint8_t chroma_scaling_from_luma;
1146- uint8_t overlap_flag;
1147- uint8_t clip_to_restricted_range;
1148-} StdVideoAV1MESAFilmGrainFlags;
1149-
1150-typedef struct StdVideoAV1MESAFilmGrainParameters {
1151- StdVideoAV1MESAFilmGrainFlags flags;
1152- uint32_t grain_scaling_minus_8;
1153- uint32_t ar_coeff_lag;
1154- uint32_t ar_coeff_shift_minus_6;
1155- uint32_t grain_scale_shift;
1156-
1157- uint16_t grain_seed;
1158- uint8_t num_y_points;
1159- uint8_t point_y_value[14];
1160- uint8_t point_y_scaling[14];
1161-
1162- uint8_t num_cb_points;
1163- uint8_t point_cb_value[10];
1164- uint8_t point_cb_scaling[10];
1165-
1166- uint8_t num_cr_points;
1167- uint8_t point_cr_value[10];
1168- uint8_t point_cr_scaling[10];
1169-
1170- int8_t ar_coeffs_y_plus_128[24];
1171- int8_t ar_coeffs_cb_plus_128[25];
1172- int8_t ar_coeffs_cr_plus_128[25];
1173- uint8_t cb_mult;
1174- uint8_t cb_luma_mult;
1175- uint16_t cb_offset;
1176- uint8_t cr_mult;
1177- uint8_t cr_luma_mult;
1178- uint16_t cr_offset;
1179-} StdVideoAV1MESAFilmGrainParameters;
1180-
1181-typedef struct StdVideoAV1MESAGlobalMotionFlags {
1182- uint8_t gm_invalid;
1183-} StdVideoAV1MESAGlobalMotionFlags;
1184-
1185-typedef struct StdVideoAV1MESAGlobalMotion {
1186- StdVideoAV1MESAGlobalMotionFlags flags;
1187- uint8_t gm_type;
1188- uint32_t gm_params[6];
1189-} StdVideoAV1MESAGlobalMotion;
1190-
1191-typedef struct StdVideoAV1MESALoopRestoration {
1192- uint8_t lr_type[3];
1193- uint8_t lr_unit_shift;
1194- uint8_t lr_uv_shift;
1195-} StdVideoAV1MESALoopRestoration;
1196-
1197-typedef struct StdVideoAV1MESATileInfoFlags {
1198- uint8_t uniform_tile_spacing_flag;
1199-} StdVideoAV1MESATileInfoFlags;
1200-
1201-typedef struct StdVideoAV1MESATileInfo {
1202- StdVideoAV1MESATileInfoFlags flags;
1203- uint8_t tile_cols;
1204- uint8_t tile_rows;
1205- uint8_t tile_start_col_sb[64];
1206- uint8_t tile_start_row_sb[64];
1207- uint8_t width_in_sbs_minus_1[64];
1208- uint8_t height_in_sbs_minus_1[64];
1209- uint16_t context_update_tile_id;
1210- uint8_t tile_size_bytes_minus1;
1211-} StdVideoAV1MESATileInfo;
1212-
1213-typedef struct StdVideoAV1MESAQuantizationFlags {
1214- uint8_t using_qmatrix;
1215-} StdVideoAV1MESAQuantizationFlags;
1216-
1217-typedef struct StdVideoAV1MESAQuantization {
1218- StdVideoAV1MESAQuantizationFlags flags;
1219- uint8_t base_q_idx;
1220- int8_t delta_q_y_dc;
1221- uint8_t diff_uv_delta;
1222- int8_t delta_q_u_dc;
1223- int8_t delta_q_u_ac;
1224- int8_t delta_q_v_dc;
1225- int8_t delta_q_v_ac;
1226- uint8_t qm_y;
1227- uint8_t qm_u;
1228- uint8_t qm_v;
1229-} StdVideoAV1MESAQuantization;
1230-
1231-typedef struct StdVideoAV1MESACDEF {
1232- uint8_t damping_minus_3;
1233- uint8_t bits;
1234- uint8_t y_pri_strength[8];
1235- uint8_t y_sec_strength[8];
1236- uint8_t uv_pri_strength[8];
1237- uint8_t uv_sec_strength[8];
1238-} StdVideoAV1MESACDEF;
1239-
1240-typedef struct StdVideoAV1MESADeltaQFlags {
1241- uint8_t delta_lf_present;
1242- uint8_t delta_lf_multi;
1243-} StdVideoAV1MESADeltaQFlags;
1244-
1245-typedef struct StdVideoAV1MESADeltaQ {
1246- StdVideoAV1MESADeltaQFlags flags;
1247- uint8_t delta_q_res;
1248- uint8_t delta_lf_res;
1249-} StdVideoAV1MESADeltaQ;
1250-
1251-typedef struct StdVideoAV1MESASegmentationFlags {
1252- uint8_t enabled;
1253- uint8_t update_map;
1254- uint8_t temporal_update;
1255- uint8_t update_data;
1256-} StdVideoAV1MESASegmentationFlags;
1257-
1258-typedef struct StdVideoAV1MESASegmentation {
1259- StdVideoAV1MESASegmentationFlags flags;
1260- uint8_t feature_enabled_bits[8];
1261- int16_t feature_data[8][8];
1262-} StdVideoAV1MESASegmentation;
1263-
1264-typedef struct StdVideoAV1MESALoopFilterFlags {
1265- uint8_t delta_enabled;
1266- uint8_t delta_update;
1267-} StdVideoAV1MESALoopFilterFlags;
1268-
1269-typedef struct StdVideoAV1MESALoopFilter {
1270- StdVideoAV1MESALoopFilterFlags flags;
1271- uint8_t level[4];
1272- uint8_t sharpness;
1273- int8_t ref_deltas[8];
1274- int8_t mode_deltas[2];
1275-} StdVideoAV1MESALoopFilter;
1276-
1277-typedef struct StdVideoAV1MESAFrameHeaderFlags {
1278- uint8_t error_resilient_mode;
1279- uint8_t disable_cdf_update;
1280- uint8_t use_superres;
1281- uint8_t render_and_frame_size_different;
1282- uint8_t allow_screen_content_tools;
1283- uint8_t is_filter_switchable;
1284- uint8_t force_integer_mv;
1285- uint8_t frame_size_override_flag;
1286- uint8_t buffer_removal_time_present_flag;
1287- uint8_t allow_intrabc;
1288- uint8_t frame_refs_short_signaling;
1289- uint8_t allow_high_precision_mv;
1290- uint8_t is_motion_mode_switchable;
1291- uint8_t use_ref_frame_mvs;
1292- uint8_t disable_frame_end_update_cdf;
1293- uint8_t allow_warped_motion;
1294- uint8_t reduced_tx_set;
1295- uint8_t reference_select;
1296- uint8_t skip_mode_present;
1297- uint8_t delta_q_present;
1298- uint8_t UsesLr;
1299-} StdVideoAV1MESAFrameHeaderFlags;
1300-
1301-typedef struct StdVideoAV1MESAFrameHeader {
1302- StdVideoAV1MESAFrameHeaderFlags flags;
1303-
1304- uint32_t frame_presentation_time;
1305- uint32_t display_frame_id;
1306- uint32_t current_frame_id;
1307- uint8_t frame_to_show_map_idx;
1308- uint8_t frame_type;
1309- uint8_t order_hint;
1310- uint8_t primary_ref_frame;
1311- uint16_t frame_width_minus_1;
1312- uint16_t frame_height_minus_1;
1313- uint16_t render_width_minus_1;
1314- uint16_t render_height_minus_1;
1315- uint8_t coded_denom;
1316-
1317- uint8_t refresh_frame_flags;
1318- uint8_t ref_order_hint[8];
1319- int8_t ref_frame_idx[7];
1320- uint32_t delta_frame_id_minus1[7];
1321-
1322- uint8_t interpolation_filter;
1323- uint8_t tx_mode;
1324-
1325- StdVideoAV1MESATileInfo tiling;
1326- StdVideoAV1MESAQuantization quantization;
1327- StdVideoAV1MESASegmentation segmentation;
1328- StdVideoAV1MESADeltaQ delta_q;
1329- StdVideoAV1MESALoopFilter loop_filter;
1330- StdVideoAV1MESACDEF cdef;
1331- StdVideoAV1MESALoopRestoration lr;
1332- StdVideoAV1MESAGlobalMotion global_motion[8]; // One per ref frame
1333- StdVideoAV1MESAFilmGrainParameters film_grain;
1334-} StdVideoAV1MESAFrameHeader;
1335-
1336-typedef struct StdVideoAV1MESAScreenCoding {
1337- uint8_t seq_force_screen_content_tools;
1338-} StdVideoAV1MESAScreenCoding;
1339-
1340-typedef struct StdVideoAV1MESATimingInfoFlags {
1341- uint8_t equal_picture_interval;
1342-} StdVideoAV1MESATimingInfoFlags;
1343-
1344-typedef struct StdVideoAV1MESATimingInfo {
1345- StdVideoAV1MESATimingInfoFlags flags;
1346- uint32_t num_units_in_display_tick;
1347- uint32_t time_scale;
1348- uint32_t num_ticks_per_picture_minus_1;
1349-} StdVideoAV1MESATimingInfo;
1350-
1351-typedef struct StdVideoAV1MESAColorConfigFlags {
1352- uint8_t mono_chrome;
1353- uint8_t color_range;
1354- uint8_t separate_uv_delta_q;
1355-} StdVideoAV1MESAColorConfigFlags;
1356-
1357-typedef struct StdVideoAV1MESAColorConfig {
1358- StdVideoAV1MESAColorConfigFlags flags;
1359- uint8_t bit_depth;
1360- uint8_t subsampling_x;
1361- uint8_t subsampling_y;
1362-} StdVideoAV1MESAColorConfig;
1363-
1364-typedef struct StdVideoAV1MESASequenceHeaderFlags {
1365- uint8_t still_picture;
1366- uint8_t reduced_still_picture_header;
1367- uint8_t use_128x128_superblock;
1368- uint8_t enable_filter_intra;
1369- uint8_t enable_intra_edge_filter;
1370- uint8_t enable_interintra_compound;
1371- uint8_t enable_masked_compound;
1372- uint8_t enable_warped_motion;
1373- uint8_t enable_dual_filter;
1374- uint8_t enable_order_hint;
1375- uint8_t enable_jnt_comp;
1376- uint8_t enable_ref_frame_mvs;
1377- uint8_t frame_id_numbers_present_flag;
1378- uint8_t enable_superres;
1379- uint8_t enable_cdef;
1380- uint8_t enable_restoration;
1381- uint8_t film_grain_params_present;
1382- uint8_t timing_info_present_flag;
1383- uint8_t initial_display_delay_present_flag;
1384-} StdVideoAV1MESASequenceHeaderFlags;
1385-
1386-typedef struct StdVideoAV1MESASequenceHeader {
1387- StdVideoAV1MESASequenceHeaderFlags flags;
1388-
1389- StdVideoAV1MESAProfile seq_profile;
1390- uint8_t frame_width_bits_minus_1;
1391- uint8_t frame_height_bits_minus_1;
1392- uint16_t max_frame_width_minus_1;
1393- uint16_t max_frame_height_minus_1;
1394- uint8_t delta_frame_id_length_minus_2;
1395- uint8_t additional_frame_id_length_minus_1;
1396- uint8_t order_hint_bits_minus_1;
1397- uint8_t seq_choose_integer_mv;
1398- uint8_t seq_force_integer_mv;
1399-
1400- StdVideoAV1MESATimingInfo timing_info;
1401- StdVideoAV1MESAColorConfig color_config;
1402-} StdVideoAV1MESASequenceHeader;
1403-
1404-typedef struct StdVideoAV1MESATile {
1405- uint16_t tg_start;
1406- uint16_t tg_end;
1407- uint16_t row;
1408- uint16_t column;
1409- uint32_t size;
1410- uint32_t offset;
1411-} StdVideoAV1MESATile;
1412-
1413-typedef struct StdVideoAV1MESATileList {
1414- StdVideoAV1MESATile *tile_list;
1415- uint32_t nb_tiles;
1416-} StdVideoAV1MESATileList;
1417-
1418-typedef struct VkVideoDecodeAV1PictureInfoMESA {
1419- VkStructureType sType;
1420- const void *pNext;
1421- StdVideoAV1MESAFrameHeader *frame_header;
1422- StdVideoAV1MESATileList *tile_list;
1423- uint8_t skip_mode_frame_idx[2];
1424-} VkVideoDecodeAV1PictureInfoMESA;
1425-
1426-typedef struct VkVideoDecodeAV1DpbSlotInfoMESA {
1427- VkStructureType sType;
1428- const void *pNext;
1429- uint8_t frameIdx;
1430- uint8_t ref_order_hint[7];
1431- uint8_t disable_frame_end_update_cdf;
1432-} VkVideoDecodeAV1DpbSlotInfoMESA;
1433-
1434-typedef struct VkVideoDecodeAV1SessionParametersAddInfoMESA {
1435- VkStructureType sType;
1436- const void *pNext;
1437- StdVideoAV1MESASequenceHeader *sequence_header;
1438-} VkVideoDecodeAV1SessionParametersAddInfoMESA;
1439-
1440-typedef struct VkVideoDecodeAV1SessionParametersCreateInfoMESA {
1441- VkStructureType sType;
1442- const void *pNext;
1443- const VkVideoDecodeAV1SessionParametersAddInfoMESA *pParametersAddInfo;
1444-} VkVideoDecodeAV1SessionParametersCreateInfoMESA;
1445-
1446-typedef struct VkVideoDecodeAV1ProfileInfoMESA {
1447- VkStructureType sType;
1448- const void *pNext;
1449- StdVideoAV1MESAProfile stdProfileIdc;
1450-} VkVideoDecodeAV1ProfileInfoMESA;
1451-
1452-typedef enum VkVideoDecodeAV1CapabilityFlagBitsMESA {
1453- VK_VIDEO_DECODE_AV1_CAPABILITY_EXTERNAL_FILM_GRAIN_MESA = 0x00000001,
1454- VK_VIDEO_DECODE_AV1_CAPABILITY_FLAG_BITS_MAX_ENUM_MESA = 0x7FFFFFFF
1455-} VkVideoDecodeAV1CapabilityFlagBitsMESA;
1456-typedef VkFlags VkVideoDecodeAV1CapabilityFlagsMESA;
1457-
1458-typedef struct VkVideoDecodeAV1CapabilitiesMESA {
1459- VkStructureType sType;
1460- const void *pNext;
1461- VkVideoDecodeAV1CapabilityFlagsMESA flags;
1462- StdVideoAV1MESALevel maxLevelIdc;
1463-} VkVideoDecodeAV1CapabilitiesMESA;
1464-
1465-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_MESA 1000509000
1466-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_CREATE_INFO_MESA 1000509001
1467-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_SESSION_PARAMETERS_ADD_INFO_MESA 1000509002
1468-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_DPB_SLOT_INFO_MESA 1000509003
1469-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_CAPABILITIES_MESA 1000509004
1470-#define VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PROFILE_INFO_MESA 1000509005
1471-
1472-#ifdef __cplusplus
1473-}
1474-#endif
1475-
1476-#endif
1477diff --git a/libavutil/hwcontext_vulkan.c b/libavutil/hwcontext_vulkan.c
1478index 91b9f96ccf..6e3b96b73a 100644
1479--- a/libavutil/hwcontext_vulkan.c
1480+++ b/libavutil/hwcontext_vulkan.c
1481@@ -446,7 +446,7 @@ static const VulkanOptExtension optional_device_exts[] = {
1482 { VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_QUEUE },
1483 { VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_H264 },
1484 { VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_H265 },
1485- { "VK_MESA_video_decode_av1", FF_VK_EXT_VIDEO_DECODE_AV1 },
1486+ { VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_AV1 },
1487 };
1488
1489 static VkBool32 VKAPI_CALL vk_dbg_callback(VkDebugUtilsMessageSeverityFlagBitsEXT severity,
1490diff --git a/libavutil/vulkan_functions.h b/libavutil/vulkan_functions.h
1491index 65021b04b1..6b379acf93 100644
1492--- a/libavutil/vulkan_functions.h
1493+++ b/libavutil/vulkan_functions.h
1494@@ -43,7 +43,7 @@ typedef enum FFVulkanExtensions {
1495 FF_VK_EXT_VIDEO_DECODE_QUEUE = 1ULL << 11, /* VK_KHR_video_decode_queue */
1496 FF_VK_EXT_VIDEO_DECODE_H264 = 1ULL << 12, /* VK_EXT_video_decode_h264 */
1497 FF_VK_EXT_VIDEO_DECODE_H265 = 1ULL << 13, /* VK_EXT_video_decode_h265 */
1498- FF_VK_EXT_VIDEO_DECODE_AV1 = 1ULL << 14, /* VK_MESA_video_decode_av1 */
1499+ FF_VK_EXT_VIDEO_DECODE_AV1 = 1ULL << 14, /* VK_KHR_video_decode_av1 */
1500 FF_VK_EXT_ATOMIC_FLOAT = 1ULL << 15, /* VK_EXT_shader_atomic_float */
1501 FF_VK_EXT_COOP_MATRIX = 1ULL << 16, /* VK_KHR_cooperative_matrix */
1502
1503diff --git a/libavutil/vulkan_loader.h b/libavutil/vulkan_loader.h
1504index f9e739e1e3..73cf03935d 100644
1505--- a/libavutil/vulkan_loader.h
1506+++ b/libavutil/vulkan_loader.h
1507@@ -58,7 +58,7 @@ static inline uint64_t ff_vk_extensions_to_mask(const char * const *extensions,
1508 { VK_KHR_VIDEO_DECODE_QUEUE_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_QUEUE },
1509 { VK_KHR_VIDEO_DECODE_H264_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_H264 },
1510 { VK_KHR_VIDEO_DECODE_H265_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_H265 },
1511- { "VK_MESA_video_decode_av1", FF_VK_EXT_VIDEO_DECODE_AV1 },
1512+ { VK_KHR_VIDEO_DECODE_AV1_EXTENSION_NAME, FF_VK_EXT_VIDEO_DECODE_AV1 },
1513 };
1514
1515 FFVulkanExtensions mask = 0x0;
1516--- ffmpeg-6.1.1/libavcodec/vulkan_video.c.orig 2023-11-11 01:25:17.000000000 +0100
1517+++ ffmpeg-6.1.1/libavcodec/vulkan_video.c 2024-04-15 21:49:23.744852316 +0200
1518@@ -37,7 +37,7 @@ const FFVkCodecMap ff_vk_codec_map[AV_CO
1519 0,
1520 0,
1521 FF_VK_EXT_VIDEO_DECODE_AV1,
1522- 0x01000000 /* TODO fix this */
1523+ VK_VIDEO_CODEC_OPERATION_DECODE_AV1_BIT_KHR,
1524 },
1525 };
1526
This page took 0.211327 seconds and 4 git commands to generate.