Skip to contentSkip to conversation

package/ffmpeg: add optional dependency to vulkan-headers

PATCH New Bernd Kuhls 1 participant 1 message May 24

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/ffmpeg: add optional dependency to vulkan-headers

ffmpeg added optional vulkan support to version 4.3 with upstream commit
https://git.videolan.org/?p=ffmpeg.git;a=commit;h=a88449ffb2f249e31ecf98f84e7f8c338308e7e4

Buildroot bumped ffmpeg to 4.3 with commit d6312941d66886bea75ad9915bf406cf9472c04d but did not add configure options so we relied on ffmpeg's autodetection.

Building this defconfig

BR2_PACKAGE_FFMPEG=y
BR2_PACKAGE_VULKAN_HEADERS=y

is broken with certain toolchains when vulkan-headers was built before ffmpeg:

                             arm-aarch64 [ 1/32]: OK
                   bootlin-aarch64-glibc [ 2/32]: OK
               bootlin-aarch64-glibc-old [ 3/32]: OK
               bootlin-arcle-hs38-uclibc [ 4/32]: FAILED
                    bootlin-armv5-uclibc [ 5/32]: FAILED
                     bootlin-armv7-glibc [ 6/32]: FAILED
                   bootlin-armv7m-uclibc [ 7/32]: SKIPPED
                      bootlin-armv7-musl [ 8/32]: FAILED
                bootlin-m68k-5208-uclibc [ 9/32]: SKIPPED
               bootlin-m68k-68040-uclibc [10/32]: FAILED
             bootlin-microblazeel-uclibc [11/32]: FAILED
                  bootlin-mips64el-glibc [12/32]: FAILED
                bootlin-mipsel32r6-glibc [13/32]: FAILED
                   bootlin-mipsel-uclibc [14/32]: FAILED
                 bootlin-openrisc-uclibc [15/32]: FAILED
        bootlin-powerpc64le-power8-glibc [16/32]: OK
           bootlin-powerpc-e500mc-uclibc [17/32]: FAILED
                   bootlin-riscv32-glibc [18/32]: FAILED
                   bootlin-riscv64-glibc [19/32]: OK
                    bootlin-riscv64-musl [20/32]: OK
                 bootlin-s390x-z13-glibc [21/32]: OK
                      bootlin-sh4-uclibc [22/32]: FAILED
                   bootlin-sparc64-glibc [23/32]: OK
                    bootlin-sparc-uclibc [24/32]: FAILED
                    bootlin-x86-64-glibc [25/32]: OK
                     bootlin-x86-64-musl [26/32]: OK
                   bootlin-x86-64-uclibc [27/32]: OK
                   bootlin-x86-i686-musl [28/32]: FAILED
                   bootlin-xtensa-uclibc [29/32]: FAILED
                            br-arm-basic [30/32]: SKIPPED
                    br-arm-full-nothread [31/32]: SKIPPED
                      br-arm-full-static [32/32]: FAILED

32 builds, 4 skipped, 17 build failed, 0 legal-info failed, 0 show-info failed

This patch adds configure options for vulkan support which will cause the build errors quoted above. Vulkan support depends on dynamic library:
https://git.videolan.org/?p=ffmpeg.git;a=blob;f=configure;h=49f59a1962b359587fd17a53821cdebd17ae3132;hb=a44ab44236a99ae26594fb3e14fe0c956210673d#l3061

So we also add an upstream patch which was added to ffmpeg 7.0 to fix the build errors:

                             arm-aarch64 [ 1/32]: OK
                   bootlin-aarch64-glibc [ 2/32]: OK
               bootlin-aarch64-glibc-old [ 3/32]: OK
               bootlin-arcle-hs38-uclibc [ 4/32]: OK
                    bootlin-armv5-uclibc [ 5/32]: OK
                     bootlin-armv7-glibc [ 6/32]: OK
                   bootlin-armv7m-uclibc [ 7/32]: SKIPPED
                      bootlin-armv7-musl [ 8/32]: OK
                bootlin-m68k-5208-uclibc [ 9/32]: SKIPPED
               bootlin-m68k-68040-uclibc [10/32]: OK
             bootlin-microblazeel-uclibc [11/32]: OK
                  bootlin-mips64el-glibc [12/32]: OK
                bootlin-mipsel32r6-glibc [13/32]: OK
                   bootlin-mipsel-uclibc [14/32]: OK
                 bootlin-openrisc-uclibc [15/32]: OK
        bootlin-powerpc64le-power8-glibc [16/32]: OK
           bootlin-powerpc-e500mc-uclibc [17/32]: OK
                   bootlin-riscv32-glibc [18/32]: OK
                   bootlin-riscv64-glibc [19/32]: OK
                    bootlin-riscv64-musl [20/32]: OK
                 bootlin-s390x-z13-glibc [21/32]: OK
                      bootlin-sh4-uclibc [22/32]: OK
                   bootlin-sparc64-glibc [23/32]: OK
                    bootlin-sparc-uclibc [24/32]: OK
                    bootlin-x86-64-glibc [25/32]: OK
                     bootlin-x86-64-musl [26/32]: OK
                   bootlin-x86-64-uclibc [27/32]: OK
                   bootlin-x86-i686-musl [28/32]: FAILED
                   bootlin-xtensa-uclibc [29/32]: OK
                            br-arm-basic [30/32]: SKIPPED
                    br-arm-full-nothread [31/32]: SKIPPED
                      br-arm-full-static [32/32]: OK

32 builds, 4 skipped, 1 build failed, 0 legal-info failed, 0 show-info failed

Please note that the build error with bootlin-x86-i686-musl is unrelated.

This build error was not yet recorded by the autobuilders.

---
 ...vcodec-fix-Wint-conversion-in-vulkan.patch | 105 ++++++++++++++++++
 package/ffmpeg/ffmpeg.mk                      |   7 ++
 2 files changed, 112 insertions(+)
 create mode 100644 package/ffmpeg/0008-libavcodec-fix-Wint-conversion-in-vulkan.patch
package/ffmpeg/0008-libavcodec-fix-Wint-conversion-in-vulkan.patch new file +105 -0
new file mode 100644
index 0000000000..9dcb1dc329
@@ -0,0 +1,105 @@
+From 2f24f10d9cf34ddce274496c4daa73f732d370c1 Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Wed, 20 Dec 2023 12:32:43 +0000
+Subject: [PATCH] libavcodec: fix -Wint-conversion in vulkan
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+FIx warnings (soon to be errors in GCC 14, already so in Clang 15):
+```
+src/libavcodec/vulkan_av1.c: In function ‘vk_av1_create_params’:
+src/libavcodec/vulkan_av1.c:183:43: error: initialization of ‘long long unsigned int’ from ‘void *’ makes integer from pointer without a cast [-Wint-conversion]
+  183 |         .videoSessionParametersTemplate = NULL,
+      |                                           ^~~~
+src/libavcodec/vulkan_av1.c:183:43: note: (near initialization for ‘(anonymous).videoSessionParametersTemplate’)
+```
+
+Use Vulkan's VK_NULL_HANDLE instead of bare NULL.
+
+Fix Trac ticket #10724.
+
+Was reported downstream in Gentoo at https://bugs.gentoo.org/919067.
+
+Signed-off-by: Sam James <[email protected]>
+
+Upstream: https://git.videolan.org/?p=ffmpeg.git;a=commit;h=2f24f10d9cf34ddce274496c4daa73f732d370c1
+
+Signed-off-by: Bernd Kuhls <[email protected]>
+---
+ libavcodec/vulkan_av1.c    | 2 +-
+ libavcodec/vulkan_decode.c | 6 +++---
+ libavcodec/vulkan_h264.c   | 2 +-
+ libavcodec/vulkan_hevc.c   | 2 +-
+ libavcodec/vulkan_video.c  | 2 +-
+ 5 files changed, 7 insertions(+), 7 deletions(-)
+
+diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c
+index 4998bf7ebc55f..9730e4b08dd40 100644
+--- a/libavcodec/vulkan_av1.c
++++ b/libavcodec/vulkan_av1.c
+@@ -180,7 +180,7 @@ static int vk_av1_create_params(AVCodecContext *avctx, AVBufferRef **buf)
+         .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
+         .pNext = &av1_params,
+         .videoSession = ctx->common.session,
+-        .videoSessionParametersTemplate = NULL,
++        .videoSessionParametersTemplate = VK_NULL_HANDLE,
+     };
+ 
+     err = ff_vk_decode_create_params(buf, avctx, ctx, &session_params_create);
+diff --git a/libavcodec/vulkan_decode.c b/libavcodec/vulkan_decode.c
+index a89d84fcaa972..fdbcbb450a1e0 100644
+--- a/libavcodec/vulkan_decode.c
++++ b/libavcodec/vulkan_decode.c
+@@ -188,9 +188,9 @@ int ff_vk_decode_prepare_frame(FFVulkanDecodeContext *dec, AVFrame *pic,
+         return 0;
+ 
+     vkpic->dpb_frame     = NULL;
+-    vkpic->img_view_ref  = NULL;
+-    vkpic->img_view_out  = NULL;
+-    vkpic->img_view_dest = NULL;
++    vkpic->img_view_ref  = VK_NULL_HANDLE;
++    vkpic->img_view_out  = VK_NULL_HANDLE;
++    vkpic->img_view_dest = VK_NULL_HANDLE;
+ 
+     vkpic->destroy_image_view = vk->DestroyImageView;
+     vkpic->wait_semaphores = vk->WaitSemaphores;
+diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c
+index e727aafb162d3..39c123ddca57e 100644
+--- a/libavcodec/vulkan_h264.c
++++ b/libavcodec/vulkan_h264.c
+@@ -315,7 +315,7 @@ static int vk_h264_create_params(AVCodecContext *avctx, AVBufferRef **buf)
+         .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
+         .pNext = &h264_params,
+         .videoSession = ctx->common.session,
+-        .videoSessionParametersTemplate = NULL,
++        .videoSessionParametersTemplate = VK_NULL_HANDLE,
+     };
+ 
+     /* SPS list */
+diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c
+index 99fdcf3b45839..033172cbd6958 100644
+--- a/libavcodec/vulkan_hevc.c
++++ b/libavcodec/vulkan_hevc.c
+@@ -653,7 +653,7 @@ static int vk_hevc_create_params(AVCodecContext *avctx, AVBufferRef **buf)
+         .sType = VK_STRUCTURE_TYPE_VIDEO_SESSION_PARAMETERS_CREATE_INFO_KHR,
+         .pNext = &h265_params,
+         .videoSession = ctx->common.session,
+-        .videoSessionParametersTemplate = NULL,
++        .videoSessionParametersTemplate = VK_NULL_HANDLE,
+     };
+ 
+     HEVCHeaderSet *hdr;
+diff --git a/libavcodec/vulkan_video.c b/libavcodec/vulkan_video.c
+index 5fa8292b28eaf..fb20315db4bbf 100644
+--- a/libavcodec/vulkan_video.c
++++ b/libavcodec/vulkan_video.c
+@@ -287,7 +287,7 @@ av_cold void ff_vk_video_common_uninit(FFVulkanContext *s,
+     if (common->session) {
+         vk->DestroyVideoSessionKHR(s->hwctx->act_dev, common->session,
+                                    s->hwctx->alloc);
+-        common->session = NULL;
++        common->session = VK_NULL_HANDLE;
+     }
+ 
+     if (common->nb_mem && common->mem)
package/ffmpeg/ffmpeg.mk +7 -0
index 1289cd5e72..5585c16bc9 100644
@@ -287,6 +287,13 @@ else
 FFMPEG_CONF_OPTS += --disable-vdpau
 endif
 
+ifeq ($(BR2_PACKAGE_VULKAN_HEADERS)x$(BR2_STATIC_LIBS),yx)
+FFMPEG_CONF_OPTS += --enable-vulkan
+FFMPEG_DEPENDENCIES += vulkan-headers
+else
+FFMPEG_CONF_OPTS += --disable-vulkan
+endif
+
 # To avoid a circular dependency only use opencv if opencv itself does
 # not depend on ffmpeg.
 ifeq ($(BR2_PACKAGE_OPENCV4_LIB_IMGPROC)x$(BR2_PACKAGE_OPENCV4_WITH_FFMPEG),yx)
Signature · 6 lines
2.47.3

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot