diff options
Diffstat (limited to 'media-video/ffmpeg/files')
28 files changed, 1291 insertions, 97 deletions
diff --git a/media-video/ffmpeg/files/amf-env-vulkan-override b/media-video/ffmpeg/files/amf-env-vulkan-override new file mode 100644 index 000000000000..41ee27911178 --- /dev/null +++ b/media-video/ffmpeg/files/amf-env-vulkan-override @@ -0,0 +1 @@ +VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/amd_pro_icd64.json diff --git a/media-video/ffmpeg/files/chromium-r2.patch b/media-video/ffmpeg/files/chromium-r2.patch new file mode 100644 index 000000000000..1de86fe09a1e --- /dev/null +++ b/media-video/ffmpeg/files/chromium-r2.patch @@ -0,0 +1,41 @@ +Allow libffmpeg to be built for Chromium-based browsers +https://patchwork.ffmpeg.org/patch/4500/ + +NOTE: This patch lacks the Makefile include line. We append it +manually instead to make patching across different versions easier. + +diff --git a/ffbuild/libffmpeg.mak b/ffbuild/libffmpeg.mak +new file mode 100644 +index 0000000..992cf3c +--- /dev/null ++++ b/ffbuild/libffmpeg.mak +@@ -0,0 +1,27 @@ ++LIBFFMPEG = $(SLIBPREF)ffmpeg$(SLIBSUF) ++LIBFFMPEG_LINK = $(LD) -shared -Wl,-soname,$(LIBFFMPEG) -Wl,-Bsymbolic -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,--gc-sections $(LDFLAGS) $(LDLIBFLAGS) -o $(LIBFFMPEG) ++ ++ifeq ($(CONFIG_SHARED),yes) ++LIBFFMPEG_DEPS = libavcodec/$(SLIBPREF)avcodec$(SLIBSUF) libavformat/$(SLIBPREF)avformat$(SLIBSUF) libavutil/$(SLIBPREF)avutil$(SLIBSUF) ++else ++LIBFFMPEG_DEPS = libavcodec/$(LIBPREF)avcodec$(LIBSUF) libavformat/$(LIBPREF)avformat$(LIBSUF) libavutil/$(LIBPREF)avutil$(LIBSUF) libswresample/$(LIBPREF)swresample$(LIBSUF) ++endif ++ ++$(LIBFFMPEG): $(LIBFFMPEG_DEPS) chromium.o ++ifeq ($(CONFIG_SHARED),yes) ++ $(LIBFFMPEG_LINK) -Wl,--no-as-needed chromium.o -lavcodec -lavformat -lavutil ++else ++ $(LIBFFMPEG_LINK) -Wl,--whole-archive $^ -Wl,--no-whole-archive $(EXTRALIBS-avcodec) $(EXTRALIBS-avformat) $(EXTRALIBS-avutil) $(EXTRALIBS-swresample) ++endif ++ ++libffmpeg: $(LIBFFMPEG) ++ ++install-libffmpeg: $(LIBFFMPEG) ++ $(Q)mkdir -p "$(SHLIBDIR)/chromium" ++ $(INSTALL) -m 755 $< "$(SHLIBDIR)/chromium/$<" ++ $(STRIP) "$(SHLIBDIR)/chromium/$<" ++ ++uninstall-libffmpeg: ++ $(RM) "$(SHLIBDIR)/chromium/$(LIBFFMPEG)" ++ ++.PHONY: libffmpeg install-libffmpeg uninstall-libffmpeg +-- +2.13.1 diff --git a/media-video/ffmpeg/files/chromium.c b/media-video/ffmpeg/files/chromium.c new file mode 100644 index 000000000000..66c2e9f6614f --- /dev/null +++ b/media-video/ffmpeg/files/chromium.c @@ -0,0 +1,8 @@ +#include "libavformat/avformat.h" +#include "libavformat/internal.h" + +int64_t av_stream_get_first_dts(const AVStream *st); +int64_t av_stream_get_first_dts(const AVStream *st) +{ + return cffstream(st)->first_dts; +} diff --git a/media-video/ffmpeg/files/ffmpeg-4.3-altivec-novsx-yuv2rgb.patch b/media-video/ffmpeg/files/ffmpeg-4.3-altivec-novsx-yuv2rgb.patch deleted file mode 100644 index 40e7f9161726..000000000000 --- a/media-video/ffmpeg/files/ffmpeg-4.3-altivec-novsx-yuv2rgb.patch +++ /dev/null @@ -1,23 +0,0 @@ -Fixes build on ppc.
-https://trac.ffmpeg.org/attachment/ticket/8750/ffmpeg_altivec_yuv2rgb_novsx.patch
-diff --git a/libswscale/ppc/yuv2rgb_altivec.c b/libswscale/ppc/yuv2rgb_altivec.c
-index 536545293d..930ef6b98f 100644
---- a/libswscale/ppc/yuv2rgb_altivec.c
-+++ b/libswscale/ppc/yuv2rgb_altivec.c
-@@ -283,6 +283,16 @@ static inline void cvtyuvtoRGB(SwsContext *c, vector signed short Y,
- * ------------------------------------------------------------------------------
- */
-
-+#if !HAVE_VSX
-+static inline vector unsigned char vec_xl(signed long long offset, const ubyte *addr)
-+{
-+ const vector unsigned char *v_addr = (const vector unsigned char *) (addr + offset);
-+ vector unsigned char align_perm = vec_lvsl(offset, addr);
-+
-+ return (vector unsigned char) vec_perm(v_addr[0], v_addr[1], align_perm);
-+}
-+#endif /* !HAVE_VSX */
-+
- #define DEFCSP420_CVT(name, out_pixels) \
- static int altivec_ ## name(SwsContext *c, const unsigned char **in, \
- int *instrides, int srcSliceY, int srcSliceH, \
diff --git a/media-video/ffmpeg/files/ffmpeg-4.3-fix-build-without-SSSE3.patch b/media-video/ffmpeg/files/ffmpeg-4.3-fix-build-without-SSSE3.patch deleted file mode 100644 index c3e6733160f6..000000000000 --- a/media-video/ffmpeg/files/ffmpeg-4.3-fix-build-without-SSSE3.patch +++ /dev/null @@ -1,22 +0,0 @@ -https://bugs.gentoo.org/728566 -http://ffmpeg.org/pipermail/ffmpeg-devel/2020-February/257474.html - ---- a/libswscale/x86/yuv2rgb.c -+++ b/libswscale/x86/yuv2rgb.c -@@ -83,6 +83,7 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) - #if HAVE_X86ASM - int cpu_flags = av_get_cpu_flags(); - -+#if HAVE_SSSE3 - if (EXTERNAL_SSSE3(cpu_flags)) { - switch (c->dstFormat) { - case AV_PIX_FMT_RGB32: -@@ -111,6 +112,7 @@ av_cold SwsFunc ff_yuv2rgb_init_x86(SwsContext *c) - return yuv420_rgb15_ssse3; - } - } -+#endif - - if (EXTERNAL_MMXEXT(cpu_flags)) { - switch (c->dstFormat) { - diff --git a/media-video/ffmpeg/files/ffmpeg-4.3.1-srt-1.4.2-build.patch b/media-video/ffmpeg/files/ffmpeg-4.3.1-srt-1.4.2-build.patch deleted file mode 100644 index 691314cbacb8..000000000000 --- a/media-video/ffmpeg/files/ffmpeg-4.3.1-srt-1.4.2-build.patch +++ /dev/null @@ -1,52 +0,0 @@ -http://git.videolan.org/?p=ffmpeg.git;a=patch;h=7c59e1b0f285cd7c7b35fcd71f49c5fd52cf9315 -https://bugs.gentoo.org/756859 -From 7c59e1b0f285cd7c7b35fcd71f49c5fd52cf9315 Mon Sep 17 00:00:00 2001 -From: Jun Zhao <barryjzhao@tencent.com> -Date: Sun, 12 Jul 2020 13:48:48 +0800 -Subject: [PATCH] lavf/srt: fix build fail when used the libsrt 1.4.1 - -libsrt changed the: -SRTO_SMOOTHER -> SRTO_CONGESTION -SRTO_STRICTENC -> SRTO_ENFORCEDENCRYPTION -and removed the front of deprecated options (SRTO_SMOOTHER/SRTO_STRICTENC) -in the header, it's lead to build fail - -fix #8760 - -Signed-off-by: Jun Zhao <barryjzhao@tencent.com> ---- - libavformat/libsrt.c | 8 ++++++++ - 1 file changed, 8 insertions(+) - -diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c -index 4de575b37c..4719ce0d4b 100644 ---- a/libavformat/libsrt.c -+++ b/libavformat/libsrt.c -@@ -313,8 +313,12 @@ static int libsrt_set_options_pre(URLContext *h, int fd) - (s->pbkeylen >= 0 && libsrt_setsockopt(h, fd, SRTO_PBKEYLEN, "SRTO_PBKEYLEN", &s->pbkeylen, sizeof(s->pbkeylen)) < 0) || - (s->passphrase && libsrt_setsockopt(h, fd, SRTO_PASSPHRASE, "SRTO_PASSPHRASE", s->passphrase, strlen(s->passphrase)) < 0) || - #if SRT_VERSION_VALUE >= 0x010302 -+#if SRT_VERSION_VALUE >= 0x010401 -+ (s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_ENFORCEDENCRYPTION, "SRTO_ENFORCEDENCRYPTION", &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) || -+#else - /* SRTO_STRICTENC == SRTO_ENFORCEDENCRYPTION (53), but for compatibility, we used SRTO_STRICTENC */ - (s->enforced_encryption >= 0 && libsrt_setsockopt(h, fd, SRTO_STRICTENC, "SRTO_STRICTENC", &s->enforced_encryption, sizeof(s->enforced_encryption)) < 0) || -+#endif - (s->kmrefreshrate >= 0 && libsrt_setsockopt(h, fd, SRTO_KMREFRESHRATE, "SRTO_KMREFRESHRATE", &s->kmrefreshrate, sizeof(s->kmrefreshrate)) < 0) || - (s->kmpreannounce >= 0 && libsrt_setsockopt(h, fd, SRTO_KMPREANNOUNCE, "SRTO_KMPREANNOUNCE", &s->kmpreannounce, sizeof(s->kmpreannounce)) < 0) || - #endif -@@ -333,7 +337,11 @@ static int libsrt_set_options_pre(URLContext *h, int fd) - (s->lossmaxttl >= 0 && libsrt_setsockopt(h, fd, SRTO_LOSSMAXTTL, "SRTO_LOSSMAXTTL", &s->lossmaxttl, sizeof(s->lossmaxttl)) < 0) || - (s->minversion >= 0 && libsrt_setsockopt(h, fd, SRTO_MINVERSION, "SRTO_MINVERSION", &s->minversion, sizeof(s->minversion)) < 0) || - (s->streamid && libsrt_setsockopt(h, fd, SRTO_STREAMID, "SRTO_STREAMID", s->streamid, strlen(s->streamid)) < 0) || -+#if SRT_VERSION_VALUE >= 0x010401 -+ (s->smoother && libsrt_setsockopt(h, fd, SRTO_CONGESTION, "SRTO_CONGESTION", s->smoother, strlen(s->smoother)) < 0) || -+#else - (s->smoother && libsrt_setsockopt(h, fd, SRTO_SMOOTHER, "SRTO_SMOOTHER", s->smoother, strlen(s->smoother)) < 0) || -+#endif - (s->messageapi >= 0 && libsrt_setsockopt(h, fd, SRTO_MESSAGEAPI, "SRTO_MESSAGEAPI", &s->messageapi, sizeof(s->messageapi)) < 0) || - (s->payload_size >= 0 && libsrt_setsockopt(h, fd, SRTO_PAYLOADSIZE, "SRTO_PAYLOADSIZE", &s->payload_size, sizeof(s->payload_size)) < 0) || - ((h->flags & AVIO_FLAG_WRITE) && libsrt_setsockopt(h, fd, SRTO_SENDER, "SRTO_SENDER", &yes, sizeof(yes)) < 0)) { --- -2.20.1 - diff --git a/media-video/ffmpeg/files/ffmpeg-4.4.3-clang-14-ff_seek_frame_binary-crash.patch b/media-video/ffmpeg/files/ffmpeg-4.4.3-clang-14-ff_seek_frame_binary-crash.patch new file mode 100644 index 000000000000..c8733ea2382f --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-4.4.3-clang-14-ff_seek_frame_binary-crash.patch @@ -0,0 +1,46 @@ +https://github.com/FFmpeg/FFmpeg/commit/ab792634197e364ca1bb194f9abe36836e42f12d + +(Rebased for 4.4.x in Gentoo.) + +From ab792634197e364ca1bb194f9abe36836e42f12d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Martin=20Storsj=C3=B6?= <martin@martin.st> +Date: Mon, 18 Oct 2021 12:31:38 +0300 +Subject: [PATCH] seek: Fix crashes in ff_seek_frame_binary if built with + latest Clang 14 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Passing an uninitialized variable as argument to a function is +undefined behaviour (UB). The compiler can assume that UB does not +happen. + +Hence, the compiler can assume that the variables are never +uninitialized when passed as argument, which means that the codepaths +that initializes them must be taken. + +In ff_seek_frame_binary, this means that the compiler can assume +that the codepaths that initialize pos_min and pos_max are taken, +which means that the conditions "if (sti->index_entries)" and +"if (index >= 0)" can be optimized out. + +Current Clang git versions (upcoming Clang 14) enabled an optimization +that does this, which broke the current version of this function +(which intentionally left the variables uninitialized, but silencing +warnings about being uninitialized). See [1] for discussion on +the matter. + +[1] https://reviews.llvm.org/D105169#3069555 + +Signed-off-by: Martin Storsjö <martin@martin.st> +--- a/libavformat/utils.c ++++ b/libavformat/utils.c +@@ -2146,7 +2146,7 @@ int ff_seek_frame_binary(AVFormatContext *s, int stream_index, + int64_t target_ts, int flags) + { + const AVInputFormat *avif = s->iformat; +- int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; ++ int64_t pos_min = 0, pos_max = 0, pos, pos_limit; + int64_t ts_min, ts_max, ts; + int index; + int64_t ret; diff --git a/media-video/ffmpeg/files/ffmpeg-4.4.3-get_cabac_inline_x86-32-bit.patch b/media-video/ffmpeg/files/ffmpeg-4.4.3-get_cabac_inline_x86-32-bit.patch new file mode 100644 index 000000000000..ed273975452d --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-4.4.3-get_cabac_inline_x86-32-bit.patch @@ -0,0 +1,24 @@ +https://bugs.gentoo.org/901099 and partly https://bugs.gentoo.org/900937. + +Newer compilers may optimise such that < 7 registers are free on 32-bit x86 +and then we get an "invalid asm" error. This is https://bugs.gentoo.org/901099 +and https://trac.ffmpeg.org/ticket/8903. + +Making matters worse, GCC sometimes hangs on invalid asm, so this also +mitigates a hang with e.g. -O3 -march=znver1. See https://bugs.gentoo.org/900937 +and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137. + +In future, we may want to adjust the definition of HAVE_7REGS to just exclude +32-bit x86, but that's a big sledgehammer, so let's avoid it for now until we have +a reply on the upstream ffmpeg bug. +--- a/libavcodec/x86/cabac.h ++++ b/libavcodec/x86/cabac.h +@@ -175,7 +175,7 @@ + + #endif /* BROKEN_RELOCATIONS */ + +-#if HAVE_7REGS && !BROKEN_COMPILER ++#if HAVE_7REGS && !BROKEN_COMPILER && !ARCH_X86_32 + #define get_cabac_inline get_cabac_inline_x86 + static av_always_inline int get_cabac_inline_x86(CABACContext *c, + uint8_t *const state) diff --git a/media-video/ffmpeg/files/ffmpeg-4.4.4-fix-build-svt-av1-1.5.0.patch b/media-video/ffmpeg/files/ffmpeg-4.4.4-fix-build-svt-av1-1.5.0.patch new file mode 100644 index 000000000000..c9c180f06641 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-4.4.4-fix-build-svt-av1-1.5.0.patch @@ -0,0 +1,44 @@ +https://bugs.gentoo.org/907478 +https://bugs.gentoo.org/907493 +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=c3c8f97a9804b4234e97f13b0057ffc2c9af27c0 + +From c3c8f97a9804b4234e97f13b0057ffc2c9af27c0 Mon Sep 17 00:00:00 2001 +From: Christopher Degawa <christopher.degawa@intel.com> +Date: Thu, 20 Oct 2022 22:55:27 -0500 +Subject: [PATCH] avcodec/libsvtav1: remove compressed_ten_bit_format and + simplify alloc_buffer + +compressed_ten_bit_format has been deprecated upstream and has no effect +and can be removed. Plus, technically it was never used in the first place +since it would require the app (ffmpeg) to set it and do additional +processing of the input frames. + +Also simplify alloc_buffer by removing calculations relating to the +non-existant processing. + +Signed-off-by: Christopher Degawa <christopher.degawa@intel.com> +(cherry picked from commit 031f1561cd286596cdb374da32f8aa816ce3b135) +--- a/libavcodec/libsvtav1.c ++++ b/libavcodec/libsvtav1.c +@@ -120,16 +120,12 @@ static int svt_print_error(void *log_ctx, EbErrorType err, + + static int alloc_buffer(EbSvtAv1EncConfiguration *config, SvtContext *svt_enc) + { +- const int pack_mode_10bit = +- (config->encoder_bit_depth > 8) && (config->compressed_ten_bit_format == 0) ? 1 : 0; +- const size_t luma_size_8bit = +- config->source_width * config->source_height * (1 << pack_mode_10bit); +- const size_t luma_size_10bit = +- (config->encoder_bit_depth > 8 && pack_mode_10bit == 0) ? luma_size_8bit : 0; ++ const size_t luma_size = config->source_width * config->source_height * ++ (config->encoder_bit_depth > 8 ? 2 : 1); + + EbSvtIOFormat *in_data; + +- svt_enc->raw_size = (luma_size_8bit + luma_size_10bit) * 3 / 2; ++ svt_enc->raw_size = luma_size * 3 / 2; + + // allocate buffer for in and out + svt_enc->in_buf = av_mallocz(sizeof(*svt_enc->in_buf)); +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-4.4.4-glslang.patch b/media-video/ffmpeg/files/ffmpeg-4.4.4-glslang.patch new file mode 100644 index 000000000000..f19bf8e47a42 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-4.4.4-glslang.patch @@ -0,0 +1,25 @@ +Bug: https://bugs.gentoo.org/926551 + +diff -Naur a/configure b/configure +--- a/configure 2024-03-09 22:07:52.005888104 +0000 ++++ b/configure 2024-03-09 22:08:18.634656978 +0000 +@@ -6374,7 +6374,7 @@ + enabled libfontconfig && require_pkg_config libfontconfig fontconfig "fontconfig/fontconfig.h" FcInit + enabled libfreetype && require_pkg_config libfreetype freetype2 "ft2build.h FT_FREETYPE_H" FT_Init_FreeType + enabled libfribidi && require_pkg_config libfribidi fribidi fribidi.h fribidi_version_info +-enabled libglslang && require_cpp libglslang glslang/SPIRV/GlslangToSpv.h "glslang::TIntermediate*" -lglslang -lMachineIndependent -lOSDependent -lHLSL -lOGLCompiler -lGenericCodeGen -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lpthread -lstdc++ ++enabled libglslang && require_cpp libglslang glslang/SPIRV/GlslangToSpv.h "glslang::TIntermediate*" -lglslang -lSPVRemapper -lSPIRV -lSPIRV-Tools-opt -lSPIRV-Tools -lpthread -lstdc++ + enabled libgme && { check_pkg_config libgme libgme gme/gme.h gme_new_emu || + require libgme gme/gme.h gme_new_emu -lgme -lstdc++; } + enabled libgsm && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do +diff -Naur a/libavfilter/glslang.cpp b/libavfilter/glslang.cpp +--- a/libavfilter/glslang.cpp 2023-04-12 19:01:50.000000000 +0100 ++++ b/libavfilter/glslang.cpp 2024-03-09 22:08:36.210161783 +0000 +@@ -17,6 +17,7 @@ + */ + + #include <pthread.h> ++#include <cassert> + + extern "C" { + #include "libavutil/mem.h" diff --git a/media-video/ffmpeg/files/ffmpeg-4.4.4-opencl-parallel-gmake-fix.patch b/media-video/ffmpeg/files/ffmpeg-4.4.4-opencl-parallel-gmake-fix.patch new file mode 100644 index 000000000000..9ac8ec79cf2e --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-4.4.4-opencl-parallel-gmake-fix.patch @@ -0,0 +1,12 @@ +Bug: https://bugs.gentoo.org/782553 + +--- ffmpeg-4.4.4/tools/cl2c.orig 2024-03-14 04:53:45.468507151 +0300 ++++ ffmpeg-4.4.4/tools/cl2c 2024-03-14 04:54:53.503086088 +0300 +@@ -24,6 +24,7 @@ + + name=$(basename "$input" | sed 's/.cl$//') + ++mkdir -p "$(dirname "$output")" + cat >$output <<EOF + // Generated from $input + const char *ff_opencl_source_$name = diff --git a/media-video/ffmpeg/files/ffmpeg-4.4.4-wint-conversion-vulkan.patch b/media-video/ffmpeg/files/ffmpeg-4.4.4-wint-conversion-vulkan.patch new file mode 100644 index 000000000000..f3766bb69f50 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-4.4.4-wint-conversion-vulkan.patch @@ -0,0 +1,30 @@ +https://bugs.gentoo.org/903752 +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=cc76e8340d28438c1ac56ee7dfd774d25e944264 + +(Dropped second bit for vulkan.h as has changed significantly in >4.4.) + +From cc76e8340d28438c1ac56ee7dfd774d25e944264 Mon Sep 17 00:00:00 2001 +From: =?utf8?q?Kacper=20Michaj=C5=82ow?= <kasper93@gmail.com> +Date: Thu, 2 Mar 2023 17:27:30 +0100 +Subject: [PATCH] lavu/vulkan: fix handle type for 32-bit targets +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf8 +Content-Transfer-Encoding: 8bit + +Fixes compilation with clang which errors out on Wint-conversion. + +Signed-off-by: Kacper MichajÅow <kasper93@gmail.com> +Signed-off-by: Martin Storsjö <martin@martin.st> +--- a/libavutil/hwcontext_vulkan.c ++++ b/libavutil/hwcontext_vulkan.c +@@ -1149,7 +1149,7 @@ static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd) + + av_freep(&cmd->queues); + av_freep(&cmd->bufs); +- cmd->pool = NULL; ++ cmd->pool = VK_NULL_HANDLE; + } + + static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd) + + diff --git a/media-video/ffmpeg/files/ffmpeg-5.0-backport-ranlib-build-fix.patch b/media-video/ffmpeg/files/ffmpeg-5.0-backport-ranlib-build-fix.patch new file mode 100644 index 000000000000..1c264f752099 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-5.0-backport-ranlib-build-fix.patch @@ -0,0 +1,59 @@ +From bc5ccea3b9d2c71929af6271bd8afe9b6cfab436 Mon Sep 17 00:00:00 2001 +From: Adrian Ratiu <adrian.ratiu@collabora.com> +Date: Mon, 14 Feb 2022 15:00:07 +0200 +Subject: [PATCH] configure: move ranlib -D test after setting defaults +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Backport [from master bc5ccea3b9d2c7] + +In Gentoo and ChromeOS we want to allow pure LLVM builds without +using GNU tools, so we block any unwanted mixed GNU/LLVM usages +(GNU tools are still kept around in our chroots for projects +like glibc which cannot yet be built otherwise). + +The default ${cross_prefix}${ranlib_default} points to GNU and +fails, so move the test a bit later - after the defaults are +set and the proper values get overriden - such that ffmpeg +configure calls the llvm-ranlib we desire. [1] + +[1] https://gitweb.gentoo.org/repo/gentoo.git/tree/media-video/ffmpeg/ffmpeg-4.4.1-r1.ebuild?id=7a34377e3277a6a0e2eedd40e90452a44c55f1e6#n477 + +Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com> +Signed-off-by: Martin Storsjö <martin@martin.st> +--- + configure | 10 +++++----- + 1 file changed, 5 insertions(+), 5 deletions(-) + +diff --git a/configure b/configure +index 7d22c2a345..82642deabe 100755 +--- a/configure ++++ b/configure +@@ -4403,11 +4403,7 @@ cc_default="${cross_prefix}${cc_default}" + cxx_default="${cross_prefix}${cxx_default}" + nm_default="${cross_prefix}${nm_default}" + pkg_config_default="${cross_prefix}${pkg_config_default}" +-if ${cross_prefix}${ranlib_default} 2>&1 | grep -q "\-D "; then +- ranlib_default="${cross_prefix}${ranlib_default} -D" +-else +- ranlib_default="${cross_prefix}${ranlib_default}" +-fi ++ranlib_default="${cross_prefix}${ranlib_default}" + strip_default="${cross_prefix}${strip_default}" + windres_default="${cross_prefix}${windres_default}" + +@@ -4440,6 +4436,10 @@ set_default arch cc cxx doxygen pkg_config ranlib strip sysinclude \ + enabled cross_compile || host_cc_default=$cc + set_default host_cc + ++if ${ranlib} 2>&1 | grep -q "\-D "; then ++ ranlib="${ranlib} -D" ++fi ++ + pkg_config_fail_message="" + if ! $pkg_config --version >/dev/null 2>&1; then + warn "$pkg_config not found, library detection may fail." +-- +2.35.1 + diff --git a/media-video/ffmpeg/files/ffmpeg-5.1.2-get_cabac_inline_x86-32-bit.patch b/media-video/ffmpeg/files/ffmpeg-5.1.2-get_cabac_inline_x86-32-bit.patch new file mode 100644 index 000000000000..40db3304b564 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-5.1.2-get_cabac_inline_x86-32-bit.patch @@ -0,0 +1,25 @@ +https://bugs.gentoo.org/901099 and partly https://bugs.gentoo.org/900937. + +Newer compilers may optimise such that < 7 registers are free on 32-bit x86 +and then we get an "invalid asm" error. This is https://bugs.gentoo.org/901099 +and https://trac.ffmpeg.org/ticket/8903. + +Making matters worse, GCC sometimes hangs on invalid asm, so this also +mitigates a hang with e.g. -O3 -march=znver1. See https://bugs.gentoo.org/900937 +and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109137. + +In future, we may want to adjust the definition of HAVE_7REGS to just exclude +32-bit x86, but that's a big sledgehammer, so let's avoid it for now until we have +a reply on the upstream ffmpeg bug. +--- a/libavcodec/x86/cabac.h ++++ b/libavcodec/x86/cabac.h +@@ -175,7 +175,7 @@ + + #endif /* BROKEN_RELOCATIONS */ + +-#if HAVE_7REGS && !BROKEN_COMPILER ++#if HAVE_7REGS && !BROKEN_COMPILER && !ARCH_X86_32 + #define get_cabac_inline get_cabac_inline_x86 + static + #if defined(_WIN32) && !defined(_WIN64) && defined(__clang__) + diff --git a/media-video/ffmpeg/files/ffmpeg-5.1.3-binutils-2.41.patch b/media-video/ffmpeg/files/ffmpeg-5.1.3-binutils-2.41.patch new file mode 100644 index 000000000000..7031d1f02ccf --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-5.1.3-binutils-2.41.patch @@ -0,0 +1,76 @@ +https://bugs.gentoo.org/911582 +https://trac.ffmpeg.org/ticket/10405 +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=25cd95a9dc3510c3cc0d7aad6f9d83f6a1078c7e +https://sourceware.org/PR30578 +https://gcc.gnu.org/PR108941 + +From 25cd95a9dc3510c3cc0d7aad6f9d83f6a1078c7e Mon Sep 17 00:00:00 2001 +From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net> +Date: Sun, 16 Jul 2023 18:18:02 +0300 +Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift + instructions within inline assembly + +Fixes assembling with binutil as >= 2.41 + +Signed-off-by: James Almer <jamrial@gmail.com> +(cherry picked from commit effadce6c756247ea8bae32dc13bb3e6f464f0eb) +--- a/libavcodec/x86/mathops.h ++++ b/libavcodec/x86/mathops.h +@@ -35,12 +35,20 @@ + static av_always_inline av_const int MULL(int a, int b, unsigned shift) + { + int rt, dummy; ++ if (__builtin_constant_p(shift)) + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) +- :"a"(a), "rm"(b), "ci"((uint8_t)shift) ++ :"a"(a), "rm"(b), "i"(shift & 0x1F) + ); ++ else ++ __asm__ ( ++ "imull %3 \n\t" ++ "shrdl %4, %%edx, %%eax \n\t" ++ :"=a"(rt), "=d"(dummy) ++ :"a"(a), "rm"(b), "c"((uint8_t)shift) ++ ); + return rt; + } + +@@ -113,19 +121,31 @@ __asm__ volatile(\ + // avoid +32 for shift optimization (gcc should do that ...) + #define NEG_SSR32 NEG_SSR32 + static inline int32_t NEG_SSR32( int32_t a, int8_t s){ ++ if (__builtin_constant_p(s)) + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) +- : "ic" ((uint8_t)(-s)) ++ : "i" (-s & 0x1F) + ); ++ else ++ __asm__ ("sarl %1, %0\n\t" ++ : "+r" (a) ++ : "c" ((uint8_t)(-s)) ++ ); + return a; + } + + #define NEG_USR32 NEG_USR32 + static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ ++ if (__builtin_constant_p(s)) + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) +- : "ic" ((uint8_t)(-s)) ++ : "i" (-s & 0x1F) + ); ++ else ++ __asm__ ("shrl %1, %0\n\t" ++ : "+r" (a) ++ : "c" ((uint8_t)(-s)) ++ ); + return a; + } + +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-6.0-DECLARE_ALIGNED.patch b/media-video/ffmpeg/files/ffmpeg-6.0-DECLARE_ALIGNED.patch new file mode 100644 index 000000000000..88af1e58458c --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0-DECLARE_ALIGNED.patch @@ -0,0 +1,29 @@ +From: Zhao Zhili <zhilizhao@tencent.com> +Date: Tue, 28 Feb 2023 18:23:00 +0000 (+0800) +Subject: avcodec/aacps_tablegen: fix build error after avutil bump +X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=commitdiff_plain;h=46970dd1555b3e50eee48ec95c893ee9a52f7fab + +avcodec/aacps_tablegen: fix build error after avutil bump + +Fix tickets #10225 + +DECLARE_ALIGNED has been moved to mem_internal.h. + +Signed-off-by: Zhao Zhili <zhilizhao@tencent.com> +Reviewed-by: Anton Khirnov <anton@khirnov.net> +(cherry picked from commit 814178f92647be2411516bbb82f48532373d2554) +--- + +diff --git a/libavcodec/aacps_tablegen.h b/libavcodec/aacps_tablegen.h +index 0ac4f68d68..5fdd7f0a9d 100644 +--- a/libavcodec/aacps_tablegen.h ++++ b/libavcodec/aacps_tablegen.h +@@ -34,7 +34,7 @@ + #include "libavutil/common.h" + #include "libavutil/libm.h" + #include "libavutil/mathematics.h" +-#include "libavutil/mem.h" ++#include "libavutil/mem_internal.h" + #define NR_ALLPASS_BANDS20 30 + #define NR_ALLPASS_BANDS34 50 + #define PS_AP_LINKS 3 diff --git a/media-video/ffmpeg/files/ffmpeg-6.0-binutils-2.41.patch b/media-video/ffmpeg/files/ffmpeg-6.0-binutils-2.41.patch new file mode 100644 index 000000000000..a06b9119666f --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0-binutils-2.41.patch @@ -0,0 +1,76 @@ +https://bugs.gentoo.org/911582 +https://trac.ffmpeg.org/ticket/10405 +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=cc703cf60759d9798f440a9417e4efa2fcbe2747 +https://sourceware.org/PR30578 +https://gcc.gnu.org/PR108941 + +From cc703cf60759d9798f440a9417e4efa2fcbe2747 Mon Sep 17 00:00:00 2001 +From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= <remi@remlab.net> +Date: Sun, 16 Jul 2023 18:18:02 +0300 +Subject: [PATCH] avcodec/x86/mathops: clip constants used with shift + instructions within inline assembly + +Fixes assembling with binutil as >= 2.41 + +Signed-off-by: James Almer <jamrial@gmail.com> +(cherry picked from commit effadce6c756247ea8bae32dc13bb3e6f464f0eb) +--- a/libavcodec/x86/mathops.h ++++ b/libavcodec/x86/mathops.h +@@ -35,12 +35,20 @@ + static av_always_inline av_const int MULL(int a, int b, unsigned shift) + { + int rt, dummy; ++ if (__builtin_constant_p(shift)) + __asm__ ( + "imull %3 \n\t" + "shrdl %4, %%edx, %%eax \n\t" + :"=a"(rt), "=d"(dummy) +- :"a"(a), "rm"(b), "ci"((uint8_t)shift) ++ :"a"(a), "rm"(b), "i"(shift & 0x1F) + ); ++ else ++ __asm__ ( ++ "imull %3 \n\t" ++ "shrdl %4, %%edx, %%eax \n\t" ++ :"=a"(rt), "=d"(dummy) ++ :"a"(a), "rm"(b), "c"((uint8_t)shift) ++ ); + return rt; + } + +@@ -113,19 +121,31 @@ __asm__ volatile(\ + // avoid +32 for shift optimization (gcc should do that ...) + #define NEG_SSR32 NEG_SSR32 + static inline int32_t NEG_SSR32( int32_t a, int8_t s){ ++ if (__builtin_constant_p(s)) + __asm__ ("sarl %1, %0\n\t" + : "+r" (a) +- : "ic" ((uint8_t)(-s)) ++ : "i" (-s & 0x1F) + ); ++ else ++ __asm__ ("sarl %1, %0\n\t" ++ : "+r" (a) ++ : "c" ((uint8_t)(-s)) ++ ); + return a; + } + + #define NEG_USR32 NEG_USR32 + static inline uint32_t NEG_USR32(uint32_t a, int8_t s){ ++ if (__builtin_constant_p(s)) + __asm__ ("shrl %1, %0\n\t" + : "+r" (a) +- : "ic" ((uint8_t)(-s)) ++ : "i" (-s & 0x1F) + ); ++ else ++ __asm__ ("shrl %1, %0\n\t" ++ : "+r" (a) ++ : "c" ((uint8_t)(-s)) ++ ); + return a; + } + +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-6.0-fix-lto-type-mismatch.patch b/media-video/ffmpeg/files/ffmpeg-6.0-fix-lto-type-mismatch.patch new file mode 100644 index 000000000000..9cc2dd732016 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0-fix-lto-type-mismatch.patch @@ -0,0 +1,41 @@ +https://ffmpeg.org//pipermail/ffmpeg-devel/2023-November/317055.html +https://bugs.gentoo.org/907484 + +From 408882a387f75ae57524073385b47d68339ec486 Mon Sep 17 00:00:00 2001 +From: Alfred Wingate <parona@protonmail.com> +Date: Tue, 14 Nov 2023 13:26:47 +0000 +Subject: [PATCH 1/1] swscale/x86/rgb_2_rgb: Add opaque pointer to missed + definitions of ff_nv12ToUV + +Opaque parameters were previously added to the original definition of +ff_nv12ToUV, leading to gcc noticing a type mismatch with -Wlto-type-mismatch. + +https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/f2de911818fbd7e73343803626b697fd0c968121 +https://bugs.gentoo.org/907484 + +Signed-off-by: Alfred Wingate <parona@protonmail.com> +Signed-off-by: Anton Khirnov <anton@khirnov.net> +--- a/libswscale/x86/rgb2rgb_template.c ++++ b/libswscale/x86/rgb2rgb_template.c +@@ -1823,7 +1823,8 @@ void RENAME(ff_nv12ToUV)(uint8_t *dstU, uint8_t *dstV, + const uint8_t *src1, + const uint8_t *src2, + int w, +- uint32_t *unused2); ++ uint32_t *unused2, ++ void *opq); + static void RENAME(deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t *dst2, + int width, int height, int srcStride, + int dst1Stride, int dst2Stride) +@@ -1831,7 +1832,7 @@ static void RENAME(deinterleaveBytes)(const uint8_t *src, uint8_t *dst1, uint8_t + int h; + + for (h = 0; h < height; h++) { +- RENAME(ff_nv12ToUV)(dst1, dst2, NULL, src, NULL, width, NULL); ++ RENAME(ff_nv12ToUV)(dst1, dst2, NULL, src, NULL, width, NULL, NULL); + src += srcStride; + dst1 += dst1Stride; + dst2 += dst2Stride; +-- +2.43.0 + diff --git a/media-video/ffmpeg/files/ffmpeg-6.0-libplacebo-remove-deprecated-field.patch b/media-video/ffmpeg/files/ffmpeg-6.0-libplacebo-remove-deprecated-field.patch new file mode 100644 index 000000000000..ca05c1c56ea4 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0-libplacebo-remove-deprecated-field.patch @@ -0,0 +1,103 @@ +Bug: https://bugs.gentoo.org/910406 + +Backports the following two commits: + https://github.com/FFmpeg/FFmpeg/commit/11eca6018c40f5ebe6af93cbc4b4dce447d8b3bc + https://github.com/FFmpeg/FFmpeg/commit/1231003c3c6d4839a9e838d06f8e16ee7690958f + +--- a/doc/filters.texi ++++ b/doc/filters.texi +@@ -16242,9 +16242,6 @@ + @item disable_builtin + Disable built-in GPU sampling (forces LUT). + +-@item force_icc_lut +-Force the use of a full ICC 3DLUT for gamut mapping. +- + @item disable_fbos + Forcibly disable FBOs, resulting in loss of almost all functionality, but + offering the maximum possible speed. +--- a/libavfilter/version_major.h ++++ b/libavfilter/version_major.h +@@ -35,4 +35,6 @@ + * the public API and may change, break or disappear at any time. + */ + ++#define FF_API_LIBPLACEBO_OPTS (LIBAVFILTER_VERSION_MAJOR < 10) ++ + #endif /* AVFILTER_VERSION_MAJOR_H */ +--- a/libavfilter/vf_libplacebo.c ++++ b/libavfilter/vf_libplacebo.c +@@ -97,7 +97,6 @@ + float polar_cutoff; + int disable_linear; + int disable_builtin; +- int force_icc_lut; + int force_dither; + int disable_fbos; + +@@ -132,11 +131,15 @@ + int inverse_tonemapping; + float crosstalk; + int tonemapping_lut_size; ++ ++#if FF_API_LIBPLACEBO_OPTS + /* for backwards compatibility */ + float desat_str; + float desat_exp; + int gamut_warning; + int gamut_clipping; ++ int force_icc_lut; ++#endif + + /* pl_dither_params */ + int dithering; +@@ -380,6 +383,7 @@ + pl_rect2df_aspect_set(&target.crop, aspect, s->pad_crop_ratio); + } + ++#if FF_API_LIBPLACEBO_OPTS + /* backwards compatibility with older API */ + if (!tonemapping_mode && (s->desat_str >= 0.0f || s->desat_exp >= 0.0f)) { + float str = s->desat_str < 0.0f ? 0.9f : s->desat_str; +@@ -397,6 +401,7 @@ + gamut_mode = PL_GAMUT_WARN; + if (s->gamut_clipping) + gamut_mode = PL_GAMUT_DESATURATE; ++#endif + + /* Update render params */ + params = (struct pl_render_params) { +@@ -458,7 +463,6 @@ + .polar_cutoff = s->polar_cutoff, + .disable_linear_scaling = s->disable_linear, + .disable_builtin_scalers = s->disable_builtin, +- .force_icc_lut = s->force_icc_lut, + .force_dither = s->force_dither, + .disable_fbos = s->disable_fbos, + }; +@@ -818,11 +822,14 @@ + { "inverse_tonemapping", "Inverse tone mapping (range expansion)", OFFSET(inverse_tonemapping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, + { "tonemapping_crosstalk", "Crosstalk factor for tone-mapping", OFFSET(crosstalk), AV_OPT_TYPE_FLOAT, {.dbl = 0.04}, 0.0, 0.30, DYNAMIC }, + { "tonemapping_lut_size", "Tone-mapping LUT size", OFFSET(tonemapping_lut_size), AV_OPT_TYPE_INT, {.i64 = 256}, 2, 1024, DYNAMIC }, ++ ++#if FF_API_LIBPLACEBO_OPTS + /* deprecated options for backwards compatibility, defaulting to -1 to not override the new defaults */ + { "desaturation_strength", "Desaturation strength", OFFSET(desat_str), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 1.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, + { "desaturation_exponent", "Desaturation exponent", OFFSET(desat_exp), AV_OPT_TYPE_FLOAT, {.dbl = -1.0}, -1.0, 10.0, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, + { "gamut_warning", "Highlight out-of-gamut colors", OFFSET(gamut_warning), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, + { "gamut_clipping", "Enable colorimetric gamut clipping", OFFSET(gamut_clipping), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, ++#endif + + { "dithering", "Dither method to use", OFFSET(dithering), AV_OPT_TYPE_INT, {.i64 = PL_DITHER_BLUE_NOISE}, -1, PL_DITHER_METHOD_COUNT - 1, DYNAMIC, "dither" }, + { "none", "Disable dithering", 0, AV_OPT_TYPE_CONST, {.i64 = -1}, 0, 0, STATIC, "dither" }, +@@ -847,7 +854,9 @@ + { "polar_cutoff", "Polar LUT cutoff", OFFSET(polar_cutoff), AV_OPT_TYPE_FLOAT, {.dbl = 0}, 0.0, 1.0, DYNAMIC }, + { "disable_linear", "Disable linear scaling", OFFSET(disable_linear), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, + { "disable_builtin", "Disable built-in scalers", OFFSET(disable_builtin), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, +- { "force_icc_lut", "Force the use of a full ICC 3DLUT for color mapping", OFFSET(force_icc_lut), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, ++#if FF_API_LIBPLACEBO_OPTS ++ { "force_icc_lut", "Deprecated, does nothing", OFFSET(force_icc_lut), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC | AV_OPT_FLAG_DEPRECATED }, ++#endif + { "force_dither", "Force dithering", OFFSET(force_dither), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, + { "disable_fbos", "Force-disable FBOs", OFFSET(disable_fbos), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, DYNAMIC }, + { NULL }, diff --git a/media-video/ffmpeg/files/ffmpeg-6.0-wint-conversion-vulkan.patch b/media-video/ffmpeg/files/ffmpeg-6.0-wint-conversion-vulkan.patch new file mode 100644 index 000000000000..2c71a189329a --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0-wint-conversion-vulkan.patch @@ -0,0 +1,43 @@ +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=58f18df430d48e47a82c5e740d6e63a50c97d75f + +From 58f18df430d48e47a82c5e740d6e63a50c97d75f Mon Sep 17 00:00:00 2001 +From: =?utf8?q?Kacper=20Michaj=C5=82ow?= <kasper93@gmail.com> +Date: Thu, 2 Mar 2023 17:27:30 +0100 +Subject: [PATCH] lavu/vulkan: fix handle type for 32-bit targets +MIME-Version: 1.0 +Content-Type: text/plain; charset=utf8 +Content-Transfer-Encoding: 8bit + +Fixes compilation with clang which errors out on Wint-conversion. + +Signed-off-by: Kacper MichajÅow <kasper93@gmail.com> +Signed-off-by: Martin Storsjö <martin@martin.st> +(cherry picked from commit cc76e8340d28438c1ac56ee7dfd774d25e944264) +Signed-off-by: Martin Storsjö <martin@martin.st> +--- a/libavutil/hwcontext_vulkan.c ++++ b/libavutil/hwcontext_vulkan.c +@@ -1149,7 +1149,7 @@ static void free_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd) + + av_freep(&cmd->queues); + av_freep(&cmd->bufs); +- cmd->pool = NULL; ++ cmd->pool = VK_NULL_HANDLE; + } + + static VkCommandBuffer get_buf_exec_ctx(AVHWFramesContext *hwfc, VulkanExecCtx *cmd) +--- a/libavutil/vulkan.h ++++ b/libavutil/vulkan.h +@@ -122,7 +122,11 @@ typedef struct FFVulkanPipeline { + VkDescriptorSetLayout *desc_layout; + VkDescriptorPool desc_pool; + VkDescriptorSet *desc_set; ++#if VK_USE_64_BIT_PTR_DEFINES == 1 + void **desc_staging; ++#else ++ uint64_t *desc_staging; ++#endif + VkDescriptorSetLayoutBinding **desc_binding; + VkDescriptorUpdateTemplate *desc_template; + int *desc_set_initialized; +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-6.0.1-alignment.patch b/media-video/ffmpeg/files/ffmpeg-6.0.1-alignment.patch new file mode 100644 index 000000000000..256feab8aea2 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0.1-alignment.patch @@ -0,0 +1,114 @@ +https://trac.ffmpeg.org/ticket/10549 +https://bugs.gentoo.org/915384 +https://git.videolan.org/?p=ffmpeg.git;a=patch;h=7945d30e91b96d2f4f5b612048169087d214d41e + +From 7945d30e91b96d2f4f5b612048169087d214d41e Mon Sep 17 00:00:00 2001 +From: Timo Rothenpieler <timo@rothenpieler.org> +Date: Sun, 3 Dec 2023 21:01:50 +0100 +Subject: [PATCH] avutil/mem: limit alignment to maximum simd align + +FFmpeg has instances of DECLARE_ALIGNED(32, ...) in a lot of structs, +which then end up heap-allocated. +By declaring any variable in a struct, or tree of structs, to be 32 byte +aligned, it allows the compiler to safely assume the entire struct +itself is also 32 byte aligned. + +This might make the compiler emit code which straight up crashes or +misbehaves in other ways, and at least in one instances is now +documented to actually do (see ticket 10549 on trac). +The issue there is that an unrelated variable in SingleChannelElement is +declared to have an alignment of 32 bytes. So if the compiler does a copy +in decode_cpe() with avx instructions, but ffmpeg is built with +--disable-avx, this results in a crash, since the memory is only 16 byte +aligned. + +Mind you, even if the compiler does not emit avx instructions, the code +is still invalid and could misbehave. It just happens not to. Declaring +any variable in a struct with a 32 byte alignment promises 32 byte +alignment of the whole struct to the compiler. + +This patch limits the maximum alignment to the maximum possible simd +alignment according to configure. +While not perfect, it at the very least gets rid of a lot of UB, by +matching up the maximum DECLARE_ALIGNED value with the alignment of heap +allocations done by lavu. +--- + libavutil/mem.c | 2 +- + libavutil/mem_internal.h | 33 ++++++++++++++++++++++++++++----- + 2 files changed, 29 insertions(+), 6 deletions(-) + +diff --git a/libavutil/mem.c b/libavutil/mem.c +index 36b8940a0c..62163b4cb3 100644 +--- a/libavutil/mem.c ++++ b/libavutil/mem.c +@@ -62,7 +62,7 @@ void free(void *ptr); + + #endif /* MALLOC_PREFIX */ + +-#define ALIGN (HAVE_AVX512 ? 64 : (HAVE_AVX ? 32 : 16)) ++#define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : (HAVE_SIMD_ALIGN_32 ? 32 : 16)) + + /* NOTE: if you want to override these functions with your own + * implementations (not recommended) you have to link libav* as +diff --git a/libavutil/mem_internal.h b/libavutil/mem_internal.h +index 2448c606f1..b1d89a0605 100644 +--- a/libavutil/mem_internal.h ++++ b/libavutil/mem_internal.h +@@ -76,27 +76,50 @@ + */ + + #if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) +- #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v ++ #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v + #elif defined(__DJGPP__) +- #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v ++ #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v + #elif defined(__GNUC__) || defined(__clang__) +- #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v ++ #define DECLARE_ALIGNED_T(n,t,v) t __attribute__ ((aligned (n))) v + #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v + #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v + #elif defined(_MSC_VER) +- #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v ++ #define DECLARE_ALIGNED_T(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v + #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v + #else +- #define DECLARE_ALIGNED(n,t,v) t v ++ #define DECLARE_ALIGNED_T(n,t,v) t v + #define DECLARE_ASM_ALIGNED(n,t,v) t v + #define DECLARE_ASM_CONST(n,t,v) static const t v + #endif + ++#if HAVE_SIMD_ALIGN_64 ++ #define ALIGN_64 64 ++ #define ALIGN_32 32 ++#elif HAVE_SIMD_ALIGN_32 ++ #define ALIGN_64 32 ++ #define ALIGN_32 32 ++#else ++ #define ALIGN_64 16 ++ #define ALIGN_32 16 ++#endif ++ ++#define DECLARE_ALIGNED(n,t,v) DECLARE_ALIGNED_V(n,t,v) ++ ++// Macro needs to be double-wrapped in order to expand ++// possible other macros being passed for n. ++#define DECLARE_ALIGNED_V(n,t,v) DECLARE_ALIGNED_##n(t,v) ++ ++#define DECLARE_ALIGNED_4(t,v) DECLARE_ALIGNED_T( 4, t, v) ++#define DECLARE_ALIGNED_8(t,v) DECLARE_ALIGNED_T( 8, t, v) ++#define DECLARE_ALIGNED_16(t,v) DECLARE_ALIGNED_T( 16, t, v) ++#define DECLARE_ALIGNED_32(t,v) DECLARE_ALIGNED_T(ALIGN_32, t, v) ++#define DECLARE_ALIGNED_64(t,v) DECLARE_ALIGNED_T(ALIGN_64, t, v) ++ + // Some broken preprocessors need a second expansion + // to be forced to tokenize __VA_ARGS__ + #define E1(x) x +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch b/media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch new file mode 100644 index 000000000000..10c216ec4c88 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch @@ -0,0 +1,112 @@ +https://bugs.gentoo.org/924431 +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=75b1a555a70c178a9166629e43ec2f6250219eb2 +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=ac06190a5a11f2b170e7719d769d7c0d65bff3e0 + +From 75b1a555a70c178a9166629e43ec2f6250219eb2 Mon Sep 17 00:00:00 2001 +From: Leo Izen <leo.izen@gmail.com> +Date: Sat, 8 Jul 2023 14:43:31 -0400 +Subject: [PATCH] avcodec/libjxldec: build against libjxl 0.9 + +Git master libjxl changed several function signatures, so this commit +adds some #ifdefs to handle the new signatures without breaking old +releases. Do note that old git master development versions of libjxl +will be broken, but no releases will be. + +Signed-off-by: Leo Izen <leo.izen@gmail.com> +--- a/libavcodec/libjxldec.c ++++ b/libavcodec/libjxldec.c +@@ -210,14 +210,22 @@ static int libjxl_get_icc(AVCodecContext *avctx) + JxlDecoderStatus jret; + /* an ICC profile is present, and we can meaningfully get it, + * because the pixel data is not XYB-encoded */ ++#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) + jret = JxlDecoderGetICCProfileSize(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &icc_len); ++#else ++ jret = JxlDecoderGetICCProfileSize(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, &icc_len); ++#endif + if (jret == JXL_DEC_SUCCESS && icc_len > 0) { + av_buffer_unref(&ctx->iccp); + ctx->iccp = av_buffer_alloc(icc_len); + if (!ctx->iccp) + return AVERROR(ENOMEM); ++#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) + jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, +- ctx->iccp->data, icc_len); ++ ctx->iccp->data, icc_len); ++#else ++ jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, ctx->iccp->data, icc_len); ++#endif + if (jret != JXL_DEC_SUCCESS) { + av_log(avctx, AV_LOG_WARNING, "Unable to obtain ICC Profile\n"); + av_buffer_unref(&ctx->iccp); +@@ -253,12 +261,21 @@ static int libjxl_color_encoding_event(AVCodecContext *avctx, AVFrame *frame) + /* set this flag if we need to fall back on wide gamut */ + int fallback = 0; + ++#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) + jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, NULL, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color); ++#else ++ jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color); ++#endif + if (jret == JXL_DEC_SUCCESS) { + /* enum values describe the colors of this image */ + jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color); + if (jret == JXL_DEC_SUCCESS) +- jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color); ++#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) ++ jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, &ctx->jxl_pixfmt, ++ JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color); ++#else ++ jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color); ++#endif + /* if we couldn't successfully request the pixel data space, we fall back on wide gamut */ + /* this code path is very unlikely to happen in practice */ + if (jret != JXL_DEC_SUCCESS) +-- +2.30.2 + +From ac06190a5a11f2b170e7719d769d7c0d65bff3e0 Mon Sep 17 00:00:00 2001 +From: Leo Izen <leo.izen@gmail.com> +Date: Tue, 23 Jan 2024 17:29:14 -0500 +Subject: [PATCH] avcodec/libjxl.h: include version.h + +This file has been exported since our minimum required version (0.7.0), +but it wasn't documented. Instead it was transitively included by +<jxl/decode.h> (but not jxl/encode.h), which ffmpeg relied on. + +libjxl broke its API in libjxl/libjxl@66b959239355aef5255 by removing +the transitive include of version.h, and they do not plan on adding +it back. Instead they are choosing to leave the API backwards- +incompatible with downstream callers written for some fairly recent +versions of their API. + +As a result, we include <jxl/version.h> to continue to build against +more recent versions of libjxl. The version macros removed are also +present in that file, so we no longer need to redefine them. + +Signed-off-by: Leo Izen <leo.izen@gmail.com> +--- a/libavcodec/libjxl.h ++++ b/libavcodec/libjxl.h +@@ -27,19 +27,8 @@ + #ifndef AVCODEC_LIBJXL_H + #define AVCODEC_LIBJXL_H + +-#include <jxl/decode.h> + #include <jxl/memory_manager.h> +- +-/* +- * libjxl version 0.7.0 and earlier doesn't contain these macros at all +- * so to detect version 0.7.0 versus 0.8.0 we need to define them ourselves +- */ +-#ifndef JPEGXL_COMPUTE_NUMERIC_VERSION +- #define JPEGXL_COMPUTE_NUMERIC_VERSION(major,minor,patch) ((major<<24) | (minor<<16) | (patch<<8) | 0) +-#endif +-#ifndef JPEGXL_NUMERIC_VERSION +- #define JPEGXL_NUMERIC_VERSION JPEGXL_COMPUTE_NUMERIC_VERSION(0, 7, 0) +-#endif ++#include <jxl/version.h> + + /** + * Transform threadcount in ffmpeg to one used by libjxl. +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-6.1-gcc-14.patch b/media-video/ffmpeg/files/ffmpeg-6.1-gcc-14.patch new file mode 100644 index 000000000000..0db7301f18d9 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.1-gcc-14.patch @@ -0,0 +1,13 @@ +diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c +index 29fc8bd648..1f85fac7f4 100644 +--- a/libavutil/hwcontext_vaapi.c ++++ b/libavutil/hwcontext_vaapi.c +@@ -1203,7 +1203,7 @@ static int vaapi_map_from_drm(AVHWFramesContext *src_fc, AVFrame *dst, + + if (!use_prime2 || vas != VA_STATUS_SUCCESS) { + int k; +- unsigned long buffer_handle; ++ uintptr_t buffer_handle; + VASurfaceAttribExternalBuffers buffer_desc; + VASurfaceAttrib buffer_attrs[2] = { + { diff --git a/media-video/ffmpeg/files/ffmpeg-6.1-opencl-parallel-gmake-fix.patch b/media-video/ffmpeg/files/ffmpeg-6.1-opencl-parallel-gmake-fix.patch new file mode 100644 index 000000000000..271a18999fb3 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.1-opencl-parallel-gmake-fix.patch @@ -0,0 +1,12 @@ +Bug: https://bugs.gentoo.org/782553 + +--- ffmpeg-6.1.1/tools/source2c.orig 2024-03-14 04:53:45.468507151 +0300 ++++ ffmpeg-6.1.1/tools/source2c 2024-03-14 04:54:53.503086088 +0300 +@@ -24,6 +24,7 @@ + + name=$(basename "$input" | sed 's/.cl$//') + ++mkdir -p "$(dirname "$output")" + cat >$output <<EOF + // Generated from $input + const char *ff_opencl_source_$name = diff --git a/media-video/ffmpeg/files/ffmpeg-6.1-wint-conversion.patch b/media-video/ffmpeg/files/ffmpeg-6.1-wint-conversion.patch new file mode 100644 index 000000000000..c95566117903 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.1-wint-conversion.patch @@ -0,0 +1,88 @@ +Sent upstream to the mailing list but stuck in moderation queue / not yet on archive. + +From 50f34826bcff90f393dfbc6c4e0c908556831d4d Mon Sep 17 00:00:00 2001 +From: Sam James <sam@gentoo.org> +Date: Wed, 13 Dec 2023 04:25:54 +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 <sam@gentoo.org> +--- 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); +--- 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; +--- 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 */ +--- 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; +--- 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) +-- +2.43.0 + diff --git a/media-video/ffmpeg/files/ffmpeg-6.1.1-memory-leak.patch b/media-video/ffmpeg/files/ffmpeg-6.1.1-memory-leak.patch new file mode 100644 index 000000000000..d02522b3a3a4 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.1.1-memory-leak.patch @@ -0,0 +1,129 @@ +https://bugs.gentoo.org/931059 +https://ffmpeg.org//pipermail/ffmpeg-devel/2024-May/326569.html +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=670c823406612697b394d4933e03d3e1a176474f +https://git.videolan.org/?p=ffmpeg.git;a=commit;h=1606aab99bd84f0040fb0fa6ccccb092941f01ec + +From 670c823406612697b394d4933e03d3e1a176474f Mon Sep 17 00:00:00 2001 +From: Paul B Mahol <onemda@gmail.com> +Date: Fri, 27 Oct 2023 14:26:50 +0200 +Subject: [PATCH] avfilter/buffersrc: switch to activate + +Fixes OOM when caller keeps adding frames into filtergraph +that reached EOF by other means, for example EOF is signalled +by other filter in filtergraph or by buffersink. + +(cherry picked from commit 84e400ae37b1e2849a3ead399ef86c808356cdd6) +--- a/libavfilter/buffersrc.c ++++ b/libavfilter/buffersrc.c +@@ -36,6 +36,7 @@ + #include "audio.h" + #include "avfilter.h" + #include "buffersrc.h" ++#include "filters.h" + #include "formats.h" + #include "internal.h" + #include "video.h" +@@ -194,7 +195,7 @@ FF_ENABLE_DEPRECATION_WARNINGS + if (!frame) + return av_buffersrc_close(ctx, s->last_pts, flags); + if (s->eof) +- return AVERROR(EINVAL); ++ return AVERROR_EOF; + + s->last_pts = frame->pts + frame->duration; + +@@ -484,21 +485,28 @@ static int config_props(AVFilterLink *link) + return 0; + } + +-static int request_frame(AVFilterLink *link) ++static int activate(AVFilterContext *ctx) + { +- BufferSourceContext *c = link->src->priv; ++ AVFilterLink *outlink = ctx->outputs[0]; ++ BufferSourceContext *c = ctx->priv; + +- if (c->eof) +- return AVERROR_EOF; ++ if (!c->eof && ff_outlink_get_status(outlink)) { ++ c->eof = 1; ++ return 0; ++ } ++ ++ if (c->eof) { ++ ff_outlink_set_status(outlink, AVERROR_EOF, c->last_pts); ++ return 0; ++ } + c->nb_failed_requests++; +- return AVERROR(EAGAIN); ++ return FFERROR_NOT_READY; + } + + static const AVFilterPad avfilter_vsrc_buffer_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_VIDEO, +- .request_frame = request_frame, + .config_props = config_props, + }, + }; +@@ -507,7 +515,7 @@ const AVFilter ff_vsrc_buffer = { + .name = "buffer", + .description = NULL_IF_CONFIG_SMALL("Buffer video frames, and make them accessible to the filterchain."), + .priv_size = sizeof(BufferSourceContext), +- ++ .activate = activate, + .init = init_video, + .uninit = uninit, + +@@ -521,7 +529,6 @@ static const AVFilterPad avfilter_asrc_abuffer_outputs[] = { + { + .name = "default", + .type = AVMEDIA_TYPE_AUDIO, +- .request_frame = request_frame, + .config_props = config_props, + }, + }; +@@ -530,7 +537,7 @@ const AVFilter ff_asrc_abuffer = { + .name = "abuffer", + .description = NULL_IF_CONFIG_SMALL("Buffer audio frames, and make them accessible to the filterchain."), + .priv_size = sizeof(BufferSourceContext), +- ++ .activate = activate, + .init = init_audio, + .uninit = uninit, + +-- +2.30.2 + +From 1606aab99bd84f0040fb0fa6ccccb092941f01ec Mon Sep 17 00:00:00 2001 +From: Paul B Mahol <onemda@gmail.com> +Date: Fri, 1 Dec 2023 16:59:07 +0100 +Subject: [PATCH] avfilter/avfilter: fix OOM case for default activate + +Fixes OOM when caller keeps adding frames into filtergraph +that reached EOF by other means, for example EOF is signalled +by other filter in filtergraph or by buffersink. + +(cherry picked from commit d9e41ead82263e96ebd14d4d88d6e7f858dd944c) +--- a/libavfilter/avfilter.c ++++ b/libavfilter/avfilter.c +@@ -1167,6 +1167,16 @@ static int ff_filter_activate_default(AVFilterContext *filter) + { + unsigned i; + ++ for (i = 0; i < filter->nb_outputs; i++) { ++ int ret = filter->outputs[i]->status_in; ++ ++ if (ret) { ++ for (int j = 0; j < filter->nb_inputs; j++) ++ ff_inlink_set_status(filter->inputs[j], ret); ++ return 0; ++ } ++ } ++ + for (i = 0; i < filter->nb_inputs; i++) { + if (samples_ready(filter->inputs[i], filter->inputs[i]->min_samples)) { + return ff_filter_frame_to_filter(filter->inputs[i]); +-- +2.30.2 diff --git a/media-video/ffmpeg/files/ffmpeg-6.1.1-vulkan-rename.patch b/media-video/ffmpeg/files/ffmpeg-6.1.1-vulkan-rename.patch new file mode 100644 index 000000000000..b564e3874485 --- /dev/null +++ b/media-video/ffmpeg/files/ffmpeg-6.1.1-vulkan-rename.patch @@ -0,0 +1,127 @@ +https://bugs.gentoo.org/928593 +https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/fef22c87ada4517441701e6e61e062c9f4399c8e + +From fef22c87ada4517441701e6e61e062c9f4399c8e Mon Sep 17 00:00:00 2001 +From: =?utf8?q?Jan=20Ekstr=C3=B6m?= <jeebjp@gmail.com> +Date: Wed, 14 Feb 2024 22:40:54 +0200 +Subject: [PATCH] {avcodec,tests}: rename the bundled Mesa AV1 vulkan video + headers + +This together with adjusting the inclusion define allows for the +build to not fail with latest Vulkan-Headers that contain the +stabilized Vulkan AV1 decoding definitions. + +Compilation fails currently as the AV1 header is getting included +via hwcontext_vulkan.h -> <vulkan/vulkan.h> -> vulkan_core.h, which +finally includes vk_video/vulkan_video_codec_av1std.h and the decode +header, leading to the bundled header to never defining anything +due to the inclusion define being the same. + +This fix is imperfect, as it leads to additional re-definition +warnings for things such as +VK_STD_VULKAN_VIDEO_CODEC_AV1_DECODE_SPEC_VERSION. , but it is +not clear how to otherwise have the bundled version trump the +actually standardized one for a short-term compilation fix. + +(cherry picked from commit e06ce6d2b45edac4a2df04f304e18d4727417d24) +--- + libavcodec/Makefile | 4 ++-- + libavcodec/vulkan_video.h | 4 ++-- + ...v1std_decode.h => vulkan_video_codec_av1std_decode_mesa.h} | 4 ++-- + ..._video_codec_av1std.h => vulkan_video_codec_av1std_mesa.h} | 4 ++-- + tests/ref/fate/source | 4 ++-- + 5 files changed, 10 insertions(+), 10 deletions(-) + rename libavcodec/{vulkan_video_codec_av1std_decode.h => vulkan_video_codec_av1std_decode_mesa.h} (89%) + rename libavcodec/{vulkan_video_codec_av1std.h => vulkan_video_codec_av1std_mesa.h} (99%) + +diff --git a/libavcodec/Makefile b/libavcodec/Makefile +index ec57e53e30..eb25707ef5 100644 +--- a/libavcodec/Makefile ++++ b/libavcodec/Makefile +@@ -1284,7 +1284,7 @@ SKIPHEADERS += %_tablegen.h \ + aacenc_quantization.h \ + aacenc_quantization_misc.h \ + bitstream_template.h \ +- vulkan_video_codec_av1std.h \ ++ vulkan_video_codec_av1std_mesa.h \ + $(ARCH)/vpx_arith.h \ + + SKIPHEADERS-$(CONFIG_AMF) += amfenc.h +@@ -1306,7 +1306,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 vulkan_video_codec_av1std_decode_mesa.h + SKIPHEADERS-$(CONFIG_V4L2_M2M) += v4l2_buffers.h v4l2_context.h v4l2_m2m.h + SKIPHEADERS-$(CONFIG_ZLIB) += zlib_wrapper.h + +diff --git a/libavcodec/vulkan_video.h b/libavcodec/vulkan_video.h +index b28e3fe0bd..51f44dd543 100644 +--- a/libavcodec/vulkan_video.h ++++ b/libavcodec/vulkan_video.h +@@ -23,8 +23,8 @@ + #include "vulkan.h" + + #include <vk_video/vulkan_video_codecs_common.h> +-#include "vulkan_video_codec_av1std.h" +-#include "vulkan_video_codec_av1std_decode.h" ++#include "vulkan_video_codec_av1std_mesa.h" ++#include "vulkan_video_codec_av1std_decode_mesa.h" + + #define CODEC_VER_MAJ(ver) (ver >> 22) + #define CODEC_VER_MIN(ver) ((ver >> 12) & ((1 << 10) - 1)) +diff --git a/libavcodec/vulkan_video_codec_av1std_decode.h b/libavcodec/vulkan_video_codec_av1std_decode_mesa.h +similarity index 89% +rename from libavcodec/vulkan_video_codec_av1std_decode.h +rename to libavcodec/vulkan_video_codec_av1std_decode_mesa.h +index a697c00593..e2f37b4e6e 100644 +--- a/libavcodec/vulkan_video_codec_av1std_decode.h ++++ b/libavcodec/vulkan_video_codec_av1std_decode_mesa.h +@@ -14,8 +14,8 @@ + * limitations under the License. + */ + +-#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ +-#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_H_ 1 ++#ifndef VULKAN_VIDEO_CODEC_AV1STD_DECODE_MESA_H_ ++#define VULKAN_VIDEO_CODEC_AV1STD_DECODE_MESA_H_ 1 + + /* + ** This header is NOT YET generated from the Khronos Vulkan XML API Registry. +diff --git a/libavcodec/vulkan_video_codec_av1std.h b/libavcodec/vulkan_video_codec_av1std_mesa.h +similarity index 99% +rename from libavcodec/vulkan_video_codec_av1std.h +rename to libavcodec/vulkan_video_codec_av1std_mesa.h +index c46236c457..c91589eee2 100644 +--- a/libavcodec/vulkan_video_codec_av1std.h ++++ b/libavcodec/vulkan_video_codec_av1std_mesa.h +@@ -14,8 +14,8 @@ + * limitations under the License. + */ + +-#ifndef VULKAN_VIDEO_CODEC_AV1STD_H_ +-#define VULKAN_VIDEO_CODEC_AV1STD_H_ 1 ++#ifndef VULKAN_VIDEO_CODEC_AV1STD_MESA_H_ ++#define VULKAN_VIDEO_CODEC_AV1STD_MESA_H_ 1 + + /* + ** This header is NOT YET generated from the Khronos Vulkan XML API Registry. +diff --git a/tests/ref/fate/source b/tests/ref/fate/source +index c575789dd5..8bb58b61f1 100644 +--- a/tests/ref/fate/source ++++ b/tests/ref/fate/source +@@ -23,8 +23,8 @@ compat/djgpp/math.h + compat/float/float.h + compat/float/limits.h + libavcodec/bitstream_template.h +-libavcodec/vulkan_video_codec_av1std.h +-libavcodec/vulkan_video_codec_av1std_decode.h ++libavcodec/vulkan_video_codec_av1std_decode_mesa.h ++libavcodec/vulkan_video_codec_av1std_mesa.h + tools/decode_simple.h + Use of av_clip() where av_clip_uintp2() could be used: + Use of av_clip() where av_clip_intp2() could be used: +-- +2.25.1 + diff --git a/media-video/ffmpeg/files/vmaf-models-default-path.patch b/media-video/ffmpeg/files/vmaf-models-default-path.patch new file mode 100644 index 000000000000..a9777e94b7aa --- /dev/null +++ b/media-video/ffmpeg/files/vmaf-models-default-path.patch @@ -0,0 +1,13 @@ +Put default path of models to /usr/share/vmaf/model + +--- a/libavfilter/vf_libvmaf.c ++++ b/libavfilter/vf_libvmaf.c +@@ -72,7 +72,7 @@ typedef struct LIBVMAFContext { + #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM + + static const AVOption libvmaf_options[] = { +- {"model_path", "Set the model to be used for computing vmaf.", OFFSET(model_path), AV_OPT_TYPE_STRING, {.str="/usr/local/share/model/vmaf_v0.6.1.pkl"}, 0, 1, FLAGS}, ++ {"model_path", "Set the model to be used for computing vmaf.", OFFSET(model_path), AV_OPT_TYPE_STRING, {.str="/usr/share/vmaf/model/vmaf_v0.6.1.json"}, 0, 1, FLAGS}, + {"log_path", "Set the file path to be used to store logs.", OFFSET(log_path), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, + {"log_fmt", "Set the format of the log (xml or json).", OFFSET(log_fmt), AV_OPT_TYPE_STRING, {.str=NULL}, 0, 1, FLAGS}, + {"enable_transform", "Enables transform for computing vmaf.", OFFSET(enable_transform), AV_OPT_TYPE_BOOL, {.i64=0}, 0, 1, FLAGS}, |