Re: [FFmpeg-devel] [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API
On 2/11/24 20:45, Lynne wrote: Most of this patch was written by Dave Airlie , with some additions by me. Tested and verified that this works with https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27424 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API
On 2/13/2024 9:10 AM, Lynne wrote: Feb 13, 2024, 01:59 by ffmpeg-devel@ffmpeg.org: On Sun Feb 11, 2024 at 10:15 AM EST, Lynne wrote: From: Lynne Date: Fri, 19 Jan 2024 10:49:02 +1000 Subject: [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API Most of this patch was written by Dave Airlie , with some additions by me. --- -ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoMESA) { -.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_MESA, -.frame_header = >av1_frame_header, -.tile_list = >tile_list, +ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoKHR) { +.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_KHR, +.pStdPictureInfo = >std_pic_info, +.tileCount = ap->tile_count, +.pTileOffsets = ap->tile_offsets, Mentioned this on IRC earlier, but this means the driver always get pTileOffsets = NULL, since ap->tile_offsets only gets filled out during vk_av1_decode_slice(). Thanks, already fixed it, I did report back on IRC. + +ap->loop_restoration = (StdVideoAV1LoopRestoration) { +.FrameRestorationType[0] = remap_lr_type[frame_header->lr_type[0]], +.FrameRestorationType[1] = remap_lr_type[frame_header->lr_type[1]], +.FrameRestorationType[2] = remap_lr_type[frame_header->lr_type[2]], +.LoopRestorationSize[0] = AV1_RESTORATION_TILESIZE_MAX >> (2 - frame_header->lr_unit_shift), +.LoopRestorationSize[1] = ap->loop_restoration.LoopRestorationSize[0] >> frame_header->lr_uv_shift, +.LoopRestorationSize[2] = ap->loop_restoration.LoopRestorationSize[0] >> frame_header->lr_uv_shift, +}; Not sure what the C spec says, but at least on GCC 13.2.1 it seems like the assignment for LoopRestorationSize[1] and [2] happens before the initalization of LoopRestorationSize[0]. Nothing here on gcc-12, gcc-14 and clang-19. If some compilers break with it, then it needs to be changed. So make it: ap->loop_restoration = (StdVideoAV1LoopRestoration) { .FrameRestorationType[0] = remap_lr_type[frame_header->lr_type[0]], .FrameRestorationType[1] = remap_lr_type[frame_header->lr_type[1]], .FrameRestorationType[2] = remap_lr_type[frame_header->lr_type[2]], .LoopRestorationSize[0] = AV1_RESTORATION_TILESIZE_MAX >> (2 - frame_header->lr_unit_shift), }; ap->loop_restoration.LoopRestorationSize[1] = ap->loop_restoration.LoopRestorationSize[2] = ap->loop_restoration.LoopRestorationSize[0] >> frame_header->lr_uv_shift, ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API
Feb 13, 2024, 01:59 by ffmpeg-devel@ffmpeg.org: > On Sun Feb 11, 2024 at 10:15 AM EST, Lynne wrote: > >> From: Lynne >> Date: Fri, 19 Jan 2024 10:49:02 +1000 >> Subject: [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API >> >> Most of this patch was written by Dave Airlie , >> with some additions by me. >> --- >> >> >> -ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoMESA) { >> -.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_MESA, >> -.frame_header = >av1_frame_header, >> -.tile_list = >tile_list, >> +ap->av1_pic_info = (VkVideoDecodeAV1PictureInfoKHR) { >> +.sType = VK_STRUCTURE_TYPE_VIDEO_DECODE_AV1_PICTURE_INFO_KHR, >> +.pStdPictureInfo = >std_pic_info, >> +.tileCount = ap->tile_count, >> +.pTileOffsets = ap->tile_offsets, >> > > Mentioned this on IRC earlier, but this means the driver always get > pTileOffsets = NULL, since ap->tile_offsets only gets filled out during > vk_av1_decode_slice(). > Thanks, already fixed it, I did report back on IRC. >> + >> +ap->loop_restoration = (StdVideoAV1LoopRestoration) { >> +.FrameRestorationType[0] = remap_lr_type[frame_header->lr_type[0]], >> +.FrameRestorationType[1] = remap_lr_type[frame_header->lr_type[1]], >> +.FrameRestorationType[2] = remap_lr_type[frame_header->lr_type[2]], >> +.LoopRestorationSize[0] = AV1_RESTORATION_TILESIZE_MAX >> (2 - >> frame_header->lr_unit_shift), >> +.LoopRestorationSize[1] = >> ap->loop_restoration.LoopRestorationSize[0] >> frame_header->lr_uv_shift, >> +.LoopRestorationSize[2] = >> ap->loop_restoration.LoopRestorationSize[0] >> frame_header->lr_uv_shift, >> +}; >> > > Not sure what the C spec says, but at least on GCC 13.2.1 it seems like > the assignment for LoopRestorationSize[1] and [2] happens before the > initalization of LoopRestorationSize[0]. > Nothing here on gcc-12, gcc-14 and clang-19. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API
On Sun Feb 11, 2024 at 10:15 AM EST, Lynne wrote: > From: Lynne > Date: Fri, 19 Jan 2024 10:49:02 +1000 > Subject: [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API > > Most of this patch was written by Dave Airlie , > with some additions by me. > --- > configure | 4 +- > libavcodec/Makefile | 3 +- > libavcodec/av1.h | 2 + > libavcodec/vulkan_av1.c | 477 ++ > libavcodec/vulkan_decode.c| 24 +- > libavcodec/vulkan_decode.h| 2 +- > libavcodec/vulkan_video.c | 2 +- > libavcodec/vulkan_video.h | 2 - > libavcodec/vulkan_video_codec_av1std.h| 403 --- > libavcodec/vulkan_video_codec_av1std_decode.h | 36 -- > libavutil/hwcontext_vulkan.c | 2 +- > libavutil/vulkan_functions.h | 2 +- > libavutil/vulkan_loader.h | 2 +- > 13 files changed, 277 insertions(+), 684 deletions(-) > delete mode 100644 libavcodec/vulkan_video_codec_av1std.h > delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode.h > > diff --git a/configure b/configure > index f72533b7d2..9a3a451115 100755 > --- a/configure > +++ b/configure > @@ -7225,8 +7225,8 @@ enabled crystalhd && check_lib crystalhd "stdint.h > libcrystalhd/libcrystalhd_if. > "in maintaining it." > > if enabled vulkan; then > -check_pkg_config_header_only vulkan "vulkan >= 1.3.255" > "vulkan/vulkan.h" "defined VK_VERSION_1_3" || > -check_cpp_condition vulkan "vulkan/vulkan.h" > "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= > 255)" > +check_pkg_config_header_only vulkan "vulkan >= 1.3.277" > "vulkan/vulkan.h" "defined VK_VERSION_1_3" || > +check_cpp_condition vulkan "vulkan/vulkan.h" > "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= > 277)" > fi > > if disabled vulkan; then > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index 470d7cb9b1..581415f3b7 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -1262,7 +1262,6 @@ SKIPHEADERS+= %_tablegen.h > \ >aacenc_quantization.h \ >aacenc_quantization_misc.h\ >bitstream_template.h \ > - vulkan_video_codec_av1std.h \ >$(ARCH)/vpx_arith.h \ > > SKIPHEADERS-$(CONFIG_AMF) += amfenc.h > @@ -1285,7 +1284,7 @@ SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h > SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h > vaapi_encode.h > SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h > SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h > -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h > vulkan_decode.h vulkan_video_codec_av1std_decode.h > +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h > vulkan_decode.h > SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h > v4l2_m2m.h > SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h > > diff --git a/libavcodec/av1.h b/libavcodec/av1.h > index 8704bc41c1..18d5fa9e7f 100644 > --- a/libavcodec/av1.h > +++ b/libavcodec/av1.h > @@ -121,6 +121,8 @@ enum { > AV1_DIV_LUT_NUM = 257, > > AV1_MAX_LOOP_FILTER = 63, > + > +AV1_RESTORATION_TILESIZE_MAX = 256, > }; > > > diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c > index 9730e4b08d..641ee3e4bf 100644 > --- a/libavcodec/vulkan_av1.c > +++ b/libavcodec/vulkan_av1.c > @@ -31,22 +31,36 @@ const VkExtensionProperties ff_vk_dec_av1_ext = { > typedef struct AV1VulkanDecodePicture { > FFVulkanDecodePicture vp; > > -/* Workaround for a spec issue. > - *Can be removed once no longer needed, and threading can be enabled. */ > +/* TODO: investigate if this can be removed to make decoding completely > + * independent. */ > FFVulkanDecodeContext *dec; > > -StdVideoAV1MESATiletiles[MAX_TILES]; > -StdVideoAV1MESATileListtile_list; > -const uint32_t*tile_offsets; > +uint32_t tile_count; > +uint32_t tile_sizes[MAX_TILES]; > +const uint32_t *tile_offsets; > > /* Current picture */ > -VkVideoDecodeAV1DpbSlotInfoMESAvkav1_ref; > -StdVideoAV1MESAFrameHeader av1_frame_header; > -VkVideoDecodeAV1PictureInfoMESAav1_pic_info; > +StdVideoDecodeAV1ReferenceInfo std_ref; > +VkVideoDecodeAV1DpbSlotInfoKHR vkav1_ref; > +uint16_t width_in_sbs_minus1[64]; > +uint16_t height_in_sbs_minus1[64]; > +
[FFmpeg-devel] [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API
Most of this patch was written by Dave Airlie , with some additions by me. >From 4a0c01046e36cff48100d09565f5ef8d8185907a Mon Sep 17 00:00:00 2001 From: Lynne Date: Fri, 19 Jan 2024 10:49:02 +1000 Subject: [PATCH v4 2/2] lavc/vulkan_av1: port to the new stable API Most of this patch was written by Dave Airlie , with some additions by me. --- configure | 4 +- libavcodec/Makefile | 3 +- libavcodec/av1.h | 2 + libavcodec/vulkan_av1.c | 477 ++ libavcodec/vulkan_decode.c| 24 +- libavcodec/vulkan_decode.h| 2 +- libavcodec/vulkan_video.c | 2 +- libavcodec/vulkan_video.h | 2 - libavcodec/vulkan_video_codec_av1std.h| 403 --- libavcodec/vulkan_video_codec_av1std_decode.h | 36 -- libavutil/hwcontext_vulkan.c | 2 +- libavutil/vulkan_functions.h | 2 +- libavutil/vulkan_loader.h | 2 +- 13 files changed, 277 insertions(+), 684 deletions(-) delete mode 100644 libavcodec/vulkan_video_codec_av1std.h delete mode 100644 libavcodec/vulkan_video_codec_av1std_decode.h diff --git a/configure b/configure index f72533b7d2..9a3a451115 100755 --- a/configure +++ b/configure @@ -7225,8 +7225,8 @@ enabled crystalhd && check_lib crystalhd "stdint.h libcrystalhd/libcrystalhd_if. "in maintaining it." if enabled vulkan; then -check_pkg_config_header_only vulkan "vulkan >= 1.3.255" "vulkan/vulkan.h" "defined VK_VERSION_1_3" || -check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 255)" +check_pkg_config_header_only vulkan "vulkan >= 1.3.277" "vulkan/vulkan.h" "defined VK_VERSION_1_3" || +check_cpp_condition vulkan "vulkan/vulkan.h" "defined(VK_VERSION_1_4) || (defined(VK_VERSION_1_3) && VK_HEADER_VERSION >= 277)" fi if disabled vulkan; then diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 470d7cb9b1..581415f3b7 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -1262,7 +1262,6 @@ SKIPHEADERS+= %_tablegen.h \ aacenc_quantization.h \ aacenc_quantization_misc.h\ bitstream_template.h \ - vulkan_video_codec_av1std.h \ $(ARCH)/vpx_arith.h \ SKIPHEADERS-$(CONFIG_AMF) += amfenc.h @@ -1285,7 +1284,7 @@ SKIPHEADERS-$(CONFIG_XVMC) += xvmc.h SKIPHEADERS-$(CONFIG_VAAPI)+= vaapi_decode.h vaapi_hevc.h vaapi_encode.h SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vt_internal.h -SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h vulkan_video_codec_av1std_decode.h +SKIPHEADERS-$(CONFIG_VULKAN) += vulkan.h vulkan_video.h vulkan_decode.h SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h diff --git a/libavcodec/av1.h b/libavcodec/av1.h index 8704bc41c1..18d5fa9e7f 100644 --- a/libavcodec/av1.h +++ b/libavcodec/av1.h @@ -121,6 +121,8 @@ enum { AV1_DIV_LUT_NUM = 257, AV1_MAX_LOOP_FILTER = 63, + +AV1_RESTORATION_TILESIZE_MAX = 256, }; diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index 9730e4b08d..641ee3e4bf 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -31,22 +31,36 @@ const VkExtensionProperties ff_vk_dec_av1_ext = { typedef struct AV1VulkanDecodePicture { FFVulkanDecodePicture vp; -/* Workaround for a spec issue. - *Can be removed once no longer needed, and threading can be enabled. */ +/* TODO: investigate if this can be removed to make decoding completely + * independent. */ FFVulkanDecodeContext *dec; -StdVideoAV1MESATiletiles[MAX_TILES]; -StdVideoAV1MESATileListtile_list; -const uint32_t*tile_offsets; +uint32_t tile_count; +uint32_t tile_sizes[MAX_TILES]; +const uint32_t *tile_offsets; /* Current picture */ -VkVideoDecodeAV1DpbSlotInfoMESAvkav1_ref; -StdVideoAV1MESAFrameHeader av1_frame_header; -VkVideoDecodeAV1PictureInfoMESAav1_pic_info; +StdVideoDecodeAV1ReferenceInfo std_ref; +VkVideoDecodeAV1DpbSlotInfoKHR vkav1_ref; +uint16_t width_in_sbs_minus1[64]; +uint16_t height_in_sbs_minus1[64]; +uint16_t mi_col_starts[64]; +uint16_t mi_row_starts[64]; +StdVideoAV1TileInfo tile_info; +StdVideoAV1Quantization quantization; +