diff --git a/build-scripts/ffmpeg.build b/build-scripts/ffmpeg.build index 1533b69..fd2b0a1 100644 --- a/build-scripts/ffmpeg.build +++ b/build-scripts/ffmpeg.build @@ -1,7 +1,7 @@ #! /bin/bash # FFmpeg -# Source: https://ffmpeg.org/releases/ffmpeg-4.4.1.tar.xz +# Source: https://ffmpeg.org/releases/ffmpeg-6.0.1.tar.xz # # $BUILD = Directory to temporarily install # $PKGS = Directory to store built packages @@ -18,15 +18,22 @@ # Optional: librtmp, libssh, OpenAL, OpenCore AMR, Schroedinger, TwoLAME, # OPtional: vo-aaenc, vo-amrwbenc, and ZVBI -patch -Np1 -i ../patches/ffmpeg-alpine/0001-ffbuild-libversion.sh-add-shebang.patch -patch -Np1 -i ../patches/ffmpeg-alpine/0001-libavutil-clean-up-unused-FF_SYMVER-macro.patch -#patch -Np1 -i ../patches/ffmpeg-alpine/CVE-2021-33815.patch +# Apply patches from Chimera Linux +patch -Np1 -i ../patches/ffmpeg-chimera/clang-ppc4xx.patch +patch -Np1 -i ../patches/ffmpeg-chimera/libplacebo6-1.patch +patch -Np1 -i ../patches/ffmpeg-chimera/libplacebo6-2.patch +patch -Np1 -i ../patches/ffmpeg-chimera/riscv-asm.patch +patch -Np1 -i ../patches/ffmpeg-chimera/thin-lto.patch +patch -Np1 -i ../patches/ffmpeg-chimera/v4l-ioctl.patch case $(uname -m) in i686) export ECONF="--disable-asm --enable-libaom" ;; x86_64|aarch64) export ECONF="--enable-libaom" ;; esac && -sed -i 's/-lflite"/-lflite -lasound"/' configure && + +# If using LLVm instead of GCC, add these flags: +export XARGS="--cc=clang --cxx=clang++ " + ./configure --prefix=/usr \ --enable-gpl \ --enable-version3 \ @@ -34,7 +41,6 @@ sed -i 's/-lflite"/-lflite -lasound"/' configure && --disable-static \ --enable-shared \ --disable-debug \ - --enable-avresample \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ @@ -45,8 +51,10 @@ sed -i 's/-lflite"/-lflite -lasound"/' configure && --enable-libvpx \ --enable-libx264 \ --enable-libx265 \ - --docdir=/usr/share/doc/ffmpeg-4.4 $ECONF && + --docdir=/usr/share/doc/ffmpeg-6.0.1 $ECONF $XARGS && read -p "Compile?" && make -j2 && +unset ECONF XARGS + gcc tools/qt-faststart.c -o tools/qt-faststart && sudo -S make DESTDIR=$BUILD install && @@ -80,7 +88,7 @@ ffmpeg: ffmpeg home: http://ffmpeg.org/ ffmpeg: EOF sudo -S mv -v /tmp/slack-desc install/ && -sudo -S makepkg -l y -c n $PKGS/ffmpeg-4.4.1-$(uname -m)-mlfs.txz && +sudo -S makepkg -l y -c n $PKGS/ffmpeg-6.0.1-$PSUFFIX && cd /BMAN cat > /tmp/slack-desc << "EOF" ffmpeg-doc: Manuals for ffmpeg @@ -92,6 +100,6 @@ ffmpeg-doc: http://ffmpeg.org/ ffmpeg-doc: EOF sudo -S mv -v /tmp/slack-desc install/ && -sudo -S makepkg -l y -c n $PKGS/ffmpeg-doc-4.4.1-noarch-mlfs.txz && +sudo -S makepkg -l y -c n $PKGS/ffmpeg-doc-6.0.1-$NOPSUFFIX && sudo -S rm -rf /BMAN/* sudo -S rm -rf ${BUILD}/* diff --git a/patches/ffmpeg-chimera/clang-ppc4xx.patch b/patches/ffmpeg-chimera/clang-ppc4xx.patch new file mode 100644 index 0000000..135d921 --- /dev/null +++ b/patches/ffmpeg-chimera/clang-ppc4xx.patch @@ -0,0 +1,13 @@ +The ppc4xx support breaks with our toolchain and we don't want it anyway. + +--- a/configure ++++ b/configure +@@ -5939,7 +5939,7 @@ elif enabled ppc; then + + check_inline_asm dcbzl '"dcbzl 0, %0" :: "r"(0)' + check_inline_asm ibm_asm '"add 0, 0, 0"' +- check_inline_asm ppc4xx '"maclhw r10, r11, r12"' ++ disable ppc4xx + check_inline_asm xform_asm '"lwzx %1, %y0" :: "Z"(*(int*)0), "r"(0)' + + if enabled altivec; then diff --git a/patches/ffmpeg-chimera/libplacebo6-1.patch b/patches/ffmpeg-chimera/libplacebo6-1.patch new file mode 100644 index 0000000..cc3acc9 --- /dev/null +++ b/patches/ffmpeg-chimera/libplacebo6-1.patch @@ -0,0 +1,75 @@ +Patch-Source: https://github.com/FFmpeg/FFmpeg/commit/11eca6018c40f5ebe6af93cbc4b4dce447d8b3bc +-- +From 11eca6018c40f5ebe6af93cbc4b4dce447d8b3bc Mon Sep 17 00:00:00 2001 +From: Niklas Haas +Date: Mon, 13 Mar 2023 15:10:26 +0100 +Subject: [PATCH] avfilter/vf_libplacebo: wrap deprecated opts in FF_API define + +Signed-off-by: Niklas Haas +Signed-off-by: James Almer +--- + libavfilter/version_major.h | 2 ++ + libavfilter/vf_libplacebo.c | 8 ++++++++ + 2 files changed, 10 insertions(+) + +diff --git a/libavfilter/version_major.h b/libavfilter/version_major.h +index 899dfdb27dba..1decc4012ee0 100644 +--- 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 */ +diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c +index 7cd495de2619..d75723289069 100644 +--- a/libavfilter/vf_libplacebo.c ++++ b/libavfilter/vf_libplacebo.c +@@ -132,11 +132,14 @@ typedef struct LibplaceboContext { + 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; ++#endif + + /* pl_dither_params */ + int dithering; +@@ -380,6 +383,7 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out, AVFrame *in) + 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 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out, AVFrame *in) + gamut_mode = PL_GAMUT_WARN; + if (s->gamut_clipping) + gamut_mode = PL_GAMUT_DESATURATE; ++#endif + + /* Update render params */ + params = (struct pl_render_params) { +@@ -818,11 +823,14 @@ static const AVOption libplacebo_options[] = { + { "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" }, diff --git a/patches/ffmpeg-chimera/libplacebo6-2.patch b/patches/ffmpeg-chimera/libplacebo6-2.patch new file mode 100644 index 0000000..a28388d --- /dev/null +++ b/patches/ffmpeg-chimera/libplacebo6-2.patch @@ -0,0 +1,72 @@ +Patch-Source: https://github.com/FFmpeg/FFmpeg/commit/1231003c3c6d4839a9e838d06f8e16ee7690958f +-- +From 1231003c3c6d4839a9e838d06f8e16ee7690958f Mon Sep 17 00:00:00 2001 +From: Niklas Haas +Date: Mon, 13 Mar 2023 14:33:16 +0100 +Subject: [PATCH] avfilter/vf_libplacebo: remove deprecated field + +This has not been functional since a year ago, including in our current +minimum dependency of libplacebo (v4.192.0). It also causes build errors +against libplacebo v6, so it needs to be removed from the code. We can +keep the option around for now, but it should also be removed soon. + +Signed-off-by: Niklas Haas +Signed-off-by: James Almer +--- + doc/filters.texi | 3 --- + libavfilter/vf_libplacebo.c | 7 ++++--- + 2 files changed, 4 insertions(+), 6 deletions(-) + +diff --git a/doc/filters.texi b/doc/filters.texi +index 7a7b2ba4e79e..77b594f69cb1 100644 +--- a/doc/filters.texi ++++ b/doc/filters.texi +@@ -16242,9 +16242,6 @@ Disable linear light scaling. + @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. +diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c +index d75723289069..757dc519e9ad 100644 +--- a/libavfilter/vf_libplacebo.c ++++ b/libavfilter/vf_libplacebo.c +@@ -97,7 +97,6 @@ typedef struct LibplaceboContext { + float polar_cutoff; + int disable_linear; + int disable_builtin; +- int force_icc_lut; + int force_dither; + int disable_fbos; + +@@ -139,6 +138,7 @@ typedef struct LibplaceboContext { + float desat_exp; + int gamut_warning; + int gamut_clipping; ++ int force_icc_lut; + #endif + + /* pl_dither_params */ +@@ -463,7 +463,6 @@ static int process_frames(AVFilterContext *avctx, AVFrame *out, AVFrame *in) + .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, + }; +@@ -855,7 +854,9 @@ static const AVOption libplacebo_options[] = { + { "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/patches/ffmpeg-chimera/riscv-asm.patch b/patches/ffmpeg-chimera/riscv-asm.patch new file mode 100644 index 0000000..e3a4357 --- /dev/null +++ b/patches/ffmpeg-chimera/riscv-asm.patch @@ -0,0 +1,32 @@ +commit 0a96729183a001e55fc3ba4d7a5cfa48cdd6ceb9 +Author: q66 +Date: Fri Mar 17 01:37:03 2023 +0000 + + disable riscv asm using unratified exts + +diff --git a/libavcodec/bswapdsp.c b/libavcodec/bswapdsp.c +index f0ea2b5..ef74c92 100644 +--- a/libavcodec/bswapdsp.c ++++ b/libavcodec/bswapdsp.c +@@ -51,7 +51,7 @@ av_cold void ff_bswapdsp_init(BswapDSPContext *c) + c->bswap_buf = bswap_buf; + c->bswap16_buf = bswap16_buf; + +-#if ARCH_RISCV ++#if 0 + ff_bswapdsp_init_riscv(c); + #elif ARCH_X86 + ff_bswapdsp_init_x86(c); +diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile +index 965942f..85a3b04 100644 +--- a/libavcodec/riscv/Makefile ++++ b/libavcodec/riscv/Makefile +@@ -5,8 +5,6 @@ RVV-OBJS-$(CONFIG_ALAC_DECODER) += riscv/alacdsp_rvv.o + OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_init.o \ + riscv/audiodsp_rvf.o + RVV-OBJS-$(CONFIG_AUDIODSP) += riscv/audiodsp_rvv.o +-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_init.o \ +- riscv/bswapdsp_rvb.o + RVV-OBJS-$(CONFIG_BSWAPDSP) += riscv/bswapdsp_rvv.o + OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_init.o + RVV-OBJS-$(CONFIG_FMTCONVERT) += riscv/fmtconvert_rvv.o diff --git a/patches/ffmpeg-chimera/thin-lto.patch b/patches/ffmpeg-chimera/thin-lto.patch new file mode 100644 index 0000000..8e7cd37 --- /dev/null +++ b/patches/ffmpeg-chimera/thin-lto.patch @@ -0,0 +1,18 @@ +Just passing -flto=thin in CFLAGS is not enough, as +--enable-lto is also needed for configure (it alters +the build to be LTO compatible) but that results in +ffmpeg passing its own -flto afterwards. + +--- a/configure ++++ b/configure +@@ -6931,8 +6931,8 @@ check_optflags -fno-signed-zeros + + if enabled lto; then + test "$cc_type" != "$ld_type" && die "LTO requires same compiler and linker" +- check_cflags -flto +- check_ldflags -flto $cpuflags ++ check_cflags -flto=thin ++ check_ldflags -flto=thin $cpuflags + disable inline_asm_direct_symbol_refs + fi + diff --git a/patches/ffmpeg-chimera/v4l-ioctl.patch b/patches/ffmpeg-chimera/v4l-ioctl.patch new file mode 100644 index 0000000..1419e6a --- /dev/null +++ b/patches/ffmpeg-chimera/v4l-ioctl.patch @@ -0,0 +1,49 @@ +commit 8a48dfff8f68f075d7277b21589de175b76493c1 +Author: Daniel Kolesa +Date: Sat Jun 17 15:33:56 2023 +0200 + + unify ioctl interface with v4l2 on musl + +diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c +index 5e85d1a..ee4d362 100644 +--- a/libavdevice/v4l2.c ++++ b/libavdevice/v4l2.c +@@ -31,6 +31,7 @@ + */ + + #include ++#include + + #include "libavutil/avassert.h" + #include "libavutil/avstring.h" +@@ -107,11 +108,7 @@ struct video_data { + int (*open_f)(const char *file, int oflag, ...); + int (*close_f)(int fd); + int (*dup_f)(int fd); +-#ifdef __GLIBC__ + int (*ioctl_f)(int fd, unsigned long int request, ...); +-#else +- int (*ioctl_f)(int fd, int request, ...); +-#endif + ssize_t (*read_f)(int fd, void *buffer, size_t n); + void *(*mmap_f)(void *start, size_t length, int prot, int flags, int fd, int64_t offset); + int (*munmap_f)(void *_start, size_t length); +@@ -122,6 +119,18 @@ struct buff_data { + int index; + }; + ++/* ffs */ ++static int ioctl_wrapper(int fd, unsigned long request, ...) ++{ ++ void *arg; ++ va_list ap; ++ va_start(ap, request); ++ arg = va_arg(ap, void *); ++ va_end(ap); ++ return ioctl(fd, request, arg); ++} ++#define ioctl ioctl_wrapper ++ + static int device_open(AVFormatContext *ctx, const char* device_path) + { + struct video_data *s = ctx->priv_data;